From 22a54e46176c9cbdfaaa59ef33a6ae6a9c4969ef Mon Sep 17 00:00:00 2001
From: Jeremy Huddleston <jeremyhu@freedesktop.org>
Date: Tue, 21 Oct 2008 09:07:08 -0700
Subject: [PATCH 11/16] XQuartz: More fullscreen fixes
   Start in rooted mode when enabled
   Make the hotkey cmd-alt-a behave

---
 hw/xquartz/X11Application.m |   19 +++++++++++--------
 hw/xquartz/darwin.c         |    3 ---
 hw/xquartz/quartz.c         |    3 +--
 hw/xquartz/quartzCommon.h   |    1 -
 4 files changed, 12 insertions(+), 14 deletions(-)

diff --git hw/xquartz/X11Application.m hw/xquartz/X11Application.m
index 5df3a08..c1dee43 100644
--- hw/xquartz/X11Application.m
+++ hw/xquartz/X11Application.m
@@ -231,18 +231,12 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
                 
                 if([e type] == NSKeyDown) {
                     /* Before that though, see if there are any global
-                     shortcuts bound to it. */
+                     * shortcuts bound to it. */
 
                     if(darwinAppKitModMask & [e modifierFlags]) {
                         /* Override to force sending to Appkit */
                         swallow_up = [e keyCode];
                         for_x = NO;
-                    } else if(!quartzEnableRootless
-                              && ([e modifierFlags] & ALL_KEY_MASKS) == (NSCommandKeyMask | NSAlternateKeyMask)
-                              && ([e keyCode] == 0 /*a*/ || [e keyCode] == 53 /*Esc*/)) {
-                        swallow_up = [e keyCode];
-                        for_x = NO;
-                        DarwinSendDDXEvent(kXquartzToggleFullscreen, 0);
 #if XPLUGIN_VERSION >= 1
                     } else if(X11EnableKeyEquivalents &&
                               xp_is_symbolic_hotkey_event([e eventRef])) {
@@ -251,16 +245,25 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
 #endif
                     } else if(X11EnableKeyEquivalents &&
                               [[self mainMenu] performKeyEquivalent:e]) {
+                        swallow_up = [e keyCode];
                         for_appkit = NO;
+                        for_x = NO;
+                    } else if(!quartzEnableRootless
+                              && ([e modifierFlags] & ALL_KEY_MASKS) == (NSCommandKeyMask | NSAlternateKeyMask)
+                              && ([e keyCode] == 0 /*a*/ || [e keyCode] == 53 /*Esc*/)) {
+                        /* We have this here to force processing fullscreen 
+                         * toggle even if X11EnableKeyEquivalents is disabled */
                         swallow_up = [e keyCode];
                         for_x = NO;
+                        for_appkit = NO;
+                        DarwinSendDDXEvent(kXquartzToggleFullscreen, 0);
                     } else {
                         /* No kit window is focused, so send it to X. */
                         for_appkit = NO;
                     }
                 } else { /* KeyUp */
                     /* If we saw a key equivalent on the down, don't pass
-                     the up through to X. */
+                     * the up through to X. */
                     
                     if (swallow_up != 0 && [e keyCode] == swallow_up) {
                         swallow_up = 0;
diff --git hw/xquartz/darwin.c hw/xquartz/darwin.c
index 890fb6f..277881f 100644
--- hw/xquartz/darwin.c
+++ hw/xquartz/darwin.c
@@ -822,9 +822,6 @@ void ddxUseMsg( void )
 void ddxGiveUp( void )
 {
     ErrorF( "Quitting Xquartz...\n" );
-
-    //if (!quartzRootless)
-    //    quartzProcs->ReleaseScreens();
 }
 
 
diff --git hw/xquartz/quartz.c hw/xquartz/quartz.c
index 8032705..fe87ebb 100644
--- hw/xquartz/quartz.c
+++ hw/xquartz/quartz.c
@@ -68,11 +68,10 @@
 
 // Shared global variables for Quartz modes
 int                     quartzEventWriteFD = -1;
-int                     quartzRootless = -1;
 int                     quartzUseSysBeep = 0;
 int                     quartzUseAGL = 1;
 int                     quartzEnableKeyEquivalents = 1;
-int                     quartzServerVisible = TRUE;
+int                     quartzServerVisible = FALSE;
 int                     quartzServerQuitting = FALSE;
 int                     quartzScreenIndex = 0;
 int                     aquaMenuBarHeight = 0;
diff --git hw/xquartz/quartzCommon.h hw/xquartz/quartzCommon.h
index 5371d29..4bbc144 100644
--- hw/xquartz/quartzCommon.h
+++ hw/xquartz/quartzCommon.h
@@ -54,7 +54,6 @@ typedef struct {
 extern int              quartzEventWriteFD;
 
 // User preferences used by Quartz modes
-extern int              quartzRootless;
 extern int              quartzUseSysBeep;
 extern int              focusOnNewWindow;
 extern int              quartzUseAGL;
-- 
1.6.1

