winex11.drv: Only set MWM hints if they have not been modified

Scott Talbert talbert at techie.net
Mon Jun 13 23:33:02 CDT 2011


Hello,

The below patch resolves an issue (BZ# 27473) where the window manager 
removes window decorations and Wine restores them.  The code in the patch 
checks to see whether the window decorations have been modified and if so,
it does not modify them further.

Regards,
Scott Talbert

---
  dlls/winex11.drv/window.c |   29 ++++++++++++++++++++++++++---
  dlls/winex11.drv/x11drv.h |    2 ++
  2 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c
index 6a87afc..8258d3a 100644
--- a/dlls/winex11.drv/window.c
+++ b/dlls/winex11.drv/window.c
@@ -1132,6 +1132,11 @@ static void set_wm_hints( Display *display, struct x11drv_win_data *data )
      MwmHints mwm_hints;
      DWORD style, ex_style;
      HWND owner;
+    Atom type = None;
+    int format;
+    unsigned long nitems;
+    unsigned long bytes_after;
+    MwmHints* my_data = NULL;

      if (data->hwnd == GetDesktopWindow())
      {
@@ -1176,9 +1181,27 @@ static void set_wm_hints( Display *display, struct x11drv_win_data *data )
          if (style & WS_SYSMENU)     mwm_hints.functions |= MWM_FUNC_CLOSE;
      }

-    XChangeProperty( display, data->whole_window, x11drv_atom(_MOTIF_WM_HINTS),
-                     x11drv_atom(_MOTIF_WM_HINTS), 32, PropModeReplace,
-                     (unsigned char*)&mwm_hints, sizeof(mwm_hints)/sizeof(long) );
+    /* Only set the MWM hints if they have not been modified by someone else.
+       This prevents interfering with the window manager which may be changing them. */
+    XGetWindowProperty( display, 
+			data->whole_window,
+			x11drv_atom(_MOTIF_WM_HINTS), 0, sizeof (MwmHints)/sizeof (long),
+			False, AnyPropertyType, &type, &format, &nitems,
+			&bytes_after, (unsigned char **)&my_data );
+
+    if ((!my_data) || ((my_data) && (my_data->flags == data->mwm_hints.flags) 
+		       && (my_data->decorations == data->mwm_hints.decorations)
+		       && (my_data->functions == data->mwm_hints.functions)))
+      {
+        XChangeProperty( display, data->whole_window, x11drv_atom(_MOTIF_WM_HINTS),
+			 x11drv_atom(_MOTIF_WM_HINTS), 32, PropModeReplace,
+			 (unsigned char*)&mwm_hints, sizeof(mwm_hints)/sizeof(long) );
+	data->mwm_hints.flags = mwm_hints.flags;
+	data->mwm_hints.decorations = mwm_hints.decorations;
+	data->mwm_hints.functions = mwm_hints.functions;
+      }
+    if (my_data)
+      XFree(my_data);

      /* wm hints */
      if (data->wm_hints)
diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h
index 5a5d109..7067e69 100644
--- a/dlls/winex11.drv/x11drv.h
+++ b/dlls/winex11.drv/x11drv.h
@@ -60,6 +60,7 @@ typedef int Status;
  #include "winuser.h"
  #include "ddrawi.h"
  #include "wine/list.h"
+#include "mwm.h"

  #define MAX_PIXELFORMATS 8
  #define MAX_DASHLEN 16
@@ -796,6 +797,7 @@ struct x11drv_win_data
      unsigned long configure_serial; /* serial number of last configure request */
      HBITMAP     hWMIconBitmap;
      HBITMAP     hWMIconMask;
+    MwmHints    mwm_hints;      /* current setting of the MWM hints */
  };

  extern struct x11drv_win_data *X11DRV_get_win_data( HWND hwnd ) DECLSPEC_HIDDEN;
-- 
1.7.4.1




More information about the wine-patches mailing list