summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Turney <jon.turney@dronecode.org.uk>2015-12-01 19:33:38 +0000
committerJon Turney <jon.turney@dronecode.org.uk>2016-11-17 13:15:44 +0000
commite7b3c7840633b12210c268a6359c0e5f07a9f092 (patch)
tree3f9ad58f8a1ed42ee0c7e7586aefb5c899d1e254
parent2555dd4988bd5637dc2bd70e4102df3c40ea1a86 (diff)
Re-order window creation process
Be a bit more careful to do things in the right order and set the style flags and window state before we show the window. This is probably the right thing to do in any case as it means we can avoid the messy appearance of the window changing style just after it is first shown This is achieved by having WM_CREATE send a WM_WM_CREATE message to our window manager thread, which then does all the work of discovering the windows style. Note that this subtly changes the semantics of winCreateWindowsWindow(): previously the window was visible and drawn before that function returned, now that happens asychronously; I'm not sure if that could cause problems or not...
-rw-r--r--hw/xwin/winmultiwindowwindow.c10
-rw-r--r--hw/xwin/winmultiwindowwm.c54
-rw-r--r--hw/xwin/winmultiwindowwndproc.c31
-rw-r--r--hw/xwin/winwindow.h1
4 files changed, 61 insertions, 35 deletions
diff --git a/hw/xwin/winmultiwindowwindow.c b/hw/xwin/winmultiwindowwindow.c
index 8b76fc374..e81fe2fcc 100644
--- a/hw/xwin/winmultiwindowwindow.c
+++ b/hw/xwin/winmultiwindowwindow.c
@@ -892,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 53d40c13d..5afa176bb 100644
--- a/hw/xwin/winmultiwindowwm.c
+++ b/hw/xwin/winmultiwindowwm.c
@@ -250,6 +250,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;
@@ -711,6 +714,10 @@ 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);
winUpdateWindowPosition(hWnd, &zstyle);
@@ -964,6 +971,40 @@ winMultiWindowWMProc(void *pArg)
/* Branch on the message type */
switch (pNode->msg.msg) {
+ case WM_WM_CREATE:
+#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, TRUE);
+
+ /* 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_SHOWNOACTIVATE);
+ free(reply);
+ }
+ }
+
+ /* Send first paint message */
+ UpdateWindow(pNode->msg.hwndWindow);
+
+ break;
+
#if 0
case WM_WM_MOVE:
break;
@@ -995,26 +1036,13 @@ winMultiWindowWMProc(void *pArg)
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));
-
UpdateName(pWMInfo, pNode->msg.iWindow);
UpdateStyle(pWMInfo, pNode->msg.iWindow, TRUE);
UpdateIcon(pWMInfo, pNode->msg.iWindow);
-
/* Reshape */
{
WindowPtr pWin =
diff --git a/hw/xwin/winmultiwindowwndproc.c b/hw/xwin/winmultiwindowwndproc.c
index 56e7b8092..b54c0d47b 100644
--- a/hw/xwin/winmultiwindowwndproc.c
+++ b/hw/xwin/winmultiwindowwndproc.c
@@ -348,6 +348,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 +422,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 +442,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 3d366d7c2..792230a14 100644
--- a/hw/xwin/winwindow.h
+++ b/hw/xwin/winwindow.h
@@ -113,6 +113,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)