From 91aeed0442527b5143183507b0e391ff515c295a Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Mon, 29 Jun 2009 22:15:37 +0200 Subject: [PATCH] Resolve documentation FIXMEs, remove an unnecessary struct --- include/config.h | 17 +++++++++++++++-- include/data.h | 16 ++-------------- include/manage.h | 6 ++++-- src/handlers.c | 11 +---------- src/manage.c | 40 ++++++++++++++++++---------------------- 5 files changed, 40 insertions(+), 50 deletions(-) diff --git a/include/config.h b/include/config.h index cbfeaf1b..140db5ab 100644 --- a/include/config.h +++ b/include/config.h @@ -12,8 +12,6 @@ * */ -/* FIXME: this file lacks documentation */ - #ifndef _CONFIG_H #define _CONFIG_H @@ -22,12 +20,22 @@ typedef struct Config Config; extern Config config; +/** + * Part of the struct Config. It makes sense to group colors for background, + * border and text as every element in i3 has them (window decorations, bar). + * + */ struct Colortriple { uint32_t border; uint32_t background; uint32_t text; }; +/** + * Holds a user-assigned variable for parsing the configuration file. The key + * is replaced by value in every following line of the file. + * + */ struct Variable { char *key; char *value; @@ -35,6 +43,11 @@ struct Variable { SLIST_ENTRY(Variable) variables; }; +/** + * Holds part of the configuration (the part which is not already in dedicated + * structures in include/data.h). + * + */ struct Config { const char *terminal; const char *font; diff --git a/include/data.h b/include/data.h index 386e49cc..2776d506 100644 --- a/include/data.h +++ b/include/data.h @@ -74,7 +74,7 @@ enum { }; /** - * FIXME: needs to be documented + * Stores a rectangle, for example the size of a window, the child window etc. * */ struct Rect { @@ -135,18 +135,6 @@ struct keyvalue_element { TAILQ_ENTRY(keyvalue_element) elements; }; -/** - * FIXME: needs documentation. - * - */ -typedef struct { - enum xcb_atom_fast_tag_t tag; - union { - xcb_get_window_attributes_cookie_t cookie; - uint8_t override_redirect; - } u; -} window_attributes_t; - /****************************************************************************** * Major types *****************************************************************************/ @@ -247,7 +235,7 @@ struct Assignment { * workspace "~". Matching clients will be put into floating mode * automatically. */ bool floating; - /** FIXME: needs documentation */ + /** The number of the workspace to assign to. */ int workspace; TAILQ_ENTRY(Assignment) assignments; }; diff --git a/include/manage.h b/include/manage.h index 297d7ae8..10beeb52 100644 --- a/include/manage.h +++ b/include/manage.h @@ -3,7 +3,7 @@ * * i3 - an improved dynamic tiling window manager * - * (c) 2009 Michael Stapelberg and contributors + * © 2009 Michael Stapelberg and contributors * * See file LICENSE for license information. * @@ -28,7 +28,9 @@ void manage_existing_windows(xcb_connection_t *conn, xcb_property_handlers_t * */ void manage_window(xcb_property_handlers_t *prophs, xcb_connection_t *conn, - xcb_window_t window, window_attributes_t wa); + xcb_window_t window, + xcb_get_window_attributes_cookie_t cookie, + bool needs_to_be_mapped); /** * reparent_window() gets called when a new window was opened and becomes a diff --git a/src/handlers.c b/src/handlers.c index d56a3c31..ec02180d 100644 --- a/src/handlers.c +++ b/src/handlers.c @@ -421,22 +421,13 @@ int handle_button_press(void *ignored, xcb_connection_t *conn, xcb_button_press_ */ int handle_map_request(void *prophs, xcb_connection_t *conn, xcb_map_request_event_t *event) { xcb_get_window_attributes_cookie_t cookie; - xcb_get_window_attributes_reply_t *reply; cookie = xcb_get_window_attributes_unchecked(conn, event->window); - if ((reply = xcb_get_window_attributes_reply(conn, cookie, NULL)) == NULL) { - LOG("Could not get window attributes\n"); - return -1; - } - - window_attributes_t wa = { TAG_VALUE }; - LOG("override_redirect = %d\n", reply->override_redirect); - wa.u.override_redirect = reply->override_redirect; LOG("window = 0x%08x, serial is %d.\n", event->window, event->sequence); add_ignore_event(event->sequence); - manage_window(prophs, conn, event->window, wa); + manage_window(prophs, conn, event->window, cookie, false); return 1; } diff --git a/src/manage.c b/src/manage.c index d4641dbc..2cc0adae 100644 --- a/src/manage.c +++ b/src/manage.c @@ -53,10 +53,8 @@ void manage_existing_windows(xcb_connection_t *conn, xcb_property_handlers_t *pr cookies[i] = xcb_get_window_attributes(conn, children[i]); /* Call manage_window with the attributes for every window */ - for(i = 0; i < len; ++i) { - window_attributes_t wa = { TAG_COOKIE, { cookies[i] } }; - manage_window(prophs, conn, children[i], wa); - } + for(i = 0; i < len; ++i) + manage_window(prophs, conn, children[i], cookies[i], true); free(reply); free(cookies); @@ -66,42 +64,40 @@ void manage_existing_windows(xcb_connection_t *conn, xcb_property_handlers_t *pr * Do some sanity checks and then reparent the window. * */ -void manage_window(xcb_property_handlers_t *prophs, xcb_connection_t *conn, xcb_window_t window, window_attributes_t wa) { +void manage_window(xcb_property_handlers_t *prophs, xcb_connection_t *conn, + xcb_window_t window, xcb_get_window_attributes_cookie_t cookie, + bool needs_to_be_mapped) { LOG("managing window.\n"); xcb_drawable_t d = { window }; xcb_get_geometry_cookie_t geomc; xcb_get_geometry_reply_t *geom; xcb_get_window_attributes_reply_t *attr = 0; - if (wa.tag == TAG_COOKIE) { - /* Check if the window is mapped (it could be not mapped when intializing and - calling manage_window() for every window) */ - if ((attr = xcb_get_window_attributes_reply(conn, wa.u.cookie, 0)) == NULL) - return; + geomc = xcb_get_geometry(conn, d); - if (attr->map_state != XCB_MAP_STATE_VIEWABLE) - goto out; + /* Check if the window is mapped (it could be not mapped when intializing and + calling manage_window() for every window) */ + if ((attr = xcb_get_window_attributes_reply(conn, cookie, 0)) == NULL) { + LOG("Could not get attributes\n"); + return; + } - wa.tag = TAG_VALUE; - wa.u.override_redirect = attr->override_redirect; + if (attr->map_state != XCB_MAP_STATE_VIEWABLE) { + LOG("Window not mapped, not managing\n"); + goto out; } /* Don’t manage clients with the override_redirect flag */ - if (wa.u.override_redirect) + if (attr->override_redirect) { + LOG("override_redirect set, not managing\n"); goto out; + } /* Check if the window is already managed */ if (table_get(&by_child, window)) goto out; /* Get the initial geometry (position, size, …) */ - geomc = xcb_get_geometry(conn, d); - if (!attr) { - wa.tag = TAG_COOKIE; - wa.u.cookie = xcb_get_window_attributes(conn, window); - if ((attr = xcb_get_window_attributes_reply(conn, wa.u.cookie, 0)) == NULL) - return; - } if ((geom = xcb_get_geometry_reply(conn, geomc, 0)) == NULL) goto out;