more reformatting/cleanups

next
Michael Stapelberg 2010-04-13 17:52:23 +02:00
parent dd7acf73e9
commit eec762ea8f
3 changed files with 80 additions and 181 deletions

View File

@ -1,11 +1,8 @@
/*
* vim:ts=8:expandtab
* vim:ts=4:sw=4:expandtab
*
* i3 - an improved dynamic tiling window manager
*
* © 2009-2010 Michael Stapelberg and contributors
*
* See file LICENSE for license information.
* © 2009-2010 Michael Stapelberg and contributors (see also: LICENSE)
*
* include/data.h: This file defines all data structures used by i3
*
@ -47,15 +44,15 @@ typedef enum { D_LEFT, D_RIGHT, D_UP, D_DOWN } direction_t;
typedef enum { HORIZ, VERT, NO_ORIENTATION } orientation_t;
enum {
BIND_NONE = 0,
BIND_SHIFT = XCB_MOD_MASK_SHIFT, /* (1 << 0) */
BIND_CONTROL = XCB_MOD_MASK_CONTROL, /* (1 << 2) */
BIND_MOD1 = XCB_MOD_MASK_1, /* (1 << 3) */
BIND_MOD2 = XCB_MOD_MASK_2, /* (1 << 4) */
BIND_MOD3 = XCB_MOD_MASK_3, /* (1 << 5) */
BIND_MOD4 = XCB_MOD_MASK_4, /* (1 << 6) */
BIND_MOD5 = XCB_MOD_MASK_5, /* (1 << 7) */
BIND_MODE_SWITCH = (1 << 8)
BIND_NONE = 0,
BIND_SHIFT = XCB_MOD_MASK_SHIFT, /* (1 << 0) */
BIND_CONTROL = XCB_MOD_MASK_CONTROL, /* (1 << 2) */
BIND_MOD1 = XCB_MOD_MASK_1, /* (1 << 3) */
BIND_MOD2 = XCB_MOD_MASK_2, /* (1 << 4) */
BIND_MOD3 = XCB_MOD_MASK_3, /* (1 << 5) */
BIND_MOD4 = XCB_MOD_MASK_4, /* (1 << 6) */
BIND_MOD5 = XCB_MOD_MASK_5, /* (1 << 7) */
BIND_MODE_SWITCH = (1 << 8)
};
/**
@ -71,10 +68,10 @@ enum {
*
*/
struct Rect {
uint32_t x;
uint32_t y;
uint32_t width;
uint32_t height;
uint32_t x;
uint32_t y;
uint32_t width;
uint32_t height;
} __attribute__((packed));
/**
@ -82,43 +79,32 @@ struct Rect {
*
*/
struct Colorpixel {
uint32_t pixel;
char *hex;
SLIST_ENTRY(Colorpixel) colorpixels;
uint32_t pixel;
char *hex;
SLIST_ENTRY(Colorpixel) colorpixels;
};
struct Cached_Pixmap {
xcb_pixmap_t id;
xcb_pixmap_t id;
/* Were going to paint on it, so a graphics context will be needed */
xcb_gcontext_t gc;
/* Were going to paint on it, so a graphics context will be needed */
xcb_gcontext_t gc;
/* The rect with which the pixmap was created */
Rect rect;
/* The rect with which the pixmap was created */
Rect rect;
/* The rect of the object to which this pixmap belongs. Necessary to
* find out when we need to re-create the pixmap. */
Rect *referred_rect;
/* The rect of the object to which this pixmap belongs. Necessary to
* find out when we need to re-create the pixmap. */
Rect *referred_rect;
xcb_drawable_t referred_drawable;
xcb_drawable_t referred_drawable;
};
struct Ignore_Event {
int sequence;
time_t added;
int sequence;
time_t added;
SLIST_ENTRY(Ignore_Event) ignore_events;
};
/**
* Emulates the behaviour of tables of libxcb-wm, which in libxcb 0.3.4
* suddenly vanished.
*
*/
struct keyvalue_element {
uint32_t key;
void *value;
TAILQ_ENTRY(keyvalue_element) elements;
SLIST_ENTRY(Ignore_Event) ignore_events;
};
/******************************************************************************
@ -131,30 +117,30 @@ struct keyvalue_element {
*
*/
struct Binding {
/** Symbol the user specified in configfile, if any. This needs to be
* stored with the binding to be able to re-convert it into a keycode
* if the keyboard mapping changes (using Xmodmap for example) */
char *symbol;
/** Symbol the user specified in configfile, if any. This needs to be
* stored with the binding to be able to re-convert it into a keycode
* if the keyboard mapping changes (using Xmodmap for example) */
char *symbol;
/** Only in use if symbol != NULL. Gets set to the value to which the
* symbol got translated when binding. Useful for unbinding and
* checking which binding was used when a key press event comes in.
*
* This is an array of number_keycodes size. */
xcb_keycode_t *translated_to;
/** Only in use if symbol != NULL. Gets set to the value to which the
* symbol got translated when binding. Useful for unbinding and
* checking which binding was used when a key press event comes in.
*
* This is an array of number_keycodes size. */
xcb_keycode_t *translated_to;
uint32_t number_keycodes;
uint32_t number_keycodes;
/** Keycode to bind */
uint32_t keycode;
/** Keycode to bind */
uint32_t keycode;
/** Bitmask consisting of BIND_MOD_1, BIND_MODE_SWITCH, … */
uint32_t mods;
/** Bitmask consisting of BIND_MOD_1, BIND_MODE_SWITCH, … */
uint32_t mods;
/** Command, like in command mode */
char *command;
/** Command, like in command mode */
char *command;
TAILQ_ENTRY(Binding) bindings;
TAILQ_ENTRY(Binding) bindings;
};
/**
@ -162,30 +148,9 @@ struct Binding {
*
*/
struct Autostart {
/** Command, like in command mode */
char *command;
TAILQ_ENTRY(Autostart) autostarts;
};
/**
* Holds an assignment for a given window class/title to a specific workspace
* (see src/config.c)
*
*/
struct Assignment {
char *windowclass_title;
/** floating is true if this was an assignment to the special
* workspace "~". Matching clients will be put into floating mode
* automatically. */
enum {
ASSIGN_FLOATING_NO, /* dont float, but put on a workspace */
ASSIGN_FLOATING_ONLY, /* float, but dont assign on a workspace */
ASSIGN_FLOATING /* float and put on a workspace */
} floating;
/** The number of the workspace to assign to. */
int workspace;
TAILQ_ENTRY(Assignment) assignments;
/** Command, like in command mode */
char *command;
TAILQ_ENTRY(Autostart) autostarts;
};
/**
@ -195,16 +160,16 @@ struct Assignment {
*
*/
struct Font {
/** The name of the font, that is what the pattern resolves to */
char *name;
/** A copy of the pattern to build a cache */
char *pattern;
/** The height of the font, built from font_ascent + font_descent */
int height;
/** The xcb-id for the font */
xcb_font_t id;
/** The name of the font, that is what the pattern resolves to */
char *name;
/** A copy of the pattern to build a cache */
char *pattern;
/** The height of the font, built from font_ascent + font_descent */
int height;
/** The xcb-id for the font */
xcb_font_t id;
TAILQ_ENTRY(Font) fonts;
TAILQ_ENTRY(Font) fonts;
};
@ -216,32 +181,32 @@ struct Font {
*
*/
struct xoutput {
/** Output id, so that we can requery the output directly later */
xcb_randr_output_t id;
/** Name of the output */
char *name;
/** Output id, so that we can requery the output directly later */
xcb_randr_output_t id;
/** Name of the output */
char *name;
/** Whether the output is currently active (has a CRTC attached with a
* valid mode) */
bool active;
/** Whether the output is currently active (has a CRTC attached with a
* valid mode) */
bool active;
/** Internal flags, necessary for querying RandR screens (happens in
* two stages) */
bool changed;
bool to_be_disabled;
/** Internal flags, necessary for querying RandR screens (happens in
* two stages) */
bool changed;
bool to_be_disabled;
/** x, y, width, height */
Rect rect;
/** x, y, width, height */
Rect rect;
/** The bar window */
xcb_window_t bar;
xcb_gcontext_t bargc;
/** The bar window */
xcb_window_t bar;
xcb_gcontext_t bargc;
/** Contains all clients with _NET_WM_WINDOW_TYPE ==
* _NET_WM_WINDOW_TYPE_DOCK */
SLIST_HEAD(dock_clients_head, Client) dock_clients;
/** Contains all clients with _NET_WM_WINDOW_TYPE ==
* _NET_WM_WINDOW_TYPE_DOCK */
SLIST_HEAD(dock_clients_head, Client) dock_clients;
TAILQ_ENTRY(xoutput) outputs;
TAILQ_ENTRY(xoutput) outputs;
};
struct Window {

View File

@ -34,10 +34,6 @@
} \
while (0)
TAILQ_HEAD(keyvalue_table_head, keyvalue_element);
extern struct keyvalue_table_head by_parent;
extern struct keyvalue_table_head by_child;
int min(int a, int b);
int max(int a, int b);
@ -76,26 +72,6 @@ void *srealloc(void *ptr, size_t size);
*/
char *sstrdup(const char *str);
/**
* Inserts an element into the given keyvalue-table using the given key.
*
*/
bool table_put(struct keyvalue_table_head *head, uint32_t key, void *value);
/**
* Removes the element from the given keyvalue-table with the given key and
* returns its value;
*
*/
void *table_remove(struct keyvalue_table_head *head, uint32_t key);
/**
* Returns the value of the element of the given keyvalue-table with the given
* key.
*
*/
void *table_get(struct keyvalue_table_head *head, uint32_t key);
/**
* Starts the given application by passing it through a shell. We use double
* fork to avoid zombie processes. As the started applications parent exits

View File

@ -22,8 +22,6 @@
#include "all.h"
static iconv_t conversion_descriptor = 0;
struct keyvalue_table_head by_parent = TAILQ_HEAD_INITIALIZER(by_parent);
struct keyvalue_table_head by_child = TAILQ_HEAD_INITIALIZER(by_child);
int min(int a, int b) {
return (a < b ? a : b);
@ -73,46 +71,6 @@ char *sstrdup(const char *str) {
return result;
}
#if 0
/*
* The table_* functions emulate the behaviour of libxcb-wm, which in libxcb 0.3.4 suddenly
* vanished. Great.
*
*/
bool table_put(struct keyvalue_table_head *head, uint32_t key, void *value) {
struct keyvalue_element *element = scalloc(sizeof(struct keyvalue_element));
element->key = key;
element->value = value;
TAILQ_INSERT_TAIL(head, element, elements);
return true;
}
void *table_remove(struct keyvalue_table_head *head, uint32_t key) {
struct keyvalue_element *element;
TAILQ_FOREACH(element, head, elements)
if (element->key == key) {
void *value = element->value;
TAILQ_REMOVE(head, element, elements);
free(element);
return value;
}
return NULL;
}
void *table_get(struct keyvalue_table_head *head, uint32_t key) {
struct keyvalue_element *element;
TAILQ_FOREACH(element, head, elements)
if (element->key == key)
return element->value;
return NULL;
}
#endif
/*
* Starts the given application by passing it through a shell. We use double fork
* to avoid zombie processes. As the started applications parent exits (immediately),