diff options
author | Jon TURNEY <jon.turney@dronecode.org.uk> | 2009-11-04 17:34:40 +0000 |
---|---|---|
committer | Jon TURNEY <jon.turney@dronecode.org.uk> | 2009-11-09 20:33:35 +0000 |
commit | 71519a572fe15b85c0eb2b02636c9e871f2c858f (patch) | |
tree | cfb841190176086ee14632254cda7bf23e2073af /hw | |
parent | f3fad371cce0f3836514ad5b29e59fa1ca0627a7 (diff) |
Cygwin/X: Fix typo in g_fAnotherWMRunning and tidy up WM detection code
Tidy up code for detecting another WM is already running
Fix typo g_fAnotherWMRunnig -> g_fAnotherWMRunning
Remove some unused event mask macros
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/xwin/winmultiwindowwindow.c | 12 | ||||
-rw-r--r-- | hw/xwin/winmultiwindowwm.c | 65 |
2 files changed, 25 insertions, 52 deletions
diff --git a/hw/xwin/winmultiwindowwindow.c b/hw/xwin/winmultiwindowwindow.c index 631f1a97d..447c99b56 100644 --- a/hw/xwin/winmultiwindowwindow.c +++ b/hw/xwin/winmultiwindowwindow.c @@ -64,18 +64,6 @@ winUpdateWindowsWindow (WindowPtr pWin); static void winFindWindow (pointer value, XID id, pointer cdata); -/* - * Macros - */ - -#define SubSend(pWin) \ - ((pWin->eventMask|wOtherEventMasks(pWin)) & SubstructureNotifyMask) - -#define StrSend(pWin) \ - ((pWin->eventMask|wOtherEventMasks(pWin)) & StructureNotifyMask) - -#define SubStrSend(pWin,pParent) (StrSend(pWin) || SubSend(pParent)) - static void winInitMultiWindowClass(void) { diff --git a/hw/xwin/winmultiwindowwm.c b/hw/xwin/winmultiwindowwm.c index 18d9aedc2..d7f13c7ef 100644 --- a/hw/xwin/winmultiwindowwm.c +++ b/hw/xwin/winmultiwindowwm.c @@ -209,7 +209,7 @@ static jmp_buf g_jmpWMEntry; static jmp_buf g_jmpXMsgProcEntry; static Bool g_shutdown = FALSE; static Bool redirectError = FALSE; -static Bool g_fAnotherWMRunnig = FALSE; +static Bool g_fAnotherWMRunning = FALSE; /* * PushMessage - Push a message onto the queue @@ -651,7 +651,7 @@ winMultiWindowWMProc (void *pArg) { WMMsgNodePtr pNode; - if(g_fAnotherWMRunnig)/* Another Window manager exists. */ + if(g_fAnotherWMRunning)/* Another Window manager exists. */ { Sleep (1000); continue; @@ -978,26 +978,15 @@ winMultiWindowXMsgProc (void *pArg) "successfully opened the display.\n"); /* Check if another window manager is already running */ - 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_fAnotherWMRunning = CheckAnotherWindowManager (pProcArg->pDisplay, pProcArg->dwScreen); + + if (g_fAnotherWMRunning && !pProcArg->pWMInfo->fAllowOtherWM) + { + ErrorF ("winMultiWindowXMsgProc - " + "another window manager is running. Exiting.\n"); + pthread_exit (NULL); } - g_fAnotherWMRunnig = FALSE; - } - + /* Set up the supported icon sizes */ xis = XAllocIconSize (); if (xis) @@ -1032,17 +1021,17 @@ winMultiWindowXMsgProc (void *pArg) { if (CheckAnotherWindowManager (pProcArg->pDisplay, pProcArg->dwScreen)) { - if (!g_fAnotherWMRunnig) + if (!g_fAnotherWMRunning) { - g_fAnotherWMRunnig = TRUE; + g_fAnotherWMRunning = TRUE; SendMessage(*(HWND*)pProcArg->hwndScreen, WM_UNMANAGE, 0, 0); } } else { - if (g_fAnotherWMRunnig) + if (g_fAnotherWMRunning) { - g_fAnotherWMRunnig = FALSE; + g_fAnotherWMRunning = FALSE; SendMessage(*(HWND*)pProcArg->hwndScreen, WM_MANAGE, 0, 0); } } @@ -1454,27 +1443,23 @@ winRedirectErrorHandler (Display *pDisplay, XErrorEvent *pErr) static Bool CheckAnotherWindowManager (Display *pDisplay, DWORD dwScreen) { + /* + Try to select the events which only one client at a time is allowed to select. + If this causes an error, another window manager is already running... + */ redirectError = FALSE; XSetErrorHandler (winRedirectErrorHandler); XSelectInput(pDisplay, RootWindow (pDisplay, dwScreen), - // SubstructureNotifyMask | ButtonPressMask - ColormapChangeMask | EnterWindowMask | PropertyChangeMask | - SubstructureRedirectMask | KeyPressMask | - ButtonPressMask | ButtonReleaseMask); + ResizeRedirectMask | SubstructureRedirectMask | ButtonPressMask); XSync (pDisplay, 0); XSetErrorHandler (winMultiWindowXMsgProcErrorHandler); - XSelectInput(pDisplay, RootWindow (pDisplay, dwScreen), - SubstructureNotifyMask); + + /* + Side effect: select the events we are actually interested in... + */ + XSelectInput(pDisplay, RootWindow (pDisplay, dwScreen), SubstructureNotifyMask); XSync (pDisplay, 0); - if (redirectError) - { - //ErrorF ("CheckAnotherWindowManager() - another window manager is running. Exiting.\n"); - return TRUE; - } - else - { - return FALSE; - } + return redirectError; } /* |