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.
diff --git a/dlls/x11drv/window.c b/dlls/x11drv/window.c index c754c1b..51281c0 100644 --- a/dlls/x11drv/window.c +++ b/dlls/x11drv/window.c
@@ -151,6 +151,24 @@ /*********************************************************************** + * 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 @@ 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);
diff --git a/dlls/x11drv/winpos.c b/dlls/x11drv/winpos.c index dd97694..3665880 100644 --- a/dlls/x11drv/winpos.c +++ b/dlls/x11drv/winpos.c
@@ -817,7 +817,8 @@ { 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 @@ { 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 @@ 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 @@ 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 @@ 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 @@ 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;
diff --git a/dlls/x11drv/x11drv.h b/dlls/x11drv/x11drv.h index cc40b4a..fcc26c3 100644 --- a/dlls/x11drv/x11drv.h +++ b/dlls/x11drv/x11drv.h
@@ -517,6 +517,7 @@ 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 )