Module: wine Branch: master Commit: a06aeaba39a5732856a037ac3221ce72c5cc4fe2 URL: http://source.winehq.org/git/wine.git/?a=commit;h=a06aeaba39a5732856a037ac32...
Author: Alexandre Julliard julliard@winehq.org Date: Thu Oct 26 12:53:59 2006 +0200
winex11.drv: Offset X11 coordinates with the primary monitor position.
No longer force the primary monitor to contain the X11 (0,0) coordinate.
---
dlls/winex11.drv/mouse.c | 13 +++++++++++-- dlls/winex11.drv/window.c | 14 +++++++++----- dlls/winex11.drv/winpos.c | 9 +++++++-- dlls/winex11.drv/xinerama.c | 19 +++++++++++-------- 4 files changed, 38 insertions(+), 17 deletions(-)
diff --git a/dlls/winex11.drv/mouse.c b/dlls/winex11.drv/mouse.c index 5ac714c..e6f899a 100644 --- a/dlls/winex11.drv/mouse.c +++ b/dlls/winex11.drv/mouse.c @@ -123,6 +123,11 @@ static void update_mouse_state( HWND hwn { struct x11drv_thread_data *data = x11drv_thread_data();
+ if (window == root_window) + { + x += virtual_screen_rect.left; + y += virtual_screen_rect.top; + } get_coords( hwnd, x, y, pt ); update_key_state( state );
@@ -287,7 +292,8 @@ void X11DRV_send_mouse_input( HWND hwnd, { TRACE( "warping to (%d,%d)\n", pt.x, pt.y ); wine_tsx11_lock(); - XWarpPointer( thread_display(), root_window, root_window, 0, 0, 0, 0, pt.x, pt.y ); + XWarpPointer( thread_display(), root_window, root_window, 0, 0, 0, 0, + pt.x - virtual_screen_rect.left, pt.y - virtual_screen_rect.top ); wine_tsx11_unlock(); } } @@ -690,7 +696,8 @@ BOOL X11DRV_SetCursorPos( INT x, INT y ) TRACE( "warping to (%d,%d)\n", x, y );
wine_tsx11_lock(); - XWarpPointer( display, root_window, root_window, 0, 0, 0, 0, x, y ); + XWarpPointer( display, root_window, root_window, 0, 0, 0, 0, + x - virtual_screen_rect.left, y - virtual_screen_rect.top ); XFlush( display ); /* avoids bad mouse lag in games that do their own mouse warping */ cursor_pos.x = x; cursor_pos.y = y; @@ -714,6 +721,8 @@ BOOL X11DRV_GetCursorPos(LPPOINT pos) { update_key_state( xstate ); update_button_state( xstate ); + winX += virtual_screen_rect.left; + winY += virtual_screen_rect.top; TRACE("pointer at (%d,%d)\n", winX, winY ); cursor_pos.x = winX; cursor_pos.y = winY; diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c index 39c58c9..b17efff 100644 --- a/dlls/winex11.drv/window.c +++ b/dlls/winex11.drv/window.c @@ -611,8 +611,8 @@ void X11DRV_set_iconic_state( HWND hwnd if (!(wm_hints = XGetWMHints( display, data->whole_window ))) wm_hints = XAllocWMHints(); wm_hints->flags |= StateHint | IconPositionHint; wm_hints->initial_state = iconic ? IconicState : NormalState; - wm_hints->icon_x = rect.left; - wm_hints->icon_y = rect.top; + wm_hints->icon_x = rect.left - virtual_screen_rect.left; + wm_hints->icon_y = rect.top - virtual_screen_rect.top; XSetWMHints( display, data->whole_window, wm_hints );
if (style & WS_VISIBLE) @@ -734,6 +734,8 @@ void X11DRV_sync_window_position( Displa
wine_tsx11_lock(); if (mask & (CWWidth|CWHeight)) set_size_hints( display, data, style ); + if (mask & CWX) changes.x -= virtual_screen_rect.left; + if (mask & CWY) changes.y -= virtual_screen_rect.top; XReconfigureWMWindow( display, data->whole_window, DefaultScreen(display), mask, &changes ); wine_tsx11_unlock(); @@ -773,9 +775,11 @@ static Window create_whole_window( Displ wine_tsx11_lock();
data->whole_rect = rect; - data->whole_window = XCreateWindow( display, root_window, rect.left, rect.top, cx, cy, - 0, screen_depth, InputOutput, visual, - mask, &attr ); + data->whole_window = XCreateWindow( display, root_window, + rect.left - virtual_screen_rect.left, + rect.top - virtual_screen_rect.top, + cx, cy, 0, screen_depth, InputOutput, + visual, mask, &attr );
if (!data->whole_window) { diff --git a/dlls/winex11.drv/winpos.c b/dlls/winex11.drv/winpos.c index 3215f7c..4ebcda8 100644 --- a/dlls/winex11.drv/winpos.c +++ b/dlls/winex11.drv/winpos.c @@ -102,6 +102,9 @@ void X11DRV_Expose( HWND hwnd, XEvent *x rect.right = rect.left + event->width; rect.bottom = rect.top + event->height;
+ if (event->window == root_window) + OffsetRect( &rect, virtual_screen_rect.left, virtual_screen_rect.top ); + if (rect.left < data->client_rect.left || rect.top < data->client_rect.top || rect.right > data->client_rect.right || @@ -1168,6 +1171,7 @@ void X11DRV_MapNotify( HWND hwnd, XEvent rect.top = y; rect.right = x + width; rect.bottom = y + height; + OffsetRect( &rect, virtual_screen_rect.left, virtual_screen_rect.top ); X11DRV_X_to_window_rect( data, &rect );
invalidate_dce( hwnd, &data->window_rect ); @@ -1255,9 +1259,9 @@ void X11DRV_handle_desktop_resize( unsig screen_height = height; xinerama_init(); TRACE("desktop %p change to (%dx%d)\n", hwnd, width, height); - SetRect( &rect, 0, 0, width, height ); data->lock_changes++; - X11DRV_set_window_pos( hwnd, 0, &rect, &rect, SWP_NOZORDER|SWP_NOMOVE, NULL ); + X11DRV_set_window_pos( hwnd, 0, &virtual_screen_rect, &virtual_screen_rect, + SWP_NOZORDER|SWP_NOMOVE, NULL ); data->lock_changes--; SendMessageTimeoutW( HWND_BROADCAST, WM_DISPLAYCHANGE, screen_depth, MAKELPARAM( width, height ), SMTO_ABORTIFHUNG, 2000, NULL ); @@ -1295,6 +1299,7 @@ void X11DRV_ConfigureNotify( HWND hwnd, rect.top = y; rect.right = x + event->width; rect.bottom = y + event->height; + OffsetRect( &rect, virtual_screen_rect.left, virtual_screen_rect.top ); TRACE( "win %p new X rect %d,%d,%dx%d (event %d,%d,%dx%d)\n", hwnd, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, event->x, event->y, event->width, event->height ); diff --git a/dlls/winex11.drv/xinerama.c b/dlls/winex11.drv/xinerama.c index 0d01b58..db39407 100644 --- a/dlls/winex11.drv/xinerama.c +++ b/dlls/winex11.drv/xinerama.c @@ -106,9 +106,6 @@ static int query_screens(void) nb_monitors = count; for (i = 0; i < nb_monitors; i++) { - /* FIXME: for now, force primary to be the screen that starts at (0,0) origin */ - if (!screens[i].x_org && !screens[i].y_org) primary_monitor = i; - monitors[i].cbSize = sizeof( monitors[i] ); monitors[i].rcMonitor.left = screens[i].x_org; monitors[i].rcMonitor.top = screens[i].y_org; @@ -121,11 +118,6 @@ static int query_screens(void) }
get_primary()->dwFlags |= MONITORINFOF_PRIMARY; - - for (i = 0; i < nb_monitors; i++) - TRACE( "monitor %p: %s%s\n", - index_to_monitor(i), wine_dbgstr_rect(&monitors[i].rcMonitor), - (monitors[i].dwFlags & MONITORINFOF_PRIMARY) ? " (primary)" : "" ); } else count = 0;
@@ -145,6 +137,7 @@ #endif /* HAVE_LIBXINERAMA */ void xinerama_init(void) { MONITORINFOEXW *primary; + int i;
wine_tsx11_lock();
@@ -158,8 +151,18 @@ void xinerama_init(void) }
primary = get_primary(); + /* coordinates (0,0) have to point to the primary monitor origin */ OffsetRect( &virtual_screen_rect, -primary->rcMonitor.left, -primary->rcMonitor.top ); + for (i = 0; i < nb_monitors; i++) + { + OffsetRect( &monitors[i].rcMonitor, virtual_screen_rect.left, virtual_screen_rect.top ); + OffsetRect( &monitors[i].rcWork, virtual_screen_rect.left, virtual_screen_rect.top ); + TRACE( "monitor %p: %s%s\n", + index_to_monitor(i), wine_dbgstr_rect(&monitors[i].rcMonitor), + (monitors[i].dwFlags & MONITORINFOF_PRIMARY) ? " (primary)" : "" ); + } + screen_width = primary->rcMonitor.right - primary->rcMonitor.left; screen_height = primary->rcMonitor.bottom - primary->rcMonitor.top; TRACE( "virtual size: %s primary size: %dx%d\n",