debugging
authorClaus Gittinger <cg@exept.de>
Mon, 04 Feb 2013 17:27:46 +0100
changeset 6003 2a2de0c8e157
parent 6002 3773c70bed6a
child 6004 7f78335fa58a
debugging
WinWorkstation.st
--- a/WinWorkstation.st	Sun Feb 03 22:07:03 2013 +0100
+++ b/WinWorkstation.st	Mon Feb 04 17:27:46 2013 +0100
@@ -547,7 +547,7 @@
 
 #ifdef DEBUG
 # define PRINTF(x)              { console_printf x;}
-# define CPRINTF(x)             { if (__debug__ > 1) console_printf x;}
+# define CPRINTF(x)             { if (__debug__ % 1) console_printf x;}
 # define RESPRINTF(x)           /*{ if (__debug__) console_printf x;}*/
 # define RES1PRINTF(x)          /*{ if (__debug__) console_printf x;}*/
 # define RES_BMP_PRINTF(x)      /*{ if (__debug__) console_printf x;}*/
@@ -555,10 +555,11 @@
 # define DPRINTF(x)             { if (__debug__) console_printf x;}
 # define NDPRINTF(x)            { if (__debugNative__) console_printf x;}
 # define NDPRINTF2(x)           { if (__debugNative__ > 1) console_printf x;}
-# define DDPRINTF(x)            { if (__debug__ > 1) console_printf x;}
-# define BMDPRINTF(x)           { if (__debug__ > 1) console_printf x;}
-# define EVENT_PRINTF(x)        { if (__debug__) console_printf x;}
-# define EVENT_PRINTF2(x)       { if (__debug__ > 1) console_printf x;}
+# define DDPRINTF(x)            { if (__debug__ & 2) console_printf x;}
+# define DDDPRINTF(x)           { if (__debug__ & 4) console_printf x;}
+# define BMDPRINTF(x)           { if (__debug__ & 2) console_printf x;}
+# define EVENT_PRINTF(x)        { if (__debug__ & 8) console_printf x;}
+# define EVENT_PRINTF2(x)       { if (__debug__ & 4) console_printf x;}
 # define EVENT_PRINTF3(x)       /* */
 # define DPRINTFIF(flag, x)                 { if (flag) console_printf x;}
 # define EVENT_PRINTFIF(flag, x)            { if (flag && __debug__) console_printf x;}
@@ -575,6 +576,7 @@
 # define NDPRINTF(x)            /* */
 # define NDPRINTF2(x)           /* */
 # define DDPRINTF(x)            /* */
+# define DDDPRINTF(x)           /* */
 # define BMDPRINTF(x)           /* */
 # define EVENT_PRINTF(x)        /* */
 # define EVENT_PRINTF2(x)       /* */
@@ -950,6 +952,8 @@
 static int __debug_WM_COPYDATA__ = 0;
 static int __debug_WM_DROPFILES__ = 0;
 static int __debug_WM_SHOWWINDOW__ = 0;
+static int __debug_WM_SETCURSOR__ = 0;
+static int __debug_WM_FOCUS__ = 0;
 
 static int __debugNative__ = 0;
 static int __depth;
@@ -2813,7 +2817,7 @@
 		     */
 		    return 0;
 		}
-		DDPRINTF(("WM_SETCURSOR\n"));
+		DPRINTFIF(__debug_WM_SETCURSOR__ , ("WM_SETCURSOR\n"));
 		curs = GetWindow_Cursor(hWnd);
 		if (curs) {
 		    SetCursor(curs);
@@ -3167,7 +3171,7 @@
 	    break;
 
 	case WM_SHOWWINDOW:
-	    DPRINTFIF(__debug_WM_SHOWWINDOW__ , ("WM_SHOWWINDOW\n"));
+	    DPRINTFIF(__debug_WM_SHOWWINDOW__ , ("WM_SHOWWINDOW h=%x\n", hWnd));
 	    enqEvent(0, hWnd, message, wParam, 0, 0, 0, 0, EV_NOTIME);
 	    if (isNative) {
 		NDPRINTF(("WM_SHOWWINDOW for native - default handling\n"));
@@ -3577,7 +3581,7 @@
 			}
 			__currentPointerView = hWnd;
 		    }
-		    DDPRINTF(("MouseMove %x\n", __currentPointerView));
+		    DPRINTFIF(__debug_WM_MOUSEMOVE__ , ("MouseMove %x\n", __currentPointerView));
 		} else {
 		    CPRINTF(("MouseMove Capture %x\n", __currentPointerView));
 		}
@@ -3608,12 +3612,15 @@
 	    return 0;
 
 	case WM_LBUTTONUP:
