xserver: Branch 'master' - 2 commits

Jeremy Huddleston jeremyhu at kemper.freedesktop.org
Fri Nov 14 11:10:26 PST 2008


 hw/xquartz/X11Application.m |  107 ++++++++++++++++++++++++--------------------
 1 file changed, 59 insertions(+), 48 deletions(-)

New commits:
commit 1d7049f8fd3c0798250b9213149d3ce0b37ab77f
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Thu Nov 13 12:45:35 2008 -0800

    Xquartz: Force sending mouse clicks to AppKit if we're over the menu bar
    (cherry picked from commit 7dff93ec1ac92aeaf3b70d5cfe787fa4a28c0dba)

diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 1ffd442..dbab365 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -221,6 +221,34 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
                         [self activateX:YES];
                 }
             }
+
+            /* We want to force sending to appkit if we're over the menu bar */
+            if(!for_appkit) {
+                NSPoint NSlocation = [e locationInWindow];
+                NSWindow *window = [e window];
+                
+                if (window != nil)	{
+                    NSRect frame = [window frame];
+                    NSlocation.x += frame.origin.x;
+                    NSlocation.y += frame.origin.y;
+                }
+
+                NSRect NSframe = [[NSScreen mainScreen] frame];
+                NSRect NSvisibleFrame = [[NSScreen mainScreen] visibleFrame];
+                
+                CGRect CGframe = CGRectMake(NSframe.origin.x, NSframe.origin.y,
+                                            NSframe.size.width, NSframe.size.height);
+                CGRect CGvisibleFrame = CGRectMake(NSvisibleFrame.origin.x,
+                                                   NSvisibleFrame.origin.y,
+                                                   NSvisibleFrame.size.width,
+                                                   NSvisibleFrame.size.height);
+                CGPoint CGlocation = CGPointMake(NSlocation.x, NSlocation.y);
+                
+                if(CGRectContainsPoint(CGframe, CGlocation) &&
+                   !CGRectContainsPoint(CGvisibleFrame, CGlocation))
+                    for_appkit = YES;
+            }
+            
             break;
             
         case NSKeyDown: case NSKeyUp:
@@ -865,32 +893,32 @@ void X11ApplicationMain (int argc, char **argv, char **envp) {
 extern int darwin_modifier_flags; // darwinEvents.c
 
 - (void) sendX11NSEvent:(NSEvent *)e {
-	NSRect screen;
-	NSPoint location;
-	NSWindow *window;
-	int ev_button, ev_type;
-	float pointer_x, pointer_y, pressure, tilt_x, tilt_y;
+    NSRect screen;
+    NSPoint location;
+    NSWindow *window;
+    int ev_button, ev_type;
+    float pointer_x, pointer_y, pressure, tilt_x, tilt_y;
     DeviceIntPtr pDev;
-    
-	/* convert location to be relative to top-left of primary display */
-	location = [e locationInWindow];
-	window = [e window];
-	screen = [[[NSScreen screens] objectAtIndex:0] frame];
-    
+
+    /* convert location to be relative to top-left of primary display */
+    location = [e locationInWindow];
+    window = [e window];
+    screen = [[[NSScreen screens] objectAtIndex:0] frame];
+
     if (window != nil)	{
-		NSRect frame = [window frame];
-		pointer_x = location.x + frame.origin.x;
-		pointer_y = (((screen.origin.y + screen.size.height)
-                      - location.y) - frame.origin.y);
-	} else {
-		pointer_x = location.x;
-		pointer_y = (screen.origin.y + screen.size.height) - location.y;
-	}
-    
+        NSRect frame = [window frame];
+        pointer_x = location.x + frame.origin.x;
+        pointer_y = (screen.origin.y + screen.size.height)
+                    - (location.y + frame.origin.y);
+    } else {
+        pointer_x = location.x;
+        pointer_y = (screen.origin.y + screen.size.height) - location.y;
+    }
+
     /* Setup our valuators.  These will range from 0 to 1 */
-	pressure = 0;
-	tilt_x = 0;
-	tilt_y = 0;
+    pressure = 0;
+    tilt_x = 0;
+    tilt_y = 0;
     
     /* 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
commit 3c124832642f1ec3228a57bea3d1eda68a188ff3
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Wed Aug 20 10:37:17 2008 -0700

    XQuartz: Made X11Application.m a little more tidy.
    (cherry picked from commit 3520386261b838196a8918e8bee16bdccbc9781d)

diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index fa7c532..1ffd442 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -70,6 +70,10 @@ X11Application *X11App;
 
 #define ALL_KEY_MASKS (NSShiftKeyMask | NSControlKeyMask | NSAlternateKeyMask | NSCommandKeyMask)
 
+ at interface X11Application (Private)
+- (void) sendX11NSEvent:(NSEvent *)e;
+ at end
+
 @implementation X11Application
 
 typedef struct message_struct message;
@@ -81,8 +85,6 @@ struct message_struct {
 
 static mach_port_t _port;
 
-static void send_nsevent(NSEvent *e);
-
 /* Quartz mode initialization routine. This is often dynamically loaded
    but is statically linked into this X server. */
 Bool QuartzModeBundleInit(void);
@@ -195,11 +197,8 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
 }
 
 - (void) sendEvent:(NSEvent *)e {
-    NSEventType type;
     OSX_BOOL for_appkit, for_x;
     
-    type = [e type];
-    
     /* By default pass down the responder chain and to X. */
     for_appkit = YES;
     for_x = YES;
@@ -322,7 +321,7 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
     
     if (for_appkit) [super sendEvent:e];
     
-    if (for_x) send_nsevent(e);
+    if (for_x) [self sendX11NSEvent:e];
 }
 
 - (void) set_window_menu:(NSArray *)list {
@@ -862,27 +861,10 @@ void X11ApplicationMain (int argc, char **argv, char **envp) {
     /* not reached */
 }
 
-/* event conversion */
-
-static inline unsigned short
-convert_flags (unsigned int nsflags) {
-    unsigned int xflags = 0;
-	
-    if (nsflags == ~0) return 0xffff;
-	
-    if (nsflags & NSAlphaShiftKeyMask)	xflags |= LockMask;
-    if (nsflags & NSShiftKeyMask)	xflags |= ShiftMask;
-    if (nsflags & NSControlKeyMask)	xflags |= ControlMask;
-    if (nsflags & NSAlternateKeyMask)	xflags |= Mod1Mask;
-    if (nsflags & NSCommandKeyMask)	xflags |= Mod2Mask;
-    /* FIXME: secondaryfn? */
-	
-    return xflags;
-}
-
+ at implementation X11Application (Private)
 extern int darwin_modifier_flags; // darwinEvents.c
 
-static void send_nsevent(NSEvent *e) {
+- (void) sendX11NSEvent:(NSEvent *)e {
 	NSRect screen;
 	NSPoint location;
 	NSWindow *window;
@@ -1047,3 +1029,4 @@ static void send_nsevent(NSEvent *e) {
         default: break; /* for gcc */
 	}	
 }
+ at end


More information about the xorg-commit mailing list