aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/xwin/winmultiwindowwm.c
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/hw/xwin/winmultiwindowwm.c')
-rw-r--r--xorg-server/hw/xwin/winmultiwindowwm.c373
1 files changed, 173 insertions, 200 deletions
diff --git a/xorg-server/hw/xwin/winmultiwindowwm.c b/xorg-server/hw/xwin/winmultiwindowwm.c
index 0749f5df6..b5b0fef84 100644
--- a/xorg-server/hw/xwin/winmultiwindowwm.c
+++ b/xorg-server/hw/xwin/winmultiwindowwm.c
@@ -43,6 +43,9 @@
#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>
@@ -61,7 +64,9 @@
#include "winprefs.h"
#include "window.h"
#include "pixmapstr.h"
+#include "winmsg.h"
#include "windowstr.h"
+#include "winmultiwindowclass.h"
#ifdef XWIN_MULTIWINDOWEXTWM
#include <X11/extensions/windowswmstr.h>
@@ -75,10 +80,6 @@ extern void winDebug(const char *format, ...);
extern void winReshapeMultiWindow(WindowPtr pWin);
extern void winUpdateRgnMultiWindow(WindowPtr pWin);
-#ifndef CYGDEBUG
-#define CYGDEBUG NO
-#endif
-
/*
* Constant defines
*/
@@ -179,17 +180,15 @@ winMultiWindowXMsgProcErrorHandler (Display *pDisplay, XErrorEvent *pErr);
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, Bool fAllowOtherWM);
@@ -204,7 +203,11 @@ winUpdateWindowPosition (HWND hWnd, Bool reshape, HWND *zstyle);
*/
static jmp_buf g_jmpWMEntry;
+static XIOErrorHandler g_winMultiWindowWMOldIOErrorHandler;
+static pthread_t g_winMultiWindowWMThread;
static jmp_buf g_jmpXMsgProcEntry;
+static XIOErrorHandler g_winMultiWindowXMsgProcOldIOErrorHandler;
+static pthread_t g_winMultiWindowXMsgProcThread;
static Bool g_shutdown = FALSE;
static Bool redirectError = FALSE;
static Bool g_fAnotherWMRunning = FALSE;
@@ -233,46 +236,6 @@ 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
-
/* Increase the count of elements in the queue by one */
++(pQueue->nQueueSize);
@@ -284,7 +247,7 @@ PushMessage (WMMsgQueuePtr pQueue, WMMsgNodePtr pNode)
}
-#if CYGMULTIWINDOW_DEBUG
+#ifdef WINDBG
/*
* QueueSize - Return the size of the queue
*/
@@ -336,9 +299,7 @@ PopMessage (WMMsgQueuePtr pQueue, WMInfoPtr pWMInfo)
/* 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));
/* Release the queue mutex */
pthread_mutex_unlock (&pQueue->pmMutex);
@@ -390,22 +351,20 @@ InitQueue (WMMsgQueuePtr pQueue)
/* There are no elements initially */
pQueue->nQueueSize = 0;
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("InitQueue - Queue Size %d %d\n", pQueue->nQueueSize,
+ winDebug ("InitQueue - Queue Size %d %d\n", pQueue->nQueueSize,
QueueSize(pQueue));
-#endif
- ErrorF ("InitQueue - Calling pthread_mutex_init\n");
+ winDebug ("InitQueue - Calling pthread_mutex_init\n");
/* Create synchronization objects */
pthread_mutex_init (&pQueue->pmMutex, NULL);
- ErrorF ("InitQueue - pthread_mutex_init returned\n");
- ErrorF ("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);
- ErrorF ("InitQueue - pthread_cond_init returned\n");
+ winDebug ("InitQueue - pthread_cond_init returned\n");
return TRUE;
}
@@ -424,9 +383,7 @@ GetWindowName (Display *pDisplay, Window iWin, wchar_t **ppName)
int iLen, i;
XTextProperty xtpName;
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("GetWindowName\n");
-#endif
+ winDebug ("GetWindowName\n");
/* Intialize ppName to NULL */
*ppName = NULL;
@@ -435,9 +392,7 @@ GetWindowName (Display *pDisplay, Window iWin, wchar_t **ppName)
nResult = XGetWMName (pDisplay, iWin, &xtpName);
if (!nResult || !xtpName.value || !xtpName.nitems)
{
-#if CYGMULTIWINDOW_DEBUG
ErrorF ("GetWindowName - XGetWMName failed. No name.\n");
-#endif
return;
}
@@ -460,10 +415,7 @@ GetWindowName (Display *pDisplay, Window iWin, wchar_t **ppName)
MultiByteToWideChar (CP_UTF8, 0, pszReturnData, -1, *ppName, iLen);
XFree (xtpName.value);
free (pszReturnData);
-
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("GetWindowName - Returning\n");
-#endif
+ winDebug ("GetWindowName - Returning\n");
}
@@ -626,13 +578,13 @@ 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 explicity break out */
for (;;)
@@ -655,48 +607,27 @@ winMultiWindowWMProc (void *pArg)
pthread_exit (NULL);
}
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("winMultiWindowWMProc - %d ms MSG: %d ID: %d\n",
+ winDebug ("winMultiWindowWMProc - %d ms MSG: %d ID: %d\n",
GetTickCount (), (int)pNode->msg.msg, (int)pNode->msg.dwID);
-#endif
/* 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,
@@ -708,12 +639,16 @@ winMultiWindowWMProc (void *pArg)
1);
UpdateName (pWMInfo, pNode->msg.iWindow);
winUpdateIcon (pNode->msg.iWindow);
+ {
+ HWND zstyle = HWND_NOTOPMOST;
+ winApplyHints (pWMInfo->pDisplay, pNode->msg.iWindow, pNode->msg.hwndWindow, &zstyle);
+ winUpdateWindowPosition (pNode->msg.hwndWindow, TRUE, &zstyle);
+ }
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,
@@ -725,9 +660,8 @@ 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,
@@ -747,18 +681,14 @@ winMultiWindowWMProc (void *pArg)
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");
{
int i, n, found = 0;
Atom *protocols;
@@ -789,9 +719,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 */
XSetInputFocus (pWMInfo->pDisplay,
@@ -835,9 +763,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;
}
@@ -860,7 +789,9 @@ winMultiWindowXMsgProc (void *pArg)
int iReturn;
XIconSize *xis;
- ErrorF ("winMultiWindowXMsgProc - Hello\n");
+ pthread_cleanup_push(&winMultiWindowThreadExit, NULL);
+
+ winDebug ("winMultiWindowXMsgProc - Hello\n");
/* Check that argument pointer is not invalid */
if (pProcArg == NULL)
@@ -869,7 +800,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);
@@ -881,14 +812,7 @@ 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);
- }
+ winDebug ("winMultiWindowXMsgProc - pthread_mutex_lock () returned.\n");
/* See if X supports the current locale */
if (XSupportsLocale () == False)
@@ -899,11 +823,16 @@ winMultiWindowXMsgProc (void *pArg)
/* 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);
+ g_winMultiWindowXMsgProcThread = pthread_self();
+ g_winMultiWindowXMsgProcOldIOErrorHandler = XSetIOErrorHandler (winMultiWindowXMsgProcIOErrorHandler);
/* Set jump point for IO Error exits */
iReturn = setjmp (g_jmpXMsgProcEntry);
-
+
/* Check if we should continue operations */
if (iReturn != WIN_JMP_ERROR_IO
&& iReturn != WIN_JMP_OKAY)
@@ -919,16 +848,11 @@ winMultiWindowXMsgProc (void *pArg)
pthread_exit (NULL);
}
- /* Install our error handler */
- XSetErrorHandler (winMultiWindowXMsgProcErrorHandler);
- XSetIOErrorHandler (winMultiWindowXMsgProcIOErrorHandler);
-
/* Setup the display connection string x */
- snprintf (pszDisplay,
- 512, "127.0.0.1:%s.%d", display, (int)pProcArg->dwScreen);
+ winGetDisplayName(pszDisplay, (int)pProcArg->dwScreen);
/* Print the display connection string */
- ErrorF ("winMultiWindowXMsgProc - DISPLAY=%s\n", pszDisplay);
+ winDebug ("winMultiWindowXMsgProc - DISPLAY=%s\n", pszDisplay);
/* Use our generated cookie for authentication */
winSetAuthorization();
@@ -943,7 +867,7 @@ winMultiWindowXMsgProc (void *pArg)
pProcArg->pDisplay = XOpenDisplay (pszDisplay);
if (pProcArg->pDisplay == NULL)
{
- ErrorF ("winMultiWindowXMsgProc - Could not open display, try: %d, "
+ winDebug ("winMultiWindowXMsgProc - Could not open display, try: %d, "
"sleeping: %d\n",
iRetries + 1, WIN_CONNECT_DELAY);
++iRetries;
@@ -963,7 +887,7 @@ winMultiWindowXMsgProc (void *pArg)
pthread_exit (NULL);
}
- ErrorF ("winMultiWindowXMsgProc - XOpenDisplay () returned and "
+ winDebug ("winMultiWindowXMsgProc - XOpenDisplay () returned and "
"successfully opened the display.\n");
/* Check if another window manager is already running */
@@ -1042,7 +966,7 @@ winMultiWindowXMsgProc (void *pArg)
XNextEvent (pProcArg->pDisplay, &event);
/* Branch on event type */
- if (event.type == CreateNotify)
+ if (event.type == MapNotify /* CreateNotify */)
{
XWindowAttributes attr;
@@ -1055,7 +979,7 @@ winMultiWindowXMsgProc (void *pArg)
event.xcreatewindow.window,
&attr);
- if (!attr.override_redirect)
+ if (!attr.override_redirect && attr.class != InputOnly)
XSetWindowBorderWidth(pProcArg->pDisplay,
event.xcreatewindow.window,
0);
@@ -1114,6 +1038,30 @@ winMultiWindowXMsgProc (void *pArg)
}
}
}
+ else if (event.type == ConfigureNotify)
+ {
+ if (!event.xconfigure.send_event)
+ {
+ /*
+ Java applications using AWT on JRE 1.6.0 break with non-reparenting WMs AWT
+ doesn't explicitly know about (See sun bug #6434227)
+
+ XDecoratedPeer.handleConfigureNotifyEvent() only processes non-synthetic
+ ConfigureNotify events to update window location if it's identified the
+ WM as a non-reparenting WM it knows about (compiz or lookingglass)
+
+ Rather than tell all sorts of lies to get XWM to recognize us as one of
+ those, simply send a synthetic ConfigureNotify for every non-synthetic one
+ */
+ XEvent event_send = event;
+ event_send.xconfigure.send_event = TRUE;
+ event_send.xconfigure.event = event.xconfigure.window;
+ XSendEvent(event.xconfigure.display,
+ event.xconfigure.window,
+ True, StructureNotifyMask,
+ &event_send);
+ }
+ }
else if (event.type == PropertyNotify
&& event.xproperty.atom == atmWmName)
{
@@ -1140,7 +1088,7 @@ winMultiWindowXMsgProc (void *pArg)
&& 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));
@@ -1152,7 +1100,7 @@ winMultiWindowXMsgProc (void *pArg)
}
XCloseDisplay (pProcArg->pDisplay);
- pthread_exit (NULL);
+ pthread_cleanup_pop(0);
return NULL;
}
@@ -1224,9 +1172,7 @@ winInitWM (void **ppWMInfo,
return FALSE;
}
-#if CYGDEBUG || YES
winDebug ("winInitWM - Returning.\n");
-#endif
return TRUE;
}
@@ -1243,7 +1189,7 @@ winInitMultiWindowWM (WMInfoPtr pWMInfo, WMProcArgPtr pProcArg)
char pszDisplay[512];
int iReturn;
- ErrorF ("winInitMultiWindowWM - Hello\n");
+ winDebug ("winInitMultiWindowWM - Hello\n");
/* Check that argument pointer is not invalid */
if (pProcArg == NULL)
@@ -1252,7 +1198,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);
@@ -1264,14 +1210,7 @@ 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);
- }
+ winDebug ("winInitMultiWindowWM - pthread_mutex_lock () returned.\n");
/* See if X supports the current locale */
if (XSupportsLocale () == False)
@@ -1282,11 +1221,16 @@ winInitMultiWindowWM (WMInfoPtr pWMInfo, WMProcArgPtr pProcArg)
/* 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);
+ g_winMultiWindowWMThread = pthread_self();
+ g_winMultiWindowWMOldIOErrorHandler = XSetIOErrorHandler (winMultiWindowWMIOErrorHandler);
/* Set jump point for IO Error exits */
iReturn = setjmp (g_jmpWMEntry);
-
+
/* Check if we should continue operations */
if (iReturn != WIN_JMP_ERROR_IO
&& iReturn != WIN_JMP_OKAY)
@@ -1302,19 +1246,11 @@ winInitMultiWindowWM (WMInfoPtr pWMInfo, WMProcArgPtr pProcArg)
pthread_exit (NULL);
}
- /* Install our error handler */
- XSetErrorHandler (winMultiWindowWMErrorHandler);
- XSetIOErrorHandler (winMultiWindowWMIOErrorHandler);
-
/* Setup the display connection string x */
- snprintf (pszDisplay,
- 512,
- "127.0.0.1:%s.%d",
- display,
- (int) pProcArg->dwScreen);
+ 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();
@@ -1346,7 +1282,7 @@ winInitMultiWindowWM (WMInfoPtr pWMInfo, WMProcArgPtr pProcArg)
pthread_exit (NULL);
}
- ErrorF ("winInitMultiWindowWM - XOpenDisplay () returned and "
+ winDebug ("winInitMultiWindowWM - XOpenDisplay () returned and "
"successfully opened the display.\n");
@@ -1383,9 +1319,7 @@ winSendMessageToWM (void *pWMInfo, winWMMessagePtr pMsg)
{
WMMsgNodePtr pNode;
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("winSendMessageToWM ()\n");
-#endif
+ winDebug ("winSendMessageToWM ()\n");
pNode = (WMMsgNodePtr)malloc(sizeof(WMMsgNodeRec));
if (pNode != NULL)
@@ -1417,7 +1351,18 @@ winMultiWindowWMErrorHandler (Display *pDisplay, XErrorEvent *pErr)
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;
}
@@ -1432,12 +1377,18 @@ winMultiWindowWMIOErrorHandler (Display *pDisplay)
{
ErrorF ("winMultiWindowWMIOErrorHandler!\n\n");
- if (g_shutdown)
- pthread_exit(NULL);
+ 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);
+ }
+
+ if (g_winMultiWindowWMOldIOErrorHandler)
+ g_winMultiWindowWMOldIOErrorHandler(pDisplay);
- /* Restart at the main entry point */
- longjmp (g_jmpWMEntry, WIN_JMP_ERROR_IO);
-
return 0;
}
@@ -1455,9 +1406,18 @@ winMultiWindowXMsgProcErrorHandler (Display *pDisplay, XErrorEvent *pErr)
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;
}
@@ -1472,12 +1432,30 @@ winMultiWindowXMsgProcIOErrorHandler (Display *pDisplay)
{
ErrorF ("winMultiWindowXMsgProcIOErrorHandler!\n\n");
- /* Restart at the main entry point */
- longjmp (g_jmpXMsgProcEntry, WIN_JMP_ERROR_IO);
-
+ if (pthread_equal(pthread_self(),g_winMultiWindowXMsgProcThread))
+ {
+ /* Restart at the main entry point */
+ longjmp (g_jmpXMsgProcEntry, WIN_JMP_ERROR_IO);
+ }
+
+ if (g_winMultiWindowXMsgProcOldIOErrorHandler)
+ g_winMultiWindowXMsgProcOldIOErrorHandler(pDisplay);
+
return 0;
}
+/*
+ * winMultiWindowThreadExit - Thread exit handler
+ */
+
+static void
+winMultiWindowThreadExit(void *arg)
+{
+ AbortDDX();
+
+ /* multiwindow client thread has exited, stop server as well */
+ TerminateProcess(GetCurrentProcess(),1);
+}
/*
* Catch RedirectError to detect other window manager running
@@ -1528,7 +1506,7 @@ CheckAnotherWindowManager (Display *pDisplay, DWORD dwScreen, Bool fAllowOtherWM
void
winDeinitMultiWindowWM (void)
{
- ErrorF ("winDeinitMultiWindowWM - Noting shutdown in progress\n");
+ winDebug ("winDeinitMultiWindowWM - Noting shutdown in progress\n");
g_shutdown = TRUE;
}
@@ -1553,6 +1531,8 @@ winApplyHints (Display *pDisplay, Window iWindow, HWND hWnd, HWND *zstyle)
int format;
unsigned long hint = 0, maxmin = 0, style, nitems = 0 , left = 0;
WindowPtr pWin = GetProp (hWnd, WIN_WINDOW_PROP);
+ MwmHints *mwm_hint = NULL;
+ WinXSizeHints SizeHints;
if (!hWnd) return;
if (!IsWindow (hWnd)) return;
@@ -1584,7 +1564,6 @@ winApplyHints (Display *pDisplay, Window iWindow, HWND hWnd, HWND *zstyle)
}
nitems = left = 0;
- MwmHints *mwm_hint = NULL;
if (XGetWindowProperty(pDisplay, iWindow, motif_wm_hints, 0L,
PropMwmHintsElements, False, motif_wm_hints, &type, &format,
&nitems, &left, (unsigned char **)&mwm_hint) == Success)
@@ -1657,16 +1636,14 @@ winApplyHints (Display *pDisplay, Window iWindow, HWND hWnd, HWND *zstyle)
if (style & STYLE_NOTITLE)
hint = (hint & ~HINT_NOFRAME & ~HINT_BORDER & ~HINT_CAPTION) | HINT_SIZEBOX;
else if (style & STYLE_OUTLINE)
- hint = (hint & ~HINT_NOFRAME & ~HINT_SIZEBOX & ~HINT_CAPTION) | HINT_BORDER;
+ hint = (hint & ~HINT_NOFRAME & ~HINT_CAPTION) | HINT_BORDER;
else if (style & STYLE_NOFRAME)
- hint = (hint & ~HINT_BORDER & ~HINT_CAPTION & ~HINT_SIZEBOX) | HINT_NOFRAME;
+ hint = (hint & ~HINT_BORDER & ~HINT_CAPTION) | HINT_NOFRAME;
/* Now apply styles to window */
style = GetWindowLongPtr(hWnd, GWL_STYLE) & ~WS_CAPTION & ~WS_SIZEBOX; /* Just in case */
- if (!style) return;
-
- if (!hint) /* All on */
- style = style | WS_CAPTION | WS_SIZEBOX;
+ if (!hint) /* All on, but no resize of children is allowed */
+ style = style | WS_CAPTION;
else if (hint & HINT_NOFRAME) /* All off */
style = style & ~WS_CAPTION & ~WS_SIZEBOX;
else style = style | ((hint & HINT_BORDER) ? WS_BORDER : 0) |
@@ -1676,6 +1653,14 @@ winApplyHints (Display *pDisplay, Window iWindow, HWND hWnd, HWND *zstyle)
if (hint & HINT_NOMAXIMIZE)
style = style & ~WS_MAXIMIZEBOX;
+
+ if (winMultiWindowGetWMNormalHints(pWin, &SizeHints))
+ {
+ if (!(SizeHints.max_width&&SizeHints.max_height&&(SizeHints.min_width == SizeHints.max_width)&&(SizeHints.min_height == SizeHints.max_height) ))
+ style|=WS_SIZEBOX;
+ }
+ else
+ style|=WS_SIZEBOX;
SetWindowLongPtr (hWnd, GWL_STYLE, style);
}
@@ -1703,12 +1688,6 @@ winUpdateWindowPosition (HWND hWnd, Bool reshape, HWND *zstyle)
/* Setup a rectangle with the X window position and size */
SetRect (&rcNew, iX, iY, iX + iWidth, iY + iHeight);
-#if 0
- ErrorF ("winUpdateWindowPosition - (%d, %d)-(%d, %d)\n",
- rcNew.left, rcNew.top,
- rcNew.right, rcNew.bottom);
-#endif
-
AdjustWindowRectEx (&rcNew, GetWindowLongPtr (hWnd, GWL_STYLE), FALSE, WS_EX_APPWINDOW);
/* Don't allow window decoration to disappear off to top-left as a result of this adjustment */
@@ -1726,12 +1705,6 @@ winUpdateWindowPosition (HWND hWnd, Bool reshape, HWND *zstyle)
rcNew.bottom += iDy;
}
-#if 0
- ErrorF ("winUpdateWindowPosition - (%d, %d)-(%d, %d)\n",
- rcNew.left, rcNew.top,
- rcNew.right, rcNew.bottom);
-#endif
-
/* Position the Windows window */
SetWindowPos (hWnd, *zstyle, rcNew.left, rcNew.top,
rcNew.right - rcNew.left, rcNew.bottom - rcNew.top,