Commit d7cd4413 authored by Alexandre Julliard's avatar Alexandre Julliard

winex11: Use the stored coordinates to convert back from X11 to window rectangle.

parent 34119228
...@@ -1077,17 +1077,13 @@ static BOOL X11DRV_ConfigureNotify( HWND hwnd, XEvent *xev ) ...@@ -1077,17 +1077,13 @@ static BOOL X11DRV_ConfigureNotify( HWND hwnd, XEvent *xev )
} }
else pos = root_to_virtual_screen( x, y ); else pos = root_to_virtual_screen( x, y );
rect.left = pos.x; X11DRV_X_to_window_rect( data, &rect, pos.x, pos.y, event->width, event->height );
rect.top = pos.y; if (root_coords) MapWindowPoints( 0, parent, (POINT *)&rect, 2 );
rect.right = pos.x + event->width;
rect.bottom = pos.y + event->height;
TRACE( "win %p/%lx new X rect %d,%d,%dx%d (event %d,%d,%dx%d)\n", TRACE( "win %p/%lx new X rect %d,%d,%dx%d (event %d,%d,%dx%d)\n",
hwnd, data->whole_window, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, hwnd, data->whole_window, 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 );
X11DRV_X_to_window_rect( data, &rect );
if (root_coords) MapWindowPoints( 0, parent, (POINT *)&rect, 2 );
/* Compare what has changed */ /* Compare what has changed */
x = rect.left; x = rect.left;
...@@ -1155,7 +1151,8 @@ static BOOL X11DRV_GravityNotify( HWND hwnd, XEvent *xev ) ...@@ -1155,7 +1151,8 @@ static BOOL X11DRV_GravityNotify( HWND hwnd, XEvent *xev )
{ {
XGravityEvent *event = &xev->xgravity; XGravityEvent *event = &xev->xgravity;
struct x11drv_win_data *data = get_win_data( hwnd ); struct x11drv_win_data *data = get_win_data( hwnd );
RECT rect, window_rect; RECT window_rect;
int x, y;
if (!data) return FALSE; if (!data) return FALSE;
...@@ -1165,22 +1162,18 @@ static BOOL X11DRV_GravityNotify( HWND hwnd, XEvent *xev ) ...@@ -1165,22 +1162,18 @@ static BOOL X11DRV_GravityNotify( HWND hwnd, XEvent *xev )
return FALSE; return FALSE;
} }
rect.left = event->x; x = event->x + data->window_rect.left - data->whole_rect.left;
rect.top = event->y; y = event->y + data->window_rect.top - data->whole_rect.top;
rect.right = rect.left + data->whole_rect.right - data->whole_rect.left;
rect.bottom = rect.top + data->whole_rect.bottom - data->whole_rect.top;
TRACE( "win %p/%lx new X rect %d,%d,%dx%d (event %d,%d)\n", TRACE( "win %p/%lx new X pos %d,%d (event %d,%d)\n",
hwnd, data->whole_window, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, hwnd, data->whole_window, x, y, event->x, event->y );
event->x, event->y );
X11DRV_X_to_window_rect( data, &rect );
window_rect = data->window_rect; window_rect = data->window_rect;
release_win_data( data ); release_win_data( data );
if (window_rect.left != rect.left || window_rect.top != rect.top) if (window_rect.left != x || window_rect.top != y)
SetWindowPos( hwnd, 0, rect.left, rect.top, 0, 0, SetWindowPos( hwnd, 0, x, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOCOPYBITS );
SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOCOPYBITS );
return TRUE; return TRUE;
} }
......
...@@ -306,33 +306,6 @@ static unsigned long get_mwm_decorations( struct x11drv_win_data *data, ...@@ -306,33 +306,6 @@ static unsigned long get_mwm_decorations( struct x11drv_win_data *data,
/*********************************************************************** /***********************************************************************
* get_x11_rect_offset
*
* Helper for X11DRV_window_to_X_rect and X11DRV_X_to_window_rect.
*/
static void get_x11_rect_offset( struct x11drv_win_data *data, RECT *rect )
{
DWORD style, ex_style, style_mask = 0, ex_style_mask = 0;
unsigned long decor;
rect->top = rect->bottom = rect->left = rect->right = 0;
style = GetWindowLongW( data->hwnd, GWL_STYLE );
ex_style = GetWindowLongW( data->hwnd, GWL_EXSTYLE );
decor = get_mwm_decorations( data, style, ex_style );
if (decor & MWM_DECOR_TITLE) style_mask |= WS_CAPTION;
if (decor & MWM_DECOR_BORDER)
{
style_mask |= WS_DLGFRAME | WS_THICKFRAME;
ex_style_mask |= WS_EX_DLGMODALFRAME;
}
AdjustWindowRectEx( rect, style & style_mask, FALSE, ex_style & ex_style_mask );
}
/***********************************************************************
* get_window_attributes * get_window_attributes
* *
* Fill the window attributes structure for an X window. * Fill the window attributes structure for an X window.
...@@ -1185,12 +1158,26 @@ void make_window_embedded( struct x11drv_win_data *data ) ...@@ -1185,12 +1158,26 @@ void make_window_embedded( struct x11drv_win_data *data )
*/ */
static void X11DRV_window_to_X_rect( struct x11drv_win_data *data, RECT *rect ) static void X11DRV_window_to_X_rect( struct x11drv_win_data *data, RECT *rect )
{ {
DWORD style, ex_style, style_mask = 0, ex_style_mask = 0;
unsigned long decor;
RECT rc; RECT rc;
if (!data->managed) return; if (!data->managed) return;
if (IsRectEmpty( rect )) return; if (IsRectEmpty( rect )) return;
get_x11_rect_offset( data, &rc ); style = GetWindowLongW( data->hwnd, GWL_STYLE );
ex_style = GetWindowLongW( data->hwnd, GWL_EXSTYLE );
decor = get_mwm_decorations( data, style, ex_style );
if (decor & MWM_DECOR_TITLE) style_mask |= WS_CAPTION;
if (decor & MWM_DECOR_BORDER)
{
style_mask |= WS_DLGFRAME | WS_THICKFRAME;
ex_style_mask |= WS_EX_DLGMODALFRAME;
}
SetRectEmpty( &rc );
AdjustWindowRectEx( &rc, style & style_mask, FALSE, ex_style & ex_style_mask );
rect->left -= rc.left; rect->left -= rc.left;
rect->right -= rc.right; rect->right -= rc.right;
...@@ -1206,21 +1193,15 @@ static void X11DRV_window_to_X_rect( struct x11drv_win_data *data, RECT *rect ) ...@@ -1206,21 +1193,15 @@ static void X11DRV_window_to_X_rect( struct x11drv_win_data *data, RECT *rect )
* *
* Opposite of X11DRV_window_to_X_rect * Opposite of X11DRV_window_to_X_rect
*/ */
void X11DRV_X_to_window_rect( struct x11drv_win_data *data, RECT *rect ) void X11DRV_X_to_window_rect( struct x11drv_win_data *data, RECT *rect, int x, int y, int cx, int cy )
{ {
RECT rc; x += data->window_rect.left - data->whole_rect.left;
y += data->window_rect.top - data->whole_rect.top;
if (!data->managed) return; cx += (data->window_rect.right - data->window_rect.left) -
if (IsRectEmpty( rect )) return; (data->whole_rect.right - data->whole_rect.left);
cy += (data->window_rect.bottom - data->window_rect.top) -
get_x11_rect_offset( data, &rc ); (data->whole_rect.bottom - data->whole_rect.top);
SetRect( rect, x, y, x + cx, y + cy );
rect->left += rc.left;
rect->right += rc.right;
rect->top += rc.top;
rect->bottom += rc.bottom;
if (rect->top >= rect->bottom) rect->bottom = rect->top + 1;
if (rect->left >= rect->right) rect->right = rect->left + 1;
} }
...@@ -1531,8 +1512,6 @@ static void create_whole_window( struct x11drv_win_data *data ) ...@@ -1531,8 +1512,6 @@ static void create_whole_window( struct x11drv_win_data *data )
mask = get_window_attributes( data, &attr ); mask = get_window_attributes( data, &attr );
data->whole_rect = data->window_rect;
X11DRV_window_to_X_rect( data, &data->whole_rect );
if (!(cx = data->whole_rect.right - data->whole_rect.left)) cx = 1; if (!(cx = data->whole_rect.right - data->whole_rect.left)) cx = 1;
else if (cx > 65535) cx = 65535; else if (cx > 65535) cx = 65535;
if (!(cy = data->whole_rect.bottom - data->whole_rect.top)) cy = 1; if (!(cy = data->whole_rect.bottom - data->whole_rect.top)) cy = 1;
...@@ -2517,11 +2496,7 @@ UINT CDECL X11DRV_ShowWindow( HWND hwnd, INT cmd, RECT *rect, UINT swp ) ...@@ -2517,11 +2496,7 @@ UINT CDECL X11DRV_ShowWindow( HWND hwnd, INT cmd, RECT *rect, UINT swp )
&root, &x, &y, &width, &height, &border, &depth ); &root, &x, &y, &width, &height, &border, &depth );
XTranslateCoordinates( thread_data->display, data->whole_window, root, 0, 0, &x, &y, &top ); XTranslateCoordinates( thread_data->display, data->whole_window, root, 0, 0, &x, &y, &top );
pos = root_to_virtual_screen( x, y ); pos = root_to_virtual_screen( x, y );
rect->left = pos.x; X11DRV_X_to_window_rect( data, rect, pos.x, pos.y, width, height );
rect->top = pos.y;
rect->right = pos.x + width;
rect->bottom = pos.y + height;
X11DRV_X_to_window_rect( data, rect );
swp &= ~(SWP_NOMOVE | SWP_NOCLIENTMOVE | SWP_NOSIZE | SWP_NOCLIENTSIZE); swp &= ~(SWP_NOMOVE | SWP_NOCLIENTMOVE | SWP_NOSIZE | SWP_NOCLIENTSIZE);
done: done:
......
...@@ -633,7 +633,7 @@ typedef int (*x11drv_error_callback)( Display *display, XErrorEvent *event, void ...@@ -633,7 +633,7 @@ typedef int (*x11drv_error_callback)( Display *display, XErrorEvent *event, void
extern void X11DRV_expect_error( Display *display, x11drv_error_callback callback, void *arg ) DECLSPEC_HIDDEN; extern void X11DRV_expect_error( Display *display, x11drv_error_callback callback, void *arg ) DECLSPEC_HIDDEN;
extern int X11DRV_check_error(void) DECLSPEC_HIDDEN; 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 void X11DRV_X_to_window_rect( struct x11drv_win_data *data, RECT *rect, int x, int y, int cx, int cy ) DECLSPEC_HIDDEN;
extern POINT virtual_screen_to_root( INT x, INT y ) 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 POINT root_to_virtual_screen( INT x, INT y ) DECLSPEC_HIDDEN;
extern RECT get_virtual_screen_rect(void) DECLSPEC_HIDDEN; extern RECT get_virtual_screen_rect(void) DECLSPEC_HIDDEN;
......
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