more reformatting/cleanups
This commit is contained in:
parent
dd7acf73e9
commit
eec762ea8f
195
include/data.h
195
include/data.h
|
@ -1,11 +1,8 @@
|
||||||
/*
|
/*
|
||||||
* vim:ts=8:expandtab
|
* vim:ts=4:sw=4:expandtab
|
||||||
*
|
*
|
||||||
* i3 - an improved dynamic tiling window manager
|
* i3 - an improved dynamic tiling window manager
|
||||||
*
|
* © 2009-2010 Michael Stapelberg and contributors (see also: LICENSE)
|
||||||
* © 2009-2010 Michael Stapelberg and contributors
|
|
||||||
*
|
|
||||||
* See file LICENSE for license information.
|
|
||||||
*
|
*
|
||||||
* include/data.h: This file defines all data structures used by i3
|
* 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;
|
typedef enum { HORIZ, VERT, NO_ORIENTATION } orientation_t;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
BIND_NONE = 0,
|
BIND_NONE = 0,
|
||||||
BIND_SHIFT = XCB_MOD_MASK_SHIFT, /* (1 << 0) */
|
BIND_SHIFT = XCB_MOD_MASK_SHIFT, /* (1 << 0) */
|
||||||
BIND_CONTROL = XCB_MOD_MASK_CONTROL, /* (1 << 2) */
|
BIND_CONTROL = XCB_MOD_MASK_CONTROL, /* (1 << 2) */
|
||||||
BIND_MOD1 = XCB_MOD_MASK_1, /* (1 << 3) */
|
BIND_MOD1 = XCB_MOD_MASK_1, /* (1 << 3) */
|
||||||
BIND_MOD2 = XCB_MOD_MASK_2, /* (1 << 4) */
|
BIND_MOD2 = XCB_MOD_MASK_2, /* (1 << 4) */
|
||||||
BIND_MOD3 = XCB_MOD_MASK_3, /* (1 << 5) */
|
BIND_MOD3 = XCB_MOD_MASK_3, /* (1 << 5) */
|
||||||
BIND_MOD4 = XCB_MOD_MASK_4, /* (1 << 6) */
|
BIND_MOD4 = XCB_MOD_MASK_4, /* (1 << 6) */
|
||||||
BIND_MOD5 = XCB_MOD_MASK_5, /* (1 << 7) */
|
BIND_MOD5 = XCB_MOD_MASK_5, /* (1 << 7) */
|
||||||
BIND_MODE_SWITCH = (1 << 8)
|
BIND_MODE_SWITCH = (1 << 8)
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -71,10 +68,10 @@ enum {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
struct Rect {
|
struct Rect {
|
||||||
uint32_t x;
|
uint32_t x;
|
||||||
uint32_t y;
|
uint32_t y;
|
||||||
uint32_t width;
|
uint32_t width;
|
||||||
uint32_t height;
|
uint32_t height;
|
||||||
} __attribute__((packed));
|
} __attribute__((packed));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -82,43 +79,32 @@ struct Rect {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
struct Colorpixel {
|
struct Colorpixel {
|
||||||
uint32_t pixel;
|
uint32_t pixel;
|
||||||
char *hex;
|
char *hex;
|
||||||
SLIST_ENTRY(Colorpixel) colorpixels;
|
SLIST_ENTRY(Colorpixel) colorpixels;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Cached_Pixmap {
|
struct Cached_Pixmap {
|
||||||
xcb_pixmap_t id;
|
xcb_pixmap_t id;
|
||||||
|
|
||||||
/* We’re going to paint on it, so a graphics context will be needed */
|
/* We’re going to paint on it, so a graphics context will be needed */
|
||||||
xcb_gcontext_t gc;
|
xcb_gcontext_t gc;
|
||||||
|
|
||||||
/* The rect with which the pixmap was created */
|
/* The rect with which the pixmap was created */
|
||||||
Rect rect;
|
Rect rect;
|
||||||
|
|
||||||
/* The rect of the object to which this pixmap belongs. Necessary to
|
/* The rect of the object to which this pixmap belongs. Necessary to
|
||||||
* find out when we need to re-create the pixmap. */
|
* find out when we need to re-create the pixmap. */
|
||||||
Rect *referred_rect;
|
Rect *referred_rect;
|
||||||
|
|
||||||
xcb_drawable_t referred_drawable;
|
xcb_drawable_t referred_drawable;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Ignore_Event {
|
struct Ignore_Event {
|
||||||
int sequence;
|
int sequence;
|
||||||
time_t added;
|
time_t added;
|
||||||
|
|
||||||
SLIST_ENTRY(Ignore_Event) ignore_events;
|
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;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
|
@ -131,30 +117,30 @@ struct keyvalue_element {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
struct Binding {
|
struct Binding {
|
||||||
/** Symbol the user specified in configfile, if any. This needs to be
|
/** 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
|
* stored with the binding to be able to re-convert it into a keycode
|
||||||
* if the keyboard mapping changes (using Xmodmap for example) */
|
* if the keyboard mapping changes (using Xmodmap for example) */
|
||||||
char *symbol;
|
char *symbol;
|
||||||
|
|
||||||
/** Only in use if symbol != NULL. Gets set to the value to which the
|
/** Only in use if symbol != NULL. Gets set to the value to which the
|
||||||
* symbol got translated when binding. Useful for unbinding and
|
* symbol got translated when binding. Useful for unbinding and
|
||||||
* checking which binding was used when a key press event comes in.
|
* checking which binding was used when a key press event comes in.
|
||||||
*
|
*
|
||||||
* This is an array of number_keycodes size. */
|
* This is an array of number_keycodes size. */
|
||||||
xcb_keycode_t *translated_to;
|
xcb_keycode_t *translated_to;
|
||||||
|
|
||||||
uint32_t number_keycodes;
|
uint32_t number_keycodes;
|
||||||
|
|
||||||
/** Keycode to bind */
|
/** Keycode to bind */
|
||||||
uint32_t keycode;
|
uint32_t keycode;
|
||||||
|
|
||||||
/** Bitmask consisting of BIND_MOD_1, BIND_MODE_SWITCH, … */
|
/** Bitmask consisting of BIND_MOD_1, BIND_MODE_SWITCH, … */
|
||||||
uint32_t mods;
|
uint32_t mods;
|
||||||
|
|
||||||
/** Command, like in command mode */
|
/** Command, like in command mode */
|
||||||
char *command;
|
char *command;
|
||||||
|
|
||||||
TAILQ_ENTRY(Binding) bindings;
|
TAILQ_ENTRY(Binding) bindings;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -162,30 +148,9 @@ struct Binding {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
struct Autostart {
|
struct Autostart {
|
||||||
/** Command, like in command mode */
|
/** Command, like in command mode */
|
||||||
char *command;
|
char *command;
|
||||||
TAILQ_ENTRY(Autostart) autostarts;
|
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, /* don’t float, but put on a workspace */
|
|
||||||
ASSIGN_FLOATING_ONLY, /* float, but don’t 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;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -195,16 +160,16 @@ struct Assignment {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
struct Font {
|
struct Font {
|
||||||
/** The name of the font, that is what the pattern resolves to */
|
/** The name of the font, that is what the pattern resolves to */
|
||||||
char *name;
|
char *name;
|
||||||
/** A copy of the pattern to build a cache */
|
/** A copy of the pattern to build a cache */
|
||||||
char *pattern;
|
char *pattern;
|
||||||
/** The height of the font, built from font_ascent + font_descent */
|
/** The height of the font, built from font_ascent + font_descent */
|
||||||
int height;
|
int height;
|
||||||
/** The xcb-id for the font */
|
/** The xcb-id for the font */
|
||||||
xcb_font_t id;
|
xcb_font_t id;
|
||||||
|
|
||||||
TAILQ_ENTRY(Font) fonts;
|
TAILQ_ENTRY(Font) fonts;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -216,32 +181,32 @@ struct Font {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
struct xoutput {
|
struct xoutput {
|
||||||
/** Output id, so that we can requery the output directly later */
|
/** Output id, so that we can requery the output directly later */
|
||||||
xcb_randr_output_t id;
|
xcb_randr_output_t id;
|
||||||
/** Name of the output */
|
/** Name of the output */
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
/** Whether the output is currently active (has a CRTC attached with a
|
/** Whether the output is currently active (has a CRTC attached with a
|
||||||
* valid mode) */
|
* valid mode) */
|
||||||
bool active;
|
bool active;
|
||||||
|
|
||||||
/** Internal flags, necessary for querying RandR screens (happens in
|
/** Internal flags, necessary for querying RandR screens (happens in
|
||||||
* two stages) */
|
* two stages) */
|
||||||
bool changed;
|
bool changed;
|
||||||
bool to_be_disabled;
|
bool to_be_disabled;
|
||||||
|
|
||||||
/** x, y, width, height */
|
/** x, y, width, height */
|
||||||
Rect rect;
|
Rect rect;
|
||||||
|
|
||||||
/** The bar window */
|
/** The bar window */
|
||||||
xcb_window_t bar;
|
xcb_window_t bar;
|
||||||
xcb_gcontext_t bargc;
|
xcb_gcontext_t bargc;
|
||||||
|
|
||||||
/** Contains all clients with _NET_WM_WINDOW_TYPE ==
|
/** Contains all clients with _NET_WM_WINDOW_TYPE ==
|
||||||
* _NET_WM_WINDOW_TYPE_DOCK */
|
* _NET_WM_WINDOW_TYPE_DOCK */
|
||||||
SLIST_HEAD(dock_clients_head, Client) dock_clients;
|
SLIST_HEAD(dock_clients_head, Client) dock_clients;
|
||||||
|
|
||||||
TAILQ_ENTRY(xoutput) outputs;
|
TAILQ_ENTRY(xoutput) outputs;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Window {
|
struct Window {
|
||||||
|
|
|
@ -34,10 +34,6 @@
|
||||||
} \
|
} \
|
||||||
while (0)
|
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 min(int a, int b);
|
||||||
int max(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);
|
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
|
* Starts the given application by passing it through a shell. We use double
|
||||||
* fork to avoid zombie processes. As the started application’s parent exits
|
* fork to avoid zombie processes. As the started application’s parent exits
|
||||||
|
|
42
src/util.c
42
src/util.c
|
@ -22,8 +22,6 @@
|
||||||
#include "all.h"
|
#include "all.h"
|
||||||
|
|
||||||
static iconv_t conversion_descriptor = 0;
|
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) {
|
int min(int a, int b) {
|
||||||
return (a < b ? a : b);
|
return (a < b ? a : b);
|
||||||
|
@ -73,46 +71,6 @@ char *sstrdup(const char *str) {
|
||||||
return result;
|
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
|
* Starts the given application by passing it through a shell. We use double fork
|
||||||
* to avoid zombie processes. As the started application’s parent exits (immediately),
|
* to avoid zombie processes. As the started application’s parent exits (immediately),
|
||||||
|
|
Loading…
Reference in New Issue