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
#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;

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 {
@ -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;
};

View File

@ -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

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) {
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;
}

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]);
/* 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;
}
/* 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;
}
/* 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;