xserver: Branch 'xorg-server-1.2-apple' - 2 commits

Ben Byer bbyer at kemper.freedesktop.org
Thu Nov 15 02:41:10 PST 2007


 hw/darwin/apple/X11Controller.m |    2 --
 hw/darwin/darwin.c              |   19 +++++++++++++++++++
 hw/darwin/darwin.h              |   10 ++++++++++
 hw/darwin/darwinEvents.c        |    7 +++++++
 hw/darwin/quartz/quartz.c       |   20 ++++++++++----------
 hw/darwin/quartz/quartz.h       |    8 --------
 6 files changed, 46 insertions(+), 20 deletions(-)

New commits:
commit faab78376322f8a0d929fca07b917a0c8ae75865
Author: Ben Byer <bbyer at bbyer.local>
Date:   Thu Nov 15 02:41:07 2007 -0800

    a first stab at DEBUG_LOG

diff --git a/hw/darwin/apple/X11Controller.m b/hw/darwin/apple/X11Controller.m
index a6a75d0..df90049 100644
--- a/hw/darwin/apple/X11Controller.m
+++ b/hw/darwin/apple/X11Controller.m
@@ -54,8 +54,6 @@
 #include <sys/types.h>
 #include <sys/wait.h>
 
-#define TRACE() fprintf (stderr, "%s\n", __FUNCTION__)
-
 @implementation X11Controller
 
 - (void) awakeFromNib
diff --git a/hw/darwin/darwin.c b/hw/darwin/darwin.c
index ada29c4..789b0e2 100644
--- a/hw/darwin/darwin.c
+++ b/hw/darwin/darwin.c
@@ -667,6 +667,7 @@ void OsVendorInit(void)
 	}
 #endif
     }
