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 ) ...@@ -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 * get_window_attributes
* *
* Fill the window attributes structure for an X window. * Fill the window attributes structure for an X window.
...@@ -516,7 +534,8 @@ void X11DRV_set_iconic_state( WND *win ) ...@@ -516,7 +534,8 @@ void X11DRV_set_iconic_state( WND *win )
if (iconic) if (iconic)
XIconifyWindow( display, data->whole_window, DefaultScreen(display) ); XIconifyWindow( display, data->whole_window, DefaultScreen(display) );
else 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); XFree(wm_hints);
......
...@@ -817,7 +817,8 @@ static void set_visible_style( HWND hwnd, BOOL set ) ...@@ -817,7 +817,8 @@ static void set_visible_style( HWND hwnd, BOOL set )
{ {
if (win->dwStyle & WS_VISIBLE) goto done; if (win->dwStyle & WS_VISIBLE) goto done;
WIN_SetStyle( hwnd, win->dwStyle | WS_VISIBLE ); 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(); Display *display = thread_display();
X11DRV_sync_window_style( display, win ); X11DRV_sync_window_style( display, win );
...@@ -832,7 +833,8 @@ static void set_visible_style( HWND hwnd, BOOL set ) ...@@ -832,7 +833,8 @@ static void set_visible_style( HWND hwnd, BOOL set )
{ {
if (!(win->dwStyle & WS_VISIBLE)) goto done; if (!(win->dwStyle & WS_VISIBLE)) goto done;
WIN_SetStyle( hwnd, win->dwStyle & ~WS_VISIBLE ); 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 ); TRACE( "unmapping win %p\n", hwnd );
wine_tsx11_lock(); wine_tsx11_lock();
...@@ -864,7 +866,7 @@ void X11DRV_SetWindowStyle( HWND hwnd, LONG oldStyle ) ...@@ -864,7 +866,7 @@ void X11DRV_SetWindowStyle( HWND hwnd, LONG oldStyle )
if (changed & WS_VISIBLE) if (changed & WS_VISIBLE)
{ {
if (!IsRectEmpty( &wndPtr->rectWindow )) if (X11DRV_is_window_rect_mapped( &wndPtr->rectWindow ))
{ {
if (wndPtr->dwStyle & WS_VISIBLE) if (wndPtr->dwStyle & WS_VISIBLE)
{ {
...@@ -1013,10 +1015,11 @@ BOOL X11DRV_SetWindowPos( WINDOWPOS *winpos ) ...@@ -1013,10 +1015,11 @@ BOOL X11DRV_SetWindowPos( WINDOWPOS *winpos )
set_visible_style( winpos->hwnd, FALSE ); set_visible_style( winpos->hwnd, FALSE );
} }
else if ((wndPtr->dwStyle & WS_VISIBLE) && 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 */ /* resizing to zero size or off screen -> unmap */
TRACE( "unmapping zero size win %p\n", winpos->hwnd ); TRACE( "unmapping zero size or off-screen win %p\n", winpos->hwnd );
wine_tsx11_lock(); wine_tsx11_lock();
XUnmapWindow( display, get_whole_window(wndPtr) ); XUnmapWindow( display, get_whole_window(wndPtr) );
wine_tsx11_unlock(); wine_tsx11_unlock();
...@@ -1044,10 +1047,11 @@ BOOL X11DRV_SetWindowPos( WINDOWPOS *winpos ) ...@@ -1044,10 +1047,11 @@ BOOL X11DRV_SetWindowPos( WINDOWPOS *winpos )
set_visible_style( winpos->hwnd, TRUE ); set_visible_style( winpos->hwnd, TRUE );
} }
else if ((wndPtr->dwStyle & WS_VISIBLE) && 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 */ /* 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) ); XMapWindow( display, get_whole_window(wndPtr) );
} }
XFlush( display ); /* FIXME: should not be necessary */ XFlush( display ); /* FIXME: should not be necessary */
...@@ -1449,7 +1453,8 @@ void X11DRV_UnmapNotify( HWND hwnd, XUnmapEvent *event ) ...@@ -1449,7 +1453,8 @@ void X11DRV_UnmapNotify( HWND hwnd, XUnmapEvent *event )
if (!(win = WIN_GetPtr( hwnd ))) return; 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) if (win->dwStyle & WS_MAXIMIZE)
win->flags |= WIN_RESTORE_MAX; win->flags |= WIN_RESTORE_MAX;
......
...@@ -517,6 +517,7 @@ typedef struct x11drv_win_data X11DRV_WND_DATA; ...@@ -517,6 +517,7 @@ typedef struct x11drv_win_data X11DRV_WND_DATA;
extern Window X11DRV_get_client_window( HWND hwnd ); extern Window X11DRV_get_client_window( HWND hwnd );
extern Window X11DRV_get_whole_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 ); extern XIC X11DRV_get_ic( HWND hwnd );
inline static Window get_client_window( WND *wnd ) 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