winex11.drv: Offset X11 coordinates with the primary monitor position.

No longer force the primary monitor to contain the X11 (0,0) coordinate.
This commit is contained in:
Alexandre Julliard 2006-10-26 12:53:59 +02:00
parent 844374afaf
commit a06aeaba39
4 changed files with 38 additions and 17 deletions

View File

@ -123,6 +123,11 @@ static void update_mouse_state( HWND hwnd, Window window, int x, int y, unsigned
{ {
struct x11drv_thread_data *data = x11drv_thread_data(); 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 ); get_coords( hwnd, x, y, pt );
update_key_state( state ); update_key_state( state );
@ -287,7 +292,8 @@ void X11DRV_send_mouse_input( HWND hwnd, DWORD flags, DWORD x, DWORD y,
{ {
TRACE( "warping to (%d,%d)\n", pt.x, pt.y ); TRACE( "warping to (%d,%d)\n", pt.x, pt.y );
wine_tsx11_lock(); 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(); wine_tsx11_unlock();
} }
} }
@ -690,7 +696,8 @@ BOOL X11DRV_SetCursorPos( INT x, INT y )
TRACE( "warping to (%d,%d)\n", x, y ); TRACE( "warping to (%d,%d)\n", x, y );
wine_tsx11_lock(); 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 */ XFlush( display ); /* avoids bad mouse lag in games that do their own mouse warping */
cursor_pos.x = x; cursor_pos.x = x;
cursor_pos.y = y; cursor_pos.y = y;
@ -714,6 +721,8 @@ BOOL X11DRV_GetCursorPos(LPPOINT pos)
{ {
update_key_state( xstate ); update_key_state( xstate );
update_button_state( xstate ); update_button_state( xstate );
winX += virtual_screen_rect.left;
winY += virtual_screen_rect.top;
TRACE("pointer at (%d,%d)\n", winX, winY ); TRACE("pointer at (%d,%d)\n", winX, winY );
cursor_pos.x = winX; cursor_pos.x = winX;
cursor_pos.y = winY; cursor_pos.y = winY;

View File

@ -611,8 +611,8 @@ void X11DRV_set_iconic_state( HWND hwnd )
if (!(wm_hints = XGetWMHints( display, data->whole_window ))) wm_hints = XAllocWMHints(); if (!(wm_hints = XGetWMHints( display, data->whole_window ))) wm_hints = XAllocWMHints();
wm_hints->flags |= StateHint | IconPositionHint; wm_hints->flags |= StateHint | IconPositionHint;
wm_hints->initial_state = iconic ? IconicState : NormalState; wm_hints->initial_state = iconic ? IconicState : NormalState;
wm_hints->icon_x = rect.left; wm_hints->icon_x = rect.left - virtual_screen_rect.left;
wm_hints->icon_y = rect.top; wm_hints->icon_y = rect.top - virtual_screen_rect.top;
XSetWMHints( display, data->whole_window, wm_hints ); XSetWMHints( display, data->whole_window, wm_hints );
if (style & WS_VISIBLE) if (style & WS_VISIBLE)
@ -734,6 +734,8 @@ void X11DRV_sync_window_position( Display *display, struct x11drv_win_data *data
wine_tsx11_lock(); wine_tsx11_lock();
if (mask & (CWWidth|CWHeight)) set_size_hints( display, data, style ); 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, XReconfigureWMWindow( display, data->whole_window,
DefaultScreen(display), mask, &changes ); DefaultScreen(display), mask, &changes );
wine_tsx11_unlock(); wine_tsx11_unlock();
@ -773,9 +775,11 @@ static Window create_whole_window( Display *display, struct x11drv_win_data *dat
wine_tsx11_lock(); wine_tsx11_lock();
data->whole_rect = rect; data->whole_rect = rect;
data->whole_window = XCreateWindow( display, root_window, rect.left, rect.top, cx, cy, data->whole_window = XCreateWindow( display, root_window,
0, screen_depth, InputOutput, visual, rect.left - virtual_screen_rect.left,
mask, &attr ); rect.top - virtual_screen_rect.top,
cx, cy, 0, screen_depth, InputOutput,
visual, mask, &attr );
if (!data->whole_window) if (!data->whole_window)
{ {

View File

@ -102,6 +102,9 @@ void X11DRV_Expose( HWND hwnd, XEvent *xev )
rect.right = rect.left + event->width; rect.right = rect.left + event->width;
rect.bottom = rect.top + event->height; 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 || if (rect.left < data->client_rect.left ||
rect.top < data->client_rect.top || rect.top < data->client_rect.top ||
rect.right > data->client_rect.right || rect.right > data->client_rect.right ||
@ -1168,6 +1171,7 @@ void X11DRV_MapNotify( HWND hwnd, XEvent *event )
rect.top = y; rect.top = y;
rect.right = x + width; rect.right = x + width;
rect.bottom = y + height; rect.bottom = y + height;
OffsetRect( &rect, virtual_screen_rect.left, virtual_screen_rect.top );
X11DRV_X_to_window_rect( data, &rect ); X11DRV_X_to_window_rect( data, &rect );
invalidate_dce( hwnd, &data->window_rect ); invalidate_dce( hwnd, &data->window_rect );
@ -1255,9 +1259,9 @@ void X11DRV_handle_desktop_resize( unsigned int width, unsigned int height )
screen_height = height; screen_height = height;
xinerama_init(); xinerama_init();
TRACE("desktop %p change to (%dx%d)\n", hwnd, width, height); TRACE("desktop %p change to (%dx%d)\n", hwnd, width, height);
SetRect( &rect, 0, 0, width, height );
data->lock_changes++; 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--; data->lock_changes--;
SendMessageTimeoutW( HWND_BROADCAST, WM_DISPLAYCHANGE, screen_depth, SendMessageTimeoutW( HWND_BROADCAST, WM_DISPLAYCHANGE, screen_depth,
MAKELPARAM( width, height ), SMTO_ABORTIFHUNG, 2000, NULL ); MAKELPARAM( width, height ), SMTO_ABORTIFHUNG, 2000, NULL );
@ -1295,6 +1299,7 @@ void X11DRV_ConfigureNotify( HWND hwnd, XEvent *xev )
rect.top = y; rect.top = y;
rect.right = x + event->width; rect.right = x + event->width;
rect.bottom = y + event->height; 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", 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, hwnd, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top,
event->x, event->y, event->width, event->height ); event->x, event->y, event->width, event->height );

View File

@ -106,9 +106,6 @@ static int query_screens(void)
nb_monitors = count; nb_monitors = count;
for (i = 0; i < nb_monitors; i++) 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].cbSize = sizeof( monitors[i] );
monitors[i].rcMonitor.left = screens[i].x_org; monitors[i].rcMonitor.left = screens[i].x_org;
monitors[i].rcMonitor.top = screens[i].y_org; monitors[i].rcMonitor.top = screens[i].y_org;
@ -121,11 +118,6 @@ static int query_screens(void)
} }
get_primary()->dwFlags |= MONITORINFOF_PRIMARY; 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; else count = 0;
@ -145,6 +137,7 @@ static inline int query_screens(void)
void xinerama_init(void) void xinerama_init(void)
{ {
MONITORINFOEXW *primary; MONITORINFOEXW *primary;
int i;
wine_tsx11_lock(); wine_tsx11_lock();
@ -158,8 +151,18 @@ void xinerama_init(void)
} }
primary = get_primary(); primary = get_primary();
/* coordinates (0,0) have to point to the primary monitor origin */ /* coordinates (0,0) have to point to the primary monitor origin */
OffsetRect( &virtual_screen_rect, -primary->rcMonitor.left, -primary->rcMonitor.top ); 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_width = primary->rcMonitor.right - primary->rcMonitor.left;
screen_height = primary->rcMonitor.bottom - primary->rcMonitor.top; screen_height = primary->rcMonitor.bottom - primary->rcMonitor.top;
TRACE( "virtual size: %s primary size: %dx%d\n", TRACE( "virtual size: %s primary size: %dx%d\n",