From 3af77ad3e754c4d419a1996ca73a9fd01f92388a Mon Sep 17 00:00:00 2001 From: Alexander Gottwald Date: Tue, 5 Jul 2005 14:09:48 +0000 Subject: [PATCH] External windowmanagers could connect in multiwindow mode which lead to strange results with the internal windowmanager. --- hw/xwin/ChangeLog | 8 ++++++++ hw/xwin/winmultiwindowwm.c | 27 ++++++++++++++++++++++++--- hw/xwin/winscrinit.c | 3 ++- hw/xwin/winwindow.h | 3 ++- 4 files changed, 36 insertions(+), 5 deletions(-) diff --git a/hw/xwin/ChangeLog b/hw/xwin/ChangeLog index b9f521cb3..7ce672667 100644 --- a/hw/xwin/ChangeLog +++ b/hw/xwin/ChangeLog @@ -1,3 +1,11 @@ +2005-07-05 Alexander Gottwald + + * winwindow.h: + * winmultiwindowwm.c: + * winscrinit.c: + External windowmanagers could connect in multiwindow mode which lead + to strange results with the internal windowmanager. + 2005-07-05 Alexander Gottwald * *.c: diff --git a/hw/xwin/winmultiwindowwm.c b/hw/xwin/winmultiwindowwm.c index 217603dc9..47c43d98f 100644 --- a/hw/xwin/winmultiwindowwm.c +++ b/hw/xwin/winmultiwindowwm.c @@ -112,6 +112,7 @@ typedef struct _WMInfo { Atom atmWmProtos; Atom atmWmDelete; Atom atmPrivMap; + Bool fAllowOtherWM; } WMInfoRec, *WMInfoPtr; typedef struct _WMProcArgRec { @@ -933,7 +934,25 @@ winMultiWindowXMsgProc (void *pArg) "successfully opened the display.\n"); /* Check if another window manager is already running */ - g_fAnotherWMRunnig = CheckAnotherWindowManager (pProcArg->pDisplay, pProcArg->dwScreen); + if (pProcArg->pWMInfo->fAllowOtherWM) + { + g_fAnotherWMRunnig = CheckAnotherWindowManager (pProcArg->pDisplay, pProcArg->dwScreen); + } else { + redirectError = FALSE; + XSetErrorHandler (winRedirectErrorHandler); + XSelectInput(pProcArg->pDisplay, + RootWindow (pProcArg->pDisplay, pProcArg->dwScreen), + SubstructureNotifyMask | ButtonPressMask); + XSync (pProcArg->pDisplay, 0); + XSetErrorHandler (winMultiWindowXMsgProcErrorHandler); + if (redirectError) + { + ErrorF ("winMultiWindowXMsgProc - " + "another window manager is running. Exiting.\n"); + pthread_exit (NULL); + } + g_fAnotherWMRunnig = FALSE; + } /* Set up the supported icon sizes */ xis = XAllocIconSize (); @@ -962,7 +981,7 @@ winMultiWindowXMsgProc (void *pArg) /* Loop until we explicitly break out */ while (1) { - if (!XPending (pProcArg->pDisplay)) + if (pProcArg->pWMInfo->fAllowOtherWM && !XPending (pProcArg->pDisplay)) { if (CheckAnotherWindowManager (pProcArg->pDisplay, pProcArg->dwScreen)) { @@ -1057,7 +1076,8 @@ winInitWM (void **ppWMInfo, pthread_t *ptXMsgProc, pthread_mutex_t *ppmServerStarted, int dwScreen, - HWND hwndScreen) + HWND hwndScreen, + BOOL allowOtherWM) { WMProcArgPtr pArg = (WMProcArgPtr) malloc (sizeof(WMProcArgRec)); WMInfoPtr pWMInfo = (WMInfoPtr) malloc (sizeof(WMInfoRec)); @@ -1077,6 +1097,7 @@ winInitWM (void **ppWMInfo, /* Set a return pointer to the Window Manager info structure */ *ppWMInfo = pWMInfo; + pWMInfo->fAllowOtherWM = allowOtherWM; /* Setup the argument structure for the thread function */ pArg->dwScreen = dwScreen; diff --git a/hw/xwin/winscrinit.c b/hw/xwin/winscrinit.c index d5117513e..0c8d23ad5 100644 --- a/hw/xwin/winscrinit.c +++ b/hw/xwin/winscrinit.c @@ -610,7 +610,8 @@ winFinishScreenInitFB (int index, &pScreenPriv->ptXMsgProc, &pScreenPriv->pmServerStarted, pScreenInfo->dwScreen, - (HWND)&pScreenPriv->hwndScreen)) + (HWND)&pScreenPriv->hwndScreen, + pScreenInfo->fInternalWM)) { ErrorF ("winFinishScreenInitFB - winInitWM () failed.\n"); return FALSE; diff --git a/hw/xwin/winwindow.h b/hw/xwin/winwindow.h index 6cc69aa19..d0499bcbb 100644 --- a/hw/xwin/winwindow.h +++ b/hw/xwin/winwindow.h @@ -124,7 +124,8 @@ winInitWM (void **ppWMInfo, pthread_t *ptXMsgProc, pthread_mutex_t *ppmServerStarted, int dwScreen, - HWND hwndScreen); + HWND hwndScreen, + BOOL allowOtherWM); void winDeinitMultiWindowWM (void);