xserver: Branch 'master' - 8 commits

Jeremy Huddleston jeremyhu at kemper.freedesktop.org
Fri Apr 10 00:48:40 PDT 2009


 hw/xquartz/X11Application.m     |   49 ++++++++++++++++++++++++----------------
 hw/xquartz/quartz.c             |   15 ++++++++----
 hw/xquartz/xpr/xpr.h            |   15 ++++++++++++
 hw/xquartz/xpr/xprAppleWM.c     |   29 +++++++++++++----------
 hw/xquartz/xpr/xprFrame.c       |   47 ++++++++++++++++++++++----------------
 hw/xquartz/xpr/xprScreen.c      |    3 ++
 miext/rootless/rootless.h       |    1 
 miext/rootless/rootlessWindow.c |    9 -------
 8 files changed, 104 insertions(+), 64 deletions(-)

New commits:
commit 808fd2c67f303cb721769375b11ce8b90ffc1909
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Thu Apr 9 20:00:37 2009 -0700

    XQuartz: xprSetWindowLevel updated to store the level requested by the WM
    (cherry picked from commit c28c2ddc3a8f3c5b9beec396953bb3ac9ee4714b)

diff --git a/hw/xquartz/xpr/xprAppleWM.c b/hw/xquartz/xpr/xprAppleWM.c
index b13db06..9c44e20 100644
--- a/hw/xquartz/xpr/xprAppleWM.c
+++ b/hw/xquartz/xpr/xprAppleWM.c
@@ -38,6 +38,7 @@
 
 #include "applewmExt.h"
 #include "rootless.h"
+#include "rootlessCommon.h"
 #include <Xplugin.h>
 #include <X11/X.h>
 #include "quartz.h"
@@ -49,13 +50,24 @@ static int xprSetWindowLevel(
 {
     xp_window_id wid;
     xp_window_changes wc;
+    RootlessWindowRec *winRec;
 
+    // AppleWMNumWindowLevels is allowed, but is only set by the server
+    // for the root window.
+    if (level < 0 || level >= AppleWMNumWindowLevels) {
+        return BadValue;
+    }
+    
     wid = x_cvt_vptr_to_uint(RootlessFrameForWindow (pWin, TRUE));
     if (wid == 0)
         return BadWindow;
 
     RootlessStopDrawing (pWin, FALSE);
-
+    winRec = WINREC(pWin);
+ 
+    if(!winRec)
+        return BadWindow;
+    
     if(quartzEnableRootless)
         wc.window_level = normal_window_levels[level];
     else
@@ -65,6 +77,8 @@ static int xprSetWindowLevel(
         return BadValue;
     }
 
+    winRec->level = level;
+
     return Success;
 }
 
commit dfb0d7aefbbdfc0db966e3a84d52f638135d9138
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Thu Apr 9 18:51:22 2009 -0700

    XQuartz: Update window levels when changing rootless state
    (cherry picked from commit 1359ded5bfc14a80fb998b01a54ecacb96c4ff88)

diff --git a/hw/xquartz/xpr/xprFrame.c b/hw/xquartz/xpr/xprFrame.c
index ba697ac..6635f08 100644
--- a/hw/xquartz/xpr/xprFrame.c
+++ b/hw/xquartz/xpr/xprFrame.c
@@ -162,10 +162,12 @@ xprCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen,
         mask |= XP_SHAPE;
     }
 
+    pFrame->level = !IsRoot (pWin) ? AppleWMWindowLevelNormal : AppleWMNumWindowLevels;
+
     if(quartzEnableRootless)
-        wc.window_level = normal_window_levels[!IsRoot (pWin) ? AppleWMWindowLevelNormal : AppleWMNumWindowLevels];
+        wc.window_level = normal_window_levels[pFrame->level];
     else
-        wc.window_level = rooted_window_levels[!IsRoot (pWin) ? AppleWMWindowLevelNormal : AppleWMNumWindowLevels];
+        wc.window_level = rooted_window_levels[pFrame->level];
     mask |= XP_WINDOW_LEVEL;
 
     err = xp_create_window(mask, &wc, (xp_window_id *) &pFrame->wid);
