clang-format-3.5 **/*.h **/*.c
This should be the last commit that formats a big bunch of files. From here on, whenever I merge patches, I’ll run clang-format like described in the title.
This commit is contained in:
parent
4211274fcd
commit
4c06e7a573
@ -1,8 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
/* from X11/keysymdef.h */
|
/* from X11/keysymdef.h */
|
||||||
#define XCB_NUM_LOCK 0xff7f
|
#define XCB_NUM_LOCK 0xff7f
|
||||||
|
|
||||||
#define xmacro(atom) xcb_atom_t A_ ## atom;
|
#define xmacro(atom) xcb_atom_t A_##atom;
|
||||||
#include "atoms.xmacro"
|
#include "atoms.xmacro"
|
||||||
#undef xmacro
|
#undef xmacro
|
||||||
|
@ -3,12 +3,12 @@
|
|||||||
#include <err.h>
|
#include <err.h>
|
||||||
|
|
||||||
#define die(...) errx(EXIT_FAILURE, __VA_ARGS__);
|
#define die(...) errx(EXIT_FAILURE, __VA_ARGS__);
|
||||||
#define FREE(pointer) do { \
|
#define FREE(pointer) \
|
||||||
|
do { \
|
||||||
if (pointer != NULL) { \
|
if (pointer != NULL) { \
|
||||||
free(pointer); \
|
free(pointer); \
|
||||||
pointer = NULL; \
|
pointer = NULL; \
|
||||||
} \
|
} \
|
||||||
} \
|
} while (0)
|
||||||
while (0)
|
|
||||||
|
|
||||||
extern xcb_window_t root;
|
extern xcb_window_t root;
|
||||||
|
@ -3,15 +3,15 @@
|
|||||||
#include <err.h>
|
#include <err.h>
|
||||||
|
|
||||||
#define die(...) errx(EXIT_FAILURE, __VA_ARGS__);
|
#define die(...) errx(EXIT_FAILURE, __VA_ARGS__);
|
||||||
#define FREE(pointer) do { \
|
#define FREE(pointer) \
|
||||||
|
do { \
|
||||||
if (pointer != NULL) { \
|
if (pointer != NULL) { \
|
||||||
free(pointer); \
|
free(pointer); \
|
||||||
pointer = NULL; \
|
pointer = NULL; \
|
||||||
} \
|
} \
|
||||||
} \
|
} while (0)
|
||||||
while (0)
|
|
||||||
|
|
||||||
#define xmacro(atom) xcb_atom_t A_ ## atom;
|
#define xmacro(atom) xcb_atom_t A_##atom;
|
||||||
#include "atoms.xmacro"
|
#include "atoms.xmacro"
|
||||||
#undef xmacro
|
#undef xmacro
|
||||||
|
|
||||||
|
@ -15,9 +15,9 @@
|
|||||||
|
|
||||||
typedef struct rect_t rect;
|
typedef struct rect_t rect;
|
||||||
|
|
||||||
struct ev_loop* main_loop;
|
struct ev_loop *main_loop;
|
||||||
char *statusline;
|
char *statusline;
|
||||||
char *statusline_buffer;
|
char *statusline_buffer;
|
||||||
|
|
||||||
struct rect_t {
|
struct rect_t {
|
||||||
int x;
|
int x;
|
||||||
|
@ -18,27 +18,30 @@ typedef enum {
|
|||||||
} position_t;
|
} position_t;
|
||||||
|
|
||||||
/* Bar display mode (hide unless modifier is pressed or show in dock mode or always hide in invisible mode) */
|
/* Bar display mode (hide unless modifier is pressed or show in dock mode or always hide in invisible mode) */
|
||||||
typedef enum { M_DOCK = 0, M_HIDE = 1, M_INVISIBLE = 2 } bar_display_mode_t;
|
typedef enum { M_DOCK = 0,
|
||||||
|
M_HIDE = 1,
|
||||||
|
M_INVISIBLE = 2 } bar_display_mode_t;
|
||||||
|
|
||||||
typedef struct config_t {
|
typedef struct config_t {
|
||||||
int modifier;
|
int modifier;
|
||||||
position_t position;
|
position_t position;
|
||||||
int verbose;
|
int verbose;
|
||||||
struct xcb_color_strings_t colors;
|
struct xcb_color_strings_t colors;
|
||||||
bool disable_binding_mode_indicator;
|
bool disable_binding_mode_indicator;
|
||||||
bool disable_ws;
|
bool disable_ws;
|
||||||
bool strip_ws_numbers;
|
bool strip_ws_numbers;
|
||||||
char *bar_id;
|
char *bar_id;
|
||||||
char *command;
|
char *command;
|
||||||
char *fontname;
|
char *fontname;
|
||||||
char *tray_output;
|
char *tray_output;
|
||||||
int num_outputs;
|
int num_outputs;
|
||||||
char **outputs;
|
char **outputs;
|
||||||
|
|
||||||
bar_display_mode_t hide_on_modifier;
|
bar_display_mode_t hide_on_modifier;
|
||||||
|
|
||||||
/* The current hidden_state of the bar, which indicates whether it is hidden or shown */
|
/* The current hidden_state of the bar, which indicates whether it is hidden or shown */
|
||||||
enum { S_HIDE = 0, S_SHOW = 1 } hidden_state;
|
enum { S_HIDE = 0,
|
||||||
|
S_SHOW = 1 } hidden_state;
|
||||||
} config_t;
|
} config_t;
|
||||||
|
|
||||||
config_t config;
|
config_t config;
|
||||||
|
@ -29,7 +29,7 @@ void destroy_connection(void);
|
|||||||
* type must be a valid I3_IPC_MESSAGE_TYPE (see i3/ipc.h for further information)
|
* type must be a valid I3_IPC_MESSAGE_TYPE (see i3/ipc.h for further information)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
int i3_send_msg(uint32_t type, const char* payload);
|
int i3_send_msg(uint32_t type, const char *payload);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Subscribe to all the i3-events, we need
|
* Subscribe to all the i3-events, we need
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
typedef struct i3_output i3_output;
|
typedef struct i3_output i3_output;
|
||||||
|
|
||||||
SLIST_HEAD(outputs_head, i3_output);
|
SLIST_HEAD(outputs_head, i3_output);
|
||||||
struct outputs_head *outputs;
|
struct outputs_head* outputs;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Start parsing the received json-string
|
* Start parsing the received json-string
|
||||||
@ -37,18 +37,18 @@ void init_outputs(void);
|
|||||||
i3_output* get_output_by_name(char* name);
|
i3_output* get_output_by_name(char* name);
|
||||||
|
|
||||||
struct i3_output {
|
struct i3_output {
|
||||||
char* name; /* Name of the output */
|
char* name; /* Name of the output */
|
||||||
bool active; /* If the output is active */
|
bool active; /* If the output is active */
|
||||||
bool primary; /* If it is the primary output */
|
bool primary; /* If it is the primary output */
|
||||||
int ws; /* The number of the currently visible ws */
|
int ws; /* The number of the currently visible ws */
|
||||||
rect rect; /* The rect (relative to the root-win) */
|
rect rect; /* The rect (relative to the root-win) */
|
||||||
|
|
||||||
xcb_window_t bar; /* The id of the bar of the output */
|
xcb_window_t bar; /* The id of the bar of the output */
|
||||||
xcb_pixmap_t buffer; /* An extra pixmap for double-buffering */
|
xcb_pixmap_t buffer; /* An extra pixmap for double-buffering */
|
||||||
xcb_gcontext_t bargc; /* The graphical context of the bar */
|
xcb_gcontext_t bargc; /* The graphical context of the bar */
|
||||||
|
|
||||||
struct ws_head *workspaces; /* The workspaces on this output */
|
struct ws_head* workspaces; /* The workspaces on this output */
|
||||||
struct tc_head *trayclients; /* The tray clients on this output */
|
struct tc_head* trayclients; /* The tray clients on this output */
|
||||||
|
|
||||||
SLIST_ENTRY(i3_output) slist; /* Pointer for the SLIST-Macro */
|
SLIST_ENTRY(i3_output) slist; /* Pointer for the SLIST-Macro */
|
||||||
};
|
};
|
||||||
|
@ -14,9 +14,9 @@ typedef struct trayclient trayclient;
|
|||||||
TAILQ_HEAD(tc_head, trayclient);
|
TAILQ_HEAD(tc_head, trayclient);
|
||||||
|
|
||||||
struct trayclient {
|
struct trayclient {
|
||||||
xcb_window_t win; /* The window ID of the tray client */
|
xcb_window_t win; /* The window ID of the tray client */
|
||||||
bool mapped; /* Whether this window is mapped */
|
bool mapped; /* Whether this window is mapped */
|
||||||
int xe_version; /* The XEMBED version supported by the client */
|
int xe_version; /* The XEMBED version supported by the client */
|
||||||
|
|
||||||
TAILQ_ENTRY(trayclient) tailq; /* Pointer for the TAILQ-Macro */
|
TAILQ_ENTRY(trayclient) tailq; /* Pointer for the TAILQ-Macro */
|
||||||
};
|
};
|
||||||
|
@ -11,55 +11,60 @@
|
|||||||
|
|
||||||
/* Get the maximum/minimum of x and y */
|
/* Get the maximum/minimum of x and y */
|
||||||
#undef MAX
|
#undef MAX
|
||||||
#define MAX(x,y) ((x) > (y) ? (x) : (y))
|
#define MAX(x, y) ((x) > (y) ? (x) : (y))
|
||||||
#undef MIN
|
#undef MIN
|
||||||
#define MIN(x,y) ((x) < (y) ? (x) : (y))
|
#define MIN(x, y) ((x) < (y) ? (x) : (y))
|
||||||
|
|
||||||
#define STARTS_WITH(string, len, needle) ((len >= strlen(needle)) && strncasecmp(string, needle, strlen(needle)) == 0)
|
#define STARTS_WITH(string, len, needle) ((len >= strlen(needle)) && strncasecmp(string, needle, strlen(needle)) == 0)
|
||||||
|
|
||||||
/* Securely free p */
|
/* Securely free p */
|
||||||
#define FREE(p) do { \
|
#define FREE(p) \
|
||||||
if (p != NULL) { \
|
do { \
|
||||||
free(p); \
|
if (p != NULL) { \
|
||||||
p = NULL; \
|
free(p); \
|
||||||
} \
|
p = NULL; \
|
||||||
} while (0)
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
/* Securely fee single-linked list */
|
/* Securely fee single-linked list */
|
||||||
#define FREE_SLIST(l, type) do { \
|
#define FREE_SLIST(l, type) \
|
||||||
type *walk = SLIST_FIRST(l); \
|
do { \
|
||||||
while (!SLIST_EMPTY(l)) { \
|
type *walk = SLIST_FIRST(l); \
|
||||||
SLIST_REMOVE_HEAD(l, slist); \
|
while (!SLIST_EMPTY(l)) { \
|
||||||
FREE(walk); \
|
SLIST_REMOVE_HEAD(l, slist); \
|
||||||
walk = SLIST_FIRST(l); \
|
FREE(walk); \
|
||||||
} \
|
walk = SLIST_FIRST(l); \
|
||||||
} while (0)
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
/* Securely fee tail-queues */
|
/* Securely fee tail-queues */
|
||||||
#define FREE_TAILQ(l, type) do { \
|
#define FREE_TAILQ(l, type) \
|
||||||
type *walk = TAILQ_FIRST(l); \
|
do { \
|
||||||
while (!TAILQ_EMPTY(l)) { \
|
type *walk = TAILQ_FIRST(l); \
|
||||||
TAILQ_REMOVE(l, TAILQ_FIRST(l), tailq); \
|
while (!TAILQ_EMPTY(l)) { \
|
||||||
FREE(walk); \
|
TAILQ_REMOVE(l, TAILQ_FIRST(l), tailq); \
|
||||||
walk = TAILQ_FIRST(l); \
|
FREE(walk); \
|
||||||
} \
|
walk = TAILQ_FIRST(l); \
|
||||||
} while (0)
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#if defined(DLOG)
|
#if defined(DLOG)
|
||||||
#undef DLOG
|
#undef DLOG
|
||||||
#endif
|
#endif
|
||||||
/* Use cool logging-macros */
|
/* Use cool logging-macros */
|
||||||
#define DLOG(fmt, ...) do { \
|
#define DLOG(fmt, ...) \
|
||||||
if (config.verbose) { \
|
do { \
|
||||||
printf("[%s:%d] " fmt, __FILE__, __LINE__, ##__VA_ARGS__); \
|
if (config.verbose) { \
|
||||||
} \
|
printf("[%s:%d] " fmt, __FILE__, __LINE__, ##__VA_ARGS__); \
|
||||||
} while(0)
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
/* We will include libi3.h which define its own version of ELOG.
|
/* We will include libi3.h which define its own version of ELOG.
|
||||||
* We want *our* version, so we undef the libi3 one. */
|
* We want *our* version, so we undef the libi3 one. */
|
||||||
#if defined(ELOG)
|
#if defined(ELOG)
|
||||||
#undef ELOG
|
#undef ELOG
|
||||||
#endif
|
#endif
|
||||||
#define ELOG(fmt, ...) do { \
|
#define ELOG(fmt, ...) \
|
||||||
fprintf(stderr, "[%s:%d] ERROR: " fmt, __FILE__, __LINE__, ##__VA_ARGS__); \
|
do { \
|
||||||
} while(0)
|
fprintf(stderr, "[%s:%d] ERROR: " fmt, __FILE__, __LINE__, ##__VA_ARGS__); \
|
||||||
|
} while (0)
|
||||||
|
@ -30,15 +30,15 @@ void parse_workspaces_json(char *json);
|
|||||||
void free_workspaces(void);
|
void free_workspaces(void);
|
||||||
|
|
||||||
struct i3_ws {
|
struct i3_ws {
|
||||||
int num; /* The internal number of the ws */
|
int num; /* The internal number of the ws */
|
||||||
char *canonical_name; /* The true name of the ws according to the ipc */
|
char *canonical_name; /* The true name of the ws according to the ipc */
|
||||||
i3String *name; /* The name of the ws that is displayed on the bar */
|
i3String *name; /* The name of the ws that is displayed on the bar */
|
||||||
int name_width; /* The rendered width of the name */
|
int name_width; /* The rendered width of the name */
|
||||||
bool visible; /* If the ws is currently visible on an output */
|
bool visible; /* If the ws is currently visible on an output */
|
||||||
bool focused; /* If the ws is currently focused */
|
bool focused; /* If the ws is currently focused */
|
||||||
bool urgent; /* If the urgent-hint of the ws is set */
|
bool urgent; /* If the urgent-hint of the ws is set */
|
||||||
rect rect; /* The rect of the ws (not used (yet)) */
|
rect rect; /* The rect of the ws (not used (yet)) */
|
||||||
struct i3_output *output; /* The current output of the ws */
|
struct i3_output *output; /* The current output of the ws */
|
||||||
|
|
||||||
TAILQ_ENTRY(i3_ws) tailq; /* Pointer for the TAILQ-Macro */
|
TAILQ_ENTRY(i3_ws) tailq; /* Pointer for the TAILQ-Macro */
|
||||||
};
|
};
|
||||||
|
@ -18,11 +18,11 @@
|
|||||||
|
|
||||||
#define _NET_SYSTEM_TRAY_ORIENTATION_HORZ 0
|
#define _NET_SYSTEM_TRAY_ORIENTATION_HORZ 0
|
||||||
#define _NET_SYSTEM_TRAY_ORIENTATION_VERT 1
|
#define _NET_SYSTEM_TRAY_ORIENTATION_VERT 1
|
||||||
#define SYSTEM_TRAY_REQUEST_DOCK 0
|
#define SYSTEM_TRAY_REQUEST_DOCK 0
|
||||||
#define SYSTEM_TRAY_BEGIN_MESSAGE 1
|
#define SYSTEM_TRAY_BEGIN_MESSAGE 1
|
||||||
#define SYSTEM_TRAY_CANCEL_MESSAGE 2
|
#define SYSTEM_TRAY_CANCEL_MESSAGE 2
|
||||||
#define XEMBED_MAPPED (1 << 0)
|
#define XEMBED_MAPPED (1 << 0)
|
||||||
#define XEMBED_EMBEDDED_NOTIFY 0
|
#define XEMBED_EMBEDDED_NOTIFY 0
|
||||||
|
|
||||||
struct xcb_color_strings_t {
|
struct xcb_color_strings_t {
|
||||||
char *bar_fg;
|
char *bar_fg;
|
||||||
|
@ -243,7 +243,7 @@ static int stdin_end_map(void *context) {
|
|||||||
static int stdin_end_array(void *context) {
|
static int stdin_end_array(void *context) {
|
||||||
DLOG("dumping statusline:\n");
|
DLOG("dumping statusline:\n");
|
||||||
struct status_block *current;
|
struct status_block *current;
|
||||||
TAILQ_FOREACH (current, &statusline_head, blocks) {
|
TAILQ_FOREACH(current, &statusline_head, blocks) {
|
||||||
DLOG("full_text = %s\n", i3string_as_utf8(current->full_text));
|
DLOG("full_text = %s\n", i3string_as_utf8(current->full_text));
|
||||||
DLOG("color = %s\n", current->color);
|
DLOG("color = %s\n", current->color);
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ void got_output_reply(char *reply) {
|
|||||||
reconfig_windows(false);
|
reconfig_windows(false);
|
||||||
|
|
||||||
i3_output *o_walk;
|
i3_output *o_walk;
|
||||||
SLIST_FOREACH (o_walk, outputs, slist) {
|
SLIST_FOREACH(o_walk, outputs, slist) {
|
||||||
kick_tray_clients(o_walk);
|
kick_tray_clients(o_walk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -296,7 +296,7 @@ i3_output *get_output_by_name(char *name) {
|
|||||||
if (name == NULL) {
|
if (name == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
SLIST_FOREACH (walk, outputs, slist) {
|
SLIST_FOREACH(walk, outputs, slist) {
|
||||||
if (!strcmp(walk->name, name)) {
|
if (!strcmp(walk->name, name)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -266,9 +266,9 @@ void free_workspaces(void) {
|
|||||||
}
|
}
|
||||||
i3_ws *ws_walk;
|
i3_ws *ws_walk;
|
||||||
|
|
||||||
SLIST_FOREACH (outputs_walk, outputs, slist) {
|
SLIST_FOREACH(outputs_walk, outputs, slist) {
|
||||||
if (outputs_walk->workspaces != NULL && !TAILQ_EMPTY(outputs_walk->workspaces)) {
|
if (outputs_walk->workspaces != NULL && !TAILQ_EMPTY(outputs_walk->workspaces)) {
|
||||||
TAILQ_FOREACH (ws_walk, outputs_walk->workspaces, tailq) {
|
TAILQ_FOREACH(ws_walk, outputs_walk->workspaces, tailq) {
|
||||||
I3STRING_FREE(ws_walk->name);
|
I3STRING_FREE(ws_walk->name);
|
||||||
FREE(ws_walk->canonical_name);
|
FREE(ws_walk->canonical_name);
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,7 @@ void refresh_statusline(void) {
|
|||||||
statusline_width = 0;
|
statusline_width = 0;
|
||||||
|
|
||||||
/* Predict the text width of all blocks (in pixels). */
|
/* Predict the text width of all blocks (in pixels). */
|
||||||
TAILQ_FOREACH (block, &statusline_head, blocks) {
|
TAILQ_FOREACH(block, &statusline_head, blocks) {
|
||||||
if (i3string_get_num_bytes(block->full_text) == 0)
|
if (i3string_get_num_bytes(block->full_text) == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -173,7 +173,7 @@ void refresh_statusline(void) {
|
|||||||
|
|
||||||
/* Draw the text of each block. */
|
/* Draw the text of each block. */
|
||||||
uint32_t x = 0;
|
uint32_t x = 0;
|
||||||
TAILQ_FOREACH (block, &statusline_head, blocks) {
|
TAILQ_FOREACH(block, &statusline_head, blocks) {
|
||||||
if (i3string_get_num_bytes(block->full_text) == 0)
|
if (i3string_get_num_bytes(block->full_text) == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -206,7 +206,7 @@ void hide_bars(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
i3_output *walk;
|
i3_output *walk;
|
||||||
SLIST_FOREACH (walk, outputs, slist) {
|
SLIST_FOREACH(walk, outputs, slist) {
|
||||||
if (!walk->active) {
|
if (!walk->active) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -231,7 +231,7 @@ void unhide_bars(void) {
|
|||||||
|
|
||||||
cont_child();
|
cont_child();
|
||||||
|
|
||||||
SLIST_FOREACH (walk, outputs, slist) {
|
SLIST_FOREACH(walk, outputs, slist) {
|
||||||
if (walk->bar == XCB_NONE) {
|
if (walk->bar == XCB_NONE) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -303,7 +303,7 @@ void handle_button(xcb_button_press_event_t *event) {
|
|||||||
/* Determine, which bar was clicked */
|
/* Determine, which bar was clicked */
|
||||||
i3_output *walk;
|
i3_output *walk;
|
||||||
xcb_window_t bar = event->event;
|
xcb_window_t bar = event->event;
|
||||||
SLIST_FOREACH (walk, outputs, slist) {
|
SLIST_FOREACH(walk, outputs, slist) {
|
||||||
if (walk->bar == bar) {
|
if (walk->bar == bar) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -315,7 +315,7 @@ void handle_button(xcb_button_press_event_t *event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: Move this to extern get_ws_for_output() */
|
/* TODO: Move this to extern get_ws_for_output() */
|
||||||
TAILQ_FOREACH (cur_ws, walk->workspaces, tailq) {
|
TAILQ_FOREACH(cur_ws, walk->workspaces, tailq) {
|
||||||
if (cur_ws->visible) {
|
if (cur_ws->visible) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -338,7 +338,7 @@ void handle_button(xcb_button_press_event_t *event) {
|
|||||||
/* First calculate width of tray area */
|
/* First calculate width of tray area */
|
||||||
trayclient *trayclient;
|
trayclient *trayclient;
|
||||||
int tray_width = 0;
|
int tray_width = 0;
|
||||||
TAILQ_FOREACH_REVERSE (trayclient, walk->trayclients, tc_head, tailq) {
|
TAILQ_FOREACH_REVERSE(trayclient, walk->trayclients, tc_head, tailq) {
|
||||||
if (!trayclient->mapped)
|
if (!trayclient->mapped)
|
||||||
continue;
|
continue;
|
||||||
tray_width += (font.height + logical_px(2));
|
tray_width += (font.height + logical_px(2));
|
||||||
@ -351,7 +351,7 @@ void handle_button(xcb_button_press_event_t *event) {
|
|||||||
if (x >= 0) {
|
if (x >= 0) {
|
||||||
struct status_block *block;
|
struct status_block *block;
|
||||||
|
|
||||||
TAILQ_FOREACH (block, &statusline_head, blocks) {
|
TAILQ_FOREACH(block, &statusline_head, blocks) {
|
||||||
last_block_x = block_x;
|
last_block_x = block_x;
|
||||||
block_x += block->width + block->x_offset + block->x_append;
|
block_x += block->width + block->x_offset + block->x_append;
|
||||||
|
|
||||||
@ -387,7 +387,7 @@ void handle_button(xcb_button_press_event_t *event) {
|
|||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
/* Check if this event regards a workspace button */
|
/* Check if this event regards a workspace button */
|
||||||
TAILQ_FOREACH (cur_ws, walk->workspaces, tailq) {
|
TAILQ_FOREACH(cur_ws, walk->workspaces, tailq) {
|
||||||
DLOG("x = %d\n", x);
|
DLOG("x = %d\n", x);
|
||||||
if (x >= 0 && x < cur_ws->name_width + logical_px(10)) {
|
if (x >= 0 && x < cur_ws->name_width + logical_px(10)) {
|
||||||
break;
|
break;
|
||||||
@ -398,7 +398,7 @@ void handle_button(xcb_button_press_event_t *event) {
|
|||||||
/* Otherwise, focus our currently visible workspace if it is not
|
/* Otherwise, focus our currently visible workspace if it is not
|
||||||
* already focused */
|
* already focused */
|
||||||
if (cur_ws == NULL) {
|
if (cur_ws == NULL) {
|
||||||
TAILQ_FOREACH (cur_ws, walk->workspaces, tailq) {
|
TAILQ_FOREACH(cur_ws, walk->workspaces, tailq) {
|
||||||
if (cur_ws->visible && !cur_ws->focused)
|
if (cur_ws->visible && !cur_ws->focused)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -455,12 +455,12 @@ void handle_button(xcb_button_press_event_t *event) {
|
|||||||
static void configure_trayclients(void) {
|
static void configure_trayclients(void) {
|
||||||
trayclient *trayclient;
|
trayclient *trayclient;
|
||||||
i3_output *output;
|
i3_output *output;
|
||||||
SLIST_FOREACH (output, outputs, slist) {
|
SLIST_FOREACH(output, outputs, slist) {
|
||||||
if (!output->active)
|
if (!output->active)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
int clients = 0;
|
int clients = 0;
|
||||||
TAILQ_FOREACH_REVERSE (trayclient, output->trayclients, tc_head, tailq) {
|
TAILQ_FOREACH_REVERSE(trayclient, output->trayclients, tc_head, tailq) {
|
||||||
if (!trayclient->mapped)
|
if (!trayclient->mapped)
|
||||||
continue;
|
continue;
|
||||||
clients++;
|
clients++;
|
||||||
@ -544,7 +544,7 @@ static void handle_client_message(xcb_client_message_event_t *event) {
|
|||||||
|
|
||||||
DLOG("X window %08x requested docking\n", client);
|
DLOG("X window %08x requested docking\n", client);
|
||||||
i3_output *walk, *output = NULL;
|
i3_output *walk, *output = NULL;
|
||||||
SLIST_FOREACH (walk, outputs, slist) {
|
SLIST_FOREACH(walk, outputs, slist) {
|
||||||
if (!walk->active)
|
if (!walk->active)
|
||||||
continue;
|
continue;
|
||||||
if (config.tray_output) {
|
if (config.tray_output) {
|
||||||
@ -562,7 +562,7 @@ static void handle_client_message(xcb_client_message_event_t *event) {
|
|||||||
if (output == NULL &&
|
if (output == NULL &&
|
||||||
config.tray_output &&
|
config.tray_output &&
|
||||||
strcasecmp("primary", config.tray_output) == 0) {
|
strcasecmp("primary", config.tray_output) == 0) {
|
||||||
SLIST_FOREACH (walk, outputs, slist) {
|
SLIST_FOREACH(walk, outputs, slist) {
|
||||||
if (!walk->active)
|
if (!walk->active)
|
||||||
continue;
|
continue;
|
||||||
DLOG("Falling back to output %s because no primary output is configured\n", walk->name);
|
DLOG("Falling back to output %s because no primary output is configured\n", walk->name);
|
||||||
@ -650,12 +650,12 @@ static void handle_destroy_notify(xcb_destroy_notify_event_t *event) {
|
|||||||
DLOG("DestroyNotify for window = %08x, event = %08x\n", event->window, event->event);
|
DLOG("DestroyNotify for window = %08x, event = %08x\n", event->window, event->event);
|
||||||
|
|
||||||
i3_output *walk;
|
i3_output *walk;
|
||||||
SLIST_FOREACH (walk, outputs, slist) {
|
SLIST_FOREACH(walk, outputs, slist) {
|
||||||
if (!walk->active)
|
if (!walk->active)
|
||||||
continue;
|
continue;
|
||||||
DLOG("checking output %s\n", walk->name);
|
DLOG("checking output %s\n", walk->name);
|
||||||
trayclient *trayclient;
|
trayclient *trayclient;
|
||||||
TAILQ_FOREACH (trayclient, walk->trayclients, tailq) {
|
TAILQ_FOREACH(trayclient, walk->trayclients, tailq) {
|
||||||
if (trayclient->win != event->window)
|
if (trayclient->win != event->window)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -679,12 +679,12 @@ static void handle_map_notify(xcb_map_notify_event_t *event) {
|
|||||||
DLOG("MapNotify for window = %08x, event = %08x\n", event->window, event->event);
|
DLOG("MapNotify for window = %08x, event = %08x\n", event->window, event->event);
|
||||||
|
|
||||||
i3_output *walk;
|
i3_output *walk;
|
||||||
SLIST_FOREACH (walk, outputs, slist) {
|
SLIST_FOREACH(walk, outputs, slist) {
|
||||||
if (!walk->active)
|
if (!walk->active)
|
||||||
continue;
|
continue;
|
||||||
DLOG("checking output %s\n", walk->name);
|
DLOG("checking output %s\n", walk->name);
|
||||||
trayclient *trayclient;
|
trayclient *trayclient;
|
||||||
TAILQ_FOREACH (trayclient, walk->trayclients, tailq) {
|
TAILQ_FOREACH(trayclient, walk->trayclients, tailq) {
|
||||||
if (trayclient->win != event->window)
|
if (trayclient->win != event->window)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -707,12 +707,12 @@ static void handle_unmap_notify(xcb_unmap_notify_event_t *event) {
|
|||||||
DLOG("UnmapNotify for window = %08x, event = %08x\n", event->window, event->event);
|
DLOG("UnmapNotify for window = %08x, event = %08x\n", event->window, event->event);
|
||||||
|
|
||||||
i3_output *walk;
|
i3_output *walk;
|
||||||
SLIST_FOREACH (walk, outputs, slist) {
|
SLIST_FOREACH(walk, outputs, slist) {
|
||||||
if (!walk->active)
|
if (!walk->active)
|
||||||
continue;
|
continue;
|
||||||
DLOG("checking output %s\n", walk->name);
|
DLOG("checking output %s\n", walk->name);
|
||||||
trayclient *trayclient;
|
trayclient *trayclient;
|
||||||
TAILQ_FOREACH (trayclient, walk->trayclients, tailq) {
|
TAILQ_FOREACH(trayclient, walk->trayclients, tailq) {
|
||||||
if (trayclient->win != event->window)
|
if (trayclient->win != event->window)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -739,11 +739,11 @@ static void handle_property_notify(xcb_property_notify_event_t *event) {
|
|||||||
DLOG("xembed_info updated\n");
|
DLOG("xembed_info updated\n");
|
||||||
trayclient *trayclient = NULL, *walk;
|
trayclient *trayclient = NULL, *walk;
|
||||||
i3_output *o_walk;
|
i3_output *o_walk;
|
||||||
SLIST_FOREACH (o_walk, outputs, slist) {
|
SLIST_FOREACH(o_walk, outputs, slist) {
|
||||||
if (!o_walk->active)
|
if (!o_walk->active)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
TAILQ_FOREACH (walk, o_walk->trayclients, tailq) {
|
TAILQ_FOREACH(walk, o_walk->trayclients, tailq) {
|
||||||
if (walk->win != event->window)
|
if (walk->win != event->window)
|
||||||
continue;
|
continue;
|
||||||
trayclient = walk;
|
trayclient = walk;
|
||||||
@ -802,12 +802,12 @@ static void handle_configure_request(xcb_configure_request_event_t *event) {
|
|||||||
|
|
||||||
trayclient *trayclient;
|
trayclient *trayclient;
|
||||||
i3_output *output;
|
i3_output *output;
|
||||||
SLIST_FOREACH (output, outputs, slist) {
|
SLIST_FOREACH(output, outputs, slist) {
|
||||||
if (!output->active)
|
if (!output->active)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
int clients = 0;
|
int clients = 0;
|
||||||
TAILQ_FOREACH_REVERSE (trayclient, output->trayclients, tc_head, tailq) {
|
TAILQ_FOREACH_REVERSE(trayclient, output->trayclients, tc_head, tailq) {
|
||||||
if (!trayclient->mapped)
|
if (!trayclient->mapped)
|
||||||
continue;
|
continue;
|
||||||
clients++;
|
clients++;
|
||||||
@ -1280,7 +1280,7 @@ void init_tray_colors(void) {
|
|||||||
void clean_xcb(void) {
|
void clean_xcb(void) {
|
||||||
i3_output *o_walk;
|
i3_output *o_walk;
|
||||||
free_workspaces();
|
free_workspaces();
|
||||||
SLIST_FOREACH (o_walk, outputs, slist) {
|
SLIST_FOREACH(o_walk, outputs, slist) {
|
||||||
destroy_window(o_walk);
|
destroy_window(o_walk);
|
||||||
FREE(o_walk->trayclients);
|
FREE(o_walk->trayclients);
|
||||||
FREE(o_walk->workspaces);
|
FREE(o_walk->workspaces);
|
||||||
@ -1434,7 +1434,7 @@ void reconfig_windows(bool redraw_bars) {
|
|||||||
static bool tray_configured = false;
|
static bool tray_configured = false;
|
||||||
|
|
||||||
i3_output *walk;
|
i3_output *walk;
|
||||||
SLIST_FOREACH (walk, outputs, slist) {
|
SLIST_FOREACH(walk, outputs, slist) {
|
||||||
if (!walk->active) {
|
if (!walk->active) {
|
||||||
/* If an output is not active, we destroy its bar */
|
/* If an output is not active, we destroy its bar */
|
||||||
/* FIXME: Maybe we rather want to unmap? */
|
/* FIXME: Maybe we rather want to unmap? */
|
||||||
@ -1596,7 +1596,7 @@ void reconfig_windows(bool redraw_bars) {
|
|||||||
* VGA-1 but output == [HDMI-1]).
|
* VGA-1 but output == [HDMI-1]).
|
||||||
*/
|
*/
|
||||||
i3_output *output;
|
i3_output *output;
|
||||||
SLIST_FOREACH (output, outputs, slist) {
|
SLIST_FOREACH(output, outputs, slist) {
|
||||||
if (strcasecmp(output->name, tray_output) == 0 ||
|
if (strcasecmp(output->name, tray_output) == 0 ||
|
||||||
(strcasecmp(tray_output, "primary") == 0 && output->primary)) {
|
(strcasecmp(tray_output, "primary") == 0 && output->primary)) {
|
||||||
init_tray();
|
init_tray();
|
||||||
@ -1685,7 +1685,7 @@ void draw_bars(bool unhide) {
|
|||||||
refresh_statusline();
|
refresh_statusline();
|
||||||
|
|
||||||
i3_output *outputs_walk;
|
i3_output *outputs_walk;
|
||||||
SLIST_FOREACH (outputs_walk, outputs, slist) {
|
SLIST_FOREACH(outputs_walk, outputs, slist) {
|
||||||
if (!outputs_walk->active) {
|
if (!outputs_walk->active) {
|
||||||
DLOG("Output %s inactive, skipping...\n", outputs_walk->name);
|
DLOG("Output %s inactive, skipping...\n", outputs_walk->name);
|
||||||
continue;
|
continue;
|
||||||
@ -1715,7 +1715,7 @@ void draw_bars(bool unhide) {
|
|||||||
* position */
|
* position */
|
||||||
trayclient *trayclient;
|
trayclient *trayclient;
|
||||||
int traypx = 0;
|
int traypx = 0;
|
||||||
TAILQ_FOREACH (trayclient, outputs_walk->trayclients, tailq) {
|
TAILQ_FOREACH(trayclient, outputs_walk->trayclients, tailq) {
|
||||||
if (!trayclient->mapped)
|
if (!trayclient->mapped)
|
||||||
continue;
|
continue;
|
||||||
/* We assume the tray icons are quadratic (we use the font
|
/* We assume the tray icons are quadratic (we use the font
|
||||||
@ -1737,7 +1737,7 @@ void draw_bars(bool unhide) {
|
|||||||
|
|
||||||
if (!config.disable_ws) {
|
if (!config.disable_ws) {
|
||||||
i3_ws *ws_walk;
|
i3_ws *ws_walk;
|
||||||
TAILQ_FOREACH (ws_walk, outputs_walk->workspaces, tailq) {
|
TAILQ_FOREACH(ws_walk, outputs_walk->workspaces, tailq) {
|
||||||
DLOG("Drawing Button for WS %s at x = %d, len = %d\n",
|
DLOG("Drawing Button for WS %s at x = %d, len = %d\n",
|
||||||
i3string_as_utf8(ws_walk->name), i, ws_walk->name_width);
|
i3string_as_utf8(ws_walk->name), i, ws_walk->name_width);
|
||||||
uint32_t fg_color = colors.inactive_ws_fg;
|
uint32_t fg_color = colors.inactive_ws_fg;
|
||||||
@ -1853,7 +1853,7 @@ void draw_bars(bool unhide) {
|
|||||||
*/
|
*/
|
||||||
void redraw_bars(void) {
|
void redraw_bars(void) {
|
||||||
i3_output *outputs_walk;
|
i3_output *outputs_walk;
|
||||||
SLIST_FOREACH (outputs_walk, outputs, slist) {
|
SLIST_FOREACH(outputs_walk, outputs, slist) {
|
||||||
if (!outputs_walk->active) {
|
if (!outputs_walk->active) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ const char *DEFAULT_BINDING_MODE;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
Binding *configure_binding(const char *bindtype, const char *modifiers, const char *input_code,
|
Binding *configure_binding(const char *bindtype, const char *modifiers, const char *input_code,
|
||||||
const char *release, const char *command, const char *mode);
|
const char *release, const char *command, const char *mode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Grab the bound keys (tell X to send us keypress events for those keycodes)
|
* Grab the bound keys (tell X to send us keypress events for those keycodes)
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
*/
|
*/
|
||||||
Con *con_new_skeleton(Con *parent, i3Window *window);
|
Con *con_new_skeleton(Con *parent, i3Window *window);
|
||||||
|
|
||||||
|
|
||||||
/* A wrapper for con_new_skeleton, to retain the old con_new behaviour
|
/* A wrapper for con_new_skeleton, to retain the old con_new behaviour
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -241,10 +241,13 @@ struct Barconfig {
|
|||||||
char *socket_path;
|
char *socket_path;
|
||||||
|
|
||||||
/** Bar display mode (hide unless modifier is pressed or show in dock mode or always hide in invisible mode) */
|
/** Bar display mode (hide unless modifier is pressed or show in dock mode or always hide in invisible mode) */
|
||||||
enum { M_DOCK = 0, M_HIDE = 1, M_INVISIBLE = 2 } mode;
|
enum { M_DOCK = 0,
|
||||||
|
M_HIDE = 1,
|
||||||
|
M_INVISIBLE = 2 } mode;
|
||||||
|
|
||||||
/* The current hidden_state of the bar, which indicates whether it is hidden or shown */
|
/* The current hidden_state of the bar, which indicates whether it is hidden or shown */
|
||||||
enum { S_HIDE = 0, S_SHOW = 1 } hidden_state;
|
enum { S_HIDE = 0,
|
||||||
|
S_SHOW = 1 } hidden_state;
|
||||||
|
|
||||||
/** Bar modifier (to show bar when in hide mode). */
|
/** Bar modifier (to show bar when in hide mode). */
|
||||||
enum {
|
enum {
|
||||||
@ -259,7 +262,8 @@ struct Barconfig {
|
|||||||
} modifier;
|
} modifier;
|
||||||
|
|
||||||
/** Bar position (bottom by default). */
|
/** Bar position (bottom by default). */
|
||||||
enum { P_BOTTOM = 0, P_TOP = 1 } position;
|
enum { P_BOTTOM = 0,
|
||||||
|
P_TOP = 1 } position;
|
||||||
|
|
||||||
/** Command that should be run to execute i3bar, give a full path if i3bar is not
|
/** Command that should be run to execute i3bar, give a full path if i3bar is not
|
||||||
* in your $PATH.
|
* in your $PATH.
|
||||||
|
@ -24,7 +24,7 @@ uint32_t modifiers_from_str(const char *str);
|
|||||||
* using 'call cfg_foo()' in parser-specs/.*.spec. Useful so that we don’t need
|
* using 'call cfg_foo()' in parser-specs/.*.spec. Useful so that we don’t need
|
||||||
* to repeat the definition all the time. */
|
* to repeat the definition all the time. */
|
||||||
#define CFGFUN(name, ...) \
|
#define CFGFUN(name, ...) \
|
||||||
void cfg_ ## name (I3_CFG, ## __VA_ARGS__ )
|
void cfg_##name(I3_CFG, ##__VA_ARGS__)
|
||||||
|
|
||||||
/* The following functions are called by the config parser, see
|
/* The following functions are called by the config parser, see
|
||||||
* parser-specs/config.spec. They get the parsed parameters and store them in
|
* parser-specs/config.spec. They get the parsed parameters and store them in
|
||||||
|
@ -47,34 +47,42 @@ typedef struct Match Match;
|
|||||||
typedef struct Assignment Assignment;
|
typedef struct Assignment Assignment;
|
||||||
typedef struct Window i3Window;
|
typedef struct Window i3Window;
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Helper types
|
* Helper types
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
typedef enum { D_LEFT, D_RIGHT, D_UP, D_DOWN } direction_t;
|
typedef enum { D_LEFT,
|
||||||
typedef enum { NO_ORIENTATION = 0, HORIZ, VERT } orientation_t;
|
D_RIGHT,
|
||||||
typedef enum { BS_NORMAL = 0, BS_NONE = 1, BS_PIXEL = 2 } border_style_t;
|
D_UP,
|
||||||
|
D_DOWN } direction_t;
|
||||||
|
typedef enum { NO_ORIENTATION = 0,
|
||||||
|
HORIZ,
|
||||||
|
VERT } orientation_t;
|
||||||
|
typedef enum { BS_NORMAL = 0,
|
||||||
|
BS_NONE = 1,
|
||||||
|
BS_PIXEL = 2 } border_style_t;
|
||||||
|
|
||||||
/** parameter to specify whether tree_close() and x_window_kill() should kill
|
/** parameter to specify whether tree_close() and x_window_kill() should kill
|
||||||
* only this specific window or the whole X11 client */
|
* only this specific window or the whole X11 client */
|
||||||
typedef enum { DONT_KILL_WINDOW = 0, KILL_WINDOW = 1, KILL_CLIENT = 2 } kill_window_t;
|
typedef enum { DONT_KILL_WINDOW = 0,
|
||||||
|
KILL_WINDOW = 1,
|
||||||
|
KILL_CLIENT = 2 } kill_window_t;
|
||||||
|
|
||||||
/** describes if the window is adjacent to the output (physical screen) edges. */
|
/** describes if the window is adjacent to the output (physical screen) edges. */
|
||||||
typedef enum { ADJ_NONE = 0,
|
typedef enum { ADJ_NONE = 0,
|
||||||
ADJ_LEFT_SCREEN_EDGE = (1 << 0),
|
ADJ_LEFT_SCREEN_EDGE = (1 << 0),
|
||||||
ADJ_RIGHT_SCREEN_EDGE = (1 << 1),
|
ADJ_RIGHT_SCREEN_EDGE = (1 << 1),
|
||||||
ADJ_UPPER_SCREEN_EDGE = (1 << 2),
|
ADJ_UPPER_SCREEN_EDGE = (1 << 2),
|
||||||
ADJ_LOWER_SCREEN_EDGE = (1 << 4)} adjacent_t;
|
ADJ_LOWER_SCREEN_EDGE = (1 << 4) } adjacent_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)
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -267,7 +275,6 @@ struct Binding {
|
|||||||
* 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;
|
||||||
|
|
||||||
|
|
||||||
/** Command, like in command mode */
|
/** Command, like in command mode */
|
||||||
char *command;
|
char *command;
|
||||||
|
|
||||||
@ -367,7 +374,9 @@ struct Window {
|
|||||||
bool doesnt_accept_focus;
|
bool doesnt_accept_focus;
|
||||||
|
|
||||||
/** Whether the window says it is a dock window */
|
/** Whether the window says it is a dock window */
|
||||||
enum { W_NODOCK = 0, W_DOCK_TOP = 1, W_DOCK_BOTTOM = 2 } dock;
|
enum { W_NODOCK = 0,
|
||||||
|
W_DOCK_TOP = 1,
|
||||||
|
W_DOCK_BOTTOM = 2 } dock;
|
||||||
|
|
||||||
/** When this window was marked urgent. 0 means not urgent */
|
/** When this window was marked urgent. 0 means not urgent */
|
||||||
struct timeval urgent;
|
struct timeval urgent;
|
||||||
@ -407,7 +416,9 @@ struct Match {
|
|||||||
M_DOCK_BOTTOM = 3
|
M_DOCK_BOTTOM = 3
|
||||||
} dock;
|
} dock;
|
||||||
xcb_window_t id;
|
xcb_window_t id;
|
||||||
enum { M_ANY = 0, M_TILING, M_FLOATING } floating;
|
enum { M_ANY = 0,
|
||||||
|
M_TILING,
|
||||||
|
M_FLOATING } floating;
|
||||||
Con *con_id;
|
Con *con_id;
|
||||||
|
|
||||||
/* Where the window looking for a match should be inserted:
|
/* Where the window looking for a match should be inserted:
|
||||||
@ -419,7 +430,9 @@ struct Match {
|
|||||||
* (dockareas)
|
* (dockareas)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
enum { M_HERE = 0, M_ASSIGN_WS, M_BELOW } insert_where;
|
enum { M_HERE = 0,
|
||||||
|
M_ASSIGN_WS,
|
||||||
|
M_BELOW } insert_where;
|
||||||
|
|
||||||
TAILQ_ENTRY(Match) matches;
|
TAILQ_ENTRY(Match) matches;
|
||||||
|
|
||||||
@ -450,10 +463,10 @@ struct Assignment {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
enum {
|
enum {
|
||||||
A_ANY = 0,
|
A_ANY = 0,
|
||||||
A_COMMAND = (1 << 0),
|
A_COMMAND = (1 << 0),
|
||||||
A_TO_WORKSPACE = (1 << 1),
|
A_TO_WORKSPACE = (1 << 1),
|
||||||
A_TO_OUTPUT = (1 << 2)
|
A_TO_OUTPUT = (1 << 2)
|
||||||
} type;
|
} type;
|
||||||
|
|
||||||
/** the criteria to check if a window matches */
|
/** the criteria to check if a window matches */
|
||||||
@ -470,7 +483,9 @@ struct Assignment {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/** Fullscreen modes. Used by Con.fullscreen_mode. */
|
/** Fullscreen modes. Used by Con.fullscreen_mode. */
|
||||||
typedef enum { CF_NONE = 0, CF_OUTPUT = 1, CF_GLOBAL = 2 } fullscreen_mode_t;
|
typedef enum { CF_NONE = 0,
|
||||||
|
CF_OUTPUT = 1,
|
||||||
|
CF_GLOBAL = 2 } fullscreen_mode_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A 'Con' represents everything from the X11 root window down to a single X11 window.
|
* A 'Con' represents everything from the X11 root window down to a single X11 window.
|
||||||
@ -596,7 +611,7 @@ struct Con {
|
|||||||
TAILQ_ENTRY(Con) floating_windows;
|
TAILQ_ENTRY(Con) floating_windows;
|
||||||
|
|
||||||
/** callbacks */
|
/** callbacks */
|
||||||
void(*on_remove_child)(Con *);
|
void (*on_remove_child)(Con *);
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
/* Not a scratchpad window. */
|
/* Not a scratchpad window. */
|
||||||
|
@ -12,18 +12,18 @@
|
|||||||
#include "tree.h"
|
#include "tree.h"
|
||||||
|
|
||||||
/** Callback for dragging */
|
/** Callback for dragging */
|
||||||
typedef void(*callback_t)(Con*, Rect*, uint32_t, uint32_t, const void*);
|
typedef void (*callback_t)(Con *, Rect *, uint32_t, uint32_t, const void *);
|
||||||
|
|
||||||
/** Macro to create a callback function for dragging */
|
/** Macro to create a callback function for dragging */
|
||||||
#define DRAGGING_CB(name) \
|
#define DRAGGING_CB(name) \
|
||||||
static void name(Con *con, Rect *old_rect, uint32_t new_x, \
|
static void name(Con *con, Rect *old_rect, uint32_t new_x, \
|
||||||
uint32_t new_y, const void *extra)
|
uint32_t new_y, const void *extra)
|
||||||
|
|
||||||
/** On which border was the dragging initiated? */
|
/** On which border was the dragging initiated? */
|
||||||
typedef enum { BORDER_LEFT = (1 << 0),
|
typedef enum { BORDER_LEFT = (1 << 0),
|
||||||
BORDER_RIGHT = (1 << 1),
|
BORDER_RIGHT = (1 << 1),
|
||||||
BORDER_TOP = (1 << 2),
|
BORDER_TOP = (1 << 2),
|
||||||
BORDER_BOTTOM = (1 << 3)} border_t;
|
BORDER_BOTTOM = (1 << 3) } border_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enables floating mode for the given container by detaching it from its
|
* Enables floating mode for the given container by detaching it from its
|
||||||
@ -164,8 +164,8 @@ typedef enum {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
drag_result_t drag_pointer(Con *con, const xcb_button_press_event_t *event,
|
drag_result_t drag_pointer(Con *con, const xcb_button_press_event_t *event,
|
||||||
xcb_window_t confine_to, border_t border, int cursor,
|
xcb_window_t confine_to, border_t border, int cursor,
|
||||||
callback_t callback, const void *extra);
|
callback_t callback, const void *extra);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Repositions the CT_FLOATING_CON to have the coordinates specified by
|
* Repositions the CT_FLOATING_CON to have the coordinates specified by
|
||||||
|
@ -42,7 +42,7 @@ extern xcb_key_symbols_t *keysyms;
|
|||||||
extern char **start_argv;
|
extern char **start_argv;
|
||||||
extern Display *xlibdpy, *xkbdpy;
|
extern Display *xlibdpy, *xkbdpy;
|
||||||
extern int xkb_current_group;
|
extern int xkb_current_group;
|
||||||
extern TAILQ_HEAD(bindings_head, Binding) *bindings;
|
extern TAILQ_HEAD(bindings_head, Binding) * bindings;
|
||||||
extern TAILQ_HEAD(autostarts_head, Autostart) autostarts;
|
extern TAILQ_HEAD(autostarts_head, Autostart) autostarts;
|
||||||
extern TAILQ_HEAD(autostarts_always_head, Autostart) autostarts_always;
|
extern TAILQ_HEAD(autostarts_always_head, Autostart) autostarts_always;
|
||||||
extern TAILQ_HEAD(ws_assignments_head, Workspace_Assignment) ws_assignments;
|
extern TAILQ_HEAD(ws_assignments_head, Workspace_Assignment) ws_assignments;
|
||||||
|
@ -17,7 +17,7 @@ typedef struct i3_ipc_header {
|
|||||||
char magic[6];
|
char magic[6];
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
uint32_t type;
|
uint32_t type;
|
||||||
} __attribute__ ((packed)) i3_ipc_header_t;
|
} __attribute__((packed)) i3_ipc_header_t;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Messages from clients to i3
|
* Messages from clients to i3
|
||||||
@ -25,31 +25,31 @@ typedef struct i3_ipc_header {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/** Never change this, only on major IPC breakage (don’t do that) */
|
/** Never change this, only on major IPC breakage (don’t do that) */
|
||||||
#define I3_IPC_MAGIC "i3-ipc"
|
#define I3_IPC_MAGIC "i3-ipc"
|
||||||
|
|
||||||
/** The payload of the message will be interpreted as a command */
|
/** The payload of the message will be interpreted as a command */
|
||||||
#define I3_IPC_MESSAGE_TYPE_COMMAND 0
|
#define I3_IPC_MESSAGE_TYPE_COMMAND 0
|
||||||
|
|
||||||
/** Requests the current workspaces from i3 */
|
/** Requests the current workspaces from i3 */
|
||||||
#define I3_IPC_MESSAGE_TYPE_GET_WORKSPACES 1
|
#define I3_IPC_MESSAGE_TYPE_GET_WORKSPACES 1
|
||||||
|
|
||||||
/** Subscribe to the specified events */
|
/** Subscribe to the specified events */
|
||||||
#define I3_IPC_MESSAGE_TYPE_SUBSCRIBE 2
|
#define I3_IPC_MESSAGE_TYPE_SUBSCRIBE 2
|
||||||
|
|
||||||
/** Requests the current outputs from i3 */
|
/** Requests the current outputs from i3 */
|
||||||
#define I3_IPC_MESSAGE_TYPE_GET_OUTPUTS 3
|
#define I3_IPC_MESSAGE_TYPE_GET_OUTPUTS 3
|
||||||
|
|
||||||
/** Requests the tree layout from i3 */
|
/** Requests the tree layout from i3 */
|
||||||
#define I3_IPC_MESSAGE_TYPE_GET_TREE 4
|
#define I3_IPC_MESSAGE_TYPE_GET_TREE 4
|
||||||
|
|
||||||
/** Request the current defined marks from i3 */
|
/** Request the current defined marks from i3 */
|
||||||
#define I3_IPC_MESSAGE_TYPE_GET_MARKS 5
|
#define I3_IPC_MESSAGE_TYPE_GET_MARKS 5
|
||||||
|
|
||||||
/** Request the configuration for a specific 'bar' */
|
/** Request the configuration for a specific 'bar' */
|
||||||
#define I3_IPC_MESSAGE_TYPE_GET_BAR_CONFIG 6
|
#define I3_IPC_MESSAGE_TYPE_GET_BAR_CONFIG 6
|
||||||
|
|
||||||
/** Request the i3 version */
|
/** Request the i3 version */
|
||||||
#define I3_IPC_MESSAGE_TYPE_GET_VERSION 7
|
#define I3_IPC_MESSAGE_TYPE_GET_VERSION 7
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Messages from i3 to clients
|
* Messages from i3 to clients
|
||||||
@ -57,46 +57,46 @@ typedef struct i3_ipc_header {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/** Command reply type */
|
/** Command reply type */
|
||||||
#define I3_IPC_REPLY_TYPE_COMMAND 0
|
#define I3_IPC_REPLY_TYPE_COMMAND 0
|
||||||
|
|
||||||
/** Workspaces reply type */
|
/** Workspaces reply type */
|
||||||
#define I3_IPC_REPLY_TYPE_WORKSPACES 1
|
#define I3_IPC_REPLY_TYPE_WORKSPACES 1
|
||||||
|
|
||||||
/** Subscription reply type */
|
/** Subscription reply type */
|
||||||
#define I3_IPC_REPLY_TYPE_SUBSCRIBE 2
|
#define I3_IPC_REPLY_TYPE_SUBSCRIBE 2
|
||||||
|
|
||||||
/** Outputs reply type */
|
/** Outputs reply type */
|
||||||
#define I3_IPC_REPLY_TYPE_OUTPUTS 3
|
#define I3_IPC_REPLY_TYPE_OUTPUTS 3
|
||||||
|
|
||||||
/** Tree reply type */
|
/** Tree reply type */
|
||||||
#define I3_IPC_REPLY_TYPE_TREE 4
|
#define I3_IPC_REPLY_TYPE_TREE 4
|
||||||
|
|
||||||
/** Marks reply type */
|
/** Marks reply type */
|
||||||
#define I3_IPC_REPLY_TYPE_MARKS 5
|
#define I3_IPC_REPLY_TYPE_MARKS 5
|
||||||
|
|
||||||
/** Bar config reply type */
|
/** Bar config reply type */
|
||||||
#define I3_IPC_REPLY_TYPE_BAR_CONFIG 6
|
#define I3_IPC_REPLY_TYPE_BAR_CONFIG 6
|
||||||
|
|
||||||
/** i3 version reply type */
|
/** i3 version reply type */
|
||||||
#define I3_IPC_REPLY_TYPE_VERSION 7
|
#define I3_IPC_REPLY_TYPE_VERSION 7
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Events from i3 to clients. Events have the first bit set high.
|
* Events from i3 to clients. Events have the first bit set high.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#define I3_IPC_EVENT_MASK (1 << 31)
|
#define I3_IPC_EVENT_MASK (1 << 31)
|
||||||
|
|
||||||
/* The workspace event will be triggered upon changes in the workspace list */
|
/* The workspace event will be triggered upon changes in the workspace list */
|
||||||
#define I3_IPC_EVENT_WORKSPACE (I3_IPC_EVENT_MASK | 0)
|
#define I3_IPC_EVENT_WORKSPACE (I3_IPC_EVENT_MASK | 0)
|
||||||
|
|
||||||
/* The output event will be triggered upon changes in the output list */
|
/* The output event will be triggered upon changes in the output list */
|
||||||
#define I3_IPC_EVENT_OUTPUT (I3_IPC_EVENT_MASK | 1)
|
#define I3_IPC_EVENT_OUTPUT (I3_IPC_EVENT_MASK | 1)
|
||||||
|
|
||||||
/* The output event will be triggered upon mode changes */
|
/* The output event will be triggered upon mode changes */
|
||||||
#define I3_IPC_EVENT_MODE (I3_IPC_EVENT_MASK | 2)
|
#define I3_IPC_EVENT_MODE (I3_IPC_EVENT_MASK | 2)
|
||||||
|
|
||||||
/* The window event will be triggered upon window changes */
|
/* The window event will be triggered upon window changes */
|
||||||
#define I3_IPC_EVENT_WINDOW (I3_IPC_EVENT_MASK | 3)
|
#define I3_IPC_EVENT_WINDOW (I3_IPC_EVENT_MASK | 3)
|
||||||
|
|
||||||
/** Bar config update will be triggered to update the bar config */
|
/** Bar config update will be triggered to update the bar config */
|
||||||
#define I3_IPC_EVENT_BARCONFIG_UPDATE (I3_IPC_EVENT_MASK | 4)
|
#define I3_IPC_EVENT_BARCONFIG_UPDATE (I3_IPC_EVENT_MASK | 4)
|
||||||
|
@ -23,13 +23,13 @@
|
|||||||
extern char *current_socketpath;
|
extern char *current_socketpath;
|
||||||
|
|
||||||
typedef struct ipc_client {
|
typedef struct ipc_client {
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
/* The events which this client wants to receive */
|
/* The events which this client wants to receive */
|
||||||
int num_events;
|
int num_events;
|
||||||
char **events;
|
char **events;
|
||||||
|
|
||||||
TAILQ_ENTRY(ipc_client) clients;
|
TAILQ_ENTRY(ipc_client) clients;
|
||||||
} ipc_client;
|
} ipc_client;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -42,13 +42,13 @@ typedef struct ipc_client {
|
|||||||
* message_type is the type of the message as the sender specified it.
|
* message_type is the type of the message as the sender specified it.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
typedef void(*handler_t)(int, uint8_t*, int, uint32_t, uint32_t);
|
typedef void (*handler_t)(int, uint8_t *, int, uint32_t, uint32_t);
|
||||||
|
|
||||||
/* Macro to declare a callback */
|
/* Macro to declare a callback */
|
||||||
#define IPC_HANDLER(name) \
|
#define IPC_HANDLER(name) \
|
||||||
static void handle_ ## name (int fd, uint8_t *message, \
|
static void handle_##name(int fd, uint8_t *message, \
|
||||||
int size, uint32_t message_size, \
|
int size, uint32_t message_size, \
|
||||||
uint32_t message_type)
|
uint32_t message_type)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler for activity on the listening socket, meaning that a new client
|
* Handler for activity on the listening socket, meaning that a new client
|
||||||
|
@ -72,17 +72,17 @@ struct Font {
|
|||||||
* infrastructure, we define a fallback. */
|
* infrastructure, we define a fallback. */
|
||||||
#if !defined(LOG)
|
#if !defined(LOG)
|
||||||
void verboselog(char *fmt, ...)
|
void verboselog(char *fmt, ...)
|
||||||
__attribute__ ((format (printf, 1, 2)));
|
__attribute__((format(printf, 1, 2)));
|
||||||
#define LOG(fmt, ...) verboselog("[libi3] " __FILE__ " " fmt, ##__VA_ARGS__)
|
#define LOG(fmt, ...) verboselog("[libi3] " __FILE__ " " fmt, ##__VA_ARGS__)
|
||||||
#endif
|
#endif
|
||||||
#if !defined(ELOG)
|
#if !defined(ELOG)
|
||||||
void errorlog(char *fmt, ...)
|
void errorlog(char *fmt, ...)
|
||||||
__attribute__ ((format (printf, 1, 2)));
|
__attribute__((format(printf, 1, 2)));
|
||||||
#define ELOG(fmt, ...) errorlog("[libi3] ERROR: " fmt, ##__VA_ARGS__)
|
#define ELOG(fmt, ...) errorlog("[libi3] ERROR: " fmt, ##__VA_ARGS__)
|
||||||
#endif
|
#endif
|
||||||
#if !defined(DLOG)
|
#if !defined(DLOG)
|
||||||
void debuglog(char *fmt, ...)
|
void debuglog(char *fmt, ...)
|
||||||
__attribute__ ((format (printf, 1, 2)));
|
__attribute__((format(printf, 1, 2)));
|
||||||
#define DLOG(fmt, ...) debuglog("%s:%s:%d - " fmt, I3__FILE__, __FUNCTION__, __LINE__, ##__VA_ARGS__)
|
#define DLOG(fmt, ...) debuglog("%s:%s:%d - " fmt, I3__FILE__, __FUNCTION__, __LINE__, ##__VA_ARGS__)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -167,13 +167,13 @@ void i3string_free(i3String *str);
|
|||||||
* to prevent accidentally using freed memory.
|
* to prevent accidentally using freed memory.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#define I3STRING_FREE(str) \
|
#define I3STRING_FREE(str) \
|
||||||
do { \
|
do { \
|
||||||
if (str != NULL) { \
|
if (str != NULL) { \
|
||||||
i3string_free(str); \
|
i3string_free(str); \
|
||||||
str = NULL; \
|
str = NULL; \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the UTF-8 encoded version of the i3String.
|
* Returns the UTF-8 encoded version of the i3String.
|
||||||
@ -285,8 +285,8 @@ uint32_t aio_get_mod_mask_for(uint32_t keysym, xcb_key_symbols_t *symbols);
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
uint32_t get_mod_mask_for(uint32_t keysym,
|
uint32_t get_mod_mask_for(uint32_t keysym,
|
||||||
xcb_key_symbols_t *symbols,
|
xcb_key_symbols_t *symbols,
|
||||||
xcb_get_modifier_mapping_reply_t *modmap_reply);
|
xcb_get_modifier_mapping_reply_t *modmap_reply);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads a font for usage, also getting its height. If fallback is true,
|
* Loads a font for usage, also getting its height. If fallback is true,
|
||||||
@ -338,14 +338,14 @@ void set_font_colors(xcb_gcontext_t gc, uint32_t foreground, uint32_t background
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void draw_text(i3String *text, xcb_drawable_t drawable,
|
void draw_text(i3String *text, xcb_drawable_t drawable,
|
||||||
xcb_gcontext_t gc, int x, int y, int max_width);
|
xcb_gcontext_t gc, int x, int y, int max_width);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ASCII version of draw_text to print static strings.
|
* ASCII version of draw_text to print static strings.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void draw_text_ascii(const char *text, xcb_drawable_t drawable,
|
void draw_text_ascii(const char *text, xcb_drawable_t drawable,
|
||||||
xcb_gcontext_t gc, int x, int y, int max_width);
|
xcb_gcontext_t gc, int x, int y, int max_width);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Predict the text width in pixels for the given text. Text must be
|
* Predict the text width in pixels for the given text. Text must be
|
||||||
|
@ -78,14 +78,14 @@ void set_verbosity(bool _verbose);
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void debuglog(char *fmt, ...)
|
void debuglog(char *fmt, ...)
|
||||||
__attribute__ ((format (printf, 1, 2)));
|
__attribute__((format(printf, 1, 2)));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs the given message to stdout while prefixing the current time to it.
|
* Logs the given message to stdout while prefixing the current time to it.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void errorlog(char *fmt, ...)
|
void errorlog(char *fmt, ...)
|
||||||
__attribute__ ((format (printf, 1, 2)));
|
__attribute__((format(printf, 1, 2)));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs the given message to stdout while prefixing the current time to it,
|
* Logs the given message to stdout while prefixing the current time to it,
|
||||||
@ -93,7 +93,7 @@ void errorlog(char *fmt, ...)
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void verboselog(char *fmt, ...)
|
void verboselog(char *fmt, ...)
|
||||||
__attribute__ ((format (printf, 1, 2)));
|
__attribute__((format(printf, 1, 2)));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes the unused log files. Useful if i3 exits immediately, eg.
|
* Deletes the unused log files. Useful if i3 exits immediately, eg.
|
||||||
|
704
include/queue.h
704
include/queue.h
@ -90,448 +90,468 @@
|
|||||||
/*
|
/*
|
||||||
* Singly-linked List definitions.
|
* Singly-linked List definitions.
|
||||||
*/
|
*/
|
||||||
#define SLIST_HEAD(name, type) \
|
#define SLIST_HEAD(name, type) \
|
||||||
struct name { \
|
struct name { \
|
||||||
struct type *slh_first; /* first element */ \
|
struct type *slh_first; /* first element */ \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SLIST_HEAD_INITIALIZER(head) \
|
#define SLIST_HEAD_INITIALIZER(head) \
|
||||||
{ NULL }
|
{ NULL }
|
||||||
|
|
||||||
#define SLIST_ENTRY(type) \
|
#define SLIST_ENTRY(type) \
|
||||||
struct { \
|
struct { \
|
||||||
struct type *sle_next; /* next element */ \
|
struct type *sle_next; /* next element */ \
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Singly-linked List access methods.
|
* Singly-linked List access methods.
|
||||||
*/
|
*/
|
||||||
#define SLIST_FIRST(head) ((head)->slh_first)
|
#define SLIST_FIRST(head) ((head)->slh_first)
|
||||||
#define SLIST_END(head) NULL
|
#define SLIST_END(head) NULL
|
||||||
#define SLIST_EMPTY(head) (SLIST_FIRST(head) == SLIST_END(head))
|
#define SLIST_EMPTY(head) (SLIST_FIRST(head) == SLIST_END(head))
|
||||||
#define SLIST_NEXT(elm, field) ((elm)->field.sle_next)
|
#define SLIST_NEXT(elm, field) ((elm)->field.sle_next)
|
||||||
|
|
||||||
#define SLIST_FOREACH(var, head, field) \
|
#define SLIST_FOREACH(var, head, field) \
|
||||||
for((var) = SLIST_FIRST(head); \
|
for ((var) = SLIST_FIRST(head); \
|
||||||
(var) != SLIST_END(head); \
|
(var) != SLIST_END(head); \
|
||||||
(var) = SLIST_NEXT(var, field))
|
(var) = SLIST_NEXT(var, field))
|
||||||
|
|
||||||
#define SLIST_FOREACH_PREVPTR(var, varp, head, field) \
|
#define SLIST_FOREACH_PREVPTR(var, varp, head, field) \
|
||||||
for ((varp) = &SLIST_FIRST((head)); \
|
for ((varp) = &SLIST_FIRST((head)); \
|
||||||
((var) = *(varp)) != SLIST_END(head); \
|
((var) = *(varp)) != SLIST_END(head); \
|
||||||
(varp) = &SLIST_NEXT((var), field))
|
(varp) = &SLIST_NEXT((var), field))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Singly-linked List functions.
|
* Singly-linked List functions.
|
||||||
*/
|
*/
|
||||||
#define SLIST_INIT(head) { \
|
#define SLIST_INIT(head) \
|
||||||
SLIST_FIRST(head) = SLIST_END(head); \
|
{ \
|
||||||
}
|
SLIST_FIRST(head) = SLIST_END(head); \
|
||||||
|
}
|
||||||
|
|
||||||
#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \
|
#define SLIST_INSERT_AFTER(slistelm, elm, field) \
|
||||||
(elm)->field.sle_next = (slistelm)->field.sle_next; \
|
do { \
|
||||||
(slistelm)->field.sle_next = (elm); \
|
(elm)->field.sle_next = (slistelm)->field.sle_next; \
|
||||||
} while (0)
|
(slistelm)->field.sle_next = (elm); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define SLIST_INSERT_HEAD(head, elm, field) do { \
|
#define SLIST_INSERT_HEAD(head, elm, field) \
|
||||||
(elm)->field.sle_next = (head)->slh_first; \
|
do { \
|
||||||
(head)->slh_first = (elm); \
|
(elm)->field.sle_next = (head)->slh_first; \
|
||||||
} while (0)
|
(head)->slh_first = (elm); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define SLIST_REMOVE_NEXT(head, elm, field) do { \
|
#define SLIST_REMOVE_NEXT(head, elm, field) \
|
||||||
(elm)->field.sle_next = (elm)->field.sle_next->field.sle_next; \
|
do { \
|
||||||
} while (0)
|
(elm)->field.sle_next = (elm)->field.sle_next->field.sle_next; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define SLIST_REMOVE_HEAD(head, field) do { \
|
#define SLIST_REMOVE_HEAD(head, field) \
|
||||||
(head)->slh_first = (head)->slh_first->field.sle_next; \
|
do { \
|
||||||
} while (0)
|
(head)->slh_first = (head)->slh_first->field.sle_next; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define SLIST_REMOVE(head, elm, type, field) do { \
|
#define SLIST_REMOVE(head, elm, type, field) \
|
||||||
if ((head)->slh_first == (elm)) { \
|
do { \
|
||||||
SLIST_REMOVE_HEAD((head), field); \
|
if ((head)->slh_first == (elm)) { \
|
||||||
} else { \
|
SLIST_REMOVE_HEAD((head), field); \
|
||||||
struct type *curelm = (head)->slh_first; \
|
} else { \
|
||||||
\
|
struct type *curelm = (head)->slh_first; \
|
||||||
while (curelm->field.sle_next != (elm)) \
|
\
|
||||||
curelm = curelm->field.sle_next; \
|
while (curelm->field.sle_next != (elm)) \
|
||||||
curelm->field.sle_next = \
|
curelm = curelm->field.sle_next; \
|
||||||
curelm->field.sle_next->field.sle_next; \
|
curelm->field.sle_next = curelm->field.sle_next->field.sle_next; \
|
||||||
_Q_INVALIDATE((elm)->field.sle_next); \
|
_Q_INVALIDATE((elm)->field.sle_next); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* List definitions.
|
* List definitions.
|
||||||
*/
|
*/
|
||||||
#define LIST_HEAD(name, type) \
|
#define LIST_HEAD(name, type) \
|
||||||
struct name { \
|
struct name { \
|
||||||
struct type *lh_first; /* first element */ \
|
struct type *lh_first; /* first element */ \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define LIST_HEAD_INITIALIZER(head) \
|
#define LIST_HEAD_INITIALIZER(head) \
|
||||||
{ NULL }
|
{ NULL }
|
||||||
|
|
||||||
#define LIST_ENTRY(type) \
|
#define LIST_ENTRY(type) \
|
||||||
struct { \
|
struct { \
|
||||||
struct type *le_next; /* next element */ \
|
struct type *le_next; /* next element */ \
|
||||||
struct type **le_prev; /* address of previous next element */ \
|
struct type **le_prev; /* address of previous next element */ \
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* List access methods
|
* List access methods
|
||||||
*/
|
*/
|
||||||
#define LIST_FIRST(head) ((head)->lh_first)
|
#define LIST_FIRST(head) ((head)->lh_first)
|
||||||
#define LIST_END(head) NULL
|
#define LIST_END(head) NULL
|
||||||
#define LIST_EMPTY(head) (LIST_FIRST(head) == LIST_END(head))
|
#define LIST_EMPTY(head) (LIST_FIRST(head) == LIST_END(head))
|
||||||
#define LIST_NEXT(elm, field) ((elm)->field.le_next)
|
#define LIST_NEXT(elm, field) ((elm)->field.le_next)
|
||||||
|
|
||||||
#define LIST_FOREACH(var, head, field) \
|
#define LIST_FOREACH(var, head, field) \
|
||||||
for((var) = LIST_FIRST(head); \
|
for ((var) = LIST_FIRST(head); \
|
||||||
(var)!= LIST_END(head); \
|
(var) != LIST_END(head); \
|
||||||
(var) = LIST_NEXT(var, field))
|
(var) = LIST_NEXT(var, field))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* List functions.
|
* List functions.
|
||||||
*/
|
*/
|
||||||
#define LIST_INIT(head) do { \
|
#define LIST_INIT(head) \
|
||||||
LIST_FIRST(head) = LIST_END(head); \
|
do { \
|
||||||
} while (0)
|
LIST_FIRST(head) = LIST_END(head); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define LIST_INSERT_AFTER(listelm, elm, field) do { \
|
#define LIST_INSERT_AFTER(listelm, elm, field) \
|
||||||
if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \
|
do { \
|
||||||
(listelm)->field.le_next->field.le_prev = \
|
if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \
|
||||||
&(elm)->field.le_next; \
|
(listelm)->field.le_next->field.le_prev = &(elm)->field.le_next; \
|
||||||
(listelm)->field.le_next = (elm); \
|
(listelm)->field.le_next = (elm); \
|
||||||
(elm)->field.le_prev = &(listelm)->field.le_next; \
|
(elm)->field.le_prev = &(listelm)->field.le_next; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define LIST_INSERT_BEFORE(listelm, elm, field) do { \
|
#define LIST_INSERT_BEFORE(listelm, elm, field) \
|
||||||
(elm)->field.le_prev = (listelm)->field.le_prev; \
|
do { \
|
||||||
(elm)->field.le_next = (listelm); \
|
(elm)->field.le_prev = (listelm)->field.le_prev; \
|
||||||
*(listelm)->field.le_prev = (elm); \
|
(elm)->field.le_next = (listelm); \
|
||||||
(listelm)->field.le_prev = &(elm)->field.le_next; \
|
*(listelm)->field.le_prev = (elm); \
|
||||||
} while (0)
|
(listelm)->field.le_prev = &(elm)->field.le_next; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define LIST_INSERT_HEAD(head, elm, field) do { \
|
#define LIST_INSERT_HEAD(head, elm, field) \
|
||||||
if (((elm)->field.le_next = (head)->lh_first) != NULL) \
|
do { \
|
||||||
(head)->lh_first->field.le_prev = &(elm)->field.le_next;\
|
if (((elm)->field.le_next = (head)->lh_first) != NULL) \
|
||||||
(head)->lh_first = (elm); \
|
(head)->lh_first->field.le_prev = &(elm)->field.le_next; \
|
||||||
(elm)->field.le_prev = &(head)->lh_first; \
|
(head)->lh_first = (elm); \
|
||||||
} while (0)
|
(elm)->field.le_prev = &(head)->lh_first; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define LIST_REMOVE(elm, field) do { \
|
#define LIST_REMOVE(elm, field) \
|
||||||
if ((elm)->field.le_next != NULL) \
|
do { \
|
||||||
(elm)->field.le_next->field.le_prev = \
|
if ((elm)->field.le_next != NULL) \
|
||||||
(elm)->field.le_prev; \
|
(elm)->field.le_next->field.le_prev = (elm)->field.le_prev; \
|
||||||
*(elm)->field.le_prev = (elm)->field.le_next; \
|
*(elm)->field.le_prev = (elm)->field.le_next; \
|
||||||
_Q_INVALIDATE((elm)->field.le_prev); \
|
_Q_INVALIDATE((elm)->field.le_prev); \
|
||||||
_Q_INVALIDATE((elm)->field.le_next); \
|
_Q_INVALIDATE((elm)->field.le_next); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define LIST_REPLACE(elm, elm2, field) do { \
|
#define LIST_REPLACE(elm, elm2, field) \
|
||||||
if (((elm2)->field.le_next = (elm)->field.le_next) != NULL) \
|
do { \
|
||||||
(elm2)->field.le_next->field.le_prev = \
|
if (((elm2)->field.le_next = (elm)->field.le_next) != NULL) \
|
||||||
&(elm2)->field.le_next; \
|
(elm2)->field.le_next->field.le_prev = &(elm2)->field.le_next; \
|
||||||
(elm2)->field.le_prev = (elm)->field.le_prev; \
|
(elm2)->field.le_prev = (elm)->field.le_prev; \
|
||||||
*(elm2)->field.le_prev = (elm2); \
|
*(elm2)->field.le_prev = (elm2); \
|
||||||
_Q_INVALIDATE((elm)->field.le_prev); \
|
_Q_INVALIDATE((elm)->field.le_prev); \
|
||||||
_Q_INVALIDATE((elm)->field.le_next); \
|
_Q_INVALIDATE((elm)->field.le_next); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Simple queue definitions.
|
* Simple queue definitions.
|
||||||
*/
|
*/
|
||||||
#define SIMPLEQ_HEAD(name, type) \
|
#define SIMPLEQ_HEAD(name, type) \
|
||||||
struct name { \
|
struct name { \
|
||||||
struct type *sqh_first; /* first element */ \
|
struct type *sqh_first; /* first element */ \
|
||||||
struct type **sqh_last; /* addr of last next element */ \
|
struct type **sqh_last; /* addr of last next element */ \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SIMPLEQ_HEAD_INITIALIZER(head) \
|
#define SIMPLEQ_HEAD_INITIALIZER(head) \
|
||||||
{ NULL, &(head).sqh_first }
|
{ NULL, &(head).sqh_first }
|
||||||
|
|
||||||
#define SIMPLEQ_ENTRY(type) \
|
#define SIMPLEQ_ENTRY(type) \
|
||||||
struct { \
|
struct { \
|
||||||
struct type *sqe_next; /* next element */ \
|
struct type *sqe_next; /* next element */ \
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Simple queue access methods.
|
* Simple queue access methods.
|
||||||
*/
|
*/
|
||||||
#define SIMPLEQ_FIRST(head) ((head)->sqh_first)
|
#define SIMPLEQ_FIRST(head) ((head)->sqh_first)
|
||||||
#define SIMPLEQ_END(head) NULL
|
#define SIMPLEQ_END(head) NULL
|
||||||
#define SIMPLEQ_EMPTY(head) (SIMPLEQ_FIRST(head) == SIMPLEQ_END(head))
|
#define SIMPLEQ_EMPTY(head) (SIMPLEQ_FIRST(head) == SIMPLEQ_END(head))
|
||||||
#define SIMPLEQ_NEXT(elm, field) ((elm)->field.sqe_next)
|
#define SIMPLEQ_NEXT(elm, field) ((elm)->field.sqe_next)
|
||||||
|
|
||||||
#define SIMPLEQ_FOREACH(var, head, field) \
|
#define SIMPLEQ_FOREACH(var, head, field) \
|
||||||
for((var) = SIMPLEQ_FIRST(head); \
|
for ((var) = SIMPLEQ_FIRST(head); \
|
||||||
(var) != SIMPLEQ_END(head); \
|
(var) != SIMPLEQ_END(head); \
|
||||||
(var) = SIMPLEQ_NEXT(var, field))
|
(var) = SIMPLEQ_NEXT(var, field))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Simple queue functions.
|
* Simple queue functions.
|
||||||
*/
|
*/
|
||||||
#define SIMPLEQ_INIT(head) do { \
|
#define SIMPLEQ_INIT(head) \
|
||||||
(head)->sqh_first = NULL; \
|
do { \
|
||||||
(head)->sqh_last = &(head)->sqh_first; \
|
(head)->sqh_first = NULL; \
|
||||||
} while (0)
|
(head)->sqh_last = &(head)->sqh_first; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define SIMPLEQ_INSERT_HEAD(head, elm, field) do { \
|
#define SIMPLEQ_INSERT_HEAD(head, elm, field) \
|
||||||
if (((elm)->field.sqe_next = (head)->sqh_first) == NULL) \
|
do { \
|
||||||
(head)->sqh_last = &(elm)->field.sqe_next; \
|
if (((elm)->field.sqe_next = (head)->sqh_first) == NULL) \
|
||||||
(head)->sqh_first = (elm); \
|
(head)->sqh_last = &(elm)->field.sqe_next; \
|
||||||
} while (0)
|
(head)->sqh_first = (elm); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define SIMPLEQ_INSERT_TAIL(head, elm, field) do { \
|
#define SIMPLEQ_INSERT_TAIL(head, elm, field) \
|
||||||
(elm)->field.sqe_next = NULL; \
|
do { \
|
||||||
*(head)->sqh_last = (elm); \
|
(elm)->field.sqe_next = NULL; \
|
||||||
(head)->sqh_last = &(elm)->field.sqe_next; \
|
*(head)->sqh_last = (elm); \
|
||||||
} while (0)
|
(head)->sqh_last = &(elm)->field.sqe_next; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do { \
|
#define SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) \
|
||||||
if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL)\
|
do { \
|
||||||
(head)->sqh_last = &(elm)->field.sqe_next; \
|
if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL) \
|
||||||
(listelm)->field.sqe_next = (elm); \
|
(head)->sqh_last = &(elm)->field.sqe_next; \
|
||||||
} while (0)
|
(listelm)->field.sqe_next = (elm); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define SIMPLEQ_REMOVE_HEAD(head, field) do { \
|
#define SIMPLEQ_REMOVE_HEAD(head, field) \
|
||||||
if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL) \
|
do { \
|
||||||
(head)->sqh_last = &(head)->sqh_first; \
|
if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL) \
|
||||||
} while (0)
|
(head)->sqh_last = &(head)->sqh_first; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Tail queue definitions.
|
* Tail queue definitions.
|
||||||
*/
|
*/
|
||||||
#define TAILQ_HEAD(name, type) \
|
#define TAILQ_HEAD(name, type) \
|
||||||
struct name { \
|
struct name { \
|
||||||
struct type *tqh_first; /* first element */ \
|
struct type *tqh_first; /* first element */ \
|
||||||
struct type **tqh_last; /* addr of last next element */ \
|
struct type **tqh_last; /* addr of last next element */ \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define TAILQ_HEAD_INITIALIZER(head) \
|
#define TAILQ_HEAD_INITIALIZER(head) \
|
||||||
{ NULL, &(head).tqh_first }
|
{ NULL, &(head).tqh_first }
|
||||||
|
|
||||||
#define TAILQ_ENTRY(type) \
|
#define TAILQ_ENTRY(type) \
|
||||||
struct { \
|
struct { \
|
||||||
struct type *tqe_next; /* next element */ \
|
struct type *tqe_next; /* next element */ \
|
||||||
struct type **tqe_prev; /* address of previous next element */ \
|
struct type **tqe_prev; /* address of previous next element */ \
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* tail queue access methods
|
* tail queue access methods
|
||||||
*/
|
*/
|
||||||
#define TAILQ_FIRST(head) ((head)->tqh_first)
|
#define TAILQ_FIRST(head) ((head)->tqh_first)
|
||||||
#define TAILQ_END(head) NULL
|
#define TAILQ_END(head) NULL
|
||||||
#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
|
#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
|
||||||
#define TAILQ_LAST(head, headname) \
|
#define TAILQ_LAST(head, headname) \
|
||||||
(*(((struct headname *)((head)->tqh_last))->tqh_last))
|
(*(((struct headname *)((head)->tqh_last))->tqh_last))
|
||||||
/* XXX */
|
/* XXX */
|
||||||
#define TAILQ_PREV(elm, headname, field) \
|
#define TAILQ_PREV(elm, headname, field) \
|
||||||
(*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
|
(*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
|
||||||
#define TAILQ_EMPTY(head) \
|
#define TAILQ_EMPTY(head) \
|
||||||
(TAILQ_FIRST(head) == TAILQ_END(head))
|
(TAILQ_FIRST(head) == TAILQ_END(head))
|
||||||
|
|
||||||
#define TAILQ_FOREACH(var, head, field) \
|
#define TAILQ_FOREACH(var, head, field) \
|
||||||
for((var) = TAILQ_FIRST(head); \
|
for ((var) = TAILQ_FIRST(head); \
|
||||||
(var) != TAILQ_END(head); \
|
(var) != TAILQ_END(head); \
|
||||||
(var) = TAILQ_NEXT(var, field))
|
(var) = TAILQ_NEXT(var, field))
|
||||||
|
|
||||||
#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \
|
#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \
|
||||||
for((var) = TAILQ_LAST(head, headname); \
|
for ((var) = TAILQ_LAST(head, headname); \
|
||||||
(var) != TAILQ_END(head); \
|
(var) != TAILQ_END(head); \
|
||||||
(var) = TAILQ_PREV(var, headname, field))
|
(var) = TAILQ_PREV(var, headname, field))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Tail queue functions.
|
* Tail queue functions.
|
||||||
*/
|
*/
|
||||||
#define TAILQ_INIT(head) do { \
|
#define TAILQ_INIT(head) \
|
||||||
(head)->tqh_first = NULL; \
|
do { \
|
||||||
(head)->tqh_last = &(head)->tqh_first; \
|
(head)->tqh_first = NULL; \
|
||||||
} while (0)
|
(head)->tqh_last = &(head)->tqh_first; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define TAILQ_INSERT_HEAD(head, elm, field) do { \
|
#define TAILQ_INSERT_HEAD(head, elm, field) \
|
||||||
if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \
|
do { \
|
||||||
(head)->tqh_first->field.tqe_prev = \
|
if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \
|
||||||
&(elm)->field.tqe_next; \
|
(head)->tqh_first->field.tqe_prev = &(elm)->field.tqe_next; \
|
||||||
else \
|
else \
|
||||||
(head)->tqh_last = &(elm)->field.tqe_next; \
|
(head)->tqh_last = &(elm)->field.tqe_next; \
|
||||||
(head)->tqh_first = (elm); \
|
(head)->tqh_first = (elm); \
|
||||||
(elm)->field.tqe_prev = &(head)->tqh_first; \
|
(elm)->field.tqe_prev = &(head)->tqh_first; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define TAILQ_INSERT_TAIL(head, elm, field) do { \
|
#define TAILQ_INSERT_TAIL(head, elm, field) \
|
||||||
(elm)->field.tqe_next = NULL; \
|
do { \
|
||||||
(elm)->field.tqe_prev = (head)->tqh_last; \
|
(elm)->field.tqe_next = NULL; \
|
||||||
*(head)->tqh_last = (elm); \
|
(elm)->field.tqe_prev = (head)->tqh_last; \
|
||||||
(head)->tqh_last = &(elm)->field.tqe_next; \
|
*(head)->tqh_last = (elm); \
|
||||||
} while (0)
|
(head)->tqh_last = &(elm)->field.tqe_next; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \
|
#define TAILQ_INSERT_AFTER(head, listelm, elm, field) \
|
||||||
if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\
|
do { \
|
||||||
(elm)->field.tqe_next->field.tqe_prev = \
|
if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL) \
|
||||||
&(elm)->field.tqe_next; \
|
(elm)->field.tqe_next->field.tqe_prev = &(elm)->field.tqe_next; \
|
||||||
else \
|
else \
|
||||||
(head)->tqh_last = &(elm)->field.tqe_next; \
|
(head)->tqh_last = &(elm)->field.tqe_next; \
|
||||||
(listelm)->field.tqe_next = (elm); \
|
(listelm)->field.tqe_next = (elm); \
|
||||||
(elm)->field.tqe_prev = &(listelm)->field.tqe_next; \
|
(elm)->field.tqe_prev = &(listelm)->field.tqe_next; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \
|
#define TAILQ_INSERT_BEFORE(listelm, elm, field) \
|
||||||
(elm)->field.tqe_prev = (listelm)->field.tqe_prev; \
|
do { \
|
||||||
(elm)->field.tqe_next = (listelm); \
|
(elm)->field.tqe_prev = (listelm)->field.tqe_prev; \
|
||||||
*(listelm)->field.tqe_prev = (elm); \
|
(elm)->field.tqe_next = (listelm); \
|
||||||
(listelm)->field.tqe_prev = &(elm)->field.tqe_next; \
|
*(listelm)->field.tqe_prev = (elm); \
|
||||||
} while (0)
|
(listelm)->field.tqe_prev = &(elm)->field.tqe_next; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define TAILQ_REMOVE(head, elm, field) do { \
|
#define TAILQ_REMOVE(head, elm, field) \
|
||||||
if (((elm)->field.tqe_next) != NULL) \
|
do { \
|
||||||
(elm)->field.tqe_next->field.tqe_prev = \
|
if (((elm)->field.tqe_next) != NULL) \
|
||||||
(elm)->field.tqe_prev; \
|
(elm)->field.tqe_next->field.tqe_prev = (elm)->field.tqe_prev; \
|
||||||
else \
|
else \
|
||||||
(head)->tqh_last = (elm)->field.tqe_prev; \
|
(head)->tqh_last = (elm)->field.tqe_prev; \
|
||||||
*(elm)->field.tqe_prev = (elm)->field.tqe_next; \
|
*(elm)->field.tqe_prev = (elm)->field.tqe_next; \
|
||||||
_Q_INVALIDATE((elm)->field.tqe_prev); \
|
_Q_INVALIDATE((elm)->field.tqe_prev); \
|
||||||
_Q_INVALIDATE((elm)->field.tqe_next); \
|
_Q_INVALIDATE((elm)->field.tqe_next); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define TAILQ_REPLACE(head, elm, elm2, field) do { \
|
#define TAILQ_REPLACE(head, elm, elm2, field) \
|
||||||
if (((elm2)->field.tqe_next = (elm)->field.tqe_next) != NULL) \
|
do { \
|
||||||
(elm2)->field.tqe_next->field.tqe_prev = \
|
if (((elm2)->field.tqe_next = (elm)->field.tqe_next) != NULL) \
|
||||||
&(elm2)->field.tqe_next; \
|
(elm2)->field.tqe_next->field.tqe_prev = &(elm2)->field.tqe_next; \
|
||||||
else \
|
else \
|
||||||
(head)->tqh_last = &(elm2)->field.tqe_next; \
|
(head)->tqh_last = &(elm2)->field.tqe_next; \
|
||||||
(elm2)->field.tqe_prev = (elm)->field.tqe_prev; \
|
(elm2)->field.tqe_prev = (elm)->field.tqe_prev; \
|
||||||
*(elm2)->field.tqe_prev = (elm2); \
|
*(elm2)->field.tqe_prev = (elm2); \
|
||||||
_Q_INVALIDATE((elm)->field.tqe_prev); \
|
_Q_INVALIDATE((elm)->field.tqe_prev); \
|
||||||
_Q_INVALIDATE((elm)->field.tqe_next); \
|
_Q_INVALIDATE((elm)->field.tqe_next); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
/* Swaps two consecutive elements. 'second' *MUST* follow 'first' */
|
/* Swaps two consecutive elements. 'second' *MUST* follow 'first' */
|
||||||
#define TAILQ_SWAP(first, second, head, field) do { \
|
#define TAILQ_SWAP(first, second, head, field) \
|
||||||
*((first)->field.tqe_prev) = (second); \
|
do { \
|
||||||
(second)->field.tqe_prev = (first)->field.tqe_prev; \
|
*((first)->field.tqe_prev) = (second); \
|
||||||
(first)->field.tqe_prev = &((second)->field.tqe_next); \
|
(second)->field.tqe_prev = (first)->field.tqe_prev; \
|
||||||
(first)->field.tqe_next = (second)->field.tqe_next; \
|
(first)->field.tqe_prev = &((second)->field.tqe_next); \
|
||||||
if ((second)->field.tqe_next) \
|
(first)->field.tqe_next = (second)->field.tqe_next; \
|
||||||
(second)->field.tqe_next->field.tqe_prev = &((first)->field.tqe_next); \
|
if ((second)->field.tqe_next) \
|
||||||
(second)->field.tqe_next = first; \
|
(second)->field.tqe_next->field.tqe_prev = &((first)->field.tqe_next); \
|
||||||
if ((head)->tqh_last == &((second)->field.tqe_next)) \
|
(second)->field.tqe_next = first; \
|
||||||
(head)->tqh_last = &((first)->field.tqe_next); \
|
if ((head)->tqh_last == &((second)->field.tqe_next)) \
|
||||||
} while (0)
|
(head)->tqh_last = &((first)->field.tqe_next); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Circular queue definitions.
|
* Circular queue definitions.
|
||||||
*/
|
*/
|
||||||
#define CIRCLEQ_HEAD(name, type) \
|
#define CIRCLEQ_HEAD(name, type) \
|
||||||
struct name { \
|
struct name { \
|
||||||
struct type *cqh_first; /* first element */ \
|
struct type *cqh_first; /* first element */ \
|
||||||
struct type *cqh_last; /* last element */ \
|
struct type *cqh_last; /* last element */ \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CIRCLEQ_HEAD_INITIALIZER(head) \
|
#define CIRCLEQ_HEAD_INITIALIZER(head) \
|
||||||
{ CIRCLEQ_END(&head), CIRCLEQ_END(&head) }
|
{ CIRCLEQ_END(&head), CIRCLEQ_END(&head) }
|
||||||
|
|
||||||
#define CIRCLEQ_ENTRY(type) \
|
#define CIRCLEQ_ENTRY(type) \
|
||||||
struct { \
|
struct { \
|
||||||
struct type *cqe_next; /* next element */ \
|
struct type *cqe_next; /* next element */ \
|
||||||
struct type *cqe_prev; /* previous element */ \
|
struct type *cqe_prev; /* previous element */ \
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Circular queue access methods
|
* Circular queue access methods
|
||||||
*/
|
*/
|
||||||
#define CIRCLEQ_FIRST(head) ((head)->cqh_first)
|
#define CIRCLEQ_FIRST(head) ((head)->cqh_first)
|
||||||
#define CIRCLEQ_LAST(head) ((head)->cqh_last)
|
#define CIRCLEQ_LAST(head) ((head)->cqh_last)
|
||||||
#define CIRCLEQ_END(head) ((void *)(head))
|
#define CIRCLEQ_END(head) ((void *)(head))
|
||||||
#define CIRCLEQ_NEXT(elm, field) ((elm)->field.cqe_next)
|
#define CIRCLEQ_NEXT(elm, field) ((elm)->field.cqe_next)
|
||||||
#define CIRCLEQ_PREV(elm, field) ((elm)->field.cqe_prev)
|
#define CIRCLEQ_PREV(elm, field) ((elm)->field.cqe_prev)
|
||||||
#define CIRCLEQ_EMPTY(head) \
|
#define CIRCLEQ_EMPTY(head) \
|
||||||
(CIRCLEQ_FIRST(head) == CIRCLEQ_END(head))
|
(CIRCLEQ_FIRST(head) == CIRCLEQ_END(head))
|
||||||
|
|
||||||
#define CIRCLEQ_FOREACH(var, head, field) \
|
#define CIRCLEQ_FOREACH(var, head, field) \
|
||||||
for((var) = CIRCLEQ_FIRST(head); \
|
for ((var) = CIRCLEQ_FIRST(head); \
|
||||||
(var) != CIRCLEQ_END(head); \
|
(var) != CIRCLEQ_END(head); \
|
||||||
(var) = CIRCLEQ_NEXT(var, field))
|
(var) = CIRCLEQ_NEXT(var, field))
|
||||||
|
|
||||||
#define CIRCLEQ_FOREACH_REVERSE(var, head, field) \
|
#define CIRCLEQ_FOREACH_REVERSE(var, head, field) \
|
||||||
for((var) = CIRCLEQ_LAST(head); \
|
for ((var) = CIRCLEQ_LAST(head); \
|
||||||
(var) != CIRCLEQ_END(head); \
|
(var) != CIRCLEQ_END(head); \
|
||||||
(var) = CIRCLEQ_PREV(var, field))
|
(var) = CIRCLEQ_PREV(var, field))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Circular queue functions.
|
* Circular queue functions.
|
||||||
*/
|
*/
|
||||||
#define CIRCLEQ_INIT(head) do { \
|
#define CIRCLEQ_INIT(head) \
|
||||||
(head)->cqh_first = CIRCLEQ_END(head); \
|
do { \
|
||||||
(head)->cqh_last = CIRCLEQ_END(head); \
|
(head)->cqh_first = CIRCLEQ_END(head); \
|
||||||
} while (0)
|
(head)->cqh_last = CIRCLEQ_END(head); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do { \
|
#define CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) \
|
||||||
(elm)->field.cqe_next = (listelm)->field.cqe_next; \
|
do { \
|
||||||
(elm)->field.cqe_prev = (listelm); \
|
(elm)->field.cqe_next = (listelm)->field.cqe_next; \
|
||||||
if ((listelm)->field.cqe_next == CIRCLEQ_END(head)) \
|
(elm)->field.cqe_prev = (listelm); \
|
||||||
(head)->cqh_last = (elm); \
|
if ((listelm)->field.cqe_next == CIRCLEQ_END(head)) \
|
||||||
else \
|
(head)->cqh_last = (elm); \
|
||||||
(listelm)->field.cqe_next->field.cqe_prev = (elm); \
|
else \
|
||||||
(listelm)->field.cqe_next = (elm); \
|
(listelm)->field.cqe_next->field.cqe_prev = (elm); \
|
||||||
} while (0)
|
(listelm)->field.cqe_next = (elm); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) do { \
|
#define CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) \
|
||||||
(elm)->field.cqe_next = (listelm); \
|
do { \
|
||||||
(elm)->field.cqe_prev = (listelm)->field.cqe_prev; \
|
(elm)->field.cqe_next = (listelm); \
|
||||||
if ((listelm)->field.cqe_prev == CIRCLEQ_END(head)) \
|
(elm)->field.cqe_prev = (listelm)->field.cqe_prev; \
|
||||||
(head)->cqh_first = (elm); \
|
if ((listelm)->field.cqe_prev == CIRCLEQ_END(head)) \
|
||||||
else \
|
(head)->cqh_first = (elm); \
|
||||||
(listelm)->field.cqe_prev->field.cqe_next = (elm); \
|
else \
|
||||||
(listelm)->field.cqe_prev = (elm); \
|
(listelm)->field.cqe_prev->field.cqe_next = (elm); \
|
||||||
} while (0)
|
(listelm)->field.cqe_prev = (elm); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define CIRCLEQ_INSERT_HEAD(head, elm, field) do { \
|
#define CIRCLEQ_INSERT_HEAD(head, elm, field) \
|
||||||
(elm)->field.cqe_next = (head)->cqh_first; \
|
do { \
|
||||||
(elm)->field.cqe_prev = CIRCLEQ_END(head); \
|
(elm)->field.cqe_next = (head)->cqh_first; \
|
||||||
if ((head)->cqh_last == CIRCLEQ_END(head)) \
|
(elm)->field.cqe_prev = CIRCLEQ_END(head); \
|
||||||
(head)->cqh_last = (elm); \
|
if ((head)->cqh_last == CIRCLEQ_END(head)) \
|
||||||
else \
|
(head)->cqh_last = (elm); \
|
||||||
(head)->cqh_first->field.cqe_prev = (elm); \
|
else \
|
||||||
(head)->cqh_first = (elm); \
|
(head)->cqh_first->field.cqe_prev = (elm); \
|
||||||
} while (0)
|
(head)->cqh_first = (elm); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define CIRCLEQ_INSERT_TAIL(head, elm, field) do { \
|
#define CIRCLEQ_INSERT_TAIL(head, elm, field) \
|
||||||
(elm)->field.cqe_next = CIRCLEQ_END(head); \
|
do { \
|
||||||
(elm)->field.cqe_prev = (head)->cqh_last; \
|
(elm)->field.cqe_next = CIRCLEQ_END(head); \
|
||||||
if ((head)->cqh_first == CIRCLEQ_END(head)) \
|
(elm)->field.cqe_prev = (head)->cqh_last; \
|
||||||
(head)->cqh_first = (elm); \
|
if ((head)->cqh_first == CIRCLEQ_END(head)) \
|
||||||
else \
|
(head)->cqh_first = (elm); \
|
||||||
(head)->cqh_last->field.cqe_next = (elm); \
|
else \
|
||||||
(head)->cqh_last = (elm); \
|
(head)->cqh_last->field.cqe_next = (elm); \
|
||||||
} while (0)
|
(head)->cqh_last = (elm); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define CIRCLEQ_REMOVE(head, elm, field) do { \
|
#define CIRCLEQ_REMOVE(head, elm, field) \
|
||||||
if ((elm)->field.cqe_next == CIRCLEQ_END(head)) \
|
do { \
|
||||||
(head)->cqh_last = (elm)->field.cqe_prev; \
|
if ((elm)->field.cqe_next == CIRCLEQ_END(head)) \
|
||||||
else \
|
(head)->cqh_last = (elm)->field.cqe_prev; \
|
||||||
(elm)->field.cqe_next->field.cqe_prev = \
|
else \
|
||||||
(elm)->field.cqe_prev; \
|
(elm)->field.cqe_next->field.cqe_prev = (elm)->field.cqe_prev; \
|
||||||
if ((elm)->field.cqe_prev == CIRCLEQ_END(head)) \
|
if ((elm)->field.cqe_prev == CIRCLEQ_END(head)) \
|
||||||
(head)->cqh_first = (elm)->field.cqe_next; \
|
(head)->cqh_first = (elm)->field.cqe_next; \
|
||||||
else \
|
else \
|
||||||
(elm)->field.cqe_prev->field.cqe_next = \
|
(elm)->field.cqe_prev->field.cqe_next = (elm)->field.cqe_next; \
|
||||||
(elm)->field.cqe_next; \
|
_Q_INVALIDATE((elm)->field.cqe_prev); \
|
||||||
_Q_INVALIDATE((elm)->field.cqe_prev); \
|
_Q_INVALIDATE((elm)->field.cqe_next); \
|
||||||
_Q_INVALIDATE((elm)->field.cqe_next); \
|
} while (0)
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define CIRCLEQ_REPLACE(head, elm, elm2, field) do { \
|
#define CIRCLEQ_REPLACE(head, elm, elm2, field) \
|
||||||
if (((elm2)->field.cqe_next = (elm)->field.cqe_next) == \
|
do { \
|
||||||
CIRCLEQ_END(head)) \
|
if (((elm2)->field.cqe_next = (elm)->field.cqe_next) == CIRCLEQ_END(head)) \
|
||||||
(head)->cqh_last = (elm2); \
|
(head)->cqh_last = (elm2); \
|
||||||
else \
|
else \
|
||||||
(elm2)->field.cqe_next->field.cqe_prev = (elm2); \
|
(elm2)->field.cqe_next->field.cqe_prev = (elm2); \
|
||||||
if (((elm2)->field.cqe_prev = (elm)->field.cqe_prev) == \
|
if (((elm2)->field.cqe_prev = (elm)->field.cqe_prev) == CIRCLEQ_END(head)) \
|
||||||
CIRCLEQ_END(head)) \
|
(head)->cqh_first = (elm2); \
|
||||||
(head)->cqh_first = (elm2); \
|
else \
|
||||||
else \
|
(elm2)->field.cqe_prev->field.cqe_next = (elm2); \
|
||||||
(elm2)->field.cqe_prev->field.cqe_next = (elm2); \
|
_Q_INVALIDATE((elm)->field.cqe_prev); \
|
||||||
_Q_INVALIDATE((elm)->field.cqe_prev); \
|
_Q_INVALIDATE((elm)->field.cqe_next); \
|
||||||
_Q_INVALIDATE((elm)->field.cqe_next); \
|
} while (0)
|
||||||
} while (0)
|
|
||||||
|
@ -68,15 +68,15 @@ extern "C" {
|
|||||||
|
|
||||||
#ifndef _sd_printf_attr_
|
#ifndef _sd_printf_attr_
|
||||||
#if __GNUC__ >= 4
|
#if __GNUC__ >= 4
|
||||||
#define _sd_printf_attr_(a,b) __attribute__ ((format (printf, a, b)))
|
#define _sd_printf_attr_(a, b) __attribute__((format(printf, a, b)))
|
||||||
#else
|
#else
|
||||||
#define _sd_printf_attr_(a,b)
|
#define _sd_printf_attr_(a, b)
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef _sd_hidden_
|
#ifndef _sd_hidden_
|
||||||
#if (__GNUC__ >= 4) && !defined(SD_EXPORT_SYMBOLS)
|
#if (__GNUC__ >= 4) && !defined(SD_EXPORT_SYMBOLS)
|
||||||
#define _sd_hidden_ __attribute__ ((visibility("hidden")))
|
#define _sd_hidden_ __attribute__((visibility("hidden")))
|
||||||
#else
|
#else
|
||||||
#define _sd_hidden_
|
#define _sd_hidden_
|
||||||
#endif
|
#endif
|
||||||
@ -89,14 +89,14 @@ extern "C" {
|
|||||||
|
|
||||||
This is similar to printk() usage in the kernel.
|
This is similar to printk() usage in the kernel.
|
||||||
*/
|
*/
|
||||||
#define SD_EMERG "<0>" /* system is unusable */
|
#define SD_EMERG "<0>" /* system is unusable */
|
||||||
#define SD_ALERT "<1>" /* action must be taken immediately */
|
#define SD_ALERT "<1>" /* action must be taken immediately */
|
||||||
#define SD_CRIT "<2>" /* critical conditions */
|
#define SD_CRIT "<2>" /* critical conditions */
|
||||||
#define SD_ERR "<3>" /* error conditions */
|
#define SD_ERR "<3>" /* error conditions */
|
||||||
#define SD_WARNING "<4>" /* warning conditions */
|
#define SD_WARNING "<4>" /* warning conditions */
|
||||||
#define SD_NOTICE "<5>" /* normal but significant condition */
|
#define SD_NOTICE "<5>" /* normal but significant condition */
|
||||||
#define SD_INFO "<6>" /* informational */
|
#define SD_INFO "<6>" /* informational */
|
||||||
#define SD_DEBUG "<7>" /* debug-level messages */
|
#define SD_DEBUG "<7>" /* debug-level messages */
|
||||||
|
|
||||||
/* The first passed file descriptor is fd 3 */
|
/* The first passed file descriptor is fd 3 */
|
||||||
#define SD_LISTEN_FDS_START 3
|
#define SD_LISTEN_FDS_START 3
|
||||||
@ -242,7 +242,7 @@ int sd_notify(int unset_environment, const char *state) _sd_hidden_;
|
|||||||
|
|
||||||
See sd_notifyf(3) for more information.
|
See sd_notifyf(3) for more information.
|
||||||
*/
|
*/
|
||||||
int sd_notifyf(int unset_environment, const char *format, ...) _sd_printf_attr_(2,3) _sd_hidden_;
|
int sd_notifyf(int unset_environment, const char *format, ...) _sd_printf_attr_(2, 3) _sd_hidden_;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Returns > 0 if the system was booted with systemd. Returns < 0 on
|
Returns > 0 if the system was booted with systemd. Returns < 0 on
|
||||||
|
@ -49,7 +49,7 @@ void startup_monitor_event(SnMonitorEvent *event, void *userdata);
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
struct Startup_Sequence *startup_sequence_get(i3Window *cwindow,
|
struct Startup_Sequence *startup_sequence_get(i3Window *cwindow,
|
||||||
xcb_get_property_reply_t *startup_id_reply, bool ignore_mapped_leader);
|
xcb_get_property_reply_t *startup_id_reply, bool ignore_mapped_leader);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the given window belongs to a startup notification by checking if
|
* Checks if the given window belongs to a startup notification by checking if
|
||||||
|
@ -15,43 +15,45 @@
|
|||||||
#include "data.h"
|
#include "data.h"
|
||||||
|
|
||||||
#define die(...) errx(EXIT_FAILURE, __VA_ARGS__);
|
#define die(...) errx(EXIT_FAILURE, __VA_ARGS__);
|
||||||
#define exit_if_null(pointer, ...) { if (pointer == NULL) die(__VA_ARGS__); }
|
#define exit_if_null(pointer, ...) \
|
||||||
|
{ \
|
||||||
|
if (pointer == NULL) \
|
||||||
|
die(__VA_ARGS__); \
|
||||||
|
}
|
||||||
#define STARTS_WITH(string, needle) (strncasecmp(string, needle, strlen(needle)) == 0)
|
#define STARTS_WITH(string, needle) (strncasecmp(string, needle, strlen(needle)) == 0)
|
||||||
#define CIRCLEQ_NEXT_OR_NULL(head, elm, field) (CIRCLEQ_NEXT(elm, field) != CIRCLEQ_END(head) ? \
|
#define CIRCLEQ_NEXT_OR_NULL(head, elm, field) (CIRCLEQ_NEXT(elm, field) != CIRCLEQ_END(head) ? CIRCLEQ_NEXT(elm, field) : NULL)
|
||||||
CIRCLEQ_NEXT(elm, field) : NULL)
|
#define CIRCLEQ_PREV_OR_NULL(head, elm, field) (CIRCLEQ_PREV(elm, field) != CIRCLEQ_END(head) ? CIRCLEQ_PREV(elm, field) : NULL)
|
||||||
#define CIRCLEQ_PREV_OR_NULL(head, elm, field) (CIRCLEQ_PREV(elm, field) != CIRCLEQ_END(head) ? \
|
#define FOR_TABLE(workspace) \
|
||||||
CIRCLEQ_PREV(elm, field) : NULL)
|
for (int cols = 0; cols < (workspace)->cols; cols++) \
|
||||||
#define FOR_TABLE(workspace) \
|
for (int rows = 0; rows < (workspace)->rows; rows++)
|
||||||
for (int cols = 0; cols < (workspace)->cols; cols++) \
|
|
||||||
for (int rows = 0; rows < (workspace)->rows; rows++)
|
|
||||||
|
|
||||||
#define NODES_FOREACH(head) \
|
#define NODES_FOREACH(head) \
|
||||||
for (Con *child = (Con*)-1; (child == (Con*)-1) && ((child = 0), true);) \
|
for (Con *child = (Con *)-1; (child == (Con *)-1) && ((child = 0), true);) \
|
||||||
TAILQ_FOREACH(child, &((head)->nodes_head), nodes)
|
TAILQ_FOREACH(child, &((head)->nodes_head), nodes)
|
||||||
|
|
||||||
#define NODES_FOREACH_REVERSE(head) \
|
#define NODES_FOREACH_REVERSE(head) \
|
||||||
for (Con *child = (Con*)-1; (child == (Con*)-1) && ((child = 0), true);) \
|
for (Con *child = (Con *)-1; (child == (Con *)-1) && ((child = 0), true);) \
|
||||||
TAILQ_FOREACH_REVERSE(child, &((head)->nodes_head), nodes_head, nodes)
|
TAILQ_FOREACH_REVERSE(child, &((head)->nodes_head), nodes_head, nodes)
|
||||||
|
|
||||||
/* greps the ->nodes of the given head and returns the first node that matches the given condition */
|
/* greps the ->nodes of the given head and returns the first node that matches the given condition */
|
||||||
#define GREP_FIRST(dest, head, condition) \
|
#define GREP_FIRST(dest, head, condition) \
|
||||||
NODES_FOREACH(head) { \
|
NODES_FOREACH(head) { \
|
||||||
if (!(condition)) \
|
if (!(condition)) \
|
||||||
continue; \
|
continue; \
|
||||||
\
|
\
|
||||||
(dest) = child; \
|
(dest) = child; \
|
||||||
break; \
|
break; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define FREE(pointer) do { \
|
#define FREE(pointer) \
|
||||||
|
do { \
|
||||||
if (pointer != NULL) { \
|
if (pointer != NULL) { \
|
||||||
free(pointer); \
|
free(pointer); \
|
||||||
pointer = NULL; \
|
pointer = NULL; \
|
||||||
} \
|
} \
|
||||||
} \
|
} while (0)
|
||||||
while (0)
|
|
||||||
|
|
||||||
#define CALL(obj, member, ...) obj->member(obj, ## __VA_ARGS__)
|
#define CALL(obj, member, ...) obj->member(obj, ##__VA_ARGS__)
|
||||||
|
|
||||||
int min(int a, int b);
|
int min(int a, int b);
|
||||||
int max(int a, int b);
|
int max(int a, int b);
|
||||||
|
@ -68,25 +68,25 @@ void workspace_show_by_name(const char *num);
|
|||||||
* Returns the next workspace.
|
* Returns the next workspace.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
Con* workspace_next(void);
|
Con *workspace_next(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the previous workspace.
|
* Returns the previous workspace.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
Con* workspace_prev(void);
|
Con *workspace_prev(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the next workspace on the same output
|
* Returns the next workspace on the same output
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
Con* workspace_next_on_output(void);
|
Con *workspace_next_on_output(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the previous workspace on the same output
|
* Returns the previous workspace on the same output
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
Con* workspace_prev_on_output(void);
|
Con *workspace_prev_on_output(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Focuses the previously focused workspace.
|
* Focuses the previously focused workspace.
|
||||||
@ -100,7 +100,6 @@ void workspace_back_and_forth(void);
|
|||||||
*/
|
*/
|
||||||
Con *workspace_back_and_forth_get(void);
|
Con *workspace_back_and_forth_get(void);
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/**
|
/**
|
||||||
* Assigns the given workspace to the given screen by correctly updating its
|
* Assigns the given workspace to the given screen by correctly updating its
|
||||||
|
@ -12,48 +12,48 @@
|
|||||||
#include "data.h"
|
#include "data.h"
|
||||||
#include "xcursor.h"
|
#include "xcursor.h"
|
||||||
|
|
||||||
#define _NET_WM_STATE_REMOVE 0
|
#define _NET_WM_STATE_REMOVE 0
|
||||||
#define _NET_WM_STATE_ADD 1
|
#define _NET_WM_STATE_ADD 1
|
||||||
#define _NET_WM_STATE_TOGGLE 2
|
#define _NET_WM_STATE_TOGGLE 2
|
||||||
|
|
||||||
/** This is the equivalent of XC_left_ptr. I’m not sure why xcb doesn’t have a
|
/** This is the equivalent of XC_left_ptr. I’m not sure why xcb doesn’t have a
|
||||||
* constant for that. */
|
* constant for that. */
|
||||||
#define XCB_CURSOR_LEFT_PTR 68
|
#define XCB_CURSOR_LEFT_PTR 68
|
||||||
#define XCB_CURSOR_SB_H_DOUBLE_ARROW 108
|
#define XCB_CURSOR_SB_H_DOUBLE_ARROW 108
|
||||||
#define XCB_CURSOR_SB_V_DOUBLE_ARROW 116
|
#define XCB_CURSOR_SB_V_DOUBLE_ARROW 116
|
||||||
#define XCB_CURSOR_WATCH 150
|
#define XCB_CURSOR_WATCH 150
|
||||||
|
|
||||||
/* from X11/keysymdef.h */
|
/* from X11/keysymdef.h */
|
||||||
#define XCB_NUM_LOCK 0xff7f
|
#define XCB_NUM_LOCK 0xff7f
|
||||||
|
|
||||||
/* The event masks are defined here because we don’t only set them once but we
|
/* The event masks are defined here because we don’t only set them once but we
|
||||||
need to set slight variations of them (without XCB_EVENT_MASK_ENTER_WINDOW
|
need to set slight variations of them (without XCB_EVENT_MASK_ENTER_WINDOW
|
||||||
while rendering the layout) */
|
while rendering the layout) */
|
||||||
/** The XCB_CW_EVENT_MASK for the child (= real window) */
|
/** The XCB_CW_EVENT_MASK for the child (= real window) */
|
||||||
#define CHILD_EVENT_MASK (XCB_EVENT_MASK_PROPERTY_CHANGE | \
|
#define CHILD_EVENT_MASK (XCB_EVENT_MASK_PROPERTY_CHANGE | \
|
||||||
XCB_EVENT_MASK_STRUCTURE_NOTIFY | \
|
XCB_EVENT_MASK_STRUCTURE_NOTIFY | \
|
||||||
XCB_EVENT_MASK_FOCUS_CHANGE)
|
XCB_EVENT_MASK_FOCUS_CHANGE)
|
||||||
|
|
||||||
/** The XCB_CW_EVENT_MASK for its frame */
|
/** The XCB_CW_EVENT_MASK for its frame */
|
||||||
#define FRAME_EVENT_MASK (XCB_EVENT_MASK_BUTTON_PRESS | /* …mouse is pressed/released */ \
|
#define FRAME_EVENT_MASK (XCB_EVENT_MASK_BUTTON_PRESS | /* …mouse is pressed/released */ \
|
||||||
XCB_EVENT_MASK_BUTTON_RELEASE | \
|
XCB_EVENT_MASK_BUTTON_RELEASE | \
|
||||||
XCB_EVENT_MASK_POINTER_MOTION | /* …mouse is moved */ \
|
XCB_EVENT_MASK_POINTER_MOTION | /* …mouse is moved */ \
|
||||||
XCB_EVENT_MASK_EXPOSURE | /* …our window needs to be redrawn */ \
|
XCB_EVENT_MASK_EXPOSURE | /* …our window needs to be redrawn */ \
|
||||||
XCB_EVENT_MASK_STRUCTURE_NOTIFY | /* …the frame gets destroyed */ \
|
XCB_EVENT_MASK_STRUCTURE_NOTIFY | /* …the frame gets destroyed */ \
|
||||||
XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | /* …the application tries to resize itself */ \
|
XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | /* …the application tries to resize itself */ \
|
||||||
XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | /* …subwindows get notifies */ \
|
XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | /* …subwindows get notifies */ \
|
||||||
XCB_EVENT_MASK_ENTER_WINDOW) /* …user moves cursor inside our window */
|
XCB_EVENT_MASK_ENTER_WINDOW) /* …user moves cursor inside our window */
|
||||||
|
|
||||||
#define ROOT_EVENT_MASK (XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | \
|
#define ROOT_EVENT_MASK (XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | \
|
||||||
XCB_EVENT_MASK_BUTTON_PRESS | \
|
XCB_EVENT_MASK_BUTTON_PRESS | \
|
||||||
XCB_EVENT_MASK_STRUCTURE_NOTIFY | /* when the user adds a screen (e.g. video \
|
XCB_EVENT_MASK_STRUCTURE_NOTIFY | /* when the user adds a screen (e.g. video \
|
||||||
projector), the root window gets a \
|
projector), the root window gets a \
|
||||||
ConfigureNotify */ \
|
ConfigureNotify */ \
|
||||||
XCB_EVENT_MASK_POINTER_MOTION | \
|
XCB_EVENT_MASK_POINTER_MOTION | \
|
||||||
XCB_EVENT_MASK_PROPERTY_CHANGE | \
|
XCB_EVENT_MASK_PROPERTY_CHANGE | \
|
||||||
XCB_EVENT_MASK_ENTER_WINDOW)
|
XCB_EVENT_MASK_ENTER_WINDOW)
|
||||||
|
|
||||||
#define xmacro(atom) xcb_atom_t A_ ## atom;
|
#define xmacro(atom) xcb_atom_t A_##atom;
|
||||||
#include "atoms.xmacro"
|
#include "atoms.xmacro"
|
||||||
#undef xmacro
|
#undef xmacro
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ extern unsigned int xcb_numlock_mask;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
xcb_window_t create_window(xcb_connection_t *conn, Rect r, uint16_t depth, xcb_visualid_t visual,
|
xcb_window_t create_window(xcb_connection_t *conn, Rect r, uint16_t depth, xcb_visualid_t visual,
|
||||||
uint16_t window_class, enum xcursor_cursor_t cursor, bool map, uint32_t mask, uint32_t *values);
|
uint16_t window_class, enum xcursor_cursor_t cursor, bool map, uint32_t mask, uint32_t *values);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draws a line from x,y to to_x,to_y using the given color
|
* Draws a line from x,y to to_x,to_y using the given color
|
||||||
@ -108,7 +108,6 @@ void xcb_raise_window(xcb_connection_t *conn, xcb_window_t window);
|
|||||||
*/
|
*/
|
||||||
void xcb_set_window_rect(xcb_connection_t *conn, xcb_window_t window, Rect r);
|
void xcb_set_window_rect(xcb_connection_t *conn, xcb_window_t window, Rect r);
|
||||||
|
|
||||||
|
|
||||||
bool xcb_reply_contains_atom(xcb_get_property_reply_t *prop, xcb_atom_t atom);
|
bool xcb_reply_contains_atom(xcb_get_property_reply_t *prop, xcb_atom_t atom);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -14,8 +14,8 @@
|
|||||||
#include <yajl/yajl_version.h>
|
#include <yajl/yajl_version.h>
|
||||||
|
|
||||||
/* Shorter names for all those yajl_gen_* functions */
|
/* Shorter names for all those yajl_gen_* functions */
|
||||||
#define y(x, ...) yajl_gen_ ## x (gen, ##__VA_ARGS__)
|
#define y(x, ...) yajl_gen_##x(gen, ##__VA_ARGS__)
|
||||||
#define ystr(str) yajl_gen_string(gen, (unsigned char*)str, strlen(str))
|
#define ystr(str) yajl_gen_string(gen, (unsigned char *)str, strlen(str))
|
||||||
|
|
||||||
#define ygenalloc() yajl_gen_alloc(NULL)
|
#define ygenalloc() yajl_gen_alloc(NULL)
|
||||||
#define yalloc(callbacks, client) yajl_alloc(callbacks, NULL, client)
|
#define yalloc(callbacks, client) yajl_alloc(callbacks, NULL, client)
|
||||||
|
@ -23,7 +23,7 @@ void run_assignments(i3Window *window) {
|
|||||||
|
|
||||||
/* Check if any assignments match */
|
/* Check if any assignments match */
|
||||||
Assignment *current;
|
Assignment *current;
|
||||||
TAILQ_FOREACH (current, &assignments, assignments) {
|
TAILQ_FOREACH(current, &assignments, assignments) {
|
||||||
if (!match_matches_window(&(current->match), window))
|
if (!match_matches_window(&(current->match), window))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ void run_assignments(i3Window *window) {
|
|||||||
Assignment *assignment_for(i3Window *window, int type) {
|
Assignment *assignment_for(i3Window *window, int type) {
|
||||||
Assignment *assignment;
|
Assignment *assignment;
|
||||||
|
|
||||||
TAILQ_FOREACH (assignment, &assignments, assignments) {
|
TAILQ_FOREACH(assignment, &assignments, assignments) {
|
||||||
if ((type != A_ANY && (assignment->type & type) == 0) ||
|
if ((type != A_ANY && (assignment->type & type) == 0) ||
|
||||||
!match_matches_window(&(assignment->match), window))
|
!match_matches_window(&(assignment->match), window))
|
||||||
continue;
|
continue;
|
||||||
|
@ -25,7 +25,7 @@ static struct Mode *mode_from_name(const char *name) {
|
|||||||
struct Mode *mode;
|
struct Mode *mode;
|
||||||
|
|
||||||
/* Try to find the mode in the list of modes and return it */
|
/* Try to find the mode in the list of modes and return it */
|
||||||
SLIST_FOREACH (mode, &modes, modes) {
|
SLIST_FOREACH(mode, &modes, modes) {
|
||||||
if (strcmp(mode->name, name) == 0)
|
if (strcmp(mode->name, name) == 0)
|
||||||
return mode;
|
return mode;
|
||||||
}
|
}
|
||||||
@ -104,7 +104,7 @@ static void grab_keycode_for_binding(xcb_connection_t *conn, Binding *bind, uint
|
|||||||
*/
|
*/
|
||||||
void grab_all_keys(xcb_connection_t *conn, bool bind_mode_switch) {
|
void grab_all_keys(xcb_connection_t *conn, bool bind_mode_switch) {
|
||||||
Binding *bind;
|
Binding *bind;
|
||||||
TAILQ_FOREACH (bind, bindings, bindings) {
|
TAILQ_FOREACH(bind, bindings, bindings) {
|
||||||
if (bind->input_type != B_KEYBOARD ||
|
if (bind->input_type != B_KEYBOARD ||
|
||||||
(bind_mode_switch && (bind->mods & BIND_MODE_SWITCH) == 0) ||
|
(bind_mode_switch && (bind->mods & BIND_MODE_SWITCH) == 0) ||
|
||||||
(!bind_mode_switch && (bind->mods & BIND_MODE_SWITCH) != 0))
|
(!bind_mode_switch && (bind->mods & BIND_MODE_SWITCH) != 0))
|
||||||
@ -133,7 +133,7 @@ static Binding *get_binding(uint16_t modifiers, bool is_release, uint16_t input_
|
|||||||
if (!is_release) {
|
if (!is_release) {
|
||||||
/* On a press event, we first reset all B_UPON_KEYRELEASE_IGNORE_MODS
|
/* On a press event, we first reset all B_UPON_KEYRELEASE_IGNORE_MODS
|
||||||
* bindings back to B_UPON_KEYRELEASE */
|
* bindings back to B_UPON_KEYRELEASE */
|
||||||
TAILQ_FOREACH (bind, bindings, bindings) {
|
TAILQ_FOREACH(bind, bindings, bindings) {
|
||||||
if (bind->input_type != input_type)
|
if (bind->input_type != input_type)
|
||||||
continue;
|
continue;
|
||||||
if (bind->release == B_UPON_KEYRELEASE_IGNORE_MODS)
|
if (bind->release == B_UPON_KEYRELEASE_IGNORE_MODS)
|
||||||
@ -141,7 +141,7 @@ static Binding *get_binding(uint16_t modifiers, bool is_release, uint16_t input_
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TAILQ_FOREACH (bind, bindings, bindings) {
|
TAILQ_FOREACH(bind, bindings, bindings) {
|
||||||
/* First compare the modifiers (unless this is a
|
/* First compare the modifiers (unless this is a
|
||||||
* B_UPON_KEYRELEASE_IGNORE_MODS binding and this is a KeyRelease
|
* B_UPON_KEYRELEASE_IGNORE_MODS binding and this is a KeyRelease
|
||||||
* event) */
|
* event) */
|
||||||
@ -248,7 +248,7 @@ void translate_keysyms(void) {
|
|||||||
min_keycode = xcb_get_setup(conn)->min_keycode;
|
min_keycode = xcb_get_setup(conn)->min_keycode;
|
||||||
max_keycode = xcb_get_setup(conn)->max_keycode;
|
max_keycode = xcb_get_setup(conn)->max_keycode;
|
||||||
|
|
||||||
TAILQ_FOREACH (bind, bindings, bindings) {
|
TAILQ_FOREACH(bind, bindings, bindings) {
|
||||||
if (bind->input_type == B_MOUSE) {
|
if (bind->input_type == B_MOUSE) {
|
||||||
int button = atoi(bind->symbol + (sizeof("button") - 1));
|
int button = atoi(bind->symbol + (sizeof("button") - 1));
|
||||||
bind->keycode = button;
|
bind->keycode = button;
|
||||||
@ -304,7 +304,7 @@ void switch_mode(const char *new_mode) {
|
|||||||
|
|
||||||
DLOG("Switching to mode %s\n", new_mode);
|
DLOG("Switching to mode %s\n", new_mode);
|
||||||
|
|
||||||
SLIST_FOREACH (mode, &modes, modes) {
|
SLIST_FOREACH(mode, &modes, modes) {
|
||||||
if (strcasecmp(mode->name, new_mode) != 0)
|
if (strcasecmp(mode->name, new_mode) != 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -334,8 +334,8 @@ void switch_mode(const char *new_mode) {
|
|||||||
*/
|
*/
|
||||||
void check_for_duplicate_bindings(struct context *context) {
|
void check_for_duplicate_bindings(struct context *context) {
|
||||||
Binding *bind, *current;
|
Binding *bind, *current;
|
||||||
TAILQ_FOREACH (current, bindings, bindings) {
|
TAILQ_FOREACH(current, bindings, bindings) {
|
||||||
TAILQ_FOREACH (bind, bindings, bindings) {
|
TAILQ_FOREACH(bind, bindings, bindings) {
|
||||||
/* Abort when we reach the current keybinding, only check the
|
/* Abort when we reach the current keybinding, only check the
|
||||||
* bindings before */
|
* bindings before */
|
||||||
if (bind == current)
|
if (bind == current)
|
||||||
|
@ -330,7 +330,7 @@ int handle_button_press(xcb_button_press_event_t *event) {
|
|||||||
* click coordinates and focus the output's active workspace. */
|
* click coordinates and focus the output's active workspace. */
|
||||||
if (event->event == root) {
|
if (event->event == root) {
|
||||||
Con *output, *ws;
|
Con *output, *ws;
|
||||||
TAILQ_FOREACH (output, &(croot->nodes_head), nodes) {
|
TAILQ_FOREACH(output, &(croot->nodes_head), nodes) {
|
||||||
if (con_is_internal(output) ||
|
if (con_is_internal(output) ||
|
||||||
!rect_contains(output->rect, event->event_x, event->event_y))
|
!rect_contains(output->rect, event->event_x, event->event_y))
|
||||||
continue;
|
continue;
|
||||||
@ -358,7 +358,7 @@ int handle_button_press(xcb_button_press_event_t *event) {
|
|||||||
|
|
||||||
/* Check if the click was on the decoration of a child */
|
/* Check if the click was on the decoration of a child */
|
||||||
Con *child;
|
Con *child;
|
||||||
TAILQ_FOREACH (child, &(con->nodes_head), nodes) {
|
TAILQ_FOREACH(child, &(con->nodes_head), nodes) {
|
||||||
if (!rect_contains(child->deco_rect, event->event_x, event->event_y))
|
if (!rect_contains(child->deco_rect, event->event_x, event->event_y))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
104
src/commands.c
104
src/commands.c
@ -273,7 +273,7 @@ void cmd_criteria_init(I3_CMD) {
|
|||||||
}
|
}
|
||||||
TAILQ_INIT(&owindows);
|
TAILQ_INIT(&owindows);
|
||||||
/* copy all_cons */
|
/* copy all_cons */
|
||||||
TAILQ_FOREACH (con, &all_cons, all_cons) {
|
TAILQ_FOREACH(con, &all_cons, all_cons) {
|
||||||
ow = smalloc(sizeof(owindow));
|
ow = smalloc(sizeof(owindow));
|
||||||
ow->con = con;
|
ow->con = con;
|
||||||
TAILQ_INSERT_TAIL(&owindows, ow, owindows);
|
TAILQ_INSERT_TAIL(&owindows, ow, owindows);
|
||||||
@ -324,7 +324,7 @@ void cmd_criteria_match_windows(I3_CMD) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TAILQ_FOREACH (current, &owindows, owindows) {
|
TAILQ_FOREACH(current, &owindows, owindows) {
|
||||||
DLOG("matching: %p / %s\n", current->con, current->con->name);
|
DLOG("matching: %p / %s\n", current->con, current->con->name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -448,7 +448,7 @@ void cmd_move_con_to_workspace(I3_CMD, char *which) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TAILQ_FOREACH (current, &owindows, owindows) {
|
TAILQ_FOREACH(current, &owindows, owindows) {
|
||||||
DLOG("matching: %p / %s\n", current->con, current->con->name);
|
DLOG("matching: %p / %s\n", current->con, current->con->name);
|
||||||
con_move_to_workspace(current->con, ws, true, false);
|
con_move_to_workspace(current->con, ws, true, false);
|
||||||
}
|
}
|
||||||
@ -475,7 +475,7 @@ void cmd_move_con_to_workspace_back_and_forth(I3_CMD) {
|
|||||||
|
|
||||||
HANDLE_EMPTY_MATCH;
|
HANDLE_EMPTY_MATCH;
|
||||||
|
|
||||||
TAILQ_FOREACH (current, &owindows, owindows) {
|
TAILQ_FOREACH(current, &owindows, owindows) {
|
||||||
DLOG("matching: %p / %s\n", current->con, current->con->name);
|
DLOG("matching: %p / %s\n", current->con, current->con->name);
|
||||||
con_move_to_workspace(current->con, ws, true, false);
|
con_move_to_workspace(current->con, ws, true, false);
|
||||||
}
|
}
|
||||||
@ -519,7 +519,7 @@ void cmd_move_con_to_workspace_name(I3_CMD, char *name) {
|
|||||||
|
|
||||||
HANDLE_EMPTY_MATCH;
|
HANDLE_EMPTY_MATCH;
|
||||||
|
|
||||||
TAILQ_FOREACH (current, &owindows, owindows) {
|
TAILQ_FOREACH(current, &owindows, owindows) {
|
||||||
DLOG("matching: %p / %s\n", current->con, current->con->name);
|
DLOG("matching: %p / %s\n", current->con, current->con->name);
|
||||||
con_move_to_workspace(current->con, ws, true, false);
|
con_move_to_workspace(current->con, ws, true, false);
|
||||||
}
|
}
|
||||||
@ -562,9 +562,9 @@ void cmd_move_con_to_workspace_number(I3_CMD, char *which) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TAILQ_FOREACH (output, &(croot->nodes_head), nodes)
|
TAILQ_FOREACH(output, &(croot->nodes_head), nodes)
|
||||||
GREP_FIRST(workspace, output_get_content(output),
|
GREP_FIRST(workspace, output_get_content(output),
|
||||||
child->num == parsed_num);
|
child->num == parsed_num);
|
||||||
|
|
||||||
if (!workspace) {
|
if (!workspace) {
|
||||||
workspace = workspace_get(which, NULL);
|
workspace = workspace_get(which, NULL);
|
||||||
@ -574,7 +574,7 @@ void cmd_move_con_to_workspace_number(I3_CMD, char *which) {
|
|||||||
|
|
||||||
HANDLE_EMPTY_MATCH;
|
HANDLE_EMPTY_MATCH;
|
||||||
|
|
||||||
TAILQ_FOREACH (current, &owindows, owindows) {
|
TAILQ_FOREACH(current, &owindows, owindows) {
|
||||||
DLOG("matching: %p / %s\n", current->con, current->con->name);
|
DLOG("matching: %p / %s\n", current->con, current->con->name);
|
||||||
con_move_to_workspace(current->con, workspace, true, false);
|
con_move_to_workspace(current->con, workspace, true, false);
|
||||||
}
|
}
|
||||||
@ -728,7 +728,7 @@ static bool cmd_resize_tiling_width_height(I3_CMD, Con *current, char *way, char
|
|||||||
|
|
||||||
/* Ensure all the other children have a percentage set. */
|
/* Ensure all the other children have a percentage set. */
|
||||||
Con *child;
|
Con *child;
|
||||||
TAILQ_FOREACH (child, &(current->parent->nodes_head), nodes) {
|
TAILQ_FOREACH(child, &(current->parent->nodes_head), nodes) {
|
||||||
LOG("child->percent = %f (child %p)\n", child->percent, child);
|
LOG("child->percent = %f (child %p)\n", child->percent, child);
|
||||||
if (child->percent == 0.0)
|
if (child->percent == 0.0)
|
||||||
child->percent = percentage;
|
child->percent = percentage;
|
||||||
@ -740,7 +740,7 @@ static bool cmd_resize_tiling_width_height(I3_CMD, Con *current, char *way, char
|
|||||||
LOG("subtract_percent = %f\n", subtract_percent);
|
LOG("subtract_percent = %f\n", subtract_percent);
|
||||||
/* Ensure that the new percentages are positive and greater than
|
/* Ensure that the new percentages are positive and greater than
|
||||||
* 0.05 to have a reasonable minimum size. */
|
* 0.05 to have a reasonable minimum size. */
|
||||||
TAILQ_FOREACH (child, &(current->parent->nodes_head), nodes) {
|
TAILQ_FOREACH(child, &(current->parent->nodes_head), nodes) {
|
||||||
if (child == current)
|
if (child == current)
|
||||||
continue;
|
continue;
|
||||||
if (!definitelyGreaterThan(child->percent - subtract_percent, 0.05, DBL_EPSILON)) {
|
if (!definitelyGreaterThan(child->percent - subtract_percent, 0.05, DBL_EPSILON)) {
|
||||||
@ -758,7 +758,7 @@ static bool cmd_resize_tiling_width_height(I3_CMD, Con *current, char *way, char
|
|||||||
current->percent += ((double)ppt / 100.0);
|
current->percent += ((double)ppt / 100.0);
|
||||||
LOG("current->percent after = %f\n", current->percent);
|
LOG("current->percent after = %f\n", current->percent);
|
||||||
|
|
||||||
TAILQ_FOREACH (child, &(current->parent->nodes_head), nodes) {
|
TAILQ_FOREACH(child, &(current->parent->nodes_head), nodes) {
|
||||||
if (child == current)
|
if (child == current)
|
||||||
continue;
|
continue;
|
||||||
child->percent -= subtract_percent;
|
child->percent -= subtract_percent;
|
||||||
@ -786,7 +786,7 @@ void cmd_resize(I3_CMD, char *way, char *direction, char *resize_px, char *resiz
|
|||||||
HANDLE_EMPTY_MATCH;
|
HANDLE_EMPTY_MATCH;
|
||||||
|
|
||||||
owindow *current;
|
owindow *current;
|
||||||
TAILQ_FOREACH (current, &owindows, owindows) {
|
TAILQ_FOREACH(current, &owindows, owindows) {
|
||||||
/* Don't handle dock windows (issue #1201) */
|
/* Don't handle dock windows (issue #1201) */
|
||||||
if (current->con->window && current->con->window->dock) {
|
if (current->con->window && current->con->window->dock) {
|
||||||
DLOG("This is a dock window. Not resizing (con = %p)\n)", current->con);
|
DLOG("This is a dock window. Not resizing (con = %p)\n)", current->con);
|
||||||
@ -823,7 +823,7 @@ void cmd_border(I3_CMD, char *border_style_str, char *border_width) {
|
|||||||
|
|
||||||
HANDLE_EMPTY_MATCH;
|
HANDLE_EMPTY_MATCH;
|
||||||
|
|
||||||
TAILQ_FOREACH (current, &owindows, owindows) {
|
TAILQ_FOREACH(current, &owindows, owindows) {
|
||||||
DLOG("matching: %p / %s\n", current->con, current->con->name);
|
DLOG("matching: %p / %s\n", current->con, current->con->name);
|
||||||
int border_style = current->con->border_style;
|
int border_style = current->con->border_style;
|
||||||
char *end;
|
char *end;
|
||||||
@ -967,9 +967,9 @@ void cmd_workspace_number(I3_CMD, char *which) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TAILQ_FOREACH (output, &(croot->nodes_head), nodes)
|
TAILQ_FOREACH(output, &(croot->nodes_head), nodes)
|
||||||
GREP_FIRST(workspace, output_get_content(output),
|
GREP_FIRST(workspace, output_get_content(output),
|
||||||
child->num == parsed_num);
|
child->num == parsed_num);
|
||||||
|
|
||||||
if (!workspace) {
|
if (!workspace) {
|
||||||
LOG("There is no workspace with number %ld, creating a new one.\n", parsed_num);
|
LOG("There is no workspace with number %ld, creating a new one.\n", parsed_num);
|
||||||
@ -1028,7 +1028,7 @@ void cmd_mark(I3_CMD, char *mark) {
|
|||||||
DLOG("Clearing all windows which have that mark first\n");
|
DLOG("Clearing all windows which have that mark first\n");
|
||||||
|
|
||||||
Con *con;
|
Con *con;
|
||||||
TAILQ_FOREACH (con, &all_cons, all_cons) {
|
TAILQ_FOREACH(con, &all_cons, all_cons) {
|
||||||
if (con->mark && strcmp(con->mark, mark) == 0)
|
if (con->mark && strcmp(con->mark, mark) == 0)
|
||||||
FREE(con->mark);
|
FREE(con->mark);
|
||||||
}
|
}
|
||||||
@ -1038,7 +1038,7 @@ void cmd_mark(I3_CMD, char *mark) {
|
|||||||
|
|
||||||
HANDLE_EMPTY_MATCH;
|
HANDLE_EMPTY_MATCH;
|
||||||
|
|
||||||
TAILQ_FOREACH (current, &owindows, owindows) {
|
TAILQ_FOREACH(current, &owindows, owindows) {
|
||||||
DLOG("matching: %p / %s\n", current->con, current->con->name);
|
DLOG("matching: %p / %s\n", current->con, current->con->name);
|
||||||
current->con->mark = sstrdup(mark);
|
current->con->mark = sstrdup(mark);
|
||||||
}
|
}
|
||||||
@ -1055,13 +1055,13 @@ void cmd_mark(I3_CMD, char *mark) {
|
|||||||
void cmd_unmark(I3_CMD, char *mark) {
|
void cmd_unmark(I3_CMD, char *mark) {
|
||||||
if (mark == NULL) {
|
if (mark == NULL) {
|
||||||
Con *con;
|
Con *con;
|
||||||
TAILQ_FOREACH (con, &all_cons, all_cons) {
|
TAILQ_FOREACH(con, &all_cons, all_cons) {
|
||||||
FREE(con->mark);
|
FREE(con->mark);
|
||||||
}
|
}
|
||||||
DLOG("removed all window marks");
|
DLOG("removed all window marks");
|
||||||
} else {
|
} else {
|
||||||
Con *con;
|
Con *con;
|
||||||
TAILQ_FOREACH (con, &all_cons, all_cons) {
|
TAILQ_FOREACH(con, &all_cons, all_cons) {
|
||||||
if (con->mark && strcmp(con->mark, mark) == 0)
|
if (con->mark && strcmp(con->mark, mark) == 0)
|
||||||
FREE(con->mark);
|
FREE(con->mark);
|
||||||
}
|
}
|
||||||
@ -1101,8 +1101,8 @@ void cmd_move_con_to_output(I3_CMD, char *name) {
|
|||||||
Output *output;
|
Output *output;
|
||||||
|
|
||||||
// TODO: fix the handling of criteria
|
// TODO: fix the handling of criteria
|
||||||
TAILQ_FOREACH (current, &owindows, owindows)
|
TAILQ_FOREACH(current, &owindows, owindows)
|
||||||
current_output = get_output_of_con(current->con);
|
current_output = get_output_of_con(current->con);
|
||||||
|
|
||||||
assert(current_output != NULL);
|
assert(current_output != NULL);
|
||||||
|
|
||||||
@ -1132,7 +1132,7 @@ void cmd_move_con_to_output(I3_CMD, char *name) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TAILQ_FOREACH (current, &owindows, owindows) {
|
TAILQ_FOREACH(current, &owindows, owindows) {
|
||||||
DLOG("matching: %p / %s\n", current->con, current->con->name);
|
DLOG("matching: %p / %s\n", current->con, current->con->name);
|
||||||
con_move_to_workspace(current->con, ws, true, false);
|
con_move_to_workspace(current->con, ws, true, false);
|
||||||
}
|
}
|
||||||
@ -1153,7 +1153,7 @@ void cmd_floating(I3_CMD, char *floating_mode) {
|
|||||||
|
|
||||||
HANDLE_EMPTY_MATCH;
|
HANDLE_EMPTY_MATCH;
|
||||||
|
|
||||||
TAILQ_FOREACH (current, &owindows, owindows) {
|
TAILQ_FOREACH(current, &owindows, owindows) {
|
||||||
DLOG("matching: %p / %s\n", current->con, current->con->name);
|
DLOG("matching: %p / %s\n", current->con, current->con->name);
|
||||||
if (strcmp(floating_mode, "toggle") == 0) {
|
if (strcmp(floating_mode, "toggle") == 0) {
|
||||||
DLOG("should toggle mode\n");
|
DLOG("should toggle mode\n");
|
||||||
@ -1183,7 +1183,7 @@ void cmd_move_workspace_to_output(I3_CMD, char *name) {
|
|||||||
HANDLE_EMPTY_MATCH;
|
HANDLE_EMPTY_MATCH;
|
||||||
|
|
||||||
owindow *current;
|
owindow *current;
|
||||||
TAILQ_FOREACH (current, &owindows, owindows) {
|
TAILQ_FOREACH(current, &owindows, owindows) {
|
||||||
Output *current_output = get_output_of_con(current->con);
|
Output *current_output = get_output_of_con(current->con);
|
||||||
if (!current_output) {
|
if (!current_output) {
|
||||||
ELOG("Cannot get current output. This is a bug in i3.\n");
|
ELOG("Cannot get current output. This is a bug in i3.\n");
|
||||||
@ -1213,15 +1213,15 @@ void cmd_move_workspace_to_output(I3_CMD, char *name) {
|
|||||||
/* check if we can find a workspace assigned to this output */
|
/* check if we can find a workspace assigned to this output */
|
||||||
bool used_assignment = false;
|
bool used_assignment = false;
|
||||||
struct Workspace_Assignment *assignment;
|
struct Workspace_Assignment *assignment;
|
||||||
TAILQ_FOREACH (assignment, &ws_assignments, ws_assignments) {
|
TAILQ_FOREACH(assignment, &ws_assignments, ws_assignments) {
|
||||||
if (strcmp(assignment->output, current_output->name) != 0)
|
if (strcmp(assignment->output, current_output->name) != 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* check if this workspace is already attached to the tree */
|
/* check if this workspace is already attached to the tree */
|
||||||
Con *workspace = NULL, *out;
|
Con *workspace = NULL, *out;
|
||||||
TAILQ_FOREACH (out, &(croot->nodes_head), nodes)
|
TAILQ_FOREACH(out, &(croot->nodes_head), nodes)
|
||||||
GREP_FIRST(workspace, output_get_content(out),
|
GREP_FIRST(workspace, output_get_content(out),
|
||||||
!strcasecmp(child->name, assignment->name));
|
!strcasecmp(child->name, assignment->name));
|
||||||
if (workspace != NULL)
|
if (workspace != NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -1256,8 +1256,8 @@ void cmd_move_workspace_to_output(I3_CMD, char *name) {
|
|||||||
|
|
||||||
/* fix the coordinates of the floating containers */
|
/* fix the coordinates of the floating containers */
|
||||||
Con *floating_con;
|
Con *floating_con;
|
||||||
TAILQ_FOREACH (floating_con, &(ws->floating_head), floating_windows)
|
TAILQ_FOREACH(floating_con, &(ws->floating_head), floating_windows)
|
||||||
floating_fix_coordinates(floating_con, &(old_content->rect), &(content->rect));
|
floating_fix_coordinates(floating_con, &(old_content->rect), &(content->rect));
|
||||||
|
|
||||||
ipc_send_event("workspace", I3_IPC_EVENT_WORKSPACE, "{\"change\":\"move\"}");
|
ipc_send_event("workspace", I3_IPC_EVENT_WORKSPACE, "{\"change\":\"move\"}");
|
||||||
if (workspace_was_visible) {
|
if (workspace_was_visible) {
|
||||||
@ -1270,7 +1270,7 @@ void cmd_move_workspace_to_output(I3_CMD, char *name) {
|
|||||||
* focus order/number of other workspaces on the output.
|
* focus order/number of other workspaces on the output.
|
||||||
* Instead, we loop through the available workspaces and only work with
|
* Instead, we loop through the available workspaces and only work with
|
||||||
* previously_visible_ws if we still find it. */
|
* previously_visible_ws if we still find it. */
|
||||||
TAILQ_FOREACH (ws, &(content->nodes_head), nodes) {
|
TAILQ_FOREACH(ws, &(content->nodes_head), nodes) {
|
||||||
if (ws != previously_visible_ws)
|
if (ws != previously_visible_ws)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -1298,7 +1298,7 @@ void cmd_split(I3_CMD, char *direction) {
|
|||||||
if (match_is_empty(current_match))
|
if (match_is_empty(current_match))
|
||||||
tree_split(focused, (direction[0] == 'v' ? VERT : HORIZ));
|
tree_split(focused, (direction[0] == 'v' ? VERT : HORIZ));
|
||||||
else {
|
else {
|
||||||
TAILQ_FOREACH (current, &owindows, owindows) {
|
TAILQ_FOREACH(current, &owindows, owindows) {
|
||||||
DLOG("matching: %p / %s\n", current->con, current->con->name);
|
DLOG("matching: %p / %s\n", current->con, current->con->name);
|
||||||
tree_split(current->con, (direction[0] == 'v' ? VERT : HORIZ));
|
tree_split(current->con, (direction[0] == 'v' ? VERT : HORIZ));
|
||||||
}
|
}
|
||||||
@ -1335,7 +1335,7 @@ void cmd_kill(I3_CMD, char *kill_mode_str) {
|
|||||||
if (match_is_empty(current_match))
|
if (match_is_empty(current_match))
|
||||||
tree_close_con(kill_mode);
|
tree_close_con(kill_mode);
|
||||||
else {
|
else {
|
||||||
TAILQ_FOREACH (current, &owindows, owindows) {
|
TAILQ_FOREACH(current, &owindows, owindows) {
|
||||||
DLOG("matching: %p / %s\n", current->con, current->con->name);
|
DLOG("matching: %p / %s\n", current->con, current->con->name);
|
||||||
tree_close(current->con, kill_mode, false, false);
|
tree_close(current->con, kill_mode, false, false);
|
||||||
}
|
}
|
||||||
@ -1403,7 +1403,7 @@ void cmd_focus_window_mode(I3_CMD, char *window_mode) {
|
|||||||
else
|
else
|
||||||
window_mode = "floating";
|
window_mode = "floating";
|
||||||
}
|
}
|
||||||
TAILQ_FOREACH (current, &(ws->focus_head), focused) {
|
TAILQ_FOREACH(current, &(ws->focus_head), focused) {
|
||||||
if ((strcmp(window_mode, "floating") == 0 && current->type != CT_FLOATING_CON) ||
|
if ((strcmp(window_mode, "floating") == 0 && current->type != CT_FLOATING_CON) ||
|
||||||
(strcmp(window_mode, "tiling") == 0 && current->type == CT_FLOATING_CON))
|
(strcmp(window_mode, "tiling") == 0 && current->type == CT_FLOATING_CON))
|
||||||
continue;
|
continue;
|
||||||
@ -1465,7 +1465,7 @@ void cmd_focus(I3_CMD) {
|
|||||||
Con *__i3_scratch = workspace_get("__i3_scratch", NULL);
|
Con *__i3_scratch = workspace_get("__i3_scratch", NULL);
|
||||||
int count = 0;
|
int count = 0;
|
||||||
owindow *current;
|
owindow *current;
|
||||||
TAILQ_FOREACH (current, &owindows, owindows) {
|
TAILQ_FOREACH(current, &owindows, owindows) {
|
||||||
Con *ws = con_get_workspace(current->con);
|
Con *ws = con_get_workspace(current->con);
|
||||||
/* If no workspace could be found, this was a dock window.
|
/* If no workspace could be found, this was a dock window.
|
||||||
* Just skip it, you cannot focus dock windows. */
|
* Just skip it, you cannot focus dock windows. */
|
||||||
@ -1534,7 +1534,7 @@ void cmd_fullscreen(I3_CMD, char *fullscreen_mode) {
|
|||||||
|
|
||||||
HANDLE_EMPTY_MATCH;
|
HANDLE_EMPTY_MATCH;
|
||||||
|
|
||||||
TAILQ_FOREACH (current, &owindows, owindows) {
|
TAILQ_FOREACH(current, &owindows, owindows) {
|
||||||
DLOG("matching: %p / %s\n", current->con, current->con->name);
|
DLOG("matching: %p / %s\n", current->con, current->con->name);
|
||||||
con_toggle_fullscreen(current->con, (strcmp(fullscreen_mode, "global") == 0 ? CF_GLOBAL : CF_OUTPUT));
|
con_toggle_fullscreen(current->con, (strcmp(fullscreen_mode, "global") == 0 ? CF_GLOBAL : CF_OUTPUT));
|
||||||
}
|
}
|
||||||
@ -1607,7 +1607,7 @@ void cmd_layout(I3_CMD, char *layout_str) {
|
|||||||
if (match_is_empty(current_match))
|
if (match_is_empty(current_match))
|
||||||
con_set_layout(focused, layout);
|
con_set_layout(focused, layout);
|
||||||
else {
|
else {
|
||||||
TAILQ_FOREACH (current, &owindows, owindows) {
|
TAILQ_FOREACH(current, &owindows, owindows) {
|
||||||
DLOG("matching: %p / %s\n", current->con, current->con->name);
|
DLOG("matching: %p / %s\n", current->con, current->con->name);
|
||||||
con_set_layout(current->con, layout);
|
con_set_layout(current->con, layout);
|
||||||
}
|
}
|
||||||
@ -1634,7 +1634,7 @@ void cmd_layout_toggle(I3_CMD, char *toggle_mode) {
|
|||||||
if (match_is_empty(current_match))
|
if (match_is_empty(current_match))
|
||||||
con_toggle_layout(focused, toggle_mode);
|
con_toggle_layout(focused, toggle_mode);
|
||||||
else {
|
else {
|
||||||
TAILQ_FOREACH (current, &owindows, owindows) {
|
TAILQ_FOREACH(current, &owindows, owindows) {
|
||||||
DLOG("matching: %p / %s\n", current->con, current->con->name);
|
DLOG("matching: %p / %s\n", current->con, current->con->name);
|
||||||
con_toggle_layout(current->con, toggle_mode);
|
con_toggle_layout(current->con, toggle_mode);
|
||||||
}
|
}
|
||||||
@ -1733,8 +1733,8 @@ void cmd_focus_output(I3_CMD, char *name) {
|
|||||||
Output *current_output = NULL;
|
Output *current_output = NULL;
|
||||||
Output *output;
|
Output *output;
|
||||||
|
|
||||||
TAILQ_FOREACH (current, &owindows, owindows)
|
TAILQ_FOREACH(current, &owindows, owindows)
|
||||||
current_output = get_output_of_con(current->con);
|
current_output = get_output_of_con(current->con);
|
||||||
assert(current_output != NULL);
|
assert(current_output != NULL);
|
||||||
|
|
||||||
output = get_output_from_string(current_output, name);
|
output = get_output_from_string(current_output, name);
|
||||||
@ -1844,7 +1844,7 @@ void cmd_move_scratchpad(I3_CMD) {
|
|||||||
|
|
||||||
HANDLE_EMPTY_MATCH;
|
HANDLE_EMPTY_MATCH;
|
||||||
|
|
||||||
TAILQ_FOREACH (current, &owindows, owindows) {
|
TAILQ_FOREACH(current, &owindows, owindows) {
|
||||||
DLOG("matching: %p / %s\n", current->con, current->con->name);
|
DLOG("matching: %p / %s\n", current->con, current->con->name);
|
||||||
scratchpad_move(current->con);
|
scratchpad_move(current->con);
|
||||||
}
|
}
|
||||||
@ -1865,7 +1865,7 @@ void cmd_scratchpad_show(I3_CMD) {
|
|||||||
if (match_is_empty(current_match)) {
|
if (match_is_empty(current_match)) {
|
||||||
scratchpad_show(NULL);
|
scratchpad_show(NULL);
|
||||||
} else {
|
} else {
|
||||||
TAILQ_FOREACH (current, &owindows, owindows) {
|
TAILQ_FOREACH(current, &owindows, owindows) {
|
||||||
DLOG("matching: %p / %s\n", current->con, current->con->name);
|
DLOG("matching: %p / %s\n", current->con, current->con->name);
|
||||||
scratchpad_show(current->con);
|
scratchpad_show(current->con);
|
||||||
}
|
}
|
||||||
@ -1894,9 +1894,9 @@ void cmd_rename_workspace(I3_CMD, char *old_name, char *new_name) {
|
|||||||
|
|
||||||
Con *output, *workspace = NULL;
|
Con *output, *workspace = NULL;
|
||||||
if (old_name) {
|
if (old_name) {
|
||||||
TAILQ_FOREACH (output, &(croot->nodes_head), nodes)
|
TAILQ_FOREACH(output, &(croot->nodes_head), nodes)
|
||||||
GREP_FIRST(workspace, output_get_content(output),
|
GREP_FIRST(workspace, output_get_content(output),
|
||||||
!strcasecmp(child->name, old_name));
|
!strcasecmp(child->name, old_name));
|
||||||
} else {
|
} else {
|
||||||
workspace = con_get_workspace(focused);
|
workspace = con_get_workspace(focused);
|
||||||
}
|
}
|
||||||
@ -1910,9 +1910,9 @@ void cmd_rename_workspace(I3_CMD, char *old_name, char *new_name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Con *check_dest = NULL;
|
Con *check_dest = NULL;
|
||||||
TAILQ_FOREACH (output, &(croot->nodes_head), nodes)
|
TAILQ_FOREACH(output, &(croot->nodes_head), nodes)
|
||||||
GREP_FIRST(check_dest, output_get_content(output),
|
GREP_FIRST(check_dest, output_get_content(output),
|
||||||
!strcasecmp(child->name, new_name));
|
!strcasecmp(child->name, new_name));
|
||||||
|
|
||||||
if (check_dest != NULL) {
|
if (check_dest != NULL) {
|
||||||
// TODO: we should include the new workspace name here and use yajl for
|
// TODO: we should include the new workspace name here and use yajl for
|
||||||
@ -1972,7 +1972,7 @@ bool cmd_bar_mode(char *bar_mode, char *bar_id) {
|
|||||||
|
|
||||||
bool changed_sth = false;
|
bool changed_sth = false;
|
||||||
Barconfig *current = NULL;
|
Barconfig *current = NULL;
|
||||||
TAILQ_FOREACH (current, &barconfigs, configs) {
|
TAILQ_FOREACH(current, &barconfigs, configs) {
|
||||||
if (bar_id && strcmp(current->id, bar_id) != 0)
|
if (bar_id && strcmp(current->id, bar_id) != 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -2015,7 +2015,7 @@ bool cmd_bar_hidden_state(char *bar_hidden_state, char *bar_id) {
|
|||||||
|
|
||||||
bool changed_sth = false;
|
bool changed_sth = false;
|
||||||
Barconfig *current = NULL;
|
Barconfig *current = NULL;
|
||||||
TAILQ_FOREACH (current, &barconfigs, configs) {
|
TAILQ_FOREACH(current, &barconfigs, configs) {
|
||||||
if (bar_id && strcmp(current->id, bar_id) != 0)
|
if (bar_id && strcmp(current->id, bar_id) != 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
58
src/con.c
58
src/con.c
@ -142,7 +142,7 @@ void con_attach(Con *con, Con *parent, bool ignore_focus) {
|
|||||||
} else {
|
} else {
|
||||||
if (!ignore_focus) {
|
if (!ignore_focus) {
|
||||||
/* Get the first tiling container in focus stack */
|
/* Get the first tiling container in focus stack */
|
||||||
TAILQ_FOREACH (loop, &(parent->focus_head), focused) {
|
TAILQ_FOREACH(loop, &(parent->focus_head), focused) {
|
||||||
if (loop->type == CT_FLOATING_CON)
|
if (loop->type == CT_FLOATING_CON)
|
||||||
continue;
|
continue;
|
||||||
current = loop;
|
current = loop;
|
||||||
@ -388,13 +388,13 @@ Con *con_get_fullscreen_con(Con *con, fullscreen_mode_t fullscreen_mode) {
|
|||||||
TAILQ_REMOVE(&bfs_head, entry, entries);
|
TAILQ_REMOVE(&bfs_head, entry, entries);
|
||||||
free(entry);
|
free(entry);
|
||||||
|
|
||||||
TAILQ_FOREACH (child, &(current->nodes_head), nodes) {
|
TAILQ_FOREACH(child, &(current->nodes_head), nodes) {
|
||||||
entry = smalloc(sizeof(struct bfs_entry));
|
entry = smalloc(sizeof(struct bfs_entry));
|
||||||
entry->con = child;
|
entry->con = child;
|
||||||
TAILQ_INSERT_TAIL(&bfs_head, entry, entries);
|
TAILQ_INSERT_TAIL(&bfs_head, entry, entries);
|
||||||
}
|
}
|
||||||
|
|
||||||
TAILQ_FOREACH (child, &(current->floating_head), floating_windows) {
|
TAILQ_FOREACH(child, &(current->floating_head), floating_windows) {
|
||||||
entry = smalloc(sizeof(struct bfs_entry));
|
entry = smalloc(sizeof(struct bfs_entry));
|
||||||
entry->con = child;
|
entry->con = child;
|
||||||
TAILQ_INSERT_TAIL(&bfs_head, entry, entries);
|
TAILQ_INSERT_TAIL(&bfs_head, entry, entries);
|
||||||
@ -460,9 +460,9 @@ bool con_inside_focused(Con *con) {
|
|||||||
*/
|
*/
|
||||||
Con *con_by_window_id(xcb_window_t window) {
|
Con *con_by_window_id(xcb_window_t window) {
|
||||||
Con *con;
|
Con *con;
|
||||||
TAILQ_FOREACH (con, &all_cons, all_cons)
|
TAILQ_FOREACH(con, &all_cons, all_cons)
|
||||||
if (con->window != NULL && con->window->id == window)
|
if (con->window != NULL && con->window->id == window)
|
||||||
return con;
|
return con;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -473,9 +473,9 @@ Con *con_by_window_id(xcb_window_t window) {
|
|||||||
*/
|
*/
|
||||||
Con *con_by_frame_id(xcb_window_t frame) {
|
Con *con_by_frame_id(xcb_window_t frame) {
|
||||||
Con *con;
|
Con *con;
|
||||||
TAILQ_FOREACH (con, &all_cons, all_cons)
|
TAILQ_FOREACH(con, &all_cons, all_cons)
|
||||||
if (con->frame == frame)
|
if (con->frame == frame)
|
||||||
return con;
|
return con;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -490,8 +490,8 @@ Con *con_for_window(Con *con, i3Window *window, Match **store_match) {
|
|||||||
//DLOG("searching con for window %p starting at con %p\n", window, con);
|
//DLOG("searching con for window %p starting at con %p\n", window, con);
|
||||||
//DLOG("class == %s\n", window->class_class);
|
//DLOG("class == %s\n", window->class_class);
|
||||||
|
|
||||||
TAILQ_FOREACH (child, &(con->nodes_head), nodes) {
|
TAILQ_FOREACH(child, &(con->nodes_head), nodes) {
|
||||||
TAILQ_FOREACH (match, &(child->swallow_head), matches) {
|
TAILQ_FOREACH(match, &(child->swallow_head), matches) {
|
||||||
if (!match_matches_window(match, window))
|
if (!match_matches_window(match, window))
|
||||||
continue;
|
continue;
|
||||||
if (store_match != NULL)
|
if (store_match != NULL)
|
||||||
@ -503,8 +503,8 @@ Con *con_for_window(Con *con, i3Window *window, Match **store_match) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
TAILQ_FOREACH (child, &(con->floating_head), floating_windows) {
|
TAILQ_FOREACH(child, &(con->floating_head), floating_windows) {
|
||||||
TAILQ_FOREACH (match, &(child->swallow_head), matches) {
|
TAILQ_FOREACH(match, &(child->swallow_head), matches) {
|
||||||
if (!match_matches_window(match, window))
|
if (!match_matches_window(match, window))
|
||||||
continue;
|
continue;
|
||||||
if (store_match != NULL)
|
if (store_match != NULL)
|
||||||
@ -527,8 +527,8 @@ int con_num_children(Con *con) {
|
|||||||
Con *child;
|
Con *child;
|
||||||
int children = 0;
|
int children = 0;
|
||||||
|
|
||||||
TAILQ_FOREACH (child, &(con->nodes_head), nodes)
|
TAILQ_FOREACH(child, &(con->nodes_head), nodes)
|
||||||
children++;
|
children++;
|
||||||
|
|
||||||
return children;
|
return children;
|
||||||
}
|
}
|
||||||
@ -547,7 +547,7 @@ void con_fix_percent(Con *con) {
|
|||||||
// with a percentage set we have
|
// with a percentage set we have
|
||||||
double total = 0.0;
|
double total = 0.0;
|
||||||
int children_with_percent = 0;
|
int children_with_percent = 0;
|
||||||
TAILQ_FOREACH (child, &(con->nodes_head), nodes) {
|
TAILQ_FOREACH(child, &(con->nodes_head), nodes) {
|
||||||
if (child->percent > 0.0) {
|
if (child->percent > 0.0) {
|
||||||
total += child->percent;
|
total += child->percent;
|
||||||
++children_with_percent;
|
++children_with_percent;
|
||||||
@ -557,7 +557,7 @@ void con_fix_percent(Con *con) {
|
|||||||
// if there were children without a percentage set, set to a value that
|
// if there were children without a percentage set, set to a value that
|
||||||
// will make those children proportional to all others
|
// will make those children proportional to all others
|
||||||
if (children_with_percent != children) {
|
if (children_with_percent != children) {
|
||||||
TAILQ_FOREACH (child, &(con->nodes_head), nodes) {
|
TAILQ_FOREACH(child, &(con->nodes_head), nodes) {
|
||||||
if (child->percent <= 0.0) {
|
if (child->percent <= 0.0) {
|
||||||
if (children_with_percent == 0)
|
if (children_with_percent == 0)
|
||||||
total += (child->percent = 1.0);
|
total += (child->percent = 1.0);
|
||||||
@ -570,11 +570,11 @@ void con_fix_percent(Con *con) {
|
|||||||
// if we got a zero, just distribute the space equally, otherwise
|
// if we got a zero, just distribute the space equally, otherwise
|
||||||
// distribute according to the proportions we got
|
// distribute according to the proportions we got
|
||||||
if (total == 0.0) {
|
if (total == 0.0) {
|
||||||
TAILQ_FOREACH (child, &(con->nodes_head), nodes)
|
TAILQ_FOREACH(child, &(con->nodes_head), nodes)
|
||||||
child->percent = 1.0 / children;
|
child->percent = 1.0 / children;
|
||||||
} else if (total != 1.0) {
|
} else if (total != 1.0) {
|
||||||
TAILQ_FOREACH (child, &(con->nodes_head), nodes)
|
TAILQ_FOREACH(child, &(con->nodes_head), nodes)
|
||||||
child->percent /= total;
|
child->percent /= total;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -807,7 +807,7 @@ void con_move_to_workspace(Con *con, Con *workspace, bool fix_coordinates, bool
|
|||||||
|
|
||||||
if (!con_is_leaf(con)) {
|
if (!con_is_leaf(con)) {
|
||||||
Con *child;
|
Con *child;
|
||||||
TAILQ_FOREACH (child, &(con->nodes_head), nodes) {
|
TAILQ_FOREACH(child, &(con->nodes_head), nodes) {
|
||||||
if (!child->window)
|
if (!child->window)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -1003,7 +1003,7 @@ Con *con_descend_tiling_focused(Con *con) {
|
|||||||
return next;
|
return next;
|
||||||
do {
|
do {
|
||||||
before = next;
|
before = next;
|
||||||
TAILQ_FOREACH (child, &(next->focus_head), focused) {
|
TAILQ_FOREACH(child, &(next->focus_head), focused) {
|
||||||
if (child->type == CT_FLOATING_CON)
|
if (child->type == CT_FLOATING_CON)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -1038,7 +1038,7 @@ Con *con_descend_direction(Con *con, direction_t direction) {
|
|||||||
/* Wrong orientation. We use the last focused con. Within that con,
|
/* Wrong orientation. We use the last focused con. Within that con,
|
||||||
* we recurse to chose the left/right con or at least the last
|
* we recurse to chose the left/right con or at least the last
|
||||||
* focused one. */
|
* focused one. */
|
||||||
TAILQ_FOREACH (current, &(con->focus_head), focused) {
|
TAILQ_FOREACH(current, &(con->focus_head), focused) {
|
||||||
if (current->type != CT_FLOATING_CON) {
|
if (current->type != CT_FLOATING_CON) {
|
||||||
most = current;
|
most = current;
|
||||||
break;
|
break;
|
||||||
@ -1063,7 +1063,7 @@ Con *con_descend_direction(Con *con, direction_t direction) {
|
|||||||
/* Wrong orientation. We use the last focused con. Within that con,
|
/* Wrong orientation. We use the last focused con. Within that con,
|
||||||
* we recurse to chose the top/bottom con or at least the last
|
* we recurse to chose the top/bottom con or at least the last
|
||||||
* focused one. */
|
* focused one. */
|
||||||
TAILQ_FOREACH (current, &(con->focus_head), focused) {
|
TAILQ_FOREACH(current, &(con->focus_head), focused) {
|
||||||
if (current->type != CT_FLOATING_CON) {
|
if (current->type != CT_FLOATING_CON) {
|
||||||
most = current;
|
most = current;
|
||||||
break;
|
break;
|
||||||
@ -1426,7 +1426,7 @@ Rect con_minimum_size(Con *con) {
|
|||||||
if (con->layout == L_STACKED || con->layout == L_TABBED) {
|
if (con->layout == L_STACKED || con->layout == L_TABBED) {
|
||||||
uint32_t max_width = 0, max_height = 0, deco_height = 0;
|
uint32_t max_width = 0, max_height = 0, deco_height = 0;
|
||||||
Con *child;
|
Con *child;
|
||||||
TAILQ_FOREACH (child, &(con->nodes_head), nodes) {
|
TAILQ_FOREACH(child, &(con->nodes_head), nodes) {
|
||||||
Rect min = con_minimum_size(child);
|
Rect min = con_minimum_size(child);
|
||||||
deco_height += child->deco_rect.height;
|
deco_height += child->deco_rect.height;
|
||||||
max_width = max(max_width, min.width);
|
max_width = max(max_width, min.width);
|
||||||
@ -1443,7 +1443,7 @@ Rect con_minimum_size(Con *con) {
|
|||||||
if (con_is_split(con)) {
|
if (con_is_split(con)) {
|
||||||
uint32_t width = 0, height = 0;
|
uint32_t width = 0, height = 0;
|
||||||
Con *child;
|
Con *child;
|
||||||
TAILQ_FOREACH (child, &(con->nodes_head), nodes) {
|
TAILQ_FOREACH(child, &(con->nodes_head), nodes) {
|
||||||
Rect min = con_minimum_size(child);
|
Rect min = con_minimum_size(child);
|
||||||
if (con->layout == L_SPLITH) {
|
if (con->layout == L_SPLITH) {
|
||||||
width += min.width;
|
width += min.width;
|
||||||
@ -1538,7 +1538,7 @@ bool con_has_urgent_child(Con *con) {
|
|||||||
|
|
||||||
/* We are not interested in floating windows since they can only be
|
/* We are not interested in floating windows since they can only be
|
||||||
* attached to a workspace → nodes_head instead of focus_head */
|
* attached to a workspace → nodes_head instead of focus_head */
|
||||||
TAILQ_FOREACH (child, &(con->nodes_head), nodes) {
|
TAILQ_FOREACH(child, &(con->nodes_head), nodes) {
|
||||||
if (con_has_urgent_child(child))
|
if (con_has_urgent_child(child))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1651,7 +1651,7 @@ char *con_get_tree_representation(Con *con) {
|
|||||||
|
|
||||||
/* 2) append representation of children */
|
/* 2) append representation of children */
|
||||||
Con *child;
|
Con *child;
|
||||||
TAILQ_FOREACH (child, &(con->nodes_head), nodes) {
|
TAILQ_FOREACH(child, &(con->nodes_head), nodes) {
|
||||||
char *child_txt = con_get_tree_representation(child);
|
char *child_txt = con_get_tree_representation(child);
|
||||||
|
|
||||||
char *tmp_buf;
|
char *tmp_buf;
|
||||||
|
@ -36,7 +36,7 @@ void ungrab_all_keys(xcb_connection_t *conn) {
|
|||||||
*/
|
*/
|
||||||
void update_barconfig() {
|
void update_barconfig() {
|
||||||
Barconfig *current;
|
Barconfig *current;
|
||||||
TAILQ_FOREACH (current, &barconfigs, configs) {
|
TAILQ_FOREACH(current, &barconfigs, configs) {
|
||||||
ipc_send_barconfig_update_event(current);
|
ipc_send_barconfig_update_event(current);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -204,8 +204,8 @@ void load_configuration(xcb_connection_t *conn, const char *override_configpath,
|
|||||||
|
|
||||||
/* Invalidate pixmap caches in case font or colors changed */
|
/* Invalidate pixmap caches in case font or colors changed */
|
||||||
Con *con;
|
Con *con;
|
||||||
TAILQ_FOREACH (con, &all_cons, all_cons)
|
TAILQ_FOREACH(con, &all_cons, all_cons)
|
||||||
FREE(con->deco_render_params);
|
FREE(con->deco_render_params);
|
||||||
|
|
||||||
/* Get rid of the current font */
|
/* Get rid of the current font */
|
||||||
free_font();
|
free_font();
|
||||||
|
@ -334,7 +334,7 @@ CFGFUN(workspace, const char *workspace, const char *output) {
|
|||||||
* outputs */
|
* outputs */
|
||||||
struct Workspace_Assignment *assignment;
|
struct Workspace_Assignment *assignment;
|
||||||
bool duplicate = false;
|
bool duplicate = false;
|
||||||
TAILQ_FOREACH (assignment, &ws_assignments, ws_assignments) {
|
TAILQ_FOREACH(assignment, &ws_assignments, ws_assignments) {
|
||||||
if (strcasecmp(assignment->name, workspace) == 0) {
|
if (strcasecmp(assignment->name, workspace) == 0) {
|
||||||
ELOG("You have a duplicate workspace assignment for workspace \"%s\"\n",
|
ELOG("You have a duplicate workspace assignment for workspace \"%s\"\n",
|
||||||
workspace);
|
workspace);
|
||||||
|
@ -917,7 +917,7 @@ void parse_file(const char *f) {
|
|||||||
* variables (otherwise we will count them twice, which is bad when
|
* variables (otherwise we will count them twice, which is bad when
|
||||||
* 'extra' is negative) */
|
* 'extra' is negative) */
|
||||||
char *bufcopy = sstrdup(buf);
|
char *bufcopy = sstrdup(buf);
|
||||||
SLIST_FOREACH (current, &variables, variables) {
|
SLIST_FOREACH(current, &variables, variables) {
|
||||||
int extra = (strlen(current->value) - strlen(current->key));
|
int extra = (strlen(current->value) - strlen(current->key));
|
||||||
char *next;
|
char *next;
|
||||||
for (next = bufcopy;
|
for (next = bufcopy;
|
||||||
@ -937,11 +937,11 @@ void parse_file(const char *f) {
|
|||||||
destwalk = new;
|
destwalk = new;
|
||||||
while (walk < (buf + stbuf.st_size)) {
|
while (walk < (buf + stbuf.st_size)) {
|
||||||
/* Find the next variable */
|
/* Find the next variable */
|
||||||
SLIST_FOREACH (current, &variables, variables)
|
SLIST_FOREACH(current, &variables, variables)
|
||||||
current->next_match = strcasestr(walk, current->key);
|
current->next_match = strcasestr(walk, current->key);
|
||||||
nearest = NULL;
|
nearest = NULL;
|
||||||
int distance = stbuf.st_size;
|
int distance = stbuf.st_size;
|
||||||
SLIST_FOREACH (current, &variables, variables) {
|
SLIST_FOREACH(current, &variables, variables) {
|
||||||
if (current->next_match == NULL)
|
if (current->next_match == NULL)
|
||||||
continue;
|
continue;
|
||||||
if ((current->next_match - walk) < distance) {
|
if ((current->next_match - walk) < distance) {
|
||||||
|
@ -24,9 +24,9 @@ void ewmh_update_current_desktop(void) {
|
|||||||
uint32_t idx = 0;
|
uint32_t idx = 0;
|
||||||
/* We count to get the index of this workspace because named workspaces
|
/* We count to get the index of this workspace because named workspaces
|
||||||
* don’t have the ->num property */
|
* don’t have the ->num property */
|
||||||
TAILQ_FOREACH (output, &(croot->nodes_head), nodes) {
|
TAILQ_FOREACH(output, &(croot->nodes_head), nodes) {
|
||||||
Con *ws;
|
Con *ws;
|
||||||
TAILQ_FOREACH (ws, &(output_get_content(output)->nodes_head), nodes) {
|
TAILQ_FOREACH(ws, &(output_get_content(output)->nodes_head), nodes) {
|
||||||
if (STARTS_WITH(ws->name, "__"))
|
if (STARTS_WITH(ws->name, "__"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -20,9 +20,9 @@ static int num_screens;
|
|||||||
*/
|
*/
|
||||||
static Output *get_screen_at(unsigned int x, unsigned int y) {
|
static Output *get_screen_at(unsigned int x, unsigned int y) {
|
||||||
Output *output;
|
Output *output;
|
||||||
TAILQ_FOREACH (output, &outputs, outputs)
|
TAILQ_FOREACH(output, &outputs, outputs)
|
||||||
if (output->rect.x == x && output->rect.y == y)
|
if (output->rect.x == x && output->rect.y == y)
|
||||||
return output;
|
return output;
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ static Rect total_outputs_dimensions(void) {
|
|||||||
Output *output;
|
Output *output;
|
||||||
/* Use Rect to encapsulate dimensions, ignoring x/y */
|
/* Use Rect to encapsulate dimensions, ignoring x/y */
|
||||||
Rect outputs_dimensions = {0, 0, 0, 0};
|
Rect outputs_dimensions = {0, 0, 0, 0};
|
||||||
TAILQ_FOREACH (output, &outputs, outputs) {
|
TAILQ_FOREACH(output, &outputs, outputs) {
|
||||||
outputs_dimensions.height += output->rect.height;
|
outputs_dimensions.height += output->rect.height;
|
||||||
outputs_dimensions.width += output->rect.width;
|
outputs_dimensions.width += output->rect.width;
|
||||||
}
|
}
|
||||||
@ -205,7 +205,7 @@ void floating_enable(Con *con, bool automatic) {
|
|||||||
if (memcmp(&(nc->rect), &zero, sizeof(Rect)) == 0) {
|
if (memcmp(&(nc->rect), &zero, sizeof(Rect)) == 0) {
|
||||||
DLOG("Geometry not set, combining children\n");
|
DLOG("Geometry not set, combining children\n");
|
||||||
Con *child;
|
Con *child;
|
||||||
TAILQ_FOREACH (child, &(con->nodes_head), nodes) {
|
TAILQ_FOREACH(child, &(con->nodes_head), nodes) {
|
||||||
DLOG("child geometry: %d x %d\n", child->geometry.width, child->geometry.height);
|
DLOG("child geometry: %d x %d\n", child->geometry.width, child->geometry.height);
|
||||||
nc->rect.width += child->geometry.width;
|
nc->rect.width += child->geometry.width;
|
||||||
nc->rect.height = max(nc->rect.height, child->geometry.height);
|
nc->rect.height = max(nc->rect.height, child->geometry.height);
|
||||||
|
@ -62,7 +62,7 @@ bool event_is_ignored(const int sequence, const int response_type) {
|
|||||||
event = SLIST_NEXT(event, ignore_events);
|
event = SLIST_NEXT(event, ignore_events);
|
||||||
}
|
}
|
||||||
|
|
||||||
SLIST_FOREACH (event, &ignore_events, ignore_events) {
|
SLIST_FOREACH(event, &ignore_events, ignore_events) {
|
||||||
if (event->sequence != sequence)
|
if (event->sequence != sequence)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -163,12 +163,12 @@ static void handle_enter_notify(xcb_enter_notify_event_t *event) {
|
|||||||
layout_t layout = (enter_child ? con->parent->layout : con->layout);
|
layout_t layout = (enter_child ? con->parent->layout : con->layout);
|
||||||
if (layout == L_DEFAULT) {
|
if (layout == L_DEFAULT) {
|
||||||
Con *child;
|
Con *child;
|
||||||
TAILQ_FOREACH (child, &(con->nodes_head), nodes)
|
TAILQ_FOREACH(child, &(con->nodes_head), nodes)
|
||||||
if (rect_contains(child->deco_rect, event->event_x, event->event_y)) {
|
if (rect_contains(child->deco_rect, event->event_x, event->event_y)) {
|
||||||
LOG("using child %p / %s instead!\n", child, child->name);
|
LOG("using child %p / %s instead!\n", child, child->name);
|
||||||
con = child;
|
con = child;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
@ -231,7 +231,7 @@ static void handle_motion_notify(xcb_motion_notify_event_t *event) {
|
|||||||
|
|
||||||
/* see over which rect the user is */
|
/* see over which rect the user is */
|
||||||
Con *current;
|
Con *current;
|
||||||
TAILQ_FOREACH (current, &(con->nodes_head), nodes) {
|
TAILQ_FOREACH(current, &(con->nodes_head), nodes) {
|
||||||
if (!rect_contains(current->deco_rect, event->event_x, event->event_y))
|
if (!rect_contains(current->deco_rect, event->event_x, event->event_y))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
30
src/ipc.c
30
src/ipc.c
@ -74,7 +74,7 @@ static bool mkdirp(const char *path) {
|
|||||||
*/
|
*/
|
||||||
void ipc_send_event(const char *event, uint32_t message_type, const char *payload) {
|
void ipc_send_event(const char *event, uint32_t message_type, const char *payload) {
|
||||||
ipc_client *current;
|
ipc_client *current;
|
||||||
TAILQ_FOREACH (current, &all_clients, clients) {
|
TAILQ_FOREACH(current, &all_clients, clients) {
|
||||||
/* see if this client is interested in this event */
|
/* see if this client is interested in this event */
|
||||||
bool interested = false;
|
bool interested = false;
|
||||||
for (int i = 0; i < current->num_events; i++) {
|
for (int i = 0; i < current->num_events; i++) {
|
||||||
@ -344,7 +344,7 @@ void dump_node(yajl_gen gen, struct Con *con, bool inplace_restart) {
|
|||||||
y(array_open);
|
y(array_open);
|
||||||
Con *node;
|
Con *node;
|
||||||
if (con->type != CT_DOCKAREA || !inplace_restart) {
|
if (con->type != CT_DOCKAREA || !inplace_restart) {
|
||||||
TAILQ_FOREACH (node, &(con->nodes_head), nodes) {
|
TAILQ_FOREACH(node, &(con->nodes_head), nodes) {
|
||||||
dump_node(gen, node, inplace_restart);
|
dump_node(gen, node, inplace_restart);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -352,14 +352,14 @@ void dump_node(yajl_gen gen, struct Con *con, bool inplace_restart) {
|
|||||||
|
|
||||||
ystr("floating_nodes");
|
ystr("floating_nodes");
|
||||||
y(array_open);
|
y(array_open);
|
||||||
TAILQ_FOREACH (node, &(con->floating_head), floating_windows) {
|
TAILQ_FOREACH(node, &(con->floating_head), floating_windows) {
|
||||||
dump_node(gen, node, inplace_restart);
|
dump_node(gen, node, inplace_restart);
|
||||||
}
|
}
|
||||||
y(array_close);
|
y(array_close);
|
||||||
|
|
||||||
ystr("focus");
|
ystr("focus");
|
||||||
y(array_open);
|
y(array_open);
|
||||||
TAILQ_FOREACH (node, &(con->focus_head), focused) {
|
TAILQ_FOREACH(node, &(con->focus_head), focused) {
|
||||||
y(integer, (long int)node);
|
y(integer, (long int)node);
|
||||||
}
|
}
|
||||||
y(array_close);
|
y(array_close);
|
||||||
@ -386,7 +386,7 @@ void dump_node(yajl_gen gen, struct Con *con, bool inplace_restart) {
|
|||||||
ystr("swallows");
|
ystr("swallows");
|
||||||
y(array_open);
|
y(array_open);
|
||||||
Match *match;
|
Match *match;
|
||||||
TAILQ_FOREACH (match, &(con->swallow_head), matches) {
|
TAILQ_FOREACH(match, &(con->swallow_head), matches) {
|
||||||
y(map_open);
|
y(map_open);
|
||||||
if (match->dock != -1) {
|
if (match->dock != -1) {
|
||||||
ystr("dock");
|
ystr("dock");
|
||||||
@ -591,11 +591,11 @@ IPC_HANDLER(get_workspaces) {
|
|||||||
Con *focused_ws = con_get_workspace(focused);
|
Con *focused_ws = con_get_workspace(focused);
|
||||||
|
|
||||||
Con *output;
|
Con *output;
|
||||||
TAILQ_FOREACH (output, &(croot->nodes_head), nodes) {
|
TAILQ_FOREACH(output, &(croot->nodes_head), nodes) {
|
||||||
if (con_is_internal(output))
|
if (con_is_internal(output))
|
||||||
continue;
|
continue;
|
||||||
Con *ws;
|
Con *ws;
|
||||||
TAILQ_FOREACH (ws, &(output_get_content(output)->nodes_head), nodes) {
|
TAILQ_FOREACH(ws, &(output_get_content(output)->nodes_head), nodes) {
|
||||||
assert(ws->type == CT_WORKSPACE);
|
assert(ws->type == CT_WORKSPACE);
|
||||||
y(map_open);
|
y(map_open);
|
||||||
|
|
||||||
@ -656,7 +656,7 @@ IPC_HANDLER(get_outputs) {
|
|||||||
y(array_open);
|
y(array_open);
|
||||||
|
|
||||||
Output *output;
|
Output *output;
|
||||||
TAILQ_FOREACH (output, &outputs, outputs) {
|
TAILQ_FOREACH(output, &outputs, outputs) {
|
||||||
y(map_open);
|
y(map_open);
|
||||||
|
|
||||||
ystr("name");
|
ystr("name");
|
||||||
@ -710,9 +710,9 @@ IPC_HANDLER(get_marks) {
|
|||||||
y(array_open);
|
y(array_open);
|
||||||
|
|
||||||
Con *con;
|
Con *con;
|
||||||
TAILQ_FOREACH (con, &all_cons, all_cons)
|
TAILQ_FOREACH(con, &all_cons, all_cons)
|
||||||
if (con->mark != NULL)
|
if (con->mark != NULL)
|
||||||
ystr(con->mark);
|
ystr(con->mark);
|
||||||
|
|
||||||
y(array_close);
|
y(array_close);
|
||||||
|
|
||||||
@ -766,7 +766,7 @@ IPC_HANDLER(get_bar_config) {
|
|||||||
if (message_size == 0) {
|
if (message_size == 0) {
|
||||||
y(array_open);
|
y(array_open);
|
||||||
Barconfig *current;
|
Barconfig *current;
|
||||||
TAILQ_FOREACH (current, &barconfigs, configs) {
|
TAILQ_FOREACH(current, &barconfigs, configs) {
|
||||||
ystr(current->id);
|
ystr(current->id);
|
||||||
}
|
}
|
||||||
y(array_close);
|
y(array_close);
|
||||||
@ -786,7 +786,7 @@ IPC_HANDLER(get_bar_config) {
|
|||||||
strncpy(bar_id, (const char *)message, message_size);
|
strncpy(bar_id, (const char *)message, message_size);
|
||||||
LOG("IPC: looking for config for bar ID \"%s\"\n", bar_id);
|
LOG("IPC: looking for config for bar ID \"%s\"\n", bar_id);
|
||||||
Barconfig *current, *config = NULL;
|
Barconfig *current, *config = NULL;
|
||||||
TAILQ_FOREACH (current, &barconfigs, configs) {
|
TAILQ_FOREACH(current, &barconfigs, configs) {
|
||||||
if (strcmp(current->id, bar_id) != 0)
|
if (strcmp(current->id, bar_id) != 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -852,7 +852,7 @@ IPC_HANDLER(subscribe) {
|
|||||||
ipc_client *current, *client = NULL;
|
ipc_client *current, *client = NULL;
|
||||||
|
|
||||||
/* Search the ipc_client structure for this connection */
|
/* Search the ipc_client structure for this connection */
|
||||||
TAILQ_FOREACH (current, &all_clients, clients) {
|
TAILQ_FOREACH(current, &all_clients, clients) {
|
||||||
if (current->fd != fd)
|
if (current->fd != fd)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -932,7 +932,7 @@ static void ipc_receive_message(EV_P_ struct ev_io *w, int revents) {
|
|||||||
|
|
||||||
/* Delete the client from the list of clients */
|
/* Delete the client from the list of clients */
|
||||||
ipc_client *current;
|
ipc_client *current;
|
||||||
TAILQ_FOREACH (current, &all_clients, clients) {
|
TAILQ_FOREACH(current, &all_clients, clients) {
|
||||||
if (current->fd != w->fd)
|
if (current->fd != w->fd)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -110,10 +110,10 @@ static int json_end_array(void *ctx) {
|
|||||||
if (parsing_focus) {
|
if (parsing_focus) {
|
||||||
/* Clear the list of focus mappings */
|
/* Clear the list of focus mappings */
|
||||||
struct focus_mapping *mapping;
|
struct focus_mapping *mapping;
|
||||||
TAILQ_FOREACH_REVERSE (mapping, &focus_mappings, focus_mappings_head, focus_mappings) {
|
TAILQ_FOREACH_REVERSE(mapping, &focus_mappings, focus_mappings_head, focus_mappings) {
|
||||||
LOG("focus (reverse) %d\n", mapping->old_id);
|
LOG("focus (reverse) %d\n", mapping->old_id);
|
||||||
Con *con;
|
Con *con;
|
||||||
TAILQ_FOREACH (con, &(json_node->focus_head), focused) {
|
TAILQ_FOREACH(con, &(json_node->focus_head), focused) {
|
||||||
if (con->old_id != mapping->old_id)
|
if (con->old_id != mapping->old_id)
|
||||||
continue;
|
continue;
|
||||||
LOG("got it! %p\n", con);
|
LOG("got it! %p\n", con);
|
||||||
|
@ -884,7 +884,7 @@ int main(int argc, char *argv[]) {
|
|||||||
/* Autostarting exec-lines */
|
/* Autostarting exec-lines */
|
||||||
if (autostart) {
|
if (autostart) {
|
||||||
struct Autostart *exec;
|
struct Autostart *exec;
|
||||||
TAILQ_FOREACH (exec, &autostarts, autostarts) {
|
TAILQ_FOREACH(exec, &autostarts, autostarts) {
|
||||||
LOG("auto-starting %s\n", exec->command);
|
LOG("auto-starting %s\n", exec->command);
|
||||||
start_application(exec->command, exec->no_startup_id);
|
start_application(exec->command, exec->no_startup_id);
|
||||||
}
|
}
|
||||||
@ -892,14 +892,14 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
/* Autostarting exec_always-lines */
|
/* Autostarting exec_always-lines */
|
||||||
struct Autostart *exec_always;
|
struct Autostart *exec_always;
|
||||||
TAILQ_FOREACH (exec_always, &autostarts_always, autostarts_always) {
|
TAILQ_FOREACH(exec_always, &autostarts_always, autostarts_always) {
|
||||||
LOG("auto-starting (always!) %s\n", exec_always->command);
|
LOG("auto-starting (always!) %s\n", exec_always->command);
|
||||||
start_application(exec_always->command, exec_always->no_startup_id);
|
start_application(exec_always->command, exec_always->no_startup_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Start i3bar processes for all configured bars */
|
/* Start i3bar processes for all configured bars */
|
||||||
Barconfig *barconfig;
|
Barconfig *barconfig;
|
||||||
TAILQ_FOREACH (barconfig, &barconfigs, configs) {
|
TAILQ_FOREACH(barconfig, &barconfigs, configs) {
|
||||||
char *command = NULL;
|
char *command = NULL;
|
||||||
sasprintf(&command, "%s --bar_id=%s --socket=\"%s\"",
|
sasprintf(&command, "%s --bar_id=%s --socket=\"%s\"",
|
||||||
barconfig->i3bar_command ? barconfig->i3bar_command : "i3bar",
|
barconfig->i3bar_command ? barconfig->i3bar_command : "i3bar",
|
||||||
|
20
src/manage.c
20
src/manage.c
@ -56,16 +56,16 @@ void restore_geometry(void) {
|
|||||||
DLOG("Restoring geometry\n");
|
DLOG("Restoring geometry\n");
|
||||||
|
|
||||||
Con *con;
|
Con *con;
|
||||||
TAILQ_FOREACH (con, &all_cons, all_cons)
|
TAILQ_FOREACH(con, &all_cons, all_cons)
|
||||||
if (con->window) {
|
if (con->window) {
|
||||||
DLOG("Re-adding X11 border of %d px\n", con->border_width);
|
DLOG("Re-adding X11 border of %d px\n", con->border_width);
|
||||||
con->window_rect.width += (2 * con->border_width);
|
con->window_rect.width += (2 * con->border_width);
|
||||||
con->window_rect.height += (2 * con->border_width);
|
con->window_rect.height += (2 * con->border_width);
|
||||||
xcb_set_window_rect(conn, con->window->id, con->window_rect);
|
xcb_set_window_rect(conn, con->window->id, con->window_rect);
|
||||||
DLOG("placing window %08x at %d %d\n", con->window->id, con->rect.x, con->rect.y);
|
DLOG("placing window %08x at %d %d\n", con->window->id, con->rect.x, con->rect.y);
|
||||||
xcb_reparent_window(conn, con->window->id, root,
|
xcb_reparent_window(conn, con->window->id, root,
|
||||||
con->rect.x, con->rect.y);
|
con->rect.x, con->rect.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Strictly speaking, this line doesn’t really belong here, but since we
|
/* Strictly speaking, this line doesn’t really belong here, but since we
|
||||||
* are syncing, let’s un-register as a window manager first */
|
* are syncing, let’s un-register as a window manager first */
|
||||||
|
@ -136,7 +136,7 @@ bool match_matches_window(Match *match, i3Window *window) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
/* if we find a window that is newer than this one, bail */
|
/* if we find a window that is newer than this one, bail */
|
||||||
TAILQ_FOREACH (con, &all_cons, all_cons) {
|
TAILQ_FOREACH(con, &all_cons, all_cons) {
|
||||||
if ((con->window != NULL) &&
|
if ((con->window != NULL) &&
|
||||||
_i3_timercmp(con->window->urgent, window->urgent, > )) {
|
_i3_timercmp(con->window->urgent, window->urgent, > )) {
|
||||||
return false;
|
return false;
|
||||||
@ -151,7 +151,7 @@ bool match_matches_window(Match *match, i3Window *window) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
/* if we find a window that is older than this one (and not 0), bail */
|
/* if we find a window that is older than this one (and not 0), bail */
|
||||||
TAILQ_FOREACH (con, &all_cons, all_cons) {
|
TAILQ_FOREACH(con, &all_cons, all_cons) {
|
||||||
if ((con->window != NULL) &&
|
if ((con->window != NULL) &&
|
||||||
(con->window->urgent.tv_sec != 0) &&
|
(con->window->urgent.tv_sec != 0) &&
|
||||||
_i3_timercmp(con->window->urgent, window->urgent, < )) {
|
_i3_timercmp(con->window->urgent, window->urgent, < )) {
|
||||||
|
@ -18,9 +18,9 @@
|
|||||||
Con *output_get_content(Con *output) {
|
Con *output_get_content(Con *output) {
|
||||||
Con *child;
|
Con *child;
|
||||||
|
|
||||||
TAILQ_FOREACH (child, &(output->nodes_head), nodes)
|
TAILQ_FOREACH(child, &(output->nodes_head), nodes)
|
||||||
if (child->type == CT_CON)
|
if (child->type == CT_CON)
|
||||||
return child;
|
return child;
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
66
src/randr.c
66
src/randr.c
@ -37,9 +37,9 @@ static bool randr_disabled = false;
|
|||||||
*/
|
*/
|
||||||
static Output *get_output_by_id(xcb_randr_output_t id) {
|
static Output *get_output_by_id(xcb_randr_output_t id) {
|
||||||
Output *output;
|
Output *output;
|
||||||
TAILQ_FOREACH (output, &outputs, outputs)
|
TAILQ_FOREACH(output, &outputs, outputs)
|
||||||
if (output->id == id)
|
if (output->id == id)
|
||||||
return output;
|
return output;
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -50,10 +50,10 @@ static Output *get_output_by_id(xcb_randr_output_t id) {
|
|||||||
*/
|
*/
|
||||||
Output *get_output_by_name(const char *name) {
|
Output *get_output_by_name(const char *name) {
|
||||||
Output *output;
|
Output *output;
|
||||||
TAILQ_FOREACH (output, &outputs, outputs)
|
TAILQ_FOREACH(output, &outputs, outputs)
|
||||||
if (output->active &&
|
if (output->active &&
|
||||||
strcasecmp(output->name, name) == 0)
|
strcasecmp(output->name, name) == 0)
|
||||||
return output;
|
return output;
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -65,9 +65,9 @@ Output *get_output_by_name(const char *name) {
|
|||||||
Output *get_first_output(void) {
|
Output *get_first_output(void) {
|
||||||
Output *output;
|
Output *output;
|
||||||
|
|
||||||
TAILQ_FOREACH (output, &outputs, outputs)
|
TAILQ_FOREACH(output, &outputs, outputs)
|
||||||
if (output->active)
|
if (output->active)
|
||||||
return output;
|
return output;
|
||||||
|
|
||||||
die("No usable outputs available.\n");
|
die("No usable outputs available.\n");
|
||||||
}
|
}
|
||||||
@ -79,7 +79,7 @@ Output *get_first_output(void) {
|
|||||||
*/
|
*/
|
||||||
Output *get_output_containing(unsigned int x, unsigned int y) {
|
Output *get_output_containing(unsigned int x, unsigned int y) {
|
||||||
Output *output;
|
Output *output;
|
||||||
TAILQ_FOREACH (output, &outputs, outputs) {
|
TAILQ_FOREACH(output, &outputs, outputs) {
|
||||||
if (!output->active)
|
if (!output->active)
|
||||||
continue;
|
continue;
|
||||||
DLOG("comparing x=%d y=%d with x=%d and y=%d width %d height %d\n",
|
DLOG("comparing x=%d y=%d with x=%d and y=%d width %d height %d\n",
|
||||||
@ -104,7 +104,7 @@ bool contained_by_output(Rect rect) {
|
|||||||
Output *output;
|
Output *output;
|
||||||
int lx = rect.x, uy = rect.y;
|
int lx = rect.x, uy = rect.y;
|
||||||
int rx = rect.x + rect.width, by = rect.y + rect.height;
|
int rx = rect.x + rect.width, by = rect.y + rect.height;
|
||||||
TAILQ_FOREACH (output, &outputs, outputs) {
|
TAILQ_FOREACH(output, &outputs, outputs) {
|
||||||
if (!output->active)
|
if (!output->active)
|
||||||
continue;
|
continue;
|
||||||
DLOG("comparing x=%d y=%d with x=%d and y=%d width %d height %d\n",
|
DLOG("comparing x=%d y=%d with x=%d and y=%d width %d height %d\n",
|
||||||
@ -163,7 +163,7 @@ Output *get_output_next(direction_t direction, Output *current, output_close_far
|
|||||||
*other;
|
*other;
|
||||||
Output *output,
|
Output *output,
|
||||||
*best = NULL;
|
*best = NULL;
|
||||||
TAILQ_FOREACH (output, &outputs, outputs) {
|
TAILQ_FOREACH(output, &outputs, outputs) {
|
||||||
if (!output->active)
|
if (!output->active)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -256,7 +256,7 @@ void output_init_con(Output *output) {
|
|||||||
|
|
||||||
/* Search for a Con with that name directly below the root node. There
|
/* Search for a Con with that name directly below the root node. There
|
||||||
* might be one from a restored layout. */
|
* might be one from a restored layout. */
|
||||||
TAILQ_FOREACH (current, &(croot->nodes_head), nodes) {
|
TAILQ_FOREACH(current, &(croot->nodes_head), nodes) {
|
||||||
if (strcmp(current->name, output->name) != 0)
|
if (strcmp(current->name, output->name) != 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -355,15 +355,15 @@ void output_init_con(Output *output) {
|
|||||||
void init_ws_for_output(Output *output, Con *content) {
|
void init_ws_for_output(Output *output, Con *content) {
|
||||||
/* go through all assignments and move the existing workspaces to this output */
|
/* go through all assignments and move the existing workspaces to this output */
|
||||||
struct Workspace_Assignment *assignment;
|
struct Workspace_Assignment *assignment;
|
||||||
TAILQ_FOREACH (assignment, &ws_assignments, ws_assignments) {
|
TAILQ_FOREACH(assignment, &ws_assignments, ws_assignments) {
|
||||||
if (strcmp(assignment->output, output->name) != 0)
|
if (strcmp(assignment->output, output->name) != 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* check if this workspace actually exists */
|
/* check if this workspace actually exists */
|
||||||
Con *workspace = NULL, *out;
|
Con *workspace = NULL, *out;
|
||||||
TAILQ_FOREACH (out, &(croot->nodes_head), nodes)
|
TAILQ_FOREACH(out, &(croot->nodes_head), nodes)
|
||||||
GREP_FIRST(workspace, output_get_content(out),
|
GREP_FIRST(workspace, output_get_content(out),
|
||||||
!strcasecmp(child->name, assignment->name));
|
!strcasecmp(child->name, assignment->name));
|
||||||
if (workspace == NULL)
|
if (workspace == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -401,10 +401,10 @@ void init_ws_for_output(Output *output, Con *content) {
|
|||||||
Con *ws_out_content = output_get_content(workspace_out);
|
Con *ws_out_content = output_get_content(workspace_out);
|
||||||
|
|
||||||
Con *floating_con;
|
Con *floating_con;
|
||||||
TAILQ_FOREACH (floating_con, &(workspace->floating_head), floating_windows)
|
TAILQ_FOREACH(floating_con, &(workspace->floating_head), floating_windows)
|
||||||
/* NB: We use output->con here because content is not yet rendered,
|
/* NB: We use output->con here because content is not yet rendered,
|
||||||
* so it has a rect of {0, 0, 0, 0}. */
|
* so it has a rect of {0, 0, 0, 0}. */
|
||||||
floating_fix_coordinates(floating_con, &(ws_out_content->rect), &(output->con->rect));
|
floating_fix_coordinates(floating_con, &(ws_out_content->rect), &(output->con->rect));
|
||||||
|
|
||||||
con_detach(workspace);
|
con_detach(workspace);
|
||||||
con_attach(workspace, content, false);
|
con_attach(workspace, content, false);
|
||||||
@ -436,7 +436,7 @@ void init_ws_for_output(Output *output, Con *content) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* otherwise, we create the first assigned ws for this output */
|
/* otherwise, we create the first assigned ws for this output */
|
||||||
TAILQ_FOREACH (assignment, &ws_assignments, ws_assignments) {
|
TAILQ_FOREACH(assignment, &ws_assignments, ws_assignments) {
|
||||||
if (strcmp(assignment->output, output->name) != 0)
|
if (strcmp(assignment->output, output->name) != 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -478,8 +478,8 @@ static void output_change_mode(xcb_connection_t *conn, Output *output) {
|
|||||||
|
|
||||||
/* Fix the position of all floating windows on this output.
|
/* Fix the position of all floating windows on this output.
|
||||||
* The 'rect' of each workspace will be updated in src/render.c. */
|
* The 'rect' of each workspace will be updated in src/render.c. */
|
||||||
TAILQ_FOREACH (workspace, &(content->nodes_head), nodes) {
|
TAILQ_FOREACH(workspace, &(content->nodes_head), nodes) {
|
||||||
TAILQ_FOREACH (child, &(workspace->floating_head), floating_windows) {
|
TAILQ_FOREACH(child, &(workspace->floating_head), floating_windows) {
|
||||||
floating_fix_coordinates(child, &(workspace->rect), &(output->con->rect));
|
floating_fix_coordinates(child, &(workspace->rect), &(output->con->rect));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -488,7 +488,7 @@ static void output_change_mode(xcb_connection_t *conn, Output *output) {
|
|||||||
* the workspaces and their childs depending on output resolution. This is
|
* the workspaces and their childs depending on output resolution. This is
|
||||||
* only done for workspaces with maximum one child. */
|
* only done for workspaces with maximum one child. */
|
||||||
if (config.default_orientation == NO_ORIENTATION) {
|
if (config.default_orientation == NO_ORIENTATION) {
|
||||||
TAILQ_FOREACH (workspace, &(content->nodes_head), nodes) {
|
TAILQ_FOREACH(workspace, &(content->nodes_head), nodes) {
|
||||||
/* Workspaces with more than one child are left untouched because
|
/* Workspaces with more than one child are left untouched because
|
||||||
* we do not want to change an existing layout. */
|
* we do not want to change an existing layout. */
|
||||||
if (con_num_children(workspace) > 1)
|
if (con_num_children(workspace) > 1)
|
||||||
@ -640,7 +640,7 @@ void randr_query_outputs(void) {
|
|||||||
|
|
||||||
/* Check for clones, disable the clones and reduce the mode to the
|
/* Check for clones, disable the clones and reduce the mode to the
|
||||||
* lowest common mode */
|
* lowest common mode */
|
||||||
TAILQ_FOREACH (output, &outputs, outputs) {
|
TAILQ_FOREACH(output, &outputs, outputs) {
|
||||||
if (!output->active || output->to_be_disabled)
|
if (!output->active || output->to_be_disabled)
|
||||||
continue;
|
continue;
|
||||||
DLOG("output %p / %s, position (%d, %d), checking for clones\n",
|
DLOG("output %p / %s, position (%d, %d), checking for clones\n",
|
||||||
@ -681,7 +681,7 @@ void randr_query_outputs(void) {
|
|||||||
* necessary because in the next step, a clone might get disabled. Example:
|
* necessary because in the next step, a clone might get disabled. Example:
|
||||||
* LVDS1 active, VGA1 gets activated as a clone of LVDS1 (has no con).
|
* LVDS1 active, VGA1 gets activated as a clone of LVDS1 (has no con).
|
||||||
* LVDS1 gets disabled. */
|
* LVDS1 gets disabled. */
|
||||||
TAILQ_FOREACH (output, &outputs, outputs) {
|
TAILQ_FOREACH(output, &outputs, outputs) {
|
||||||
if (output->active && output->con == NULL) {
|
if (output->active && output->con == NULL) {
|
||||||
DLOG("Need to initialize a Con for output %s\n", output->name);
|
DLOG("Need to initialize a Con for output %s\n", output->name);
|
||||||
output_init_con(output);
|
output_init_con(output);
|
||||||
@ -691,7 +691,7 @@ void randr_query_outputs(void) {
|
|||||||
|
|
||||||
/* Handle outputs which have a new mode or are disabled now (either
|
/* Handle outputs which have a new mode or are disabled now (either
|
||||||
* because the user disabled them or because they are clones) */
|
* because the user disabled them or because they are clones) */
|
||||||
TAILQ_FOREACH (output, &outputs, outputs) {
|
TAILQ_FOREACH(output, &outputs, outputs) {
|
||||||
if (output->to_be_disabled) {
|
if (output->to_be_disabled) {
|
||||||
output->active = false;
|
output->active = false;
|
||||||
DLOG("Output %s disabled, re-assigning workspaces/docks\n", output->name);
|
DLOG("Output %s disabled, re-assigning workspaces/docks\n", output->name);
|
||||||
@ -731,8 +731,8 @@ void randr_query_outputs(void) {
|
|||||||
con_attach(current, first_content, false);
|
con_attach(current, first_content, false);
|
||||||
DLOG("Fixing the coordinates of floating containers\n");
|
DLOG("Fixing the coordinates of floating containers\n");
|
||||||
Con *floating_con;
|
Con *floating_con;
|
||||||
TAILQ_FOREACH (floating_con, &(current->floating_head), floating_windows)
|
TAILQ_FOREACH(floating_con, &(current->floating_head), floating_windows)
|
||||||
floating_fix_coordinates(floating_con, &(output->con->rect), &(first->con->rect));
|
floating_fix_coordinates(floating_con, &(output->con->rect), &(first->con->rect));
|
||||||
DLOG("Done, next\n");
|
DLOG("Done, next\n");
|
||||||
}
|
}
|
||||||
DLOG("re-attached all workspaces\n");
|
DLOG("re-attached all workspaces\n");
|
||||||
@ -745,7 +745,7 @@ void randr_query_outputs(void) {
|
|||||||
|
|
||||||
/* 3: move the dock clients to the first output */
|
/* 3: move the dock clients to the first output */
|
||||||
Con *child;
|
Con *child;
|
||||||
TAILQ_FOREACH (child, &(output->con->nodes_head), nodes) {
|
TAILQ_FOREACH(child, &(output->con->nodes_head), nodes) {
|
||||||
if (child->type != CT_DOCKAREA)
|
if (child->type != CT_DOCKAREA)
|
||||||
continue;
|
continue;
|
||||||
DLOG("Handling dock con %p\n", child);
|
DLOG("Handling dock con %p\n", child);
|
||||||
@ -788,7 +788,7 @@ void randr_query_outputs(void) {
|
|||||||
get_first_output();
|
get_first_output();
|
||||||
|
|
||||||
/* Just go through each active output and assign one workspace */
|
/* Just go through each active output and assign one workspace */
|
||||||
TAILQ_FOREACH (output, &outputs, outputs) {
|
TAILQ_FOREACH(output, &outputs, outputs) {
|
||||||
if (!output->active)
|
if (!output->active)
|
||||||
continue;
|
continue;
|
||||||
Con *content = output_get_content(output->con);
|
Con *content = output_get_content(output->con);
|
||||||
@ -799,7 +799,7 @@ void randr_query_outputs(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Focus the primary screen, if possible */
|
/* Focus the primary screen, if possible */
|
||||||
TAILQ_FOREACH (output, &outputs, outputs) {
|
TAILQ_FOREACH(output, &outputs, outputs) {
|
||||||
if (!output->primary || !output->con)
|
if (!output->primary || !output->con)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
24
src/render.c
24
src/render.c
@ -41,7 +41,7 @@ static void render_l_output(Con *con) {
|
|||||||
/* Find the content container and ensure that there is exactly one. Also
|
/* Find the content container and ensure that there is exactly one. Also
|
||||||
* check for any non-CT_DOCKAREA clients. */
|
* check for any non-CT_DOCKAREA clients. */
|
||||||
Con *content = NULL;
|
Con *content = NULL;
|
||||||
TAILQ_FOREACH (child, &(con->nodes_head), nodes) {
|
TAILQ_FOREACH(child, &(con->nodes_head), nodes) {
|
||||||
if (child->type == CT_CON) {
|
if (child->type == CT_CON) {
|
||||||
if (content != NULL) {
|
if (content != NULL) {
|
||||||
DLOG("More than one CT_CON on output container\n");
|
DLOG("More than one CT_CON on output container\n");
|
||||||
@ -77,19 +77,19 @@ static void render_l_output(Con *con) {
|
|||||||
|
|
||||||
/* First pass: determine the height of all CT_DOCKAREAs (the sum of their
|
/* First pass: determine the height of all CT_DOCKAREAs (the sum of their
|
||||||
* children) and figure out how many pixels we have left for the rest */
|
* children) and figure out how many pixels we have left for the rest */
|
||||||
TAILQ_FOREACH (child, &(con->nodes_head), nodes) {
|
TAILQ_FOREACH(child, &(con->nodes_head), nodes) {
|
||||||
if (child->type != CT_DOCKAREA)
|
if (child->type != CT_DOCKAREA)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
child->rect.height = 0;
|
child->rect.height = 0;
|
||||||
TAILQ_FOREACH (dockchild, &(child->nodes_head), nodes)
|
TAILQ_FOREACH(dockchild, &(child->nodes_head), nodes)
|
||||||
child->rect.height += dockchild->geometry.height;
|
child->rect.height += dockchild->geometry.height;
|
||||||
|
|
||||||
height -= child->rect.height;
|
height -= child->rect.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Second pass: Set the widths/heights */
|
/* Second pass: Set the widths/heights */
|
||||||
TAILQ_FOREACH (child, &(con->nodes_head), nodes) {
|
TAILQ_FOREACH(child, &(con->nodes_head), nodes) {
|
||||||
if (child->type == CT_CON) {
|
if (child->type == CT_CON) {
|
||||||
child->rect.x = x;
|
child->rect.x = x;
|
||||||
child->rect.y = y;
|
child->rect.y = y;
|
||||||
@ -224,7 +224,7 @@ void render_con(Con *con, bool render_fullscreen) {
|
|||||||
Con *child;
|
Con *child;
|
||||||
int i = 0, assigned = 0;
|
int i = 0, assigned = 0;
|
||||||
int total = con_orientation(con) == HORIZ ? rect.width : rect.height;
|
int total = con_orientation(con) == HORIZ ? rect.width : rect.height;
|
||||||
TAILQ_FOREACH (child, &(con->nodes_head), nodes) {
|
TAILQ_FOREACH(child, &(con->nodes_head), nodes) {
|
||||||
double percentage = child->percent > 0.0 ? child->percent : 1.0 / children;
|
double percentage = child->percent > 0.0 ? child->percent : 1.0 / children;
|
||||||
assigned += sizes[i++] = percentage * total;
|
assigned += sizes[i++] = percentage * total;
|
||||||
}
|
}
|
||||||
@ -247,7 +247,7 @@ void render_con(Con *con, bool render_fullscreen) {
|
|||||||
render_l_output(con);
|
render_l_output(con);
|
||||||
} else if (con->type == CT_ROOT) {
|
} else if (con->type == CT_ROOT) {
|
||||||
Con *output;
|
Con *output;
|
||||||
TAILQ_FOREACH (output, &(con->nodes_head), nodes) {
|
TAILQ_FOREACH(output, &(con->nodes_head), nodes) {
|
||||||
render_con(output, false);
|
render_con(output, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,7 +256,7 @@ void render_con(Con *con, bool render_fullscreen) {
|
|||||||
* all times. This is important when the user places floating
|
* all times. This is important when the user places floating
|
||||||
* windows/containers so that they overlap on another output. */
|
* windows/containers so that they overlap on another output. */
|
||||||
DLOG("Rendering floating windows:\n");
|
DLOG("Rendering floating windows:\n");
|
||||||
TAILQ_FOREACH (output, &(con->nodes_head), nodes) {
|
TAILQ_FOREACH(output, &(con->nodes_head), nodes) {
|
||||||
if (con_is_internal(output))
|
if (con_is_internal(output))
|
||||||
continue;
|
continue;
|
||||||
/* Get the active workspace of that output */
|
/* Get the active workspace of that output */
|
||||||
@ -268,7 +268,7 @@ void render_con(Con *con, bool render_fullscreen) {
|
|||||||
Con *workspace = TAILQ_FIRST(&(content->focus_head));
|
Con *workspace = TAILQ_FIRST(&(content->focus_head));
|
||||||
Con *fullscreen = con_get_fullscreen_con(workspace, CF_OUTPUT);
|
Con *fullscreen = con_get_fullscreen_con(workspace, CF_OUTPUT);
|
||||||
Con *child;
|
Con *child;
|
||||||
TAILQ_FOREACH (child, &(workspace->floating_head), floating_windows) {
|
TAILQ_FOREACH(child, &(workspace->floating_head), floating_windows) {
|
||||||
/* Don’t render floating windows when there is a fullscreen window
|
/* Don’t render floating windows when there is a fullscreen window
|
||||||
* on that workspace. Necessary to make floating fullscreen work
|
* on that workspace. Necessary to make floating fullscreen work
|
||||||
* correctly (ticket #564). */
|
* correctly (ticket #564). */
|
||||||
@ -321,7 +321,7 @@ void render_con(Con *con, bool render_fullscreen) {
|
|||||||
} else {
|
} else {
|
||||||
/* FIXME: refactor this into separate functions: */
|
/* FIXME: refactor this into separate functions: */
|
||||||
Con *child;
|
Con *child;
|
||||||
TAILQ_FOREACH (child, &(con->nodes_head), nodes) {
|
TAILQ_FOREACH(child, &(con->nodes_head), nodes) {
|
||||||
assert(children > 0);
|
assert(children > 0);
|
||||||
|
|
||||||
/* default layout */
|
/* default layout */
|
||||||
@ -428,8 +428,8 @@ void render_con(Con *con, bool render_fullscreen) {
|
|||||||
|
|
||||||
/* in a stacking or tabbed container, we ensure the focused client is raised */
|
/* in a stacking or tabbed container, we ensure the focused client is raised */
|
||||||
if (con->layout == L_STACKED || con->layout == L_TABBED) {
|
if (con->layout == L_STACKED || con->layout == L_TABBED) {
|
||||||
TAILQ_FOREACH_REVERSE (child, &(con->focus_head), focus_head, focused)
|
TAILQ_FOREACH_REVERSE(child, &(con->focus_head), focus_head, focused)
|
||||||
x_raise_con(child);
|
x_raise_con(child);
|
||||||
if ((child = TAILQ_FIRST(&(con->focus_head)))) {
|
if ((child = TAILQ_FIRST(&(con->focus_head)))) {
|
||||||
/* By rendering the stacked container again, we handle the case
|
/* By rendering the stacked container again, we handle the case
|
||||||
* that we have a non-leaf-container inside the stack. In that
|
* that we have a non-leaf-container inside the stack. In that
|
||||||
|
@ -137,7 +137,7 @@ static void update_placeholder_contents(placeholder_state *state) {
|
|||||||
|
|
||||||
Match *swallows;
|
Match *swallows;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
TAILQ_FOREACH (swallows, &(state->con->swallow_head), matches) {
|
TAILQ_FOREACH(swallows, &(state->con->swallow_head), matches) {
|
||||||
char *serialized = NULL;
|
char *serialized = NULL;
|
||||||
|
|
||||||
#define APPEND_REGEX(re_name) \
|
#define APPEND_REGEX(re_name) \
|
||||||
@ -222,10 +222,10 @@ static void open_placeholder_window(Con *con) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Con *child;
|
Con *child;
|
||||||
TAILQ_FOREACH (child, &(con->nodes_head), nodes) {
|
TAILQ_FOREACH(child, &(con->nodes_head), nodes) {
|
||||||
open_placeholder_window(child);
|
open_placeholder_window(child);
|
||||||
}
|
}
|
||||||
TAILQ_FOREACH (child, &(con->floating_head), floating_windows) {
|
TAILQ_FOREACH(child, &(con->floating_head), floating_windows) {
|
||||||
open_placeholder_window(child);
|
open_placeholder_window(child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -239,10 +239,10 @@ static void open_placeholder_window(Con *con) {
|
|||||||
*/
|
*/
|
||||||
void restore_open_placeholder_windows(Con *parent) {
|
void restore_open_placeholder_windows(Con *parent) {
|
||||||
Con *child;
|
Con *child;
|
||||||
TAILQ_FOREACH (child, &(parent->nodes_head), nodes) {
|
TAILQ_FOREACH(child, &(parent->nodes_head), nodes) {
|
||||||
open_placeholder_window(child);
|
open_placeholder_window(child);
|
||||||
}
|
}
|
||||||
TAILQ_FOREACH (child, &(parent->floating_head), floating_windows) {
|
TAILQ_FOREACH(child, &(parent->floating_head), floating_windows) {
|
||||||
open_placeholder_window(child);
|
open_placeholder_window(child);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -258,7 +258,7 @@ void restore_open_placeholder_windows(Con *parent) {
|
|||||||
*/
|
*/
|
||||||
bool restore_kill_placeholder(xcb_window_t placeholder) {
|
bool restore_kill_placeholder(xcb_window_t placeholder) {
|
||||||
placeholder_state *state;
|
placeholder_state *state;
|
||||||
TAILQ_FOREACH (state, &state_head, state) {
|
TAILQ_FOREACH(state, &state_head, state) {
|
||||||
if (state->window != placeholder)
|
if (state->window != placeholder)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -277,7 +277,7 @@ bool restore_kill_placeholder(xcb_window_t placeholder) {
|
|||||||
|
|
||||||
static void expose_event(xcb_expose_event_t *event) {
|
static void expose_event(xcb_expose_event_t *event) {
|
||||||
placeholder_state *state;
|
placeholder_state *state;
|
||||||
TAILQ_FOREACH (state, &state_head, state) {
|
TAILQ_FOREACH(state, &state_head, state) {
|
||||||
if (state->window != event->window)
|
if (state->window != event->window)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -305,7 +305,7 @@ static void expose_event(xcb_expose_event_t *event) {
|
|||||||
*/
|
*/
|
||||||
static void configure_notify(xcb_configure_notify_event_t *event) {
|
static void configure_notify(xcb_configure_notify_event_t *event) {
|
||||||
placeholder_state *state;
|
placeholder_state *state;
|
||||||
TAILQ_FOREACH (state, &state_head, state) {
|
TAILQ_FOREACH(state, &state_head, state) {
|
||||||
if (state->window != event->window)
|
if (state->window != event->window)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ void scratchpad_show(Con *con) {
|
|||||||
* unfocused scratchpad on the current workspace and focus it */
|
* unfocused scratchpad on the current workspace and focus it */
|
||||||
Con *walk_con;
|
Con *walk_con;
|
||||||
Con *focused_ws = con_get_workspace(focused);
|
Con *focused_ws = con_get_workspace(focused);
|
||||||
TAILQ_FOREACH (walk_con, &(focused_ws->floating_head), floating_windows) {
|
TAILQ_FOREACH(walk_con, &(focused_ws->floating_head), floating_windows) {
|
||||||
if (!con && (floating = con_inside_floating(walk_con)) &&
|
if (!con && (floating = con_inside_floating(walk_con)) &&
|
||||||
floating->scratchpad_state != SCRATCHPAD_NONE &&
|
floating->scratchpad_state != SCRATCHPAD_NONE &&
|
||||||
floating != con_inside_floating(focused)) {
|
floating != con_inside_floating(focused)) {
|
||||||
@ -134,7 +134,7 @@ void scratchpad_show(Con *con) {
|
|||||||
* visible scratchpad window on another workspace. In this case we move it
|
* visible scratchpad window on another workspace. In this case we move it
|
||||||
* to the current workspace. */
|
* to the current workspace. */
|
||||||
focused_ws = con_get_workspace(focused);
|
focused_ws = con_get_workspace(focused);
|
||||||
TAILQ_FOREACH (walk_con, &all_cons, all_cons) {
|
TAILQ_FOREACH(walk_con, &all_cons, all_cons) {
|
||||||
Con *walk_ws = con_get_workspace(walk_con);
|
Con *walk_ws = con_get_workspace(walk_con);
|
||||||
if (!con && walk_ws &&
|
if (!con && walk_ws &&
|
||||||
!con_is_internal(walk_ws) && focused_ws != walk_ws &&
|
!con_is_internal(walk_ws) && focused_ws != walk_ws &&
|
||||||
@ -257,7 +257,7 @@ void scratchpad_fix_resolution(void) {
|
|||||||
Con *output;
|
Con *output;
|
||||||
int new_width = -1,
|
int new_width = -1,
|
||||||
new_height = -1;
|
new_height = -1;
|
||||||
TAILQ_FOREACH (output, &(croot->nodes_head), nodes) {
|
TAILQ_FOREACH(output, &(croot->nodes_head), nodes) {
|
||||||
if (output == __i3_output)
|
if (output == __i3_output)
|
||||||
continue;
|
continue;
|
||||||
DLOG("output %s's resolution: (%d, %d) %d x %d\n",
|
DLOG("output %s's resolution: (%d, %d) %d x %d\n",
|
||||||
@ -288,7 +288,7 @@ void scratchpad_fix_resolution(void) {
|
|||||||
|
|
||||||
DLOG("Fixing coordinates of scratchpad windows\n");
|
DLOG("Fixing coordinates of scratchpad windows\n");
|
||||||
Con *con;
|
Con *con;
|
||||||
TAILQ_FOREACH (con, &(__i3_scratch->floating_head), floating_windows) {
|
TAILQ_FOREACH(con, &(__i3_scratch->floating_head), floating_windows) {
|
||||||
floating_fix_coordinates(con, &old_rect, &new_rect);
|
floating_fix_coordinates(con, &old_rect, &new_rect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -253,7 +253,7 @@ static void open_popups() {
|
|||||||
/* Open a popup window on each virtual screen */
|
/* Open a popup window on each virtual screen */
|
||||||
Output *screen;
|
Output *screen;
|
||||||
xcb_window_t win;
|
xcb_window_t win;
|
||||||
TAILQ_FOREACH (screen, &outputs, outputs) {
|
TAILQ_FOREACH(screen, &outputs, outputs) {
|
||||||
if (!screen->active)
|
if (!screen->active)
|
||||||
continue;
|
continue;
|
||||||
win = open_input_window(conn, screen->rect, width, height);
|
win = open_input_window(conn, screen->rect, width, height);
|
||||||
|
@ -37,7 +37,7 @@ static void startup_timeout(EV_P_ ev_timer *w, int revents) {
|
|||||||
DLOG("Timeout for startup sequence %s\n", id);
|
DLOG("Timeout for startup sequence %s\n", id);
|
||||||
|
|
||||||
struct Startup_Sequence *current, *sequence = NULL;
|
struct Startup_Sequence *current, *sequence = NULL;
|
||||||
TAILQ_FOREACH (current, &startup_sequences, sequences) {
|
TAILQ_FOREACH(current, &startup_sequences, sequences) {
|
||||||
if (strcmp(current->id, id) != 0)
|
if (strcmp(current->id, id) != 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -219,7 +219,7 @@ void startup_monitor_event(SnMonitorEvent *event, void *userdata) {
|
|||||||
/* Get the corresponding internal startup sequence */
|
/* Get the corresponding internal startup sequence */
|
||||||
const char *id = sn_startup_sequence_get_id(snsequence);
|
const char *id = sn_startup_sequence_get_id(snsequence);
|
||||||
struct Startup_Sequence *current, *sequence = NULL;
|
struct Startup_Sequence *current, *sequence = NULL;
|
||||||
TAILQ_FOREACH (current, &startup_sequences, sequences) {
|
TAILQ_FOREACH(current, &startup_sequences, sequences) {
|
||||||
if (strcmp(current->id, id) != 0)
|
if (strcmp(current->id, id) != 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -309,7 +309,7 @@ struct Startup_Sequence *startup_sequence_get(i3Window *cwindow,
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct Startup_Sequence *current, *sequence = NULL;
|
struct Startup_Sequence *current, *sequence = NULL;
|
||||||
TAILQ_FOREACH (current, &startup_sequences, sequences) {
|
TAILQ_FOREACH(current, &startup_sequences, sequences) {
|
||||||
if (strcmp(current->id, startup_id) != 0)
|
if (strcmp(current->id, startup_id) != 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
14
src/tree.c
14
src/tree.c
@ -167,9 +167,9 @@ Con *tree_open_con(Con *con, i3Window *window) {
|
|||||||
static bool _is_con_mapped(Con *con) {
|
static bool _is_con_mapped(Con *con) {
|
||||||
Con *child;
|
Con *child;
|
||||||
|
|
||||||
TAILQ_FOREACH (child, &(con->nodes_head), nodes)
|
TAILQ_FOREACH(child, &(con->nodes_head), nodes)
|
||||||
if (_is_con_mapped(child))
|
if (_is_con_mapped(child))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return con->mapped;
|
return con->mapped;
|
||||||
}
|
}
|
||||||
@ -489,13 +489,13 @@ static void mark_unmapped(Con *con) {
|
|||||||
Con *current;
|
Con *current;
|
||||||
|
|
||||||
con->mapped = false;
|
con->mapped = false;
|
||||||
TAILQ_FOREACH (current, &(con->nodes_head), nodes)
|
TAILQ_FOREACH(current, &(con->nodes_head), nodes)
|
||||||
mark_unmapped(current);
|
mark_unmapped(current);
|
||||||
if (con->type == CT_WORKSPACE) {
|
if (con->type == CT_WORKSPACE) {
|
||||||
/* We need to call mark_unmapped on floating nodes aswell since we can
|
/* We need to call mark_unmapped on floating nodes aswell since we can
|
||||||
* make containers floating. */
|
* make containers floating. */
|
||||||
TAILQ_FOREACH (current, &(con->floating_head), floating_windows)
|
TAILQ_FOREACH(current, &(con->floating_head), floating_windows)
|
||||||
mark_unmapped(current);
|
mark_unmapped(current);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,8 +44,8 @@ static void _workspace_apply_default_orientation(Con *ws) {
|
|||||||
Con *workspace_get(const char *num, bool *created) {
|
Con *workspace_get(const char *num, bool *created) {
|
||||||
Con *output, *workspace = NULL;
|
Con *output, *workspace = NULL;
|
||||||
|
|
||||||
TAILQ_FOREACH (output, &(croot->nodes_head), nodes)
|
TAILQ_FOREACH(output, &(croot->nodes_head), nodes)
|
||||||
GREP_FIRST(workspace, output_get_content(output), !strcasecmp(child->name, num));
|
GREP_FIRST(workspace, output_get_content(output), !strcasecmp(child->name, num));
|
||||||
|
|
||||||
if (workspace == NULL) {
|
if (workspace == NULL) {
|
||||||
LOG("Creating new workspace \"%s\"\n", num);
|
LOG("Creating new workspace \"%s\"\n", num);
|
||||||
@ -59,7 +59,7 @@ Con *workspace_get(const char *num, bool *created) {
|
|||||||
* -1. */
|
* -1. */
|
||||||
long parsed_num = ws_name_to_number(num);
|
long parsed_num = ws_name_to_number(num);
|
||||||
|
|
||||||
TAILQ_FOREACH (assignment, &ws_assignments, ws_assignments) {
|
TAILQ_FOREACH(assignment, &ws_assignments, ws_assignments) {
|
||||||
if (strcmp(assignment->name, num) == 0) {
|
if (strcmp(assignment->name, num) == 0) {
|
||||||
DLOG("Found workspace name assignment to output \"%s\"\n", assignment->output);
|
DLOG("Found workspace name assignment to output \"%s\"\n", assignment->output);
|
||||||
GREP_FIRST(output, croot, !strcmp(child->name, assignment->output));
|
GREP_FIRST(output, croot, !strcmp(child->name, assignment->output));
|
||||||
@ -117,7 +117,7 @@ Con *create_workspace_on_output(Output *output, Con *content) {
|
|||||||
|
|
||||||
/* try the configured workspace bindings first to find a free name */
|
/* try the configured workspace bindings first to find a free name */
|
||||||
Binding *bind;
|
Binding *bind;
|
||||||
TAILQ_FOREACH (bind, bindings, bindings) {
|
TAILQ_FOREACH(bind, bindings, bindings) {
|
||||||
DLOG("binding with command %s\n", bind->command);
|
DLOG("binding with command %s\n", bind->command);
|
||||||
if (strlen(bind->command) < strlen("workspace ") ||
|
if (strlen(bind->command) < strlen("workspace ") ||
|
||||||
strncasecmp(bind->command, "workspace", strlen("workspace")) != 0)
|
strncasecmp(bind->command, "workspace", strlen("workspace")) != 0)
|
||||||
@ -156,7 +156,7 @@ Con *create_workspace_on_output(Output *output, Con *content) {
|
|||||||
* find a new workspace, etc… */
|
* find a new workspace, etc… */
|
||||||
bool assigned = false;
|
bool assigned = false;
|
||||||
struct Workspace_Assignment *assignment;
|
struct Workspace_Assignment *assignment;
|
||||||
TAILQ_FOREACH (assignment, &ws_assignments, ws_assignments) {
|
TAILQ_FOREACH(assignment, &ws_assignments, ws_assignments) {
|
||||||
if (strcmp(assignment->name, ws->name) != 0 ||
|
if (strcmp(assignment->name, ws->name) != 0 ||
|
||||||
strcmp(assignment->output, output->name) == 0)
|
strcmp(assignment->output, output->name) == 0)
|
||||||
continue;
|
continue;
|
||||||
@ -169,8 +169,8 @@ Con *create_workspace_on_output(Output *output, Con *content) {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
current = NULL;
|
current = NULL;
|
||||||
TAILQ_FOREACH (out, &(croot->nodes_head), nodes)
|
TAILQ_FOREACH(out, &(croot->nodes_head), nodes)
|
||||||
GREP_FIRST(current, output_get_content(out), !strcasecmp(child->name, ws->name));
|
GREP_FIRST(current, output_get_content(out), !strcasecmp(child->name, ws->name));
|
||||||
|
|
||||||
exists = (current != NULL);
|
exists = (current != NULL);
|
||||||
if (!exists) {
|
if (!exists) {
|
||||||
@ -201,8 +201,8 @@ Con *create_workspace_on_output(Output *output, Con *content) {
|
|||||||
ws->num = c;
|
ws->num = c;
|
||||||
|
|
||||||
current = NULL;
|
current = NULL;
|
||||||
TAILQ_FOREACH (out, &(croot->nodes_head), nodes)
|
TAILQ_FOREACH(out, &(croot->nodes_head), nodes)
|
||||||
GREP_FIRST(current, output_get_content(out), child->num == ws->num);
|
GREP_FIRST(current, output_get_content(out), child->num == ws->num);
|
||||||
exists = (current != NULL);
|
exists = (current != NULL);
|
||||||
|
|
||||||
DLOG("result for ws %d: exists = %d\n", c, exists);
|
DLOG("result for ws %d: exists = %d\n", c, exists);
|
||||||
@ -245,7 +245,7 @@ bool workspace_is_visible(Con *ws) {
|
|||||||
Con *_get_sticky(Con *con, const char *sticky_group, Con *exclude) {
|
Con *_get_sticky(Con *con, const char *sticky_group, Con *exclude) {
|
||||||
Con *current;
|
Con *current;
|
||||||
|
|
||||||
TAILQ_FOREACH (current, &(con->nodes_head), nodes) {
|
TAILQ_FOREACH(current, &(con->nodes_head), nodes) {
|
||||||
if (current != exclude &&
|
if (current != exclude &&
|
||||||
current->sticky_group != NULL &&
|
current->sticky_group != NULL &&
|
||||||
current->window != NULL &&
|
current->window != NULL &&
|
||||||
@ -257,7 +257,7 @@ Con *_get_sticky(Con *con, const char *sticky_group, Con *exclude) {
|
|||||||
return recurse;
|
return recurse;
|
||||||
}
|
}
|
||||||
|
|
||||||
TAILQ_FOREACH (current, &(con->floating_head), floating_windows) {
|
TAILQ_FOREACH(current, &(con->floating_head), floating_windows) {
|
||||||
if (current != exclude &&
|
if (current != exclude &&
|
||||||
current->sticky_group != NULL &&
|
current->sticky_group != NULL &&
|
||||||
current->window != NULL &&
|
current->window != NULL &&
|
||||||
@ -284,7 +284,7 @@ static void workspace_reassign_sticky(Con *con) {
|
|||||||
/* 1: go through all containers */
|
/* 1: go through all containers */
|
||||||
|
|
||||||
/* handle all children and floating windows of this node */
|
/* handle all children and floating windows of this node */
|
||||||
TAILQ_FOREACH (current, &(con->nodes_head), nodes) {
|
TAILQ_FOREACH(current, &(con->nodes_head), nodes) {
|
||||||
if (current->sticky_group == NULL) {
|
if (current->sticky_group == NULL) {
|
||||||
workspace_reassign_sticky(current);
|
workspace_reassign_sticky(current);
|
||||||
continue;
|
continue;
|
||||||
@ -312,8 +312,8 @@ static void workspace_reassign_sticky(Con *con) {
|
|||||||
LOG("re-assigned window from src %p to dest %p\n", src, current);
|
LOG("re-assigned window from src %p to dest %p\n", src, current);
|
||||||
}
|
}
|
||||||
|
|
||||||
TAILQ_FOREACH (current, &(con->floating_head), floating_windows)
|
TAILQ_FOREACH(current, &(con->floating_head), floating_windows)
|
||||||
workspace_reassign_sticky(current);
|
workspace_reassign_sticky(current);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -344,7 +344,7 @@ static void _workspace_show(Con *workspace) {
|
|||||||
|
|
||||||
/* disable fullscreen for the other workspaces and get the workspace we are
|
/* disable fullscreen for the other workspaces and get the workspace we are
|
||||||
* currently on. */
|
* currently on. */
|
||||||
TAILQ_FOREACH (current, &(workspace->parent->nodes_head), nodes) {
|
TAILQ_FOREACH(current, &(workspace->parent->nodes_head), nodes) {
|
||||||
if (current->fullscreen_mode == CF_OUTPUT)
|
if (current->fullscreen_mode == CF_OUTPUT)
|
||||||
old = current;
|
old = current;
|
||||||
current->fullscreen_mode = CF_NONE;
|
current->fullscreen_mode = CF_NONE;
|
||||||
@ -472,11 +472,11 @@ Con *workspace_next(void) {
|
|||||||
next = TAILQ_NEXT(current, nodes);
|
next = TAILQ_NEXT(current, nodes);
|
||||||
} else {
|
} else {
|
||||||
/* If currently a numbered workspace, find next numbered workspace. */
|
/* If currently a numbered workspace, find next numbered workspace. */
|
||||||
TAILQ_FOREACH (output, &(croot->nodes_head), nodes) {
|
TAILQ_FOREACH(output, &(croot->nodes_head), nodes) {
|
||||||
/* Skip outputs starting with __, they are internal. */
|
/* Skip outputs starting with __, they are internal. */
|
||||||
if (con_is_internal(output))
|
if (con_is_internal(output))
|
||||||
continue;
|
continue;
|
||||||
NODES_FOREACH (output_get_content(output)) {
|
NODES_FOREACH(output_get_content(output)) {
|
||||||
if (child->type != CT_WORKSPACE)
|
if (child->type != CT_WORKSPACE)
|
||||||
continue;
|
continue;
|
||||||
if (child->num == -1)
|
if (child->num == -1)
|
||||||
@ -493,11 +493,11 @@ Con *workspace_next(void) {
|
|||||||
/* Find next named workspace. */
|
/* Find next named workspace. */
|
||||||
if (!next) {
|
if (!next) {
|
||||||
bool found_current = false;
|
bool found_current = false;
|
||||||
TAILQ_FOREACH (output, &(croot->nodes_head), nodes) {
|
TAILQ_FOREACH(output, &(croot->nodes_head), nodes) {
|
||||||
/* Skip outputs starting with __, they are internal. */
|
/* Skip outputs starting with __, they are internal. */
|
||||||
if (con_is_internal(output))
|
if (con_is_internal(output))
|
||||||
continue;
|
continue;
|
||||||
NODES_FOREACH (output_get_content(output)) {
|
NODES_FOREACH(output_get_content(output)) {
|
||||||
if (child->type != CT_WORKSPACE)
|
if (child->type != CT_WORKSPACE)
|
||||||
continue;
|
continue;
|
||||||
if (child == current) {
|
if (child == current) {
|
||||||
@ -512,11 +512,11 @@ Con *workspace_next(void) {
|
|||||||
|
|
||||||
/* Find first workspace. */
|
/* Find first workspace. */
|
||||||
if (!next) {
|
if (!next) {
|
||||||
TAILQ_FOREACH (output, &(croot->nodes_head), nodes) {
|
TAILQ_FOREACH(output, &(croot->nodes_head), nodes) {
|
||||||
/* Skip outputs starting with __, they are internal. */
|
/* Skip outputs starting with __, they are internal. */
|
||||||
if (con_is_internal(output))
|
if (con_is_internal(output))
|
||||||
continue;
|
continue;
|
||||||
NODES_FOREACH (output_get_content(output)) {
|
NODES_FOREACH(output_get_content(output)) {
|
||||||
if (child->type != CT_WORKSPACE)
|
if (child->type != CT_WORKSPACE)
|
||||||
continue;
|
continue;
|
||||||
if (!next || (child->num != -1 && child->num < next->num))
|
if (!next || (child->num != -1 && child->num < next->num))
|
||||||
@ -544,11 +544,11 @@ Con *workspace_prev(void) {
|
|||||||
prev = NULL;
|
prev = NULL;
|
||||||
} else {
|
} else {
|
||||||
/* If numbered workspace, find previous numbered workspace. */
|
/* If numbered workspace, find previous numbered workspace. */
|
||||||
TAILQ_FOREACH_REVERSE (output, &(croot->nodes_head), nodes_head, nodes) {
|
TAILQ_FOREACH_REVERSE(output, &(croot->nodes_head), nodes_head, nodes) {
|
||||||
/* Skip outputs starting with __, they are internal. */
|
/* Skip outputs starting with __, they are internal. */
|
||||||
if (con_is_internal(output))
|
if (con_is_internal(output))
|
||||||
continue;
|
continue;
|
||||||
NODES_FOREACH_REVERSE (output_get_content(output)) {
|
NODES_FOREACH_REVERSE(output_get_content(output)) {
|
||||||
if (child->type != CT_WORKSPACE || child->num == -1)
|
if (child->type != CT_WORKSPACE || child->num == -1)
|
||||||
continue;
|
continue;
|
||||||
/* Need to check child against current and previous because we
|
/* Need to check child against current and previous because we
|
||||||
@ -563,11 +563,11 @@ Con *workspace_prev(void) {
|
|||||||
/* Find previous named workspace. */
|
/* Find previous named workspace. */
|
||||||
if (!prev) {
|
if (!prev) {
|
||||||
bool found_current = false;
|
bool found_current = false;
|
||||||
TAILQ_FOREACH_REVERSE (output, &(croot->nodes_head), nodes_head, nodes) {
|
TAILQ_FOREACH_REVERSE(output, &(croot->nodes_head), nodes_head, nodes) {
|
||||||
/* Skip outputs starting with __, they are internal. */
|
/* Skip outputs starting with __, they are internal. */
|
||||||
if (con_is_internal(output))
|
if (con_is_internal(output))
|
||||||
continue;
|
continue;
|
||||||
NODES_FOREACH_REVERSE (output_get_content(output)) {
|
NODES_FOREACH_REVERSE(output_get_content(output)) {
|
||||||
if (child->type != CT_WORKSPACE)
|
if (child->type != CT_WORKSPACE)
|
||||||
continue;
|
continue;
|
||||||
if (child == current) {
|
if (child == current) {
|
||||||
@ -582,11 +582,11 @@ Con *workspace_prev(void) {
|
|||||||
|
|
||||||
/* Find last workspace. */
|
/* Find last workspace. */
|
||||||
if (!prev) {
|
if (!prev) {
|
||||||
TAILQ_FOREACH_REVERSE (output, &(croot->nodes_head), nodes_head, nodes) {
|
TAILQ_FOREACH_REVERSE(output, &(croot->nodes_head), nodes_head, nodes) {
|
||||||
/* Skip outputs starting with __, they are internal. */
|
/* Skip outputs starting with __, they are internal. */
|
||||||
if (con_is_internal(output))
|
if (con_is_internal(output))
|
||||||
continue;
|
continue;
|
||||||
NODES_FOREACH_REVERSE (output_get_content(output)) {
|
NODES_FOREACH_REVERSE(output_get_content(output)) {
|
||||||
if (child->type != CT_WORKSPACE)
|
if (child->type != CT_WORKSPACE)
|
||||||
continue;
|
continue;
|
||||||
if (!prev || child->num > prev->num)
|
if (!prev || child->num > prev->num)
|
||||||
@ -613,7 +613,7 @@ Con *workspace_next_on_output(void) {
|
|||||||
next = TAILQ_NEXT(current, nodes);
|
next = TAILQ_NEXT(current, nodes);
|
||||||
} else {
|
} else {
|
||||||
/* If currently a numbered workspace, find next numbered workspace. */
|
/* If currently a numbered workspace, find next numbered workspace. */
|
||||||
NODES_FOREACH (output_get_content(output)) {
|
NODES_FOREACH(output_get_content(output)) {
|
||||||
if (child->type != CT_WORKSPACE)
|
if (child->type != CT_WORKSPACE)
|
||||||
continue;
|
continue;
|
||||||
if (child->num == -1)
|
if (child->num == -1)
|
||||||
@ -629,7 +629,7 @@ Con *workspace_next_on_output(void) {
|
|||||||
/* Find next named workspace. */
|
/* Find next named workspace. */
|
||||||
if (!next) {
|
if (!next) {
|
||||||
bool found_current = false;
|
bool found_current = false;
|
||||||
NODES_FOREACH (output_get_content(output)) {
|
NODES_FOREACH(output_get_content(output)) {
|
||||||
if (child->type != CT_WORKSPACE)
|
if (child->type != CT_WORKSPACE)
|
||||||
continue;
|
continue;
|
||||||
if (child == current) {
|
if (child == current) {
|
||||||
@ -643,7 +643,7 @@ Con *workspace_next_on_output(void) {
|
|||||||
|
|
||||||
/* Find first workspace. */
|
/* Find first workspace. */
|
||||||
if (!next) {
|
if (!next) {
|
||||||
NODES_FOREACH (output_get_content(output)) {
|
NODES_FOREACH(output_get_content(output)) {
|
||||||
if (child->type != CT_WORKSPACE)
|
if (child->type != CT_WORKSPACE)
|
||||||
continue;
|
continue;
|
||||||
if (!next || (child->num != -1 && child->num < next->num))
|
if (!next || (child->num != -1 && child->num < next->num))
|
||||||
@ -671,7 +671,7 @@ Con *workspace_prev_on_output(void) {
|
|||||||
prev = NULL;
|
prev = NULL;
|
||||||
} else {
|
} else {
|
||||||
/* If numbered workspace, find previous numbered workspace. */
|
/* If numbered workspace, find previous numbered workspace. */
|
||||||
NODES_FOREACH_REVERSE (output_get_content(output)) {
|
NODES_FOREACH_REVERSE(output_get_content(output)) {
|
||||||
if (child->type != CT_WORKSPACE || child->num == -1)
|
if (child->type != CT_WORKSPACE || child->num == -1)
|
||||||
continue;
|
continue;
|
||||||
/* Need to check child against current and previous because we
|
/* Need to check child against current and previous because we
|
||||||
@ -685,7 +685,7 @@ Con *workspace_prev_on_output(void) {
|
|||||||
/* Find previous named workspace. */
|
/* Find previous named workspace. */
|
||||||
if (!prev) {
|
if (!prev) {
|
||||||
bool found_current = false;
|
bool found_current = false;
|
||||||
NODES_FOREACH_REVERSE (output_get_content(output)) {
|
NODES_FOREACH_REVERSE(output_get_content(output)) {
|
||||||
if (child->type != CT_WORKSPACE)
|
if (child->type != CT_WORKSPACE)
|
||||||
continue;
|
continue;
|
||||||
if (child == current) {
|
if (child == current) {
|
||||||
@ -699,7 +699,7 @@ Con *workspace_prev_on_output(void) {
|
|||||||
|
|
||||||
/* Find last workspace. */
|
/* Find last workspace. */
|
||||||
if (!prev) {
|
if (!prev) {
|
||||||
NODES_FOREACH_REVERSE (output_get_content(output)) {
|
NODES_FOREACH_REVERSE(output_get_content(output)) {
|
||||||
if (child->type != CT_WORKSPACE)
|
if (child->type != CT_WORKSPACE)
|
||||||
continue;
|
continue;
|
||||||
if (!prev || child->num > prev->num)
|
if (!prev || child->num > prev->num)
|
||||||
@ -742,13 +742,13 @@ Con *workspace_back_and_forth_get(void) {
|
|||||||
|
|
||||||
static bool get_urgency_flag(Con *con) {
|
static bool get_urgency_flag(Con *con) {
|
||||||
Con *child;
|
Con *child;
|
||||||
TAILQ_FOREACH (child, &(con->nodes_head), nodes)
|
TAILQ_FOREACH(child, &(con->nodes_head), nodes)
|
||||||
if (child->urgent || get_urgency_flag(child))
|
if (child->urgent || get_urgency_flag(child))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
TAILQ_FOREACH (child, &(con->floating_head), floating_windows)
|
TAILQ_FOREACH(child, &(con->floating_head), floating_windows)
|
||||||
if (child->urgent || get_urgency_flag(child))
|
if (child->urgent || get_urgency_flag(child))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
50
src/x.c
50
src/x.c
@ -76,9 +76,9 @@ TAILQ_HEAD(initial_mapping_head, con_state) initial_mapping_head =
|
|||||||
*/
|
*/
|
||||||
static con_state *state_for_frame(xcb_window_t window) {
|
static con_state *state_for_frame(xcb_window_t window) {
|
||||||
con_state *state;
|
con_state *state;
|
||||||
CIRCLEQ_FOREACH (state, &state_head, state)
|
CIRCLEQ_FOREACH(state, &state_head, state)
|
||||||
if (state->id == window)
|
if (state->id == window)
|
||||||
return state;
|
return state;
|
||||||
|
|
||||||
/* TODO: better error handling? */
|
/* TODO: better error handling? */
|
||||||
ELOG("No state found\n");
|
ELOG("No state found\n");
|
||||||
@ -579,11 +579,11 @@ void x_deco_recurse(Con *con) {
|
|||||||
con_state *state = state_for_frame(con->frame);
|
con_state *state = state_for_frame(con->frame);
|
||||||
|
|
||||||
if (!leaf) {
|
if (!leaf) {
|
||||||
TAILQ_FOREACH (current, &(con->nodes_head), nodes)
|
TAILQ_FOREACH(current, &(con->nodes_head), nodes)
|
||||||
x_deco_recurse(current);
|
x_deco_recurse(current);
|
||||||
|
|
||||||
TAILQ_FOREACH (current, &(con->floating_head), floating_windows)
|
TAILQ_FOREACH(current, &(con->floating_head), floating_windows)
|
||||||
x_deco_recurse(current);
|
x_deco_recurse(current);
|
||||||
|
|
||||||
if (state->mapped)
|
if (state->mapped)
|
||||||
xcb_copy_area(conn, con->pixmap, con->frame, con->pm_gc, 0, 0, 0, 0, con->rect.width, con->rect.height);
|
xcb_copy_area(conn, con->pixmap, con->frame, con->pm_gc, 0, 0, 0, 0, con->rect.width, con->rect.height);
|
||||||
@ -620,7 +620,7 @@ void x_push_node(Con *con) {
|
|||||||
/* Calculate the height of all window decorations which will be drawn on to
|
/* Calculate the height of all window decorations which will be drawn on to
|
||||||
* this frame. */
|
* this frame. */
|
||||||
uint32_t max_y = 0, max_height = 0;
|
uint32_t max_y = 0, max_height = 0;
|
||||||
TAILQ_FOREACH (current, &(con->nodes_head), nodes) {
|
TAILQ_FOREACH(current, &(con->nodes_head), nodes) {
|
||||||
Rect *dr = &(current->deco_rect);
|
Rect *dr = &(current->deco_rect);
|
||||||
if (dr->y >= max_y && dr->height >= max_height) {
|
if (dr->y >= max_y && dr->height >= max_height) {
|
||||||
max_y = dr->y;
|
max_y = dr->y;
|
||||||
@ -799,8 +799,8 @@ void x_push_node(Con *con) {
|
|||||||
/* Handle all children and floating windows of this node. We recurse
|
/* Handle all children and floating windows of this node. We recurse
|
||||||
* in focus order to display the focused client in a stack first when
|
* in focus order to display the focused client in a stack first when
|
||||||
* switching workspaces (reduces flickering). */
|
* switching workspaces (reduces flickering). */
|
||||||
TAILQ_FOREACH (current, &(con->focus_head), focused)
|
TAILQ_FOREACH(current, &(con->focus_head), focused)
|
||||||
x_push_node(current);
|
x_push_node(current);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -844,11 +844,11 @@ static void x_push_node_unmaps(Con *con) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* handle all children and floating windows of this node */
|
/* handle all children and floating windows of this node */
|
||||||
TAILQ_FOREACH (current, &(con->nodes_head), nodes)
|
TAILQ_FOREACH(current, &(con->nodes_head), nodes)
|
||||||
x_push_node_unmaps(current);
|
x_push_node_unmaps(current);
|
||||||
|
|
||||||
TAILQ_FOREACH (current, &(con->floating_head), floating_windows)
|
TAILQ_FOREACH(current, &(con->floating_head), floating_windows)
|
||||||
x_push_node_unmaps(current);
|
x_push_node_unmaps(current);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -861,7 +861,7 @@ static bool is_con_attached(Con *con) {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
Con *current;
|
Con *current;
|
||||||
TAILQ_FOREACH (current, &(con->parent->nodes_head), nodes) {
|
TAILQ_FOREACH(current, &(con->parent->nodes_head), nodes) {
|
||||||
if (current == con)
|
if (current == con)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -892,7 +892,7 @@ void x_push_changes(Con *con) {
|
|||||||
DLOG("-- PUSHING WINDOW STACK --\n");
|
DLOG("-- PUSHING WINDOW STACK --\n");
|
||||||
//DLOG("Disabling EnterNotify\n");
|
//DLOG("Disabling EnterNotify\n");
|
||||||
uint32_t values[1] = {XCB_NONE};
|
uint32_t values[1] = {XCB_NONE};
|
||||||
CIRCLEQ_FOREACH_REVERSE (state, &state_head, state) {
|
CIRCLEQ_FOREACH_REVERSE(state, &state_head, state) {
|
||||||
if (state->mapped)
|
if (state->mapped)
|
||||||
xcb_change_window_attributes(conn, state->id, XCB_CW_EVENT_MASK, values);
|
xcb_change_window_attributes(conn, state->id, XCB_CW_EVENT_MASK, values);
|
||||||
}
|
}
|
||||||
@ -903,9 +903,9 @@ void x_push_changes(Con *con) {
|
|||||||
/* count first, necessary to (re)allocate memory for the bottom-to-top
|
/* count first, necessary to (re)allocate memory for the bottom-to-top
|
||||||
* stack afterwards */
|
* stack afterwards */
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
CIRCLEQ_FOREACH_REVERSE (state, &state_head, state)
|
CIRCLEQ_FOREACH_REVERSE(state, &state_head, state)
|
||||||
if (con_has_managed_window(state->con))
|
if (con_has_managed_window(state->con))
|
||||||
cnt++;
|
cnt++;
|
||||||
|
|
||||||
/* The bottom-to-top window stack of all windows which are managed by i3.
|
/* The bottom-to-top window stack of all windows which are managed by i3.
|
||||||
* Used for x_get_window_stack(). */
|
* Used for x_get_window_stack(). */
|
||||||
@ -920,7 +920,7 @@ void x_push_changes(Con *con) {
|
|||||||
xcb_window_t *walk = client_list_windows;
|
xcb_window_t *walk = client_list_windows;
|
||||||
|
|
||||||
/* X11 correctly represents the stack if we push it from bottom to top */
|
/* X11 correctly represents the stack if we push it from bottom to top */
|
||||||
CIRCLEQ_FOREACH_REVERSE (state, &state_head, state) {
|
CIRCLEQ_FOREACH_REVERSE(state, &state_head, state) {
|
||||||
if (con_has_managed_window(state->con))
|
if (con_has_managed_window(state->con))
|
||||||
memcpy(walk++, &(state->con->window->id), sizeof(xcb_window_t));
|
memcpy(walk++, &(state->con->window->id), sizeof(xcb_window_t));
|
||||||
|
|
||||||
@ -951,7 +951,7 @@ void x_push_changes(Con *con) {
|
|||||||
walk = client_list_windows;
|
walk = client_list_windows;
|
||||||
|
|
||||||
/* reorder by initial mapping */
|
/* reorder by initial mapping */
|
||||||
TAILQ_FOREACH (state, &initial_mapping_head, initial_mapping_order) {
|
TAILQ_FOREACH(state, &initial_mapping_head, initial_mapping_order) {
|
||||||
if (con_has_managed_window(state->con))
|
if (con_has_managed_window(state->con))
|
||||||
*walk++ = state->con->window->id;
|
*walk++ = state->con->window->id;
|
||||||
}
|
}
|
||||||
@ -984,7 +984,7 @@ void x_push_changes(Con *con) {
|
|||||||
|
|
||||||
//DLOG("Re-enabling EnterNotify\n");
|
//DLOG("Re-enabling EnterNotify\n");
|
||||||
values[0] = FRAME_EVENT_MASK;
|
values[0] = FRAME_EVENT_MASK;
|
||||||
CIRCLEQ_FOREACH_REVERSE (state, &state_head, state) {
|
CIRCLEQ_FOREACH_REVERSE(state, &state_head, state) {
|
||||||
if (state->mapped)
|
if (state->mapped)
|
||||||
xcb_change_window_attributes(conn, state->id, XCB_CW_EVENT_MASK, values);
|
xcb_change_window_attributes(conn, state->id, XCB_CW_EVENT_MASK, values);
|
||||||
}
|
}
|
||||||
@ -1056,7 +1056,7 @@ void x_push_changes(Con *con) {
|
|||||||
* unmapped, the second one appears under the cursor and therefore gets an
|
* unmapped, the second one appears under the cursor and therefore gets an
|
||||||
* EnterNotify event. */
|
* EnterNotify event. */
|
||||||
values[0] = FRAME_EVENT_MASK & ~XCB_EVENT_MASK_ENTER_WINDOW;
|
values[0] = FRAME_EVENT_MASK & ~XCB_EVENT_MASK_ENTER_WINDOW;
|
||||||
CIRCLEQ_FOREACH_REVERSE (state, &state_head, state) {
|
CIRCLEQ_FOREACH_REVERSE(state, &state_head, state) {
|
||||||
if (!state->unmap_now)
|
if (!state->unmap_now)
|
||||||
continue;
|
continue;
|
||||||
xcb_change_window_attributes(conn, state->id, XCB_CW_EVENT_MASK, values);
|
xcb_change_window_attributes(conn, state->id, XCB_CW_EVENT_MASK, values);
|
||||||
@ -1066,7 +1066,7 @@ void x_push_changes(Con *con) {
|
|||||||
x_push_node_unmaps(con);
|
x_push_node_unmaps(con);
|
||||||
|
|
||||||
/* save the current stack as old stack */
|
/* save the current stack as old stack */
|
||||||
CIRCLEQ_FOREACH (state, &state_head, state) {
|
CIRCLEQ_FOREACH(state, &state_head, state) {
|
||||||
CIRCLEQ_REMOVE(&old_state_head, state, old_state);
|
CIRCLEQ_REMOVE(&old_state_head, state, old_state);
|
||||||
CIRCLEQ_INSERT_TAIL(&old_state_head, state, old_state);
|
CIRCLEQ_INSERT_TAIL(&old_state_head, state, old_state);
|
||||||
}
|
}
|
||||||
@ -1155,7 +1155,7 @@ void x_mask_event_mask(uint32_t mask) {
|
|||||||
uint32_t values[] = {FRAME_EVENT_MASK & mask};
|
uint32_t values[] = {FRAME_EVENT_MASK & mask};
|
||||||
|
|
||||||
con_state *state;
|
con_state *state;
|
||||||
CIRCLEQ_FOREACH_REVERSE (state, &state_head, state) {
|
CIRCLEQ_FOREACH_REVERSE(state, &state_head, state) {
|
||||||
if (state->mapped)
|
if (state->mapped)
|
||||||
xcb_change_window_attributes(conn, state->id, XCB_CW_EVENT_MASK, values);
|
xcb_change_window_attributes(conn, state->id, XCB_CW_EVENT_MASK, values);
|
||||||
}
|
}
|
||||||
|
@ -23,9 +23,9 @@ static int num_screens;
|
|||||||
*/
|
*/
|
||||||
static Output *get_screen_at(unsigned int x, unsigned int y) {
|
static Output *get_screen_at(unsigned int x, unsigned int y) {
|
||||||
Output *output;
|
Output *output;
|
||||||
TAILQ_FOREACH (output, &outputs, outputs)
|
TAILQ_FOREACH(output, &outputs, outputs)
|
||||||
if (output->rect.x == x && output->rect.y == y)
|
if (output->rect.x == x && output->rect.y == y)
|
||||||
return output;
|
return output;
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
681
tests/queue.h
681
tests/queue.h
@ -90,435 +90,454 @@
|
|||||||
/*
|
/*
|
||||||
* Singly-linked List definitions.
|
* Singly-linked List definitions.
|
||||||
*/
|
*/
|
||||||
#define SLIST_HEAD(name, type) \
|
#define SLIST_HEAD(name, type) \
|
||||||
struct name { \
|
struct name { \
|
||||||
struct type *slh_first; /* first element */ \
|
struct type *slh_first; /* first element */ \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SLIST_HEAD_INITIALIZER(head) \
|
#define SLIST_HEAD_INITIALIZER(head) \
|
||||||
{ NULL }
|
{ NULL }
|
||||||
|
|
||||||
#define SLIST_ENTRY(type) \
|
#define SLIST_ENTRY(type) \
|
||||||
struct { \
|
struct { \
|
||||||
struct type *sle_next; /* next element */ \
|
struct type *sle_next; /* next element */ \
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Singly-linked List access methods.
|
* Singly-linked List access methods.
|
||||||
*/
|
*/
|
||||||
#define SLIST_FIRST(head) ((head)->slh_first)
|
#define SLIST_FIRST(head) ((head)->slh_first)
|
||||||
#define SLIST_END(head) NULL
|
#define SLIST_END(head) NULL
|
||||||
#define SLIST_EMPTY(head) (SLIST_FIRST(head) == SLIST_END(head))
|
#define SLIST_EMPTY(head) (SLIST_FIRST(head) == SLIST_END(head))
|
||||||
#define SLIST_NEXT(elm, field) ((elm)->field.sle_next)
|
#define SLIST_NEXT(elm, field) ((elm)->field.sle_next)
|
||||||
|
|
||||||
#define SLIST_FOREACH(var, head, field) \
|
#define SLIST_FOREACH(var, head, field) \
|
||||||
for((var) = SLIST_FIRST(head); \
|
for ((var) = SLIST_FIRST(head); \
|
||||||
(var) != SLIST_END(head); \
|
(var) != SLIST_END(head); \
|
||||||
(var) = SLIST_NEXT(var, field))
|
(var) = SLIST_NEXT(var, field))
|
||||||
|
|
||||||
#define SLIST_FOREACH_PREVPTR(var, varp, head, field) \
|
#define SLIST_FOREACH_PREVPTR(var, varp, head, field) \
|
||||||
for ((varp) = &SLIST_FIRST((head)); \
|
for ((varp) = &SLIST_FIRST((head)); \
|
||||||
((var) = *(varp)) != SLIST_END(head); \
|
((var) = *(varp)) != SLIST_END(head); \
|
||||||
(varp) = &SLIST_NEXT((var), field))
|
(varp) = &SLIST_NEXT((var), field))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Singly-linked List functions.
|
* Singly-linked List functions.
|
||||||
*/
|
*/
|
||||||
#define SLIST_INIT(head) { \
|
#define SLIST_INIT(head) \
|
||||||
SLIST_FIRST(head) = SLIST_END(head); \
|
{ \
|
||||||
}
|
SLIST_FIRST(head) = SLIST_END(head); \
|
||||||
|
}
|
||||||
|
|
||||||
#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \
|
#define SLIST_INSERT_AFTER(slistelm, elm, field) \
|
||||||
(elm)->field.sle_next = (slistelm)->field.sle_next; \
|
do { \
|
||||||
(slistelm)->field.sle_next = (elm); \
|
(elm)->field.sle_next = (slistelm)->field.sle_next; \
|
||||||
} while (0)
|
(slistelm)->field.sle_next = (elm); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define SLIST_INSERT_HEAD(head, elm, field) do { \
|
#define SLIST_INSERT_HEAD(head, elm, field) \
|
||||||
(elm)->field.sle_next = (head)->slh_first; \
|
do { \
|
||||||
(head)->slh_first = (elm); \
|
(elm)->field.sle_next = (head)->slh_first; \
|
||||||
} while (0)
|
(head)->slh_first = (elm); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define SLIST_REMOVE_NEXT(head, elm, field) do { \
|
#define SLIST_REMOVE_NEXT(head, elm, field) \
|
||||||
(elm)->field.sle_next = (elm)->field.sle_next->field.sle_next; \
|
do { \
|
||||||
} while (0)
|
(elm)->field.sle_next = (elm)->field.sle_next->field.sle_next; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define SLIST_REMOVE_HEAD(head, field) do { \
|
#define SLIST_REMOVE_HEAD(head, field) \
|
||||||
(head)->slh_first = (head)->slh_first->field.sle_next; \
|
do { \
|
||||||
} while (0)
|
(head)->slh_first = (head)->slh_first->field.sle_next; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define SLIST_REMOVE(head, elm, type, field) do { \
|
#define SLIST_REMOVE(head, elm, type, field) \
|
||||||
if ((head)->slh_first == (elm)) { \
|
do { \
|
||||||
SLIST_REMOVE_HEAD((head), field); \
|
if ((head)->slh_first == (elm)) { \
|
||||||
} else { \
|
SLIST_REMOVE_HEAD((head), field); \
|
||||||
struct type *curelm = (head)->slh_first; \
|
} else { \
|
||||||
\
|
struct type *curelm = (head)->slh_first; \
|
||||||
while (curelm->field.sle_next != (elm)) \
|
\
|
||||||
curelm = curelm->field.sle_next; \
|
while (curelm->field.sle_next != (elm)) \
|
||||||
curelm->field.sle_next = \
|
curelm = curelm->field.sle_next; \
|
||||||
curelm->field.sle_next->field.sle_next; \
|
curelm->field.sle_next = curelm->field.sle_next->field.sle_next; \
|
||||||
_Q_INVALIDATE((elm)->field.sle_next); \
|
_Q_INVALIDATE((elm)->field.sle_next); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* List definitions.
|
* List definitions.
|
||||||
*/
|
*/
|
||||||
#define LIST_HEAD(name, type) \
|
#define LIST_HEAD(name, type) \
|
||||||
struct name { \
|
struct name { \
|
||||||
struct type *lh_first; /* first element */ \
|
struct type *lh_first; /* first element */ \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define LIST_HEAD_INITIALIZER(head) \
|
#define LIST_HEAD_INITIALIZER(head) \
|
||||||
{ NULL }
|
{ NULL }
|
||||||
|
|
||||||
#define LIST_ENTRY(type) \
|
#define LIST_ENTRY(type) \
|
||||||
struct { \
|
struct { \
|
||||||
struct type *le_next; /* next element */ \
|
struct type *le_next; /* next element */ \
|
||||||
struct type **le_prev; /* address of previous next element */ \
|
struct type **le_prev; /* address of previous next element */ \
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* List access methods
|
* List access methods
|
||||||
*/
|
*/
|
||||||
#define LIST_FIRST(head) ((head)->lh_first)
|
#define LIST_FIRST(head) ((head)->lh_first)
|
||||||
#define LIST_END(head) NULL
|
#define LIST_END(head) NULL
|
||||||
#define LIST_EMPTY(head) (LIST_FIRST(head) == LIST_END(head))
|
#define LIST_EMPTY(head) (LIST_FIRST(head) == LIST_END(head))
|
||||||
#define LIST_NEXT(elm, field) ((elm)->field.le_next)
|
#define LIST_NEXT(elm, field) ((elm)->field.le_next)
|
||||||
|
|
||||||
#define LIST_FOREACH(var, head, field) \
|
#define LIST_FOREACH(var, head, field) \
|
||||||
for((var) = LIST_FIRST(head); \
|
for ((var) = LIST_FIRST(head); \
|
||||||
(var)!= LIST_END(head); \
|
(var) != LIST_END(head); \
|
||||||
(var) = LIST_NEXT(var, field))
|
(var) = LIST_NEXT(var, field))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* List functions.
|
* List functions.
|
||||||
*/
|
*/
|
||||||
#define LIST_INIT(head) do { \
|
#define LIST_INIT(head) \
|
||||||
LIST_FIRST(head) = LIST_END(head); \
|
do { \
|
||||||
} while (0)
|
LIST_FIRST(head) = LIST_END(head); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define LIST_INSERT_AFTER(listelm, elm, field) do { \
|
#define LIST_INSERT_AFTER(listelm, elm, field) \
|
||||||
if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \
|
do { \
|
||||||
(listelm)->field.le_next->field.le_prev = \
|
if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \
|
||||||
&(elm)->field.le_next; \
|
(listelm)->field.le_next->field.le_prev = &(elm)->field.le_next; \
|
||||||
(listelm)->field.le_next = (elm); \
|
(listelm)->field.le_next = (elm); \
|
||||||
(elm)->field.le_prev = &(listelm)->field.le_next; \
|
(elm)->field.le_prev = &(listelm)->field.le_next; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define LIST_INSERT_BEFORE(listelm, elm, field) do { \
|
#define LIST_INSERT_BEFORE(listelm, elm, field) \
|
||||||
(elm)->field.le_prev = (listelm)->field.le_prev; \
|
do { \
|
||||||
(elm)->field.le_next = (listelm); \
|
(elm)->field.le_prev = (listelm)->field.le_prev; \
|
||||||
*(listelm)->field.le_prev = (elm); \
|
(elm)->field.le_next = (listelm); \
|
||||||
(listelm)->field.le_prev = &(elm)->field.le_next; \
|
*(listelm)->field.le_prev = (elm); \
|
||||||
} while (0)
|
(listelm)->field.le_prev = &(elm)->field.le_next; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define LIST_INSERT_HEAD(head, elm, field) do { \
|
#define LIST_INSERT_HEAD(head, elm, field) \
|
||||||
if (((elm)->field.le_next = (head)->lh_first) != NULL) \
|
do { \
|
||||||
(head)->lh_first->field.le_prev = &(elm)->field.le_next;\
|
if (((elm)->field.le_next = (head)->lh_first) != NULL) \
|
||||||
(head)->lh_first = (elm); \
|
(head)->lh_first->field.le_prev = &(elm)->field.le_next; \
|
||||||
(elm)->field.le_prev = &(head)->lh_first; \
|
(head)->lh_first = (elm); \
|
||||||
} while (0)
|
(elm)->field.le_prev = &(head)->lh_first; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define LIST_REMOVE(elm, field) do { \
|
#define LIST_REMOVE(elm, field) \
|
||||||
if ((elm)->field.le_next != NULL) \
|
do { \
|
||||||
(elm)->field.le_next->field.le_prev = \
|
if ((elm)->field.le_next != NULL) \
|
||||||
(elm)->field.le_prev; \
|
(elm)->field.le_next->field.le_prev = (elm)->field.le_prev; \
|
||||||
*(elm)->field.le_prev = (elm)->field.le_next; \
|
*(elm)->field.le_prev = (elm)->field.le_next; \
|
||||||
_Q_INVALIDATE((elm)->field.le_prev); \
|
_Q_INVALIDATE((elm)->field.le_prev); \
|
||||||
_Q_INVALIDATE((elm)->field.le_next); \
|
_Q_INVALIDATE((elm)->field.le_next); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define LIST_REPLACE(elm, elm2, field) do { \
|
#define LIST_REPLACE(elm, elm2, field) \
|
||||||
if (((elm2)->field.le_next = (elm)->field.le_next) != NULL) \
|
do { \
|
||||||
(elm2)->field.le_next->field.le_prev = \
|
if (((elm2)->field.le_next = (elm)->field.le_next) != NULL) \
|
||||||
&(elm2)->field.le_next; \
|
(elm2)->field.le_next->field.le_prev = &(elm2)->field.le_next; \
|
||||||
(elm2)->field.le_prev = (elm)->field.le_prev; \
|
(elm2)->field.le_prev = (elm)->field.le_prev; \
|
||||||
*(elm2)->field.le_prev = (elm2); \
|
*(elm2)->field.le_prev = (elm2); \
|
||||||
_Q_INVALIDATE((elm)->field.le_prev); \
|
_Q_INVALIDATE((elm)->field.le_prev); \
|
||||||
_Q_INVALIDATE((elm)->field.le_next); \
|
_Q_INVALIDATE((elm)->field.le_next); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Simple queue definitions.
|
* Simple queue definitions.
|
||||||
*/
|
*/
|
||||||
#define SIMPLEQ_HEAD(name, type) \
|
#define SIMPLEQ_HEAD(name, type) \
|
||||||
struct name { \
|
struct name { \
|
||||||
struct type *sqh_first; /* first element */ \
|
struct type *sqh_first; /* first element */ \
|
||||||
struct type **sqh_last; /* addr of last next element */ \
|
struct type **sqh_last; /* addr of last next element */ \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SIMPLEQ_HEAD_INITIALIZER(head) \
|
#define SIMPLEQ_HEAD_INITIALIZER(head) \
|
||||||
{ NULL, &(head).sqh_first }
|
{ NULL, &(head).sqh_first }
|
||||||
|
|
||||||
#define SIMPLEQ_ENTRY(type) \
|
#define SIMPLEQ_ENTRY(type) \
|
||||||
struct { \
|
struct { \
|
||||||
struct type *sqe_next; /* next element */ \
|
struct type *sqe_next; /* next element */ \
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Simple queue access methods.
|
* Simple queue access methods.
|
||||||
*/
|
*/
|
||||||
#define SIMPLEQ_FIRST(head) ((head)->sqh_first)
|
#define SIMPLEQ_FIRST(head) ((head)->sqh_first)
|
||||||
#define SIMPLEQ_END(head) NULL
|
#define SIMPLEQ_END(head) NULL
|
||||||
#define SIMPLEQ_EMPTY(head) (SIMPLEQ_FIRST(head) == SIMPLEQ_END(head))
|
#define SIMPLEQ_EMPTY(head) (SIMPLEQ_FIRST(head) == SIMPLEQ_END(head))
|
||||||
#define SIMPLEQ_NEXT(elm, field) ((elm)->field.sqe_next)
|
#define SIMPLEQ_NEXT(elm, field) ((elm)->field.sqe_next)
|
||||||
|
|
||||||
#define SIMPLEQ_FOREACH(var, head, field) \
|
#define SIMPLEQ_FOREACH(var, head, field) \
|
||||||
for((var) = SIMPLEQ_FIRST(head); \
|
for ((var) = SIMPLEQ_FIRST(head); \
|
||||||
(var) != SIMPLEQ_END(head); \
|
(var) != SIMPLEQ_END(head); \
|
||||||
(var) = SIMPLEQ_NEXT(var, field))
|
(var) = SIMPLEQ_NEXT(var, field))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Simple queue functions.
|
* Simple queue functions.
|
||||||
*/
|
*/
|
||||||
#define SIMPLEQ_INIT(head) do { \
|
#define SIMPLEQ_INIT(head) \
|
||||||
(head)->sqh_first = NULL; \
|
do { \
|
||||||
(head)->sqh_last = &(head)->sqh_first; \
|
(head)->sqh_first = NULL; \
|
||||||
} while (0)
|
(head)->sqh_last = &(head)->sqh_first; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define SIMPLEQ_INSERT_HEAD(head, elm, field) do { \
|
#define SIMPLEQ_INSERT_HEAD(head, elm, field) \
|
||||||
if (((elm)->field.sqe_next = (head)->sqh_first) == NULL) \
|
do { \
|
||||||
(head)->sqh_last = &(elm)->field.sqe_next; \
|
if (((elm)->field.sqe_next = (head)->sqh_first) == NULL) \
|
||||||
(head)->sqh_first = (elm); \
|
(head)->sqh_last = &(elm)->field.sqe_next; \
|
||||||
} while (0)
|
(head)->sqh_first = (elm); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define SIMPLEQ_INSERT_TAIL(head, elm, field) do { \
|
#define SIMPLEQ_INSERT_TAIL(head, elm, field) \
|
||||||
(elm)->field.sqe_next = NULL; \
|
do { \
|
||||||
*(head)->sqh_last = (elm); \
|
(elm)->field.sqe_next = NULL; \
|
||||||
(head)->sqh_last = &(elm)->field.sqe_next; \
|
*(head)->sqh_last = (elm); \
|
||||||
} while (0)
|
(head)->sqh_last = &(elm)->field.sqe_next; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do { \
|
#define SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) \
|
||||||
if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL)\
|
do { \
|
||||||
(head)->sqh_last = &(elm)->field.sqe_next; \
|
if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL) \
|
||||||
(listelm)->field.sqe_next = (elm); \
|
(head)->sqh_last = &(elm)->field.sqe_next; \
|
||||||
} while (0)
|
(listelm)->field.sqe_next = (elm); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define SIMPLEQ_REMOVE_HEAD(head, field) do { \
|
#define SIMPLEQ_REMOVE_HEAD(head, field) \
|
||||||
if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL) \
|
do { \
|
||||||
(head)->sqh_last = &(head)->sqh_first; \
|
if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL) \
|
||||||
} while (0)
|
(head)->sqh_last = &(head)->sqh_first; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Tail queue definitions.
|
* Tail queue definitions.
|
||||||
*/
|
*/
|
||||||
#define TAILQ_HEAD(name, type) \
|
#define TAILQ_HEAD(name, type) \
|
||||||
struct name { \
|
struct name { \
|
||||||
struct type *tqh_first; /* first element */ \
|
struct type *tqh_first; /* first element */ \
|
||||||
struct type **tqh_last; /* addr of last next element */ \
|
struct type **tqh_last; /* addr of last next element */ \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define TAILQ_HEAD_INITIALIZER(head) \
|
#define TAILQ_HEAD_INITIALIZER(head) \
|
||||||
{ NULL, &(head).tqh_first }
|
{ NULL, &(head).tqh_first }
|
||||||
|
|
||||||
#define TAILQ_ENTRY(type) \
|
#define TAILQ_ENTRY(type) \
|
||||||
struct { \
|
struct { \
|
||||||
struct type *tqe_next; /* next element */ \
|
struct type *tqe_next; /* next element */ \
|
||||||
struct type **tqe_prev; /* address of previous next element */ \
|
struct type **tqe_prev; /* address of previous next element */ \
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* tail queue access methods
|
* tail queue access methods
|
||||||
*/
|
*/
|
||||||
#define TAILQ_FIRST(head) ((head)->tqh_first)
|
#define TAILQ_FIRST(head) ((head)->tqh_first)
|
||||||
#define TAILQ_END(head) NULL
|
#define TAILQ_END(head) NULL
|
||||||
#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
|
#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
|
||||||
#define TAILQ_LAST(head, headname) \
|
#define TAILQ_LAST(head, headname) \
|
||||||
(*(((struct headname *)((head)->tqh_last))->tqh_last))
|
(*(((struct headname *)((head)->tqh_last))->tqh_last))
|
||||||
/* XXX */
|
/* XXX */
|
||||||
#define TAILQ_PREV(elm, headname, field) \
|
#define TAILQ_PREV(elm, headname, field) \
|
||||||
(*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
|
(*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
|
||||||
#define TAILQ_EMPTY(head) \
|
#define TAILQ_EMPTY(head) \
|
||||||
(TAILQ_FIRST(head) == TAILQ_END(head))
|
(TAILQ_FIRST(head) == TAILQ_END(head))
|
||||||
|
|
||||||
#define TAILQ_FOREACH(var, head, field) \
|
#define TAILQ_FOREACH(var, head, field) \
|
||||||
for((var) = TAILQ_FIRST(head); \
|
for ((var) = TAILQ_FIRST(head); \
|
||||||
(var) != TAILQ_END(head); \
|
(var) != TAILQ_END(head); \
|
||||||
(var) = TAILQ_NEXT(var, field))
|
(var) = TAILQ_NEXT(var, field))
|
||||||
|
|
||||||
#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \
|
#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \
|
||||||
for((var) = TAILQ_LAST(head, headname); \
|
for ((var) = TAILQ_LAST(head, headname); \
|
||||||
(var) != TAILQ_END(head); \
|
(var) != TAILQ_END(head); \
|
||||||
(var) = TAILQ_PREV(var, headname, field))
|
(var) = TAILQ_PREV(var, headname, field))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Tail queue functions.
|
* Tail queue functions.
|
||||||
*/
|
*/
|
||||||
#define TAILQ_INIT(head) do { \
|
#define TAILQ_INIT(head) \
|
||||||
(head)->tqh_first = NULL; \
|
do { \
|
||||||
(head)->tqh_last = &(head)->tqh_first; \
|
(head)->tqh_first = NULL; \
|
||||||
} while (0)
|
(head)->tqh_last = &(head)->tqh_first; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define TAILQ_INSERT_HEAD(head, elm, field) do { \
|
#define TAILQ_INSERT_HEAD(head, elm, field) \
|
||||||
if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \
|
do { \
|
||||||
(head)->tqh_first->field.tqe_prev = \
|
if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \
|
||||||
&(elm)->field.tqe_next; \
|
(head)->tqh_first->field.tqe_prev = &(elm)->field.tqe_next; \
|
||||||
else \
|
else \
|
||||||
(head)->tqh_last = &(elm)->field.tqe_next; \
|
(head)->tqh_last = &(elm)->field.tqe_next; \
|
||||||
(head)->tqh_first = (elm); \
|
(head)->tqh_first = (elm); \
|
||||||
(elm)->field.tqe_prev = &(head)->tqh_first; \
|
(elm)->field.tqe_prev = &(head)->tqh_first; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define TAILQ_INSERT_TAIL(head, elm, field) do { \
|
#define TAILQ_INSERT_TAIL(head, elm, field) \
|
||||||
(elm)->field.tqe_next = NULL; \
|
do { \
|
||||||
(elm)->field.tqe_prev = (head)->tqh_last; \
|
(elm)->field.tqe_next = NULL; \
|
||||||
*(head)->tqh_last = (elm); \
|
(elm)->field.tqe_prev = (head)->tqh_last; \
|
||||||
(head)->tqh_last = &(elm)->field.tqe_next; \
|
*(head)->tqh_last = (elm); \
|
||||||
} while (0)
|
(head)->tqh_last = &(elm)->field.tqe_next; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \
|
#define TAILQ_INSERT_AFTER(head, listelm, elm, field) \
|
||||||
if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\
|
do { \
|
||||||
(elm)->field.tqe_next->field.tqe_prev = \
|
if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL) \
|
||||||
&(elm)->field.tqe_next; \
|
(elm)->field.tqe_next->field.tqe_prev = &(elm)->field.tqe_next; \
|
||||||
else \
|
else \
|
||||||
(head)->tqh_last = &(elm)->field.tqe_next; \
|
(head)->tqh_last = &(elm)->field.tqe_next; \
|
||||||
(listelm)->field.tqe_next = (elm); \
|
(listelm)->field.tqe_next = (elm); \
|
||||||
(elm)->field.tqe_prev = &(listelm)->field.tqe_next; \
|
(elm)->field.tqe_prev = &(listelm)->field.tqe_next; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \
|
#define TAILQ_INSERT_BEFORE(listelm, elm, field) \
|
||||||
(elm)->field.tqe_prev = (listelm)->field.tqe_prev; \
|
do { \
|
||||||
(elm)->field.tqe_next = (listelm); \
|
(elm)->field.tqe_prev = (listelm)->field.tqe_prev; \
|
||||||
*(listelm)->field.tqe_prev = (elm); \
|
(elm)->field.tqe_next = (listelm); \
|
||||||
(listelm)->field.tqe_prev = &(elm)->field.tqe_next; \
|
*(listelm)->field.tqe_prev = (elm); \
|
||||||
} while (0)
|
(listelm)->field.tqe_prev = &(elm)->field.tqe_next; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define TAILQ_REMOVE(head, elm, field) do { \
|
#define TAILQ_REMOVE(head, elm, field) \
|
||||||
if (((elm)->field.tqe_next) != NULL) \
|
do { \
|
||||||
(elm)->field.tqe_next->field.tqe_prev = \
|
if (((elm)->field.tqe_next) != NULL) \
|
||||||
(elm)->field.tqe_prev; \
|
(elm)->field.tqe_next->field.tqe_prev = (elm)->field.tqe_prev; \
|
||||||
else \
|
else \
|
||||||
(head)->tqh_last = (elm)->field.tqe_prev; \
|
(head)->tqh_last = (elm)->field.tqe_prev; \
|
||||||
*(elm)->field.tqe_prev = (elm)->field.tqe_next; \
|
*(elm)->field.tqe_prev = (elm)->field.tqe_next; \
|
||||||
_Q_INVALIDATE((elm)->field.tqe_prev); \
|
_Q_INVALIDATE((elm)->field.tqe_prev); \
|
||||||
_Q_INVALIDATE((elm)->field.tqe_next); \
|
_Q_INVALIDATE((elm)->field.tqe_next); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define TAILQ_REPLACE(head, elm, elm2, field) do { \
|
#define TAILQ_REPLACE(head, elm, elm2, field) \
|
||||||
if (((elm2)->field.tqe_next = (elm)->field.tqe_next) != NULL) \
|
do { \
|
||||||
(elm2)->field.tqe_next->field.tqe_prev = \
|
if (((elm2)->field.tqe_next = (elm)->field.tqe_next) != NULL) \
|
||||||
&(elm2)->field.tqe_next; \
|
(elm2)->field.tqe_next->field.tqe_prev = &(elm2)->field.tqe_next; \
|
||||||
else \
|
else \
|
||||||
(head)->tqh_last = &(elm2)->field.tqe_next; \
|
(head)->tqh_last = &(elm2)->field.tqe_next; \
|
||||||
(elm2)->field.tqe_prev = (elm)->field.tqe_prev; \
|
(elm2)->field.tqe_prev = (elm)->field.tqe_prev; \
|
||||||
*(elm2)->field.tqe_prev = (elm2); \
|
*(elm2)->field.tqe_prev = (elm2); \
|
||||||
_Q_INVALIDATE((elm)->field.tqe_prev); \
|
_Q_INVALIDATE((elm)->field.tqe_prev); \
|
||||||
_Q_INVALIDATE((elm)->field.tqe_next); \
|
_Q_INVALIDATE((elm)->field.tqe_next); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Circular queue definitions.
|
* Circular queue definitions.
|
||||||
*/
|
*/
|
||||||
#define CIRCLEQ_HEAD(name, type) \
|
#define CIRCLEQ_HEAD(name, type) \
|
||||||
struct name { \
|
struct name { \
|
||||||
struct type *cqh_first; /* first element */ \
|
struct type *cqh_first; /* first element */ \
|
||||||
struct type *cqh_last; /* last element */ \
|
struct type *cqh_last; /* last element */ \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CIRCLEQ_HEAD_INITIALIZER(head) \
|
#define CIRCLEQ_HEAD_INITIALIZER(head) \
|
||||||
{ CIRCLEQ_END(&head), CIRCLEQ_END(&head) }
|
{ CIRCLEQ_END(&head), CIRCLEQ_END(&head) }
|
||||||
|
|
||||||
#define CIRCLEQ_ENTRY(type) \
|
#define CIRCLEQ_ENTRY(type) \
|
||||||
struct { \
|
struct { \
|
||||||
struct type *cqe_next; /* next element */ \
|
struct type *cqe_next; /* next element */ \
|
||||||
struct type *cqe_prev; /* previous element */ \
|
struct type *cqe_prev; /* previous element */ \
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Circular queue access methods
|
* Circular queue access methods
|
||||||
*/
|
*/
|
||||||
#define CIRCLEQ_FIRST(head) ((head)->cqh_first)
|
#define CIRCLEQ_FIRST(head) ((head)->cqh_first)
|
||||||
#define CIRCLEQ_LAST(head) ((head)->cqh_last)
|
#define CIRCLEQ_LAST(head) ((head)->cqh_last)
|
||||||
#define CIRCLEQ_END(head) ((void *)(head))
|
#define CIRCLEQ_END(head) ((void *)(head))
|
||||||
#define CIRCLEQ_NEXT(elm, field) ((elm)->field.cqe_next)
|
#define CIRCLEQ_NEXT(elm, field) ((elm)->field.cqe_next)
|
||||||
#define CIRCLEQ_PREV(elm, field) ((elm)->field.cqe_prev)
|
#define CIRCLEQ_PREV(elm, field) ((elm)->field.cqe_prev)
|
||||||
#define CIRCLEQ_EMPTY(head) \
|
#define CIRCLEQ_EMPTY(head) \
|
||||||
(CIRCLEQ_FIRST(head) == CIRCLEQ_END(head))
|
(CIRCLEQ_FIRST(head) == CIRCLEQ_END(head))
|
||||||
|
|
||||||
#define CIRCLEQ_FOREACH(var, head, field) \
|
#define CIRCLEQ_FOREACH(var, head, field) \
|
||||||
for((var) = CIRCLEQ_FIRST(head); \
|
for ((var) = CIRCLEQ_FIRST(head); \
|
||||||
(var) != CIRCLEQ_END(head); \
|
(var) != CIRCLEQ_END(head); \
|
||||||
(var) = CIRCLEQ_NEXT(var, field))
|
(var) = CIRCLEQ_NEXT(var, field))
|
||||||
|
|
||||||
#define CIRCLEQ_FOREACH_REVERSE(var, head, field) \
|
#define CIRCLEQ_FOREACH_REVERSE(var, head, field) \
|
||||||
for((var) = CIRCLEQ_LAST(head); \
|
for ((var) = CIRCLEQ_LAST(head); \
|
||||||
(var) != CIRCLEQ_END(head); \
|
(var) != CIRCLEQ_END(head); \
|
||||||
(var) = CIRCLEQ_PREV(var, field))
|
(var) = CIRCLEQ_PREV(var, field))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Circular queue functions.
|
* Circular queue functions.
|
||||||
*/
|
*/
|
||||||
#define CIRCLEQ_INIT(head) do { \
|
#define CIRCLEQ_INIT(head) \
|
||||||
(head)->cqh_first = CIRCLEQ_END(head); \
|
do { \
|
||||||
(head)->cqh_last = CIRCLEQ_END(head); \
|
(head)->cqh_first = CIRCLEQ_END(head); \
|
||||||
} while (0)
|
(head)->cqh_last = CIRCLEQ_END(head); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do { \
|
#define CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) \
|
||||||
(elm)->field.cqe_next = (listelm)->field.cqe_next; \
|
do { \
|
||||||
(elm)->field.cqe_prev = (listelm); \
|
(elm)->field.cqe_next = (listelm)->field.cqe_next; \
|
||||||
if ((listelm)->field.cqe_next == CIRCLEQ_END(head)) \
|
(elm)->field.cqe_prev = (listelm); \
|
||||||
(head)->cqh_last = (elm); \
|
if ((listelm)->field.cqe_next == CIRCLEQ_END(head)) \
|
||||||
else \
|
(head)->cqh_last = (elm); \
|
||||||
(listelm)->field.cqe_next->field.cqe_prev = (elm); \
|
else \
|
||||||
(listelm)->field.cqe_next = (elm); \
|
(listelm)->field.cqe_next->field.cqe_prev = (elm); \
|
||||||
} while (0)
|
(listelm)->field.cqe_next = (elm); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) do { \
|
#define CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) \
|
||||||
(elm)->field.cqe_next = (listelm); \
|
do { \
|
||||||
(elm)->field.cqe_prev = (listelm)->field.cqe_prev; \
|
(elm)->field.cqe_next = (listelm); \
|
||||||
if ((listelm)->field.cqe_prev == CIRCLEQ_END(head)) \
|
(elm)->field.cqe_prev = (listelm)->field.cqe_prev; \
|
||||||
(head)->cqh_first = (elm); \
|
if ((listelm)->field.cqe_prev == CIRCLEQ_END(head)) \
|
||||||
else \
|
(head)->cqh_first = (elm); \
|
||||||
(listelm)->field.cqe_prev->field.cqe_next = (elm); \
|
else \
|
||||||
(listelm)->field.cqe_prev = (elm); \
|
(listelm)->field.cqe_prev->field.cqe_next = (elm); \
|
||||||
} while (0)
|
(listelm)->field.cqe_prev = (elm); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define CIRCLEQ_INSERT_HEAD(head, elm, field) do { \
|
#define CIRCLEQ_INSERT_HEAD(head, elm, field) \
|
||||||
(elm)->field.cqe_next = (head)->cqh_first; \
|
do { \
|
||||||
(elm)->field.cqe_prev = CIRCLEQ_END(head); \
|
(elm)->field.cqe_next = (head)->cqh_first; \
|
||||||
if ((head)->cqh_last == CIRCLEQ_END(head)) \
|
(elm)->field.cqe_prev = CIRCLEQ_END(head); \
|
||||||
(head)->cqh_last = (elm); \
|
if ((head)->cqh_last == CIRCLEQ_END(head)) \
|
||||||
else \
|
(head)->cqh_last = (elm); \
|
||||||
(head)->cqh_first->field.cqe_prev = (elm); \
|
else \
|
||||||
(head)->cqh_first = (elm); \
|
(head)->cqh_first->field.cqe_prev = (elm); \
|
||||||
} while (0)
|
(head)->cqh_first = (elm); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define CIRCLEQ_INSERT_TAIL(head, elm, field) do { \
|
#define CIRCLEQ_INSERT_TAIL(head, elm, field) \
|
||||||
(elm)->field.cqe_next = CIRCLEQ_END(head); \
|
do { \
|
||||||
(elm)->field.cqe_prev = (head)->cqh_last; \
|
(elm)->field.cqe_next = CIRCLEQ_END(head); \
|
||||||
if ((head)->cqh_first == CIRCLEQ_END(head)) \
|
(elm)->field.cqe_prev = (head)->cqh_last; \
|
||||||
(head)->cqh_first = (elm); \
|
if ((head)->cqh_first == CIRCLEQ_END(head)) \
|
||||||
else \
|
(head)->cqh_first = (elm); \
|
||||||
(head)->cqh_last->field.cqe_next = (elm); \
|
else \
|
||||||
(head)->cqh_last = (elm); \
|
(head)->cqh_last->field.cqe_next = (elm); \
|
||||||
} while (0)
|
(head)->cqh_last = (elm); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define CIRCLEQ_REMOVE(head, elm, field) do { \
|
#define CIRCLEQ_REMOVE(head, elm, field) \
|
||||||
if ((elm)->field.cqe_next == CIRCLEQ_END(head)) \
|
do { \
|
||||||
(head)->cqh_last = (elm)->field.cqe_prev; \
|
if ((elm)->field.cqe_next == CIRCLEQ_END(head)) \
|
||||||
else \
|
(head)->cqh_last = (elm)->field.cqe_prev; \
|
||||||
(elm)->field.cqe_next->field.cqe_prev = \
|
else \
|
||||||
(elm)->field.cqe_prev; \
|
(elm)->field.cqe_next->field.cqe_prev = (elm)->field.cqe_prev; \
|
||||||
if ((elm)->field.cqe_prev == CIRCLEQ_END(head)) \
|
if ((elm)->field.cqe_prev == CIRCLEQ_END(head)) \
|
||||||
(head)->cqh_first = (elm)->field.cqe_next; \
|
(head)->cqh_first = (elm)->field.cqe_next; \
|
||||||
else \
|
else \
|
||||||
(elm)->field.cqe_prev->field.cqe_next = \
|
(elm)->field.cqe_prev->field.cqe_next = (elm)->field.cqe_next; \
|
||||||
(elm)->field.cqe_next; \
|
_Q_INVALIDATE((elm)->field.cqe_prev); \
|
||||||
_Q_INVALIDATE((elm)->field.cqe_prev); \
|
_Q_INVALIDATE((elm)->field.cqe_next); \
|
||||||
_Q_INVALIDATE((elm)->field.cqe_next); \
|
} while (0)
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define CIRCLEQ_REPLACE(head, elm, elm2, field) do { \
|
#define CIRCLEQ_REPLACE(head, elm, elm2, field) \
|
||||||
if (((elm2)->field.cqe_next = (elm)->field.cqe_next) == \
|
do { \
|
||||||
CIRCLEQ_END(head)) \
|
if (((elm2)->field.cqe_next = (elm)->field.cqe_next) == CIRCLEQ_END(head)) \
|
||||||
(head)->cqh_last = (elm2); \
|
(head)->cqh_last = (elm2); \
|
||||||
else \
|
else \
|
||||||
(elm2)->field.cqe_next->field.cqe_prev = (elm2); \
|
(elm2)->field.cqe_next->field.cqe_prev = (elm2); \
|
||||||
if (((elm2)->field.cqe_prev = (elm)->field.cqe_prev) == \
|
if (((elm2)->field.cqe_prev = (elm)->field.cqe_prev) == CIRCLEQ_END(head)) \
|
||||||
CIRCLEQ_END(head)) \
|
(head)->cqh_first = (elm2); \
|
||||||
(head)->cqh_first = (elm2); \
|
else \
|
||||||
else \
|
(elm2)->field.cqe_prev->field.cqe_next = (elm2); \
|
||||||
(elm2)->field.cqe_prev->field.cqe_next = (elm2); \
|
_Q_INVALIDATE((elm)->field.cqe_prev); \
|
||||||
_Q_INVALIDATE((elm)->field.cqe_prev); \
|
_Q_INVALIDATE((elm)->field.cqe_next); \
|
||||||
_Q_INVALIDATE((elm)->field.cqe_next); \
|
} while (0)
|
||||||
} while (0)
|
|
||||||
|
@ -24,11 +24,11 @@ void dump() {
|
|||||||
printf("first: %d\n", e->abc);
|
printf("first: %d\n", e->abc);
|
||||||
e = TAILQ_LAST(&head, objhead);
|
e = TAILQ_LAST(&head, objhead);
|
||||||
printf("last: %d\n", e->abc);
|
printf("last: %d\n", e->abc);
|
||||||
TAILQ_FOREACH (e, &head, entry) {
|
TAILQ_FOREACH(e, &head, entry) {
|
||||||
printf(" %d\n", e->abc);
|
printf(" %d\n", e->abc);
|
||||||
}
|
}
|
||||||
printf("again, but reverse:\n");
|
printf("again, but reverse:\n");
|
||||||
TAILQ_FOREACH_REVERSE (e, &head, objhead, entry) {
|
TAILQ_FOREACH_REVERSE(e, &head, objhead, entry) {
|
||||||
printf(" %d\n", e->abc);
|
printf(" %d\n", e->abc);
|
||||||
}
|
}
|
||||||
printf("done\n\n");
|
printf("done\n\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user