xserver: Branch 'xorg-server-1.4-apple' - 5 commits

Ben Byer bbyer at kemper.freedesktop.org
Thu Apr 17 02:32:02 PDT 2008


 hw/xquartz/X11Application.m |    2 
 hw/xquartz/darwin.c         |   11 --
 hw/xquartz/darwinEvents.c   |  187 ++++++++++++++++++++++----------------------
 hw/xquartz/darwinEvents.h   |    2 
 hw/xquartz/darwinKeyboard.c |   11 --
 5 files changed, 101 insertions(+), 112 deletions(-)

New commits:
commit 19872a6aeb8ee9cb0e33e4b4ffd794c9dbefe0cf
Author: Ben Byer <bbyer at apple.com>
Date:   Thu Apr 17 02:31:53 2008 -0700

    oops, missed a spot

diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index bb2a97d..37a66f7 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -459,7 +459,7 @@ void DarwinSendScrollEvents(float count_x, float count_y,
 		ErrorF("DarwinSendScrollEvents called before darwinEvents was initialized\n");
 		return;
 	}
-	ErrorF("scroll(%f, %f)\n", count_x, count_y);
+
 	int sign_x = count_x > 0.0f ? SCROLLWHEELLEFTFAKE : SCROLLWHEELRIGHTFAKE;
 	int sign_y = count_y > 0.0f ? SCROLLWHEELUPFAKE : SCROLLWHEELDOWNFAKE;
 	count_x = fabs(count_x);
commit 769acd29348abf9e5b0bebfca6ae695d345f3077
Author: Ben Byer <bbyer at apple.com>
Date:   Thu Apr 17 02:30:36 2008 -0700

    formatting cleanup

diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index c4ba146..bb2a97d 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -324,16 +324,12 @@ Bool DarwinEQInit(DevicePtr pKbd, DevicePtr pPtr) {
  */
 void ProcessInputEvents(void) {
     xEvent  xe;
-    // button number and modifier mask of currently pressed fake button
-    input_check_flag=0;
+	int x = sizeof(xe);
 
-    //    ErrorF("calling mieqProcessInputEvents\n");
     mieqProcessInputEvents();
 
     // Empty the signaling pipe
-    int x = sizeof(xe);
     while (x == sizeof(xe)) {
-//      DEBUG_LOG("draining pipe\n");
       x = read(darwinEventReadFD, &xe, sizeof(xe));
     }
 }
@@ -341,23 +337,23 @@ void ProcessInputEvents(void) {
 /* Sends a null byte down darwinEventWriteFD, which will cause the
    Dispatch() event loop to check out event queue */
 void DarwinPokeEQ(void) {
-  char nullbyte=0;
-  input_check_flag++;
-  //  <daniels> bushing: oh, i ... er ... christ.
-  write(darwinEventWriteFD, &nullbyte, 1);
+	char nullbyte=0;
+	input_check_flag++;
+	//  <daniels> oh, i ... er ... christ.
+	write(darwinEventWriteFD, &nullbyte, 1);
 }
 
 void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int pointer_y, 
 			     float pressure, float tilt_x, float tilt_y) {
-  static int darwinFakeMouseButtonDown = 0;
-  static int darwinFakeMouseButtonMask = 0;
-  int i, num_events;
+	static int darwinFakeMouseButtonDown = 0;
+	static int darwinFakeMouseButtonMask = 0;
+	int i, num_events;
 
 	if(!darwinEvents) {
 		ErrorF("DarwinSendPointerEvents called before darwinEvents was initialized\n");
 		return;
 	}
-  /* I can't find a spec for this, but at least GTK expects that tablets are
+	/* I can't find a spec for this, but at least GTK expects that tablets are
      just like mice, except they have either one or three extra valuators, in this
      order:
      
@@ -366,91 +362,92 @@ void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int poin
      we can't do that.  Again, GTK seems to record the min/max of each valuator,
      and then perform scaling back to float itself using that info. Soo.... */
 
-  int valuators[5] = {pointer_x, pointer_y, 
+	int valuators[5] = {pointer_x, pointer_y, 
 		      pressure * INT32_MAX * 1.0f, 
 		      tilt_x * INT32_MAX * 1.0f, 
 		      tilt_y * INT32_MAX * 1.0f};
 
-  if (ev_type == ButtonPress && darwinFakeButtons && ev_button == 1) {
-    // Mimic multi-button mouse with modifier-clicks
-    // If both sets of modifiers are pressed,
-    // button 2 is clicked.
-    if ((old_flags & darwinFakeMouse2Mask) == darwinFakeMouse2Mask) {
-      DarwinSimulateMouseClick(pointer_x, pointer_y, pressure, 
+	if (ev_type == ButtonPress && darwinFakeButtons && ev_button == 1) {
+		// Mimic multi-button mouse with modifier-clicks
+		// If both sets of modifiers are pressed,
+		// button 2 is clicked.
+		if ((old_flags & darwinFakeMouse2Mask) == darwinFakeMouse2Mask) {
+			DarwinSimulateMouseClick(pointer_x, pointer_y, pressure, 
 			       tilt_x, tilt_y, 2, darwinFakeMouse2Mask);
-      darwinFakeMouseButtonDown = 2;
-      darwinFakeMouseButtonMask = darwinFakeMouse2Mask;
-      return;
-    } else if ((old_flags & darwinFakeMouse3Mask) == darwinFakeMouse3Mask) {
-      DarwinSimulateMouseClick(pointer_x, pointer_y, pressure, 
+			darwinFakeMouseButtonDown = 2;
+			darwinFakeMouseButtonMask = darwinFakeMouse2Mask;
+			return;
+		} else if ((old_flags & darwinFakeMouse3Mask) == darwinFakeMouse3Mask) {
+			DarwinSimulateMouseClick(pointer_x, pointer_y, pressure, 
 			       tilt_x, tilt_y, 3, darwinFakeMouse3Mask);
-      darwinFakeMouseButtonDown = 3;
-      darwinFakeMouseButtonMask = darwinFakeMouse3Mask;
-      return;
-    }
-  }
-  if (ev_type == ButtonRelease && darwinFakeButtons && darwinFakeMouseButtonDown) {
-    // If last mousedown was a fake click, don't check for
-    // mouse modifiers here. The user may have released the
-    // modifiers before the mouse button.
-    ev_button = darwinFakeMouseButtonDown;
-    darwinFakeMouseButtonDown = 0;
-    // Bring modifiers back up to date
-    DarwinUpdateModifiers(KeyPress, darwinFakeMouseButtonMask & old_flags);
-    darwinFakeMouseButtonMask = 0;
-    return;
-  } 
-
-  num_events = GetPointerEvents(darwinEvents, darwinPointer, ev_type, ev_button, 
+			darwinFakeMouseButtonDown = 3;
+			darwinFakeMouseButtonMask = darwinFakeMouse3Mask;
+			return;
+		}
+	}
+
+	if (ev_type == ButtonRelease && darwinFakeButtons && darwinFakeMouseButtonDown) {
+		// If last mousedown was a fake click, don't check for
+		// mouse modifiers here. The user may have released the
+		// modifiers before the mouse button.
+		ev_button = darwinFakeMouseButtonDown;
+		darwinFakeMouseButtonDown = 0;
+		// Bring modifiers back up to date
+		DarwinUpdateModifiers(KeyPress, darwinFakeMouseButtonMask & old_flags);
+		darwinFakeMouseButtonMask = 0;
+		return;
+	} 
+
+	num_events = GetPointerEvents(darwinEvents, darwinPointer, ev_type, ev_button, 
 				POINTER_ABSOLUTE, 0, 5, valuators);
       
-  for(i=0; i<num_events; i++) mieqEnqueue (darwinPointer,&darwinEvents[i]);
-  DarwinPokeEQ();
+	for(i=0; i<num_events; i++) mieqEnqueue (darwinPointer,&darwinEvents[i]);
+	DarwinPokeEQ();
 }
 
 void DarwinSendKeyboardEvents(int ev_type, int keycode) {
-  int i, num_events;
+	int i, num_events;
 	if(!darwinEvents) {
 		ErrorF("DarwinSendKeyboardEvents called before darwinEvents was initialized\n");
 		return;
 	}
 
-  if (old_flags == 0 && darwinSyncKeymap && darwinKeymapFile == NULL) {
-    /* See if keymap has changed. */
+	if (old_flags == 0 && darwinSyncKeymap && darwinKeymapFile == NULL) {
+		/* See if keymap has changed. */
 
-    static unsigned int last_seed;
-    unsigned int this_seed;
+		static unsigned int last_seed;
+		unsigned int this_seed;
 
-    this_seed = QuartzSystemKeymapSeed();
-    if (this_seed != last_seed) {
-		last_seed = this_seed;
-		DarwinSendDDXEvent(kXquartzReloadKeymap, 0);
-    }
-  }
+		this_seed = QuartzSystemKeymapSeed();
+		if (this_seed != last_seed) {
+			last_seed = this_seed;
+			DarwinSendDDXEvent(kXquartzReloadKeymap, 0);
+		}
+	}
 
-  num_events = GetKeyboardEvents(darwinEvents, darwinKeyboard, ev_type, keycode + MIN_KEYCODE);
-  for(i=0; i<num_events; i++) mieqEnqueue(darwinKeyboard,&darwinEvents[i]);
-  DarwinPokeEQ();
+	num_events = GetKeyboardEvents(darwinEvents, darwinKeyboard, ev_type, keycode + MIN_KEYCODE);
+	for(i=0; i<num_events; i++) mieqEnqueue(darwinKeyboard,&darwinEvents[i]);
+	DarwinPokeEQ();
 }
 
 void DarwinSendProximityEvents(int ev_type, int pointer_x, int pointer_y, 
 			       float pressure, float tilt_x, float tilt_y) {
-  int i, num_events;
-  int valuators[5] = {pointer_x, pointer_y, 
+	int i, num_events;
+	int valuators[5] = {pointer_x, pointer_y, 
 		      pressure * INT32_MAX * 1.0f, 
 		      tilt_x * INT32_MAX * 1.0f, 
 		      tilt_y * INT32_MAX * 1.0f};
 
-  if(!darwinEvents) {
+	if(!darwinEvents) {
 		ErrorF("DarwinSendProximityvents called before darwinEvents was initialized\n");
 		return;
-}
+	}
 
-  num_events = GetProximityEvents(darwinEvents, darwinPointer, ev_type,
+	num_events = GetProximityEvents(darwinEvents, darwinPointer, ev_type,
 				0, 5, valuators);
       
-  for(i=0; i<num_events; i++) mieqEnqueue (darwinPointer,&darwinEvents[i]);
-  DarwinPokeEQ();
+	for(i=0; i<num_events; i++) mieqEnqueue (darwinPointer,&darwinEvents[i]);
+	DarwinPokeEQ();
 }
 
 
@@ -485,9 +482,9 @@ void DarwinSendScrollEvents(float count_x, float count_y,
 /* Send the appropriate KeyPress/KeyRelease events to GetKeyboardEvents to
    reflect changing modifier flags (alt, control, meta, etc) */
 void DarwinUpdateModKeys(int flags) {
-  DarwinUpdateModifiers(KeyRelease, old_flags & ~flags);
-  DarwinUpdateModifiers(KeyPress, ~old_flags & flags);
-  old_flags = flags;
+	DarwinUpdateModifiers(KeyRelease, old_flags & ~flags);
+	DarwinUpdateModifiers(KeyPress, ~old_flags & flags);
+	old_flags = flags;
 }
 
 
commit f04f3af86a91d0cafbc86a0d71aeb0599d685f07
Author: Ben Byer <bbyer at apple.com>
Date:   Thu Apr 17 02:21:33 2008 -0700

    delete debugging spew

diff --git a/hw/xquartz/darwinKeyboard.c b/hw/xquartz/darwinKeyboard.c
index baf38f1..e29ba5d 100644
--- a/hw/xquartz/darwinKeyboard.c
+++ b/hw/xquartz/darwinKeyboard.c
@@ -731,14 +731,6 @@ static void DarwinBuildModifierMaps(darwinKeyboardInfo *info) {
  *  it to an equivalent X keyboard map and modifier map.
  */
 static void DarwinLoadKeyboardMapping(KeySymsRec *keySyms) {
-  void* callstack[128];
-  int i, frames = backtrace(callstack, 128);
-  char** strs = backtrace_symbols(callstack, frames);
-  for (i = 0; i < frames; ++i) {
-    ErrorF("%s\n", strs[i]);
-  }
-  free(strs);
-
     memset(keyInfo.keyMap, 0, sizeof(keyInfo.keyMap));
 
     /* TODO: Clean this up
commit f525a4a432ebd0545ad1dd0a7ad84ad3e47e8b61
Author: Ben Byer <bbyer at apple.com>
Date:   Thu Apr 17 02:21:11 2008 -0700

    add support for horizontal scrolling (buttons 6 and 7)

diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 2ac8a8c..726ddb4 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -903,7 +903,7 @@ static void send_nsevent (NSEventType type, NSEvent *e) {
 		break;
 
 		case NSScrollWheel:
-			DarwinSendScrollEvents([e deltaY], pointer_x, pointer_y,
+			DarwinSendScrollEvents([e deltaX], [e deltaY], pointer_x, pointer_y,
 				pressure, tilt_x, tilt_y);
 		break;
 
diff --git a/hw/xquartz/darwin.c b/hw/xquartz/darwin.c
index e397795..2232cf5 100644
--- a/hw/xquartz/darwin.c
+++ b/hw/xquartz/darwin.c
@@ -337,7 +337,7 @@ static int DarwinMouseProc(
     DeviceIntPtr    pPointer,
     int             what )
 {
-    CARD8 map[6];
+  CARD8 map[8] = {0, 1, 2, 3, 4, 5, 6, 7};
 
     switch (what) {
 
@@ -345,15 +345,10 @@ static int DarwinMouseProc(
             pPointer->public.on = FALSE;
 
             // Set button map.
-            map[1] = 1;
-            map[2] = 2;
-            map[3] = 3;
-            map[4] = 4;
-            map[5] = 5;
-            InitPointerDeviceStruct( (DevicePtr)pPointer, map, 5,
+              InitPointerDeviceStruct( (DevicePtr)pPointer, map, 7,
 				     GetMotionHistory,
 				     (PtrCtrlProcPtr)NoopDDA,
-				     GetMotionHistorySize(), 5);
+				     GetMotionHistorySize(), 7);
 	    InitProximityClassDeviceStruct( (DevicePtr)pPointer);
             break;
 
diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index 70dfdaf..c4ba146 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -1,7 +1,7 @@
 /*
 Darwin event queue and event handling
 
-Copyright 2007 Apple Inc.
+Copyright 2007-2008 Apple Inc.
 Copyright 2004 Kaleb S. KEITHLEY. All Rights Reserved.
 Copyright (c) 2002-2004 Torrey T. Lyons. All Rights Reserved.
 
@@ -56,6 +56,12 @@ in this Software without prior written authorization from The Open Group.
 #include <unistd.h>
 #include <IOKit/hidsystem/IOLLEvent.h>
 
+/* Fake button press/release for scroll wheel move. */
+#define SCROLLWHEELUPFAKE    4
+#define SCROLLWHEELDOWNFAKE  5
+#define SCROLLWHEELLEFTFAKE  6
+#define SCROLLWHEELRIGHTFAKE 7
+
 #define _APPLEWM_SERVER_
 #include "applewmExt.h"
 #include <X11/extensions/applewm.h>
@@ -65,10 +71,6 @@ in this Software without prior written authorization from The Open Group.
 #include "rootlessWindow.h"
 WindowPtr xprGetXWindow(xp_window_id wid);
 
-/* Fake button press/release for scroll wheel move. */
-#define SCROLLWHEELUPFAKE   4
-#define SCROLLWHEELDOWNFAKE 5
-
 int input_check_zero, input_check_flag;
 
 static int old_flags = 0;  // last known modifier state
@@ -452,30 +454,32 @@ void DarwinSendProximityEvents(int ev_type, int pointer_x, int pointer_y,
 }
 
 
-/* Send the appropriate number of button 4 / 5 clicks to emulate scroll wheel */
-void DarwinSendScrollEvents(float count, int pointer_x, int pointer_y, 
-			    float pressure, float tilt_x, float tilt_y) {
-  int i;
-  int ev_button = count > 0.0f ? 4 : 5;
-  int valuators[5] = {pointer_x, pointer_y, 
-		      pressure * INT32_MAX * 1.0f, 
-		      tilt_x * INT32_MAX * 1.0f, 
-		      tilt_y * INT32_MAX * 1.0f};
-
+/* Send the appropriate number of button clicks to emulate scroll wheel */
+void DarwinSendScrollEvents(float count_x, float count_y, 
+							int pointer_x, int pointer_y, 
+			    			float pressure, float tilt_x, float tilt_y) {
 	if(!darwinEvents) {
 		ErrorF("DarwinSendScrollEvents called before darwinEvents was initialized\n");
 		return;
 	}
-
-  for (count = fabs(count); count > 0.0; count = count - 1.0f) {
-    int num_events = GetPointerEvents(darwinEvents, darwinPointer, ButtonPress, ev_button, 
-				      POINTER_ABSOLUTE, 0, 5, valuators);
-    for(i=0; i<num_events; i++) mieqEnqueue(darwinPointer,&darwinEvents[i]);
-    num_events = GetPointerEvents(darwinEvents, darwinPointer, ButtonRelease, ev_button, 
-				      POINTER_ABSOLUTE, 0, 5, valuators);
-    for(i=0; i<num_events; i++) mieqEnqueue(darwinPointer,&darwinEvents[i]);
-  }
-  DarwinPokeEQ();
+	ErrorF("scroll(%f, %f)\n", count_x, count_y);
+	int sign_x = count_x > 0.0f ? SCROLLWHEELLEFTFAKE : SCROLLWHEELRIGHTFAKE;
+	int sign_y = count_y > 0.0f ? SCROLLWHEELUPFAKE : SCROLLWHEELDOWNFAKE;
+	count_x = fabs(count_x);
+	count_y = fabs(count_y);
+	
+	while ((count_x > 0.0f) || (count_y > 0.0f)) {
+		if (count_x > 0.0f) {
+			DarwinSendPointerEvents(ButtonPress, sign_x, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
+			DarwinSendPointerEvents(ButtonRelease, sign_x, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
+			count_x = count_x - 1.0f;
+		}
+		if (count_y > 0.0f) {
+			DarwinSendPointerEvents(ButtonPress, sign_y, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
+			DarwinSendPointerEvents(ButtonRelease, sign_y, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
+			count_y = count_y - 1.0f;
+		}
+	}
 }
 
 /* Send the appropriate KeyPress/KeyRelease events to GetKeyboardEvents to
diff --git a/hw/xquartz/darwinEvents.h b/hw/xquartz/darwinEvents.h
index 7c56be9..98426d6 100644
--- a/hw/xquartz/darwinEvents.h
+++ b/hw/xquartz/darwinEvents.h
@@ -38,7 +38,7 @@ void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int poin
 void DarwinSendProximityEvents(int ev_type, int pointer_x, int pointer_y, 
 			       float pressure, float tilt_x, float tilt_y);
 void DarwinSendKeyboardEvents(int ev_type, int keycode);
-void DarwinSendScrollEvents(float count, int pointer_x, int pointer_y,
+void DarwinSendScrollEvents(float count_x, float count_y, int pointer_x, int pointer_y,
 			    float pressure, float tilt_x, float tilt_y);
 void DarwinUpdateModKeys(int flags);
 
commit ab662c736e0654e2b4347091f0d9e87f26034216
Author: Ben Byer <bbyer at apple.com>
Date:   Thu Apr 17 01:32:56 2008 -0700

    enable keyboard map debugging -- it's going to x11-debug.txt, anyway ... so no harm

diff --git a/hw/xquartz/darwinKeyboard.c b/hw/xquartz/darwinKeyboard.c
index 8186af2..baf38f1 100644
--- a/hw/xquartz/darwinKeyboard.c
+++ b/hw/xquartz/darwinKeyboard.c
@@ -62,7 +62,7 @@
 
 // Define this to get a diagnostic output to stderr which is helpful
 // in determining how the X server is interpreting the Darwin keymap.
-// #define DUMP_DARWIN_KEYMAP
+#define DUMP_DARWIN_KEYMAP
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -222,6 +222,7 @@ static int const NUM_KEYPAD = sizeof(normal_to_keypad) / sizeof(normal_to_keypad
 
 static void DarwinChangeKeyboardControl( DeviceIntPtr device, KeybdCtrl *ctrl )
 {
+	// FIXME: to be implemented
     // keyclick, bell volume / pitch, autorepead, LED's
 }
 


More information about the xorg-commit mailing list