summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJess VanDerwalker <washu@sonic.net>2012-08-03 10:09:58 -0700
committerJess VanDerwalker <washu@sonic.net>2012-08-29 09:15:38 -0700
commita03984bad4ea754c4f601b1e2c236b2e0ce9c414 (patch)
treefb35f61992014e37b5993fd0e2c649e18c58b8d5
parent2a0823151ae237a1d6866985bdaa1a56428abded (diff)
libxcwm: Creating window for EWMH compliant window manager.
Creating a window that is never mapped, but has name of EWMH compliant window manager and has _NET_SUPPORTING_WM_CHECK set to its ID on both itself and the root window. As specified in the EWMH spec: http://standards.freedesktop.org/wm-spec/wm-spec-latest.html#id2577320 _xcwm_atoms_init now returns 0 on success, or XCB error code if atom initialization fails or if another EWMH compliant window manager is running. Signed-off-by: Jess VanDerwalker <washu@sonic.net> Reviewed-by: Jeremy Huddlestone Sequoia <jeremyhu@apple.com>
-rw-r--r--include/xcwm/context.h1
-rw-r--r--src/libxcwm/atoms.c69
-rw-r--r--src/libxcwm/xcwm_internal.h7
3 files changed, 71 insertions, 6 deletions
diff --git a/include/xcwm/context.h b/include/xcwm/context.h
index 3d28131..cb02d3b 100644
--- a/include/xcwm/context.h
+++ b/include/xcwm/context.h
@@ -50,6 +50,7 @@ struct xcwm_context_t {
int conn_screen;
xcwm_window_t *root_window;
int damage_event_mask;
+ xcb_window_t wm_cm_window;
xcwm_wm_atoms_t *atoms;
};
typedef struct xcwm_context_t xcwm_context_t;
diff --git a/src/libxcwm/atoms.c b/src/libxcwm/atoms.c
index b1ba149..a080436 100644
--- a/src/libxcwm/atoms.c
+++ b/src/libxcwm/atoms.c
@@ -37,24 +37,35 @@
/* Local functions */
+/* Check to make sure another EWMH window manager is not running */
+int
+check_wm_cm_owner(xcwm_context_t *context);
+
+/* Create the window required to show a EWMH compliant window manager
+ * is running */
+void
+create_wm_cm_window(xcwm_context_t *context);
+
/* Get and set the size hints for the window */
void
set_window_size_hints(xcwm_window_t *window);
-void
+int
_xcwm_atoms_init(xcwm_context_t *context)
{
xcb_intern_atom_reply_t *atom_reply;
xcb_intern_atom_cookie_t atom_cookie;
xcb_intern_atom_cookie_t *atom_cookies;
+ xcb_generic_error_t *error;
/* Initialization for the xcb_ewmh connection and EWMH atoms */
atom_cookies = xcb_ewmh_init_atoms(context->conn,
&context->atoms->ewmh_conn);
- xcb_ewmh_init_atoms_replies(&context->atoms->ewmh_conn,
- atom_cookies,
- NULL);
+ if (!xcb_ewmh_init_atoms_replies(&context->atoms->ewmh_conn,
+ atom_cookies, &error)) {
+ return error->major_code;;
+ }
/* Set the _NET_SUPPORTED atom for this context
* Most of these are defined ast MUSTs in the
@@ -110,6 +121,53 @@ _xcwm_atoms_init(xcwm_context_t *context)
free(atom_reply);
}
+ if (!check_wm_cm_owner(context)) {
+ return XCB_WINDOW;
+ }
+
+ create_wm_cm_window(context);
+
+ return 0;
+}
+
+int
+check_wm_cm_owner(xcwm_context_t *context)
+{
+ xcb_get_selection_owner_cookie_t cookie;
+ xcb_window_t wm_owner;
+
+ cookie = xcb_ewmh_get_wm_cm_owner(&context->atoms->ewmh_conn,
+ context->conn_screen);
+ xcb_ewmh_get_wm_cm_owner_reply(&context->atoms->ewmh_conn,
+ cookie, &wm_owner, NULL);
+ if (wm_owner != XCB_NONE) {
+ return 0;
+ }
+ return 1;
+}
+
+void
+create_wm_cm_window(xcwm_context_t *context)
+{
+ context->wm_cm_window = xcb_generate_id(context->conn);
+
+ xcb_create_window(context->conn,
+ XCB_COPY_FROM_PARENT,
+ context->wm_cm_window,
+ context->root_window->window_id,
+ 0, 0, 1, 1, 0, /* 1x1 size, no border */
+ XCB_COPY_FROM_PARENT,
+ XCB_COPY_FROM_PARENT,
+ 0, NULL);
+
+ /* Set the atoms for the window */
+ xcb_ewmh_set_wm_name(&context->atoms->ewmh_conn,
+ context->wm_cm_window,
+ strlen("xcwm"), "xcwm");
+
+ xcb_ewmh_set_supporting_wm_check(&context->atoms->ewmh_conn,
+ context->conn_screen,
+ context->wm_cm_window);
}
void
@@ -223,4 +281,7 @@ _xcwm_atoms_release(xcwm_context_t *context)
/* Free the xcb_ewmh_connection_t */
xcb_ewmh_connection_wipe(&context->atoms->ewmh_conn);
+
+ /* Close the wm window */
+ xcb_destroy_window(context->conn, context->wm_cm_window);
}
diff --git a/src/libxcwm/xcwm_internal.h b/src/libxcwm/xcwm_internal.h
index 5e083f7..eba10e1 100644
--- a/src/libxcwm/xcwm_internal.h
+++ b/src/libxcwm/xcwm_internal.h
@@ -282,10 +282,13 @@ _xcwm_map_window(xcb_connection_t *conn, xcwm_window_t *window);
****************/
/**
- * Get the values for the WM_* atoms that we need.
+ * Get the values for the WM_* atoms that we need, as well as checking
+ * to make sure another window manager is not running on the
+ * connection.
* @param context The context
+ * @return Returns 0 on success, otherwise XCB error code.
*/
-void
+int
_xcwm_atoms_init(xcwm_context_t *context);
/**