diff options
Diffstat (limited to 'xorg-server/hw/xwin/winmultiwindowwm.c')
-rw-r--r-- | xorg-server/hw/xwin/winmultiwindowwm.c | 391 |
1 files changed, 190 insertions, 201 deletions
diff --git a/xorg-server/hw/xwin/winmultiwindowwm.c b/xorg-server/hw/xwin/winmultiwindowwm.c index 6599dfba8..869eeadf4 100644 --- a/xorg-server/hw/xwin/winmultiwindowwm.c +++ b/xorg-server/hw/xwin/winmultiwindowwm.c @@ -43,12 +43,14 @@ #include <fcntl.h> #include <setjmp.h> #define HANDLE void * +#ifdef _MSC_VER +typedef int pid_t; +#endif #include <pthread.h> #undef HANDLE #include <X11/X.h> #include <X11/Xatom.h> #include <X11/Xlib.h> -#include <X11/Xlocale.h> #include <X11/Xproto.h> #include <X11/Xutil.h> #include <X11/cursorfont.h> @@ -59,11 +61,14 @@ #include "winprefs.h" #include "window.h" #include "pixmapstr.h" +#include "winmsg.h" #include "windowstr.h" +#include "winmultiwindowclass.h" #include "winglobals.h" #include "windisplay.h" #ifdef XWIN_MULTIWINDOWEXTWM +#define _WINDOWSWM_SERVER_ #include <X11/extensions/windowswmstr.h> #else /* We need the native HWND atom for intWM, so for consistency use the @@ -79,9 +84,8 @@ extern void winDebug(const char *format, ...); extern void winReshapeMultiWindow(WindowPtr pWin); extern void winUpdateRgnMultiWindow(WindowPtr pWin); -#ifndef CYGDEBUG -#define CYGDEBUG NO -#endif +extern void winSetAuthorization(void); +extern void winUpdateIcon(HWND hWnd, Display *pDisplay, Window id, HICON hIconNew); /* * Constant defines @@ -109,7 +113,9 @@ typedef struct _WMMsgQueueRec { struct _WMMsgNodeRec *pTail; pthread_mutex_t pmMutex; pthread_cond_t pcNotEmpty; +#ifdef _DEBUG int nQueueSize; +#endif } WMMsgQueueRec, *WMMsgQueuePtr; typedef struct _WMInfo { @@ -119,7 +125,9 @@ typedef struct _WMInfo { Atom atmWmDelete; Atom atmWmTakeFocus; Atom atmPrivMap; +#ifdef XWIN_MULTIWINDOWINTWM Bool fAllowOtherWM; +#endif } WMInfoRec, *WMInfoPtr; typedef struct _WMProcArgRec { @@ -173,20 +181,17 @@ static int static int winMultiWindowXMsgProcIOErrorHandler(Display * pDisplay); +static void + winMultiWindowThreadExit(void *arg); + static int winRedirectErrorHandler(Display * pDisplay, XErrorEvent * pErr); static void winInitMultiWindowWM(WMInfoPtr pWMInfo, WMProcArgPtr pProcArg); -#if 0 -static void - PreserveWin32Stack(WMInfoPtr pWMInfo, Window iWindow, UINT direction); -#endif - static Bool - -CheckAnotherWindowManager(Display * pDisplay, DWORD dwScreen, + CheckAnotherWindowManager(Display * pDisplay, DWORD dwScreen, Bool fAllowOtherWM); static void @@ -231,46 +236,10 @@ PushMessage(WMMsgQueuePtr pQueue, WMMsgNodePtr 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 - +#ifdef _DEBUG /* Increase the count of elements in the queue by one */ ++(pQueue->nQueueSize); +#endif /* Release the queue mutex */ pthread_mutex_unlock(&pQueue->pmMutex); @@ -279,7 +248,7 @@ PushMessage(WMMsgQueuePtr pQueue, WMMsgNodePtr pNode) pthread_cond_signal(&pQueue->pcNotEmpty); } -#if CYGMULTIWINDOW_DEBUG +#ifdef WINDBG /* * QueueSize - Return the size of the queue */ @@ -324,12 +293,12 @@ PopMessage(WMMsgQueuePtr pQueue, WMInfoPtr pWMInfo) pQueue->pTail = NULL; } + #ifdef _DEBUG /* Drop the number of elements in the queue by one */ --(pQueue->nQueueSize); -#if CYGMULTIWINDOW_DEBUG - ErrorF("Queue Size %d %d\n", pQueue->nQueueSize, QueueSize(pQueue)); -#endif + winDebug ("Queue Size %d %d\n", pQueue->nQueueSize, QueueSize(pQueue)); + #endif /* Release the queue mutex */ pthread_mutex_unlock(&pQueue->pmMutex); @@ -375,24 +344,24 @@ InitQueue(WMMsgQueuePtr pQueue) pQueue->pTail = NULL; /* There are no elements initially */ + #ifdef _DEBUG pQueue->nQueueSize = 0; -#if CYGMULTIWINDOW_DEBUG winDebug("InitQueue - Queue Size %d %d\n", pQueue->nQueueSize, QueueSize(pQueue)); -#endif + #endif - winDebug("InitQueue - Calling pthread_mutex_init\n"); + winDebug ("InitQueue - Calling pthread_mutex_init\n"); /* Create synchronization objects */ pthread_mutex_init(&pQueue->pmMutex, NULL); - winDebug("InitQueue - pthread_mutex_init returned\n"); - winDebug("InitQueue - Calling pthread_cond_init\n"); + winDebug ("InitQueue - pthread_mutex_init returned\n"); + winDebug ("InitQueue - Calling pthread_cond_init\n"); pthread_cond_init(&pQueue->pcNotEmpty, NULL); - winDebug("InitQueue - pthread_cond_init returned\n"); + winDebug ("InitQueue - pthread_cond_init returned\n"); return TRUE; } @@ -441,9 +410,7 @@ GetWindowName(Display * pDisplay, Window iWin, char **ppWindowName) char *pszClientMachine; char hostname[HOST_NAME_MAX + 1]; -#if CYGMULTIWINDOW_DEBUG - ErrorF("GetWindowName\n"); -#endif + winDebug ("GetWindowName\n"); /* Intialize ppWindowName to NULL */ *ppWindowName = NULL; @@ -451,9 +418,7 @@ GetWindowName(Display * pDisplay, Window iWin, char **ppWindowName) /* Try to get window name */ nResult = XGetWMName(pDisplay, iWin, &xtpWindowName); if (!nResult || !xtpWindowName.value || !xtpWindowName.nitems) { -#if CYGMULTIWINDOW_DEBUG ErrorF("GetWindowName - XGetWMName failed. No name.\n"); -#endif return; } @@ -746,21 +711,23 @@ winMultiWindowWMProc(void *pArg) WMProcArgPtr pProcArg = (WMProcArgPtr) pArg; WMInfoPtr pWMInfo = pProcArg->pWMInfo; + pthread_cleanup_push(&winMultiWindowThreadExit, NULL); + /* Initialize the Window Manager */ winInitMultiWindowWM(pWMInfo, pProcArg); -#if CYGMULTIWINDOW_DEBUG - ErrorF("winMultiWindowWMProc ()\n"); -#endif + winDebug ("winMultiWindowWMProc ()\n"); /* Loop until we explicitly break out */ for (;;) { WMMsgNodePtr pNode; +#ifdef XWIN_MULTIWINDOWINTWM if (g_fAnotherWMRunning) { /* Another Window manager exists. */ Sleep(1000); continue; } +#endif /* Pop a message off of our queue */ pNode = PopMessage(&pWMInfo->wmMsgQueue, pWMInfo); @@ -771,47 +738,26 @@ winMultiWindowWMProc(void *pArg) pthread_exit(NULL); } -#if CYGMULTIWINDOW_DEBUG - ErrorF("winMultiWindowWMProc - %d ms MSG: %d ID: %d\n", - GetTickCount(), (int) pNode->msg.msg, (int) pNode->msg.dwID); -#endif + winDebug ("winMultiWindowWMProc - %d ms MSG: %d ID: %d\n", + GetTickCount(), (int) pNode->msg.msg, (int) pNode->msg.dwID); /* Branch on the message type */ switch (pNode->msg.msg) { -#if 0 - case WM_WM_MOVE: - ErrorF("\tWM_WM_MOVE\n"); - break; - - case WM_WM_SIZE: - ErrorF("\tWM_WM_SIZE\n"); - break; -#endif - case WM_WM_RAISE: -#if CYGMULTIWINDOW_DEBUG - ErrorF("\tWM_WM_RAISE\n"); -#endif + winDebug ("\tWM_WM_RAISE\n"); /* Raise the window */ XRaiseWindow(pWMInfo->pDisplay, pNode->msg.iWindow); -#if 0 - PreserveWin32Stack(pWMInfo, pNode->msg.iWindow, GW_HWNDPREV); -#endif break; case WM_WM_LOWER: -#if CYGMULTIWINDOW_DEBUG - ErrorF("\tWM_WM_LOWER\n"); -#endif + winDebug ("\tWM_WM_LOWER\n"); /* Lower the window */ XLowerWindow(pWMInfo->pDisplay, pNode->msg.iWindow); break; case WM_WM_MAP: -#if CYGMULTIWINDOW_DEBUG - ErrorF("\tWM_WM_MAP\n"); -#endif + winDebug ("\tWM_WM_MAP\n"); /* Put a note as to the HWND associated with this Window */ XChangeProperty(pWMInfo->pDisplay, pNode->msg.iWindow, pWMInfo->atmPrivMap, XA_INTEGER, 32, @@ -822,9 +768,8 @@ winMultiWindowWMProc(void *pArg) break; case WM_WM_MAP2: -#if CYGMULTIWINDOW_DEBUG - ErrorF("\tWM_WM_MAP2\n"); -#endif + winDebug ("\tWM_WM_MAP2\n"); + XChangeProperty(pWMInfo->pDisplay, pNode->msg.iWindow, pWMInfo->atmPrivMap, XA_INTEGER, 32, PropModeReplace, @@ -832,16 +777,14 @@ winMultiWindowWMProc(void *pArg) break; case WM_WM_MAP3: -#if CYGMULTIWINDOW_DEBUG - ErrorF("\tWM_WM_MAP3\n"); -#endif + winDebug ("\tWM_WM_MAP3\n"); + /* Put a note as to the HWND associated with this Window */ XChangeProperty(pWMInfo->pDisplay, pNode->msg.iWindow, pWMInfo->atmPrivMap, XA_INTEGER, 32, PropModeReplace, (unsigned char *) &(pNode->msg.hwndWindow), sizeof(HWND)/4); UpdateName(pWMInfo, pNode->msg.iWindow); - UpdateIcon(pWMInfo, pNode->msg.iWindow); UpdateStyle(pWMInfo, pNode->msg.iWindow); @@ -855,21 +798,18 @@ winMultiWindowWMProc(void *pArg) } } + UpdateIcon(pWMInfo, pNode->msg.iWindow); break; case WM_WM_UNMAP: -#if CYGMULTIWINDOW_DEBUG - ErrorF("\tWM_WM_UNMAP\n"); -#endif + winDebug ("\tWM_WM_UNMAP\n"); /* Unmap the window */ XUnmapWindow(pWMInfo->pDisplay, pNode->msg.iWindow); break; case WM_WM_KILL: -#if CYGMULTIWINDOW_DEBUG - ErrorF("\tWM_WM_KILL\n"); -#endif + winDebug ("\tWM_WM_KILL\n"); { /* --- */ if (IsWmProtocolAvailable(pWMInfo->pDisplay, @@ -884,9 +824,7 @@ winMultiWindowWMProc(void *pArg) break; case WM_WM_ACTIVATE: -#if CYGMULTIWINDOW_DEBUG - ErrorF("\tWM_WM_ACTIVATE\n"); -#endif + winDebug ("\tWM_WM_ACTIVATE\n"); /* Set the input focus */ /* @@ -970,9 +908,10 @@ winMultiWindowWMProc(void *pArg) /* Free the passed-in argument */ free(pProcArg); -#if CYGMULTIWINDOW_DEBUG - ErrorF("-winMultiWindowWMProc ()\n"); -#endif + winDebug("-winMultiWindowWMProc ()\n"); + + pthread_cleanup_pop(0); + return NULL; } @@ -996,6 +935,8 @@ winMultiWindowXMsgProc(void *pArg) int iReturn; XIconSize *xis; + pthread_cleanup_push(&winMultiWindowThreadExit, NULL); + winDebug("winMultiWindowXMsgProc - Hello\n"); /* Check that argument pointer is not invalid */ @@ -1004,7 +945,7 @@ winMultiWindowXMsgProc(void *pArg) pthread_exit(NULL); } - ErrorF("winMultiWindowXMsgProc - Calling pthread_mutex_lock ()\n"); + winDebug("winMultiWindowXMsgProc - Calling pthread_mutex_lock ()\n"); /* Grab the server started mutex - pause until we get it */ iReturn = pthread_mutex_lock(pProcArg->ppmServerStarted); @@ -1014,23 +955,12 @@ winMultiWindowXMsgProc(void *pArg) pthread_exit(NULL); } - ErrorF("winMultiWindowXMsgProc - pthread_mutex_lock () returned.\n"); - - /* Allow multiple threads to access Xlib */ - if (XInitThreads() == 0) { - ErrorF("winMultiWindowXMsgProc - XInitThreads () failed. Exiting.\n"); - pthread_exit(NULL); - } - - /* See if X supports the current locale */ - if (XSupportsLocale() == False) { - ErrorF("winMultiWindowXMsgProc - Warning: locale not supported by X\n"); - } + winDebug("winMultiWindowXMsgProc - pthread_mutex_lock () returned.\n"); /* Release the server started mutex */ pthread_mutex_unlock(pProcArg->ppmServerStarted); - ErrorF("winMultiWindowXMsgProc - pthread_mutex_unlock () returned.\n"); + winDebug("winMultiWindowXMsgProc - pthread_mutex_unlock () returned.\n"); /* Install our error handler */ XSetErrorHandler(winMultiWindowXMsgProcErrorHandler); @@ -1057,10 +987,7 @@ winMultiWindowXMsgProc(void *pArg) winGetDisplayName(pszDisplay, (int) pProcArg->dwScreen); /* Print the display connection string */ - ErrorF("winMultiWindowXMsgProc - DISPLAY=%s\n", pszDisplay); - - /* Use our generated cookie for authentication */ - winSetAuthorization(); + winDebug("winMultiWindowXMsgProc - DISPLAY=%s\n", pszDisplay); /* Initialize retry count */ iRetries = 0; @@ -1070,8 +997,8 @@ winMultiWindowXMsgProc(void *pArg) /* Try to open the display */ pProcArg->pDisplay = XOpenDisplay(pszDisplay); if (pProcArg->pDisplay == NULL) { - ErrorF("winMultiWindowXMsgProc - Could not open display, try: %d, " - "sleeping: %d\n", iRetries + 1, WIN_CONNECT_DELAY); + winDebug("winMultiWindowXMsgProc - Could not open display, try: %d, " + "sleeping: %d\n", iRetries + 1, WIN_CONNECT_DELAY); ++iRetries; sleep(WIN_CONNECT_DELAY); continue; @@ -1088,15 +1015,25 @@ winMultiWindowXMsgProc(void *pArg) pthread_exit(NULL); } - ErrorF("winMultiWindowXMsgProc - XOpenDisplay () returned and " - "successfully opened the display.\n"); + winDebug("winMultiWindowXMsgProc - XOpenDisplay () returned and " + "successfully opened the display.\n"); /* Check if another window manager is already running */ +#ifdef XWIN_MULTIWINDOWINTWM g_fAnotherWMRunning = CheckAnotherWindowManager(pProcArg->pDisplay, pProcArg->dwScreen, pProcArg->pWMInfo->fAllowOtherWM); +#else + g_fAnotherWMRunning = + CheckAnotherWindowManager(pProcArg->pDisplay, pProcArg->dwScreen, + FALSE); +#endif - if (g_fAnotherWMRunning && !pProcArg->pWMInfo->fAllowOtherWM) { + if (g_fAnotherWMRunning +#ifdef XWIN_MULTIWINDOWINTWM + && !pProcArg->pWMInfo->fAllowOtherWM +#endif + ) { ErrorF("winMultiWindowXMsgProc - " "another window manager is running. Exiting.\n"); pthread_exit(NULL); @@ -1109,19 +1046,13 @@ winMultiWindowXMsgProc(void *pArg) xis->max_width = xis->max_height = 48; xis->width_inc = xis->height_inc = 16; XSetIconSizes(pProcArg->pDisplay, - RootWindow(pProcArg->pDisplay, pProcArg->dwScreen), + XRootWindow(pProcArg->pDisplay, pProcArg->dwScreen), xis, 1); XFree(xis); } atmWmName = XInternAtom(pProcArg->pDisplay, "WM_NAME", False); - atmWmHints = XInternAtom(pProcArg->pDisplay, "WM_HINTS", False); atmWmChange = XInternAtom(pProcArg->pDisplay, "WM_CHANGE_STATE", False); - atmNetWmIcon = XInternAtom(pProcArg->pDisplay, "_NET_WM_ICON", False); - atmWindowState = XInternAtom(pProcArg->pDisplay, "_NET_WM_STATE", False); - atmMotifWmHints = XInternAtom(pProcArg->pDisplay, "_MOTIF_WM_HINTS", False); - atmWindowType = XInternAtom(pProcArg->pDisplay, "_NET_WM_WINDOW_TYPE", False); - atmNormalHints = XInternAtom(pProcArg->pDisplay, "WM_NORMAL_HINTS", False); /* iiimxcf had a bug until 2009-04-27, assuming that the @@ -1138,6 +1069,7 @@ winMultiWindowXMsgProc(void *pArg) if (g_shutdown) break; +#ifdef XWIN_MULTIWINDOWINTWM if (pProcArg->pWMInfo->fAllowOtherWM && !XPending(pProcArg->pDisplay)) { if (CheckAnotherWindowManager (pProcArg->pDisplay, pProcArg->dwScreen, TRUE)) { @@ -1155,12 +1087,13 @@ winMultiWindowXMsgProc(void *pArg) Sleep(500); continue; } +#endif /* Fetch next event */ XNextEvent(pProcArg->pDisplay, &event); /* Branch on event type */ - if (event.type == CreateNotify) { + if (event.type == MapNotify /* CreateNotify */) { XWindowAttributes attr; XSelectInput(pProcArg->pDisplay, @@ -1170,7 +1103,7 @@ winMultiWindowXMsgProc(void *pArg) XGetWindowAttributes(pProcArg->pDisplay, event.xcreatewindow.window, &attr); - if (!attr.override_redirect) + if (!attr.override_redirect && attr.class != InputOnly) XSetWindowBorderWidth(pProcArg->pDisplay, event.xcreatewindow.window, 0); } @@ -1218,6 +1151,7 @@ winMultiWindowXMsgProc(void *pArg) event_send.xreparent.parent = parent; event_send.xreparent.x = attr.x; event_send.xreparent.y = attr.y; + event_send.xreparent.override_redirect = False; XSendEvent(event.xmap.display, event.xmap.window, @@ -1258,6 +1192,20 @@ winMultiWindowXMsgProc(void *pArg) winSendMessageToWM(pProcArg->pWMInfo, &msg); } else { + static Atom atmWindowState, atmMotifWmHints, atmWindowType, atmNormalHints, atmWmHints, atmNetWmIcon; + if (atmWmHints == None) + atmWmHints = XInternAtom(pProcArg->pDisplay, "WM_HINTS", False); + if (atmWindowState == None) + atmWindowState = XInternAtom(pProcArg->pDisplay, "_NET_WM_STATE", False); + if (atmMotifWmHints == None) + atmMotifWmHints = XInternAtom(pProcArg->pDisplay, "_MOTIF_WM_HINTS", False); + if (atmWindowType == None) + atmWindowType = XInternAtom(pProcArg->pDisplay, "_NET_WM_WINDOW_TYPE", False); + if (atmNormalHints == None) + atmNormalHints = XInternAtom(pProcArg->pDisplay, "WM_NORMAL_HINTS", False); + if (atmNetWmIcon == None) + atmNetWmIcon = XInternAtom(pProcArg->pDisplay, "_NET_WM_ICON", False); + /* Several properties are considered for WM hints, check if this property change affects any of them... (this list needs to be kept in sync with winApplyHints()) @@ -1290,7 +1238,7 @@ winMultiWindowXMsgProc(void *pArg) else if (event.type == ClientMessage && event.xclient.message_type == atmWmChange && event.xclient.data.l[0] == IconicState) { - ErrorF("winMultiWindowXMsgProc - WM_CHANGE_STATE - IconicState\n"); + winDebug("winMultiWindowXMsgProc - WM_CHANGE_STATE - IconicState\n"); memset(&msg, 0, sizeof(msg)); @@ -1302,7 +1250,7 @@ winMultiWindowXMsgProc(void *pArg) } XCloseDisplay(pProcArg->pDisplay); - pthread_exit(NULL); + pthread_cleanup_pop(0); return NULL; } @@ -1339,7 +1287,9 @@ winInitWM(void **ppWMInfo, /* Set a return pointer to the Window Manager info structure */ *ppWMInfo = pWMInfo; +#ifdef XWIN_MULTIWINDOWINTWM pWMInfo->fAllowOtherWM = allowOtherWM; +#endif /* Setup the argument structure for the thread function */ pArg->dwScreen = dwScreen; @@ -1370,9 +1320,7 @@ winInitWM(void **ppWMInfo, return FALSE; } -#if CYGDEBUG || YES winDebug("winInitWM - Returning.\n"); -#endif return TRUE; } @@ -1396,7 +1344,7 @@ winInitMultiWindowWM(WMInfoPtr pWMInfo, WMProcArgPtr pProcArg) pthread_exit(NULL); } - ErrorF("winInitMultiWindowWM - Calling pthread_mutex_lock ()\n"); + winDebug("winInitMultiWindowWM - Calling pthread_mutex_lock ()\n"); /* Grab our garbage mutex to satisfy pthread_cond_wait */ iReturn = pthread_mutex_lock(pProcArg->ppmServerStarted); @@ -1406,23 +1354,12 @@ winInitMultiWindowWM(WMInfoPtr pWMInfo, WMProcArgPtr pProcArg) pthread_exit(NULL); } - ErrorF("winInitMultiWindowWM - pthread_mutex_lock () returned.\n"); - - /* Allow multiple threads to access Xlib */ - if (XInitThreads() == 0) { - ErrorF("winInitMultiWindowWM - XInitThreads () failed. Exiting.\n"); - pthread_exit(NULL); - } - - /* See if X supports the current locale */ - if (XSupportsLocale() == False) { - ErrorF("winInitMultiWindowWM - Warning: Locale not supported by X.\n"); - } + winDebug("winInitMultiWindowWM - pthread_mutex_lock () returned.\n"); /* Release the server started mutex */ pthread_mutex_unlock(pProcArg->ppmServerStarted); - ErrorF("winInitMultiWindowWM - pthread_mutex_unlock () returned.\n"); + winDebug("winInitMultiWindowWM - pthread_mutex_unlock () returned.\n"); /* Install our error handler */ XSetErrorHandler(winMultiWindowWMErrorHandler); @@ -1449,7 +1386,7 @@ winInitMultiWindowWM(WMInfoPtr pWMInfo, WMProcArgPtr pProcArg) winGetDisplayName(pszDisplay, (int) pProcArg->dwScreen); /* Print the display connection string */ - ErrorF("winInitMultiWindowWM - DISPLAY=%s\n", pszDisplay); + winDebug("winInitMultiWindowWM - DISPLAY=%s\n", pszDisplay); /* Use our generated cookie for authentication */ winSetAuthorization(); @@ -1477,8 +1414,8 @@ winInitMultiWindowWM(WMInfoPtr pWMInfo, WMProcArgPtr pProcArg) pthread_exit(NULL); } - ErrorF("winInitMultiWindowWM - XOpenDisplay () returned and " - "successfully opened the display.\n"); + winDebug("winInitMultiWindowWM - XOpenDisplay () returned and " + "successfully opened the display.\n"); /* Create some atoms */ pWMInfo->atmWmProtos = XInternAtom(pWMInfo->pDisplay, @@ -1496,7 +1433,7 @@ winInitMultiWindowWM(WMInfoPtr pWMInfo, WMProcArgPtr pProcArg) if (cursor) { XDefineCursor(pWMInfo->pDisplay, - DefaultRootWindow(pWMInfo->pDisplay), cursor); + XDefaultRootWindow(pWMInfo->pDisplay), cursor); XFreeCursor(pWMInfo->pDisplay, cursor); } } @@ -1511,9 +1448,7 @@ winSendMessageToWM(void *pWMInfo, winWMMessagePtr pMsg) { WMMsgNodePtr pNode; -#if CYGMULTIWINDOW_DEBUG - ErrorF("winSendMessageToWM ()\n"); -#endif + winDebug("winSendMessageToWM ()\n"); pNode = malloc(sizeof(WMMsgNodeRec)); if (pNode != NULL) { @@ -1539,7 +1474,18 @@ winMultiWindowWMErrorHandler(Display * pDisplay, XErrorEvent * pErr) } XGetErrorText(pDisplay, pErr->error_code, pszErrorMsg, sizeof(pszErrorMsg)); - ErrorF("winMultiWindowWMErrorHandler - ERROR: %s\n", pszErrorMsg); + ErrorF("winMultiWindowWMErrorHandler - ERROR: %s\n" + " errorCode %d\n" + " serial %d\n" + " resourceID 0x%x\n" + " majorCode %d\n" + " minorCode %d\n" + , pszErrorMsg + , pErr->error_code + , pErr->serial + , pErr->resourceid + , pErr->request_code + , pErr->minor_code); return 0; } @@ -1551,11 +1497,11 @@ winMultiWindowWMErrorHandler(Display * pDisplay, XErrorEvent * pErr) static int winMultiWindowWMIOErrorHandler(Display * pDisplay) { + if (g_shutdown) pthread_exit(NULL); + ErrorF("winMultiWindowWMIOErrorHandler!\n"); if (pthread_equal(pthread_self(), g_winMultiWindowWMThread)) { - if (g_shutdown) - pthread_exit(NULL); /* Restart at the main entry point */ longjmp(g_jmpWMEntry, WIN_JMP_ERROR_IO); @@ -1577,9 +1523,18 @@ winMultiWindowXMsgProcErrorHandler(Display * pDisplay, XErrorEvent * pErr) char pszErrorMsg[100]; XGetErrorText(pDisplay, pErr->error_code, pszErrorMsg, sizeof(pszErrorMsg)); -#if CYGMULTIWINDOW_DEBUG - ErrorF("winMultiWindowXMsgProcErrorHandler - ERROR: %s\n", pszErrorMsg); -#endif + ErrorF("winMultiWindowXMsgProcErrorHandler - ERROR: %s\n" + " errorCode %d\n" + " serial %d\n" + " resourceID 0x%x\n" + " majorCode %d\n" + " minorCode %d\n" + , pszErrorMsg + , pErr->error_code + , pErr->serial + , pErr->resourceid + , pErr->request_code + , pErr->minor_code); return 0; } @@ -1591,6 +1546,8 @@ winMultiWindowXMsgProcErrorHandler(Display * pDisplay, XErrorEvent * pErr) static int winMultiWindowXMsgProcIOErrorHandler(Display * pDisplay) { + if (g_shutdown) pthread_exit(NULL); + ErrorF("winMultiWindowXMsgProcIOErrorHandler!\n"); if (pthread_equal(pthread_self(), g_winMultiWindowXMsgProcThread)) { @@ -1605,6 +1562,18 @@ winMultiWindowXMsgProcIOErrorHandler(Display * pDisplay) } /* + * winMultiWindowThreadExit - Thread exit handler + */ + +static void +winMultiWindowThreadExit(void *arg) +{ + AbortDDX(EXIT_ERR_ABORT); + + /* multiwindow client thread has exited, stop server as well */ + TerminateProcess(GetCurrentProcess(),1); +} +/* * Catch RedirectError to detect other window manager running */ @@ -1641,7 +1610,7 @@ CheckAnotherWindowManager(Display * pDisplay, DWORD dwScreen, If other WMs are not allowed, also select one of the events which only one client at a time is allowed to select, so other window managers won't start... */ - XSelectInput(pDisplay, RootWindow(pDisplay, dwScreen), + XSelectInput(pDisplay, XRootWindow(pDisplay, dwScreen), SubstructureNotifyMask | (!fAllowOtherWM ? ButtonPressMask : 0)); XSync(pDisplay, 0); @@ -1655,7 +1624,8 @@ CheckAnotherWindowManager(Display * pDisplay, DWORD dwScreen, void winDeinitMultiWindowWM(void) { - ErrorF("winDeinitMultiWindowWM - Noting shutdown in progress\n"); + if (g_shutdown == TRUE) return; + winDebug("winDeinitMultiWindowWM - Noting shutdown in progress\n"); g_shutdown = TRUE; } @@ -1678,13 +1648,15 @@ winApplyHints(Display * pDisplay, Window iWindow, HWND hWnd, HWND * zstyle) static Atom windowState, motif_wm_hints, windowType; static Atom hiddenState, fullscreenState, belowState, aboveState, skiptaskbarState; - static Atom dockWindow; + static Atom dockWindow, splashWindow; static int generation; Atom type, *pAtom = NULL; int format; - unsigned long hint = 0, maxmin = 0, nitems = 0, left = 0; + unsigned long hint = 0, maxmin = 0, nitems = 0, left = 0, taskbar = 0; unsigned long style, exStyle; + WindowPtr pWin = GetProp (hWnd, WIN_WINDOW_PROP); MwmHints *mwm_hint = NULL; + WinXSizeHints SizeHints; if (!hWnd) return; @@ -1702,6 +1674,7 @@ winApplyHints(Display * pDisplay, Window iWindow, HWND hWnd, HWND * zstyle) belowState = XInternAtom(pDisplay, "_NET_WM_STATE_BELOW", False); aboveState = XInternAtom(pDisplay, "_NET_WM_STATE_ABOVE", False); dockWindow = XInternAtom(pDisplay, "_NET_WM_WINDOW_TYPE_DOCK", False); + splashWindow = XInternAtom(pDisplay, "_NET_WM_WINDOW_TYPE_SPLASH", False); skiptaskbarState = XInternAtom(pDisplay, "_NET_WM_STATE_SKIP_TASKBAR", False); } @@ -1738,7 +1711,7 @@ winApplyHints(Display * pDisplay, Window iWindow, HWND hWnd, HWND * zstyle) if (mwm_hint && nitems == PropMwmHintsElements && (mwm_hint->flags & MwmHintsDecorations)) { if (!mwm_hint->decorations) - hint |= HINT_NOFRAME; + hint |= (HINT_NOFRAME | HINT_NOSYSMENU | HINT_NOMINIMIZE | HINT_NOMAXIMIZE); else if (!(mwm_hint->decorations & MwmDecorAll)) { if (mwm_hint->decorations & MwmDecorBorder) hint |= HINT_BORDER; @@ -1775,7 +1748,11 @@ winApplyHints(Display * pDisplay, Window iWindow, HWND hWnd, HWND * zstyle) hint = (hint & ~HINT_NOFRAME) | HINT_SIZEBOX; /* Xming puts a sizebox on dock windows */ *zstyle = HWND_TOPMOST; } - } + else if (*pAtom == splashWindow) { + hint |= (HINT_SKIPTASKBAR | HINT_NOSYSMENU | HINT_NOMINIMIZE | HINT_NOMAXIMIZE); + *zstyle = HWND_TOPMOST; + } + } if (pAtom) XFree(pAtom); } @@ -1811,26 +1788,36 @@ winApplyHints(Display * pDisplay, Window iWindow, HWND hWnd, HWND * zstyle) */ { XClassHint class_hint = { 0, 0 }; - char *window_name = 0; - char *application_id = 0; if (XGetClassHint(pDisplay, iWindow, &class_hint)) { + char *window_name = 0; + char *application_id = 0; + char *rand_id = 0; + XFetchName(pDisplay, iWindow, &window_name); + taskbar = winOverrideTaskbar(class_hint.res_name, class_hint.res_class, window_name); + if (taskbar & TASKBAR_NEWTAB) { + int irand_id; + srand((unsigned)time(NULL)); + irand_id = rand(); + asprintf(&rand_id, "%d", irand_id); + } style = winOverrideStyle(class_hint.res_name, class_hint.res_class, window_name); -#define APPLICATION_ID_FORMAT "%s.xwin.%s" -#define APPLICATION_ID_UNKNOWN "unknown" - if (class_hint.res_class) { - asprintf(&application_id, APPLICATION_ID_FORMAT, XVENDORNAME, - class_hint.res_class); - } - else { - asprintf(&application_id, APPLICATION_ID_FORMAT, XVENDORNAME, - APPLICATION_ID_UNKNOWN); - } + /* AppUserModelID in the following form CompanyName.ProductName.SubProduct.VersionInformation + VersionInformation is set random with NEWTAB and to display-number normally. No spaces allowed. */ + asprintf(&application_id, + "%s.%s.%s.%s", + XVENDORNAME, + PROJECT_NAME, + (class_hint.res_class) ? class_hint.res_class : + (class_hint.res_name) ? class_hint.res_name : + (window_name) ? window_name : "SubProductUnknown", + (taskbar & TASKBAR_NEWTAB) ? rand_id : + (getenv("DISNO")) ? getenv("DISNO") : 0); winSetAppUserModelID(hWnd, application_id); if (class_hint.res_name) @@ -1899,13 +1886,21 @@ winApplyHints(Display * pDisplay, Window iWindow, HWND hWnd, HWND * zstyle) if (hint & HINT_NOSYSMENU) style = style & ~WS_SYSMENU; - if (hint & HINT_SKIPTASKBAR) + if ((hint & HINT_SKIPTASKBAR) || (taskbar & TASKBAR_NOTAB)) { + winShowWindowOnTaskbar(hWnd, FALSE); style = style & ~WS_MINIMIZEBOX; /* window will become lost if minimized */ + } + + if (!IsWindow (hWnd)) + { + ErrorF("Windows window 0x%x has become invalid, so returning without applying hints\n",hWnd); + return; + } SetWindowLongPtr(hWnd, GWL_STYLE, style); exStyle = GetWindowLongPtr(hWnd, GWL_EXSTYLE); - if (hint & HINT_SKIPTASKBAR) + if ((hint & HINT_SKIPTASKBAR) || (taskbar & TASKBAR_NOTAB)) exStyle = (exStyle & ~WS_EX_APPWINDOW) | WS_EX_TOOLWINDOW; else exStyle = (exStyle & ~WS_EX_TOOLWINDOW) | WS_EX_APPWINDOW; @@ -1942,9 +1937,6 @@ winUpdateWindowPosition(HWND hWnd, HWND * zstyle) /* Setup a rectangle with the X window position and size */ SetRect(&rcNew, iX, iY, iX + iWidth, iY + iHeight); - winDebug("winUpdateWindowPosition - drawable extent (%d, %d)-(%d, %d)\n", - rcNew.left, rcNew.top, rcNew.right, rcNew.bottom); - AdjustWindowRectEx(&rcNew, GetWindowLongPtr(hWnd, GWL_STYLE), FALSE, GetWindowLongPtr(hWnd, GWL_EXSTYLE)); @@ -1961,9 +1953,6 @@ winUpdateWindowPosition(HWND hWnd, HWND * zstyle) rcNew.bottom += iDy; } - winDebug("winUpdateWindowPosition - Window extent (%d, %d)-(%d, %d)\n", - rcNew.left, rcNew.top, rcNew.right, rcNew.bottom); - /* Position the Windows window */ SetWindowPos(hWnd, *zstyle, rcNew.left, rcNew.top, rcNew.right - rcNew.left, rcNew.bottom - rcNew.top, 0); |