Touch each log message and classify it as DLOG (debug), ELOG (error) or LOG (verbose)

This commit is contained in:
Michael Stapelberg 2009-12-19 22:39:00 +01:00
parent 37d795c81d
commit 6ef0d1fa79
19 changed files with 364 additions and 381 deletions

View File

@ -131,7 +131,7 @@ uint32_t client_min_width(Client *client);
* *
*/ */
#define CLIENT_LOG(client) do { \ #define CLIENT_LOG(client) do { \
LOG("Window: frame 0x%08x, child 0x%08x\n", client->frame, client->child); \ DLOG("Window: frame 0x%08x, child 0x%08x\n", client->frame, client->child); \
} while (0) } while (0)
#endif #endif

View File

@ -3,7 +3,7 @@
* *
* i3 - an improved dynamic tiling window manager * i3 - an improved dynamic tiling window manager
* *
* (c) 2009 Michael Stapelberg and contributors * © 2009 Michael Stapelberg and contributors
* *
* See file LICENSE for license information. * See file LICENSE for license information.
* *
@ -34,10 +34,6 @@
} \ } \
while (0) while (0)
/** ##__VA_ARGS__ means: leave out __VA_ARGS__ completely if it is empty, that
is, delete the preceding comma */
#define LOG(fmt, ...) slog("%s:%s:%d - " fmt, __FILE__, __FUNCTION__, __LINE__, ##__VA_ARGS__)
TAILQ_HEAD(keyvalue_table_head, keyvalue_element); TAILQ_HEAD(keyvalue_table_head, keyvalue_element);
extern struct keyvalue_table_head by_parent; extern struct keyvalue_table_head by_parent;
extern struct keyvalue_table_head by_child; extern struct keyvalue_table_head by_child;
@ -45,13 +41,6 @@ extern struct keyvalue_table_head by_child;
int min(int a, int b); int min(int a, int b);
int max(int a, int b); int max(int a, int b);
/**
* Logs the given message to stdout while prefixing the current time to it.
* This is to be called by LOG() which includes filename/linenumber
*
*/
void slog(char *fmt, ...);
/** /**
* Safe-wrapper around malloc which exits if malloc returns NULL (meaning that * Safe-wrapper around malloc which exits if malloc returns NULL (meaning that
* there is no more memory available) * there is no more memory available)

View File

@ -21,6 +21,7 @@
#include "table.h" #include "table.h"
#include "workspace.h" #include "workspace.h"
#include "xcb.h" #include "xcb.h"
#include "log.h"
typedef struct yy_buffer_state *YY_BUFFER_STATE; typedef struct yy_buffer_state *YY_BUFFER_STATE;
extern int yylex(void); extern int yylex(void);
@ -94,7 +95,7 @@ void parse_file(const char *f) {
new->key = sstrdup(v_key); new->key = sstrdup(v_key);
new->value = sstrdup(v_value); new->value = sstrdup(v_value);
SLIST_INSERT_HEAD(&variables, new, variables); SLIST_INSERT_HEAD(&variables, new, variables);
LOG("Got new variable %s = %s\n", v_key, v_value); DLOG("Got new variable %s = %s\n", v_key, v_value);
continue; continue;
} }
} }
@ -324,7 +325,7 @@ modeline:
floating_modifier: floating_modifier:
TOKFLOATING_MODIFIER WHITESPACE binding_modifiers TOKFLOATING_MODIFIER WHITESPACE binding_modifiers
{ {
LOG("floating modifier = %d\n", $<number>3); DLOG("floating modifier = %d\n", $<number>3);
config.floating_modifier = $<number>3; config.floating_modifier = $<number>3;
} }
; ;
@ -332,7 +333,7 @@ floating_modifier:
new_container: new_container:
TOKNEWCONTAINER WHITESPACE TOKCONTAINERMODE TOKNEWCONTAINER WHITESPACE TOKCONTAINERMODE
{ {
LOG("new containers will be in mode %d\n", $<number>3); DLOG("new containers will be in mode %d\n", $<number>3);
config.container_mode = $<number>3; config.container_mode = $<number>3;
/* We also need to change the layout of the already existing /* We also need to change the layout of the already existing
@ -354,7 +355,7 @@ new_container:
} }
| TOKNEWCONTAINER WHITESPACE TOKSTACKLIMIT WHITESPACE TOKSTACKLIMIT WHITESPACE NUMBER | TOKNEWCONTAINER WHITESPACE TOKSTACKLIMIT WHITESPACE TOKSTACKLIMIT WHITESPACE NUMBER
{ {
LOG("stack-limit %d with val %d\n", $<number>5, $<number>7); DLOG("stack-limit %d with val %d\n", $<number>5, $<number>7);
config.container_stack_limit = $<number>5; config.container_stack_limit = $<number>5;
config.container_stack_limit_value = $<number>7; config.container_stack_limit_value = $<number>7;
@ -373,7 +374,7 @@ new_container:
new_window: new_window:
TOKNEWWINDOW WHITESPACE WORD TOKNEWWINDOW WHITESPACE WORD
{ {
LOG("new windows should start in mode %s\n", $<string>3); DLOG("new windows should start in mode %s\n", $<string>3);
config.default_border = strdup($<string>3); config.default_border = strdup($<string>3);
} }
; ;
@ -383,7 +384,7 @@ workspace:
{ {
int ws_num = $<number>3; int ws_num = $<number>3;
if (ws_num < 1) { if (ws_num < 1) {
LOG("Invalid workspace assignment, workspace number %d out of range\n", ws_num); DLOG("Invalid workspace assignment, workspace number %d out of range\n", ws_num);
} else { } else {
Workspace *ws = workspace_get(ws_num - 1); Workspace *ws = workspace_get(ws_num - 1);
ws->preferred_screen = sstrdup($<string>7); ws->preferred_screen = sstrdup($<string>7);
@ -395,7 +396,7 @@ workspace:
{ {
int ws_num = $<number>3; int ws_num = $<number>3;
if (ws_num < 1) { if (ws_num < 1) {
LOG("Invalid workspace assignment, workspace number %d out of range\n", ws_num); DLOG("Invalid workspace assignment, workspace number %d out of range\n", ws_num);
} else { } else {
if ($<string>5 != NULL) if ($<string>5 != NULL)
workspace_set_name(workspace_get(ws_num - 1), $<string>5); workspace_set_name(workspace_get(ws_num - 1), $<string>5);
@ -486,7 +487,7 @@ exec:
terminal: terminal:
TOKTERMINAL WHITESPACE STR TOKTERMINAL WHITESPACE STR
{ {
LOG("The terminal option is DEPRECATED and has no effect. " DLOG("The terminal option is DEPRECATED and has no effect. "
"Please remove it from your configuration file."); "Please remove it from your configuration file.");
} }
; ;

View File

@ -36,6 +36,7 @@
#include "commands.h" #include "commands.h"
#include "floating.h" #include "floating.h"
#include "resize.h" #include "resize.h"
#include "log.h"
static struct Stack_Window *get_stack_window(xcb_window_t window_id) { static struct Stack_Window *get_stack_window(xcb_window_t window_id) {
struct Stack_Window *current; struct Stack_Window *current;
@ -97,18 +98,18 @@ static bool button_press_stackwin(xcb_connection_t *conn, xcb_button_press_event
int wrap = ceil((float)num_clients / container->stack_limit_value); int wrap = ceil((float)num_clients / container->stack_limit_value);
int clicked_column = (event->event_x / (stack_win->rect.width / container->stack_limit_value)); int clicked_column = (event->event_x / (stack_win->rect.width / container->stack_limit_value));
int clicked_row = (event->event_y / decoration_height); int clicked_row = (event->event_y / decoration_height);
LOG("clicked on column %d, row %d\n", clicked_column, clicked_row); DLOG("clicked on column %d, row %d\n", clicked_column, clicked_row);
destination = (wrap * clicked_column) + clicked_row; destination = (wrap * clicked_column) + clicked_row;
} else { } else {
int width = (stack_win->rect.width / ceil((float)num_clients / container->stack_limit_value)); int width = (stack_win->rect.width / ceil((float)num_clients / container->stack_limit_value));
int clicked_column = (event->event_x / width); int clicked_column = (event->event_x / width);
int clicked_row = (event->event_y / decoration_height); int clicked_row = (event->event_y / decoration_height);
LOG("clicked on column %d, row %d\n", clicked_column, clicked_row); DLOG("clicked on column %d, row %d\n", clicked_column, clicked_row);
destination = (container->stack_limit_value * clicked_column) + clicked_row; destination = (container->stack_limit_value * clicked_column) + clicked_row;
} }
} }
LOG("Click on stack_win for client %d\n", destination); DLOG("Click on stack_win for client %d\n", destination);
CIRCLEQ_FOREACH(client, &(stack_win->container->clients), clients) CIRCLEQ_FOREACH(client, &(stack_win->container->clients), clients)
if (c++ == destination) { if (c++ == destination) {
set_focus(conn, client, true); set_focus(conn, client, true);
@ -129,7 +130,7 @@ static bool button_press_bar(xcb_connection_t *conn, xcb_button_press_event_t *e
if (screen->bar != event->event) if (screen->bar != event->event)
continue; continue;
LOG("Click on a bar\n"); DLOG("Click on a bar\n");
/* Check if the button was one of button4 or button5 (scroll up / scroll down) */ /* Check if the button was one of button4 or button5 (scroll up / scroll down) */
if (event->detail == XCB_BUTTON_INDEX_4 || event->detail == XCB_BUTTON_INDEX_5) { if (event->detail == XCB_BUTTON_INDEX_4 || event->detail == XCB_BUTTON_INDEX_5) {
@ -158,7 +159,7 @@ static bool button_press_bar(xcb_connection_t *conn, xcb_button_press_event_t *e
TAILQ_FOREACH(ws, workspaces, workspaces) { TAILQ_FOREACH(ws, workspaces, workspaces) {
if (ws->screen != screen) if (ws->screen != screen)
continue; continue;
LOG("Checking if click was on workspace %d with drawn = %d, tw = %d\n", DLOG("Checking if click was on workspace %d with drawn = %d, tw = %d\n",
ws->num, drawn, ws->text_width); ws->num, drawn, ws->text_width);
if (event->event_x > (drawn + 1) && if (event->event_x > (drawn + 1) &&
event->event_x <= (drawn + 1 + ws->text_width + 5 + 5)) { event->event_x <= (drawn + 1 + ws->text_width + 5 + 5)) {
@ -201,7 +202,7 @@ static bool floating_mod_on_tiled_client(xcb_connection_t *conn, Client *client,
Workspace *ws = con->workspace; Workspace *ws = con->workspace;
int first = 0, second = 0; int first = 0, second = 0;
LOG("click was %d px to the right, %d px to the left, %d px to top, %d px to bottom\n", DLOG("click was %d px to the right, %d px to the left, %d px to top, %d px to bottom\n",
to_right, to_left, to_top, to_bottom); to_right, to_left, to_top, to_bottom);
if (to_right < to_left && if (to_right < to_left &&
@ -209,7 +210,7 @@ static bool floating_mod_on_tiled_client(xcb_connection_t *conn, Client *client,
to_right < to_bottom) { to_right < to_bottom) {
/* …right border */ /* …right border */
first = con->col + (con->colspan - 1); first = con->col + (con->colspan - 1);
LOG("column %d\n", first); DLOG("column %d\n", first);
if (!cell_exists(first, con->row) || if (!cell_exists(first, con->row) ||
(first == (ws->cols-1))) (first == (ws->cols-1)))
@ -251,7 +252,7 @@ static bool floating_mod_on_tiled_client(xcb_connection_t *conn, Client *client,
} }
int handle_button_press(void *ignored, xcb_connection_t *conn, xcb_button_press_event_t *event) { int handle_button_press(void *ignored, xcb_connection_t *conn, xcb_button_press_event_t *event) {
LOG("Button %d pressed\n", event->state); DLOG("Button %d pressed\n", event->state);
/* This was either a focus for a clients parent (= titlebar)… */ /* This was either a focus for a clients parent (= titlebar)… */
Client *client = table_get(&by_child, event->event); Client *client = table_get(&by_child, event->event);
bool border_click = false; bool border_click = false;
@ -265,20 +266,20 @@ int handle_button_press(void *ignored, xcb_connection_t *conn, xcb_button_press_
if (config.floating_modifier != 0 && if (config.floating_modifier != 0 &&
(event->state & config.floating_modifier) != 0) { (event->state & config.floating_modifier) != 0) {
if (client == NULL) { if (client == NULL) {
LOG("Not handling, floating_modifier was pressed and no client found\n"); DLOG("Not handling, floating_modifier was pressed and no client found\n");
return 1; return 1;
} }
if (client->fullscreen) { if (client->fullscreen) {
LOG("Not handling, client is in fullscreen mode\n"); DLOG("Not handling, client is in fullscreen mode\n");
return 1; return 1;
} }
if (client_is_floating(client)) { if (client_is_floating(client)) {
LOG("button %d pressed\n", event->detail); DLOG("button %d pressed\n", event->detail);
if (event->detail == 1) { if (event->detail == 1) {
LOG("left mouse button, dragging\n"); DLOG("left mouse button, dragging\n");
floating_drag_window(conn, client, event); floating_drag_window(conn, client, event);
} else if (event->detail == 3) { } else if (event->detail == 3) {
LOG("right mouse button\n"); DLOG("right mouse button\n");
floating_resize_window(conn, client, event); floating_resize_window(conn, client, event);
} }
return 1; return 1;
@ -301,7 +302,7 @@ int handle_button_press(void *ignored, xcb_connection_t *conn, xcb_button_press_
if (button_press_bar(conn, event)) if (button_press_bar(conn, event))
return 1; return 1;
LOG("Could not handle this button press\n"); DLOG("Could not handle this button press\n");
return 1; return 1;
} }
@ -309,19 +310,19 @@ int handle_button_press(void *ignored, xcb_connection_t *conn, xcb_button_press_
set_focus(conn, client, true); set_focus(conn, client, true);
/* Lets see if this was on the borders (= resize). If not, were done */ /* Lets see if this was on the borders (= resize). If not, were done */
LOG("press button on x=%d, y=%d\n", event->event_x, event->event_y); DLOG("press button on x=%d, y=%d\n", event->event_x, event->event_y);
resize_orientation_t orientation = O_VERTICAL; resize_orientation_t orientation = O_VERTICAL;
Container *con = client->container; Container *con = client->container;
int first, second; int first, second;
if (client->dock) { if (client->dock) {
LOG("dock. done.\n"); DLOG("dock. done.\n");
xcb_allow_events(conn, XCB_ALLOW_REPLAY_POINTER, event->time); xcb_allow_events(conn, XCB_ALLOW_REPLAY_POINTER, event->time);
xcb_flush(conn); xcb_flush(conn);
return 1; return 1;
} }
LOG("event->event_x = %d, client->rect.width = %d\n", event->event_x, client->rect.width); DLOG("event->event_x = %d, client->rect.width = %d\n", event->event_x, client->rect.width);
/* Some clients (xfontsel for example) seem to pass clicks on their /* Some clients (xfontsel for example) seem to pass clicks on their
* window to the parent window, thus we receive an event here which in * window to the parent window, thus we receive an event here which in
@ -331,12 +332,12 @@ int handle_button_press(void *ignored, xcb_connection_t *conn, xcb_button_press_
event->event_x <= (client->child_rect.x + client->child_rect.width) && event->event_x <= (client->child_rect.x + client->child_rect.width) &&
event->event_y >= client->child_rect.y && event->event_y >= client->child_rect.y &&
event->event_y <= (client->child_rect.y + client->child_rect.height)) { event->event_y <= (client->child_rect.y + client->child_rect.height)) {
LOG("Fixing border_click = false because of click in child\n"); DLOG("Fixing border_click = false because of click in child\n");
border_click = false; border_click = false;
} }
if (!border_click) { if (!border_click) {
LOG("client. done.\n"); DLOG("client. done.\n");
xcb_allow_events(conn, XCB_ALLOW_REPLAY_POINTER, event->time); xcb_allow_events(conn, XCB_ALLOW_REPLAY_POINTER, event->time);
/* Floating clients should be raised on click */ /* Floating clients should be raised on click */
if (client_is_floating(client)) if (client_is_floating(client))
@ -348,7 +349,7 @@ int handle_button_press(void *ignored, xcb_connection_t *conn, xcb_button_press_
/* Dont handle events inside the titlebar, only borders are interesting */ /* Dont handle events inside the titlebar, only borders are interesting */
i3Font *font = load_font(conn, config.font); i3Font *font = load_font(conn, config.font);
if (event->event_y >= 2 && event->event_y <= (font->height + 2 + 2)) { if (event->event_y >= 2 && event->event_y <= (font->height + 2 + 2)) {
LOG("click on titlebar\n"); DLOG("click on titlebar\n");
/* Floating clients can be dragged by grabbing their titlebar */ /* Floating clients can be dragged by grabbing their titlebar */
if (client_is_floating(client)) { if (client_is_floating(client)) {
@ -392,7 +393,7 @@ int handle_button_press(void *ignored, xcb_connection_t *conn, xcb_button_press_
} else if (event->event_x > 2) { } else if (event->event_x > 2) {
/* …right border */ /* …right border */
first = con->col + (con->colspan - 1); first = con->col + (con->colspan - 1);
LOG("column %d\n", first); DLOG("column %d\n", first);
if (!cell_exists(first, con->row) || if (!cell_exists(first, con->row) ||
(first == (ws->cols-1))) (first == (ws->cols-1)))

View File

@ -27,6 +27,7 @@
#include "table.h" #include "table.h"
#include "workspace.h" #include "workspace.h"
#include "config.h" #include "config.h"
#include "log.h"
/* /*
* Removes the given client from the container, either because it will be inserted into another * Removes the given client from the container, either because it will be inserted into another
@ -44,7 +45,7 @@ void client_remove_from_container(xcb_connection_t *conn, Client *client, Contai
if (CIRCLEQ_EMPTY(&(container->clients)) && if (CIRCLEQ_EMPTY(&(container->clients)) &&
(container->mode == MODE_STACK || (container->mode == MODE_STACK ||
container->mode == MODE_TABBED)) { container->mode == MODE_TABBED)) {
LOG("Unmapping stack window\n"); DLOG("Unmapping stack window\n");
struct Stack_Window *stack_win = &(container->stack_win); struct Stack_Window *stack_win = &(container->stack_win);
stack_win->rect.height = 0; stack_win->rect.height = 0;
xcb_unmap_window(conn, stack_win->window); xcb_unmap_window(conn, stack_win->window);
@ -169,7 +170,7 @@ void client_enter_fullscreen(xcb_connection_t *conn, Client *client) {
workspace->rect.width, workspace->rect.width,
workspace->rect.height}; workspace->rect.height};
LOG("child itself will be at %dx%d with size %dx%d\n", DLOG("child itself will be at %dx%d with size %dx%d\n",
values[0], values[1], values[2], values[3]); values[0], values[1], values[2], values[3]);
xcb_configure_window(conn, client->frame, mask, values); xcb_configure_window(conn, client->frame, mask, values);
@ -243,14 +244,14 @@ void client_set_below_floating(xcb_connection_t *conn, Client *client) {
if (first_floating == TAILQ_END(&(ws->floating_clients))) if (first_floating == TAILQ_END(&(ws->floating_clients)))
return; return;
LOG("Setting below floating\n"); DLOG("Setting below floating\n");
uint32_t values[] = { first_floating->frame, XCB_STACK_MODE_BELOW }; uint32_t values[] = { first_floating->frame, XCB_STACK_MODE_BELOW };
xcb_configure_window(conn, client->frame, XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE, values); xcb_configure_window(conn, client->frame, XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE, values);
if (client->workspace->fullscreen_client == NULL) if (client->workspace->fullscreen_client == NULL)
return; return;
LOG("(and below fullscreen)\n"); DLOG("(and below fullscreen)\n");
/* Ensure that the window is still below the fullscreen window */ /* Ensure that the window is still below the fullscreen window */
values[0] = client->workspace->fullscreen_client->frame; values[0] = client->workspace->fullscreen_client->frame;
xcb_configure_window(conn, client->frame, XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE, values); xcb_configure_window(conn, client->frame, XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE, values);

View File

@ -30,6 +30,7 @@
#include "workspace.h" #include "workspace.h"
#include "commands.h" #include "commands.h"
#include "resize.h" #include "resize.h"
#include "log.h"
bool focus_window_in_container(xcb_connection_t *conn, Container *container, direction_t direction) { bool focus_window_in_container(xcb_connection_t *conn, Container *container, direction_t direction) {
/* If this container is empty, were done */ /* If this container is empty, were done */
@ -45,7 +46,7 @@ bool focus_window_in_container(xcb_connection_t *conn, Container *container, dir
else if (direction == D_DOWN) { else if (direction == D_DOWN) {
if ((candidate = CIRCLEQ_NEXT_OR_NULL(&(container->clients), container->currently_focused, clients)) == NULL) if ((candidate = CIRCLEQ_NEXT_OR_NULL(&(container->clients), container->currently_focused, clients)) == NULL)
candidate = CIRCLEQ_FIRST(&(container->clients)); candidate = CIRCLEQ_FIRST(&(container->clients));
} else LOG("Direction not implemented!\n"); } else ELOG("Direction not implemented!\n");
/* If we could not switch, the container contains exactly one client. We return false */ /* If we could not switch, the container contains exactly one client. We return false */
if (candidate == container->currently_focused) if (candidate == container->currently_focused)
@ -74,11 +75,11 @@ static void jump_to_mark(xcb_connection_t *conn, const char *mark) {
return; return;
} }
LOG("No window with this mark found\n"); ELOG("No window with this mark found\n");
} }
static void focus_thing(xcb_connection_t *conn, direction_t direction, thing_t thing) { static void focus_thing(xcb_connection_t *conn, direction_t direction, thing_t thing) {
LOG("focusing direction %d\n", direction); DLOG("focusing direction %d\n", direction);
int new_row = current_row, int new_row = current_row,
new_col = current_col; new_col = current_col;
@ -120,7 +121,7 @@ static void focus_thing(xcb_connection_t *conn, direction_t direction, thing_t t
i3Screen *target = get_screen_containing(bounds.x, bounds.y); i3Screen *target = get_screen_containing(bounds.x, bounds.y);
if (target == NULL) { if (target == NULL) {
LOG("Target screen NULL\n"); DLOG("Target screen NULL\n");
/* Wrap around if the target screen is out of bounds */ /* Wrap around if the target screen is out of bounds */
if (direction == D_RIGHT) if (direction == D_RIGHT)
target = get_screen_most(D_LEFT, cs); target = get_screen_most(D_LEFT, cs);
@ -131,7 +132,7 @@ static void focus_thing(xcb_connection_t *conn, direction_t direction, thing_t t
else target = get_screen_most(D_UP, cs); else target = get_screen_most(D_UP, cs);
} }
LOG("Switching to ws %d\n", target->current_workspace + 1); DLOG("Switching to ws %d\n", target->current_workspace + 1);
workspace_show(conn, target->current_workspace->num + 1); workspace_show(conn, target->current_workspace->num + 1);
return; return;
} }
@ -159,11 +160,11 @@ static void focus_thing(xcb_connection_t *conn, direction_t direction, thing_t t
} }
} else { } else {
/* Lets see if there is a screen down/up there to which we can switch */ /* Lets see if there is a screen down/up there to which we can switch */
LOG("container is at %d with height %d\n", container->y, container->height); DLOG("container is at %d with height %d\n", container->y, container->height);
i3Screen *screen; i3Screen *screen;
int destination_y = (direction == D_UP ? (container->y - 1) : (container->y + container->height + 1)); int destination_y = (direction == D_UP ? (container->y - 1) : (container->y + container->height + 1));
if ((screen = get_screen_containing(container->x, destination_y)) == NULL) { if ((screen = get_screen_containing(container->x, destination_y)) == NULL) {
LOG("Wrapping screen around vertically\n"); DLOG("Wrapping screen around vertically\n");
/* No screen found? Then wrap */ /* No screen found? Then wrap */
screen = get_screen_most((direction == D_UP ? D_DOWN : D_UP), container->workspace->screen); screen = get_screen_most((direction == D_UP ? D_DOWN : D_UP), container->workspace->screen);
} }
@ -173,9 +174,9 @@ static void focus_thing(xcb_connection_t *conn, direction_t direction, thing_t t
check_colrow_boundaries(); check_colrow_boundaries();
LOG("new_col = %d, new_row = %d\n", new_col, new_row); DLOG("new_col = %d, new_row = %d\n", new_col, new_row);
if (t_ws->table[new_col][new_row]->currently_focused == NULL) { if (t_ws->table[new_col][new_row]->currently_focused == NULL) {
LOG("Cell empty, checking for colspanned client above...\n"); DLOG("Cell empty, checking for colspanned client above...\n");
for (int cols = 0; cols < new_col; cols += t_ws->table[cols][new_row]->colspan) { for (int cols = 0; cols < new_col; cols += t_ws->table[cols][new_row]->colspan) {
if (new_col > (cols + (t_ws->table[cols][new_row]->colspan - 1))) if (new_col > (cols + (t_ws->table[cols][new_row]->colspan - 1)))
continue; continue;
@ -183,7 +184,7 @@ static void focus_thing(xcb_connection_t *conn, direction_t direction, thing_t t
new_col = cols; new_col = cols;
break; break;
} }
LOG("Fixed it to new col %d\n", new_col); DLOG("Fixed it to new col %d\n", new_col);
} }
} else if (direction == D_LEFT || direction == D_RIGHT) { } else if (direction == D_LEFT || direction == D_RIGHT) {
if (direction == D_RIGHT && cell_exists(current_col+1, current_row)) if (direction == D_RIGHT && cell_exists(current_col+1, current_row))
@ -202,11 +203,11 @@ static void focus_thing(xcb_connection_t *conn, direction_t direction, thing_t t
} }
} else { } else {
/* Lets see if there is a screen left/right here to which we can switch */ /* Lets see if there is a screen left/right here to which we can switch */
LOG("container is at %d with width %d\n", container->x, container->width); DLOG("container is at %d with width %d\n", container->x, container->width);
i3Screen *screen; i3Screen *screen;
int destination_x = (direction == D_LEFT ? (container->x - 1) : (container->x + container->width + 1)); int destination_x = (direction == D_LEFT ? (container->x - 1) : (container->x + container->width + 1));
if ((screen = get_screen_containing(destination_x, container->y)) == NULL) { if ((screen = get_screen_containing(destination_x, container->y)) == NULL) {
LOG("Wrapping screen around horizontally\n"); DLOG("Wrapping screen around horizontally\n");
screen = get_screen_most((direction == D_LEFT ? D_RIGHT : D_LEFT), container->workspace->screen); screen = get_screen_most((direction == D_LEFT ? D_RIGHT : D_LEFT), container->workspace->screen);
} }
t_ws = screen->current_workspace; t_ws = screen->current_workspace;
@ -215,9 +216,9 @@ static void focus_thing(xcb_connection_t *conn, direction_t direction, thing_t t
check_colrow_boundaries(); check_colrow_boundaries();
LOG("new_col = %d, new_row = %d\n", new_col, new_row); DLOG("new_col = %d, new_row = %d\n", new_col, new_row);
if (t_ws->table[new_col][new_row]->currently_focused == NULL) { if (t_ws->table[new_col][new_row]->currently_focused == NULL) {
LOG("Cell empty, checking for rowspanned client above...\n"); DLOG("Cell empty, checking for rowspanned client above...\n");
for (int rows = 0; rows < new_row; rows += t_ws->table[new_col][rows]->rowspan) { for (int rows = 0; rows < new_row; rows += t_ws->table[new_col][rows]->rowspan) {
if (new_row > (rows + (t_ws->table[new_col][rows]->rowspan - 1))) if (new_row > (rows + (t_ws->table[new_col][rows]->rowspan - 1)))
continue; continue;
@ -225,10 +226,10 @@ static void focus_thing(xcb_connection_t *conn, direction_t direction, thing_t t
new_row = rows; new_row = rows;
break; break;
} }
LOG("Fixed it to new row %d\n", new_row); DLOG("Fixed it to new row %d\n", new_row);
} }
} else { } else {
LOG("direction unhandled\n"); ELOG("direction unhandled\n");
return; return;
} }
@ -254,7 +255,7 @@ static bool move_current_window_in_container(xcb_connection_t *conn, Client *cli
if (other == CIRCLEQ_END(&(client->container->clients))) if (other == CIRCLEQ_END(&(client->container->clients)))
return false; return false;
LOG("i can do that\n"); DLOG("i can do that\n");
/* We can move the client inside its current container */ /* We can move the client inside its current container */
CIRCLEQ_REMOVE(&(client->container->clients), client, clients); CIRCLEQ_REMOVE(&(client->container->clients), client, clients);
if (direction == D_UP) if (direction == D_UP)
@ -411,7 +412,7 @@ static void move_current_container(xcb_connection_t *conn, direction_t direction
return; return;
} }
LOG("old = %d,%d and new = %d,%d\n", container->col, container->row, new->col, new->row); DLOG("old = %d,%d and new = %d,%d\n", container->col, container->row, new->col, new->row);
/* Swap the containers */ /* Swap the containers */
int col = new->col; int col = new->col;
@ -453,7 +454,7 @@ static void snap_current_container(xcb_connection_t *conn, direction_t direction
/* Snap to the left is actually a move to the left and then a snap right */ /* Snap to the left is actually a move to the left and then a snap right */
if (!cell_exists(container->col - 1, container->row) || if (!cell_exists(container->col - 1, container->row) ||
CUR_TABLE[container->col-1][container->row]->currently_focused != NULL) { CUR_TABLE[container->col-1][container->row]->currently_focused != NULL) {
LOG("cannot snap to left - the cell is already used\n"); ELOG("cannot snap to left - the cell is already used\n");
return; return;
} }
@ -466,18 +467,18 @@ static void snap_current_container(xcb_connection_t *conn, direction_t direction
for (int i = 0; i < container->rowspan; i++) for (int i = 0; i < container->rowspan; i++)
if (!cell_exists(new_col, container->row + i) || if (!cell_exists(new_col, container->row + i) ||
CUR_TABLE[new_col][container->row + i]->currently_focused != NULL) { CUR_TABLE[new_col][container->row + i]->currently_focused != NULL) {
LOG("cannot snap to right - the cell is already used\n"); ELOG("cannot snap to right - the cell is already used\n");
return; return;
} }
/* Check if there are other cells with rowspan, which are in our way. /* Check if there are other cells with rowspan, which are in our way.
* If so, reduce their rowspan. */ * If so, reduce their rowspan. */
for (int i = container->row-1; i >= 0; i--) { for (int i = container->row-1; i >= 0; i--) {
LOG("we got cell %d, %d with rowspan %d\n", DLOG("we got cell %d, %d with rowspan %d\n",
new_col, i, CUR_TABLE[new_col][i]->rowspan); new_col, i, CUR_TABLE[new_col][i]->rowspan);
while ((CUR_TABLE[new_col][i]->rowspan-1) >= (container->row - i)) while ((CUR_TABLE[new_col][i]->rowspan-1) >= (container->row - i))
CUR_TABLE[new_col][i]->rowspan--; CUR_TABLE[new_col][i]->rowspan--;
LOG("new rowspan = %d\n", CUR_TABLE[new_col][i]->rowspan); DLOG("new rowspan = %d\n", CUR_TABLE[new_col][i]->rowspan);
} }
container->colspan++; container->colspan++;
@ -486,7 +487,7 @@ static void snap_current_container(xcb_connection_t *conn, direction_t direction
case D_UP: case D_UP:
if (!cell_exists(container->col, container->row - 1) || if (!cell_exists(container->col, container->row - 1) ||
CUR_TABLE[container->col][container->row-1]->currently_focused != NULL) { CUR_TABLE[container->col][container->row-1]->currently_focused != NULL) {
LOG("cannot snap to top - the cell is already used\n"); ELOG("cannot snap to top - the cell is already used\n");
return; return;
} }
@ -494,21 +495,21 @@ static void snap_current_container(xcb_connection_t *conn, direction_t direction
snap_current_container(conn, D_DOWN); snap_current_container(conn, D_DOWN);
return; return;
case D_DOWN: { case D_DOWN: {
LOG("snapping down\n"); DLOG("snapping down\n");
int new_row = container->row + container->rowspan; int new_row = container->row + container->rowspan;
for (int i = 0; i < container->colspan; i++) for (int i = 0; i < container->colspan; i++)
if (!cell_exists(container->col + i, new_row) || if (!cell_exists(container->col + i, new_row) ||
CUR_TABLE[container->col + i][new_row]->currently_focused != NULL) { CUR_TABLE[container->col + i][new_row]->currently_focused != NULL) {
LOG("cannot snap down - the cell is already used\n"); ELOG("cannot snap down - the cell is already used\n");
return; return;
} }
for (int i = container->col-1; i >= 0; i--) { for (int i = container->col-1; i >= 0; i--) {
LOG("we got cell %d, %d with colspan %d\n", DLOG("we got cell %d, %d with colspan %d\n",
i, new_row, CUR_TABLE[i][new_row]->colspan); i, new_row, CUR_TABLE[i][new_row]->colspan);
while ((CUR_TABLE[i][new_row]->colspan-1) >= (container->col - i)) while ((CUR_TABLE[i][new_row]->colspan-1) >= (container->col - i))
CUR_TABLE[i][new_row]->colspan--; CUR_TABLE[i][new_row]->colspan--;
LOG("new colspan = %d\n", CUR_TABLE[i][new_row]->colspan); DLOG("new colspan = %d\n", CUR_TABLE[i][new_row]->colspan);
} }
@ -535,7 +536,7 @@ static void move_floating_window_to_workspace(xcb_connection_t *conn, Client *cl
/* Check if there is already a fullscreen client on the destination workspace and /* Check if there is already a fullscreen client on the destination workspace and
* stop moving if so. */ * stop moving if so. */
if (client->fullscreen && (t_ws->fullscreen_client != NULL)) { if (client->fullscreen && (t_ws->fullscreen_client != NULL)) {
LOG("Not moving: Fullscreen client already existing on destination workspace.\n"); ELOG("Not moving: Fullscreen client already existing on destination workspace.\n");
return; return;
} }
@ -543,24 +544,24 @@ static void move_floating_window_to_workspace(xcb_connection_t *conn, Client *cl
/* If were moving it to an invisible screen, we need to unmap it */ /* If were moving it to an invisible screen, we need to unmap it */
if (!workspace_is_visible(t_ws)) { if (!workspace_is_visible(t_ws)) {
LOG("This workspace is not visible, unmapping\n"); DLOG("This workspace is not visible, unmapping\n");
client_unmap(conn, client); client_unmap(conn, client);
} else { } else {
/* If this is not the case, we move the window to a workspace /* If this is not the case, we move the window to a workspace
* which is on another screen, so we also need to adjust its * which is on another screen, so we also need to adjust its
* coordinates. */ * coordinates. */
LOG("before x = %d, y = %d\n", client->rect.x, client->rect.y); DLOG("before x = %d, y = %d\n", client->rect.x, client->rect.y);
uint32_t relative_x = client->rect.x - old_ws->rect.x, uint32_t relative_x = client->rect.x - old_ws->rect.x,
relative_y = client->rect.y - old_ws->rect.y; relative_y = client->rect.y - old_ws->rect.y;
LOG("rel_x = %d, rel_y = %d\n", relative_x, relative_y); DLOG("rel_x = %d, rel_y = %d\n", relative_x, relative_y);
client->rect.x = t_ws->rect.x + relative_x; client->rect.x = t_ws->rect.x + relative_x;
client->rect.y = t_ws->rect.y + relative_y; client->rect.y = t_ws->rect.y + relative_y;
LOG("after x = %d, y = %d\n", client->rect.x, client->rect.y); DLOG("after x = %d, y = %d\n", client->rect.x, client->rect.y);
reposition_client(conn, client); reposition_client(conn, client);
xcb_flush(conn); xcb_flush(conn);
} }
LOG("done\n"); DLOG("done\n");
render_layout(conn); render_layout(conn);
@ -584,7 +585,7 @@ static void move_current_window_to_workspace(xcb_connection_t *conn, int workspa
Client *current_client = container->currently_focused; Client *current_client = container->currently_focused;
if (current_client == NULL) { if (current_client == NULL) {
LOG("No currently focused client in current container.\n"); ELOG("No currently focused client in current container.\n");
return; return;
} }
Client *to_focus = CIRCLEQ_NEXT_OR_NULL(&(container->clients), current_client, clients); Client *to_focus = CIRCLEQ_NEXT_OR_NULL(&(container->clients), current_client, clients);
@ -595,7 +596,7 @@ static void move_current_window_to_workspace(xcb_connection_t *conn, int workspa
/* Check if there is already a fullscreen client on the destination workspace and /* Check if there is already a fullscreen client on the destination workspace and
* stop moving if so. */ * stop moving if so. */
if (current_client->fullscreen && (t_ws->fullscreen_client != NULL)) { if (current_client->fullscreen && (t_ws->fullscreen_client != NULL)) {
LOG("Not moving: Fullscreen client already existing on destination workspace.\n"); ELOG("Not moving: Fullscreen client already existing on destination workspace.\n");
return; return;
} }
@ -611,7 +612,7 @@ static void move_current_window_to_workspace(xcb_connection_t *conn, int workspa
CIRCLEQ_INSERT_TAIL(&(to_container->clients), current_client, clients); CIRCLEQ_INSERT_TAIL(&(to_container->clients), current_client, clients);
SLIST_INSERT_HEAD(&(to_container->workspace->focus_stack), current_client, focus_clients); SLIST_INSERT_HEAD(&(to_container->workspace->focus_stack), current_client, focus_clients);
LOG("Moved.\n"); DLOG("Moved.\n");
current_client->container = to_container; current_client->container = to_container;
current_client->workspace = to_container->workspace; current_client->workspace = to_container->workspace;
@ -620,11 +621,11 @@ static void move_current_window_to_workspace(xcb_connection_t *conn, int workspa
/* If were moving it to an invisible screen, we need to unmap it */ /* If were moving it to an invisible screen, we need to unmap it */
if (!workspace_is_visible(to_container->workspace)) { if (!workspace_is_visible(to_container->workspace)) {
LOG("This workspace is not visible, unmapping\n"); DLOG("This workspace is not visible, unmapping\n");
client_unmap(conn, current_client); client_unmap(conn, current_client);
} else { } else {
if (current_client->fullscreen) { if (current_client->fullscreen) {
LOG("Calling client_enter_fullscreen again\n"); DLOG("Calling client_enter_fullscreen again\n");
client_enter_fullscreen(conn, current_client); client_enter_fullscreen(conn, current_client);
} }
} }
@ -656,7 +657,7 @@ static void jump_to_window(xcb_connection_t *conn, const char *arguments) {
if ((client = get_matching_client(conn, classtitle, NULL)) == NULL) { if ((client = get_matching_client(conn, classtitle, NULL)) == NULL) {
free(classtitle); free(classtitle);
LOG("No matching client found.\n"); ELOG("No matching client found.\n");
return; return;
} }
@ -678,7 +679,7 @@ static void jump_to_container(xcb_connection_t *conn, const char *arguments) {
/* No match? Either no arguments were specified, or no numbers */ /* No match? Either no arguments were specified, or no numbers */
if (result < 1) { if (result < 1) {
LOG("At least one valid argument required\n"); ELOG("At least one valid argument required\n");
return; return;
} }
@ -688,7 +689,7 @@ static void jump_to_container(xcb_connection_t *conn, const char *arguments) {
if (result < 3) if (result < 3)
return; return;
LOG("Boundary-checking col %d, row %d... (max cols %d, max rows %d)\n", col, row, c_ws->cols, c_ws->rows); DLOG("Boundary-checking col %d, row %d... (max cols %d, max rows %d)\n", col, row, c_ws->cols, c_ws->rows);
/* Move to row/col */ /* Move to row/col */
if (row >= c_ws->rows) if (row >= c_ws->rows)
@ -696,7 +697,7 @@ static void jump_to_container(xcb_connection_t *conn, const char *arguments) {
if (col >= c_ws->cols) if (col >= c_ws->cols)
col = c_ws->cols - 1; col = c_ws->cols - 1;
LOG("Jumping to col %d, row %d\n", col, row); DLOG("Jumping to col %d, row %d\n", col, row);
if (c_ws->table[col][row]->currently_focused != NULL) if (c_ws->table[col][row]->currently_focused != NULL)
set_focus(conn, c_ws->table[col][row]->currently_focused, true); set_focus(conn, c_ws->table[col][row]->currently_focused, true);
} }
@ -725,7 +726,7 @@ static void travel_focus_stack(xcb_connection_t *conn, const char *arguments) {
} else if (strcasecmp(arguments, "ft") == 0) { } else if (strcasecmp(arguments, "ft") == 0) {
Client *last_focused = SLIST_FIRST(&(c_ws->focus_stack)); Client *last_focused = SLIST_FIRST(&(c_ws->focus_stack));
if (last_focused == SLIST_END(&(c_ws->focus_stack))) { if (last_focused == SLIST_END(&(c_ws->focus_stack))) {
LOG("Cannot select the next floating/tiling client because there is no client at all\n"); ELOG("Cannot select the next floating/tiling client because there is no client at all\n");
return; return;
} }
@ -733,17 +734,17 @@ static void travel_focus_stack(xcb_connection_t *conn, const char *arguments) {
} else { } else {
/* …or a number was specified */ /* …or a number was specified */
if (sscanf(arguments, "%u", &times) != 1) { if (sscanf(arguments, "%u", &times) != 1) {
LOG("No or invalid argument given (\"%s\"), using default of 1 times\n", arguments); ELOG("No or invalid argument given (\"%s\"), using default of 1 times\n", arguments);
times = 1; times = 1;
} }
SLIST_FOREACH(current, &(CUR_CELL->workspace->focus_stack), focus_clients) { SLIST_FOREACH(current, &(CUR_CELL->workspace->focus_stack), focus_clients) {
if (++count < times) { if (++count < times) {
LOG("Skipping\n"); DLOG("Skipping\n");
continue; continue;
} }
LOG("Focussing\n"); DLOG("Focussing\n");
set_focus(conn, current, true); set_focus(conn, current, true);
break; break;
} }
@ -767,7 +768,7 @@ static void travel_focus_stack(xcb_connection_t *conn, const char *arguments) {
static char **append_argument(char **original, char *argument) { static char **append_argument(char **original, char *argument) {
int num_args; int num_args;
for (num_args = 0; original[num_args] != NULL; num_args++) { for (num_args = 0; original[num_args] != NULL; num_args++) {
LOG("original argument: \"%s\"\n", original[num_args]); DLOG("original argument: \"%s\"\n", original[num_args]);
/* If the argument is already present we return the original pointer */ /* If the argument is already present we return the original pointer */
if (strcmp(original[num_args], argument) == 0) if (strcmp(original[num_args], argument) == 0)
return original; return original;
@ -821,7 +822,7 @@ static void parse_resize_command(xcb_connection_t *conn, Client *last_focused, c
command += strlen("left"); command += strlen("left");
} else if (STARTS_WITH(command, "right")) { } else if (STARTS_WITH(command, "right")) {
first = con->col + (con->colspan - 1); first = con->col + (con->colspan - 1);
LOG("column %d\n", first); DLOG("column %d\n", first);
if (!cell_exists(first, con->row) || if (!cell_exists(first, con->row) ||
(first == (ws->cols-1))) (first == (ws->cols-1)))
@ -846,7 +847,7 @@ static void parse_resize_command(xcb_connection_t *conn, Client *last_focused, c
orientation = O_HORIZONTAL; orientation = O_HORIZONTAL;
command += strlen("bottom"); command += strlen("bottom");
} else { } else {
LOG("Syntax: resize <left|right|top|bottom> [+|-]<pixels>\n"); ELOG("Syntax: resize <left|right|top|bottom> [+|-]<pixels>\n");
return; return;
} }
@ -882,14 +883,14 @@ void parse_command(xcb_connection_t *conn, const char *command) {
if (STARTS_WITH(command, "mark")) { if (STARTS_WITH(command, "mark")) {
if (last_focused == NULL) { if (last_focused == NULL) {
LOG("There is no window to mark\n"); ELOG("There is no window to mark\n");
return; return;
} }
const char *rest = command + strlen("mark"); const char *rest = command + strlen("mark");
while (*rest == ' ') while (*rest == ' ')
rest++; rest++;
if (*rest == '\0') { if (*rest == '\0') {
LOG("interactive mark starting\n"); DLOG("interactive mark starting\n");
start_application("i3-input -p 'mark ' -l 1 -P 'Mark: '"); start_application("i3-input -p 'mark ' -l 1 -P 'Mark: '");
} else { } else {
LOG("mark with \"%s\"\n", rest); LOG("mark with \"%s\"\n", rest);
@ -903,7 +904,7 @@ void parse_command(xcb_connection_t *conn, const char *command) {
while (*rest == ' ') while (*rest == ' ')
rest++; rest++;
if (*rest == '\0') { if (*rest == '\0') {
LOG("interactive go to mark starting\n"); DLOG("interactive go to mark starting\n");
start_application("i3-input -p 'goto ' -l 1 -P 'Goto: '"); start_application("i3-input -p 'goto ' -l 1 -P 'Goto: '");
} else { } else {
LOG("go to \"%s\"\n", rest); LOG("go to \"%s\"\n", rest);
@ -914,7 +915,7 @@ void parse_command(xcb_connection_t *conn, const char *command) {
if (STARTS_WITH(command, "stack-limit ")) { if (STARTS_WITH(command, "stack-limit ")) {
if (last_focused == NULL || client_is_floating(last_focused)) { if (last_focused == NULL || client_is_floating(last_focused)) {
LOG("No container focused\n"); ELOG("No container focused\n");
return; return;
} }
const char *rest = command + strlen("stack-limit "); const char *rest = command + strlen("stack-limit ");
@ -925,7 +926,7 @@ void parse_command(xcb_connection_t *conn, const char *command) {
last_focused->container->stack_limit = STACK_LIMIT_COLS; last_focused->container->stack_limit = STACK_LIMIT_COLS;
rest += strlen("cols "); rest += strlen("cols ");
} else { } else {
LOG("Syntax: stack-limit <cols|rows> <limit>\n"); ELOG("Syntax: stack-limit <cols|rows> <limit>\n");
return; return;
} }
@ -974,7 +975,7 @@ void parse_command(xcb_connection_t *conn, const char *command) {
if (STARTS_WITH(command, "kill")) { if (STARTS_WITH(command, "kill")) {
if (last_focused == NULL) { if (last_focused == NULL) {
LOG("There is no window to kill\n"); ELOG("There is no window to kill\n");
return; return;
} }
@ -1010,7 +1011,7 @@ void parse_command(xcb_connection_t *conn, const char *command) {
/* Is it just 's' for stacking or 'd' for default? */ /* Is it just 's' for stacking or 'd' for default? */
if ((command[0] == 's' || command[0] == 'd' || command[0] == 'T') && (command[1] == '\0')) { if ((command[0] == 's' || command[0] == 'd' || command[0] == 'T') && (command[1] == '\0')) {
if (last_focused != NULL && client_is_floating(last_focused)) { if (last_focused != NULL && client_is_floating(last_focused)) {
LOG("not switching, this is a floating client\n"); ELOG("not switching, this is a floating client\n");
return; return;
} }
LOG("Switching mode for current container\n"); LOG("Switching mode for current container\n");
@ -1027,7 +1028,7 @@ void parse_command(xcb_connection_t *conn, const char *command) {
/* or even 'bt' (toggle border: 'bp' -> 'bb' -> 'bn' ) */ /* or even 'bt' (toggle border: 'bp' -> 'bb' -> 'bn' ) */
if (command[0] == 'b') { if (command[0] == 'b') {
if (last_focused == NULL) { if (last_focused == NULL) {
LOG("No window focused, cannot change border type\n"); ELOG("No window focused, cannot change border type\n");
return; return;
} }
@ -1068,7 +1069,7 @@ void parse_command(xcb_connection_t *conn, const char *command) {
with = WITH_SCREEN; with = WITH_SCREEN;
command++; command++;
} else { } else {
LOG("not yet implemented.\n"); ELOG("not yet implemented.\n");
return; return;
} }
} }
@ -1081,7 +1082,7 @@ void parse_command(xcb_connection_t *conn, const char *command) {
return; return;
} }
if (last_focused == NULL) { if (last_focused == NULL) {
LOG("Cannot toggle tiling/floating: workspace empty\n"); ELOG("Cannot toggle tiling/floating: workspace empty\n");
return; return;
} }
@ -1115,7 +1116,7 @@ void parse_command(xcb_connection_t *conn, const char *command) {
direction_t direction; direction_t direction;
int times = strtol(command, &rest, 10); int times = strtol(command, &rest, 10);
if (rest == NULL) { if (rest == NULL) {
LOG("Invalid command (\"%s\")\n", command); ELOG("Invalid command (\"%s\")\n", command);
return; return;
} }
@ -1133,7 +1134,7 @@ void parse_command(xcb_connection_t *conn, const char *command) {
int workspace = strtol(rest, &rest, 10); int workspace = strtol(rest, &rest, 10);
if (rest == NULL) { if (rest == NULL) {
LOG("Invalid command (\"%s\")\n", command); ELOG("Invalid command (\"%s\")\n", command);
return; return;
} }
@ -1145,13 +1146,13 @@ void parse_command(xcb_connection_t *conn, const char *command) {
} }
if (last_focused == NULL) { if (last_focused == NULL) {
LOG("Not performing (no window found)\n"); ELOG("Not performing (no window found)\n");
return; return;
} }
if (client_is_floating(last_focused) && if (client_is_floating(last_focused) &&
(action != ACTION_FOCUS && action != ACTION_MOVE)) { (action != ACTION_FOCUS && action != ACTION_MOVE)) {
LOG("Not performing (floating)\n"); ELOG("Not performing (floating)\n");
return; return;
} }
@ -1166,7 +1167,7 @@ void parse_command(xcb_connection_t *conn, const char *command) {
else if (*rest == 'l') else if (*rest == 'l')
direction = D_RIGHT; direction = D_RIGHT;
else { else {
LOG("unknown direction: %c\n", *rest); ELOG("unknown direction: %c\n", *rest);
return; return;
} }
rest++; rest++;
@ -1189,7 +1190,7 @@ void parse_command(xcb_connection_t *conn, const char *command) {
/* TODO: this should swap the screens contents /* TODO: this should swap the screens contents
* (e.g. all workspaces) with the next/previous/ * (e.g. all workspaces) with the next/previous/
* screen */ * screen */
LOG("Not yet implemented\n"); ELOG("Not yet implemented\n");
continue; continue;
} }
if (client_is_floating(last_focused)) { if (client_is_floating(last_focused)) {
@ -1204,7 +1205,7 @@ void parse_command(xcb_connection_t *conn, const char *command) {
if (action == ACTION_SNAP) { if (action == ACTION_SNAP) {
if (with == WITH_SCREEN) { if (with == WITH_SCREEN) {
LOG("You cannot snap a screen (it makes no sense).\n"); ELOG("You cannot snap a screen (it makes no sense).\n");
continue; continue;
} }
snap_current_container(conn, direction); snap_current_container(conn, direction);

View File

@ -29,6 +29,7 @@
#include "xcb.h" #include "xcb.h"
#include "table.h" #include "table.h"
#include "workspace.h" #include "workspace.h"
#include "log.h"
Config config; Config config;
struct modes_head modes; struct modes_head modes;
@ -52,12 +53,12 @@ static char *glob_path(const char *path) {
* *
*/ */
void ungrab_all_keys(xcb_connection_t *conn) { void ungrab_all_keys(xcb_connection_t *conn) {
LOG("Ungrabbing all keys\n"); DLOG("Ungrabbing all keys\n");
xcb_ungrab_key(conn, XCB_GRAB_ANY, root, XCB_BUTTON_MASK_ANY); xcb_ungrab_key(conn, XCB_GRAB_ANY, root, XCB_BUTTON_MASK_ANY);
} }
static void grab_keycode_for_binding(xcb_connection_t *conn, Binding *bind, uint32_t keycode) { static void grab_keycode_for_binding(xcb_connection_t *conn, Binding *bind, uint32_t keycode) {
LOG("Grabbing %d\n", keycode); DLOG("Grabbing %d\n", keycode);
if ((bind->mods & BIND_MODE_SWITCH) != 0) if ((bind->mods & BIND_MODE_SWITCH) != 0)
xcb_grab_key(conn, 0, root, 0, keycode, xcb_grab_key(conn, 0, root, 0, keycode,
XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_SYNC); XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_SYNC);
@ -87,14 +88,14 @@ void grab_all_keys(xcb_connection_t *conn) {
/* We need to translate the symbol to a keycode */ /* We need to translate the symbol to a keycode */
xcb_keysym_t keysym = XStringToKeysym(bind->symbol); xcb_keysym_t keysym = XStringToKeysym(bind->symbol);
if (keysym == NoSymbol) { if (keysym == NoSymbol) {
LOG("Could not translate string to key symbol: \"%s\"\n", bind->symbol); ELOG("Could not translate string to key symbol: \"%s\"\n", bind->symbol);
continue; continue;
} }
#ifdef OLD_XCB_KEYSYMS_API #ifdef OLD_XCB_KEYSYMS_API
bind->number_keycodes = 1; bind->number_keycodes = 1;
xcb_keycode_t code = xcb_key_symbols_get_keycode(keysyms, keysym); xcb_keycode_t code = xcb_key_symbols_get_keycode(keysyms, keysym);
LOG("Translated symbol \"%s\" to 1 keycode (%d)\n", bind->symbol, code); DLOG("Translated symbol \"%s\" to 1 keycode (%d)\n", bind->symbol, code);
grab_keycode_for_binding(conn, bind, code); grab_keycode_for_binding(conn, bind, code);
bind->translated_to = smalloc(sizeof(xcb_keycode_t)); bind->translated_to = smalloc(sizeof(xcb_keycode_t));
memcpy(bind->translated_to, &code, sizeof(xcb_keycode_t)); memcpy(bind->translated_to, &code, sizeof(xcb_keycode_t));
@ -102,7 +103,7 @@ void grab_all_keys(xcb_connection_t *conn) {
uint32_t last_keycode = 0; uint32_t last_keycode = 0;
xcb_keycode_t *keycodes = xcb_key_symbols_get_keycode(keysyms, keysym); xcb_keycode_t *keycodes = xcb_key_symbols_get_keycode(keysyms, keysym);
if (keycodes == NULL) { if (keycodes == NULL) {
LOG("Could not translate symbol \"%s\"\n", bind->symbol); DLOG("Could not translate symbol \"%s\"\n", bind->symbol);
continue; continue;
} }
@ -117,7 +118,7 @@ void grab_all_keys(xcb_connection_t *conn) {
last_keycode = *walk; last_keycode = *walk;
bind->number_keycodes++; bind->number_keycodes++;
} }
LOG("Translated symbol \"%s\" to %d keycode\n", bind->symbol, bind->number_keycodes); DLOG("Translated symbol \"%s\" to %d keycode\n", bind->symbol, bind->number_keycodes);
bind->translated_to = smalloc(bind->number_keycodes * sizeof(xcb_keycode_t)); bind->translated_to = smalloc(bind->number_keycodes * sizeof(xcb_keycode_t));
memcpy(bind->translated_to, keycodes, bind->number_keycodes * sizeof(xcb_keycode_t)); memcpy(bind->translated_to, keycodes, bind->number_keycodes * sizeof(xcb_keycode_t));
free(keycodes); free(keycodes);
@ -144,7 +145,7 @@ void switch_mode(xcb_connection_t *conn, const char *new_mode) {
return; return;
} }
LOG("ERROR: Mode not found\n"); ELOG("ERROR: Mode not found\n");
} }
/* /*

View File

@ -27,6 +27,7 @@
#include "client.h" #include "client.h"
#include "floating.h" #include "floating.h"
#include "workspace.h" #include "workspace.h"
#include "log.h"
/* /*
* Toggles floating mode for the given client. * Toggles floating mode for the given client.
@ -42,7 +43,7 @@ void toggle_floating_mode(xcb_connection_t *conn, Client *client, bool automatic
i3Font *font = load_font(conn, config.font); i3Font *font = load_font(conn, config.font);
if (con == NULL) { if (con == NULL) {
LOG("This client is already in floating (container == NULL), re-inserting\n"); DLOG("This client is already in floating (container == NULL), re-inserting\n");
Client *next_tiling; Client *next_tiling;
Workspace *ws = client->workspace; Workspace *ws = client->workspace;
SLIST_FOREACH(next_tiling, &(ws->focus_stack), focus_clients) SLIST_FOREACH(next_tiling, &(ws->focus_stack), focus_clients)
@ -57,7 +58,7 @@ void toggle_floating_mode(xcb_connection_t *conn, Client *client, bool automatic
/* Remove the client from the list of floating clients */ /* Remove the client from the list of floating clients */
TAILQ_REMOVE(&(ws->floating_clients), client, floating_clients); TAILQ_REMOVE(&(ws->floating_clients), client, floating_clients);
LOG("destination container = %p\n", con); DLOG("destination container = %p\n", con);
Client *old_focused = con->currently_focused; Client *old_focused = con->currently_focused;
/* Preserve position/size */ /* Preserve position/size */
memcpy(&(client->floating_rect), &(client->rect), sizeof(Rect)); memcpy(&(client->floating_rect), &(client->rect), sizeof(Rect));
@ -69,7 +70,7 @@ void toggle_floating_mode(xcb_connection_t *conn, Client *client, bool automatic
CIRCLEQ_INSERT_AFTER(&(con->clients), old_focused, client, clients); CIRCLEQ_INSERT_AFTER(&(con->clients), old_focused, client, clients);
else CIRCLEQ_INSERT_TAIL(&(con->clients), client, clients); else CIRCLEQ_INSERT_TAIL(&(con->clients), client, clients);
LOG("Re-inserted the client into the matrix.\n"); DLOG("Re-inserted the window.\n");
con->currently_focused = client; con->currently_focused = client;
client_set_below_floating(conn, client); client_set_below_floating(conn, client);
@ -80,7 +81,7 @@ void toggle_floating_mode(xcb_connection_t *conn, Client *client, bool automatic
return; return;
} }
LOG("Entering floating for client %08x\n", client->child); DLOG("Entering floating for client %08x\n", client->child);
/* Remove the client of its container */ /* Remove the client of its container */
client_remove_from_container(conn, client, con, false); client_remove_from_container(conn, client, con, false);
@ -90,7 +91,7 @@ void toggle_floating_mode(xcb_connection_t *conn, Client *client, bool automatic
TAILQ_INSERT_TAIL(&(client->workspace->floating_clients), client, floating_clients); TAILQ_INSERT_TAIL(&(client->workspace->floating_clients), client, floating_clients);
if (con->currently_focused == client) { if (con->currently_focused == client) {
LOG("Need to re-adjust currently_focused\n"); DLOG("Need to re-adjust currently_focused\n");
/* Get the next client in the focus stack for this particular container */ /* Get the next client in the focus stack for this particular container */
con->currently_focused = get_last_focused_client(conn, con, NULL); con->currently_focused = get_last_focused_client(conn, con, NULL);
} }
@ -113,11 +114,11 @@ void toggle_floating_mode(xcb_connection_t *conn, Client *client, bool automatic
client->rect.width = client->child_rect.width + 2 + 2; client->rect.width = client->child_rect.width + 2 + 2;
client->rect.height = client->child_rect.height + (font->height + 2 + 2) + 2; client->rect.height = client->child_rect.height + (font->height + 2 + 2) + 2;
LOG("copying size from tiling (%d, %d) size (%d, %d)\n", client->floating_rect.x, client->floating_rect.y, DLOG("copying size from tiling (%d, %d) size (%d, %d)\n", client->floating_rect.x, client->floating_rect.y,
client->floating_rect.width, client->floating_rect.height); client->floating_rect.width, client->floating_rect.height);
} else { } else {
/* If the client was already in floating before we restore the old position / size */ /* If the client was already in floating before we restore the old position / size */
LOG("using: (%d, %d) size (%d, %d)\n", client->floating_rect.x, client->floating_rect.y, DLOG("using: (%d, %d) size (%d, %d)\n", client->floating_rect.x, client->floating_rect.y,
client->floating_rect.width, client->floating_rect.height); client->floating_rect.width, client->floating_rect.height);
memcpy(&(client->rect), &(client->floating_rect), sizeof(Rect)); memcpy(&(client->rect), &(client->floating_rect), sizeof(Rect));
} }
@ -163,8 +164,7 @@ void floating_assign_to_workspace(Client *client, Workspace *new_workspace) {
* *
*/ */
int floating_border_click(xcb_connection_t *conn, Client *client, xcb_button_press_event_t *event) { int floating_border_click(xcb_connection_t *conn, Client *client, xcb_button_press_event_t *event) {
DLOG("floating border click\n");
LOG("floating border click\n");
border_t border; border_t border;
@ -225,11 +225,11 @@ int floating_border_click(xcb_connection_t *conn, Client *client, xcb_button_pre
else if (event->event_x >= (client->rect.width - 2)) else if (event->event_x >= (client->rect.width - 2))
border = BORDER_RIGHT; border = BORDER_RIGHT;
else { else {
LOG("Not on any border, not doing anything.\n"); DLOG("Not on any border, not doing anything.\n");
return 1; return 1;
} }
LOG("border = %d\n", border); DLOG("border = %d\n", border);
drag_pointer(conn, client, event, XCB_NONE, border, resize_callback); drag_pointer(conn, client, event, XCB_NONE, border, resize_callback);
@ -243,7 +243,7 @@ int floating_border_click(xcb_connection_t *conn, Client *client, xcb_button_pre
* *
*/ */
void floating_drag_window(xcb_connection_t *conn, Client *client, xcb_button_press_event_t *event) { void floating_drag_window(xcb_connection_t *conn, Client *client, xcb_button_press_event_t *event) {
LOG("floating_drag_window\n"); DLOG("floating_drag_window\n");
void drag_window_callback(Rect *old_rect, uint32_t new_x, uint32_t new_y) { void drag_window_callback(Rect *old_rect, uint32_t new_x, uint32_t new_y) {
/* Reposition the client correctly while moving */ /* Reposition the client correctly while moving */
@ -266,7 +266,7 @@ void floating_drag_window(xcb_connection_t *conn, Client *client, xcb_button_pre
* *
*/ */
void floating_resize_window(xcb_connection_t *conn, Client *client, xcb_button_press_event_t *event) { void floating_resize_window(xcb_connection_t *conn, Client *client, xcb_button_press_event_t *event) {
LOG("floating_resize_window\n"); DLOG("floating_resize_window\n");
void resize_window_callback(Rect *old_rect, uint32_t new_x, uint32_t new_y) { void resize_window_callback(Rect *old_rect, uint32_t new_x, uint32_t new_y) {
int32_t new_width = old_rect->width + (new_x - event->root_x); int32_t new_width = old_rect->width + (new_x - event->root_x);
@ -346,12 +346,12 @@ void drag_pointer(xcb_connection_t *conn, Client *client, xcb_button_press_event
break; break;
case XCB_UNMAP_NOTIFY: case XCB_UNMAP_NOTIFY:
LOG("Unmap-notify, aborting\n"); DLOG("Unmap-notify, aborting\n");
xcb_event_handle(&evenths, inside_event); xcb_event_handle(&evenths, inside_event);
goto done; goto done;
default: default:
LOG("Passing to original handler\n"); DLOG("Passing to original handler\n");
/* Use original handler */ /* Use original handler */
xcb_event_handle(&evenths, inside_event); xcb_event_handle(&evenths, inside_event);
break; break;
@ -382,7 +382,7 @@ done:
* *
*/ */
void floating_focus_direction(xcb_connection_t *conn, Client *currently_focused, direction_t direction) { void floating_focus_direction(xcb_connection_t *conn, Client *currently_focused, direction_t direction) {
LOG("floating focus\n"); DLOG("floating focus\n");
if (direction == D_LEFT || direction == D_RIGHT) { if (direction == D_LEFT || direction == D_RIGHT) {
/* Go to the next/previous floating client */ /* Go to the next/previous floating client */
@ -404,7 +404,7 @@ void floating_focus_direction(xcb_connection_t *conn, Client *currently_focused,
* *
*/ */
void floating_move(xcb_connection_t *conn, Client *currently_focused, direction_t direction) { void floating_move(xcb_connection_t *conn, Client *currently_focused, direction_t direction) {
LOG("floating move\n"); DLOG("floating move\n");
switch (direction) { switch (direction) {
case D_LEFT: case D_LEFT:
@ -445,7 +445,7 @@ void floating_toggle_hide(xcb_connection_t *conn, Workspace *workspace) {
Client *client; Client *client;
workspace->floating_hidden = !workspace->floating_hidden; workspace->floating_hidden = !workspace->floating_hidden;
LOG("floating_hidden is now: %d\n", workspace->floating_hidden); DLOG("floating_hidden is now: %d\n", workspace->floating_hidden);
TAILQ_FOREACH(client, &(workspace->floating_clients), floating_clients) { TAILQ_FOREACH(client, &(workspace->floating_clients), floating_clients) {
if (workspace->floating_hidden) if (workspace->floating_hidden)
client_unmap(conn, client); client_unmap(conn, client);

View File

@ -36,6 +36,7 @@
#include "manage.h" #include "manage.h"
#include "floating.h" #include "floating.h"
#include "workspace.h" #include "workspace.h"
#include "log.h"
/* After mapping/unmapping windows, a notify event is generated. However, we dont want it, /* After mapping/unmapping windows, a notify event is generated. However, we dont want it,
since itd trigger an infinite loop of switching between the different windows when since itd trigger an infinite loop of switching between the different windows when
@ -95,15 +96,15 @@ int handle_key_release(void *ignored, xcb_connection_t *conn, xcb_key_release_ev
* *
*/ */
int handle_key_press(void *ignored, xcb_connection_t *conn, xcb_key_press_event_t *event) { int handle_key_press(void *ignored, xcb_connection_t *conn, xcb_key_press_event_t *event) {
LOG("Keypress %d, state raw = %d\n", event->detail, event->state); DLOG("Keypress %d, state raw = %d\n", event->detail, event->state);
/* Remove the numlock bit, all other bits are modifiers we can bind to */ /* Remove the numlock bit, all other bits are modifiers we can bind to */
uint16_t state_filtered = event->state & ~(xcb_numlock_mask | XCB_MOD_MASK_LOCK); uint16_t state_filtered = event->state & ~(xcb_numlock_mask | XCB_MOD_MASK_LOCK);
LOG("(removed numlock, state = %d)\n", state_filtered); DLOG("(removed numlock, state = %d)\n", state_filtered);
/* Only use the lower 8 bits of the state (modifier masks) so that mouse /* Only use the lower 8 bits of the state (modifier masks) so that mouse
* button masks are filtered out */ * button masks are filtered out */
state_filtered &= 0xFF; state_filtered &= 0xFF;
LOG("(removed upper 8 bits, state = %d)\n", state_filtered); DLOG("(removed upper 8 bits, state = %d)\n", state_filtered);
if (xkb_supported) { if (xkb_supported) {
/* We need to get the keysym group (There are group 1 to group 4, each holding /* We need to get the keysym group (There are group 1 to group 4, each holding
@ -114,7 +115,7 @@ int handle_key_press(void *ignored, xcb_connection_t *conn, xcb_key_press_event_
state_filtered |= BIND_MODE_SWITCH; state_filtered |= BIND_MODE_SWITCH;
} }
LOG("(checked mode_switch, state %d)\n", state_filtered); DLOG("(checked mode_switch, state %d)\n", state_filtered);
/* Find the binding */ /* Find the binding */
Binding *bind; Binding *bind;
@ -147,7 +148,7 @@ int handle_key_press(void *ignored, xcb_connection_t *conn, xcb_key_press_event_
parse_command(conn, bind->command); parse_command(conn, bind->command);
if (state_filtered & BIND_MODE_SWITCH) { if (state_filtered & BIND_MODE_SWITCH) {
LOG("Mode_switch -> allow_events(SyncKeyboard)\n"); DLOG("Mode_switch -> allow_events(SyncKeyboard)\n");
xcb_allow_events(conn, SyncKeyboard, event->time); xcb_allow_events(conn, SyncKeyboard, event->time);
xcb_flush(conn); xcb_flush(conn);
} }
@ -164,7 +165,7 @@ static void check_crossing_screen_boundary(uint32_t x, uint32_t y) {
i3Screen *screen; i3Screen *screen;
if ((screen = get_screen_containing(x, y)) == NULL) { if ((screen = get_screen_containing(x, y)) == NULL) {
LOG("ERROR: No such screen\n"); ELOG("ERROR: No such screen\n");
return; return;
} }
if (screen == c_ws->screen) if (screen == c_ws->screen)
@ -175,7 +176,7 @@ static void check_crossing_screen_boundary(uint32_t x, uint32_t y) {
c_ws = screen->current_workspace; c_ws = screen->current_workspace;
current_row = c_ws->current_row; current_row = c_ws->current_row;
current_col = c_ws->current_col; current_col = c_ws->current_col;
LOG("We're now on virtual screen number %d\n", screen->num); DLOG("We're now on virtual screen number %d\n", screen->num);
} }
/* /*
@ -183,9 +184,9 @@ static void check_crossing_screen_boundary(uint32_t x, uint32_t y) {
* *
*/ */
int handle_enter_notify(void *ignored, xcb_connection_t *conn, xcb_enter_notify_event_t *event) { int handle_enter_notify(void *ignored, xcb_connection_t *conn, xcb_enter_notify_event_t *event) {
LOG("enter_notify for %08x, mode = %d, detail %d, serial %d\n", event->event, event->mode, event->detail, event->sequence); DLOG("enter_notify for %08x, mode = %d, detail %d, serial %d\n", event->event, event->mode, event->detail, event->sequence);
if (event->mode != XCB_NOTIFY_MODE_NORMAL) { if (event->mode != XCB_NOTIFY_MODE_NORMAL) {
LOG("This was not a normal notify, ignoring\n"); DLOG("This was not a normal notify, ignoring\n");
return 1; return 1;
} }
/* Some events are not interesting, because they were not generated actively by the /* Some events are not interesting, because they were not generated actively by the
@ -212,7 +213,7 @@ int handle_enter_notify(void *ignored, xcb_connection_t *conn, xcb_enter_notify_
/* If not, then the user moved his cursor to the root window. In that case, we adjust c_ws */ /* If not, then the user moved his cursor to the root window. In that case, we adjust c_ws */
if (client == NULL) { if (client == NULL) {
LOG("Getting screen at %d x %d\n", event->root_x, event->root_y); DLOG("Getting screen at %d x %d\n", event->root_x, event->root_y);
check_crossing_screen_boundary(event->root_x, event->root_y); check_crossing_screen_boundary(event->root_x, event->root_y);
return 1; return 1;
} }
@ -222,7 +223,7 @@ int handle_enter_notify(void *ignored, xcb_connection_t *conn, xcb_enter_notify_
if (client->container != NULL && if (client->container != NULL &&
client->container->mode == MODE_STACK && client->container->mode == MODE_STACK &&
client->container->currently_focused != client) { client->container->currently_focused != client) {
LOG("Plausibility check says: no\n"); DLOG("Plausibility check says: no\n");
return 1; return 1;
} }
@ -230,7 +231,7 @@ int handle_enter_notify(void *ignored, xcb_connection_t *conn, xcb_enter_notify_
/* This can happen when a client gets assigned to a different workspace than /* This can happen when a client gets assigned to a different workspace than
* the current one (see src/mainx.c:reparent_window). Shortly after it was created, * the current one (see src/mainx.c:reparent_window). Shortly after it was created,
* an enter_notify will follow. */ * an enter_notify will follow. */
LOG("enter_notify for a client on a different workspace but the same screen, ignoring\n"); DLOG("enter_notify for a client on a different workspace but the same screen, ignoring\n");
return 1; return 1;
} }
@ -266,7 +267,7 @@ int handle_mapping_notify(void *ignored, xcb_connection_t *conn, xcb_mapping_not
event->request != XCB_MAPPING_MODIFIER) event->request != XCB_MAPPING_MODIFIER)
return 0; return 0;
LOG("Received mapping_notify for keyboard or modifier mapping, re-grabbing keys\n"); DLOG("Received mapping_notify for keyboard or modifier mapping, re-grabbing keys\n");
xcb_refresh_keyboard_mapping(keysyms, event); xcb_refresh_keyboard_mapping(keysyms, event);
xcb_get_numlock_mask(conn); xcb_get_numlock_mask(conn);
@ -286,7 +287,7 @@ int handle_map_request(void *prophs, xcb_connection_t *conn, xcb_map_request_eve
cookie = xcb_get_window_attributes_unchecked(conn, event->window); cookie = xcb_get_window_attributes_unchecked(conn, event->window);
LOG("window = 0x%08x, serial is %d.\n", event->window, event->sequence); DLOG("window = 0x%08x, serial is %d.\n", event->window, event->sequence);
add_ignore_event(event->sequence); add_ignore_event(event->sequence);
manage_window(prophs, conn, event->window, cookie, false); manage_window(prophs, conn, event->window, cookie, false);
@ -300,7 +301,7 @@ int handle_map_request(void *prophs, xcb_connection_t *conn, xcb_map_request_eve
* *
*/ */
int handle_configure_request(void *prophs, xcb_connection_t *conn, xcb_configure_request_event_t *event) { int handle_configure_request(void *prophs, xcb_connection_t *conn, xcb_configure_request_event_t *event) {
LOG("window 0x%08x wants to be at %dx%d with %dx%d\n", DLOG("window 0x%08x wants to be at %dx%d with %dx%d\n",
event->window, event->x, event->y, event->width, event->height); event->window, event->x, event->y, event->width, event->height);
Client *client = table_get(&by_child, event->window); Client *client = table_get(&by_child, event->window);
@ -330,7 +331,7 @@ int handle_configure_request(void *prophs, xcb_connection_t *conn, xcb_configure
} }
if (client->fullscreen) { if (client->fullscreen) {
LOG("Client is in fullscreen mode\n"); DLOG("Client is in fullscreen mode\n");
Rect child_rect = client->workspace->rect; Rect child_rect = client->workspace->rect;
child_rect.x = child_rect.y = 0; child_rect.x = child_rect.y = 0;
@ -371,7 +372,7 @@ int handle_configure_request(void *prophs, xcb_connection_t *conn, xcb_configure
} }
} }
LOG("Accepted new position/size for floating client: (%d, %d) size %d x %d\n", DLOG("Accepted new position/size for floating client: (%d, %d) size %d x %d\n",
client->rect.x, client->rect.y, client->rect.width, client->rect.height); client->rect.x, client->rect.y, client->rect.width, client->rect.height);
/* Push the new position/size to X11 */ /* Push the new position/size to X11 */
@ -384,10 +385,10 @@ int handle_configure_request(void *prophs, xcb_connection_t *conn, xcb_configure
/* Dock clients can be reconfigured in their height */ /* Dock clients can be reconfigured in their height */
if (client->dock) { if (client->dock) {
LOG("Reconfiguring height of this dock client\n"); DLOG("Reconfiguring height of this dock client\n");
if (!(event->value_mask & XCB_CONFIG_WINDOW_HEIGHT)) { if (!(event->value_mask & XCB_CONFIG_WINDOW_HEIGHT)) {
LOG("Ignoring configure request, no height given\n"); DLOG("Ignoring configure request, no height given\n");
return 1; return 1;
} }
@ -399,7 +400,7 @@ int handle_configure_request(void *prophs, xcb_connection_t *conn, xcb_configure
} }
if (client->fullscreen) { if (client->fullscreen) {
LOG("Client is in fullscreen mode\n"); DLOG("Client is in fullscreen mode\n");
Rect child_rect = client->container->workspace->rect; Rect child_rect = client->container->workspace->rect;
child_rect.x = child_rect.y = 0; child_rect.x = child_rect.y = 0;
@ -426,8 +427,8 @@ int handle_configure_event(void *prophs, xcb_connection_t *conn, xcb_configure_n
add_ignore_event(event->sequence); add_ignore_event(event->sequence);
if (event->event == root) { if (event->event == root) {
LOG("event->x = %d, ->y = %d, ->width = %d, ->height = %d\n", event->x, event->y, event->width, event->height); DLOG("event->x = %d, ->y = %d, ->width = %d, ->height = %d\n", event->x, event->y, event->width, event->height);
LOG("reconfigure of the root window, need to xinerama\n"); DLOG("reconfigure of the root window, need to xinerama\n");
/* FIXME: Somehow, this is occuring too often. Therefore, we check for 0/0, /* FIXME: Somehow, this is occuring too often. Therefore, we check for 0/0,
but is there a better way? */ but is there a better way? */
if (event->x == 0 && event->y == 0) if (event->x == 0 && event->y == 0)
@ -456,10 +457,10 @@ int handle_unmap_notify_event(void *data, xcb_connection_t *conn, xcb_unmap_noti
return 1; return 1;
} }
LOG("event->window = %08x, event->event = %08x\n", event->window, event->event); DLOG("event->window = %08x, event->event = %08x\n", event->window, event->event);
LOG("UnmapNotify for 0x%08x (received from 0x%08x)\n", event->window, event->event); DLOG("UnmapNotify for 0x%08x (received from 0x%08x)\n", event->window, event->event);
if (client == NULL) { if (client == NULL) {
LOG("not a managed window. Ignoring.\n"); DLOG("not a managed window. Ignoring.\n");
/* This was most likely the destroyed frame of a client which is /* This was most likely the destroyed frame of a client which is
* currently being unmapped, so we add this sequence (again!) to * currently being unmapped, so we add this sequence (again!) to
@ -490,17 +491,17 @@ int handle_unmap_notify_event(void *data, xcb_connection_t *conn, xcb_unmap_noti
if ((con->currently_focused != NULL) && ((con == CUR_CELL) || client->fullscreen)) if ((con->currently_focused != NULL) && ((con == CUR_CELL) || client->fullscreen))
set_focus(conn, con->currently_focused, true); set_focus(conn, con->currently_focused, true);
} else if (client_is_floating(client)) { } else if (client_is_floating(client)) {
LOG("Removing from floating clients\n"); DLOG("Removing from floating clients\n");
TAILQ_REMOVE(&(client->workspace->floating_clients), client, floating_clients); TAILQ_REMOVE(&(client->workspace->floating_clients), client, floating_clients);
SLIST_REMOVE(&(client->workspace->focus_stack), client, Client, focus_clients); SLIST_REMOVE(&(client->workspace->focus_stack), client, Client, focus_clients);
} }
if (client->dock) { if (client->dock) {
LOG("Removing from dock clients\n"); DLOG("Removing from dock clients\n");
SLIST_REMOVE(&(client->workspace->screen->dock_clients), client, Client, dock_clients); SLIST_REMOVE(&(client->workspace->screen->dock_clients), client, Client, dock_clients);
} }
LOG("child of 0x%08x.\n", client->frame); DLOG("child of 0x%08x.\n", client->frame);
xcb_reparent_window(conn, client->child, root, 0, 0); xcb_reparent_window(conn, client->child, root, 0, 0);
client_unmap(conn, client); client_unmap(conn, client);
@ -550,7 +551,7 @@ int handle_unmap_notify_event(void *data, xcb_connection_t *conn, xcb_unmap_noti
if (to_focus != NULL) if (to_focus != NULL)
set_focus(conn, to_focus, true); set_focus(conn, to_focus, true);
else { else {
LOG("Restoring focus to root screen\n"); DLOG("Restoring focus to root screen\n");
xcb_set_input_focus(conn, XCB_INPUT_FOCUS_POINTER_ROOT, root, XCB_CURRENT_TIME); xcb_set_input_focus(conn, XCB_INPUT_FOCUS_POINTER_ROOT, root, XCB_CURRENT_TIME);
xcb_flush(conn); xcb_flush(conn);
} }
@ -566,7 +567,7 @@ int handle_unmap_notify_event(void *data, xcb_connection_t *conn, xcb_unmap_noti
int handle_windowname_change(void *data, xcb_connection_t *conn, uint8_t state, int handle_windowname_change(void *data, xcb_connection_t *conn, uint8_t state,
xcb_window_t window, xcb_atom_t atom, xcb_get_property_reply_t *prop) { xcb_window_t window, xcb_atom_t atom, xcb_get_property_reply_t *prop) {
if (prop == NULL || xcb_get_property_value_length(prop) == 0) { if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
LOG("_NET_WM_NAME not specified, not changing\n"); DLOG("_NET_WM_NAME not specified, not changing\n");
return 1; return 1;
} }
Client *client = table_get(&by_child, window); Client *client = table_get(&by_child, window);
@ -628,7 +629,7 @@ int handle_windowname_change(void *data, xcb_connection_t *conn, uint8_t state,
int handle_windowname_change_legacy(void *data, xcb_connection_t *conn, uint8_t state, int handle_windowname_change_legacy(void *data, xcb_connection_t *conn, uint8_t state,
xcb_window_t window, xcb_atom_t atom, xcb_get_property_reply_t *prop) { xcb_window_t window, xcb_atom_t atom, xcb_get_property_reply_t *prop) {
if (prop == NULL || xcb_get_property_value_length(prop) == 0) { if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
LOG("prop == NULL\n"); DLOG("prop == NULL\n");
return 1; return 1;
} }
Client *client = table_get(&by_child, window); Client *client = table_get(&by_child, window);
@ -643,7 +644,7 @@ int handle_windowname_change_legacy(void *data, xcb_connection_t *conn, uint8_t
char *new_name; char *new_name;
if (asprintf(&new_name, "%.*s", xcb_get_property_value_length(prop), (char*)xcb_get_property_value(prop)) == -1) { if (asprintf(&new_name, "%.*s", xcb_get_property_value_length(prop), (char*)xcb_get_property_value(prop)) == -1) {
perror("Could not get old name"); perror("Could not get old name");
LOG("Could not get old name\n"); DLOG("Could not get old name\n");
return 1; return 1;
} }
/* Convert it to UCS-2 here for not having to convert it later every time we want to pass it to X */ /* Convert it to UCS-2 here for not having to convert it later every time we want to pass it to X */
@ -688,7 +689,7 @@ int handle_windowname_change_legacy(void *data, xcb_connection_t *conn, uint8_t
int handle_windowclass_change(void *data, xcb_connection_t *conn, uint8_t state, int handle_windowclass_change(void *data, xcb_connection_t *conn, uint8_t state,
xcb_window_t window, xcb_atom_t atom, xcb_get_property_reply_t *prop) { xcb_window_t window, xcb_atom_t atom, xcb_get_property_reply_t *prop) {
if (prop == NULL || xcb_get_property_value_length(prop) == 0) { if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
LOG("prop == NULL\n"); DLOG("prop == NULL\n");
return 1; return 1;
} }
Client *client = table_get(&by_child, window); Client *client = table_get(&by_child, window);
@ -697,7 +698,7 @@ int handle_windowclass_change(void *data, xcb_connection_t *conn, uint8_t state,
char *new_class; char *new_class;
if (asprintf(&new_class, "%.*s", xcb_get_property_value_length(prop), (char*)xcb_get_property_value(prop)) == -1) { if (asprintf(&new_class, "%.*s", xcb_get_property_value_length(prop), (char*)xcb_get_property_value(prop)) == -1) {
perror("Could not get window class"); perror("Could not get window class");
LOG("Could not get window class\n"); DLOG("Could not get window class\n");
return 1; return 1;
} }
@ -710,7 +711,7 @@ int handle_windowclass_change(void *data, xcb_connection_t *conn, uint8_t state,
return 1; return 1;
if (strcmp(new_class, "tools") == 0 || strcmp(new_class, "Dialog") == 0) { if (strcmp(new_class, "tools") == 0 || strcmp(new_class, "Dialog") == 0) {
LOG("tool/dialog window, should we put it floating?\n"); DLOG("tool/dialog window, should we put it floating?\n");
if (client->floating == FLOATING_AUTO_OFF) if (client->floating == FLOATING_AUTO_OFF)
toggle_floating_mode(conn, client, true); toggle_floating_mode(conn, client, true);
} }
@ -727,7 +728,7 @@ int handle_expose_event(void *data, xcb_connection_t *conn, xcb_expose_event_t *
skip all events but the last one */ skip all events but the last one */
if (event->count != 0) if (event->count != 0)
return 1; return 1;
LOG("window = %08x\n", event->window); DLOG("window = %08x\n", event->window);
Client *client = table_get(&by_parent, event->window); Client *client = table_get(&by_parent, event->window);
if (client == NULL) { if (client == NULL) {
@ -812,7 +813,7 @@ int handle_client_message(void *data, xcb_connection_t *conn, xcb_client_message
event->data.data32[0] == _NET_WM_STATE_TOGGLE))) event->data.data32[0] == _NET_WM_STATE_TOGGLE)))
client_toggle_fullscreen(conn, client); client_toggle_fullscreen(conn, client);
} else { } else {
LOG("unhandled clientmessage\n"); ELOG("unhandled clientmessage\n");
return 0; return 0;
} }
@ -823,7 +824,7 @@ int handle_window_type(void *data, xcb_connection_t *conn, uint8_t state, xcb_wi
xcb_atom_t atom, xcb_get_property_reply_t *property) { xcb_atom_t atom, xcb_get_property_reply_t *property) {
/* TODO: Implement this one. To do this, implement a little test program which sleep(1)s /* TODO: Implement this one. To do this, implement a little test program which sleep(1)s
before changing this property. */ before changing this property. */
LOG("_NET_WM_WINDOW_TYPE changed, this is not yet implemented.\n"); ELOG("_NET_WM_WINDOW_TYPE changed, this is not yet implemented.\n");
return 0; return 0;
} }
@ -838,7 +839,7 @@ int handle_normal_hints(void *data, xcb_connection_t *conn, uint8_t state, xcb_w
xcb_atom_t name, xcb_get_property_reply_t *reply) { xcb_atom_t name, xcb_get_property_reply_t *reply) {
Client *client = table_get(&by_child, window); Client *client = table_get(&by_child, window);
if (client == NULL) { if (client == NULL) {
LOG("Received WM_SIZE_HINTS for unknown client\n"); DLOG("Received WM_SIZE_HINTS for unknown client\n");
return 1; return 1;
} }
xcb_size_hints_t size_hints; xcb_size_hints_t size_hints;
@ -893,9 +894,9 @@ int handle_normal_hints(void *data, xcb_connection_t *conn, uint8_t state, xcb_w
base_height != client->base_height) { base_height != client->base_height) {
client->base_width = base_width; client->base_width = base_width;
client->base_height = base_height; client->base_height = base_height;
LOG("client's base_height changed to %d\n", base_height); DLOG("client's base_height changed to %d\n", base_height);
if (client->fullscreen) if (client->fullscreen)
LOG("Not resizing client, it is in fullscreen mode\n"); DLOG("Not resizing client, it is in fullscreen mode\n");
else else
resize_client(conn, client); resize_client(conn, client);
} }
@ -913,8 +914,8 @@ int handle_normal_hints(void *data, xcb_connection_t *conn, uint8_t state, xcb_w
double min_aspect = (double)size_hints.min_aspect_num / size_hints.min_aspect_den; double min_aspect = (double)size_hints.min_aspect_num / size_hints.min_aspect_den;
double max_aspect = (double)size_hints.max_aspect_num / size_hints.min_aspect_den; double max_aspect = (double)size_hints.max_aspect_num / size_hints.min_aspect_den;
LOG("Aspect ratio set: minimum %f, maximum %f\n", min_aspect, max_aspect); DLOG("Aspect ratio set: minimum %f, maximum %f\n", min_aspect, max_aspect);
LOG("width = %f, height = %f\n", width, height); DLOG("width = %f, height = %f\n", width, height);
/* Sanity checks, this is user-input, in a way */ /* Sanity checks, this is user-input, in a way */
if (max_aspect <= 0 || min_aspect <= 0 || height == 0 || (width / height) <= 0) if (max_aspect <= 0 || min_aspect <= 0 || height == 0 || (width / height) <= 0)
@ -947,7 +948,7 @@ int handle_hints(void *data, xcb_connection_t *conn, uint8_t state, xcb_window_t
xcb_atom_t name, xcb_get_property_reply_t *reply) { xcb_atom_t name, xcb_get_property_reply_t *reply) {
Client *client = table_get(&by_child, window); Client *client = table_get(&by_child, window);
if (client == NULL) { if (client == NULL) {
LOG("Received WM_HINTS for unknown client\n"); DLOG("Received WM_HINTS for unknown client\n");
return 1; return 1;
} }
xcb_wm_hints_t hints; xcb_wm_hints_t hints;
@ -962,7 +963,7 @@ int handle_hints(void *data, xcb_connection_t *conn, uint8_t state, xcb_window_t
Client *last_focused = SLIST_FIRST(&(c_ws->focus_stack)); Client *last_focused = SLIST_FIRST(&(c_ws->focus_stack));
if (!client->urgent && client == last_focused) { if (!client->urgent && client == last_focused) {
LOG("Ignoring urgency flag for current client\n"); DLOG("Ignoring urgency flag for current client\n");
return 1; return 1;
} }
@ -996,7 +997,7 @@ int handle_transient_for(void *data, xcb_connection_t *conn, uint8_t state, xcb_
xcb_atom_t name, xcb_get_property_reply_t *reply) { xcb_atom_t name, xcb_get_property_reply_t *reply) {
Client *client = table_get(&by_child, window); Client *client = table_get(&by_child, window);
if (client == NULL) { if (client == NULL) {
LOG("No such client\n"); DLOG("No such client\n");
return 1; return 1;
} }
@ -1012,7 +1013,7 @@ int handle_transient_for(void *data, xcb_connection_t *conn, uint8_t state, xcb_
} }
if (client->floating == FLOATING_AUTO_OFF) { if (client->floating == FLOATING_AUTO_OFF) {
LOG("This is a popup window, putting into floating\n"); DLOG("This is a popup window, putting into floating\n");
toggle_floating_mode(conn, client, true); toggle_floating_mode(conn, client, true);
} }
@ -1041,7 +1042,7 @@ int handle_clientleader_change(void *data, xcb_connection_t *conn, uint8_t state
if (leader == NULL || *leader == 0) if (leader == NULL || *leader == 0)
return 1; return 1;
LOG("Client leader changed to %08x\n", *leader); DLOG("Client leader changed to %08x\n", *leader);
client->leader = *leader; client->leader = *leader;

View File

@ -28,6 +28,7 @@
#include "i3.h" #include "i3.h"
#include "util.h" #include "util.h"
#include "commands.h" #include "commands.h"
#include "log.h"
typedef struct ipc_client { typedef struct ipc_client {
int fd; int fd;
@ -71,10 +72,10 @@ void broadcast(EV_P_ struct ev_timer *t, int revents) {
*/ */
static void ipc_handle_message(uint8_t *message, int size, static void ipc_handle_message(uint8_t *message, int size,
uint32_t message_size, uint32_t message_type) { uint32_t message_size, uint32_t message_type) {
LOG("handling message of size %d\n", size); DLOG("handling message of size %d\n", size);
LOG("sender specified size %d\n", message_size); DLOG("sender specified size %d\n", message_size);
LOG("sender specified type %d\n", message_type); DLOG("sender specified type %d\n", message_type);
LOG("payload as a string = %s\n", message); DLOG("payload as a string = %s\n", message);
switch (message_type) { switch (message_type) {
case I3_IPC_MESSAGE_TYPE_COMMAND: { case I3_IPC_MESSAGE_TYPE_COMMAND: {
@ -88,7 +89,7 @@ static void ipc_handle_message(uint8_t *message, int size,
break; break;
} }
default: default:
LOG("unhandled ipc message\n"); DLOG("unhandled ipc message\n");
break; break;
} }
} }
@ -135,7 +136,7 @@ static void ipc_receive_message(EV_P_ struct ev_io *w, int revents) {
ev_io_stop(EV_A_ w); ev_io_stop(EV_A_ w);
LOG("IPC: client disconnected\n"); DLOG("IPC: client disconnected\n");
return; return;
} }
@ -144,18 +145,18 @@ static void ipc_receive_message(EV_P_ struct ev_io *w, int revents) {
/* Check if the message starts with the i3 IPC magic code */ /* Check if the message starts with the i3 IPC magic code */
if (n < strlen(I3_IPC_MAGIC)) { if (n < strlen(I3_IPC_MAGIC)) {
LOG("IPC: message too short, ignoring\n"); DLOG("IPC: message too short, ignoring\n");
return; return;
} }
if (strncmp(buf, I3_IPC_MAGIC, strlen(I3_IPC_MAGIC)) != 0) { if (strncmp(buf, I3_IPC_MAGIC, strlen(I3_IPC_MAGIC)) != 0) {
LOG("IPC: message does not start with the IPC magic\n"); DLOG("IPC: message does not start with the IPC magic\n");
return; return;
} }
uint8_t *message = (uint8_t*)buf; uint8_t *message = (uint8_t*)buf;
while (n > 0) { while (n > 0) {
LOG("IPC: n = %d\n", n); DLOG("IPC: n = %d\n", n);
message += strlen(I3_IPC_MAGIC); message += strlen(I3_IPC_MAGIC);
n -= strlen(I3_IPC_MAGIC); n -= strlen(I3_IPC_MAGIC);
@ -165,7 +166,7 @@ static void ipc_receive_message(EV_P_ struct ev_io *w, int revents) {
n -= sizeof(uint32_t); n -= sizeof(uint32_t);
if (message_size > n) { if (message_size > n) {
LOG("IPC: Either the message size was wrong or the message was not read completely, dropping\n"); DLOG("IPC: Either the message size was wrong or the message was not read completely, dropping\n");
return; return;
} }
@ -204,7 +205,7 @@ void ipc_new_client(EV_P_ struct ev_io *w, int revents) {
ev_io_init(package, ipc_receive_message, client, EV_READ); ev_io_init(package, ipc_receive_message, client, EV_READ);
ev_io_start(EV_A_ package); ev_io_start(EV_A_ package);
LOG("IPC: new client connected\n"); DLOG("IPC: new client connected\n");
struct ipc_client *new = calloc(sizeof(struct ipc_client), 1); struct ipc_client *new = calloc(sizeof(struct ipc_client), 1);
new->fd = client; new->fd = client;

View File

@ -28,6 +28,7 @@
#include "floating.h" #include "floating.h"
#include "handlers.h" #include "handlers.h"
#include "workspace.h" #include "workspace.h"
#include "log.h"
/* /*
* Updates *destination with new_value and returns true if it was changed or false * Updates *destination with new_value and returns true if it was changed or false
@ -50,16 +51,16 @@ int get_unoccupied_x(Workspace *workspace) {
double unoccupied = workspace->rect.width; double unoccupied = workspace->rect.width;
double default_factor = ((float)workspace->rect.width / workspace->cols) / workspace->rect.width; double default_factor = ((float)workspace->rect.width / workspace->cols) / workspace->rect.width;
LOG("get_unoccupied_x(), starting with %f, default_factor = %f\n", unoccupied, default_factor); DLOG("get_unoccupied_x(), starting with %f, default_factor = %f\n", unoccupied, default_factor);
for (int cols = 0; cols < workspace->cols; cols++) { for (int cols = 0; cols < workspace->cols; cols++) {
LOG("width_factor[%d] = %f, unoccupied = %f\n", cols, workspace->width_factor[cols], unoccupied); DLOG("width_factor[%d] = %f, unoccupied = %f\n", cols, workspace->width_factor[cols], unoccupied);
if (workspace->width_factor[cols] == 0) if (workspace->width_factor[cols] == 0)
unoccupied -= workspace->rect.width * default_factor; unoccupied -= workspace->rect.width * default_factor;
} }
LOG("unoccupied space: %f\n", unoccupied); DLOG("unoccupied space: %f\n", unoccupied);
return unoccupied; return unoccupied;
} }
@ -69,15 +70,15 @@ int get_unoccupied_y(Workspace *workspace) {
double unoccupied = height; double unoccupied = height;
double default_factor = ((float)height / workspace->rows) / height; double default_factor = ((float)height / workspace->rows) / height;
LOG("get_unoccupied_y(), starting with %f, default_factor = %f\n", unoccupied, default_factor); DLOG("get_unoccupied_y(), starting with %f, default_factor = %f\n", unoccupied, default_factor);
for (int rows = 0; rows < workspace->rows; rows++) { for (int rows = 0; rows < workspace->rows; rows++) {
LOG("height_factor[%d] = %f, unoccupied = %f\n", rows, workspace->height_factor[rows], unoccupied); DLOG("height_factor[%d] = %f, unoccupied = %f\n", rows, workspace->height_factor[rows], unoccupied);
if (workspace->height_factor[rows] == 0) if (workspace->height_factor[rows] == 0)
unoccupied -= height * default_factor; unoccupied -= height * default_factor;
} }
LOG("unoccupied space: %f\n", unoccupied); DLOG("unoccupied space: %f\n", unoccupied);
return unoccupied; return unoccupied;
} }
@ -217,7 +218,7 @@ void decorate_window(xcb_connection_t *conn, Client *client, xcb_drawable_t draw
void reposition_client(xcb_connection_t *conn, Client *client) { void reposition_client(xcb_connection_t *conn, Client *client) {
i3Screen *screen; i3Screen *screen;
LOG("frame 0x%08x needs to be pushed to %dx%d\n", client->frame, client->rect.x, client->rect.y); DLOG("frame 0x%08x needs to be pushed to %dx%d\n", client->frame, client->rect.x, client->rect.y);
/* Note: We can use a pointer to client->x like an array of uint32_ts /* Note: We can use a pointer to client->x like an array of uint32_ts
because it is followed by client->y by definition */ because it is followed by client->y by definition */
xcb_configure_window(conn, client->frame, XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, &(client->rect.x)); xcb_configure_window(conn, client->frame, XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, &(client->rect.x));
@ -230,12 +231,12 @@ void reposition_client(xcb_connection_t *conn, Client *client) {
return; return;
if (screen == NULL) { if (screen == NULL) {
LOG("Boundary checking disabled, no screen found for (%d, %d)\n", client->rect.x, client->rect.y); DLOG("Boundary checking disabled, no screen found for (%d, %d)\n", client->rect.x, client->rect.y);
return; return;
} }
LOG("Client is on workspace %p with screen %p\n", client->workspace, client->workspace->screen); DLOG("Client is on workspace %p with screen %p\n", client->workspace, client->workspace->screen);
LOG("but screen at %d, %d is %p\n", client->rect.x, client->rect.y, screen); DLOG("but screen at %d, %d is %p\n", client->rect.x, client->rect.y, screen);
floating_assign_to_workspace(client, screen->current_workspace); floating_assign_to_workspace(client, screen->current_workspace);
} }
@ -249,8 +250,8 @@ void reposition_client(xcb_connection_t *conn, Client *client) {
void resize_client(xcb_connection_t *conn, Client *client) { void resize_client(xcb_connection_t *conn, Client *client) {
i3Font *font = load_font(conn, config.font); i3Font *font = load_font(conn, config.font);
LOG("frame 0x%08x needs to be pushed to %dx%d\n", client->frame, client->rect.x, client->rect.y); DLOG("frame 0x%08x needs to be pushed to %dx%d\n", client->frame, client->rect.x, client->rect.y);
LOG("resizing client 0x%08x to %d x %d\n", client->frame, client->rect.width, client->rect.height); DLOG("resizing client 0x%08x to %d x %d\n", client->frame, client->rect.width, client->rect.height);
xcb_configure_window(conn, client->frame, xcb_configure_window(conn, client->frame,
XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_X |
XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_Y |
@ -300,7 +301,7 @@ void resize_client(xcb_connection_t *conn, Client *client) {
/* Obey the ratio, if any */ /* Obey the ratio, if any */
if (client->proportional_height != 0 && if (client->proportional_height != 0 &&
client->proportional_width != 0) { client->proportional_width != 0) {
LOG("proportional height = %d, width = %d\n", client->proportional_height, client->proportional_width); DLOG("proportional height = %d, width = %d\n", client->proportional_height, client->proportional_width);
double new_height = rect->height + 1; double new_height = rect->height + 1;
int new_width = rect->width; int new_width = rect->width;
@ -316,24 +317,24 @@ void resize_client(xcb_connection_t *conn, Client *client) {
rect->height = new_height; rect->height = new_height;
rect->width = new_width; rect->width = new_width;
LOG("new_height = %f, new_width = %d\n", new_height, new_width); DLOG("new_height = %f, new_width = %d\n", new_height, new_width);
} }
if (client->height_increment > 1) { if (client->height_increment > 1) {
int old_height = rect->height; int old_height = rect->height;
rect->height -= (rect->height - client->base_height) % client->height_increment; rect->height -= (rect->height - client->base_height) % client->height_increment;
LOG("Lost %d pixel due to client's height_increment (%d px, base_height = %d)\n", DLOG("Lost %d pixel due to client's height_increment (%d px, base_height = %d)\n",
old_height - rect->height, client->height_increment, client->base_height); old_height - rect->height, client->height_increment, client->base_height);
} }
if (client->width_increment > 1) { if (client->width_increment > 1) {
int old_width = rect->width; int old_width = rect->width;
rect->width -= (rect->width - client->base_width) % client->width_increment; rect->width -= (rect->width - client->base_width) % client->width_increment;
LOG("Lost %d pixel due to client's width_increment (%d px, base_width = %d)\n", DLOG("Lost %d pixel due to client's width_increment (%d px, base_width = %d)\n",
old_width - rect->width, client->width_increment, client->base_width); old_width - rect->width, client->width_increment, client->base_width);
} }
LOG("child will be at %dx%d with size %dx%d\n", rect->x, rect->y, rect->width, rect->height); DLOG("child will be at %dx%d with size %dx%d\n", rect->x, rect->y, rect->width, rect->height);
xcb_configure_window(conn, client->child, mask, &(rect->x)); xcb_configure_window(conn, client->child, mask, &(rect->x));
@ -365,7 +366,7 @@ void render_container(xcb_connection_t *conn, Container *container) {
if (container->mode == MODE_DEFAULT) { if (container->mode == MODE_DEFAULT) {
int height = (container->height / max(1, num_clients)); int height = (container->height / max(1, num_clients));
int rest_pixels = (container->height % max(1, num_clients)); int rest_pixels = (container->height % max(1, num_clients));
LOG("height per client = %d, rest = %d\n", height, rest_pixels); DLOG("height per client = %d, rest = %d\n", height, rest_pixels);
CIRCLEQ_FOREACH(client, &(container->clients), clients) { CIRCLEQ_FOREACH(client, &(container->clients), clients) {
/* If the client is in fullscreen mode, it does not get reconfigured */ /* If the client is in fullscreen mode, it does not get reconfigured */
@ -409,15 +410,15 @@ void render_container(xcb_connection_t *conn, Container *container) {
/* Check if we need to remap our stack title window, it gets unmapped when the container /* Check if we need to remap our stack title window, it gets unmapped when the container
is empty in src/handlers.c:unmap_notify() */ is empty in src/handlers.c:unmap_notify() */
if (stack_win->rect.height == 0 && num_clients > 0) { if (stack_win->rect.height == 0 && num_clients > 0) {
LOG("remapping stack win\n"); DLOG("remapping stack win\n");
xcb_map_window(conn, stack_win->window); xcb_map_window(conn, stack_win->window);
} else LOG("not remapping stackwin, height = %d, num_clients = %d\n", } else DLOG("not remapping stackwin, height = %d, num_clients = %d\n",
stack_win->rect.height, num_clients); stack_win->rect.height, num_clients);
if (container->mode == MODE_TABBED) { if (container->mode == MODE_TABBED) {
/* By setting num_clients to 1 we force that the stack window will be only one line /* By setting num_clients to 1 we force that the stack window will be only one line
* high. The rest of the code is useful in both cases. */ * high. The rest of the code is useful in both cases. */
LOG("tabbed mode, setting num_clients = 1\n"); DLOG("tabbed mode, setting num_clients = 1\n");
if (stack_lines > 1) if (stack_lines > 1)
stack_lines = 1; stack_lines = 1;
} }
@ -530,7 +531,7 @@ void render_container(xcb_connection_t *conn, Container *container) {
current_client++; current_client++;
} else if (container->mode == MODE_TABBED) { } else if (container->mode == MODE_TABBED) {
if (container->stack_limit == STACK_LIMIT_ROWS) { if (container->stack_limit == STACK_LIMIT_ROWS) {
LOG("You limited this container in its rows. " LOG("You limited a tabbed container in its rows. "
"This makes no sense in tabbing mode.\n"); "This makes no sense in tabbing mode.\n");
} }
offset_x = current_client++ * size_each; offset_x = current_client++ * size_each;
@ -571,7 +572,7 @@ void render_container(xcb_connection_t *conn, Container *container) {
static void render_bars(xcb_connection_t *conn, Workspace *r_ws, int width, int *height) { static void render_bars(xcb_connection_t *conn, Workspace *r_ws, int width, int *height) {
Client *client; Client *client;
SLIST_FOREACH(client, &(r_ws->screen->dock_clients), dock_clients) { SLIST_FOREACH(client, &(r_ws->screen->dock_clients), dock_clients) {
LOG("client is at %d, should be at %d\n", client->rect.y, *height); DLOG("client is at %d, should be at %d\n", client->rect.y, *height);
if (client->force_reconfigure | if (client->force_reconfigure |
update_if_necessary(&(client->rect.x), r_ws->rect.x) | update_if_necessary(&(client->rect.x), r_ws->rect.x) |
update_if_necessary(&(client->rect.y), *height)) update_if_necessary(&(client->rect.y), *height))
@ -583,7 +584,7 @@ static void render_bars(xcb_connection_t *conn, Workspace *r_ws, int width, int
resize_client(conn, client); resize_client(conn, client);
client->force_reconfigure = false; client->force_reconfigure = false;
LOG("desired_height = %d\n", client->desired_height); DLOG("desired_height = %d\n", client->desired_height);
*height += client->desired_height; *height += client->desired_height;
} }
} }
@ -717,7 +718,7 @@ void render_workspace(xcb_connection_t *conn, i3Screen *screen, Workspace *r_ws)
single_width = container->width; single_width = container->width;
} }
LOG("height is %d\n", height); DLOG("height is %d\n", height);
container->height = 0; container->height = 0;

View File

@ -124,7 +124,7 @@ static void xcb_check_cb(EV_P_ ev_check *w, int revents) {
* *
*/ */
static void xkb_got_event(EV_P_ struct ev_io *w, int revents) { static void xkb_got_event(EV_P_ struct ev_io *w, int revents) {
LOG("got xkb event, yay\n"); DLOG("Handling XKB event\n");
XEvent ev; XEvent ev;
/* When using xmodmap, every change (!) gets an own event. /* When using xmodmap, every change (!) gets an own event.
* Therefore, we just read all events and only handle the * Therefore, we just read all events and only handle the
@ -139,9 +139,9 @@ static void xkb_got_event(EV_P_ struct ev_io *w, int revents) {
xcb_get_numlock_mask(global_conn); xcb_get_numlock_mask(global_conn);
ungrab_all_keys(global_conn); ungrab_all_keys(global_conn);
LOG("Re-grabbing...\n"); DLOG("Re-grabbing...\n");
grab_all_keys(global_conn); grab_all_keys(global_conn);
LOG("Done\n"); DLOG("Done\n");
} }
@ -258,7 +258,7 @@ int main(int argc, char *argv[], char *env[]) {
int evBase, errBase; int evBase, errBase;
if ((xkbdpy = XkbOpenDisplay(getenv("DISPLAY"), &evBase, &errBase, &major, &minor, &error)) == NULL) { if ((xkbdpy = XkbOpenDisplay(getenv("DISPLAY"), &evBase, &errBase, &major, &minor, &error)) == NULL) {
LOG("ERROR: XkbOpenDisplay() failed, disabling XKB support\n"); ELOG("ERROR: XkbOpenDisplay() failed, disabling XKB support\n");
xkb_supported = false; xkb_supported = false;
} }
@ -383,7 +383,7 @@ int main(int argc, char *argv[], char *env[]) {
#define GET_ATOM(name) { \ #define GET_ATOM(name) { \
xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(conn, atom_cookies[name], NULL); \ xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(conn, atom_cookies[name], NULL); \
if (!reply) { \ if (!reply) { \
LOG("Could not get atom " #name "\n"); \ ELOG("Could not get atom " #name "\n"); \
exit(-1); \ exit(-1); \
} \ } \
atoms[name] = reply->atom; \ atoms[name] = reply->atom; \
@ -453,7 +453,7 @@ int main(int argc, char *argv[], char *env[]) {
} }
/* check for Xinerama */ /* check for Xinerama */
LOG("Checking for Xinerama...\n"); DLOG("Checking for Xinerama...\n");
initialize_xinerama(conn); initialize_xinerama(conn);
xcb_flush(conn); xcb_flush(conn);
@ -461,18 +461,18 @@ int main(int argc, char *argv[], char *env[]) {
/* Get pointer position to see on which screen were starting */ /* Get pointer position to see on which screen were starting */
xcb_query_pointer_reply_t *reply; xcb_query_pointer_reply_t *reply;
if ((reply = xcb_query_pointer_reply(conn, xcb_query_pointer(conn, root), NULL)) == NULL) { if ((reply = xcb_query_pointer_reply(conn, xcb_query_pointer(conn, root), NULL)) == NULL) {
LOG("Could not get pointer position\n"); ELOG("Could not get pointer position\n");
return 1; return 1;
} }
i3Screen *screen = get_screen_containing(reply->root_x, reply->root_y); i3Screen *screen = get_screen_containing(reply->root_x, reply->root_y);
if (screen == NULL) { if (screen == NULL) {
LOG("ERROR: No screen at %d x %d, starting on the first screen\n", ELOG("ERROR: No screen at %d x %d, starting on the first screen\n",
reply->root_x, reply->root_y); reply->root_x, reply->root_y);
screen = TAILQ_FIRST(virtual_screens); screen = TAILQ_FIRST(virtual_screens);
} }
LOG("Starting on %d\n", screen->current_workspace); DLOG("Starting on %d\n", screen->current_workspace);
c_ws = screen->current_workspace; c_ws = screen->current_workspace;
manage_existing_windows(conn, &prophs, root); manage_existing_windows(conn, &prophs, root);
@ -481,7 +481,7 @@ int main(int argc, char *argv[], char *env[]) {
if (config.ipc_socket_path != NULL) { if (config.ipc_socket_path != NULL) {
int ipc_socket = ipc_create_socket(config.ipc_socket_path); int ipc_socket = ipc_create_socket(config.ipc_socket_path);
if (ipc_socket == -1) { if (ipc_socket == -1) {
LOG("Could not create the IPC socket, IPC disabled\n"); ELOG("Could not create the IPC socket, IPC disabled\n");
} else { } else {
struct ev_io *ipc_io = scalloc(sizeof(struct ev_io)); struct ev_io *ipc_io = scalloc(sizeof(struct ev_io));
ev_io_init(ipc_io, ipc_new_client, ipc_socket, EV_READ); ev_io_init(ipc_io, ipc_new_client, ipc_socket, EV_READ);

View File

@ -30,6 +30,7 @@
#include "floating.h" #include "floating.h"
#include "client.h" #include "client.h"
#include "workspace.h" #include "workspace.h"
#include "log.h"
/* /*
* Go through all existing windows (if the window manager is restarted) and manage them * Go through all existing windows (if the window manager is restarted) and manage them
@ -78,7 +79,7 @@ void manage_window(xcb_property_handlers_t *prophs, xcb_connection_t *conn,
/* Check if the window is mapped (it could be not mapped when intializing and /* Check if the window is mapped (it could be not mapped when intializing and
calling manage_window() for every window) */ calling manage_window() for every window) */
if ((attr = xcb_get_window_attributes_reply(conn, cookie, 0)) == NULL) { if ((attr = xcb_get_window_attributes_reply(conn, cookie, 0)) == NULL) {
LOG("Could not get attributes\n"); ELOG("Could not get attributes\n");
return; return;
} }
@ -156,8 +157,8 @@ void reparent_window(xcb_connection_t *conn, xcb_window_t child,
/* Events for already managed windows should already be filtered in manage_window() */ /* Events for already managed windows should already be filtered in manage_window() */
assert(new == NULL); assert(new == NULL);
LOG("Reparenting window 0x%08x\n", child); LOG("Managing window 0x%08x\n", child);
LOG("x = %d, y = %d, width = %d, height = %d\n", x, y, width, height); DLOG("x = %d, y = %d, width = %d, height = %d\n", x, y, width, height);
new = calloc(sizeof(Client), 1); new = calloc(sizeof(Client), 1);
new->force_reconfigure = true; new->force_reconfigure = true;
@ -220,7 +221,7 @@ void reparent_window(xcb_connection_t *conn, xcb_window_t child,
new->awaiting_useless_unmap = true; new->awaiting_useless_unmap = true;
xcb_void_cookie_t cookie = xcb_reparent_window_checked(conn, child, new->frame, 0, font->height); xcb_void_cookie_t cookie = xcb_reparent_window_checked(conn, child, new->frame, 0, font->height);
if (xcb_request_check(conn, cookie) != NULL) { if (xcb_request_check(conn, cookie) != NULL) {
LOG("Could not reparent the window, aborting\n"); DLOG("Could not reparent the window, aborting\n");
xcb_destroy_window(conn, new->frame); xcb_destroy_window(conn, new->frame);
free(new); free(new);
return; return;
@ -247,7 +248,7 @@ void reparent_window(xcb_connection_t *conn, xcb_window_t child,
if (preply != NULL && preply->value_len > 0 && (atom = xcb_get_property_value(preply))) { if (preply != NULL && preply->value_len > 0 && (atom = xcb_get_property_value(preply))) {
for (int i = 0; i < xcb_get_property_value_length(preply); i++) for (int i = 0; i < xcb_get_property_value_length(preply); i++)
if (atom[i] == atoms[_NET_WM_WINDOW_TYPE_DOCK]) { if (atom[i] == atoms[_NET_WM_WINDOW_TYPE_DOCK]) {
LOG("Window is a dock.\n"); DLOG("Window is a dock.\n");
new->dock = true; new->dock = true;
new->borderless = true; new->borderless = true;
new->titlebar_position = TITLEBAR_OFF; new->titlebar_position = TITLEBAR_OFF;
@ -263,19 +264,19 @@ void reparent_window(xcb_connection_t *conn, xcb_window_t child,
atom[i] == atoms[_NET_WM_WINDOW_TYPE_SPLASH]) { atom[i] == atoms[_NET_WM_WINDOW_TYPE_SPLASH]) {
/* Set the dialog window to automatically floating, will be used below */ /* Set the dialog window to automatically floating, will be used below */
new->floating = FLOATING_AUTO_ON; new->floating = FLOATING_AUTO_ON;
LOG("dialog/utility/toolbar/splash window, automatically floating\n"); DLOG("dialog/utility/toolbar/splash window, automatically floating\n");
} }
} }
/* All clients which have a leader should be floating */ /* All clients which have a leader should be floating */
if (!new->dock && !client_is_floating(new) && new->leader != 0) { if (!new->dock && !client_is_floating(new) && new->leader != 0) {
LOG("Client has WM_CLIENT_LEADER hint set, setting floating\n"); DLOG("Client has WM_CLIENT_LEADER hint set, setting floating\n");
new->floating = FLOATING_AUTO_ON; new->floating = FLOATING_AUTO_ON;
} }
if (new->workspace->auto_float) { if (new->workspace->auto_float) {
new->floating = FLOATING_AUTO_ON; new->floating = FLOATING_AUTO_ON;
LOG("workspace is in autofloat mode, setting floating\n"); DLOG("workspace is in autofloat mode, setting floating\n");
} }
if (new->dock) { if (new->dock) {
@ -289,12 +290,12 @@ void reparent_window(xcb_connection_t *conn, xcb_window_t child,
TODO: bars at the top */ TODO: bars at the top */
new->desired_height = strut[3]; new->desired_height = strut[3];
if (new->desired_height == 0) { if (new->desired_height == 0) {
LOG("Client wanted to be 0 pixels high, using the window's height (%d)\n", original_height); DLOG("Client wanted to be 0 pixels high, using the window's height (%d)\n", original_height);
new->desired_height = original_height; new->desired_height = original_height;
} }
LOG("the client wants to be %d pixels high\n", new->desired_height); DLOG("the client wants to be %d pixels high\n", new->desired_height);
} else { } else {
LOG("The client didn't specify space to reserve at the screen edge, using its height (%d)\n", original_height); DLOG("The client didn't specify space to reserve at the screen edge, using its height (%d)\n", original_height);
new->desired_height = original_height; new->desired_height = original_height;
} }
} else { } else {
@ -333,11 +334,11 @@ void reparent_window(xcb_connection_t *conn, xcb_window_t child,
assign->windowclass_title, assign->workspace); assign->windowclass_title, assign->workspace);
if (c_ws->screen->current_workspace->num == (assign->workspace-1)) { if (c_ws->screen->current_workspace->num == (assign->workspace-1)) {
LOG("We are already there, no need to do anything\n"); DLOG("We are already there, no need to do anything\n");
break; break;
} }
LOG("Changing container/workspace and unmapping the client\n"); DLOG("Changing container/workspace and unmapping the client\n");
Workspace *t_ws = workspace_get(assign->workspace-1); Workspace *t_ws = workspace_get(assign->workspace-1);
workspace_initialize(t_ws, c_ws->screen); workspace_initialize(t_ws, c_ws->screen);
@ -351,7 +352,7 @@ void reparent_window(xcb_connection_t *conn, xcb_window_t child,
} }
if (new->workspace->fullscreen_client != NULL) { if (new->workspace->fullscreen_client != NULL) {
LOG("Setting below fullscreen window\n"); DLOG("Setting below fullscreen window\n");
/* If we are in fullscreen, we should lower the window to not be annoying */ /* If we are in fullscreen, we should lower the window to not be annoying */
uint32_t values[] = { XCB_STACK_MODE_BELOW }; uint32_t values[] = { XCB_STACK_MODE_BELOW };
@ -388,10 +389,10 @@ void reparent_window(xcb_connection_t *conn, xcb_window_t child,
* to (0, 0), so we push them to a reasonable position * to (0, 0), so we push them to a reasonable position
* (centered over their leader) */ * (centered over their leader) */
if (new->leader != 0 && x == 0 && y == 0) { if (new->leader != 0 && x == 0 && y == 0) {
LOG("Floating client wants to (0x0), moving it over its leader instead\n"); DLOG("Floating client wants to (0x0), moving it over its leader instead\n");
Client *leader = table_get(&by_child, new->leader); Client *leader = table_get(&by_child, new->leader);
if (leader == NULL) { if (leader == NULL) {
LOG("leader is NULL, centering it over current workspace\n"); DLOG("leader is NULL, centering it over current workspace\n");
x = c_ws->rect.x + (c_ws->rect.width / 2) - (new->rect.width / 2); x = c_ws->rect.x + (c_ws->rect.width / 2) - (new->rect.width / 2);
y = c_ws->rect.y + (c_ws->rect.height / 2) - (new->rect.height / 2); y = c_ws->rect.y + (c_ws->rect.height / 2) - (new->rect.height / 2);
@ -402,10 +403,10 @@ void reparent_window(xcb_connection_t *conn, xcb_window_t child,
} }
new->floating_rect.x = new->rect.x = x; new->floating_rect.x = new->rect.x = x;
new->floating_rect.y = new->rect.y = y; new->floating_rect.y = new->rect.y = y;
LOG("copying floating_rect from tiling (%d, %d) size (%d, %d)\n", DLOG("copying floating_rect from tiling (%d, %d) size (%d, %d)\n",
new->floating_rect.x, new->floating_rect.y, new->floating_rect.x, new->floating_rect.y,
new->floating_rect.width, new->floating_rect.height); new->floating_rect.width, new->floating_rect.height);
LOG("outer rect (%d, %d) size (%d, %d)\n", DLOG("outer rect (%d, %d) size (%d, %d)\n",
new->rect.x, new->rect.y, new->rect.width, new->rect.height); new->rect.x, new->rect.y, new->rect.width, new->rect.height);
/* Make sure it is on top of the other windows */ /* Make sure it is on top of the other windows */

View File

@ -28,6 +28,7 @@
#include "config.h" #include "config.h"
#include "floating.h" #include "floating.h"
#include "workspace.h" #include "workspace.h"
#include "log.h"
/* /*
* Renders the resize window between the first/second container and resizes * Renders the resize window between the first/second container and resizes
@ -39,7 +40,7 @@ int resize_graphical_handler(xcb_connection_t *conn, Workspace *ws, int first, i
int new_position; int new_position;
i3Screen *screen = get_screen_containing(event->root_x, event->root_y); i3Screen *screen = get_screen_containing(event->root_x, event->root_y);
if (screen == NULL) { if (screen == NULL) {
LOG("BUG: No screen found at this position (%d, %d)\n", event->root_x, event->root_y); ELOG("BUG: No screen found at this position (%d, %d)\n", event->root_x, event->root_y);
return 1; return 1;
} }
@ -51,9 +52,9 @@ int resize_graphical_handler(xcb_connection_t *conn, Workspace *ws, int first, i
i3Screen *most_right = get_screen_most(D_RIGHT, screen), i3Screen *most_right = get_screen_most(D_RIGHT, screen),
*most_bottom = get_screen_most(D_DOWN, screen); *most_bottom = get_screen_most(D_DOWN, screen);
LOG("event->event_x = %d, event->root_x = %d\n", event->event_x, event->root_x); DLOG("event->event_x = %d, event->root_x = %d\n", event->event_x, event->root_x);
LOG("Screen dimensions: (%d, %d) %d x %d\n", screen->rect.x, screen->rect.y, screen->rect.width, screen->rect.height); DLOG("Screen dimensions: (%d, %d) %d x %d\n", screen->rect.x, screen->rect.y, screen->rect.width, screen->rect.height);
uint32_t mask = 0; uint32_t mask = 0;
uint32_t values[2]; uint32_t values[2];
@ -100,7 +101,7 @@ int resize_graphical_handler(xcb_connection_t *conn, Workspace *ws, int first, i
xcb_flush(conn); xcb_flush(conn);
void resize_callback(Rect *old_rect, uint32_t new_x, uint32_t new_y) { void resize_callback(Rect *old_rect, uint32_t new_x, uint32_t new_y) {
LOG("new x = %d, y = %d\n", new_x, new_y); DLOG("new x = %d, y = %d\n", new_x, new_y);
if (orientation == O_VERTICAL) { if (orientation == O_VERTICAL) {
/* Check if the new coordinates are within screen boundaries */ /* Check if the new coordinates are within screen boundaries */
if (new_x > (screen->rect.x + screen->rect.width - 25) || if (new_x > (screen->rect.x + screen->rect.width - 25) ||
@ -163,8 +164,8 @@ void resize_container(xcb_connection_t *conn, Workspace *ws, int first, int seco
if (ws->width_factor[second] == 0) if (ws->width_factor[second] == 0)
new_unoccupied_x += default_width; new_unoccupied_x += default_width;
LOG("\n\n\n"); DLOG("\n\n\n");
LOG("old = %d, new = %d\n", old_unoccupied_x, new_unoccupied_x); DLOG("old = %d, new = %d\n", old_unoccupied_x, new_unoccupied_x);
int cols_without_wf = 0; int cols_without_wf = 0;
int old_width, old_second_width; int old_width, old_second_width;
@ -172,20 +173,20 @@ void resize_container(xcb_connection_t *conn, Workspace *ws, int first, int seco
if (ws->width_factor[col] == 0) if (ws->width_factor[col] == 0)
cols_without_wf++; cols_without_wf++;
LOG("old_unoccupied_x = %d\n", old_unoccupied_x); DLOG("old_unoccupied_x = %d\n", old_unoccupied_x);
LOG("Updating first (before = %f)\n", ws->width_factor[first]); DLOG("Updating first (before = %f)\n", ws->width_factor[first]);
/* Convert 0 (for default width_factor) to actual numbers */ /* Convert 0 (for default width_factor) to actual numbers */
if (ws->width_factor[first] == 0) if (ws->width_factor[first] == 0)
old_width = (old_unoccupied_x / max(cols_without_wf, 1)); old_width = (old_unoccupied_x / max(cols_without_wf, 1));
else old_width = ws->width_factor[first] * old_unoccupied_x; else old_width = ws->width_factor[first] * old_unoccupied_x;
LOG("second (before = %f)\n", ws->width_factor[second]); DLOG("second (before = %f)\n", ws->width_factor[second]);
if (ws->width_factor[second] == 0) if (ws->width_factor[second] == 0)
old_second_width = (old_unoccupied_x / max(cols_without_wf, 1)); old_second_width = (old_unoccupied_x / max(cols_without_wf, 1));
else old_second_width = ws->width_factor[second] * old_unoccupied_x; else old_second_width = ws->width_factor[second] * old_unoccupied_x;
LOG("middle = %f\n", ws->width_factor[first]); DLOG("middle = %f\n", ws->width_factor[first]);
/* If the space used for customly resized columns has changed we need to adapt the /* If the space used for customly resized columns has changed we need to adapt the
* other customly resized columns, if any */ * other customly resized columns, if any */
@ -194,33 +195,33 @@ void resize_container(xcb_connection_t *conn, Workspace *ws, int first, int seco
if (ws->width_factor[col] == 0) if (ws->width_factor[col] == 0)
continue; continue;
LOG("Updating other column (%d) (current width_factor = %f)\n", col, ws->width_factor[col]); DLOG("Updating other column (%d) (current width_factor = %f)\n", col, ws->width_factor[col]);
ws->width_factor[col] = (ws->width_factor[col] * old_unoccupied_x) / new_unoccupied_x; ws->width_factor[col] = (ws->width_factor[col] * old_unoccupied_x) / new_unoccupied_x;
LOG("to %f\n", ws->width_factor[col]); DLOG("to %f\n", ws->width_factor[col]);
} }
LOG("Updating first (before = %f)\n", ws->width_factor[first]); DLOG("Updating first (before = %f)\n", ws->width_factor[first]);
/* Convert 0 (for default width_factor) to actual numbers */ /* Convert 0 (for default width_factor) to actual numbers */
if (ws->width_factor[first] == 0) if (ws->width_factor[first] == 0)
ws->width_factor[first] = ((float)ws->rect.width / ws->cols) / new_unoccupied_x; ws->width_factor[first] = ((float)ws->rect.width / ws->cols) / new_unoccupied_x;
LOG("first->width = %d, pixels = %d\n", old_width, pixels); DLOG("first->width = %d, pixels = %d\n", old_width, pixels);
ws->width_factor[first] *= (float)(old_width + pixels) / old_width; ws->width_factor[first] *= (float)(old_width + pixels) / old_width;
LOG("-> %f\n", ws->width_factor[first]); DLOG("-> %f\n", ws->width_factor[first]);
LOG("Updating second (before = %f)\n", ws->width_factor[second]); DLOG("Updating second (before = %f)\n", ws->width_factor[second]);
if (ws->width_factor[second] == 0) if (ws->width_factor[second] == 0)
ws->width_factor[second] = ((float)ws->rect.width / ws->cols) / new_unoccupied_x; ws->width_factor[second] = ((float)ws->rect.width / ws->cols) / new_unoccupied_x;
LOG("middle = %f\n", ws->width_factor[second]); DLOG("middle = %f\n", ws->width_factor[second]);
LOG("second->width = %d, pixels = %d\n", old_second_width, pixels); DLOG("second->width = %d, pixels = %d\n", old_second_width, pixels);
ws->width_factor[second] *= (float)(old_second_width - pixels) / old_second_width; ws->width_factor[second] *= (float)(old_second_width - pixels) / old_second_width;
LOG("-> %f\n", ws->width_factor[second]); DLOG("-> %f\n", ws->width_factor[second]);
LOG("new unoccupied_x = %d\n", get_unoccupied_x(ws)); DLOG("new unoccupied_x = %d\n", get_unoccupied_x(ws));
LOG("\n\n\n"); DLOG("\n\n\n");
} else { } else {
int ws_height = workspace_height(ws); int ws_height = workspace_height(ws);
int default_height = ws_height / ws->rows; int default_height = ws_height / ws->rows;
@ -245,24 +246,24 @@ void resize_container(xcb_connection_t *conn, Workspace *ws, int first, int seco
if (ws->height_factor[row] == 0) if (ws->height_factor[row] == 0)
cols_without_hf++; cols_without_hf++;
LOG("old_unoccupied_y = %d\n", old_unoccupied_y); DLOG("old_unoccupied_y = %d\n", old_unoccupied_y);
LOG("Updating first (before = %f)\n", ws->height_factor[first]); DLOG("Updating first (before = %f)\n", ws->height_factor[first]);
/* Convert 0 (for default width_factor) to actual numbers */ /* Convert 0 (for default width_factor) to actual numbers */
if (ws->height_factor[first] == 0) if (ws->height_factor[first] == 0)
old_height = (old_unoccupied_y / max(cols_without_hf, 1)); old_height = (old_unoccupied_y / max(cols_without_hf, 1));
else old_height = ws->height_factor[first] * old_unoccupied_y; else old_height = ws->height_factor[first] * old_unoccupied_y;
LOG("second (before = %f)\n", ws->height_factor[second]); DLOG("second (before = %f)\n", ws->height_factor[second]);
if (ws->height_factor[second] == 0) if (ws->height_factor[second] == 0)
old_second_height = (old_unoccupied_y / max(cols_without_hf, 1)); old_second_height = (old_unoccupied_y / max(cols_without_hf, 1));
else old_second_height = ws->height_factor[second] * old_unoccupied_y; else old_second_height = ws->height_factor[second] * old_unoccupied_y;
LOG("middle = %f\n", ws->height_factor[first]); DLOG("middle = %f\n", ws->height_factor[first]);
LOG("\n\n\n"); DLOG("\n\n\n");
LOG("old = %d, new = %d\n", old_unoccupied_y, new_unoccupied_y); DLOG("old = %d, new = %d\n", old_unoccupied_y, new_unoccupied_y);
/* If the space used for customly resized columns has changed we need to adapt the /* If the space used for customly resized columns has changed we need to adapt the
* other customly resized columns, if any */ * other customly resized columns, if any */
@ -271,33 +272,33 @@ void resize_container(xcb_connection_t *conn, Workspace *ws, int first, int seco
if (ws->height_factor[row] == 0) if (ws->height_factor[row] == 0)
continue; continue;
LOG("Updating other column (%d) (current width_factor = %f)\n", row, ws->height_factor[row]); DLOG("Updating other column (%d) (current width_factor = %f)\n", row, ws->height_factor[row]);
ws->height_factor[row] = (ws->height_factor[row] * old_unoccupied_y) / new_unoccupied_y; ws->height_factor[row] = (ws->height_factor[row] * old_unoccupied_y) / new_unoccupied_y;
LOG("to %f\n", ws->height_factor[row]); DLOG("to %f\n", ws->height_factor[row]);
} }
LOG("Updating first (before = %f)\n", ws->height_factor[first]); DLOG("Updating first (before = %f)\n", ws->height_factor[first]);
/* Convert 0 (for default width_factor) to actual numbers */ /* Convert 0 (for default width_factor) to actual numbers */
if (ws->height_factor[first] == 0) if (ws->height_factor[first] == 0)
ws->height_factor[first] = ((float)ws_height / ws->rows) / new_unoccupied_y; ws->height_factor[first] = ((float)ws_height / ws->rows) / new_unoccupied_y;
LOG("first->width = %d, pixels = %d\n", old_height, pixels); DLOG("first->width = %d, pixels = %d\n", old_height, pixels);
ws->height_factor[first] *= (float)(old_height + pixels) / old_height; ws->height_factor[first] *= (float)(old_height + pixels) / old_height;
LOG("-> %f\n", ws->height_factor[first]); DLOG("-> %f\n", ws->height_factor[first]);
LOG("Updating second (before = %f)\n", ws->height_factor[second]); DLOG("Updating second (before = %f)\n", ws->height_factor[second]);
if (ws->height_factor[second] == 0) if (ws->height_factor[second] == 0)
ws->height_factor[second] = ((float)ws_height / ws->rows) / new_unoccupied_y; ws->height_factor[second] = ((float)ws_height / ws->rows) / new_unoccupied_y;
LOG("middle = %f\n", ws->height_factor[second]); DLOG("middle = %f\n", ws->height_factor[second]);
LOG("second->width = %d, pixels = %d\n", old_second_height, pixels); DLOG("second->width = %d, pixels = %d\n", old_second_height, pixels);
ws->height_factor[second] *= (float)(old_second_height - pixels) / old_second_height; ws->height_factor[second] *= (float)(old_second_height - pixels) / old_second_height;
LOG("-> %f\n", ws->height_factor[second]); DLOG("-> %f\n", ws->height_factor[second]);
LOG("new unoccupied_y = %d\n", get_unoccupied_y(ws)); DLOG("new unoccupied_y = %d\n", get_unoccupied_y(ws));
LOG("\n\n\n"); DLOG("\n\n\n");
} }
render_layout(conn); render_layout(conn);

View File

@ -27,6 +27,7 @@
#include "layout.h" #include "layout.h"
#include "config.h" #include "config.h"
#include "workspace.h" #include "workspace.h"
#include "log.h"
int current_workspace = 0; int current_workspace = 0;
int num_workspaces = 1; int num_workspaces = 1;
@ -96,9 +97,9 @@ void expand_table_rows_at_head(Workspace *workspace) {
workspace->height_factor = realloc(workspace->height_factor, sizeof(float) * workspace->rows); workspace->height_factor = realloc(workspace->height_factor, sizeof(float) * workspace->rows);
LOG("rows = %d\n", workspace->rows); DLOG("rows = %d\n", workspace->rows);
for (int rows = (workspace->rows - 1); rows >= 1; rows--) { for (int rows = (workspace->rows - 1); rows >= 1; rows--) {
LOG("Moving height_factor %d (%f) to %d\n", rows-1, workspace->height_factor[rows-1], rows); DLOG("Moving height_factor %d (%f) to %d\n", rows-1, workspace->height_factor[rows-1], rows);
workspace->height_factor[rows] = workspace->height_factor[rows-1]; workspace->height_factor[rows] = workspace->height_factor[rows-1];
} }
@ -110,7 +111,7 @@ void expand_table_rows_at_head(Workspace *workspace) {
/* Move the other rows */ /* Move the other rows */
for (int cols = 0; cols < workspace->cols; cols++) for (int cols = 0; cols < workspace->cols; cols++)
for (int rows = workspace->rows - 1; rows > 0; rows--) { for (int rows = workspace->rows - 1; rows > 0; rows--) {
LOG("Moving row %d to %d\n", rows-1, rows); DLOG("Moving row %d to %d\n", rows-1, rows);
workspace->table[cols][rows] = workspace->table[cols][rows-1]; workspace->table[cols][rows] = workspace->table[cols][rows-1];
workspace->table[cols][rows]->row = rows; workspace->table[cols][rows]->row = rows;
} }
@ -148,9 +149,9 @@ void expand_table_cols_at_head(Workspace *workspace) {
workspace->width_factor = realloc(workspace->width_factor, sizeof(float) * workspace->cols); workspace->width_factor = realloc(workspace->width_factor, sizeof(float) * workspace->cols);
LOG("cols = %d\n", workspace->cols); DLOG("cols = %d\n", workspace->cols);
for (int cols = (workspace->cols - 1); cols >= 1; cols--) { for (int cols = (workspace->cols - 1); cols >= 1; cols--) {
LOG("Moving width_factor %d (%f) to %d\n", cols-1, workspace->width_factor[cols-1], cols); DLOG("Moving width_factor %d (%f) to %d\n", cols-1, workspace->width_factor[cols-1], cols);
workspace->width_factor[cols] = workspace->width_factor[cols-1]; workspace->width_factor[cols] = workspace->width_factor[cols-1];
} }
@ -162,7 +163,7 @@ void expand_table_cols_at_head(Workspace *workspace) {
/* Move the other columns */ /* Move the other columns */
for (int rows = 0; rows < workspace->rows; rows++) for (int rows = 0; rows < workspace->rows; rows++)
for (int cols = workspace->cols - 1; cols > 0; cols--) { for (int cols = workspace->cols - 1; cols > 0; cols--) {
LOG("Moving col %d to %d\n", cols-1, cols); DLOG("Moving col %d to %d\n", cols-1, cols);
workspace->table[cols][rows] = workspace->table[cols-1][rows]; workspace->table[cols][rows] = workspace->table[cols-1][rows];
workspace->table[cols][rows]->col = cols; workspace->table[cols][rows]->col = cols;
} }
@ -201,7 +202,7 @@ static void shrink_table_cols(Workspace *workspace) {
if (workspace->width_factor[cols] == 0) if (workspace->width_factor[cols] == 0)
continue; continue;
LOG("Added free space (%f) to %d (had %f)\n", free_space, cols, DLOG("Added free space (%f) to %d (had %f)\n", free_space, cols,
workspace->width_factor[cols]); workspace->width_factor[cols]);
workspace->width_factor[cols] += free_space; workspace->width_factor[cols] += free_space;
break; break;
@ -230,7 +231,7 @@ static void shrink_table_rows(Workspace *workspace) {
if (workspace->height_factor[rows] == 0) if (workspace->height_factor[rows] == 0)
continue; continue;
LOG("Added free space (%f) to %d (had %f)\n", free_space, rows, DLOG("Added free space (%f) to %d (had %f)\n", free_space, rows,
workspace->height_factor[rows]); workspace->height_factor[rows]);
workspace->height_factor[rows] += free_space; workspace->height_factor[rows] += free_space;
break; break;
@ -256,7 +257,7 @@ static void free_container(xcb_connection_t *conn, Workspace *workspace, int col
} }
static void move_columns_from(xcb_connection_t *conn, Workspace *workspace, int cols) { static void move_columns_from(xcb_connection_t *conn, Workspace *workspace, int cols) {
LOG("firstly freeing \n"); DLOG("firstly freeing \n");
/* Free the columns which are cleaned up */ /* Free the columns which are cleaned up */
for (int rows = 0; rows < workspace->rows; rows++) for (int rows = 0; rows < workspace->rows; rows++)
@ -264,10 +265,10 @@ static void move_columns_from(xcb_connection_t *conn, Workspace *workspace, int
for (; cols < workspace->cols; cols++) for (; cols < workspace->cols; cols++)
for (int rows = 0; rows < workspace->rows; rows++) { for (int rows = 0; rows < workspace->rows; rows++) {
LOG("at col = %d, row = %d\n", cols, rows); DLOG("at col = %d, row = %d\n", cols, rows);
Container *new_container = workspace->table[cols][rows]; Container *new_container = workspace->table[cols][rows];
LOG("moving cols = %d to cols -1 = %d\n", cols, cols-1); DLOG("moving cols = %d to cols -1 = %d\n", cols, cols-1);
workspace->table[cols-1][rows] = new_container; workspace->table[cols-1][rows] = new_container;
new_container->row = rows; new_container->row = rows;
@ -283,7 +284,7 @@ static void move_rows_from(xcb_connection_t *conn, Workspace *workspace, int row
for (int cols = 0; cols < workspace->cols; cols++) { for (int cols = 0; cols < workspace->cols; cols++) {
Container *new_container = workspace->table[cols][rows]; Container *new_container = workspace->table[cols][rows];
LOG("moving rows = %d to rows -1 = %d\n", rows, rows - 1); DLOG("moving rows = %d to rows -1 = %d\n", rows, rows - 1);
workspace->table[cols][rows-1] = new_container; workspace->table[cols][rows-1] = new_container;
new_container->row = rows-1; new_container->row = rows-1;
@ -296,19 +297,19 @@ static void move_rows_from(xcb_connection_t *conn, Workspace *workspace, int row
* *
*/ */
void dump_table(xcb_connection_t *conn, Workspace *workspace) { void dump_table(xcb_connection_t *conn, Workspace *workspace) {
LOG("dump_table()\n"); DLOG("dump_table()\n");
FOR_TABLE(workspace) { FOR_TABLE(workspace) {
Container *con = workspace->table[cols][rows]; Container *con = workspace->table[cols][rows];
LOG("----\n"); DLOG("----\n");
LOG("at col=%d, row=%d\n", cols, rows); DLOG("at col=%d, row=%d\n", cols, rows);
LOG("currently_focused = %p\n", con->currently_focused); DLOG("currently_focused = %p\n", con->currently_focused);
Client *loop; Client *loop;
CIRCLEQ_FOREACH(loop, &(con->clients), clients) { CIRCLEQ_FOREACH(loop, &(con->clients), clients) {
LOG("got client %08x / %s\n", loop->child, loop->name); DLOG("got client %08x / %s\n", loop->child, loop->name);
} }
LOG("----\n"); DLOG("----\n");
} }
LOG("done\n"); DLOG("done\n");
} }
/* /*
@ -316,7 +317,7 @@ void dump_table(xcb_connection_t *conn, Workspace *workspace) {
* *
*/ */
void cleanup_table(xcb_connection_t *conn, Workspace *workspace) { void cleanup_table(xcb_connection_t *conn, Workspace *workspace) {
LOG("cleanup_table()\n"); DLOG("cleanup_table()\n");
/* Check for empty columns if we got more than one column */ /* Check for empty columns if we got more than one column */
for (int cols = 0; (workspace->cols > 1) && (cols < workspace->cols);) { for (int cols = 0; (workspace->cols > 1) && (cols < workspace->cols);) {
@ -327,7 +328,7 @@ void cleanup_table(xcb_connection_t *conn, Workspace *workspace) {
break; break;
} }
if (completely_empty) { if (completely_empty) {
LOG("Removing completely empty column %d\n", cols); DLOG("Removing completely empty column %d\n", cols);
if (cols < (workspace->cols - 1)) if (cols < (workspace->cols - 1))
move_columns_from(conn, workspace, cols+1); move_columns_from(conn, workspace, cols+1);
else { else {
@ -344,14 +345,14 @@ void cleanup_table(xcb_connection_t *conn, Workspace *workspace) {
/* Check for empty rows if we got more than one row */ /* Check for empty rows if we got more than one row */
for (int rows = 0; (workspace->rows > 1) && (rows < workspace->rows);) { for (int rows = 0; (workspace->rows > 1) && (rows < workspace->rows);) {
bool completely_empty = true; bool completely_empty = true;
LOG("Checking row %d\n", rows); DLOG("Checking row %d\n", rows);
for (int cols = 0; cols < workspace->cols; cols++) for (int cols = 0; cols < workspace->cols; cols++)
if (workspace->table[cols][rows]->currently_focused != NULL) { if (workspace->table[cols][rows]->currently_focused != NULL) {
completely_empty = false; completely_empty = false;
break; break;
} }
if (completely_empty) { if (completely_empty) {
LOG("Removing completely empty row %d\n", rows); DLOG("Removing completely empty row %d\n", rows);
if (rows < (workspace->rows - 1)) if (rows < (workspace->rows - 1))
move_rows_from(conn, workspace, rows+1); move_rows_from(conn, workspace, rows+1);
else { else {
@ -381,25 +382,25 @@ void cleanup_table(xcb_connection_t *conn, Workspace *workspace) {
* *
*/ */
void fix_colrowspan(xcb_connection_t *conn, Workspace *workspace) { void fix_colrowspan(xcb_connection_t *conn, Workspace *workspace) {
LOG("Fixing col/rowspan\n"); DLOG("Fixing col/rowspan\n");
FOR_TABLE(workspace) { FOR_TABLE(workspace) {
Container *con = workspace->table[cols][rows]; Container *con = workspace->table[cols][rows];
if (con->colspan > 1) { if (con->colspan > 1) {
LOG("gots one with colspan %d (at %d c, %d r)\n", con->colspan, cols, rows); DLOG("gots one with colspan %d (at %d c, %d r)\n", con->colspan, cols, rows);
while (con->colspan > 1 && while (con->colspan > 1 &&
(!cell_exists(cols + (con->colspan-1), rows) || (!cell_exists(cols + (con->colspan-1), rows) ||
workspace->table[cols + (con->colspan - 1)][rows]->currently_focused != NULL)) workspace->table[cols + (con->colspan - 1)][rows]->currently_focused != NULL))
con->colspan--; con->colspan--;
LOG("fixed it to %d\n", con->colspan); DLOG("fixed it to %d\n", con->colspan);
} }
if (con->rowspan > 1) { if (con->rowspan > 1) {
LOG("gots one with rowspan %d (at %d c, %d r)\n", con->rowspan, cols, rows); DLOG("gots one with rowspan %d (at %d c, %d r)\n", con->rowspan, cols, rows);
while (con->rowspan > 1 && while (con->rowspan > 1 &&
(!cell_exists(cols, rows + (con->rowspan - 1)) || (!cell_exists(cols, rows + (con->rowspan - 1)) ||
workspace->table[cols][rows + (con->rowspan - 1)]->currently_focused != NULL)) workspace->table[cols][rows + (con->rowspan - 1)]->currently_focused != NULL))
con->rowspan--; con->rowspan--;
LOG("fixed it to %d\n", con->rowspan); DLOG("fixed it to %d\n", con->rowspan);
} }
} }
} }

View File

@ -31,6 +31,7 @@
#include "util.h" #include "util.h"
#include "xcb.h" #include "xcb.h"
#include "client.h" #include "client.h"
#include "log.h"
static iconv_t conversion_descriptor = 0; static iconv_t conversion_descriptor = 0;
struct keyvalue_table_head by_parent = TAILQ_HEAD_INITIALIZER(by_parent); struct keyvalue_table_head by_parent = TAILQ_HEAD_INITIALIZER(by_parent);
@ -44,27 +45,6 @@ int max(int a, int b) {
return (a > b ? a : b); return (a > b ? a : b);
} }
/*
* Logs the given message to stdout while prefixing the current time to it.
* This is to be called by LOG() which includes filename/linenumber
*
*/
void slog(char *fmt, ...) {
va_list args;
char timebuf[64];
va_start(args, fmt);
/* Get current time */
time_t t = time(NULL);
/* Convert time to local time (determined by the locale) */
struct tm *tmp = localtime(&t);
/* Generate time prefix */
strftime(timebuf, sizeof(timebuf), "%x %X - ", tmp);
printf("%s", timebuf);
vprintf(fmt, args);
va_end(args);
}
/* /*
* The s* functions (safe) are wrappers around malloc, strdup, , which exits if one of * The s* functions (safe) are wrappers around malloc, strdup, , which exits if one of
* the called functions returns NULL, meaning that there is no more memory available * the called functions returns NULL, meaning that there is no more memory available
@ -280,7 +260,7 @@ void set_focus(xcb_connection_t *conn, Client *client, bool set_anyways) {
Client *last_focused = get_last_focused_client(conn, client->container, client); Client *last_focused = get_last_focused_client(conn, client->container, client);
if (last_focused != NULL) { if (last_focused != NULL) {
LOG("raising above frame %p / child %p\n", last_focused->frame, last_focused->child); DLOG("raising above frame %p / child %p\n", last_focused->frame, last_focused->child);
uint32_t values[] = { last_focused->frame, XCB_STACK_MODE_ABOVE }; uint32_t values[] = { last_focused->frame, XCB_STACK_MODE_ABOVE };
xcb_configure_window(conn, client->frame, XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE, values); xcb_configure_window(conn, client->frame, XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE, values);
} }
@ -294,13 +274,13 @@ void set_focus(xcb_connection_t *conn, Client *client, bool set_anyways) {
/* If the last client was a floating client, we need to go to the next /* If the last client was a floating client, we need to go to the next
* tiling client in stack and re-decorate it. */ * tiling client in stack and re-decorate it. */
if (old_client != NULL && client_is_floating(old_client)) { if (old_client != NULL && client_is_floating(old_client)) {
LOG("Coming from floating client, searching next tiling...\n"); DLOG("Coming from floating client, searching next tiling...\n");
Client *current; Client *current;
SLIST_FOREACH(current, &(client->workspace->focus_stack), focus_clients) { SLIST_FOREACH(current, &(client->workspace->focus_stack), focus_clients) {
if (client_is_floating(current)) if (client_is_floating(current))
continue; continue;
LOG("Found window: %p / child %p\n", current->frame, current->child); DLOG("Found window: %p / child %p\n", current->frame, current->child);
redecorate_window(conn, current); redecorate_window(conn, current);
break; break;
} }
@ -411,14 +391,14 @@ after_stackwin:
if (client == container->currently_focused || client == last_focused) if (client == container->currently_focused || client == last_focused)
continue; continue;
LOG("setting %08x below %08x / %08x\n", client->frame, container->currently_focused->frame); DLOG("setting %08x below %08x / %08x\n", client->frame, container->currently_focused->frame);
uint32_t values[] = { container->currently_focused->frame, XCB_STACK_MODE_BELOW }; uint32_t values[] = { container->currently_focused->frame, XCB_STACK_MODE_BELOW };
xcb_configure_window(conn, client->frame, xcb_configure_window(conn, client->frame,
XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE, values); XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE, values);
} }
if (last_focused != NULL) { if (last_focused != NULL) {
LOG("Putting last_focused directly underneath the currently focused\n"); DLOG("Putting last_focused directly underneath the currently focused\n");
uint32_t values[] = { container->currently_focused->frame, XCB_STACK_MODE_BELOW }; uint32_t values[] = { container->currently_focused->frame, XCB_STACK_MODE_BELOW };
xcb_configure_window(conn, last_focused->frame, xcb_configure_window(conn, last_focused->frame,
XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE, values); XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE, values);
@ -457,7 +437,7 @@ Client *get_matching_client(xcb_connection_t *conn, const char *window_classtitl
goto done; goto done;
} }
LOG("Getting clients for class \"%s\" / title \"%s\"\n", to_class, to_title); DLOG("Getting clients for class \"%s\" / title \"%s\"\n", to_class, to_title);
Workspace *ws; Workspace *ws;
TAILQ_FOREACH(ws, workspaces, workspaces) { TAILQ_FOREACH(ws, workspaces, workspaces) {
if (ws->screen == NULL) if (ws->screen == NULL)
@ -465,7 +445,7 @@ Client *get_matching_client(xcb_connection_t *conn, const char *window_classtitl
Client *client; Client *client;
SLIST_FOREACH(client, &(ws->focus_stack), focus_clients) { SLIST_FOREACH(client, &(ws->focus_stack), focus_clients) {
LOG("Checking client with class=%s, name=%s\n", client->window_class, client->name); DLOG("Checking client with class=%s, name=%s\n", client->window_class, client->name);
if (!client_matches_class_name(client, to_class, to_title, to_title_ucs, to_title_ucs_len)) if (!client_matches_class_name(client, to_class, to_title, to_title_ucs, to_title_ucs_len))
continue; continue;

View File

@ -26,6 +26,7 @@
#include "layout.h" #include "layout.h"
#include "workspace.h" #include "workspace.h"
#include "client.h" #include "client.h"
#include "log.h"
/* /*
* Returns a pointer to the workspace with the given number (starting at 0), * Returns a pointer to the workspace with the given number (starting at 0),
@ -42,10 +43,10 @@ Workspace *workspace_get(int number) {
/* If we are still there, we could not find the requested workspace. */ /* If we are still there, we could not find the requested workspace. */
int last_ws = TAILQ_LAST(workspaces, workspaces_head)->num; int last_ws = TAILQ_LAST(workspaces, workspaces_head)->num;
LOG("We need to initialize that one, last ws = %d\n", last_ws); DLOG("We need to initialize that one, last ws = %d\n", last_ws);
for (int c = last_ws; c < number; c++) { for (int c = last_ws; c < number; c++) {
LOG("Creating new ws\n"); DLOG("Creating new ws\n");
ws = scalloc(sizeof(Workspace)); ws = scalloc(sizeof(Workspace));
ws->num = c+1; ws->num = c+1;
@ -56,7 +57,7 @@ Workspace *workspace_get(int number) {
TAILQ_INSERT_TAIL(workspaces, ws, workspaces); TAILQ_INSERT_TAIL(workspaces, ws, workspaces);
} }
LOG("done\n"); DLOG("done\n");
return ws; return ws;
} }
@ -109,7 +110,7 @@ void workspace_show(xcb_connection_t *conn, int workspace) {
/* t_ws (to workspace) is just a convenience pointer to the workspace were switching to */ /* t_ws (to workspace) is just a convenience pointer to the workspace were switching to */
Workspace *t_ws = workspace_get(workspace-1); Workspace *t_ws = workspace_get(workspace-1);
LOG("show_workspace(%d)\n", workspace); DLOG("show_workspace(%d)\n", workspace);
/* Store current_row/current_col */ /* Store current_row/current_col */
c_ws->current_row = current_row; c_ws->current_row = current_row;
@ -120,7 +121,7 @@ void workspace_show(xcb_connection_t *conn, int workspace) {
if (c_ws->screen != t_ws->screen) { if (c_ws->screen != t_ws->screen) {
/* We need to switch to the other screen first */ /* We need to switch to the other screen first */
LOG("moving over to other screen.\n"); DLOG("moving over to other screen.\n");
/* Store the old client */ /* Store the old client */
Client *old_client = CUR_CELL->currently_focused; Client *old_client = CUR_CELL->currently_focused;
@ -163,7 +164,7 @@ void workspace_show(xcb_connection_t *conn, int workspace) {
current_row = c_ws->current_row; current_row = c_ws->current_row;
current_col = c_ws->current_col; current_col = c_ws->current_col;
LOG("new current row = %d, current col = %d\n", current_row, current_col); DLOG("new current row = %d, current col = %d\n", current_row, current_col);
workspace_map_clients(conn, c_ws); workspace_map_clients(conn, c_ws);
@ -206,7 +207,7 @@ static i3Screen *get_screen_from_preference(struct screens_head *slist, char *pr
char *rest; char *rest;
int preferred_screen = strtol(preference, &rest, 10); int preferred_screen = strtol(preference, &rest, 10);
LOG("Getting screen for preference \"%s\" (%d)\n", preference, preferred_screen); DLOG("Getting screen for preference \"%s\" (%d)\n", preference, preferred_screen);
if ((rest == preference) || (preferred_screen >= num_screens)) { if ((rest == preference) || (preferred_screen >= num_screens)) {
int x = INT_MAX, y = INT_MAX; int x = INT_MAX, y = INT_MAX;
@ -222,16 +223,16 @@ static i3Screen *get_screen_from_preference(struct screens_head *slist, char *pr
x = atoi(preference); x = atoi(preference);
} }
LOG("Looking for screen at %d x %d\n", x, y); DLOG("Looking for screen at %d x %d\n", x, y);
TAILQ_FOREACH(screen, slist, screens) TAILQ_FOREACH(screen, slist, screens)
if ((x == INT_MAX || screen->rect.x == x) && if ((x == INT_MAX || screen->rect.x == x) &&
(y == INT_MAX || screen->rect.y == y)) { (y == INT_MAX || screen->rect.y == y)) {
LOG("found %p\n", screen); DLOG("found %p\n", screen);
return screen; return screen;
} }
LOG("none found\n"); DLOG("none found\n");
return NULL; return NULL;
} else { } else {
int c = 0; int c = 0;
@ -252,7 +253,7 @@ static i3Screen *get_screen_from_preference(struct screens_head *slist, char *pr
*/ */
void workspace_initialize(Workspace *ws, i3Screen *screen) { void workspace_initialize(Workspace *ws, i3Screen *screen) {
if (ws->screen != NULL) { if (ws->screen != NULL) {
LOG("Workspace already initialized\n"); DLOG("Workspace already initialized\n");
return; return;
} }
@ -298,7 +299,7 @@ Workspace *get_first_workspace_for_screen(struct screens_head *slist, i3Screen *
} }
if (result == NULL) { if (result == NULL) {
LOG("No existing free workspace found to assign, creating a new one\n"); DLOG("No existing free workspace found to assign, creating a new one\n");
Workspace *ws; Workspace *ws;
int last_ws = 0; int last_ws = 0;
@ -359,7 +360,7 @@ void workspace_unmap_clients(xcb_connection_t *conn, Workspace *u_ws) {
int unmapped_clients = 0; int unmapped_clients = 0;
FOR_TABLE(u_ws) FOR_TABLE(u_ws)
CIRCLEQ_FOREACH(client, &(u_ws->table[cols][rows]->clients), clients) { CIRCLEQ_FOREACH(client, &(u_ws->table[cols][rows]->clients), clients) {
LOG("unmapping normal client %p / %p / %p\n", client, client->frame, client->child); DLOG("unmapping normal client %p / %p / %p\n", client, client->frame, client->child);
client_unmap(conn, client); client_unmap(conn, client);
unmapped_clients++; unmapped_clients++;
} }
@ -369,7 +370,7 @@ void workspace_unmap_clients(xcb_connection_t *conn, Workspace *u_ws) {
if (!client_is_floating(client)) if (!client_is_floating(client))
continue; continue;
LOG("unmapping floating client %p / %p / %p\n", client, client->frame, client->child); DLOG("unmapping floating client %p / %p / %p\n", client, client->frame, client->child);
client_unmap(conn, client); client_unmap(conn, client);
unmapped_clients++; unmapped_clients++;
@ -380,12 +381,12 @@ void workspace_unmap_clients(xcb_connection_t *conn, Workspace *u_ws) {
if (unmapped_clients == 0 && u_ws != c_ws) { if (unmapped_clients == 0 && u_ws != c_ws) {
/* Re-assign the workspace of all dock clients which use this workspace */ /* Re-assign the workspace of all dock clients which use this workspace */
Client *dock; Client *dock;
LOG("workspace %p is empty\n", u_ws); DLOG("workspace %p is empty\n", u_ws);
SLIST_FOREACH(dock, &(u_ws->screen->dock_clients), dock_clients) { SLIST_FOREACH(dock, &(u_ws->screen->dock_clients), dock_clients) {
if (dock->workspace != u_ws) if (dock->workspace != u_ws)
continue; continue;
LOG("Re-assigning dock client to c_ws (%p)\n", c_ws); DLOG("Re-assigning dock client to c_ws (%p)\n", c_ws);
dock->workspace = c_ws; dock->workspace = c_ws;
} }
u_ws->screen = NULL; u_ws->screen = NULL;

View File

@ -21,6 +21,7 @@
#include "i3.h" #include "i3.h"
#include "util.h" #include "util.h"
#include "xcb.h" #include "xcb.h"
#include "log.h"
TAILQ_HEAD(cached_fonts_head, Font) cached_fonts = TAILQ_HEAD_INITIALIZER(cached_fonts); TAILQ_HEAD(cached_fonts_head, Font) cached_fonts = TAILQ_HEAD_INITIALIZER(cached_fonts);
unsigned int xcb_numlock_mask; unsigned int xcb_numlock_mask;
@ -270,7 +271,7 @@ void xcb_raise_window(xcb_connection_t *conn, xcb_window_t window) {
* *
*/ */
void cached_pixmap_prepare(xcb_connection_t *conn, struct Cached_Pixmap *pixmap) { void cached_pixmap_prepare(xcb_connection_t *conn, struct Cached_Pixmap *pixmap) {
LOG("preparing pixmap\n"); DLOG("preparing pixmap\n");
/* If the Rect did not change, the pixmap does not need to be recreated */ /* If the Rect did not change, the pixmap does not need to be recreated */
if (memcmp(&(pixmap->rect), pixmap->referred_rect, sizeof(Rect)) == 0) if (memcmp(&(pixmap->rect), pixmap->referred_rect, sizeof(Rect)) == 0)
@ -279,11 +280,11 @@ void cached_pixmap_prepare(xcb_connection_t *conn, struct Cached_Pixmap *pixmap)
memcpy(&(pixmap->rect), pixmap->referred_rect, sizeof(Rect)); memcpy(&(pixmap->rect), pixmap->referred_rect, sizeof(Rect));
if (pixmap->id == 0 || pixmap->gc == 0) { if (pixmap->id == 0 || pixmap->gc == 0) {
LOG("Creating new pixmap...\n"); DLOG("Creating new pixmap...\n");
pixmap->id = xcb_generate_id(conn); pixmap->id = xcb_generate_id(conn);
pixmap->gc = xcb_generate_id(conn); pixmap->gc = xcb_generate_id(conn);
} else { } else {
LOG("Re-creating this pixmap...\n"); DLOG("Re-creating this pixmap...\n");
xcb_free_gc(conn, pixmap->gc); xcb_free_gc(conn, pixmap->gc);
xcb_free_pixmap(conn, pixmap->id); xcb_free_pixmap(conn, pixmap->id);
} }

View File

@ -29,6 +29,7 @@
#include "xcb.h" #include "xcb.h"
#include "config.h" #include "config.h"
#include "workspace.h" #include "workspace.h"
#include "log.h"
/* This TAILQ of i3Screens stores the virtual screens, used for handling overlapping screens /* This TAILQ of i3Screens stores the virtual screens, used for handling overlapping screens
* (xrandr --same-as) */ * (xrandr --same-as) */
@ -75,7 +76,7 @@ i3Screen *get_screen_at(int x, int y, struct screens_head *screenlist) {
i3Screen *get_screen_containing(int x, int y) { i3Screen *get_screen_containing(int x, int y) {
i3Screen *screen; i3Screen *screen;
TAILQ_FOREACH(screen, virtual_screens, screens) { TAILQ_FOREACH(screen, virtual_screens, screens) {
LOG("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",
x, y, screen->rect.x, screen->rect.y, screen->rect.width, screen->rect.height); x, y, screen->rect.x, screen->rect.y, screen->rect.width, screen->rect.height);
if (x >= screen->rect.x && x < (screen->rect.x + screen->rect.width) && if (x >= screen->rect.x && x < (screen->rect.x + screen->rect.width) &&
y >= screen->rect.y && y < (screen->rect.y + screen->rect.height)) y >= screen->rect.y && y < (screen->rect.y + screen->rect.height))
@ -149,7 +150,7 @@ static void initialize_screen(xcb_connection_t *conn, i3Screen *screen, Workspac
SLIST_INIT(&(screen->dock_clients)); SLIST_INIT(&(screen->dock_clients));
LOG("that is virtual screen at %d x %d with %d x %d\n", DLOG("that is virtual screen at %d x %d with %d x %d\n",
screen->rect.x, screen->rect.y, screen->rect.width, screen->rect.height); screen->rect.x, screen->rect.y, screen->rect.width, screen->rect.height);
} }
@ -192,7 +193,7 @@ static void query_screens(xcb_connection_t *conn, struct screens_head *screenlis
while ((time(NULL) - before_trying) < 10) { while ((time(NULL) - before_trying) < 10) {
reply = xcb_xinerama_query_screens_reply(conn, xcb_xinerama_query_screens_unchecked(conn), NULL); reply = xcb_xinerama_query_screens_reply(conn, xcb_xinerama_query_screens_unchecked(conn), NULL);
if (!reply) { if (!reply) {
LOG("Couldn't get Xinerama screens\n"); DLOG("Couldn't get Xinerama screens\n");
return; return;
} }
screen_info = xcb_xinerama_query_screens_screen_info(reply); screen_info = xcb_xinerama_query_screens_screen_info(reply);
@ -219,7 +220,7 @@ static void query_screens(xcb_connection_t *conn, struct screens_head *screenlis
num_screens++; num_screens++;
} }
LOG("found Xinerama screen: %d x %d at %d x %d\n", DLOG("found Xinerama screen: %d x %d at %d x %d\n",
screen_info[screen].width, screen_info[screen].height, screen_info[screen].width, screen_info[screen].height,
screen_info[screen].x_org, screen_info[screen].y_org); screen_info[screen].x_org, screen_info[screen].y_org);
} }
@ -227,7 +228,7 @@ static void query_screens(xcb_connection_t *conn, struct screens_head *screenlis
free(reply); free(reply);
if (num_screens == 0) { if (num_screens == 0) {
LOG("No screens found. This is weird. Trying again...\n"); DLOG("No screens found. This is weird. Trying again...\n");
/* Give the scheduler a chance to do something else /* Give the scheduler a chance to do something else
* and dont hog the CPU */ * and dont hog the CPU */
usleep(250); usleep(250);
@ -238,7 +239,7 @@ static void query_screens(xcb_connection_t *conn, struct screens_head *screenlis
} }
if (num_screens == 0) { if (num_screens == 0) {
LOG("No screens found for 10 seconds. Please fix your setup. i3 will exit now.\n"); DLOG("No screens found for 10 seconds. Please fix your setup. i3 will exit now.\n");
exit(0); exit(0);
} }
} }
@ -253,14 +254,14 @@ void initialize_xinerama(xcb_connection_t *conn) {
TAILQ_INIT(virtual_screens); TAILQ_INIT(virtual_screens);
if (!xcb_get_extension_data(conn, &xcb_xinerama_id)->present) { if (!xcb_get_extension_data(conn, &xcb_xinerama_id)->present) {
LOG("Xinerama extension not found, disabling.\n"); DLOG("Xinerama extension not found, disabling.\n");
disable_xinerama(conn); disable_xinerama(conn);
} else { } else {
xcb_xinerama_is_active_reply_t *reply; xcb_xinerama_is_active_reply_t *reply;
reply = xcb_xinerama_is_active_reply(conn, xcb_xinerama_is_active(conn), NULL); reply = xcb_xinerama_is_active_reply(conn, xcb_xinerama_is_active(conn), NULL);
if (reply == NULL || !reply->state) { if (reply == NULL || !reply->state) {
LOG("Xinerama is not active (in your X-Server), disabling.\n"); DLOG("Xinerama is not active (in your X-Server), disabling.\n");
disable_xinerama(conn); disable_xinerama(conn);
} else } else
query_screens(conn, virtual_screens); query_screens(conn, virtual_screens);
@ -291,7 +292,7 @@ void xinerama_requery_screens(xcb_connection_t *conn) {
it change when I move the --right-of video projector to --left-of? */ it change when I move the --right-of video projector to --left-of? */
if (!xinerama_enabled) { if (!xinerama_enabled) {
LOG("Xinerama is disabled\n"); DLOG("Xinerama is disabled\n");
return; return;
} }
@ -319,21 +320,21 @@ void xinerama_requery_screens(xcb_connection_t *conn) {
if (old_screen->num != screen_count) if (old_screen->num != screen_count)
continue; continue;
LOG("Found a matching screen\n"); DLOG("Found a matching screen\n");
/* Use the same workspace */ /* Use the same workspace */
screen->current_workspace = old_screen->current_workspace; screen->current_workspace = old_screen->current_workspace;
/* Re-use the old bar window */ /* Re-use the old bar window */
screen->bar = old_screen->bar; screen->bar = old_screen->bar;
screen->bargc = old_screen->bargc; screen->bargc = old_screen->bargc;
LOG("old_screen->bar = %p\n", old_screen->bar); DLOG("old_screen->bar = %p\n", old_screen->bar);
Rect bar_rect = {screen->rect.x, Rect bar_rect = {screen->rect.x,
screen->rect.y + screen->rect.height - (font->height + 6), screen->rect.y + screen->rect.height - (font->height + 6),
screen->rect.x + screen->rect.width, screen->rect.x + screen->rect.width,
font->height + 6}; font->height + 6};
LOG("configuring bar to be at %d x %d with %d x %d\n", DLOG("configuring bar to be at %d x %d with %d x %d\n",
bar_rect.x, bar_rect.y, bar_rect.height, bar_rect.width); bar_rect.x, bar_rect.y, bar_rect.height, bar_rect.width);
xcb_configure_window(conn, screen->bar, XCB_CONFIG_WINDOW_X | xcb_configure_window(conn, screen->bar, XCB_CONFIG_WINDOW_X |
XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_Y |
@ -350,7 +351,7 @@ void xinerama_requery_screens(xcb_connection_t *conn) {
if (ws->screen != old_screen) if (ws->screen != old_screen)
continue; continue;
LOG("re-assigning ws %d\n", ws->num); DLOG("re-assigning ws %d\n", ws->num);
memcpy(&(ws->rect), &(screen->rect), sizeof(Rect)); memcpy(&(ws->rect), &(screen->rect), sizeof(Rect));
ws->screen = screen; ws->screen = screen;
ws->reassigned = true; ws->reassigned = true;
@ -362,7 +363,7 @@ void xinerama_requery_screens(xcb_connection_t *conn) {
/* Find the first unused workspace, preferring the ones /* Find the first unused workspace, preferring the ones
* which are assigned to this screen and initialize * which are assigned to this screen and initialize
* the screen with it. */ * the screen with it. */
LOG("getting first ws for screen %p\n", screen); DLOG("getting first ws for screen %p\n", screen);
Workspace *ws = get_first_workspace_for_screen(new_screens, screen); Workspace *ws = get_first_workspace_for_screen(new_screens, screen);
initialize_screen(conn, screen, ws); initialize_screen(conn, screen, ws);
ws->reassigned = true; ws->reassigned = true;
@ -379,7 +380,7 @@ void xinerama_requery_screens(xcb_connection_t *conn) {
if (SLIST_EMPTY(&(old_screen->dock_clients))) if (SLIST_EMPTY(&(old_screen->dock_clients)))
continue; continue;
LOG("dock_clients out of bounds at screen %p, reassigning\n", old_screen); DLOG("dock_clients out of bounds at screen %p, reassigning\n", old_screen);
if (SLIST_EMPTY(&(first->dock_clients))) { if (SLIST_EMPTY(&(first->dock_clients))) {
first->dock_clients = old_screen->dock_clients; first->dock_clients = old_screen->dock_clients;
continue; continue;
@ -402,10 +403,10 @@ void xinerama_requery_screens(xcb_connection_t *conn) {
Client *client; Client *client;
LOG("Closing bar window (%p)\n", ws->screen->bar); DLOG("Closing bar window (%p)\n", ws->screen->bar);
xcb_destroy_window(conn, ws->screen->bar); xcb_destroy_window(conn, ws->screen->bar);
LOG("Workspace %d's screen out of bounds, assigning to first screen\n", ws->num + 1); DLOG("Workspace %d's screen out of bounds, assigning to first screen\n", ws->num + 1);
ws->screen = first; ws->screen = first;
memcpy(&(ws->rect), &(first->rect), sizeof(Rect)); memcpy(&(ws->rect), &(first->rect), sizeof(Rect));
@ -424,7 +425,7 @@ void xinerama_requery_screens(xcb_connection_t *conn) {
workspace_unmap_clients(conn, ws); workspace_unmap_clients(conn, ws);
if (c_ws == ws) { if (c_ws == ws) {
LOG("Need to adjust c_ws...\n"); DLOG("Need to adjust c_ws...\n");
c_ws = first->current_workspace; c_ws = first->current_workspace;
} }
} }
@ -440,7 +441,7 @@ void xinerama_requery_screens(xcb_connection_t *conn) {
virtual_screens = new_screens; virtual_screens = new_screens;
LOG("Current workspace is now: %d\n", first->current_workspace); DLOG("Current workspace is now: %d\n", first->current_workspace);
render_layout(conn); render_layout(conn);
} }