winex11.drv: Handle PropertyNotify/_NET_WM_STATE, detect a maximized window state

Dmitry Timoshkov dmitry at codeweavers.com
Fri May 2 05:14:48 CDT 2008


Hello,

this patch is based on an old code Mike McCormack has created for Crossover.

Changelog:
    winex11.drv: Handle PropertyNotify/_NET_WM_STATE, detect a maximized
    window state.
---
 dlls/winex11.drv/event.c |   37 ++++++++++++++++++++++++++++++++++++-
 1 files changed, 36 insertions(+), 1 deletions(-)

diff --git a/dlls/winex11.drv/event.c b/dlls/winex11.drv/event.c
index 36aa088..ce1f7cb 100644
--- a/dlls/winex11.drv/event.c
+++ b/dlls/winex11.drv/event.c
@@ -804,6 +804,7 @@ static int get_window_wm_state( Display *display, struct x11drv_win_data *data )
         CARD32 state;
         XID     icon;
     } *state;
+    Atom *wm_state;
     Atom type;
     int format, ret = -1;
     unsigned long count, remaining;
@@ -817,6 +818,33 @@ static int get_window_wm_state( Display *display, struct x11drv_win_data *data )
             ret = state->state;
         XFree( state );
     }
+
+    if (ret == NormalState &&
+        !XGetWindowProperty( display, data->whole_window, x11drv_atom(_NET_WM_STATE), 0,
+                             32, False, AnyPropertyType,
+                             &type, &format, &count, &remaining, (unsigned char **)&wm_state ))
+    {
+
+        if (type != None && get_property_size( format, count ) >= sizeof(*wm_state))
+        {
+            BOOL vmax = FALSE, hmax = FALSE;
+            long i;
+
+            TRACE("count %ld, remaining %ld, prop size %d\n",
+                  count, remaining, get_property_size( format, count ));
+
+            for (i = 0; i < count; i++)
+            {
+                if (wm_state[i] == x11drv_atom(_NET_WM_STATE_MAXIMIZED_VERT))
+                    vmax = TRUE;
+                else if (wm_state[i] == x11drv_atom(_NET_WM_STATE_MAXIMIZED_HORZ))
+                    hmax = TRUE;
+            }
+            TRACE("_NET_WIN_STATE vmax %d hmax %d\n", vmax, hmax);
+            if (vmax && hmax) ret = ZoomState;
+        }
+        XFree( wm_state );
+    }
     wine_tsx11_unlock();
     return ret;
 }
@@ -887,6 +915,12 @@ static void handle_wm_state_notify( struct x11drv_win_data *data, XPropertyEvent
         data->iconic = TRUE;
         ShowWindow( data->hwnd, SW_MINIMIZE );
     }
+    else if (data->wm_state == ZoomState)
+    {
+        TRACE( "maximizing win %p/%lx\n", data->hwnd, data->whole_window );
+        data->iconic = FALSE;
+        ShowWindow( data->hwnd, SW_MAXIMIZE );
+    }
 }
 
 
@@ -901,7 +935,8 @@ static void X11DRV_PropertyNotify( HWND hwnd, XEvent *xev )
     if (!hwnd) return;
     if (!(data = X11DRV_get_win_data( hwnd ))) return;
 
-    if (event->atom == x11drv_atom(WM_STATE)) handle_wm_state_notify( data, event, TRUE );
+    if (event->atom == x11drv_atom(WM_STATE) || event->atom == x11drv_atom(_NET_WM_STATE))
+        handle_wm_state_notify( data, event, TRUE );
 }
 
 
-- 
1.5.5.1






More information about the wine-patches mailing list