diff options
author | Jess VanDerwalker <washu@sonic.net> | 2012-08-09 11:35:44 -0700 |
---|---|---|
committer | Jess VanDerwalker <washu@sonic.net> | 2012-08-29 09:15:52 -0700 |
commit | 01b15ed290db6a8ae3d06a44b67ead55ad8076f6 (patch) | |
tree | ed5a1cfe19066763a69f30a4d70929b15370174b | |
parent | 20f256fa9f88cdfb25c6ea39150b7ebc5a876e88 (diff) |
libxcwm: Setting _NET_WM_STATE_HIDDEN on iconic windows.
Added xcwm_window_state_t enum for the window states supported by
library.
_xcwm_atoms_set_wm_state() updated to use xcwm_window_state_t as
param. Also, _xcwm_atoms_set_wm_state sets the _NET_WM_STATE atom to
_NET_WM_STATE_HIDDEN when window is made iconic, and removes it when
window is de-iconified.
Signed-off-by: Jess VanDerwalker <washu@sonic.net>
-rw-r--r-- | include/xcwm/window.h | 10 | ||||
-rw-r--r-- | src/libxcwm/atoms.c | 47 | ||||
-rw-r--r-- | src/libxcwm/window.c | 6 | ||||
-rw-r--r-- | src/libxcwm/xcwm_internal.h | 6 |
4 files changed, 59 insertions, 10 deletions
diff --git a/include/xcwm/window.h b/include/xcwm/window.h index 611e365..95c3ff5 100644 --- a/include/xcwm/window.h +++ b/include/xcwm/window.h @@ -64,6 +64,16 @@ enum xcwm_window_type_t { typedef enum xcwm_window_type_t xcwm_window_type_t; /** + * Enumeration for possible supported window states. + */ +enum xcwm_window_state_t { + XCWM_WINDOW_STATE_UNKNOWN = 0, + XCWM_WINDOW_STATE_NORMAL, + XCWM_WINDOW_STATE_ICONIC +}; +typedef enum xcwm_window_state_t xcwm_window_state_t; + +/** * Structure defining min/max size for window and resizing * increments. A value of 0 in any field implies the field is unset. */ diff --git a/src/libxcwm/atoms.c b/src/libxcwm/atoms.c index 6963d67..00620f5 100644 --- a/src/libxcwm/atoms.c +++ b/src/libxcwm/atoms.c @@ -376,11 +376,40 @@ set_window_size_hints(xcwm_window_t *window) } void -_xcwm_atoms_set_wm_state(xcwm_window_t *window, xcb_icccm_wm_state_t state) +_xcwm_atoms_set_wm_state(xcwm_window_t *window, xcwm_window_state_t state) { - uint32_t data[] = { state, XCB_NONE }; + /* xcb_icccm_wm_state_t icccm_state; */ + + uint32_t icccm_state[2]; + xcb_atom_t *ewmh_state = NULL; + int ewmh_atom_cnt = 0; + + switch (state) { + case XCWM_WINDOW_STATE_NORMAL: + { + icccm_state[0] = XCB_ICCCM_WM_STATE_NORMAL; + icccm_state[1] = XCB_NONE; + break; + } - /* Only set this for top-level windows */ + case XCWM_WINDOW_STATE_ICONIC: + { + ewmh_atom_cnt = 1; + icccm_state[0] = XCB_ICCCM_WM_STATE_ICONIC; + icccm_state[1] = XCB_NONE; + + ewmh_state = calloc(ewmh_atom_cnt, sizeof(xcb_atom_t)); + ewmh_state[0] = window->context->atoms->ewmh_conn._NET_WM_STATE_HIDDEN; + break; + } + default: + { + /* No need to attempt to update the state */ + return; + } + } + + /* Only set for top-level windows */ if (!window->transient_for && !window->override_redirect) { xcb_change_property(window->context->conn, XCB_PROP_MODE_REPLACE, @@ -389,9 +418,19 @@ _xcwm_atoms_set_wm_state(xcwm_window_t *window, xcb_icccm_wm_state_t state) window->context->atoms->wm_state_atom, 32, 2, - data); + icccm_state); } + + xcb_ewmh_set_wm_state(&window->context->atoms->ewmh_conn, + window->window_id, + ewmh_atom_cnt, + ewmh_state); + xcb_flush(window->context->conn); + + if (ewmh_state) { + free(ewmh_state); + } } void diff --git a/src/libxcwm/window.c b/src/libxcwm/window.c index ec10327..4b24be5 100644 --- a/src/libxcwm/window.c +++ b/src/libxcwm/window.c @@ -160,7 +160,7 @@ _xcwm_window_create(xcwm_context_t *context, xcb_window_t new_window, window = _xcwm_add_window(window); /* Set the WM_STATE of the window to normal */ - _xcwm_atoms_set_wm_state(window, XCB_ICCCM_WM_STATE_NORMAL); + _xcwm_atoms_set_wm_state(window, XCWM_WINDOW_STATE_NORMAL); return window; } @@ -378,13 +378,13 @@ xcwm_window_get_sizing(xcwm_window_t const *window) void xcwm_window_iconify(xcwm_window_t *window) { - _xcwm_atoms_set_wm_state(window, XCB_ICCCM_WM_STATE_ICONIC); + _xcwm_atoms_set_wm_state(window, XCWM_WINDOW_STATE_ICONIC); } void xcwm_window_deiconify(xcwm_window_t *window) { - _xcwm_atoms_set_wm_state(window, XCB_ICCCM_WM_STATE_NORMAL); + _xcwm_atoms_set_wm_state(window, XCWM_WINDOW_STATE_NORMAL); } /* Resize the window on server side */ diff --git a/src/libxcwm/xcwm_internal.h b/src/libxcwm/xcwm_internal.h index 531d4ce..b1305a5 100644 --- a/src/libxcwm/xcwm_internal.h +++ b/src/libxcwm/xcwm_internal.h @@ -323,12 +323,12 @@ void _xcwm_atoms_release(xcwm_context_t *context); /** - * Set the ICCCM WM_STATE for the given window to the state seen by - * the window manager. + * Set the ICCCM WM_STATE and EWMH _NET_WM_STATE for the given + * window to the state seen by the window manager. * @param window The window to set the state on * @param state The new state. */ void -_xcwm_atoms_set_wm_state(xcwm_window_t *window, xcb_icccm_wm_state_t state); +_xcwm_atoms_set_wm_state(xcwm_window_t *window, xcwm_window_state_t state); #endif /* _XTOQ_INTERNAL_H_ */ |