+	    DPRINTFIF(__debug_WM_BUTTONUP__ , ("WM_LBUTTONUP h=%x\n", hWnd));
 	    curButton = Button1;
 	    goto commonButtonUp;
 	case WM_MBUTTONUP:
+	    DPRINTFIF(__debug_WM_BUTTONUP__ , ("WM_MBUTTONUP h=%x\n", hWnd));
 	    curButton = Button2;
 	    goto commonButtonUp;
 	case WM_RBUTTONUP:
+	    DPRINTFIF(__debug_WM_BUTTONUP__ , ("WM_RBUTTONUP h=%x\n", hWnd));
 	    curButton = Button3;
 commonButtonUp:
 	    if (isNative) {
@@ -3665,12 +3672,15 @@
 	    break;
 
 	case WM_LBUTTONDBLCLK:
+	    DPRINTFIF(__debug_WM_BUTTONDOWN__ , ("WM_LBUTTONDBLCLK h=%x\n", hWnd));
 	    curButton = Button1;
 	    goto commonButtonDown;
 	case WM_MBUTTONDBLCLK:
+	    DPRINTFIF(__debug_WM_BUTTONDOWN__ , ("WM_MBUTTONDBLCLK h=%x\n", hWnd));
 	    curButton = Button2;
 	    goto commonButtonDown;
 	case WM_RBUTTONDBLCLK:
+	    DPRINTFIF(__debug_WM_BUTTONDOWN__ , ("WM_RBUTTONDBLCLK h=%x\n", hWnd));
 	    curButton = Button3;
 #ifdef PRE_25_AUG_2010
 	    if (isNative) {
@@ -3683,12 +3693,15 @@
 #endif /* PRE_25_AUG_2010 */
 
 	case WM_LBUTTONDOWN:
+	    DPRINTFIF(__debug_WM_BUTTONDOWN__ , ("WM_LBUTTONDOWN h=%x\n", hWnd));
 	    curButton = Button1;
 	    goto commonButtonDown;
 	case WM_MBUTTONDOWN:
+	    DPRINTFIF(__debug_WM_BUTTONDOWN__ , ("WM_MBUTTONDOWN h=%x\n", hWnd));
 	    curButton = Button2;
 	    goto commonButtonDown;
 	case WM_RBUTTONDOWN:
+	    DPRINTFIF(__debug_WM_BUTTONDOWN__ , ("WM_RBUTTONDOWN h=%x\n", hWnd));
 	    curButton = Button3;
 
 	commonButtonDown:
@@ -3723,7 +3736,7 @@
 	    break;
 
 	case WM_CAPTURECHANGED:
-	    CPRINTF(("WM_CAPTURECHANGED %x to %x\n",hWnd,lParam));
+	    DPRINTFIF(__debug_WM_FOCUS__ , ("WM_CAPTURECHANGED h=%x to %x\n", hWnd, lParam));
 #if 0
 	    if ((__currentCapture != CAPTURE_NONE) && (__currentCapture != CAPTURE_EXPLICIT))
 	    {
@@ -3732,8 +3745,8 @@
 	    break;
 
 	case WM_KILLFOCUS:
-	    CPRINTF(("WM_KILLFOCUS\n"));
-	    //enqEvent(0, hWnd, WM_KILLFOCUS, wParam, 0, 0, 0, 0, EV_NOTIME);
+	    DPRINTFIF(__debug_WM_FOCUS__ , ("WM_KILLFOCUS h=%x\n", hWnd));
+	    // enqEvent(0, hWnd, WM_KILLFOCUS, wParam, 0, 0, 0, 0, EV_NOTIME);
 	    if (isNative) {
 		NDPRINTF(("WM_KILLFOCUS for native - default handling\n"));
 		return 0;
@@ -3742,9 +3755,9 @@
 	    break;
 
 	case WM_SETFOCUS:
-	    CPRINTF(("WM_SETFOCUS %x\n",hWnd));
-#if 0
-	    //enqEvent(0,hWnd, WM_SETFOCUS, wParam, 0, 0, 0, 0, EV_NOTIME);
+	    DPRINTFIF(__debug_WM_FOCUS__ , ("WM_SETFOCUS h=%x\n", hWnd));
+#if 0
+	    // enqEvent(0,hWnd, WM_SETFOCUS, wParam, 0, 0, 0, 0, EV_NOTIME);
 	    {
 		POINT p;
 		HWND hWndChild,hWndTemp;
@@ -4618,6 +4631,7 @@
 
 #ifdef SET_FOCUS_IN_WINTHREAD
 	    case WM_THREAD_SETFOCUS:
+		DPRINTFIF(__debug_WM_FOCUS__ , ("WM_THREAD_SETFOCUS h=%x\n", msg.wParam));
 # ifdef xxWIN32THREADS
 		if (msg.lParam) {
 		    if (AttachThreadInput(_dispatchThreadId2,msg.lParam,TRUE) == FALSE)
@@ -4808,7 +4822,7 @@
 
 	    /* short cirquit some messages */
 #if 0
-#ifndef SUPPORT_NATIVE_WINDOWS
+# ifndef SUPPORT_NATIVE_WINDOWS
 	    /*
 	     * some can simply be ignored ...
 	     */
@@ -4818,7 +4832,7 @@
 	    case WM_KILLFOCUS:
 		EVENT_PRINTF(("*WM_KILLFOCUS\n"));
 		continue;
-#endif
+# endif
 #endif
 
 #if 0
@@ -4876,9 +4890,9 @@
 
     retVal = winEventProcessing(hWnd, message, wParam, lParam, &wantDefault);
     if (wantDefault) {
-	DDPRINTF((">>DefWindowProc\n"));
+	DDDPRINTF((">>DefWindowProc\n"));
 	retVal = DefWindowProcW(hWnd, message, wParam, lParam);
-	DDPRINTF(("<<DefWindowProc\n"));
+	DDDPRINTF(("<<DefWindowProc\n"));
     }
     return retVal;
 }
@@ -6168,6 +6182,32 @@
 %}
 !
 
+debug4:aBoolean
+    "enable even more debug prints - this will vanish"
+
+%{  /* NOCONTEXT */
+
+    if (aBoolean == true) {
+	__debug__ |= 4;
+    } else {
+	__debug__ &= ~4;
+    }
+%}
+!
+
+debug8:aBoolean
+    "enable even more debug prints - this will vanish"
+
+%{  /* NOCONTEXT */
+
+    if (aBoolean == true) {
+	__debug__ |= 8;
+    } else {
+	__debug__ &= ~8;
+    }
+%}
+!
+
 debug2:aBoolean
     "enable more debug prints - this will vanish"
 
@@ -6203,6 +6243,21 @@
 	RETURN (self);
 %}
     ].
+    msg = 'WM_USER' ifTrue:[
+%{
+	__debug_WM_MOUSEENTER__ = (aBoolean == true) ? 1 : 0;
+	__debug_WM_MOUSELEAVE__ = (aBoolean == true) ? 1 : 0;
+	__debug_WM_MOUSEMOVE__ = (aBoolean == true) ? 1 : 0;
+	__debug_WM_MOUSEACTIVATE__ = (aBoolean == true) ? 1 : 0;
+	__debug_WM_BUTTONUP__ = (aBoolean == true) ? 1 : 0;
+	__debug_WM_BUTTONDOWN__ = (aBoolean == true) ? 1 : 0;
+	__debug_WM_KEYUP__ = (aBoolean == true) ? 1 : 0;
+	__debug_WM_KEYDOWN__ = (aBoolean == true) ? 1 : 0;
+	__debug_WM_CHAR__ = (aBoolean == true) ? 1 : 0;
+	RETURN (self);
+%}
+    ].
+
     msg = 'WM_MOUSEENTER' ifTrue:[
 %{
 	__debug_WM_MOUSEENTER__ = (aBoolean == true) ? 1 : 0;
@@ -6251,6 +6306,12 @@
 	RETURN (self);
 %}
     ].
+    msg = 'WM_CHAR' ifTrue:[
+%{
+	__debug_WM_CHAR__ = (aBoolean == true) ? 1 : 0;
+	RETURN (self);
+%}
+    ].
     msg = 'WM_PAINT' ifTrue:[
 %{
 	__debug_WM_PAINT__ = (aBoolean == true) ? 1 : 0;
@@ -6293,12 +6354,19 @@
 	RETURN (self);
 %}
     ].
-    msg = 'WM_CHAR' ifTrue:[
-%{
-	__debug_WM_CHAR__ = (aBoolean == true) ? 1 : 0;
+    msg = 'WM_SETCURSOR' ifTrue:[
+%{
+	__debug_WM_SETCURSOR__ = (aBoolean == true) ? 1 : 0;
 	RETURN (self);
 %}
     ].
+    msg = 'WM_FOCUS' ifTrue:[
+%{
+	__debug_WM_FOCUS__ = (aBoolean == true) ? 1 : 0;
+	RETURN (self);
+%}
+    ].
+    'unknown WM_x' infoPrintCR.
 
     "
      WinWorkstation debug:true
@@ -8647,8 +8715,8 @@
     if (__isSmallInteger(eventMask))
 	lI->eventMask = __intVal(eventMask);
     else
-	lI->eventMask = 0xffffffff;
-    DPRINTF(("eventMask is %x\n"));
+	lI->eventMask = ~0;
+    DPRINTF(("eventMask is %x\n", lI->eventMask));
 #ifdef DEBUGMASK1
     printMask(lI->eventMask);
 #endif
@@ -8809,7 +8877,7 @@
     }
 #endif
 
-    DPRINTF(("done - create\n"));
+    DPRINTF(("done - create h=%x\n", newWindowHandle));
     RETURN (windowId);
 %}
 !
@@ -8990,7 +9058,7 @@
 		}
 		GlobalUnlock(hData);
 		CloseClipboard();
-		DDPRINTF((stderr, "WinWorkstation [info]: clipBoard data size is <%d>\n", len));
+		DDPRINTF(("WinWorkstation [info]: clipBoard data size is <%d>\n", len));
 		RETURN(bytes);
 	    }
 	}
