Resolve documentation FIXMEs, remove an unnecessary struct

This commit is contained in:
Michael Stapelberg 2009-06-29 22:15:37 +02:00
parent 58cbce0380
commit 91aeed0442
5 changed files with 40 additions and 50 deletions

View File

@ -12,8 +12,6 @@
* *
*/ */
/* FIXME: this file lacks documentation */
#ifndef _CONFIG_H #ifndef _CONFIG_H
#define _CONFIG_H #define _CONFIG_H
@ -22,12 +20,22 @@
typedef struct Config Config; typedef struct Config Config;
extern 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 { struct Colortriple {
uint32_t border; uint32_t border;
uint32_t background; uint32_t background;
uint32_t text; 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 { struct Variable {
char *key; char *key;
char *value; char *value;
@ -35,6 +43,11 @@ struct Variable {
SLIST_ENTRY(Variable) variables; SLIST_ENTRY(Variable) variables;
}; };
/**
* Holds part of the configuration (the part which is not already in dedicated
* structures in include/data.h).
*
*/
struct Config { struct Config {
const char *terminal; const char *terminal;
const char *font; const char *font;

View File

@ -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 { struct Rect {
@ -135,18 +135,6 @@ struct keyvalue_element {
TAILQ_ENTRY(keyvalue_element) elements; 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 * Major types
*****************************************************************************/ *****************************************************************************/
@ -247,7 +235,7 @@ struct Assignment {
* workspace "~". Matching clients will be put into floating mode * workspace "~". Matching clients will be put into floating mode
* automatically. */ * automatically. */
bool floating; bool floating;
/** FIXME: needs documentation */ /** The number of the workspace to assign to. */
int workspace; int workspace;
TAILQ_ENTRY(Assignment) assignments; TAILQ_ENTRY(Assignment) assignments;
}; };

View File

@ -3,7 +3,7 @@
* *
* i3 - an improved dynamic tiling window manager * i3 - an improved dynamic tiling window manager
* *
* (c) 2009 Michael Stapelberg and contributors * © 2009 Michael Stapelberg and contributors
* *
* See file LICENSE for license information. * 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, 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 * reparent_window() gets called when a new window was opened and becomes a

View File

@ -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) { 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_cookie_t cookie;
xcb_get_window_attributes_reply_t *reply;
cookie = xcb_get_window_attributes_unchecked(conn, event->window); 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); LOG("window = 0x%08x, serial is %d.\n", event->window, event->sequence);
add_ignore_event(event->sequence); add_ignore_event(event->sequence);
manage_window(prophs, conn, event->window, wa); manage_window(prophs, conn, event->window, cookie, false);
return 1; return 1;
} }

View File

@ -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]); cookies[i] = xcb_get_window_attributes(conn, children[i]);
/* Call manage_window with the attributes for every window */ /* Call manage_window with the attributes for every window */
for(i = 0; i < len; ++i) { for(i = 0; i < len; ++i)
window_attributes_t wa = { TAG_COOKIE, { cookies[i] } }; manage_window(prophs, conn, children[i], cookies[i], true);
manage_window(prophs, conn, children[i], wa);
}
free(reply); free(reply);
free(cookies); 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. * 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"); LOG("managing window.\n");
xcb_drawable_t d = { window }; xcb_drawable_t d = { window };
xcb_get_geometry_cookie_t geomc; xcb_get_geometry_cookie_t geomc;
xcb_get_geometry_reply_t *geom; xcb_get_geometry_reply_t *geom;
xcb_get_window_attributes_reply_t *attr = 0; xcb_get_window_attributes_reply_t *attr = 0;
if (wa.tag == TAG_COOKIE) { geomc = xcb_get_geometry(conn, d);
/* 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;
if (attr->map_state != XCB_MAP_STATE_VIEWABLE) /* Check if the window is mapped (it could be not mapped when intializing and
goto out; 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; if (attr->map_state != XCB_MAP_STATE_VIEWABLE) {
wa.u.override_redirect = attr->override_redirect; LOG("Window not mapped, not managing\n");
goto out;
} }
/* Dont manage clients with the override_redirect flag */ /* Dont 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; goto out;
}
/* Check if the window is already managed */ /* Check if the window is already managed */
if (table_get(&by_child, window)) if (table_get(&by_child, window))
goto out; goto out;
/* Get the initial geometry (position, size, …) */ /* 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) if ((geom = xcb_get_geometry_reply(conn, geomc, 0)) == NULL)
goto out; goto out;