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>2018-05-13 18:21:59 +0100
commit62f7e38f1e110999e4f4801f850ec495bba17492 (patch)
treed7502054baaa2c08e1bdefeaeaa65e602091a187
parent60460bc72db556e24846a4f954ff32b9e0023255 (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 6dc124ff8..68bfe8aac 100644
--- a/hw/xwin/winmultiwindowwm.c
+++ b/hw/xwin/winmultiwindowwm.c
@@ -253,6 +253,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;
@@ -715,6 +718,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);
@@ -968,6 +975,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;
@@ -999,26 +1040,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 9ef98239a..e73098838 100644
--- a/hw/xwin/winwindow.h
+++ b/hw/xwin/winwindow.h
@@ -112,6 +112,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)