diff options
-rw-r--r-- | hw/xwin/winmultiwindowwindow.c | 15 | ||||
-rw-r--r-- | hw/xwin/winmultiwindowwm.c | 172 | ||||
-rw-r--r-- | hw/xwin/winmultiwindowwndproc.c | 35 | ||||
-rw-r--r-- | hw/xwin/winwindow.h | 1 |
4 files changed, 109 insertions, 114 deletions
diff --git a/hw/xwin/winmultiwindowwindow.c b/hw/xwin/winmultiwindowwindow.c index 28828af8a..e81fe2fcc 100644 --- a/hw/xwin/winmultiwindowwindow.c +++ b/hw/xwin/winmultiwindowwindow.c @@ -876,11 +876,6 @@ winUpdateWindowsWindow(WindowPtr pWin) winCreateWindowsWindow(pWin); assert(pWinPriv->hWnd != NULL); } - - /* Display the window without activating it */ - if (pWin->drawable.class != InputOnly) - ShowWindow(pWinPriv->hWnd, SW_SHOWNOACTIVATE); - } /* It's not a top-level window, but we created a window for GLX */ else if (pWinPriv->hWnd) { @@ -897,16 +892,6 @@ winUpdateWindowsWindow(WindowPtr pWin) pWin->drawable.y - pWin->parent->drawable.y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW); } - - /* If it's top level, or a GLX window which has already been created getting mapped, show it */ - if (pWinPriv->hWnd != NULL) { - /* Display the window without activating it */ - if (pWin->drawable.class != InputOnly) - ShowWindow(pWinPriv->hWnd, SW_SHOWNOACTIVATE); - - /* Send first paint message */ - UpdateWindow(pWinPriv->hWnd); - } } else if (pWinPriv->hWnd != NULL) { /* If it's been reparented to an unmapped window when previously mapped, destroy the Windows window */ 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) | diff --git a/hw/xwin/winmultiwindowwndproc.c b/hw/xwin/winmultiwindowwndproc.c index 6f3291175..2c123acb1 100644 --- a/hw/xwin/winmultiwindowwndproc.c +++ b/hw/xwin/winmultiwindowwndproc.c @@ -299,6 +299,10 @@ static void winAdjustXWindowState(winPrivScreenPtr s_pScreenPriv, winWMMessageRec *wmMsg) { + /* Do nothing if window has not yet been given initial state */ + if (!GetProp(wmMsg->hwndWindow, WIN_STATE_PROP)) + return; + wmMsg->msg = WM_WM_CHANGE_STATE; if (IsIconic(wmMsg->hwndWindow)) { wmMsg->dwID = 3; // IconicState @@ -348,6 +352,20 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) lParam); #endif + /* + If this is WM_CREATE, set up the Windows window properties which point to X window information, + before we populate other local variables... + */ + if (message == WM_CREATE) { + SetProp(hwnd, + WIN_WINDOW_PROP, + (HANDLE) ((LPCREATESTRUCT) lParam)->lpCreateParams); + SetProp(hwnd, + WIN_WID_PROP, + (HANDLE) (INT_PTR)winGetWindowID(((LPCREATESTRUCT) lParam)-> + lpCreateParams)); + } + /* Check if the Windows window property for our X window pointer is valid */ if ((pWin = GetProp(hwnd, WIN_WINDOW_PROP)) != NULL) { /* Our X window pointer is valid */ @@ -408,18 +426,6 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) /* Branch on message type */ switch (message) { case WM_CREATE: - - /* */ - SetProp(hwnd, - WIN_WINDOW_PROP, - (HANDLE) ((LPCREATESTRUCT) lParam)->lpCreateParams); - - /* */ - SetProp(hwnd, - WIN_WID_PROP, - (HANDLE) (INT_PTR) winGetWindowID(((LPCREATESTRUCT) lParam)-> - lpCreateParams)); - /* * Make X windows' Z orders sync with Windows windows because * there can be AlwaysOnTop windows overlapped on the window @@ -440,6 +446,11 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR) XMING_SIGNATURE); + /* Tell our Window Manager thread to style and then show the window */ + wmMsg.msg = WM_WM_CREATE; + if (fWMMsgInitialized) + winSendMessageToWM(s_pScreenPriv->pWMInfo, &wmMsg); + return 0; case WM_INIT_SYS_MENU: diff --git a/hw/xwin/winwindow.h b/hw/xwin/winwindow.h index 83c772c09..0d1bb7651 100644 --- a/hw/xwin/winwindow.h +++ b/hw/xwin/winwindow.h @@ -114,6 +114,7 @@ typedef struct _winWMMessageRec { #define WM_WM_MAP_UNMANAGED (WM_USER + 12) #define WM_WM_MAP_MANAGED (WM_USER + 13) #define WM_WM_HINTS_EVENT (WM_USER + 14) +#define WM_WM_CREATE (WM_USER + 15) #define MwmHintsDecorations (1L << 1) |