diff options
Diffstat (limited to 'hw/xwin/winmultiwindowwm.c')
-rw-r--r-- | hw/xwin/winmultiwindowwm.c | 172 |
1 files changed, 85 insertions, 87 deletions
diff --git a/hw/xwin/winmultiwindowwm.c b/hw/xwin/winmultiwindowwm.c index ac5a58309..215b81324 100644 --- a/hw/xwin/winmultiwindowwm.c +++ b/hw/xwin/winmultiwindowwm.c @@ -104,6 +104,9 @@ extern void winUpdateWindowPosition(HWND hWnd, HWND * zstyle); #define WIN_MSG_QUEUE_FNAME "/dev/windows" #endif +#define HINT_MAX (1L<<0) +#define HINT_MIN (1L<<1) + /* * Local structures */ @@ -118,7 +121,6 @@ typedef struct _WMMsgQueueRec { struct _WMMsgNodeRec *pTail; pthread_mutex_t pmMutex; pthread_cond_t pcNotEmpty; - int nQueueSize; } WMMsgQueueRec, *WMMsgQueuePtr; typedef struct _WMInfo { @@ -192,7 +194,7 @@ static Bool CheckAnotherWindowManager(xcb_connection_t *conn, DWORD dwScreen); static void - winApplyHints(WMInfoPtr pWMInfo, xcb_window_t iWindow, HWND hWnd, HWND * zstyle, Bool onCreate); + winApplyHints(WMInfoPtr pWMInfo, xcb_window_t iWindow, HWND hWnd, HWND * zstyle, unsigned long *maxmin); static void winApplyUrgency(WMInfoPtr pWMInfo, xcb_window_t iWindow, HWND hWnd); @@ -254,6 +256,9 @@ MessageName(winWMMessagePtr msg) case WM_WM_HINTS_EVENT: return "WM_WM_HINTS_EVENT"; break; + case WM_WM_CREATE: + return "WM_WM_CREATE"; + break; default: return "Unknown Message"; break; @@ -283,9 +288,6 @@ PushMessage(WMMsgQueuePtr pQueue, WMMsgNodePtr pNode) pQueue->pHead = pNode; } - /* Increase the count of elements in the queue by one */ - ++(pQueue->nQueueSize); - /* Release the queue mutex */ pthread_mutex_unlock(&pQueue->pmMutex); @@ -293,25 +295,6 @@ PushMessage(WMMsgQueuePtr pQueue, WMMsgNodePtr pNode) pthread_cond_signal(&pQueue->pcNotEmpty); } -#if CYGMULTIWINDOW_DEBUG -/* - * QueueSize - Return the size of the queue - */ - -static int -QueueSize(WMMsgQueuePtr pQueue) -{ - WMMsgNodePtr pNode; - int nSize = 0; - - /* Loop through all elements in the queue */ - for (pNode = pQueue->pHead; pNode != NULL; pNode = pNode->pNext) - ++nSize; - - return nSize; -} -#endif - /* * PopMessage - Pop a message from the queue */ @@ -338,13 +321,6 @@ PopMessage(WMMsgQueuePtr pQueue, WMInfoPtr pWMInfo) pQueue->pTail = NULL; } - /* 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 - /* Release the queue mutex */ pthread_mutex_unlock(&pQueue->pmMutex); @@ -388,14 +364,6 @@ InitQueue(WMMsgQueuePtr pQueue) pQueue->pHead = NULL; pQueue->pTail = NULL; - /* There are no elements initially */ - pQueue->nQueueSize = 0; - -#if CYGMULTIWINDOW_DEBUG - winDebug("InitQueue - Queue Size %d %d\n", pQueue->nQueueSize, - QueueSize(pQueue)); -#endif - winDebug("InitQueue - Calling pthread_mutex_init\n"); /* Create synchronization objects */ @@ -601,8 +569,10 @@ getHwnd(WMInfoPtr pWMInfo, xcb_window_t iWindow) } /* Some sanity checks */ - if (!hWnd) + if (!hWnd) { + winDebug("getHwnd: no HWND\n"); return NULL; + } if (!IsWindow(hWnd)) return NULL; @@ -740,7 +710,7 @@ UpdateIcon(WMInfoPtr pWMInfo, xcb_window_t iWindow) */ static void -UpdateStyle(WMInfoPtr pWMInfo, xcb_window_t iWindow, Bool onCreate) +UpdateStyle(WMInfoPtr pWMInfo, xcb_window_t iWindow, unsigned long *maxmin) { HWND hWnd; HWND zstyle = HWND_NOTOPMOST; @@ -750,8 +720,12 @@ UpdateStyle(WMInfoPtr pWMInfo, xcb_window_t iWindow, Bool onCreate) if (!hWnd) return; + /* If window isn't override-redirect */ + if (IsOverrideRedirect(pWMInfo->conn, iWindow)) + return; + /* Determine the Window style, which determines borders and clipping region... */ - winApplyHints(pWMInfo, iWindow, hWnd, &zstyle, onCreate); + winApplyHints(pWMInfo, iWindow, hWnd, &zstyle, maxmin); winUpdateWindowPosition(hWnd, &zstyle); /* Apply the updated window style, without changing it's show or activation state */ @@ -997,12 +971,62 @@ winMultiWindowWMProc(void *pArg) } #if CYGMULTIWINDOW_DEBUG - ErrorF("winMultiWindowWMProc - MSG: %s (%d) ID: %d\n", - MessageName(&(pNode->msg)), (int)pNode->msg.msg, (int)pNode->msg.dwID); + ErrorF("winMultiWindowWMProc - MSG: %s (%d) Window: %08x ID: %d\n", + MessageName(&(pNode->msg)), (int)pNode->msg.msg, pNode->msg.iWindow, (int)pNode->msg.dwID); #endif /* Branch on the message type */ switch (pNode->msg.msg) { + case WM_WM_CREATE: + { + unsigned long maxmin = 0; +#if CYGMULTIWINDOW_DEBUG + ErrorF("\tWM_WM_CREATE\n"); +#endif + + /* Put a note as to the HWND associated with this Window */ + xcb_change_property(pWMInfo->conn, XCB_PROP_MODE_REPLACE, + pNode->msg.iWindow, pWMInfo->atmPrivMap, + XCB_ATOM_INTEGER, 32, + sizeof(HWND)/4, &(pNode->msg.hwndWindow)); + + + /* Determine the Window style, which determines borders and clipping region... */ + UpdateStyle(pWMInfo, pNode->msg.iWindow, &maxmin); + + /* Display the window without activating it */ + { + xcb_get_window_attributes_cookie_t cookie; + xcb_get_window_attributes_reply_t *reply; + + cookie = xcb_get_window_attributes(pWMInfo->conn, pNode->msg.iWindow); + reply = xcb_get_window_attributes_reply(pWMInfo->conn, cookie, NULL); + + if (reply) { + if (reply->_class != InputOnly) + ShowWindow(pNode->msg.hwndWindow, SW_SHOWNA); + free(reply); + } + } + + /* Send first paint message */ + UpdateWindow(pNode->msg.hwndWindow); + + /* Establish initial state */ + UpdateState(pWMInfo, pNode->msg.iWindow, XCB_ICCCM_WM_STATE_NORMAL); + + /* + It only makes sense to apply minimize/maximize override as the + initial state, otherwise that state can't be changed. + */ + if (maxmin & HINT_MAX) + SendMessage(pNode->msg.hwndWindow, WM_SYSCOMMAND, SC_MAXIMIZE, 0); + else if (maxmin & HINT_MIN) + SendMessage(pNode->msg.hwndWindow, WM_SYSCOMMAND, SC_MINIMIZE, 0); + } + + break; + #if 0 case WM_WM_MOVE: break; @@ -1034,37 +1058,21 @@ winMultiWindowWMProc(void *pArg) break; case WM_WM_MAP: - /* Put a note as to the HWND associated with this Window */ - xcb_change_property(pWMInfo->conn, XCB_PROP_MODE_REPLACE, - pNode->msg.iWindow, pWMInfo->atmPrivMap, - XCB_ATOM_INTEGER, 32, - sizeof(HWND)/4, &(pNode->msg.hwndWindow)); - UpdateName(pWMInfo, pNode->msg.iWindow); UpdateIcon(pWMInfo, pNode->msg.iWindow); break; case WM_WM_MAP_UNMANAGED: - /* Put a note as to the HWND associated with this Window */ - xcb_change_property(pWMInfo->conn, XCB_PROP_MODE_REPLACE, - pNode->msg.iWindow, pWMInfo->atmPrivMap, - XCB_ATOM_INTEGER, 32, - sizeof(HWND)/4, &(pNode->msg.hwndWindow)); - break; case WM_WM_MAP_MANAGED: - /* Put a note as to the HWND associated with this Window */ - xcb_change_property(pWMInfo->conn, XCB_PROP_MODE_REPLACE, - pNode->msg.iWindow, pWMInfo->atmPrivMap, - XCB_ATOM_INTEGER, 32, - sizeof(HWND)/4, &(pNode->msg.hwndWindow)); + { + unsigned long maxmin = 0; UpdateName(pWMInfo, pNode->msg.iWindow); - UpdateStyle(pWMInfo, pNode->msg.iWindow, TRUE); + UpdateStyle(pWMInfo, pNode->msg.iWindow, &maxmin); UpdateIcon(pWMInfo, pNode->msg.iWindow); - /* Reshape */ { WindowPtr pWin = @@ -1074,8 +1082,9 @@ winMultiWindowWMProc(void *pArg) winUpdateRgnMultiWindow(pWin); } } + } - break; + break; case WM_WM_UNMAP: @@ -1144,11 +1153,13 @@ winMultiWindowWMProc(void *pArg) case WM_WM_HINTS_EVENT: { + unsigned long maxmin = 0; + /* Don't do anything if this is an override-redirect window */ if (IsOverrideRedirect(pWMInfo->conn, pNode->msg.iWindow)) break; - UpdateStyle(pWMInfo, pNode->msg.iWindow, FALSE); + UpdateStyle(pWMInfo, pNode->msg.iWindow, &maxmin); } break; @@ -1897,7 +1908,7 @@ winSendMessageToWM(void *pWMInfo, winWMMessagePtr pMsg) WMMsgNodePtr pNode; #if CYGMULTIWINDOW_DEBUG - ErrorF("winSendMessageToWM %s\n", MessageName(pMsg)); + ErrorF("winSendMessageToWM %s %08x %d\n", MessageName(pMsg), pMsg->iWindow, pMsg->dwID); #endif pNode = malloc(sizeof(WMMsgNodeRec)); @@ -2020,12 +2031,9 @@ winApplyUrgency(WMInfoPtr pWMInfo, xcb_window_t iWindow, HWND hWnd) #define HINT_NOMINIMIZE (1L<<5) #define HINT_NOSYSMENU (1L<<6) #define HINT_SKIPTASKBAR (1L<<7) -/* These two are used on their own */ -#define HINT_MAX (1L<<0) -#define HINT_MIN (1L<<1) static void -winApplyHints(WMInfoPtr pWMInfo, xcb_window_t iWindow, HWND hWnd, HWND * zstyle, Bool onCreate) +winApplyHints(WMInfoPtr pWMInfo, xcb_window_t iWindow, HWND hWnd, HWND * zstyle, unsigned long *maxmin) { xcb_connection_t *conn = pWMInfo->conn; @@ -2036,9 +2044,10 @@ winApplyHints(WMInfoPtr pWMInfo, xcb_window_t iWindow, HWND hWnd, HWND * zstyle, static int generation; unsigned long hint = HINT_BORDER | HINT_SIZEBOX | HINT_CAPTION; - unsigned long maxmin = 0; unsigned long style, exStyle; + *maxmin = 0; + if (!hWnd) return; if (!IsWindow(hWnd)) @@ -2070,9 +2079,9 @@ winApplyHints(WMInfoPtr pWMInfo, xcb_window_t iWindow, HWND hWnd, HWND * zstyle, if (pAtom[i] == skiptaskbarState) hint |= HINT_SKIPTASKBAR; if (pAtom[i] == hiddenState) - maxmin |= HINT_MIN; + *maxmin |= HINT_MIN; else if (pAtom[i] == fullscreenState) - maxmin |= HINT_MAX; + *maxmin |= HINT_MAX; if (pAtom[i] == belowState) *zstyle = HWND_BOTTOM; else if (pAtom[i] == aboveState) @@ -2084,7 +2093,7 @@ winApplyHints(WMInfoPtr pWMInfo, xcb_window_t iWindow, HWND hWnd, HWND * zstyle, } if (verMax && horMax) - maxmin |= HINT_MAX; + *maxmin |= HINT_MAX; free(reply); } @@ -2197,12 +2206,6 @@ winApplyHints(WMInfoPtr pWMInfo, xcb_window_t iWindow, HWND hWnd, HWND * zstyle, style = STYLE_NONE; style = winOverrideStyle(res_name, res_class, window_name); - /* - It only makes sense to apply minimize/maximize override when the - window is mapped, as otherwise the state can't be changed. - */ - if (!onCreate) - style &= ~(STYLE_MAXIMIZE | STYLE_MINIMIZE); #define APPLICATION_ID_FORMAT "%s.xwin.%s" #define APPLICATION_ID_UNKNOWN "unknown" @@ -2225,17 +2228,12 @@ winApplyHints(WMInfoPtr pWMInfo, xcb_window_t iWindow, HWND hWnd, HWND * zstyle, if (style & STYLE_TOPMOST) *zstyle = HWND_TOPMOST; else if (style & STYLE_MAXIMIZE) - maxmin = (hint & ~HINT_MIN) | HINT_MAX; + *maxmin = (hint & ~HINT_MIN) | HINT_MAX; else if (style & STYLE_MINIMIZE) - maxmin = (hint & ~HINT_MAX) | HINT_MIN; + *maxmin = (hint & ~HINT_MAX) | HINT_MIN; else if (style & STYLE_BOTTOM) *zstyle = HWND_BOTTOM; - if (maxmin & HINT_MAX) - SendMessage(hWnd, WM_SYSCOMMAND, SC_MAXIMIZE, 0); - else if (maxmin & HINT_MIN) - SendMessage(hWnd, WM_SYSCOMMAND, SC_MINIMIZE, 0); - if (style & STYLE_NOTITLE) hint = (hint & ~HINT_NOFRAME & ~HINT_BORDER & ~HINT_CAPTION) | |