summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJess VanDerwalker <washu@sonic.net>2012-08-08 11:28:16 -0700
committerJess VanDerwalker <washu@sonic.net>2012-08-29 09:15:52 -0700
commita1a33a1c42bec87b41ea995a478beae42ba1ecf4 (patch)
tree4a15270b1bbbf70a8aa0b87e53a7ea523f9709a2
parentdf5dfe47076140f5f31e3e1d73b4804a16071ba3 (diff)
libxcwm: Functions in atoms.c and window.c for setting of ICCCM WM_STATE atom.
A wm_state_atom field added to xcwm_atoms_t and value determined on atom init. Functions to change state to Iconic or Normal added to window.c and atoms.c. Functions in window.c are wrappers for the atoms.c functions. The window.c functions are to be called by window manager when window is iconified or de-iconified. Signed-off-by: Jess VanDerwalker <washu@sonic.net> Reviewed-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
-rw-r--r--include/xcwm/window.h16
-rw-r--r--src/libxcwm/atoms.c35
-rw-r--r--src/libxcwm/window.c16
-rw-r--r--src/libxcwm/xcwm_internal.h10
4 files changed, 76 insertions, 1 deletions
diff --git a/include/xcwm/window.h b/include/xcwm/window.h
index af2774d..611e365 100644
--- a/include/xcwm/window.h
+++ b/include/xcwm/window.h
@@ -231,4 +231,20 @@ xcwm_window_copy_name(xcwm_window_t const *window);
xcwm_window_sizing_t const *
xcwm_window_get_sizing(xcwm_window_t const *window);
+/**
+ * Set the window to an iconic state. Usually this means the window
+ * has been minimized.
+ * @param window The window to iconify
+ */
+void
+xcwm_window_iconify(xcwm_window_t *window);
+
+/**
+ * Set the window to a normal state, meaning that the window has moved
+ * from an iconic/minimized state to a deiconic/de-minimized state.
+ * @param window The window being deiconified
+ */
+void
+xcwm_window_deiconify(xcwm_window_t *window);
+
#endif /* _XCWM_WINDOW_H_ */
diff --git a/src/libxcwm/atoms.c b/src/libxcwm/atoms.c
index da7c637..6963d67 100644
--- a/src/libxcwm/atoms.c
+++ b/src/libxcwm/atoms.c
@@ -145,6 +145,22 @@ _xcwm_atoms_init(xcwm_context_t *context)
return XCB_WINDOW;
}
+ /* WM_STATE atom */
+ atom_cookie = xcb_intern_atom(context->conn,
+ 0,
+ strlen("WM_STATE"),
+ "WM_STATE");
+ atom_reply = xcb_intern_atom_reply(context->conn,
+ atom_cookie,
+ NULL);
+ if (!atom_reply) {
+ context->atoms->wm_state_atom = 0;
+ }
+ else {
+ context->atoms->wm_state_atom = atom_reply->atom;
+ free(atom_reply);
+ }
+
create_wm_cm_window(context);
return 0;
@@ -360,6 +376,25 @@ set_window_size_hints(xcwm_window_t *window)
}
void
+_xcwm_atoms_set_wm_state(xcwm_window_t *window, xcb_icccm_wm_state_t state)
+{
+ uint32_t data[] = { state, XCB_NONE };
+
+ /* Only set this for top-level windows */
+ if (!window->transient_for && !window->override_redirect) {
+ xcb_change_property(window->context->conn,
+ XCB_PROP_MODE_REPLACE,
+ window->window_id,
+ window->context->atoms->wm_state_atom,
+ window->context->atoms->wm_state_atom,
+ 32,
+ 2,
+ data);
+ }
+ xcb_flush(window->context->conn);
+}
+
+void
_xcwm_atoms_release(xcwm_context_t *context)
{
diff --git a/src/libxcwm/window.c b/src/libxcwm/window.c
index 3aa7d94..ec10327 100644
--- a/src/libxcwm/window.c
+++ b/src/libxcwm/window.c
@@ -159,6 +159,9 @@ _xcwm_window_create(xcwm_context_t *context, xcb_window_t new_window,
/* add context to context_list */
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);
+
return window;
}
@@ -372,6 +375,18 @@ xcwm_window_get_sizing(xcwm_window_t const *window)
return window->sizing;
}
+void
+xcwm_window_iconify(xcwm_window_t *window)
+{
+ _xcwm_atoms_set_wm_state(window, XCB_ICCCM_WM_STATE_ICONIC);
+}
+
+void
+xcwm_window_deiconify(xcwm_window_t *window)
+{
+ _xcwm_atoms_set_wm_state(window, XCB_ICCCM_WM_STATE_NORMAL);
+}
+
/* Resize the window on server side */
void
_xcwm_resize_window(xcb_connection_t *conn, xcb_window_t window,
@@ -407,7 +422,6 @@ set_window_event_masks(xcb_connection_t *conn, xcwm_window_t *window)
XCB_CW_EVENT_MASK, values);
}
-
void
init_damage_on_window(xcb_connection_t *conn, xcwm_window_t *window)
{
diff --git a/src/libxcwm/xcwm_internal.h b/src/libxcwm/xcwm_internal.h
index f49226b..531d4ce 100644
--- a/src/libxcwm/xcwm_internal.h
+++ b/src/libxcwm/xcwm_internal.h
@@ -54,6 +54,7 @@ struct xcwm_wm_atoms_t {
xcb_atom_t wm_delete_window_atom;
xcb_atom_t wm_transient_for_atom;
xcb_atom_t wm_name_atom;
+ xcb_atom_t wm_state_atom;
xcb_ewmh_connection_t ewmh_conn;
};
@@ -321,4 +322,13 @@ _xcwm_atoms_set_wm_delete(xcwm_window_t *window);
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.
+ * @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);
+
#endif /* _XTOQ_INTERNAL_H_ */