Alexandre Julliard : winex11: Fetch the current X window position on ShowWindow resulting from a window manager event .

Alexandre Julliard julliard at winehq.org
Thu Jul 31 07:17:47 CDT 2008


Module: wine
Branch: master
Commit: 31b4061c9b0b9b960346f047c3d7afa9afe092f4
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=31b4061c9b0b9b960346f047c3d7afa9afe092f4

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Thu Jul 31 11:40:49 2008 +0200

winex11: Fetch the current X window position on ShowWindow resulting from a window manager event.

This ensures that we get the correct size for maximized windows too,
which cannot be done with SetWindowPlacement.

---

 dlls/winex11.drv/event.c          |   27 +----------------------
 dlls/winex11.drv/window.c         |   42 +++++++++++++++++++++++++++++++++++++
 dlls/winex11.drv/winex11.drv.spec |    1 +
 3 files changed, 44 insertions(+), 26 deletions(-)

diff --git a/dlls/winex11.drv/event.c b/dlls/winex11.drv/event.c
index accd6b4..d54b5bb 100644
--- a/dlls/winex11.drv/event.c
+++ b/dlls/winex11.drv/event.c
@@ -883,34 +883,9 @@ static void handle_wm_state_notify( struct x11drv_win_data *data, XPropertyEvent
 
     if (data->iconic && data->wm_state == NormalState)  /* restore window */
     {
-        int x, y;
-        unsigned int width, height, border, depth;
-        Window root, top;
-        WINDOWPLACEMENT wp;
-        RECT rect;
-
-        /* FIXME: hack */
-        wine_tsx11_lock();
-        XGetGeometry( event->display, data->whole_window, &root, &x, &y, &width, &height,
-                        &border, &depth );
-        XTranslateCoordinates( event->display, data->whole_window, root, 0, 0, &x, &y, &top );
-        wine_tsx11_unlock();
-        rect.left   = x;
-        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 );
-
-        wp.length = sizeof(wp);
-        GetWindowPlacement( data->hwnd, &wp );
-        wp.flags = 0;
-        wp.showCmd = SW_RESTORE;
-        wp.rcNormalPosition = rect;
-
         TRACE( "restoring win %p/%lx\n", data->hwnd, data->whole_window );
         data->iconic = FALSE;
-        SetWindowPlacement( data->hwnd, &wp );
+        ShowWindow( data->hwnd, SW_RESTORE );
     }
     else if (!data->iconic && data->wm_state == IconicState)
     {
diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c
index a45f04b..3143765 100644
--- a/dlls/winex11.drv/window.c
+++ b/dlls/winex11.drv/window.c
@@ -2056,6 +2056,48 @@ void X11DRV_WindowPosChanged( HWND hwnd, HWND insert_after, UINT swp_flags,
 }
 
 
+/***********************************************************************
+ *           ShowWindow   (X11DRV.@)
+ */
+UINT X11DRV_ShowWindow( HWND hwnd, INT cmd, RECT *rect, UINT swp )
+{
+    int x, y;
+    unsigned int width, height, border, depth;
+    Window root, top;
+    DWORD style = GetWindowLongW( hwnd, GWL_STYLE );
+    struct x11drv_thread_data *thread_data = x11drv_thread_data();
+    struct x11drv_win_data *data = X11DRV_get_win_data( hwnd );
+
+    if (!data || !data->whole_window || !data->managed || !data->mapped || data->iconic) return swp;
+    if (style & WS_MINIMIZE) return swp;
+
+    /* only fetch the new rectangle if the ShowWindow was a result of a window manager event */
+
+    if (!thread_data->current_event || thread_data->current_event->xany.window != data->whole_window)
+        return swp;
+
+    if (thread_data->current_event->type != ConfigureNotify &&
+        thread_data->current_event->type != PropertyNotify)
+        return swp;
+
+    TRACE( "win %p/%lx cmd %d at %s flags %08x\n",
+           hwnd, data->whole_window, cmd, wine_dbgstr_rect(rect), swp );
+
+    wine_tsx11_lock();
+    XGetGeometry( thread_data->display, data->whole_window,
+                  &root, &x, &y, &width, &height, &border, &depth );
+    XTranslateCoordinates( thread_data->display, data->whole_window, root, 0, 0, &x, &y, &top );
+    wine_tsx11_unlock();
+    rect->left   = x;
+    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 );
+    return swp & ~(SWP_NOMOVE | SWP_NOCLIENTMOVE | SWP_NOSIZE | SWP_NOCLIENTSIZE);
+}
+
+
 /**********************************************************************
  *		SetWindowIcon (X11DRV.@)
  *
diff --git a/dlls/winex11.drv/winex11.drv.spec b/dlls/winex11.drv/winex11.drv.spec
index 5dbe40f..cacc5b9 100644
--- a/dlls/winex11.drv/winex11.drv.spec
+++ b/dlls/winex11.drv/winex11.drv.spec
@@ -111,6 +111,7 @@
 @ cdecl SetWindowRgn(long long long) X11DRV_SetWindowRgn
 @ cdecl SetWindowStyle(ptr long) X11DRV_SetWindowStyle
 @ cdecl SetWindowText(long wstr) X11DRV_SetWindowText
+@ cdecl ShowWindow(long long ptr long) X11DRV_ShowWindow
 @ cdecl SysCommand(long long long) X11DRV_SysCommand
 @ cdecl WindowMessage(long long long long) X11DRV_WindowMessage
 @ cdecl WindowPosChanging(long long long ptr ptr ptr) X11DRV_WindowPosChanging




More information about the wine-cvs mailing list