@@ -252,28 +254,36 @@ xprResizeFrame(RootlessFrameID wid, ScreenPtr pScreen,
 /*
  * Change frame stacking.
  */
-static void
-xprRestackFrame(RootlessFrameID wid, RootlessFrameID nextWid)
-{
+static void xprRestackFrame(RootlessFrameID wid, RootlessFrameID nextWid) {
     xp_window_changes wc;
+    unsigned int mask = XP_STACKING;
 
     TA_SERVER();
     
-   /* Stack frame below nextWid it if it exists, or raise
+    /* Stack frame below nextWid it if it exists, or raise
        frame above everything otherwise. */
 
-    if (nextWid == NULL)
-    {
+    if(nextWid == NULL) {
         wc.stack_mode = XP_MAPPED_ABOVE;
         wc.sibling = 0;
-    }
-    else
-    {
+    } else {
         wc.stack_mode = XP_MAPPED_BELOW;
         wc.sibling = x_cvt_vptr_to_uint(nextWid);
     }
 
-    xprConfigureWindow(x_cvt_vptr_to_uint(wid), XP_STACKING, &wc);
+    if(window_hash) {
+        RootlessWindowRec *winRec = x_hash_table_lookup(window_hash, x_cvt_uint_to_vptr((xp_window_id)wid), NULL);
+
+        if(winRec) {
+            if(quartzEnableRootless)
+                wc.window_level = normal_window_levels[winRec->level];
+            else
+                wc.window_level = rooted_window_levels[winRec->level];
+            mask |= XP_WINDOW_LEVEL;
+        }
+    }
+
+    xprConfigureWindow(x_cvt_vptr_to_uint(wid), mask, &wc);
 }
 
 
diff --git a/miext/rootless/rootless.h b/miext/rootless/rootless.h
index 5224dca..bde4cff 100644
--- a/miext/rootless/rootless.h
+++ b/miext/rootless/rootless.h
@@ -57,6 +57,7 @@ typedef struct _RootlessWindowRec {
     int x, y;
     unsigned int width, height;
     unsigned int borderWidth;
+    int level;
 
     RootlessFrameID wid;	// implementation specific frame id
     WindowPtr win;		// underlying X window
diff --git a/miext/rootless/rootlessWindow.c b/miext/rootless/rootlessWindow.c
index 7bd7f18..b173cef 100644
--- a/miext/rootless/rootlessWindow.c
+++ b/miext/rootless/rootlessWindow.c
@@ -478,6 +478,7 @@ RootlessEnsureFrame(WindowPtr pWin)
     winRec->is_reorder_pending = FALSE;
     winRec->pixmap = NULL;
     winRec->wid = NULL;
+    winRec->level = 0;
 
     SETWINREC(pWin, winRec);
 
commit d5ef88d7543ed787093099ab18db766c446b47d1
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Thu Apr 9 18:27:22 2009 -0700

    XQuartz: Fix window levels for rooted mode to allow showing the menu bar.
    (cherry picked from commit 80759a4186bf0335edc85aecea2faf11fe09f491)

diff --git a/hw/xquartz/xpr/xpr.h b/hw/xquartz/xpr/xpr.h
index a93b837..b329ca1 100644
--- a/hw/xquartz/xpr/xpr.h
+++ b/hw/xquartz/xpr/xpr.h
@@ -47,8 +47,10 @@ Bool QuartzInitCursor(ScreenPtr pScreen);
 void QuartzSuspendXCursor(ScreenPtr pScreen);
 void QuartzResumeXCursor(ScreenPtr pScreen, int x, int y);
 
-/* This lookup table came straight from the Tiger X11 source.  I tried to figure
- * it out based on CGWindowLevel.h, but I dunno... -JH
+/* If we are rooted, we need the root window and desktop levels to be below
+ * the menubar (24) but above native windows.  Normal window level is 0.
+ * Floating window level is 3.  The rest are filled in as appropriate.
+ * See CGWindowLevel.h
  */
 
 #define _APPLEWM_SERVER_
@@ -57,7 +59,7 @@ static const int normal_window_levels[AppleWMNumWindowLevels+1] = {
 0, 3, 4, 5, INT_MIN + 30, INT_MIN + 29,
 };
 static const int rooted_window_levels[AppleWMNumWindowLevels+1] = {
-202, 203, 204, 205, 201, 200
+20, 21, 22, 23, 19, 18,
 };
 
 #endif /* XPR_H */
commit 15146b863759640e7a73fab2301fb28ef4dead84
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Thu Apr 9 17:47:41 2009 -0700

    XQuartz: Properly set the window level for the root window
    (cherry picked from commit bdf9286d1cbfeaaf8eaf03d28091e91ee587ee25)

diff --git a/hw/xquartz/xpr/xpr.h b/hw/xquartz/xpr/xpr.h
index ab79a42..a93b837 100644
--- a/hw/xquartz/xpr/xpr.h
+++ b/hw/xquartz/xpr/xpr.h
@@ -47,4 +47,17 @@ Bool QuartzInitCursor(ScreenPtr pScreen);
 void QuartzSuspendXCursor(ScreenPtr pScreen);
 void QuartzResumeXCursor(ScreenPtr pScreen, int x, int y);
 
+/* This lookup table came straight from the Tiger X11 source.  I tried to figure
+ * it out based on CGWindowLevel.h, but I dunno... -JH
+ */
+
+#define _APPLEWM_SERVER_
+#include <X11/extensions/applewm.h>
+static const int normal_window_levels[AppleWMNumWindowLevels+1] = {
+0, 3, 4, 5, INT_MIN + 30, INT_MIN + 29,
+};
+static const int rooted_window_levels[AppleWMNumWindowLevels+1] = {
+202, 203, 204, 205, 201, 200
+};
+
 #endif /* XPR_H */
diff --git a/hw/xquartz/xpr/xprAppleWM.c b/hw/xquartz/xpr/xprAppleWM.c
index fb50698..b13db06 100644
--- a/hw/xquartz/xpr/xprAppleWM.c
+++ b/hw/xquartz/xpr/xprAppleWM.c
@@ -43,16 +43,6 @@
 #include "quartz.h"
 #include "x-hash.h"
 
-/* This lookup table came straight from the Tiger X11 source.  I tried to figure
- * it out based on CGWindowLevel.h, but I dunno... -JH
- */
-static const int normal_window_levels[AppleWMNumWindowLevels+1] = {
-0, 3, 4, 5, INT_MIN + 30, INT_MIN + 29,
-};
-static const int rooted_window_levels[AppleWMNumWindowLevels+1] = {
-202, 203, 204, 205, 201, 200
-};
-
 static int xprSetWindowLevel(
     WindowPtr pWin,
     int level)
@@ -66,8 +56,7 @@ static int xprSetWindowLevel(
 
     RootlessStopDrawing (pWin, FALSE);
 
-    //if (WINREC(WindowTable[pWin->drawable.pScreen->myNum]) == NULL)
-    if (quartzHasRoot)
+    if(quartzEnableRootless)
         wc.window_level = normal_window_levels[level];
     else
         wc.window_level = rooted_window_levels[level];
diff --git a/hw/xquartz/xpr/xprFrame.c b/hw/xquartz/xpr/xprFrame.c
index a45290e..ba697ac 100644
--- a/hw/xquartz/xpr/xprFrame.c
+++ b/hw/xquartz/xpr/xprFrame.c
@@ -42,6 +42,7 @@
 #include "dix.h"
 #include <X11/Xatom.h>
 #include "windowstr.h"
+#include "quartz.h"
 
 #include "threadSafety.h"
 
@@ -161,6 +162,12 @@ xprCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen,
         mask |= XP_SHAPE;
     }
 
+    if(quartzEnableRootless)
+        wc.window_level = normal_window_levels[!IsRoot (pWin) ? AppleWMWindowLevelNormal : AppleWMNumWindowLevels];
+    else
+        wc.window_level = rooted_window_levels[!IsRoot (pWin) ? AppleWMWindowLevelNormal : AppleWMNumWindowLevels];
+    mask |= XP_WINDOW_LEVEL;
+
     err = xp_create_window(mask, &wc, (xp_window_id *) &pFrame->wid);
 
     if (err != Success)
diff --git a/miext/rootless/rootlessWindow.c b/miext/rootless/rootlessWindow.c
index 5ce26bd..7bd7f18 100644
--- a/miext/rootless/rootlessWindow.c
+++ b/miext/rootless/rootlessWindow.c
@@ -48,8 +48,6 @@ extern int darwinMainScreenX, darwinMainScreenY;
 #endif
 #include "fb.h"
 
-#define AppleWMNumWindowLevels 5
-
 #include "rootlessCommon.h"
 #include "rootlessWindow.h"
 
@@ -105,12 +103,6 @@ current_time_in_seconds (void)
   return t;
   } */
 
-static inline Bool
-rootlessHasRoot (ScreenPtr pScreen)
-{
-  return WINREC (WindowTable[pScreen->myNum]) != NULL;
-}
-
 void
 RootlessNativeWindowStateChanged (WindowPtr pWin, unsigned int state)
 {
commit 8d5dcfe2154f217bd8fde5509d78f3383add8725
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Thu Apr 9 04:36:26 2009 -0700

    XQuartz: Properly set the menu bar and hotkey state when changing rootless mode.
    
    Currently no code path exhibits the broken behavior since we only toggle into rootless if we don't have the root.
    (cherry picked from commit 970f100ca3c5fc0662ae7658d49d118fbd9de943)

diff --git a/hw/xquartz/quartz.c b/hw/xquartz/quartz.c
index 0de63b6..344edec 100644
--- a/hw/xquartz/quartz.c
+++ b/hw/xquartz/quartz.c
@@ -352,13 +352,20 @@ void QuartzSetRootless(Bool state) {
     /* When in rootless, the menubar is not part of the screen, so we need to update our screens on toggle */    
     QuartzUpdateScreens();
 
-    if (!quartzEnableRootless && !quartzHasRoot) {
-        RootlessHideAllWindows();
-    } else if (quartzEnableRootless && !quartzHasRoot) {
-        RootlessShowAllWindows();
+    if(!quartzHasRoot) {
+        if(!quartzEnableRootless) {
+            RootlessHideAllWindows();
+        } else {
+            RootlessShowAllWindows();
+        }
     }
 
+    X11ApplicationShowHideMenubar(!quartzHasRoot);
+
     xp_reenable_update();
+
+    if (!quartzEnableRootless && quartzFullscreenDisableHotkeys)
+        xp_disable_hot_keys(quartzHasRoot);
 }
 
 /*
commit 82d7cf5cdcbc5e451a87f8c2f64cd5d2e3627d54
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Thu Apr 9 03:55:13 2009 -0700

    XQuartz: In rooted mode, make sure we start in the hidden state.
    (cherry picked from commit 5ecc497f71c2133f773f6c56ad76cb778862ddd6)

diff --git a/hw/xquartz/xpr/xprScreen.c b/hw/xquartz/xpr/xprScreen.c
index da262f6..1fac9ec 100644
--- a/hw/xquartz/xpr/xprScreen.c
+++ b/hw/xquartz/xpr/xprScreen.c
@@ -256,6 +256,9 @@ xprDisplayInit(void)
 
     AppleDRIExtensionInit();
     xprAppleWMInit();
+
+    if (!quartzEnableRootless)
+        RootlessHideAllWindows();
 }
 
 /*
commit e86f4e93020d56385418850a9eebae8076dcb9ac
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Mon Apr 6 21:34:14 2009 -0700

    XQuartz: Send MotionNotify before button presses when X11 is in the background
    (cherry picked from commit c80d0ec18ef5b842447d31360406d0b5b9424222)

diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 937517c..4417481 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -1054,8 +1054,7 @@ static inline int ensure_flag(int flags, int device_independent, int device_depe
                  * NSTabletProximityEventSubtype will come from NSTabletPoint
                  * rather than NSMouseMoved.
                 pressure = [e pressure];
-                tilt_x   = [e tilt].x;
-                tilt_y   = [e tilt].y;
+                tilt     = [e tilt];
                 pDev = darwinTabletCurrent;                
                  */
 
@@ -1071,6 +1070,7 @@ static inline int ensure_flag(int flags, int device_independent, int device_depe
             }
 
             if(!quartzServerVisible && noTestExtensions) {
+                if(ev_button == 0) {
 #if 0
 /* Seems this has somehow triggered 100% CPU usage while X11.app is in the
  * background on some obscure HW configurations.
@@ -1078,28 +1078,29 @@ static inline int ensure_flag(int flags, int device_independent, int device_depe
  */
 //#if defined(XPLUGIN_VERSION) && XPLUGIN_VERSION > 0
 /* Older libXplugin (Tiger/"Stock" Leopard) aren't thread safe, so we can't call xp_find_window from the Appkit thread */
-                xp_window_id wid;
-                xp_error e;
+                    xp_window_id wid = 0;
+                    xp_error e;
 
-                /* Sigh. Need to check that we're really over one of
-                 * our windows. (We need to receive pointer events while
-                 * not in the foreground, but we don't want to receive them
-                 * when another window is over us or we might show a tooltip)
-                 */
+                    /* Sigh. Need to check that we're really over one of
+                     * our windows. (We need to receive pointer events while
+                     * not in the foreground, but we don't want to receive them
+                     * when another window is over us or we might show a tooltip)
+                     */
 
-                wid = 0;
-                e = xp_find_window(location.x, location.y, 0, &wid);
+                    e = xp_find_window(location.x, location.y, 0, &wid);
 
-                if (e == XP_Success && wid == 0) {
-                    bgMouseLocation = location;
-                    return;
-                }
-#else
-                bgMouseLocation = location;
-                return;
+                    if (e == XP_Success && wid == 0)
 #endif
+                    {
+                        bgMouseLocation = location;
+                        return;
+                    }
+                } else {
+                    DarwinSendPointerEvents(pDev, MotionNotify, 0, location.x,
+                                            location.y, pressure, tilt.x, tilt.y);
+                }
             }
-            
+
             DarwinSendPointerEvents(pDev, ev_type, ev_button, location.x, location.y,
                                     pressure, tilt.x, tilt.y);
             
@@ -1125,6 +1126,16 @@ static inline int ensure_flag(int flags, int device_independent, int device_depe
             break;
             
 		case NSScrollWheel:
+//#if !defined(XPLUGIN_VERSION) || XPLUGIN_VERSION == 0
+#if 1 /* Strange 100% CPU issue, so always enabling.  see above */
+            /* If we're in the background, we need to send a MotionNotify event
+             * first, since we aren't getting them on background mouse motion
+             */
+            if(!quartzServerVisible && noTestExtensions) {
+                DarwinSendPointerEvents(darwinPointer, MotionNotify, 0, location.x,
+                                        location.y, pressure, tilt.x, tilt.y);
+            }
+#endif
 			DarwinSendScrollEvents([e deltaX], [e deltaY], location.x, location.y,
                                    pressure, tilt.x, tilt.y);
             break;
commit 5ccfad8df099e8ebc4bf2dd53c3db1460903b135
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Mon Apr 6 19:21:46 2009 -0700

    XQuartz: Revert most of the previous override redirect patch
    
    The changes actually caused all windows to move to the current space.  Instead, we're going with a fix entirely within Xplugin that depends on quartz-wm being the window-manager for now.
    (cherry picked from commit 997b6f3142c622541bb5bac98652abae75d1101d)

diff --git a/hw/xquartz/xpr/xprFrame.c b/hw/xquartz/xpr/xprFrame.c
index a7fc3a9..a45290e 100644
--- a/hw/xquartz/xpr/xprFrame.c
+++ b/hw/xquartz/xpr/xprFrame.c
@@ -257,22 +257,12 @@ xprRestackFrame(RootlessFrameID wid, RootlessFrameID nextWid)
 
     if (nextWid == NULL)
     {
-#if defined(XPLUGIN_VERSION) && XPLUGIN_VERSION >= 3
-        WindowPtr pWin = xprGetXWindow((xp_window_id)wid);
-        wc.stack_mode = (pWin && pWin->overrideRedirect) ? XP_MAPPED_ABOVE_CURRENT_SPACE : XP_MAPPED_ABOVE;
-#else
         wc.stack_mode = XP_MAPPED_ABOVE;
-#endif
         wc.sibling = 0;
     }
     else
     {
-#if defined(XPLUGIN_VERSION) && XPLUGIN_VERSION >= 3
-        WindowPtr pWin = xprGetXWindow((xp_window_id)wid);
-        wc.stack_mode = (pWin && pWin->overrideRedirect) ? XP_MAPPED_BELOW_CURRENT_SPACE : XP_MAPPED_BELOW;
-#else
         wc.stack_mode = XP_MAPPED_BELOW;
-#endif
         wc.sibling = x_cvt_vptr_to_uint(nextWid);
     }
 


More information about the xorg-commit mailing list