Use window manager to minimize windows

Mike McCormack mike at codeweavers.com
Fri Oct 10 13:04:52 CDT 2003


ChangeLog:
* Use window manager to minimize windows
-------------- next part --------------
Index: dlls/x11drv/winpos.c
===================================================================
RCS file: /home/wine/wine/dlls/x11drv/winpos.c,v
retrieving revision 1.68
diff -u -r1.68 winpos.c
--- dlls/x11drv/winpos.c	17 Sep 2003 04:28:28 -0000	1.68
+++ dlls/x11drv/winpos.c	9 Oct 2003 04:35:44 -0000
@@ -1215,12 +1215,44 @@
 
 
 /***********************************************************************
+ *              X11DRV_WMMinimizeWindow
+ *
+ *  See the ICCCM section 4.1.4. Changing Window State for more details.
+ *  http://tronche.com/gui/x/icccm/sec-4.html#s-4.1.4
+ */ 
+static BOOL X11DRV_WMMinimizeWindow(WND *win)
+{
+    struct x11drv_win_data *data = win->pDriverData;
+    XEvent xev;
+    
+    TRACE("%p\n", win->hwndSelf);
+
+    wine_tsx11_lock();
+
+    xev.xclient.type = ClientMessage;
+    xev.xclient.window = data->whole_window;
+    xev.xclient.message_type = XInternAtom(thread_display(),"WM_CHANGE_STATE",False);   
+    xev.xclient.serial = 0;
+    xev.xclient.display = thread_display();
+    xev.xclient.send_event = True;
+    xev.xclient.format = 32; 
+    xev.xclient.data.l[0] = IconicState;
+    xev.xclient.data.l[2] = 0;
+    XSendEvent(thread_display(), root_window, False, SubstructureNotifyMask, &xev);
+
+    wine_tsx11_unlock();
+
+    return TRUE;
+}
+
+
+/***********************************************************************
  *              ShowWindow   (X11DRV.@)
  */
 BOOL X11DRV_ShowWindow( HWND hwnd, INT cmd )
 {
     WND* 	wndPtr = WIN_FindWndPtr( hwnd );
-    BOOL 	wasVisible, showFlag;
+    BOOL 	wasVisible, showFlag, wmMinimize;
     RECT 	newPos = {0, 0, 0, 0};
     UINT 	swp = 0;
 
@@ -1231,6 +1263,17 @@
 
     wasVisible = (wndPtr->dwStyle & WS_VISIBLE) != 0;
 
+    /* check if we should request an action from the window manager */
+    wmMinimize = FALSE;
+    if (is_window_top_level(wndPtr))
+    {
+        if (cmd == SW_MINIMIZE || cmd == SW_SHOWMINIMIZED)
+        {
+            cmd = SW_RESTORE;
+            wmMinimize = TRUE;
+        }
+    }
+
     switch(cmd)
     {
         case SW_HIDE:
@@ -1335,6 +1378,9 @@
 	SendMessageA( hwnd, WM_MOVE, 0,
 		   MAKELONG(wndPtr->rectClient.left, wndPtr->rectClient.top) );
     }
+
+    if ( wmMinimize )
+        X11DRV_WMMinimizeWindow(wndPtr);
 
 END:
     WIN_ReleaseWndPtr(wndPtr);


More information about the wine-patches mailing list