xwin: Factor out MessageName() debug helper

Factor out the MessageName() debug helper for message id -> text, and
use it on message queue and dequeue.

Reorder in numerical order to match winwindow.h

Add missing WM_WM_ICON_EVENT

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
This commit is contained in:
Jon Turney 2015-07-02 13:32:40 +01:00 committed by Adam Jackson
parent 8c2006ddc5
commit 856a28f637

View File

@ -209,6 +209,64 @@ static Bool g_shutdown = FALSE;
static Bool redirectError = FALSE; static Bool redirectError = FALSE;
static Bool g_fAnotherWMRunning = FALSE; static Bool g_fAnotherWMRunning = FALSE;
/*
* Translate msg id to text, for debug purposes
*/
static const char *
MessageName(winWMMessagePtr msg)
{
switch (msg->msg)
{
case WM_WM_MOVE:
return "WM_WM_MOVE";
break;
case WM_WM_SIZE:
return "WM_WM_SIZE";
break;
case WM_WM_RAISE:
return "WM_WM_RAISE";
break;
case WM_WM_LOWER:
return "WM_WM_LOWER";
break;
case WM_WM_UNMAP:
return "WM_WM_UNMAP";
break;
case WM_WM_KILL:
return "WM_WM_KILL";
break;
case WM_WM_ACTIVATE:
return "WM_WM_ACTIVATE";
break;
case WM_WM_NAME_EVENT:
return "WM_WM_NAME_EVENT";
break;
case WM_WM_ICON_EVENT:
return "WM_WM_ICON_EVENT";
break;
case WM_WM_CHANGE_STATE:
return "WM_WM_CHANGE_STATE";
break;
case WM_WM_MAP:
return "WM_WM_MAP";
break;
case WM_WM_MAP2:
return "WM_WM_MAP2";
break;
case WM_WM_MAP3:
return "WM_WM_MAP3";
break;
case WM_WM_HINTS_EVENT:
return "WM_WM_HINTS_EVENT";
break;
default:
return "Unknown Message";
break;
}
}
/* /*
* PushMessage - Push a message onto the queue * PushMessage - Push a message onto the queue
*/ */
@ -231,44 +289,6 @@ PushMessage(WMMsgQueuePtr pQueue, WMMsgNodePtr pNode)
pQueue->pHead = pNode; pQueue->pHead = pNode;
} }
#if 0
switch (pNode->msg.msg) {
case WM_WM_MOVE:
ErrorF("\tWM_WM_MOVE\n");
break;
case WM_WM_SIZE:
ErrorF("\tWM_WM_SIZE\n");
break;
case WM_WM_RAISE:
ErrorF("\tWM_WM_RAISE\n");
break;
case WM_WM_LOWER:
ErrorF("\tWM_WM_LOWER\n");
break;
case WM_WM_MAP:
ErrorF("\tWM_WM_MAP\n");
break;
case WM_WM_MAP2:
ErrorF("\tWM_WM_MAP2\n");
break;
case WM_WM_MAP3:
ErrorF("\tWM_WM_MAP3\n");
break;
case WM_WM_UNMAP:
ErrorF("\tWM_WM_UNMAP\n");
break;
case WM_WM_KILL:
ErrorF("\tWM_WM_KILL\n");
break;
case WM_WM_ACTIVATE:
ErrorF("\tWM_WM_ACTIVATE\n");
break;
default:
ErrorF("\tUnknown Message.\n");
break;
}
#endif
/* Increase the count of elements in the queue by one */ /* Increase the count of elements in the queue by one */
++(pQueue->nQueueSize); ++(pQueue->nQueueSize);
@ -772,26 +792,21 @@ winMultiWindowWMProc(void *pArg)
} }
#if CYGMULTIWINDOW_DEBUG #if CYGMULTIWINDOW_DEBUG
ErrorF("winMultiWindowWMProc - MSG: %d ID: %d\n", ErrorF("winMultiWindowWMProc - MSG: %s (%d) ID: %d\n",
(int) pNode->msg.msg, (int) pNode->msg.dwID); MessageName(&(pNode->msg)), (int)pNode->msg.msg, (int)pNode->msg.dwID);
#endif #endif
/* Branch on the message type */ /* Branch on the message type */
switch (pNode->msg.msg) { switch (pNode->msg.msg) {
#if 0 #if 0
case WM_WM_MOVE: case WM_WM_MOVE:
ErrorF("\tWM_WM_MOVE\n");
break; break;
case WM_WM_SIZE: case WM_WM_SIZE:
ErrorF("\tWM_WM_SIZE\n");
break; break;
#endif #endif
case WM_WM_RAISE: case WM_WM_RAISE:
#if CYGMULTIWINDOW_DEBUG
ErrorF("\tWM_WM_RAISE\n");
#endif
/* Raise the window */ /* Raise the window */
XRaiseWindow(pWMInfo->pDisplay, pNode->msg.iWindow); XRaiseWindow(pWMInfo->pDisplay, pNode->msg.iWindow);
#if 0 #if 0
@ -800,18 +815,11 @@ winMultiWindowWMProc(void *pArg)
break; break;
case WM_WM_LOWER: case WM_WM_LOWER:
#if CYGMULTIWINDOW_DEBUG
ErrorF("\tWM_WM_LOWER\n");
#endif
/* Lower the window */ /* Lower the window */
XLowerWindow(pWMInfo->pDisplay, pNode->msg.iWindow); XLowerWindow(pWMInfo->pDisplay, pNode->msg.iWindow);
break; break;
case WM_WM_MAP: case WM_WM_MAP:
#if CYGMULTIWINDOW_DEBUG
ErrorF("\tWM_WM_MAP\n");
#endif
/* Put a note as to the HWND associated with this Window */ /* Put a note as to the HWND associated with this Window */
XChangeProperty(pWMInfo->pDisplay, pNode->msg.iWindow, pWMInfo->atmPrivMap, XA_INTEGER, XChangeProperty(pWMInfo->pDisplay, pNode->msg.iWindow, pWMInfo->atmPrivMap, XA_INTEGER,
32, 32,
@ -822,9 +830,6 @@ winMultiWindowWMProc(void *pArg)
break; break;
case WM_WM_MAP2: case WM_WM_MAP2:
#if CYGMULTIWINDOW_DEBUG
ErrorF("\tWM_WM_MAP2\n");
#endif
XChangeProperty(pWMInfo->pDisplay, pNode->msg.iWindow, pWMInfo->atmPrivMap, XA_INTEGER, XChangeProperty(pWMInfo->pDisplay, pNode->msg.iWindow, pWMInfo->atmPrivMap, XA_INTEGER,
32, 32,
PropModeReplace, PropModeReplace,
@ -832,9 +837,6 @@ winMultiWindowWMProc(void *pArg)
break; break;
case WM_WM_MAP3: case WM_WM_MAP3:
#if CYGMULTIWINDOW_DEBUG
ErrorF("\tWM_WM_MAP3\n");
#endif
/* Put a note as to the HWND associated with this Window */ /* Put a note as to the HWND associated with this Window */
XChangeProperty(pWMInfo->pDisplay, pNode->msg.iWindow, pWMInfo->atmPrivMap, XA_INTEGER, XChangeProperty(pWMInfo->pDisplay, pNode->msg.iWindow, pWMInfo->atmPrivMap, XA_INTEGER,
32, 32,
@ -858,18 +860,12 @@ winMultiWindowWMProc(void *pArg)
break; break;
case WM_WM_UNMAP: case WM_WM_UNMAP:
#if CYGMULTIWINDOW_DEBUG
ErrorF("\tWM_WM_UNMAP\n");
#endif
/* Unmap the window */ /* Unmap the window */
XUnmapWindow(pWMInfo->pDisplay, pNode->msg.iWindow); XUnmapWindow(pWMInfo->pDisplay, pNode->msg.iWindow);
break; break;
case WM_WM_KILL: case WM_WM_KILL:
#if CYGMULTIWINDOW_DEBUG
ErrorF("\tWM_WM_KILL\n");
#endif
{ {
/* --- */ /* --- */
if (IsWmProtocolAvailable(pWMInfo->pDisplay, if (IsWmProtocolAvailable(pWMInfo->pDisplay,
@ -884,9 +880,6 @@ winMultiWindowWMProc(void *pArg)
break; break;
case WM_WM_ACTIVATE: case WM_WM_ACTIVATE:
#if CYGMULTIWINDOW_DEBUG
ErrorF("\tWM_WM_ACTIVATE\n");
#endif
/* Set the input focus */ /* Set the input focus */
/* /*
@ -1512,7 +1505,7 @@ winSendMessageToWM(void *pWMInfo, winWMMessagePtr pMsg)
WMMsgNodePtr pNode; WMMsgNodePtr pNode;
#if CYGMULTIWINDOW_DEBUG #if CYGMULTIWINDOW_DEBUG
ErrorF("winSendMessageToWM ()\n"); ErrorF("winSendMessageToWM %s\n", MessageName(pMsg));
#endif #endif
pNode = malloc(sizeof(WMMsgNodeRec)); pNode = malloc(sizeof(WMMsgNodeRec));