From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winex11.drv/event.c | 38 +++++++++++++++++++++++++++++++++++++- dlls/winex11.drv/x11drv.h | 1 + 2 files changed, 38 insertions(+), 1 deletion(-)
diff --git a/dlls/winex11.drv/event.c b/dlls/winex11.drv/event.c index 41d486c8922..2b857340c78 100644 --- a/dlls/winex11.drv/event.c +++ b/dlls/winex11.drv/event.c @@ -200,6 +200,21 @@ void host_window_release( struct host_window *win ) } }
+static POINT host_window_map_point( struct host_window *win, int x, int y ) +{ + POINT pos = {x, y}; + + if (!win) return pos; + while (win->parent) + { + pos.x += win->rect.left; + pos.y += win->rect.top; + win = win->parent; + } + + return pos; +} + static unsigned int find_host_window_child( struct host_window *win, Window child ) { unsigned int i; @@ -217,6 +232,7 @@ static struct host_window *find_host_window( Window window, BOOL create ) struct x11drv_thread_data *data = x11drv_thread_data(); Window xparent = 0, xroot, *xchildren; struct host_window *win; + XWindowAttributes attr; unsigned int nchildren;
LIST_FOR_EACH_ENTRY( win, &data->host_windows, struct host_window, entry ) @@ -228,14 +244,17 @@ static struct host_window *find_host_window( Window window, BOOL create ) if (window != root_window) { X11DRV_expect_error( data->display, host_window_error, NULL ); + if (!XGetWindowAttributes( data->display, window, &attr )) memset( &attr, 0, sizeof(attr) ); if (!XQueryTree( data->display, window, &xroot, &xparent, &xchildren, &nchildren )) xparent = root_window; else XFree( xchildren ); if (X11DRV_check_error()) WARN( "window %lx already destroyed\n", window );
host_window_reparent( &win->parent, xparent, win->window ); + SetRect( &win->rect, attr.x, attr.y, attr.x + attr.width, attr.y + attr.height ); }
- TRACE( "created host window %p/%lx, parent %lx\n", win, win->window, xparent ); + TRACE( "created host window %p/%lx, parent %lx rect %s\n", win, win->window, + xparent, wine_dbgstr_rect(&win->rect) ); list_add_tail( &data->host_windows, &win->entry ); return win; } @@ -280,6 +299,23 @@ static BOOL host_window_filter_event( XEvent *event ) host_window_reparent( &win->parent, reparent->parent, win->window ); break; } + case GravityNotify: + { + XGravityEvent *gravity = (XGravityEvent *)event; + OffsetRect( &win->rect, gravity->x - win->rect.left, gravity->y - win->rect.top ); + TRACE( "host window %p/%lx GravityNotify, rect %s\n", win, win->window, wine_dbgstr_rect(&win->rect) ); + break; + } + case ConfigureNotify: + { + XConfigureEvent *configure = (XConfigureEvent *)event; + POINT offset = {0}; + SetRect( &win->rect, configure->x, configure->y, configure->x + configure->width, configure->y + configure->height ); + if (configure->send_event) offset = host_window_map_point( win->parent, 0, 0 ); + OffsetRect( &win->rect, -offset.x, -offset.y ); + TRACE( "host window %p/%lx ConfigureNotify, rect %s\n", win, win->window, wine_dbgstr_rect(&win->rect) ); + break; + } }
/* keep processing the event for foreign windows */ diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index fc5ab81f282..3518f005f6c 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -367,6 +367,7 @@ struct host_window struct list entry; LONG refcount; Window window; + RECT rect; /* host window rect, relative to parent */ struct host_window *parent; unsigned int children_count; struct { Window window; } *children;