+    //    DEBUG_LOG("Xquartz started at %s\n", ctime(time(NULL)));
 
     // Find the full path to the keymapping file.
     if ( darwinKeymapFile ) {
diff --git a/hw/darwin/darwinEvents.c b/hw/darwin/darwinEvents.c
index 85ae305..7984130 100644
--- a/hw/darwin/darwinEvents.c
+++ b/hw/darwin/darwinEvents.c
@@ -84,6 +84,7 @@ static void DarwinPressModifierMask(
 {
     int key = DarwinModifierNXMaskToNXKey(mask);
 
+    DEBUG_LOG("DarwinPressModifierMask(%p, %x, %d)\n", xe, mask, key);
     if (key != -1) {
         int keycode = DarwinModifierNXKeyToNXKeycode(key, 0);
         if (keycode != 0) {
@@ -127,6 +128,7 @@ static void DarwinUpdateModifiers(
     int pressed,        // KeyPress or KeyRelease
     int flags )         // modifier flags that have changed
 {
+    DEBUG_LOG("DarwinUpdateModifiers(%p, %d, %x)\n", xe, pressed, flags);
     xe->u.u.type = pressed;
     if (flags & NX_COMMANDMASK) DarwinPressModifierMask(xe, COMMAND_MASK(flags));
     if (flags & NX_CONTROLMASK) DarwinPressModifierMask(xe, CONTROL_MASK(flags));
@@ -154,6 +156,7 @@ static void DarwinReleaseModifiers(void) {
   xEvent ke;
   int i = 0, j = 0, nevents = 0; 
  
+  DEBUG_LOG("DarwinReleaseModifiers(%p)\n", darwinKeyc);
   if (!darwinKeyc) return;
   map = darwinKeyc->curKeySyms.map;
   
@@ -170,6 +173,7 @@ static void DarwinReleaseModifiers(void) {
       case XK_Kana_Lock:
 	break;
       default:
+	DEBUG_LOG("DarwinReleaseModifiers: releasing key %d\n", i);
 	  ke.u.keyButtonPointer.time = GetTimeInMillis();
 	  ke.u.keyButtonPointer.rootX = 0;
 	  ke.u.keyButtonPointer.rootY = 0;
@@ -201,6 +205,7 @@ static void DarwinSimulateMouseClick(
     int whichButton,    // mouse button to be pressed
     int modifierMask)   // modifiers used for the fake click
 {
+  DEBUG_LOG("DarwinSimulateMouseClick(%p, %d, %x)\n", xe, whichButton, modifierMask);
     // first fool X into forgetting about the keys
 	// for some reason, it's not enough to tell X we released the Command key -- 
 	// it has to be the *left* Command key.
@@ -448,6 +453,7 @@ void ProcessInputEvents(void)
                 // Update modifier state.
                 // Any amount of modifiers may have changed.
                 int flags = xe.u.clientMessage.u.l.longs0;
+		DEBUG_LOG("kxDarwinUpdateModifiers(%x, %x)\n", old_flags, flags);
                 DarwinUpdateModifiers(&xe, KeyRelease,
                                       old_flags & ~flags);
                 DarwinUpdateModifiers(&xe, KeyPress,
@@ -508,6 +514,7 @@ void ProcessInputEvents(void)
             }
 
 	    case kXDarwinDeactivate:
+	      DEBUG_LOG("kxDarwinDeactivate\n");
 	      DarwinReleaseModifiers();
 	      old_flags=0;
 	      // fall through
diff --git a/hw/darwin/quartz/quartz.c b/hw/darwin/quartz/quartz.c
index 7ba452c..fcd78ae 100644
--- a/hw/darwin/quartz/quartz.c
+++ b/hw/darwin/quartz/quartz.c
@@ -249,7 +249,7 @@ static void QuartzUpdateScreens(void)
     int x, y, width, height, sx, sy;
     xEvent e;
 
-    TRACE("QuartzUpdateScreens()\n");
+    DEBUG_LOG("QuartzUpdateScreens()\n");
     if (noPseudoramiXExtension || screenInfo.numScreens != 1)
     {
         /* FIXME: if not using Xinerama, we have multiple screens, and
@@ -414,7 +414,7 @@ void DarwinModeProcessEvent(
 {
     switch (xe->u.u.type) {
         case kXDarwinControllerNotify:
-	  TRACE("kXDarwinControllerNotify\n");
+	  DEBUG_LOG("kXDarwinControllerNotify\n");
             AppleWMSendEvent(AppleWMControllerNotify,
                              AppleWMControllerNotifyMask,
                              xe->u.clientMessage.u.l.longs0,
@@ -422,7 +422,7 @@ void DarwinModeProcessEvent(
             break;
 
         case kXDarwinPasteboardNotify:
-	  TRACE("kXDarwinPasteboardNotify\n");
+	  DEBUG_LOG("kXDarwinPasteboardNotify\n");
             AppleWMSendEvent(AppleWMPasteboardNotify,
                              AppleWMPasteboardNotifyMask,
                              xe->u.clientMessage.u.l.longs0,
@@ -430,7 +430,7 @@ void DarwinModeProcessEvent(
             break;
 
         case kXDarwinActivate:
-	  TRACE("kXDarwinActivate\n");
+	  DEBUG_LOG("kXDarwinActivate\n");
             QuartzShow(xe->u.keyButtonPointer.rootX,
                        xe->u.keyButtonPointer.rootY);
             AppleWMSendEvent(AppleWMActivationNotify,
@@ -439,7 +439,7 @@ void DarwinModeProcessEvent(
             break;
 
         case kXDarwinDeactivate:
-  	  TRACE("kXDarwinDeactivate\n");
+  	  DEBUG_LOG("kXDarwinDeactivate\n");
             AppleWMSendEvent(AppleWMActivationNotify,
                              AppleWMActivationNotifyMask,
                              AppleWMIsInactive, 0);
@@ -447,23 +447,23 @@ void DarwinModeProcessEvent(
             break;
 
         case kXDarwinDisplayChanged:
-	    TRACE("kXDarwinDisplayChanged\n");
+	    DEBUG_LOG("kXDarwinDisplayChanged\n");
             QuartzUpdateScreens();
             break;
 
         case kXDarwinWindowState:
-	  TRACE("kXDarwinWindowState\n");
+	  DEBUG_LOG("kXDarwinWindowState\n");
             RootlessNativeWindowStateChanged(xe->u.clientMessage.u.l.longs0,
 		  			     xe->u.clientMessage.u.l.longs1);
 	    break;
 	  
         case kXDarwinWindowMoved:
-	  TRACE("kXDarwinWindowMoved\n");
+	  DEBUG_LOG("kXDarwinWindowMoved\n");
             RootlessNativeWindowMoved (xe->u.clientMessage.u.l.longs0);
 	    break;
 
         case kXDarwinToggleFullscreen:
-	  TRACE("kXDarwinToggleFullscreen\n");
+	  DEBUG_LOG("kXDarwinToggleFullscreen\n");
 #ifdef DARWIN_DDX_MISSING
             if (quartzEnableRootless) QuartzSetFullscreen(!quartzHasRoot);
             else if (quartzHasRoot) QuartzHide();
@@ -499,7 +499,7 @@ void DarwinModeProcessEvent(
             break;
 
         case kXDarwinBringAllToFront:
-  	  TRACE("kXDarwinBringAllToFront\n");
+  	  DEBUG_LOG("kXDarwinBringAllToFront\n");
 	    RootlessOrderAllWindows();
             break;
 
diff --git a/hw/darwin/quartz/quartz.h b/hw/darwin/quartz/quartz.h
index febc51a..172f323 100644
--- a/hw/darwin/quartz/quartz.h
+++ b/hw/darwin/quartz/quartz.h
@@ -38,14 +38,6 @@
 #include "screenint.h"
 #include "window.h"
 
-//#define DEBUG 1
-
-#ifdef DEBUG
-#define TRACE(msg, args...) ErrorF("%s:%d: " msg, __FUNCTION__, __LINE__, ##args )
-#else
-#define TRACE(msg, args...) 
-#endif
-
 /*------------------------------------------
    Quartz display mode function types
   ------------------------------------------*/
commit b1feff2824d8da297c7553aef42b8817db376435
Author: Ben Byer <bbyer at bbyer.local>
Date:   Thu Nov 15 02:25:50 2007 -0800

    Added a lightweight debugging facility to support troubleshooting
    (for example) the stuck modifier key issue

diff --git a/hw/darwin/darwin.c b/hw/darwin/darwin.c
index f0c35f8..ada29c4 100644
--- a/hw/darwin/darwin.c
+++ b/hw/darwin/darwin.c
@@ -72,6 +72,10 @@
 #include "darwin.h"
 #include "darwinClut8.h"
 
+#ifdef ENABLE_DEBUG_LOG
+FILE *debug_log_fp = NULL;
+#endif
+
 /*
  * X server shared global variables
  */
@@ -648,6 +652,20 @@ void OsVendorInit(void)
 {
     if (serverGeneration == 1) {
         DarwinPrintBanner();
+#ifdef ENABLE_DEBUG_LOG
+	{
+	  char *home_dir=NULL, *log_file_path=NULL;
+	  home_dir = getenv("HOME");
+	  if (home_dir) asprintf(&log_file_path, "%s/%s", home_dir, DEBUG_LOG_NAME);
+	  if (log_file_path) {
+	    if (!access(log_file_path, F_OK)) {
+	      debug_log_fp = fopen(log_file_path, "a");
+	      if (debug_log_fp) ErrorF("Debug logging enabled to %s\n", log_file_path);
+	    }
+	    free(log_file_path);
+	  }
+	}
+#endif
     }
 
     // Find the full path to the keymapping file.
diff --git a/hw/darwin/darwin.h b/hw/darwin/darwin.h
index bc96bb0..25bba20 100644
--- a/hw/darwin/darwin.h
+++ b/hw/darwin/darwin.h
@@ -152,4 +152,14 @@ enum {
     kXDarwinWindowMoved       // window has moved on screen
 };
 
+#define ENABLE_DEBUG_LOG 1
+
+#ifdef ENABLE_DEBUG_LOG
+extern FILE *debug_log_fp;
+#define DEBUG_LOG_NAME "x11-debug.txt"
+#define DEBUG_LOG(msg, args...) if (debug_log_fp) fprintf(debug_log_fp, "%s:%d: " msg, __FUNCTION__, __LINE__, ##args )
+#else
+#define DEBUG_LOG(msg, args...) 
+#endif
+
 #endif  /* _DARWIN_H */


More information about the xorg-commit mailing list