@@ -9107,7 +9175,7 @@
 	    }
 	    GlobalUnlock(hData);
 	    CloseClipboard();
-	    DDPRINTF((stderr, "WinWorkstation [info]: clipBoard data is <%s>\n", (char *)hData));
+	    DDPRINTF(("WinWorkstation [info]: clipBoard data is <%s>\n", (char *)hData));
 	    RETURN(s);
 	}
     }
@@ -10454,7 +10522,7 @@
 	w = __intVal(width);
 	h = __intVal(height);
 
-	DPRINTF(("displayRectangle: %d/%d -> %d/%d\n",
+	DDPRINTF(("displayRectangle: %d/%d -> %d/%d\n",
 			xL, yT, w, h));
 
 	if ((w >= 0) && (h >= 0)) {
@@ -11585,7 +11653,8 @@
     OBJ eB;
     char nameBuffer[100];
     HWND hWnd = 0;
-    DDPRINTF(("dispatchLast\n"));
+
+    DDDPRINTF(("dispatchLast\n"));
 
     eB = __INST(eventBuffer);
 
@@ -11811,14 +11880,14 @@
 		break;
 
 	    case WM_SETFOCUS:
-		DPRINTF((">>> WM_SETFOCUS h=%x -> focusInView:\n", ev->ev_hWnd));
+		DPRINTFIF(__debug_WM_FOCUS__ , (">>> WM_SETFOCUS h=%x -> focusInView:\n", ev->ev_hWnd));
 		(*focIn.ilc_func)(self,
 				  @symbol(focusInView:),
 				  nil, &focIn, theView);
 		break;
 
 	    case WM_KILLFOCUS:
-		DPRINTF((">>> WM_KILLFOCUS h=%x -> focusOutOfView\n", ev->ev_hWnd));
+		DPRINTFIF(__debug_WM_FOCUS__ , (">>> WM_KILLFOCUS h=%x -> focusOutOfView\n", ev->ev_hWnd));
 		(*focOut.ilc_func)(self,
 				   @symbol(focusOutView:),
 				   nil, &focOut, theView);
@@ -12669,12 +12738,12 @@
 
 %{  /* NOCONTEXT */
 
-    DDPRINTF(("peek q - "));
+    DDDPRINTF(("peek q - "));
     if (hasEventQueued()) {
-	DDPRINTF(("true\n"));
+	DDDPRINTF(("true\n"));
 	RETURN (true);
     }
-    DDPRINTF(("false\n"));
+    DDDPRINTF(("false\n"));
 %}.
     ^ false
 !
@@ -15318,7 +15387,7 @@
 	}
 	if (hWnd) {
 	    if (GetFocus() != hWnd) {
-		CPRINTF(("setInputFocusTo %x revertTo %d\n",hWnd,r));
+		DPRINTFIF(__debug_WM_FOCUS__ , ("setInputFocusTo %x revertTo %d\n",hWnd,r));
 #ifdef SET_FOCUS_IN_WINTHREAD
 		PostMessage(hWnd, WM_THREAD_SETFOCUS, (INT)hWnd, GetCurrentThreadId());
 #else
@@ -19232,11 +19301,11 @@
 !WinWorkstation class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/WinWorkstation.st,v 1.469 2013-01-30 15:52:29 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/WinWorkstation.st,v 1.470 2013-02-04 16:27:46 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libview/WinWorkstation.st,v 1.469 2013-01-30 15:52:29 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/WinWorkstation.st,v 1.470 2013-02-04 16:27:46 cg Exp $'
 ! !
 
 WinWorkstation initialize!