From 96f0a37984cab1a9a4daecfb056bfe4cd161f6fe Mon Sep 17 00:00:00 2001 From: Jon TURNEY Date: Sat, 10 Nov 2012 17:18:56 +0000 Subject: Make xcwm_wm_atoms_t a member, rather than an allocation in xcwm_context_t --- src/libxcwm/atoms.c | 86 ++++++++++++++++++++++----------------------- src/libxcwm/context.c | 3 -- src/libxcwm/event_loop.c | 2 +- src/libxcwm/window.c | 4 +-- src/libxcwm/xcwm_internal.h | 2 +- 5 files changed, 47 insertions(+), 50 deletions(-) diff --git a/src/libxcwm/atoms.c b/src/libxcwm/atoms.c index 02217c9..ed63841 100644 --- a/src/libxcwm/atoms.c +++ b/src/libxcwm/atoms.c @@ -133,8 +133,8 @@ _xcwm_atoms_init(xcwm_context_t *context) /* Initialization for the xcb_ewmh connection and EWMH atoms */ atom_cookies = xcb_ewmh_init_atoms(context->conn, - &context->atoms->ewmh_conn); - if (!xcb_ewmh_init_atoms_replies(&context->atoms->ewmh_conn, + &context->atoms.ewmh_conn); + if (!xcb_ewmh_init_atoms_replies(&context->atoms.ewmh_conn, atom_cookies, &error)) { return error->major_code;; } @@ -146,36 +146,36 @@ _xcwm_atoms_init(xcwm_context_t *context) * may be expanded. */ xcb_atom_t supported[] = { - context->atoms->ewmh_conn.WM_PROTOCOLS, - context->atoms->ewmh_conn._NET_SUPPORTED, - context->atoms->ewmh_conn._NET_SUPPORTING_WM_CHECK, - context->atoms->ewmh_conn._NET_CLOSE_WINDOW, - context->atoms->ewmh_conn._NET_WM_NAME, - context->atoms->ewmh_conn._NET_WM_WINDOW_TYPE, - context->atoms->ewmh_conn._NET_WM_WINDOW_TYPE_TOOLBAR, - context->atoms->ewmh_conn._NET_WM_WINDOW_TYPE_MENU, - context->atoms->ewmh_conn._NET_WM_WINDOW_TYPE_UTILITY, - context->atoms->ewmh_conn._NET_WM_WINDOW_TYPE_SPLASH, - context->atoms->ewmh_conn._NET_WM_WINDOW_TYPE_DIALOG, - context->atoms->ewmh_conn._NET_WM_WINDOW_TYPE_DROPDOWN_MENU, - context->atoms->ewmh_conn._NET_WM_WINDOW_TYPE_POPUP_MENU, - context->atoms->ewmh_conn._NET_WM_WINDOW_TYPE_TOOLTIP, - context->atoms->ewmh_conn._NET_WM_WINDOW_TYPE_NOTIFICATION, - context->atoms->ewmh_conn._NET_WM_WINDOW_TYPE_COMBO, - context->atoms->ewmh_conn._NET_WM_WINDOW_TYPE_DND, - context->atoms->ewmh_conn._NET_WM_WINDOW_TYPE_NORMAL, - context->atoms->ewmh_conn._NET_WM_STATE, - context->atoms->ewmh_conn._NET_WM_STATE_MODAL, - context->atoms->ewmh_conn._NET_WM_STATE_HIDDEN + context->atoms.ewmh_conn.WM_PROTOCOLS, + context->atoms.ewmh_conn._NET_SUPPORTED, + context->atoms.ewmh_conn._NET_SUPPORTING_WM_CHECK, + context->atoms.ewmh_conn._NET_CLOSE_WINDOW, + context->atoms.ewmh_conn._NET_WM_NAME, + context->atoms.ewmh_conn._NET_WM_WINDOW_TYPE, + context->atoms.ewmh_conn._NET_WM_WINDOW_TYPE_TOOLBAR, + context->atoms.ewmh_conn._NET_WM_WINDOW_TYPE_MENU, + context->atoms.ewmh_conn._NET_WM_WINDOW_TYPE_UTILITY, + context->atoms.ewmh_conn._NET_WM_WINDOW_TYPE_SPLASH, + context->atoms.ewmh_conn._NET_WM_WINDOW_TYPE_DIALOG, + context->atoms.ewmh_conn._NET_WM_WINDOW_TYPE_DROPDOWN_MENU, + context->atoms.ewmh_conn._NET_WM_WINDOW_TYPE_POPUP_MENU, + context->atoms.ewmh_conn._NET_WM_WINDOW_TYPE_TOOLTIP, + context->atoms.ewmh_conn._NET_WM_WINDOW_TYPE_NOTIFICATION, + context->atoms.ewmh_conn._NET_WM_WINDOW_TYPE_COMBO, + context->atoms.ewmh_conn._NET_WM_WINDOW_TYPE_DND, + context->atoms.ewmh_conn._NET_WM_WINDOW_TYPE_NORMAL, + context->atoms.ewmh_conn._NET_WM_STATE, + context->atoms.ewmh_conn._NET_WM_STATE_MODAL, + context->atoms.ewmh_conn._NET_WM_STATE_HIDDEN }; - xcb_ewmh_set_supported(&context->atoms->ewmh_conn, + xcb_ewmh_set_supported(&context->atoms.ewmh_conn, context->conn_screen, 21, /* Length of supported[] */ supported); /* Used erroneously instead of _NET_WM_WINDOW_TYPE_SPLASH by some applications */ - context->atoms->net_wm_window_type_splashscreen = _xcwm_atom_get(context, "_NET_WM_WINDOW_TYPE_SPLASHSCREEN"); + context->atoms.net_wm_window_type_splashscreen = _xcwm_atom_get(context, "_NET_WM_WINDOW_TYPE_SPLASHSCREEN"); /* Get the ICCCM atoms we need that are not included in the * xcb_ewmh_connection_t. */ @@ -186,7 +186,7 @@ _xcwm_atoms_init(xcwm_context_t *context) _xcwm_atom_register(context, "_NET_WM_WINDOW_OPACITY", set_window_opacity, XCWM_EVENT_WINDOW_APPEARANCE); /* WM_DELETE_WINDOW atom */ - context->atoms->wm_delete_window_atom = _xcwm_atom_get(context, "WM_DELETE_WINDOW"); + context->atoms.wm_delete_window_atom = _xcwm_atom_get(context, "WM_DELETE_WINDOW"); if (!check_wm_cm_owner(context)) { return XCB_WINDOW; @@ -194,7 +194,7 @@ _xcwm_atoms_init(xcwm_context_t *context) create_wm_cm_window(context); /* WM_STATE atom */ - context->atoms->wm_state_atom = _xcwm_atom_get(context, "WM_STATE"); + context->atoms.wm_state_atom = _xcwm_atom_get(context, "WM_STATE"); return 0; } @@ -205,9 +205,9 @@ 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, + 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, + xcb_ewmh_get_wm_cm_owner_reply(&context->atoms.ewmh_conn, cookie, &wm_owner, NULL); if (wm_owner != XCB_NONE) { return 0; @@ -232,15 +232,15 @@ create_wm_cm_window(xcwm_context_t *context) 0, NULL); /* Set the atoms for the window */ - xcb_ewmh_set_wm_name(&context->atoms->ewmh_conn, + 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, + xcb_ewmh_set_supporting_wm_check(&context->atoms.ewmh_conn, context->root_window->window_id, context->wm_cm_window); - xcb_ewmh_set_supporting_wm_check(&context->atoms->ewmh_conn, + xcb_ewmh_set_supporting_wm_check(&context->atoms.ewmh_conn, context->wm_cm_window, context->wm_cm_window); } @@ -286,9 +286,9 @@ set_window_name(xcwm_window_t *window, xcwm_property_t *property) xcb_ewmh_get_utf8_strings_reply_t data; /* Check _NET_WM_NAME first */ - cookie = xcb_ewmh_get_wm_name(&window->context->atoms->ewmh_conn, + cookie = xcb_ewmh_get_wm_name(&window->context->atoms.ewmh_conn, window->window_id); - if (xcb_ewmh_get_wm_name_reply(&window->context->atoms->ewmh_conn, + if (xcb_ewmh_get_wm_name_reply(&window->context->atoms.ewmh_conn, cookie, &data, NULL)) { window->name = strndup(data.strings, data.strings_len); xcb_ewmh_get_utf8_strings_reply_wipe(&data); @@ -319,13 +319,13 @@ _xcwm_atoms_set_wm_delete(xcwm_window_t *window) /* Get the WM_PROTOCOLS */ cookie = xcb_icccm_get_wm_protocols(window->context->conn, window->window_id, - window->context->atoms->ewmh_conn.WM_PROTOCOLS); + window->context->atoms.ewmh_conn.WM_PROTOCOLS); if (xcb_icccm_get_wm_protocols_reply(window->context->conn, cookie, &reply, &error) == 1) { /* See if the WM_DELETE_WINDOW is set in WM_PROTOCOLS */ for (i = 0; i < reply.atoms_len; i++) { - if (reply.atoms[i] == window->context->atoms->wm_delete_window_atom) { + if (reply.atoms[i] == window->context->atoms.wm_delete_window_atom) { window->wm_delete_set = 1; break; } @@ -345,7 +345,7 @@ setup_window_type(xcwm_window_t *window, xcwm_property_t *property) xcb_get_property_cookie_t cookie; xcb_window_t transient; xcb_ewmh_get_atoms_reply_t type; - xcb_ewmh_connection_t ewmh_conn = window->context->atoms->ewmh_conn; + xcb_ewmh_connection_t ewmh_conn = window->context->atoms.ewmh_conn; int i; /* if nothing below matches, set the default to unknown */ @@ -388,7 +388,7 @@ setup_window_type(xcwm_window_t *window, xcwm_property_t *property) window->type = XCWM_WINDOW_TYPE_UTILITY; break; } else if ((type.atoms[i] == ewmh_conn._NET_WM_WINDOW_TYPE_SPLASH) || - (type.atoms[i] == window->context->atoms->net_wm_window_type_splashscreen)) { + (type.atoms[i] == window->context->atoms.net_wm_window_type_splashscreen)) { window->type = XCWM_WINDOW_TYPE_SPLASH; break; } else if (type.atoms[i] == ewmh_conn._NET_WM_WINDOW_TYPE_DIALOG) { @@ -482,7 +482,7 @@ _xcwm_atoms_set_wm_state(xcwm_window_t *window, xcwm_window_state_t state) 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; + ewmh_state[0] = window->context->atoms.ewmh_conn._NET_WM_STATE_HIDDEN; break; } default: @@ -497,14 +497,14 @@ _xcwm_atoms_set_wm_state(xcwm_window_t *window, xcwm_window_state_t state) 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, + window->context->atoms.wm_state_atom, + window->context->atoms.wm_state_atom, 32, 2, icccm_state); } - xcb_ewmh_set_wm_state(&window->context->atoms->ewmh_conn, + xcb_ewmh_set_wm_state(&window->context->atoms.ewmh_conn, window->window_id, ewmh_atom_cnt, ewmh_state); @@ -521,7 +521,7 @@ _xcwm_atoms_release(xcwm_context_t *context) { /* Free the xcb_ewmh_connection_t */ - xcb_ewmh_connection_wipe(&context->atoms->ewmh_conn); + 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/context.c b/src/libxcwm/context.c index ce54014..a66747a 100644 --- a/src/libxcwm/context.c +++ b/src/libxcwm/context.c @@ -85,8 +85,6 @@ xcwm_context_open(char *display) root_context->root_window->dmg_bounds = malloc(sizeof(xcwm_rect_t)); assert(root_context->root_window->bounds); assert(root_context->root_window->dmg_bounds); - root_context->atoms = malloc(sizeof(xcwm_wm_atoms_t)); - assert(root_context->atoms); root_context->conn = conn; root_context->conn_screen = conn_screen; @@ -136,7 +134,6 @@ xcwm_context_close(xcwm_context_t *context) /* Free atom related stuff */ _xcwm_atoms_release(context); - free(context->atoms); // Terminate the event loop if (_xcwm_event_stop_loop() != 1) { diff --git a/src/libxcwm/event_loop.c b/src/libxcwm/event_loop.c index 9432295..a856487 100644 --- a/src/libxcwm/event_loop.c +++ b/src/libxcwm/event_loop.c @@ -493,7 +493,7 @@ run_event_loop(void *thread_arg_struct) /* If this is WM_PROTOCOLS, do not send event, just * handle internally */ - if (notify->atom == window->context->atoms->ewmh_conn.WM_PROTOCOLS) { + if (notify->atom == window->context->atoms.ewmh_conn.WM_PROTOCOLS) { _xcwm_atoms_set_wm_delete(window); break; } diff --git a/src/libxcwm/window.c b/src/libxcwm/window.c index 2f9b53c..998d997 100644 --- a/src/libxcwm/window.c +++ b/src/libxcwm/window.c @@ -251,9 +251,9 @@ xcwm_window_request_close(xcwm_window_t *window) event.response_type = XCB_CLIENT_MESSAGE; event.window = window->window_id; - event.type = window->context->atoms->ewmh_conn.WM_PROTOCOLS; + event.type = window->context->atoms.ewmh_conn.WM_PROTOCOLS; event.format = 32; - event.data.data32[0] = window->context->atoms->wm_delete_window_atom; + event.data.data32[0] = window->context->atoms.wm_delete_window_atom; event.data.data32[1] = XCB_CURRENT_TIME; xcb_send_event(window->context->conn, 0, window->window_id, diff --git a/src/libxcwm/xcwm_internal.h b/src/libxcwm/xcwm_internal.h index e9ad0fa..d2b0b44 100644 --- a/src/libxcwm/xcwm_internal.h +++ b/src/libxcwm/xcwm_internal.h @@ -67,7 +67,7 @@ struct xcwm_context_t { xcwm_window_t *root_window; int damage_event_mask; xcb_window_t wm_cm_window; - xcwm_wm_atoms_t *atoms; + xcwm_wm_atoms_t atoms; }; /** -- cgit v1.2.3