diff options
author | Jon TURNEY <jon.turney@dronecode.org.uk> | 2013-07-03 00:13:12 +0100 |
---|---|---|
committer | Jon TURNEY <jon.turney@dronecode.org.uk> | 2013-07-06 11:30:44 +0100 |
commit | 84eea594b75805a25c58d27f415a18b0021cb871 (patch) | |
tree | d796cbdc2115f7c8c29596f10570346fa5173115 | |
parent | 4aae26152d38ea933442f3d103086644d81cc8e9 (diff) |
Implement XCWM_EVENT_WINDOW_STATE
Apply state when window is created
Show, iconify or hide it on XCWM_EVENT_WINDOW_STATE changes
Set state to iconified or deiconified when changed in Windows
-rw-r--r-- | src/main.c | 3 | ||||
-rw-r--r-- | src/wndproc.c | 57 | ||||
-rw-r--r-- | src/wndproc.h | 1 |
3 files changed, 50 insertions, 11 deletions
@@ -104,6 +104,9 @@ eventHandler(const xcwm_event_t *event) winAdjustWindowsWindow(window); break; + case XCWM_EVENT_WINDOW_STATE: + UpdateState(window); + case XCWM_EVENT_CURSOR: /* Only the 'GUI thread' is allowed to SetCursor() diff --git a/src/wndproc.c b/src/wndproc.c index f49c2e1..f003327 100644 --- a/src/wndproc.c +++ b/src/wndproc.c @@ -155,13 +155,15 @@ winAdjustXWindow (xcwm_window_t *window, HWND hWnd) if (IsIconic(hWnd)) { DEBUG("Immediately return because the window is iconized\n"); - - /* XXX: match WM_STATE.state to state of Windows window */ - /* XXX: send a WM_CHANGE_STATE message ? */ - + xcwm_window_iconify(window); return 0; } + if (IsWindowVisible(hWnd)) + { + xcwm_window_deiconify(window); + } + /* Get size of client area */ GetClientRect(hWnd, &rcWin); w = WIDTH(rcWin); @@ -664,11 +666,12 @@ winApplyStyle(xcwm_window_t *window) dance when changing the style of a window with WS_EX_LAYERED set, to ensure that the the windows contents are drawn in the right place... */ - ShowWindow(hWnd, SW_HIDE); + BOOL visible = IsWindowVisible(hWnd); + if (visible) ShowWindow(hWnd, SW_HIDE); SetWindowLongPtr(hWnd, GWL_EXSTYLE, exStyle & ~WS_EX_LAYERED); SetWindowLongPtr(hWnd, GWL_EXSTYLE, exStyle | WS_EX_LAYERED); SetWindowPos(hWnd, NULL, 0, 0, 0, 0, flags); - ShowWindow(hWnd, SW_SHOW); + if (visible) ShowWindow(hWnd, SW_SHOW); } else { @@ -898,6 +901,40 @@ UpdateShape(xcwm_window_t *window) it when it is no longer needed. */ } +/* + * Updates the visible state of a HWND +*/ +void +UpdateState(xcwm_window_t *window) +{ + HWND hWnd = xcwm_window_get_local_data(window); + if (!hWnd) + return; + + xcwm_window_state_t state = xcwm_window_get_state(window); + + switch (state) + { + case XCWM_WINDOW_STATE_NORMAL: + /* Display the window without activating it */ + ShowWindow(hWnd, SW_SHOWNOACTIVATE); + break; + + case XCWM_WINDOW_STATE_ICONIC: + /* Display the window minimized without activating it */ + ShowWindow(hWnd, SW_SHOWMINNOACTIVE); + break; + + case XCWM_WINDOW_STATE_WITHDRAWN: + /* Hide the window */ + ShowWindow(hWnd, SW_HIDE); + break; + + default: + break; + } +} + static void winStartMousePolling(void) { @@ -1551,9 +1588,6 @@ winCreateWindowsWindow(xcwm_window_t *window) SetWindowLongPtr(hWnd, GWL_STYLE, WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS); SetWindowPos(hWnd, 0, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); - /* Adjust the X window to match the window placement we actually got... */ - winAdjustXWindow(window, hWnd); - /* Make sure it gets the proper system menu for a WS_POPUP, too */ GetSystemMenu(hWnd, TRUE); @@ -1593,9 +1627,10 @@ winCreateWindowsWindow(xcwm_window_t *window) UpdateIcon(window); UpdateStyle(window); UpdateShape(window); + UpdateState(window); - /* Display the window without activating it */ - ShowWindow(hWnd, SW_SHOWNOACTIVATE); + /* Adjust the X window to match the window placement we actually got... */ + winAdjustXWindow(window, hWnd); } void diff --git a/src/wndproc.h b/src/wndproc.h index ac48e62..5e3aac1 100644 --- a/src/wndproc.h +++ b/src/wndproc.h @@ -27,6 +27,7 @@ void UpdateImage(xcwm_window_t *window); void UpdateStyle(xcwm_window_t *window); void UpdateShape(xcwm_window_t *window); void UpdateIcon(xcwm_window_t *window); +void UpdateState(xcwm_window_t *window); void winCreateWindowsWindow(xcwm_window_t *window); void winDestroyWindowsWindow(xcwm_window_t *window); void winAdjustWindowsWindow(xcwm_window_t *window); |