xserver: Branch 'master' - 6 commits

Jeremy Huddleston jeremyhu at kemper.freedesktop.org
Wed Dec 31 12:45:56 PST 2008


 hw/xquartz/X11Application.m    |   82 +++++++++++++++++++++++++++++++----------
 hw/xquartz/darwinEvents.c      |   11 ++++-
 hw/xquartz/doc/Xquartz.man.pre |    6 +++
 hw/xquartz/quartzKeyboard.c    |   28 ++++++++++++--
 4 files changed, 101 insertions(+), 26 deletions(-)

New commits:
commit 2f361186f93a791e446c4a9471bb0c3b9b818d98
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Wed Dec 31 12:40:02 2008 -0800

    XQuartz: Don't use NX_SECONDARYFNMASK, NX_NUMERICPADMASK, NX_HELPMASK
    
    We don't have keycodes for them, so don't try to use them
    (cherry picked from commit cb912aca3a2834c4ad8e386c8a0d05c1bb31b0e7)

diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index cd5ab5c..2cebd2a 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -977,13 +977,6 @@ static inline int ensure_flag(int flags, int device_independent, int device_depe
     
     modifierFlags = [e modifierFlags];
     
-    /* These are the "only" modifier keys we care about */
-    modifierFlags &= (NX_COMMANDMASK | NX_CONTROLMASK | NX_ALTERNATEMASK | NX_SHIFTMASK |
-                      NX_SECONDARYFNMASK | NX_ALPHASHIFTMASK | NX_NUMERICPADMASK |
-                      NX_HELPMASK | NX_DEVICELCTLKEYMASK | NX_DEVICELSHIFTKEYMASK |
-                      NX_DEVICERSHIFTKEYMASK | NX_DEVICELCMDKEYMASK | NX_DEVICERCMDKEYMASK |
-                      NX_DEVICELALTKEYMASK | NX_DEVICERALTKEYMASK | NX_DEVICERCTLKEYMASK);
-    
 #ifdef NX_DEVICELCMDKEYMASK
     /* This is to workaround a bug in the VNC server where we sometimes see the L
      * modifier and sometimes see no "side"
diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index 0ecc170..9a94831 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -145,7 +145,6 @@ static void DarwinPressModifierKey(int pressed, int key) {
  */
 
 static int modifier_mask_list[] = {
-    NX_SECONDARYFNMASK, NX_NUMERICPADMASK, NX_HELPMASK,
 #ifdef NX_DEVICELCMDKEYMASK
     NX_DEVICELCTLKEYMASK, NX_DEVICERCTLKEYMASK,
     NX_DEVICELSHIFTKEYMASK, NX_DEVICERSHIFTKEYMASK,
@@ -162,6 +161,7 @@ static void DarwinUpdateModifiers(
     int flags )         // modifier flags that have changed
 {
     int *f;
+    int key;
 
     /* Capslock is special.  This mask is the state of capslock (on/off),
      * not the state of the button.  Hopefully we can find a better solution.
@@ -172,8 +172,13 @@ static void DarwinUpdateModifiers(
     }
     
     for(f=modifier_mask_list; *f; f++)
-        if(*f & flags)
-            DarwinPressModifierKey(pressed, DarwinModifierNXMaskToNXKey(*f));
+        if(*f & flags) {
+            key = DarwinModifierNXMaskToNXKey(*f);
+            if(key == -1)
+                ErrorF("DarwinUpdateModifiers: Unsupported NXMask: 0x%x\n", *f);
+            else
+                DarwinPressModifierKey(pressed, key);
+        }
 }
 
 /* Generic handler for Xquartz-specifc events.  When possible, these should
commit a2abaa9fd3a5ad713c1f946e9d7f598825ad3a84
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Wed Dec 31 11:57:49 2008 -0800

    XQuartz: Make sure to reset the saved key state when deactivating X11.app
    (cherry picked from commit 3eef78eb321f4f7dbca5a10c80666c621e28a1e0)

diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index cbf5cba..cd5ab5c 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -202,8 +202,10 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
 
         DarwinUpdateModKeys(0);
         for(i=0; i < NUM_KEYCODES; i++) {
-            if(keyState[i] == NSKeyDown)
+            if(keyState[i] == NSKeyDown) {
                 DarwinSendKeyboardEvents(KeyRelease, i);
+                keyState[i] = NSKeyUp;
+            }
         }
         
         DarwinSendDDXEvent(kXquartzDeactivate, 0);
commit 3986b683adc4f6f967cc5f643e973d89764234c7
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Wed Dec 31 12:44:43 2008 -0800

    XQuartz: Honor system key repeat rate
    (cherry picked from commit 4303c9be39a86f5a21de108f72b90a989435905e)

diff --git a/hw/xquartz/quartzKeyboard.c b/hw/xquartz/quartzKeyboard.c
index 228679a..7c9ac70 100644
--- a/hw/xquartz/quartzKeyboard.c
+++ b/hw/xquartz/quartzKeyboard.c
@@ -323,7 +323,9 @@ static void DarwinKeyboardSetDeviceKeyMap(KeySymsRec *keySyms) {
  */
 void DarwinKeyboardInit(DeviceIntPtr pDev) {
     KeySymsRec keySyms;
-	XkbComponentNamesRec names;
+    XkbComponentNamesRec names;
+    CFIndex value;
+    BOOL ok;
 
     // Open a shared connection to the HID System.
     // Note that the Event Status Driver is really just a wrapper
@@ -332,7 +334,7 @@ void DarwinKeyboardInit(DeviceIntPtr pDev) {
 
     DarwinLoadKeyboardMapping(&keySyms);
 
-	bzero(&names, sizeof(names));
+    bzero(&names, sizeof(names));
 
     /* We need to really have rules... or something... */
     //XkbSetRulesDflts("base", "pc105", "us", NULL, NULL);
@@ -342,8 +344,26 @@ void DarwinKeyboardInit(DeviceIntPtr pDev) {
                                        QuartzBell, DarwinChangeKeyboardControl));
     pthread_mutex_unlock(&keyInfo_mutex);
 
-    // TODO: What do we do now in 1.6?
-	//SwitchCoreKeyboard(pDev);   
+    /* Get our key repeat settings from GlobalPreferences */
+    (void)CFPreferencesAppSynchronize(CFSTR(".GlobalPreferences"));
+    value = CFPreferencesGetAppIntegerValue(CFSTR("InitialKeyRepeat"), CFSTR(".GlobalPreferences"), &ok);
+    if(!ok)
+        value = 35;
+
+    if(value == 300000) { // off
+        XkbSetRepeatKeys(pDev, -1, AutoRepeatModeOff);
+    } else {
+        pDev->key->xkbInfo->desc->ctrls->repeat_delay = value * 15;
+
+        value = CFPreferencesGetAppIntegerValue(CFSTR("KeyRepeat"), CFSTR(".GlobalPreferences"), &ok);
+        if(!ok)
+            value = 6;
+        pDev->key->xkbInfo->desc->ctrls->repeat_interval = value * 15;
+
+        XkbSetRepeatKeys(pDev, -1, AutoRepeatModeOn);
+    }
+	// TODO: What do we do now in 1.6?
+    //SwitchCoreKeyboard(pDev);   
 
     DarwinKeyboardSetDeviceKeyMap(&keySyms);
 }
commit 1a69d56afda082298edc76271d2cb71af00526ce
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Mon Dec 29 19:54:12 2008 -0800

    XQuartz: Better avoid stuck keys on context switches
    (cherry picked from commit e9963f1a4f4f12f253eae9d4f01694b6cabe35ad)

diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index c5e78f9..cbf5cba 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -63,6 +63,9 @@ extern BOOL xpbproxy_init (void);
 #define ProximityIn    0
 #define ProximityOut   1
 
+/* Stuck modifier / button state... force release when we context switch */
+static NSEventType keyState[NUM_KEYCODES];
+
 int X11EnableKeyEquivalents = TRUE, quartzFullscreenMenu = FALSE;
 int quartzHasRoot = FALSE, quartzEnableRootless = TRUE;
 
@@ -179,29 +182,37 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
 
 - (void) activateX:(OSX_BOOL)state {
     /* Create a TSM document that supports full Unicode input, and
-	 have it activated while X is active */
+     have it activated while X is active */
     static TSMDocumentID x11_document;
-	DEBUG_LOG("state=%d, _x_active=%d, \n", state, _x_active)
+    size_t i;
+    DEBUG_LOG("state=%d, _x_active=%d, \n", state, _x_active)
     if (state) {
-		DarwinSendDDXEvent(kXquartzActivate, 0);
+        DarwinSendDDXEvent(kXquartzActivate, 0);
 
-		if (!_x_active) {
-			if (x11_document == 0) {
-				OSType types[1];
-				types[0] = kUnicodeDocument;
-				NewTSMDocument (1, types, &x11_document, 0);
-			}
+        if (!_x_active) {
+            if (x11_document == 0) {
+                OSType types[1];
+                types[0] = kUnicodeDocument;
+                NewTSMDocument (1, types, &x11_document, 0);
+            }
 
-			if (x11_document != 0)	ActivateTSMDocument (x11_document);
-		}
+            if (x11_document != 0)	ActivateTSMDocument (x11_document);
+        }
     } else {
-		DarwinSendDDXEvent(kXquartzDeactivate, 0);
 
-		if (_x_active && x11_document != 0)
-			DeactivateTSMDocument (x11_document);
-	}
+        DarwinUpdateModKeys(0);
+        for(i=0; i < NUM_KEYCODES; i++) {
+            if(keyState[i] == NSKeyDown)
+                DarwinSendKeyboardEvents(KeyRelease, i);
+        }
+        
+        DarwinSendDDXEvent(kXquartzDeactivate, 0);
 
-	_x_active = state;
+        if (_x_active && x11_document != 0)
+            DeactivateTSMDocument (x11_document);
+    }
+
+    _x_active = state;
 }
 
 - (void) became_key:(NSWindow *)win {
@@ -1126,7 +1137,12 @@ static inline int ensure_flag(int flags, int device_independent, int device_depe
                     DarwinSendDDXEvent(kXquartzReloadKeymap, 0);
                 }
             }
-            
+
+            /* Avoid stuck keys on context switch */
+            if(keyState[[e keyCode]] == [e type])
+                return;
+            keyState[[e keyCode]] = [e type];
+
             DarwinSendKeyboardEvents(([e type] == NSKeyDown) ? KeyPress : KeyRelease, [e keyCode]);
             break;
             
commit f464b5a9164b24f74adea198bcabe9affaf5552c
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Mon Dec 29 19:38:31 2008 -0800

    XQuartz: Workaround OSX VNC server bug for modifier key state
    
    A better approach which ensures we have a L modifier key down if we are told neither are down and atleast one is down... =/
    (cherry picked from commit bc13dda345f716bf4de9bfe4e1d85969263b60c2)

diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 4c8d113..c5e78f9 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -921,6 +921,18 @@ void X11ApplicationMain (int argc, char **argv, char **envp) {
 @implementation X11Application (Private)
 extern int darwin_modifier_flags; // darwinEvents.c
 
+#ifdef NX_DEVICELCMDKEYMASK
+/* This is to workaround a bug in the VNC server where we sometimes see the L
+ * modifier and sometimes see no "side"
+ */
+static inline int ensure_flag(int flags, int device_independent, int device_dependents, int device_dependent_default) {
+    if( (flags & device_independent) &&
+       !(flags & device_dependents))
+        flags |= device_dependent_default;
+    return flags;
+}
+#endif
+
 - (void) sendX11NSEvent:(NSEvent *)e {
     NSRect screen;
     NSPoint location;
@@ -928,6 +940,7 @@ extern int darwin_modifier_flags; // darwinEvents.c
     int ev_button, ev_type;
     float pointer_x, pointer_y, pressure, tilt_x, tilt_y;
     DeviceIntPtr pDev;
+    int modifierFlags;
 
     /* convert location to be relative to top-left of primary display */
     location = [e locationInWindow];
@@ -949,12 +962,32 @@ extern int darwin_modifier_flags; // darwinEvents.c
     tilt_x = 0;
     tilt_y = 0;
     
+    modifierFlags = [e modifierFlags];
+    
+    /* These are the "only" modifier keys we care about */
+    modifierFlags &= (NX_COMMANDMASK | NX_CONTROLMASK | NX_ALTERNATEMASK | NX_SHIFTMASK |
+                      NX_SECONDARYFNMASK | NX_ALPHASHIFTMASK | NX_NUMERICPADMASK |
+                      NX_HELPMASK | NX_DEVICELCTLKEYMASK | NX_DEVICELSHIFTKEYMASK |
+                      NX_DEVICERSHIFTKEYMASK | NX_DEVICELCMDKEYMASK | NX_DEVICERCMDKEYMASK |
+                      NX_DEVICELALTKEYMASK | NX_DEVICERALTKEYMASK | NX_DEVICERCTLKEYMASK);
+    
+#ifdef NX_DEVICELCMDKEYMASK
+    /* This is to workaround a bug in the VNC server where we sometimes see the L
+     * modifier and sometimes see no "side"
+     */
+    modifierFlags = ensure_flag(modifierFlags, NX_CONTROLMASK,   NX_DEVICELCTLKEYMASK   | NX_DEVICERCTLKEYMASK,     NX_DEVICELCTLKEYMASK);
+    modifierFlags = ensure_flag(modifierFlags, NX_SHIFTMASK,     NX_DEVICELSHIFTKEYMASK | NX_DEVICERSHIFTKEYMASK,   NX_DEVICELSHIFTKEYMASK);
+    modifierFlags = ensure_flag(modifierFlags, NX_COMMANDMASK,   NX_DEVICELCMDKEYMASK   | NX_DEVICERCMDKEYMASK,     NX_DEVICELCMDKEYMASK);
+    modifierFlags = ensure_flag(modifierFlags, NX_ALTERNATEMASK, NX_DEVICELALTKEYMASK   | NX_DEVICERALTKEYMASK,     NX_DEVICELALTKEYMASK);
+#endif
+
     /* We don't receive modifier key events while out of focus, and 3button
      * emulation mucks this up, so we need to check our modifier flag state
      * on every event... ugg
      */
-    if(darwin_modifier_flags != [e modifierFlags])
-        DarwinUpdateModKeys([e modifierFlags]);
+    
+    if(darwin_modifier_flags != modifierFlags)
+        DarwinUpdateModKeys(modifierFlags);
     
 	switch ([e type]) {
 		case NSLeftMouseDown:     ev_button=1; ev_type=ButtonPress;   goto handle_mouse;
commit 3ead9aa2602cab9c883aa7bcbd2a8d82c5c88f5a
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Mon Dec 29 00:30:31 2008 -0800

    XQuartz: Updated man page fullscreen_hotkeys fullscreen_menu
    (cherry picked from commit 00f3a2e33c8e91da5f855821313a04ea97445656)

diff --git a/hw/xquartz/doc/Xquartz.man.pre b/hw/xquartz/doc/Xquartz.man.pre
index a442c96..04bbee3 100644
--- a/hw/xquartz/doc/Xquartz.man.pre
+++ b/hw/xquartz/doc/Xquartz.man.pre
@@ -32,6 +32,12 @@ Change the modifier keys used to emulate the second mouse button. By default,
 Command is used to emulate the second button. Any combination of the following
 modifier names may be used: {l,r,}shift, {l,r,}option, {l,r,}control, {l,r,}command, fn
 .TP 8
+.B defaults write org.x.X11 fullscreen_hotkeys -boolean true
+Enable OSX hotkeys while in fullscreen
+.TP 8
+.B defaults write org.x.X11 fullscreen_menu -boolean true
+Show the OSX menu while in fullscreen
+.TP 8
 .B defaults write org.x.X11 no_quit_alert -boolean true
 Disables the alert dialog displayed when attempting to quit X11.
 .TP 8


More information about the xorg-commit mailing list