Commit 59b7d34b authored by Alexandre Julliard's avatar Alexandre Julliard

Replace empty window rect checks by a new X11DRV_is_window_rect_mapped

function so that we can reuse that support for off-screen windows.
parent 84af686a
......@@ -151,6 +151,24 @@ inline static BOOL is_client_window_mapped( WND *win )
/***********************************************************************
* X11DRV_is_window_rect_mapped
*
* Check if the X whole window should be mapped based on its rectangle
*/
BOOL X11DRV_is_window_rect_mapped( const RECT *rect )
{
/* don't map if rect is empty */
if (IsRectEmpty( rect )) return FALSE;
/* don't map if rect is off-screen */
if (rect->left >= screen_width || rect->top >= screen_height) return FALSE;
if (rect->right < 0 || rect->bottom < 0) return FALSE;
return TRUE;
}
/***********************************************************************
* get_window_attributes
*
* Fill the window attributes structure for an X window.
......@@ -516,7 +534,8 @@ void X11DRV_set_iconic_state( WND *win )
if (iconic)
XIconifyWindow( display, data->whole_window, DefaultScreen(display) );
else
if (!IsRectEmpty( &win->rectWindow )) XMapWindow( display, data->whole_window );
if (X11DRV_is_window_rect_mapped( &win->rectWindow ))
XMapWindow( display, data->whole_window );
}
XFree(wm_hints);
......
......@@ -817,7 +817,8 @@ static void set_visible_style( HWND hwnd, BOOL set )
{
if (win->dwStyle & WS_VISIBLE) goto done;
WIN_SetStyle( hwnd, win->dwStyle | WS_VISIBLE );
if (!IsRectEmpty( &win->rectWindow ) && get_whole_window(win) && is_window_top_level(win))
if (X11DRV_is_window_rect_mapped( &win->rectWindow ) &&
get_whole_window(win) && is_window_top_level(win))
{
Display *display = thread_display();
X11DRV_sync_window_style( display, win );
......@@ -832,7 +833,8 @@ static void set_visible_style( HWND hwnd, BOOL set )
{
if (!(win->dwStyle & WS_VISIBLE)) goto done;
WIN_SetStyle( hwnd, win->dwStyle & ~WS_VISIBLE );
if (!IsRectEmpty( &win->rectWindow ) && get_whole_window(win) && is_window_top_level(win))
if (X11DRV_is_window_rect_mapped( &win->rectWindow ) &&
get_whole_window(win) && is_window_top_level(win))
{
TRACE( "unmapping win %p\n", hwnd );
wine_tsx11_lock();
......@@ -864,7 +866,7 @@ void X11DRV_SetWindowStyle( HWND hwnd, LONG oldStyle )
if (changed & WS_VISIBLE)
{
if (!IsRectEmpty( &wndPtr->rectWindow ))
if (X11DRV_is_window_rect_mapped( &wndPtr->rectWindow ))
{
if (wndPtr->dwStyle & WS_VISIBLE)
{
......@@ -1013,10 +1015,11 @@ BOOL X11DRV_SetWindowPos( WINDOWPOS *winpos )
set_visible_style( winpos->hwnd, FALSE );
}
else if ((wndPtr->dwStyle & WS_VISIBLE) &&
!IsRectEmpty( &oldWindowRect ) && IsRectEmpty( &newWindowRect ))
X11DRV_is_window_rect_mapped( &oldWindowRect ) &&
!X11DRV_is_window_rect_mapped( &newWindowRect ))
{
/* resizing to zero size -> unmap */
TRACE( "unmapping zero size win %p\n", winpos->hwnd );
/* resizing to zero size or off screen -> unmap */
TRACE( "unmapping zero size or off-screen win %p\n", winpos->hwnd );
wine_tsx11_lock();
XUnmapWindow( display, get_whole_window(wndPtr) );
wine_tsx11_unlock();
......@@ -1044,10 +1047,11 @@ BOOL X11DRV_SetWindowPos( WINDOWPOS *winpos )
set_visible_style( winpos->hwnd, TRUE );
}
else if ((wndPtr->dwStyle & WS_VISIBLE) &&
IsRectEmpty( &oldWindowRect ) && !IsRectEmpty( &newWindowRect ))
!X11DRV_is_window_rect_mapped( &oldWindowRect ) &&
X11DRV_is_window_rect_mapped( &newWindowRect ))
{
/* resizing from zero size to non-zero -> map */
TRACE( "mapping non zero size win %p\n", winpos->hwnd );
TRACE( "mapping non zero size or off-screen win %p\n", winpos->hwnd );
XMapWindow( display, get_whole_window(wndPtr) );
}
XFlush( display ); /* FIXME: should not be necessary */
......@@ -1449,7 +1453,8 @@ void X11DRV_UnmapNotify( HWND hwnd, XUnmapEvent *event )
if (!(win = WIN_GetPtr( hwnd ))) return;
if ((win->dwStyle & WS_VISIBLE) && (win->dwExStyle & WS_EX_MANAGED))
if ((win->dwStyle & WS_VISIBLE) && (win->dwExStyle & WS_EX_MANAGED) &&
X11DRV_is_window_rect_mapped( &win->rectWindow ))
{
if (win->dwStyle & WS_MAXIMIZE)
win->flags |= WIN_RESTORE_MAX;
......
......@@ -517,6 +517,7 @@ typedef struct x11drv_win_data X11DRV_WND_DATA;
extern Window X11DRV_get_client_window( HWND hwnd );
extern Window X11DRV_get_whole_window( HWND hwnd );
extern BOOL X11DRV_is_window_rect_mapped( const RECT *rect );
extern XIC X11DRV_get_ic( HWND hwnd );
inline static Window get_client_window( WND *wnd )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment