From 9f1f29cc911178f47ae64f5ba6c859578eea1a3c Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Mon, 14 Oct 2013 14:38:58 +0200 Subject: [PATCH] winex11: Add a helper function to return the virtual screen rectangle. --- dlls/winex11.drv/desktop.c | 14 ++++++++------ dlls/winex11.drv/init.c | 14 ++++++++++---- dlls/winex11.drv/mouse.c | 23 ++++++++++++++--------- dlls/winex11.drv/window.c | 19 ++++++++++--------- dlls/winex11.drv/x11drv.h | 31 ++++++++++++++++--------------- dlls/winex11.drv/x11drv_main.c | 1 - dlls/winex11.drv/xinerama.c | 7 +++++++ 7 files changed, 65 insertions(+), 44 deletions(-) diff --git a/dlls/winex11.drv/desktop.c b/dlls/winex11.drv/desktop.c index 733aca819dc..dfb65061450 100644 --- a/dlls/winex11.drv/desktop.c +++ b/dlls/winex11.drv/desktop.c @@ -171,6 +171,7 @@ struct desktop_resize_data { RECT old_screen_rect; RECT old_virtual_rect; + RECT new_virtual_rect; }; static BOOL CALLBACK update_windows_on_desktop_resize( HWND hwnd, LPARAM lparam ) @@ -184,8 +185,8 @@ static BOOL CALLBACK update_windows_on_desktop_resize( HWND hwnd, LPARAM lparam /* update the full screen state */ update_net_wm_states( data ); - if (resize_data->old_virtual_rect.left != virtual_screen_rect.left) mask |= CWX; - if (resize_data->old_virtual_rect.top != virtual_screen_rect.top) mask |= CWY; + if (resize_data->old_virtual_rect.left != resize_data->new_virtual_rect.left) mask |= CWX; + if (resize_data->old_virtual_rect.top != resize_data->new_virtual_rect.top) mask |= CWY; if (mask && data->whole_window) { POINT pos = virtual_screen_to_root( data->whole_rect.left, data->whole_rect.top ); @@ -246,9 +247,10 @@ void X11DRV_resize_desktop( unsigned int width, unsigned int height ) struct desktop_resize_data resize_data; SetRect( &resize_data.old_screen_rect, 0, 0, screen_width, screen_height ); - resize_data.old_virtual_rect = virtual_screen_rect; + resize_data.old_virtual_rect = get_virtual_screen_rect(); xinerama_init( width, height ); + resize_data.new_virtual_rect = get_virtual_screen_rect(); if (GetWindowThreadProcessId( hwnd, NULL ) != GetCurrentThreadId()) { @@ -258,9 +260,9 @@ void X11DRV_resize_desktop( unsigned int width, unsigned int height ) { TRACE( "desktop %p change to (%dx%d)\n", hwnd, width, height ); update_desktop_fullscreen( width, height ); - SetWindowPos( hwnd, 0, virtual_screen_rect.left, virtual_screen_rect.top, - virtual_screen_rect.right - virtual_screen_rect.left, - virtual_screen_rect.bottom - virtual_screen_rect.top, + SetWindowPos( hwnd, 0, resize_data.new_virtual_rect.left, resize_data.new_virtual_rect.top, + resize_data.new_virtual_rect.right - resize_data.new_virtual_rect.left, + resize_data.new_virtual_rect.bottom - resize_data.new_virtual_rect.top, SWP_NOZORDER | SWP_NOACTIVATE | SWP_DEFERERASE ); ungrab_clipping_window(); SendMessageTimeoutW( HWND_BROADCAST, WM_DISPLAYCHANGE, screen_bpp, diff --git a/dlls/winex11.drv/init.c b/dlls/winex11.drv/init.c index 6e6ed173f5b..fc6b8ee6f5c 100644 --- a/dlls/winex11.drv/init.c +++ b/dlls/winex11.drv/init.c @@ -128,8 +128,8 @@ static BOOL X11DRV_CreateDC( PHYSDEV *pdev, LPCWSTR driver, LPCWSTR device, physDev->depth = default_visual.depth; physDev->color_shifts = &X11DRV_PALETTE_default_shifts; - SetRect( &physDev->dc_rect, 0, 0, virtual_screen_rect.right - virtual_screen_rect.left, - virtual_screen_rect.bottom - virtual_screen_rect.top ); + physDev->dc_rect = get_virtual_screen_rect(); + OffsetRect( &physDev->dc_rect, -physDev->dc_rect.left, -physDev->dc_rect.top ); push_dc_driver( pdev, &physDev->dev, &x11drv_funcs ); if (xrender_funcs && !xrender_funcs->pCreateDC( pdev, driver, device, output, initData )) return FALSE; return TRUE; @@ -212,9 +212,15 @@ static INT X11DRV_GetDeviceCaps( PHYSDEV dev, INT cap ) case VERTRES: return screen_height; case DESKTOPHORZRES: - return virtual_screen_rect.right - virtual_screen_rect.left; + { + RECT virtual_rect = get_virtual_screen_rect(); + return virtual_rect.right - virtual_rect.left; + } case DESKTOPVERTRES: - return virtual_screen_rect.bottom - virtual_screen_rect.top; + { + RECT virtual_rect = get_virtual_screen_rect(); + return virtual_rect.bottom - virtual_rect.top; + } case BITSPIXEL: return screen_bpp; case PLANES: diff --git a/dlls/winex11.drv/mouse.c b/dlls/winex11.drv/mouse.c index c89f69b46bd..e3179afa160 100644 --- a/dlls/winex11.drv/mouse.c +++ b/dlls/winex11.drv/mouse.c @@ -473,11 +473,11 @@ LRESULT clip_cursor_notify( HWND hwnd, HWND new_clip_hwnd ) } else if (hwnd == GetForegroundWindow()) /* request to clip */ { - RECT clip; + RECT clip, virtual_rect = get_virtual_screen_rect(); GetClipCursor( &clip ); - if (clip.left > virtual_screen_rect.left || clip.right < virtual_screen_rect.right || - clip.top > virtual_screen_rect.top || clip.bottom < virtual_screen_rect.bottom) + if (clip.left > virtual_rect.left || clip.right < virtual_rect.right || + clip.top > virtual_rect.top || clip.bottom < virtual_rect.bottom) return grab_clipping_window( &clip ); } return 0; @@ -512,7 +512,8 @@ BOOL clip_fullscreen_window( HWND hwnd, BOOL reset ) SetRect( &rect, 0, 0, screen_width, screen_height ); if (!grab_fullscreen) { - if (!EqualRect( &rect, &virtual_screen_rect )) return FALSE; + RECT virtual_rect = get_virtual_screen_rect(); + if (!EqualRect( &rect, &virtual_rect )) return FALSE; if (root_window != DefaultRootWindow( gdi_display )) return FALSE; } TRACE( "win %p clipping fullscreen\n", hwnd ); @@ -1382,15 +1383,17 @@ BOOL CDECL X11DRV_GetCursorPos(LPPOINT pos) */ BOOL CDECL X11DRV_ClipCursor( LPCRECT clip ) { - if (!clip) clip = &virtual_screen_rect; + RECT virtual_rect = get_virtual_screen_rect(); + + if (!clip) clip = &virtual_rect; if (grab_pointer) { HWND foreground = GetForegroundWindow(); /* we are clipping if the clip rectangle is smaller than the screen */ - if (clip->left > virtual_screen_rect.left || clip->right < virtual_screen_rect.right || - clip->top > virtual_screen_rect.top || clip->bottom < virtual_screen_rect.bottom) + if (clip->left > virtual_rect.left || clip->right < virtual_rect.right || + clip->top > virtual_rect.top || clip->bottom < virtual_rect.bottom) { DWORD tid, pid; @@ -1616,6 +1619,7 @@ static void X11DRV_RawMotion( XGenericEventCookie *xev ) { XIRawEvent *event = xev->data; const double *values = event->valuators.values; + RECT virtual_rect; INPUT input; int i, j; double dx = 0, dy = 0; @@ -1632,6 +1636,7 @@ static void X11DRV_RawMotion( XGenericEventCookie *xev ) input.u.mi.dx = 0; input.u.mi.dy = 0; + virtual_rect = get_virtual_screen_rect(); for (i = 0; i < thread_data->xi2_device_count; ++i) { if (devices[i].deviceid != event->deviceid) continue; @@ -1648,7 +1653,7 @@ static void X11DRV_RawMotion( XGenericEventCookie *xev ) { input.u.mi.dx = dx = val; if (class->min < class->max) - input.u.mi.dx = val * (virtual_screen_rect.right - virtual_screen_rect.left) + input.u.mi.dx = val * (virtual_rect.right - virtual_rect.left) / (class->max - class->min); } else if (class->label == x11drv_atom( Rel_Y ) || @@ -1656,7 +1661,7 @@ static void X11DRV_RawMotion( XGenericEventCookie *xev ) { input.u.mi.dy = dy = val; if (class->min < class->max) - input.u.mi.dy = val * (virtual_screen_rect.bottom - virtual_screen_rect.top) + input.u.mi.dy = val * (virtual_rect.bottom - virtual_rect.top) / (class->max - class->min); } } diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c index b7718225a77..17859f83354 100644 --- a/dlls/winex11.drv/window.c +++ b/dlls/winex11.drv/window.c @@ -1684,15 +1684,17 @@ BOOL CDECL X11DRV_CreateDesktopWindow( HWND hwnd ) if (!width && !height) /* not initialized yet */ { + RECT rect = get_virtual_screen_rect(); + SERVER_START_REQ( set_window_pos ) { req->handle = wine_server_user_handle( hwnd ); req->previous = 0; req->swp_flags = SWP_NOZORDER; - req->window.left = virtual_screen_rect.left; - req->window.top = virtual_screen_rect.top; - req->window.right = virtual_screen_rect.right; - req->window.bottom = virtual_screen_rect.bottom; + req->window.left = rect.left; + req->window.top = rect.top; + req->window.right = rect.right; + req->window.bottom = rect.bottom; req->client = req->window; wine_server_call( req ); } @@ -2016,9 +2018,8 @@ void CDECL X11DRV_ReleaseDC( HWND hwnd, HDC hdc ) escape.hwnd = GetDesktopWindow(); escape.drawable = root_window; escape.mode = IncludeInferiors; - SetRect( &escape.dc_rect, 0, 0, virtual_screen_rect.right - virtual_screen_rect.left, - virtual_screen_rect.bottom - virtual_screen_rect.top ); - OffsetRect( &escape.dc_rect, -virtual_screen_rect.left, -virtual_screen_rect.top ); + escape.dc_rect = get_virtual_screen_rect(); + OffsetRect( &escape.dc_rect, -2 * escape.dc_rect.left, -2 * escape.dc_rect.top ); escape.fbconfig_id = 0; ExtEscape( hdc, X11DRV_ESCAPE, sizeof(escape), (LPSTR)&escape, 0, NULL ); } @@ -2123,9 +2124,9 @@ done: static inline RECT get_surface_rect( const RECT *visible_rect ) { - RECT rect; + RECT rect = get_virtual_screen_rect(); - IntersectRect( &rect, visible_rect, &virtual_screen_rect ); + IntersectRect( &rect, &rect, visible_rect ); OffsetRect( &rect, -visible_rect->left, -visible_rect->top ); rect.left &= ~31; rect.top &= ~31; diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index b5621e2e0a6..7b301470467 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -367,7 +367,6 @@ extern int clipping_cursor DECLSPEC_HIDDEN; extern unsigned int screen_width DECLSPEC_HIDDEN; extern unsigned int screen_height DECLSPEC_HIDDEN; extern unsigned int screen_bpp DECLSPEC_HIDDEN; -extern RECT virtual_screen_rect DECLSPEC_HIDDEN; extern int use_xkb DECLSPEC_HIDDEN; extern int usexrandr DECLSPEC_HIDDEN; extern int usexvidmode DECLSPEC_HIDDEN; @@ -599,20 +598,6 @@ static inline void mirror_rect( const RECT *window_rect, RECT *rect ) rect->right = width - tmp; } -static inline BOOL is_window_rect_mapped( const RECT *rect ) -{ - return (rect->left < virtual_screen_rect.right && - rect->top < virtual_screen_rect.bottom && - max( rect->right, rect->left + 1 ) > virtual_screen_rect.left && - max( rect->bottom, rect->top + 1 ) > virtual_screen_rect.top); -} - -static inline BOOL is_window_rect_fullscreen( const RECT *rect ) -{ - return (rect->left <= 0 && rect->right >= screen_width && - rect->top <= 0 && rect->bottom >= screen_height); -} - /* X context to associate a hwnd to an X window */ extern XContext winContext DECLSPEC_HIDDEN; /* X context to associate a struct x11drv_win_data to an hwnd */ @@ -642,6 +627,7 @@ extern int X11DRV_check_error(void) DECLSPEC_HIDDEN; extern void X11DRV_X_to_window_rect( struct x11drv_win_data *data, RECT *rect ) DECLSPEC_HIDDEN; extern POINT virtual_screen_to_root( INT x, INT y ) DECLSPEC_HIDDEN; extern POINT root_to_virtual_screen( INT x, INT y ) DECLSPEC_HIDDEN; +extern RECT get_virtual_screen_rect(void) DECLSPEC_HIDDEN; extern void xinerama_init( unsigned int width, unsigned int height ) DECLSPEC_HIDDEN; struct x11drv_mode_info @@ -678,4 +664,19 @@ extern void X11DRV_SetPreeditState(HWND hwnd, BOOL fOpen) DECLSPEC_HIDDEN; #define XEMBED_MAPPED (1 << 0) +static inline BOOL is_window_rect_mapped( const RECT *rect ) +{ + RECT virtual_rect = get_virtual_screen_rect(); + return (rect->left < virtual_rect.right && + rect->top < virtual_rect.bottom && + max( rect->right, rect->left + 1 ) > virtual_rect.left && + max( rect->bottom, rect->top + 1 ) > virtual_rect.top); +} + +static inline BOOL is_window_rect_fullscreen( const RECT *rect ) +{ + return (rect->left <= 0 && rect->right >= screen_width && + rect->top <= 0 && rect->bottom >= screen_height); +} + #endif /* __WINE_X11DRV_H */ diff --git a/dlls/winex11.drv/x11drv_main.c b/dlls/winex11.drv/x11drv_main.c index 329fea584b0..99bfe7cf068 100644 --- a/dlls/winex11.drv/x11drv_main.c +++ b/dlls/winex11.drv/x11drv_main.c @@ -63,7 +63,6 @@ XPixmapFormatValues **pixmap_formats; unsigned int screen_width; unsigned int screen_height; unsigned int screen_bpp; -RECT virtual_screen_rect; Window root_window; int usexvidmode = 1; int usexrandr = 1; diff --git a/dlls/winex11.drv/xinerama.c b/dlls/winex11.drv/xinerama.c index 60b392d79db..029c1191421 100644 --- a/dlls/winex11.drv/xinerama.c +++ b/dlls/winex11.drv/xinerama.c @@ -33,6 +33,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(x11drv); +static RECT virtual_screen_rect; + static MONITORINFOEXW default_monitor = { sizeof(default_monitor), /* cbSize */ @@ -173,6 +175,11 @@ POINT root_to_virtual_screen( INT x, INT y ) return pt; } +RECT get_virtual_screen_rect(void) +{ + return virtual_screen_rect; +} + void xinerama_init( unsigned int width, unsigned int height ) { MONITORINFOEXW *primary; -- 2.11.4.GIT