*
*/
-/* FIXME: this file lacks documentation */
-
#ifndef _CONFIG_H
#define _CONFIG_H
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;
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;
};
/**
- * FIXME: needs to be documented
+ * Stores a rectangle, for example the size of a window, the child window etc.
*
*/
struct Rect {
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
*****************************************************************************/
* 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;
};
*
* i3 - an improved dynamic tiling window manager
*
- * (c) 2009 Michael Stapelberg and contributors
+ * © 2009 Michael Stapelberg and contributors
*
* See file LICENSE for license information.
*
*
*/
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
*/
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;
}
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);
* 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;