Implement slog() and the LOG() macro, convert printf() to LOG()

This commit is contained in:
Michael Stapelberg 2009-03-06 06:46:43 +01:00
parent 0831f3e129
commit 96ac9f9066
9 changed files with 175 additions and 148 deletions

View File

@ -20,10 +20,14 @@
CIRCLEQ_NEXT(elm, field) : NULL)
#define CIRCLEQ_PREV_OR_NULL(head, elm, field) (CIRCLEQ_PREV(elm, field) != CIRCLEQ_END(head) ? \
CIRCLEQ_PREV(elm, field) : NULL)
/* ##__VA_ARGS__ means: leave out __VA_ARGS__ completely if it is empty, that is,
delete the preceding comma */
#define LOG(fmt, ...) slog("%s:%d - " fmt, __FILE__, __LINE__, ##__VA_ARGS__)
int min(int a, int b);
int max(int a, int b);
void slog(char *fmt, ...);
void die(char *fmt, ...);
void *smalloc(size_t size);
void *scalloc(size_t size);

View File

@ -39,7 +39,7 @@ static bool focus_window_in_container(xcb_connection_t *conn, Container *contain
else if (direction == D_DOWN) {
if ((candidate = CIRCLEQ_NEXT_OR_NULL(&(container->clients), container->currently_focused, clients)) == NULL)
candidate = CIRCLEQ_FIRST(&(container->clients));
} else printf("Direction not implemented!\n");
} else LOG("Direction not implemented!\n");
/* If we could not switch, the container contains exactly one client. We return false */
if (candidate == container->currently_focused)
@ -54,7 +54,7 @@ static bool focus_window_in_container(xcb_connection_t *conn, Container *contain
typedef enum { THING_WINDOW, THING_CONTAINER } thing_t;
static void focus_thing(xcb_connection_t *conn, direction_t direction, thing_t thing) {
printf("focusing direction %d\n", direction);
LOG("focusing direction %d\n", direction);
int new_row = current_row,
new_col = current_col;
@ -78,11 +78,11 @@ static void focus_thing(xcb_connection_t *conn, direction_t direction, thing_t t
new_row--;
else {
/* Lets see if there is a screen down/up there to which we can switch */
printf("container is at %d with height %d\n", container->y, container->height);
LOG("container is at %d with height %d\n", container->y, container->height);
i3Screen *screen;
int destination_y = (direction == D_UP ? (container->y - 1) : (container->y + container->height + 1));
if ((screen = get_screen_containing(container->x, destination_y)) == NULL) {
printf("Not possible, no screen found.\n");
LOG("Not possible, no screen found.\n");
return;
}
t_ws = &(workspaces[screen->current_workspace]);
@ -100,11 +100,11 @@ static void focus_thing(xcb_connection_t *conn, direction_t direction, thing_t t
new_col--;
else {
/* Lets see if there is a screen left/right here to which we can switch */
printf("container is at %d with width %d\n", container->x, container->width);
LOG("container is at %d with width %d\n", container->x, container->width);
i3Screen *screen;
int destination_x = (direction == D_LEFT ? (container->x - 1) : (container->x + container->width + 1));
if ((screen = get_screen_containing(destination_x, container->y)) == NULL) {
printf("Not possible, no screen found.\n");
LOG("Not possible, no screen found.\n");
return;
}
t_ws = &(workspaces[screen->current_workspace]);
@ -116,7 +116,7 @@ static void focus_thing(xcb_connection_t *conn, direction_t direction, thing_t t
new_row = (t_ws->rows - 1);
}
} else {
printf("direction unhandled\n");
LOG("direction unhandled\n");
return;
}
@ -140,7 +140,7 @@ static bool move_current_window_in_container(xcb_connection_t *conn, Client *cli
if (other == CIRCLEQ_END(&(client->container->clients)))
return false;
printf("i can do that\n");
LOG("i can do that\n");
/* We can move the client inside its current container */
/* TODO: needs wrapping */
CIRCLEQ_REMOVE(&(client->container->clients), client, clients);
@ -157,7 +157,7 @@ static bool move_current_window_in_container(xcb_connection_t *conn, Client *cli
*
*/
static void move_current_window(xcb_connection_t *conn, direction_t direction) {
printf("moving window to direction %s\n", (direction == D_UP ? "up" : (direction == D_DOWN ? "down" :
LOG("moving window to direction %s\n", (direction == D_UP ? "up" : (direction == D_DOWN ? "down" :
(direction == D_LEFT ? "left" : "right"))));
/* Get current window */
Container *container = CUR_CELL,
@ -237,7 +237,7 @@ static void move_current_window(xcb_connection_t *conn, direction_t direction) {
*
*/
static void snap_current_container(xcb_connection_t *conn, direction_t direction) {
printf("snapping container to direction %d\n", direction);
LOG("snapping container to direction %d\n", direction);
Container *container = CUR_CELL;
@ -248,7 +248,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 */
if (!cell_exists(container->col - 1, container->row) ||
CUR_TABLE[container->col-1][container->row]->currently_focused != NULL) {
printf("cannot snap to left - the cell is already used\n");
LOG("cannot snap to left - the cell is already used\n");
return;
}
@ -260,18 +260,18 @@ static void snap_current_container(xcb_connection_t *conn, direction_t direction
int new_col = container->col + container->colspan;
if (!cell_exists(new_col, container->row) ||
CUR_TABLE[new_col][container->row]->currently_focused != NULL) {
printf("cannot snap to right - the cell is already used\n");
LOG("cannot snap to right - the cell is already used\n");
return;
}
/* Check if there are other cells with rowspan, which are in our way.
* If so, reduce their rowspan. */
for (int i = container->row-1; i >= 0; i--) {
printf("we got cell %d, %d with rowspan %d\n",
LOG("we got cell %d, %d with rowspan %d\n",
new_col, i, CUR_TABLE[new_col][i]->rowspan);
while ((CUR_TABLE[new_col][i]->rowspan-1) >= (container->row - i))
CUR_TABLE[new_col][i]->rowspan--;
printf("new rowspan = %d\n", CUR_TABLE[new_col][i]->rowspan);
LOG("new rowspan = %d\n", CUR_TABLE[new_col][i]->rowspan);
}
container->colspan++;
@ -280,7 +280,7 @@ static void snap_current_container(xcb_connection_t *conn, direction_t direction
case D_UP:
if (!cell_exists(container->col, container->row - 1) ||
CUR_TABLE[container->col][container->row-1]->currently_focused != NULL) {
printf("cannot snap to top - the cell is already used\n");
LOG("cannot snap to top - the cell is already used\n");
return;
}
@ -288,20 +288,20 @@ static void snap_current_container(xcb_connection_t *conn, direction_t direction
snap_current_container(conn, D_DOWN);
return;
case D_DOWN: {
printf("snapping down\n");
LOG("snapping down\n");
int new_row = container->row + container->rowspan;
if (!cell_exists(container->col, new_row) ||
CUR_TABLE[container->col][new_row]->currently_focused != NULL) {
printf("cannot snap down - the cell is already used\n");
LOG("cannot snap down - the cell is already used\n");
return;
}
for (int i = container->col-1; i >= 0; i--) {
printf("we got cell %d, %d with colspan %d\n",
LOG("we got cell %d, %d with colspan %d\n",
i, new_row, CUR_TABLE[i][new_row]->colspan);
while ((CUR_TABLE[i][new_row]->colspan-1) >= (container->col - i))
CUR_TABLE[i][new_row]->colspan--;
printf("new colspan = %d\n", CUR_TABLE[i][new_row]->colspan);
LOG("new colspan = %d\n", CUR_TABLE[i][new_row]->colspan);
}
@ -318,7 +318,7 @@ static void snap_current_container(xcb_connection_t *conn, direction_t direction
*
*/
static void move_current_window_to_workspace(xcb_connection_t *conn, int workspace) {
printf("Moving current window to workspace %d\n", workspace);
LOG("Moving current window to workspace %d\n", workspace);
Container *container = CUR_CELL;
@ -329,7 +329,7 @@ static void move_current_window_to_workspace(xcb_connection_t *conn, int workspa
Client *current_client = container->currently_focused;
if (current_client == NULL) {
printf("No currently focused client in current container.\n");
LOG("No currently focused client in current container.\n");
return;
}
Client *to_focus = CIRCLEQ_NEXT_OR_NULL(&(container->clients), current_client, clients);
@ -337,7 +337,7 @@ static void move_current_window_to_workspace(xcb_connection_t *conn, int workspa
to_focus = CIRCLEQ_PREV_OR_NULL(&(container->clients), current_client, clients);
if (t_ws->screen == NULL) {
printf("initializing new workspace, setting num to %d\n", workspace-1);
LOG("initializing new workspace, setting num to %d\n", workspace-1);
t_ws->screen = container->workspace->screen;
/* Copy the dimensions from the virtual screen */
memcpy(&(t_ws->rect), &(container->workspace->screen->rect), sizeof(Rect));
@ -352,7 +352,7 @@ static void move_current_window_to_workspace(xcb_connection_t *conn, int workspa
CIRCLEQ_INSERT_TAIL(&(to_container->clients), current_client, clients);
SLIST_INSERT_HEAD(&(to_container->workspace->focus_stack), current_client, focus_clients);
printf("Moved.\n");
LOG("Moved.\n");
current_client->container = to_container;
container->currently_focused = to_focus;
@ -360,7 +360,7 @@ 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 (to_container->workspace->screen->current_workspace != to_container->workspace->num) {
printf("This workspace is not visible, unmapping\n");
LOG("This workspace is not visible, unmapping\n");
xcb_unmap_window(conn, current_client->frame);
}
@ -376,7 +376,7 @@ static void show_workspace(xcb_connection_t *conn, int workspace) {
/* t_ws (to workspace) is just a convenience pointer to the workspace were switching to */
Workspace *t_ws = &(workspaces[workspace-1]);
printf("show_workspace(%d)\n", workspace);
LOG("show_workspace(%d)\n", workspace);
/* Store current_row/current_col */
c_ws->current_row = current_row;
@ -384,7 +384,7 @@ static void show_workspace(xcb_connection_t *conn, int workspace) {
/* Check if the workspace has not been used yet */
if (t_ws->screen == NULL) {
printf("initializing new workspace, setting num to %d\n", workspace);
LOG("initializing new workspace, setting num to %d\n", workspace);
t_ws->screen = c_ws->screen;
/* Copy the dimensions from the virtual screen */
memcpy(&(t_ws->rect), &(t_ws->screen->rect), sizeof(Rect));
@ -392,7 +392,7 @@ static void show_workspace(xcb_connection_t *conn, int workspace) {
if (c_ws->screen != t_ws->screen) {
/* We need to switch to the other screen first */
printf("moving over to other screen.\n");
LOG("moving over to other screen.\n");
c_ws = &(workspaces[t_ws->screen->current_workspace]);
current_col = c_ws->current_col;
current_row = c_ws->current_row;
@ -436,7 +436,7 @@ static void show_workspace(xcb_connection_t *conn, int workspace) {
c_ws = &workspaces[workspace-1];
current_row = c_ws->current_row;
current_col = c_ws->current_col;
printf("new current row = %d, current col = %d\n", current_row, current_col);
LOG("new current row = %d, current col = %d\n", current_row, current_col);
/* Map all clients on the new workspace */
for (int cols = 0; cols < c_ws->cols; cols++)
@ -464,21 +464,21 @@ static void show_workspace(xcb_connection_t *conn, int workspace) {
*
*/
void parse_command(xcb_connection_t *conn, const char *command) {
printf("--- parsing command \"%s\" ---\n", command);
LOG("--- parsing command \"%s\" ---\n", command);
/* Hmm, just to be sure */
if (command[0] == '\0')
return;
/* Is it an <exec>? */
if (strncmp(command, "exec ", strlen("exec ")) == 0) {
printf("starting \"%s\"\n", command + strlen("exec "));
LOG("starting \"%s\"\n", command + strlen("exec "));
start_application(command+strlen("exec "));
return;
}
/* Is it <restart>? */
if (strncmp(command, "restart", strlen("restart")) == 0) {
printf("restarting \"%s\"...\n", application_path);
LOG("restarting \"%s\"...\n", application_path);
execl(application_path, application_path, NULL);
/* not reached */
}
@ -493,7 +493,7 @@ void parse_command(xcb_connection_t *conn, const char *command) {
/* Is it just 's' for stacking or 'd' for default? */
if ((command[0] == 's' || command[0] == 'd') && (command[1] == '\0')) {
printf("Switching mode for current container\n");
LOG("Switching mode for current container\n");
switch_layout_mode(conn, CUR_CELL, (command[0] == 's' ? MODE_STACK : MODE_DEFAULT));
return;
}
@ -508,7 +508,7 @@ void parse_command(xcb_connection_t *conn, const char *command) {
with = WITH_CONTAINER;
command++;
} else {
printf("not yet implemented.\n");
LOG("not yet implemented.\n");
return;
}
}
@ -519,7 +519,7 @@ void parse_command(xcb_connection_t *conn, const char *command) {
direction_t direction;
int times = strtol(command, &rest, 10);
if (rest == NULL) {
printf("Invalid command (\"%s\")\n", command);
LOG("Invalid command (\"%s\")\n", command);
return;
}
@ -537,7 +537,7 @@ void parse_command(xcb_connection_t *conn, const char *command) {
int workspace = strtol(rest, &rest, 10);
if (rest == NULL) {
printf("Invalid command (\"%s\")\n", command);
LOG("Invalid command (\"%s\")\n", command);
return;
}
@ -557,7 +557,7 @@ void parse_command(xcb_connection_t *conn, const char *command) {
else if (*rest == 'l')
direction = D_RIGHT;
else {
printf("unknown direction: %c\n", *rest);
LOG("unknown direction: %c\n", *rest);
return;
}
@ -572,5 +572,5 @@ void parse_command(xcb_connection_t *conn, const char *command) {
rest++;
}
printf("--- done ---\n");
LOG("--- done ---\n");
}

View File

@ -115,7 +115,7 @@ void load_configuration(const char *override_configpath) {
if (!rest || *rest != ' ')
die("Invalid binding\n");
rest++;
printf("keycode = %d, modifiers = %d, command = *%s*\n", keycode, modifiers, rest);
LOG("keycode = %d, modifiers = %d, command = *%s*\n", keycode, modifiers, rest);
Binding *new = smalloc(sizeof(Binding));
new->keycode = keycode;
new->mods = modifiers;

View File

@ -40,7 +40,7 @@ int ignore_notify_event = -1;
*
*/
int handle_key_release(void *ignored, xcb_connection_t *conn, xcb_key_release_event_t *event) {
printf("got key release, just passing\n");
LOG("got key release, just passing\n");
xcb_allow_events(conn, XCB_ALLOW_REPLAY_KEYBOARD, event->time);
xcb_flush(conn);
return 1;
@ -52,7 +52,7 @@ 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) {
printf("Keypress %d\n", event->detail);
LOG("Keypress %d\n", event->detail);
/* We need to get the keysym group (There are group 1 to group 4, each holding
two keysyms (without shift and with shift) using Xkb because X fails to
@ -61,7 +61,7 @@ int handle_key_press(void *ignored, xcb_connection_t *conn, xcb_key_press_event_
if (XkbGetState(xkbdpy, XkbUseCoreKbd, &state) == Success && (state.group+1) == 2)
event->state |= 0x2;
printf("state %d\n", event->state);
LOG("state %d\n", event->state);
/* Remove the numlock bit, all other bits are modifiers we can bind to */
uint16_t state_filtered = event->state & ~XCB_MOD_MASK_LOCK;
@ -82,7 +82,7 @@ int handle_key_press(void *ignored, xcb_connection_t *conn, xcb_key_press_event_
parse_command(conn, bind->command);
if (event->state & 0x2) {
printf("Mode_switch -> allow_events(SyncKeyboard)\n");
LOG("Mode_switch -> allow_events(SyncKeyboard)\n");
xcb_allow_events(conn, SyncKeyboard, event->time);
xcb_flush(conn);
}
@ -95,11 +95,11 @@ int handle_key_press(void *ignored, xcb_connection_t *conn, xcb_key_press_event_
*
*/
int handle_enter_notify(void *ignored, xcb_connection_t *conn, xcb_enter_notify_event_t *event) {
printf("enter_notify for %08x, serial %d\n", event->event, event->sequence);
LOG("enter_notify for %08x, serial %d\n", event->event, event->sequence);
/* Some events are not interesting, because they were not generated actively by the
user, but be reconfiguration of windows */
if (event->sequence == ignore_notify_event) {
printf("Ignoring, because of previous map\n");
LOG("Ignoring, because of previous map\n");
return 1;
}
@ -111,14 +111,14 @@ 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 (client == NULL) {
printf("Getting screen at %d x %d\n", event->root_x, event->root_y);
LOG("Getting screen at %d x %d\n", event->root_x, event->root_y);
i3Screen *screen = get_screen_containing(event->root_x, event->root_y);
if (screen == NULL) {
printf("ERROR: No such screen\n");
LOG("ERROR: No such screen\n");
return 0;
}
c_ws = &workspaces[screen->current_workspace];
printf("We're now on virtual screen number %d\n", screen->num);
LOG("We're now on virtual screen number %d\n", screen->num);
return 1;
}
@ -128,7 +128,7 @@ int handle_enter_notify(void *ignored, xcb_connection_t *conn, xcb_enter_notify_
}
int handle_button_press(void *ignored, xcb_connection_t *conn, xcb_button_press_event_t *event) {
printf("button press!\n");
LOG("button press!\n");
/* This was either a focus for a clients parent (= titlebar)… */
Client *client = table_get(byChild, event->event);
bool border_click = false;
@ -150,7 +150,7 @@ int handle_button_press(void *ignored, xcb_connection_t *conn, xcb_button_press_
c = 0;
Client *client;
printf("Click on stack_win for client %d\n", destination);
LOG("Click on stack_win for client %d\n", destination);
CIRCLEQ_FOREACH(client, &(stack_win->container->clients), clients)
if (c++ == destination) {
set_focus(conn, client);
@ -170,7 +170,7 @@ int handle_button_press(void *ignored, xcb_connection_t *conn, xcb_button_press_
set_focus(conn, client);
/* Lets see if this was on the borders (= resize). If not, were done */
printf("press button on x=%d, y=%d\n", event->event_x, event->event_y);
LOG("press button on x=%d, y=%d\n", event->event_x, event->event_y);
Container *con = client->container,
*first = NULL,
@ -178,16 +178,16 @@ int handle_button_press(void *ignored, xcb_connection_t *conn, xcb_button_press_
enum { O_HORIZONTAL, O_VERTICAL } orientation = O_VERTICAL;
if (con == NULL) {
printf("dock. done.\n");
LOG("dock. done.\n");
xcb_allow_events(conn, XCB_ALLOW_REPLAY_POINTER, event->time);
xcb_flush(conn);
return 1;
}
printf("event->event_x = %d, client->rect.width = %d\n", event->event_x, client->rect.width);
LOG("event->event_x = %d, client->rect.width = %d\n", event->event_x, client->rect.width);
if (!border_click) {
printf("client. done.\n");
LOG("client. done.\n");
xcb_allow_events(conn, XCB_ALLOW_REPLAY_POINTER, event->time);
xcb_flush(conn);
return 1;
@ -290,7 +290,7 @@ int handle_button_press(void *ignored, xcb_connection_t *conn, xcb_button_press_
xcb_event_handle(&evenths, inside_event);
break;
default:
printf("Ignoring event of type %d\n", nr);
LOG("Ignoring event of type %d\n", nr);
break;
}
free(inside_event);
@ -303,7 +303,7 @@ int handle_button_press(void *ignored, xcb_connection_t *conn, xcb_button_press_
Workspace *ws = con->workspace;
if (orientation == O_VERTICAL) {
printf("Resize was from X = %d to X = %d\n", event->root_x, values[0]);
LOG("Resize was from X = %d to X = %d\n", event->root_x, values[0]);
/* Convert 0 (for default width_factor) to actual numbers */
if (first->width_factor == 0)
@ -314,7 +314,7 @@ int handle_button_press(void *ignored, xcb_connection_t *conn, xcb_button_press_
first->width_factor *= (float)(first->width + (values[0] - event->root_x)) / first->width;
second->width_factor *= (float)(second->width - (values[0] - event->root_x)) / second->width;
} else {
printf("Resize was from Y = %d to Y = %d\n", event->root_y, values[0]);
LOG("Resize was from Y = %d to Y = %d\n", event->root_y, values[0]);
/* Convert 0 (for default height_factor) to actual numbers */
if (first->height_factor == 0)
@ -338,8 +338,8 @@ int handle_button_press(void *ignored, xcb_connection_t *conn, xcb_button_press_
int handle_map_notify_event(void *prophs, xcb_connection_t *conn, xcb_map_notify_event_t *event) {
window_attributes_t wa = { TAG_VALUE };
wa.u.override_redirect = event->override_redirect;
printf("MapNotify for 0x%08x, serial is %d.\n", event->window, event->sequence);
printf("setting ignore_notify_event = %d\n", event->sequence);
LOG("MapNotify for 0x%08x, serial is %d.\n", event->window, event->sequence);
LOG("setting ignore_notify_event = %d\n", event->sequence);
ignore_notify_event = event->sequence;
manage_window(prophs, conn, event->window, wa);
return 1;
@ -353,15 +353,15 @@ int handle_map_notify_event(void *prophs, xcb_connection_t *conn, xcb_map_notify
int handle_configure_event(void *prophs, xcb_connection_t *conn, xcb_configure_notify_event_t *event) {
xcb_window_t root = xcb_setup_roots_iterator(xcb_get_setup(conn)).data->root;
printf("handle_configure_event\n");
printf("event->type = %d, \n", event->response_type);
printf("event->x = %d, ->y = %d, ->width = %d, ->height = %d\n", event->x, event->y, event->width, event->height);
printf("sequence = %d\n", event->sequence);
LOG("handle_configure_event\n");
LOG("event->type = %d, \n", event->response_type);
LOG("event->x = %d, ->y = %d, ->width = %d, ->height = %d\n", event->x, event->y, event->width, event->height);
LOG("sequence = %d\n", event->sequence);
ignore_notify_event = event->sequence;
if (event->event == root) {
printf("reconfigure of the root window, need to xinerama\n");
LOG("reconfigure of the root window, need to xinerama\n");
/* FIXME: Somehow, this is occuring too often. Therefore, we check for 0/0,
but is there a better way? */
if (event->x == 0 && event->y == 0)
@ -371,12 +371,12 @@ int handle_configure_event(void *prophs, xcb_connection_t *conn, xcb_configure_n
Client *client = table_get(byChild, event->window);
if (client == NULL) {
printf("client not managed, ignoring\n");
LOG("client not managed, ignoring\n");
return 1;
}
if (client->fullscreen) {
printf("client in fullscreen, not touching\n");
LOG("client in fullscreen, not touching\n");
return 1;
}
@ -386,7 +386,7 @@ int handle_configure_event(void *prophs, xcb_connection_t *conn, xcb_configure_n
(event->width != client->child_rect.width) ||
(event->height != client->child_rect.height)) {
/* Who is your window manager? Whos that, huh? I AM YOUR WINDOW MANAGER! */
printf("Application wanted to resize itself. Fixed that.\n");
LOG("Application wanted to resize itself. Fixed that.\n");
client->force_reconfigure = true;
render_container(conn, client->container);
xcb_flush(conn);
@ -403,7 +403,7 @@ int handle_configure_event(void *prophs, xcb_connection_t *conn, xcb_configure_n
int handle_unmap_notify_event(void *data, xcb_connection_t *conn, xcb_unmap_notify_event_t *event) {
xcb_window_t root = xcb_setup_roots_iterator(xcb_get_setup(conn)).data->root;
printf("setting ignore_notify_event = %d\n", event->sequence);
LOG("setting ignore_notify_event = %d\n", event->sequence);
ignore_notify_event = event->sequence;
@ -411,15 +411,15 @@ int handle_unmap_notify_event(void *data, xcb_connection_t *conn, xcb_unmap_noti
/* First, we need to check if the client is awaiting an unmap-request which
was generated by us reparenting the window. In that case, we just ignore it. */
if (client != NULL && client->awaiting_useless_unmap) {
printf("Dropping this unmap request, it was generated by reparenting\n");
LOG("Dropping this unmap request, it was generated by reparenting\n");
client->awaiting_useless_unmap = false;
return 1;
}
client = table_remove(byChild, event->window);
printf("UnmapNotify for 0x%08x (received from 0x%08x): ", event->window, event->event);
LOG("UnmapNotify for 0x%08x (received from 0x%08x): ", event->window, event->event);
if (client == NULL) {
printf("not a managed window. Ignoring.\n");
LOG("not a managed window. Ignoring.\n");
return 0;
}
@ -445,7 +445,7 @@ int handle_unmap_notify_event(void *data, xcb_connection_t *conn, xcb_unmap_noti
CIRCLEQ_REMOVE(&(con->clients), client, clients);
/* Remove from the focus stack */
printf("Removing from focus stack\n");
LOG("Removing from focus stack\n");
SLIST_REMOVE(&(con->workspace->focus_stack), client, Client, focus_clients);
/* Set currently_focused to the next client which will get focus in this
@ -464,7 +464,7 @@ int handle_unmap_notify_event(void *data, xcb_connection_t *conn, xcb_unmap_noti
set_focus(conn, SLIST_FIRST(&(con->workspace->focus_stack)));
}
printf("child of 0x%08x.\n", client->frame);
LOG("child of 0x%08x.\n", client->frame);
xcb_reparent_window(conn, client->child, root, 0, 0);
xcb_destroy_window(conn, client->frame);
xcb_flush(conn);
@ -485,7 +485,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,
xcb_window_t window, xcb_atom_t atom, xcb_get_property_reply_t *prop) {
printf("window's name changed.\n");
LOG("window's name changed.\n");
Client *client = table_get(byChild, window);
if (client == NULL)
return 1;
@ -496,7 +496,7 @@ int handle_windowname_change(void *data, xcb_connection_t *conn, uint8_t state,
client->name_len = xcb_get_property_value_length(prop);
client->name = smalloc(client->name_len);
strncpy(client->name, xcb_get_property_value(prop), client->name_len);
printf("rename to \"%.*s\".\n", client->name_len, client->name);
LOG("rename to \"%.*s\".\n", client->name_len, client->name);
if (client->container->mode == MODE_STACK)
render_container(conn, client->container);
@ -529,7 +529,7 @@ int handle_expose_event(void *data, xcb_connection_t *conn, xcb_expose_event_t *
return 1;
}
printf("handle_expose_event()\n");
LOG("handle_expose_event()\n");
if (client->container->mode != MODE_STACK)
decorate_window(conn, client, client->frame, client->titlegc, 0);
else {
@ -566,13 +566,13 @@ int handle_expose_event(void *data, xcb_connection_t *conn, xcb_expose_event_t *
*
*/
int handle_client_message(void *data, xcb_connection_t *conn, xcb_client_message_event_t *event) {
printf("client_message\n");
LOG("client_message\n");
if (event->type == atoms[_NET_WM_STATE]) {
if (event->format != 32 || event->data.data32[1] != atoms[_NET_WM_STATE_FULLSCREEN])
return 0;
printf("fullscreen\n");
LOG("fullscreen\n");
Client *client = table_get(byChild, event->window);
if (client == NULL)
@ -587,7 +587,7 @@ int handle_client_message(void *data, xcb_connection_t *conn, xcb_client_message
event->data.data32[0] == _NET_WM_STATE_TOGGLE)))
toggle_fullscreen(conn, client);
} else {
printf("unhandled clientmessage\n");
LOG("unhandled clientmessage\n");
return 0;
}
@ -598,7 +598,7 @@ int window_type_handler(void *data, xcb_connection_t *conn, uint8_t state, xcb_w
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
before changing this property. */
printf("_NET_WM_WINDOW_TYPE changed, this is not yet implemented.\n");
LOG("_NET_WM_WINDOW_TYPE changed, this is not yet implemented.\n");
return 0;
}
@ -611,10 +611,10 @@ int window_type_handler(void *data, xcb_connection_t *conn, uint8_t state, xcb_w
*/
int handle_normal_hints(void *data, xcb_connection_t *conn, uint8_t state, xcb_window_t window,
xcb_atom_t name, xcb_get_property_reply_t *reply) {
printf("handle_normal_hints\n");
LOG("handle_normal_hints\n");
Client *client = table_get(byChild, window);
if (client == NULL) {
printf("No such client\n");
LOG("No such client\n");
return;
}
xcb_size_hints_t size_hints;
@ -629,11 +629,11 @@ int handle_normal_hints(void *data, xcb_connection_t *conn, uint8_t state, xcb_w
if (!(size_hints.flags & XCB_SIZE_HINT_P_ASPECT) ||
(size_hints.min_aspect_num <= 0) ||
(size_hints.min_aspect_den <= 0)) {
printf("No aspect ratio set, ignoring\n");
LOG("No aspect ratio set, ignoring\n");
return;
}
printf("window is %08x / %s\n", client->child, client->name);
LOG("window is %08x / %s\n", client->child, client->name);
int base_width = 0, base_height = 0,
min_width = 0, min_height = 0;
@ -663,8 +663,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 max_aspect = (double)size_hints.max_aspect_num / size_hints.min_aspect_den;
printf("min_aspect = %f, max_aspect = %f\n", min_aspect, max_aspect);
printf("width = %f, height = %f\n", width, height);
LOG("min_aspect = %f, max_aspect = %f\n", min_aspect, max_aspect);
LOG("width = %f, height = %f\n", width, height);
/* Sanity checks, this is user-input, in a way */
if (max_aspect <= 0 || min_aspect <= 0 || height == 0 || (width / height) <= 0)

View File

@ -45,11 +45,11 @@ int get_unoccupied_x(Workspace *workspace, int row) {
int unoccupied = workspace->rect.width;
float default_factor = ((float)workspace->rect.width / workspace->cols) / workspace->rect.width;
printf("get_unoccupied_x(), starting with %d, default_factor = %f\n", unoccupied, default_factor);
LOG("get_unoccupied_x(), starting with %d, default_factor = %f\n", unoccupied, default_factor);
for (int cols = 0; cols < workspace->cols;) {
Container *con = workspace->table[cols][row];
printf("width_factor[%d][%d] = %f, colspan = %d\n", cols, row, con->width_factor, con->colspan);
LOG("width_factor[%d][%d] = %f, colspan = %d\n", cols, row, con->width_factor, con->colspan);
if (con->width_factor == 0)
unoccupied -= workspace->rect.width * default_factor * con->colspan;
cols += con->colspan;
@ -57,7 +57,7 @@ int get_unoccupied_x(Workspace *workspace, int row) {
assert(unoccupied != 0);
printf("unoccupied space: %d\n", unoccupied);
LOG("unoccupied space: %d\n", unoccupied);
return unoccupied;
}
@ -66,11 +66,11 @@ int get_unoccupied_y(Workspace *workspace, int col) {
int unoccupied = workspace->rect.height;
float default_factor = ((float)workspace->rect.height / workspace->rows) / workspace->rect.height;
printf("get_unoccupied_y(), starting with %d, default_factor = %f\n", unoccupied, default_factor);
LOG("get_unoccupied_y(), starting with %d, default_factor = %f\n", unoccupied, default_factor);
for (int rows = 0; rows < workspace->rows;) {
Container *con = workspace->table[col][rows];
printf("height_factor[%d][%d] = %f, rowspan %d\n", col, rows, con->height_factor, con->rowspan);
LOG("height_factor[%d][%d] = %f, rowspan %d\n", col, rows, con->height_factor, con->rowspan);
if (con->height_factor == 0)
unoccupied -= workspace->rect.height * default_factor * con->rowspan;
rows += con->rowspan;
@ -78,7 +78,7 @@ int get_unoccupied_y(Workspace *workspace, int col) {
assert(unoccupied != 0);
printf("unoccupied space: %d\n", unoccupied);
LOG("unoccupied space: %d\n", unoccupied);
return unoccupied;
}
@ -179,7 +179,7 @@ void decorate_window(xcb_connection_t *conn, Client *client, xcb_drawable_t draw
*
*/
static void reposition_client(xcb_connection_t *conn, Client *client) {
printf("frame needs to be pushed to %dx%d\n", client->rect.x, client->rect.y);
LOG("frame needs to be pushed to %dx%d\n", client->rect.x, client->rect.y);
/* Note: We can use a pointer to client->x like an array of uint32_ts
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));
@ -192,7 +192,7 @@ static void reposition_client(xcb_connection_t *conn, Client *client) {
static void resize_client(xcb_connection_t *conn, Client *client) {
i3Font *font = load_font(conn, config.font);
printf("resizing client to %d x %d\n", client->rect.width, client->rect.height);
LOG("resizing client to %d x %d\n", client->rect.width, client->rect.height);
xcb_configure_window(conn, client->frame,
XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT,
&(client->rect.width));
@ -230,7 +230,7 @@ static void resize_client(xcb_connection_t *conn, Client *client) {
/* Obey the ratio, if any */
if (client->proportional_height != 0 &&
client->proportional_width != 0) {
printf("proportional height = %d, width = %d\n", client->proportional_height, client->proportional_width);
LOG("proportional height = %d, width = %d\n", client->proportional_height, client->proportional_width);
double new_height = rect->height + 1;
int new_width = rect->width;
@ -246,10 +246,10 @@ static void resize_client(xcb_connection_t *conn, Client *client) {
rect->height = new_height;
rect->width = new_width;
printf("new_height = %f, new_width = %d\n", new_height, new_width);
LOG("new_height = %f, new_width = %d\n", new_height, new_width);
}
printf("child will be at %dx%d with size %dx%d\n", rect->x, rect->y, rect->width, rect->height);
LOG("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));
@ -290,7 +290,7 @@ void render_container(xcb_connection_t *conn, Container *container) {
num_clients++;
if (container->mode == MODE_DEFAULT) {
printf("got %d clients in this default container.\n", num_clients);
LOG("got %d clients in this default container.\n", num_clients);
CIRCLEQ_FOREACH(client, &(container->clients), clients) {
/* Check if we changed client->x or client->y by updating it.
* Note the bitwise OR instead of logical OR to force evaluation of both statements */
@ -386,7 +386,7 @@ static void render_bars(xcb_connection_t *conn, Workspace *r_ws, int width, int
}
static void render_internal_bar(xcb_connection_t *conn, Workspace *r_ws, int width, int height) {
printf("Rendering internal bar\n");
LOG("Rendering internal bar\n");
i3Font *font = load_font(conn, config.font);
i3Screen *screen = r_ws->screen;
enum { SET_NORMAL = 0, SET_FOCUSED = 1 };
@ -433,7 +433,7 @@ static void render_internal_bar(xcb_connection_t *conn, Workspace *r_ws, int wid
}
}
printf("done rendering internal\n");
LOG("done rendering internal\n");
}
void render_layout(xcb_connection_t *conn) {
@ -444,7 +444,7 @@ void render_layout(xcb_connection_t *conn) {
/* r_ws (rendering workspace) is just a shortcut to the Workspace being currently rendered */
Workspace *r_ws = &(workspaces[screen->current_workspace]);
printf("Rendering screen %d\n", screen->num);
LOG("Rendering screen %d\n", screen->num);
if (r_ws->fullscreen_client != NULL)
/* This is easy: A client has entered fullscreen mode, so we dont render at all */
continue;
@ -460,7 +460,7 @@ void render_layout(xcb_connection_t *conn) {
/* Space for the internal bar */
height -= (font->height + 6);
printf("got %d rows and %d cols\n", r_ws->rows, r_ws->cols);
LOG("got %d rows and %d cols\n", r_ws->rows, r_ws->cols);
int xoffset[r_ws->rows];
int yoffset[r_ws->cols];
@ -476,9 +476,11 @@ void render_layout(xcb_connection_t *conn) {
for (int rows = 0; rows < r_ws->rows; rows++) {
Container *container = r_ws->table[cols][rows];
int single_width, single_height;
printf("\n========\ncontainer has %d colspan, %d rowspan\n",
LOG("\n");
LOG("========\n");
LOG("container has %d colspan, %d rowspan\n",
container->colspan, container->rowspan);
printf("container at %d, %d\n", xoffset[rows], yoffset[cols]);
LOG("container at %d, %d\n", xoffset[rows], yoffset[cols]);
/* Update position of the container */
container->row = rows;
container->col = cols;
@ -502,7 +504,7 @@ void render_layout(xcb_connection_t *conn) {
xoffset[rows] += single_width;
yoffset[cols] += single_height;
printf("==========\n");
LOG("==========\n");
}
render_bars(conn, r_ws, width, &height);

View File

@ -66,7 +66,7 @@ int num_screens = 0;
*
*/
void manage_window(xcb_property_handlers_t *prophs, xcb_connection_t *conn, xcb_window_t window, window_attributes_t wa) {
printf("managing window.\n");
LOG("managing window.\n");
xcb_drawable_t d = { window };
xcb_get_geometry_cookie_t geomc;
xcb_get_geometry_reply_t *geom;
@ -135,7 +135,7 @@ void reparent_window(xcb_connection_t *conn, xcb_window_t child,
/* Events for already managed windows should already be filtered in manage_window() */
assert(new == NULL);
printf("reparenting new client\n");
LOG("reparenting new client\n");
new = calloc(sizeof(Client), 1);
new->force_reconfigure = true;
uint32_t mask = 0;
@ -162,7 +162,7 @@ void reparent_window(xcb_connection_t *conn, xcb_window_t child,
XCB_EVENT_MASK_EXPOSURE | /* …our window needs to be redrawn */
XCB_EVENT_MASK_ENTER_WINDOW; /* …user moves cursor inside our window */
printf("Reparenting 0x%08x under 0x%08x.\n", child, new->frame);
LOG("Reparenting 0x%08x under 0x%08x.\n", child, new->frame);
i3Font *font = load_font(conn, config.font);
width = min(width, c_ws->rect.x + c_ws->rect.width);
@ -216,7 +216,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))) {
for (int i = 0; i < xcb_get_property_value_length(preply); i++)
if (atom[i] == atoms[_NET_WM_WINDOW_TYPE_DOCK]) {
printf("Window is a dock.\n");
LOG("Window is a dock.\n");
new->dock = true;
new->titlebar_position = TITLEBAR_OFF;
new->force_reconfigure = true;
@ -234,7 +234,7 @@ void reparent_window(xcb_connection_t *conn, xcb_window_t child,
with maximum horizontal size.
TODO: bars at the top */
new->desired_height = strut[3];
printf("the client wants to be %d pixels height\n", new->desired_height);
LOG("the client wants to be %d pixels height\n", new->desired_height);
}
/* Insert into the currently active container, if its not a dock window */
@ -449,14 +449,14 @@ int main(int argc, char *argv[], char *env[]) {
/* Grab the bound keys */
Binding *bind;
TAILQ_FOREACH(bind, &bindings, bindings) {
printf("Grabbing %d\n", bind->keycode);
LOG("Grabbing %d\n", bind->keycode);
if (bind->mods & BIND_MODE_SWITCH)
xcb_grab_key(conn, 0, root, 0, bind->keycode, XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_SYNC);
else xcb_grab_key(conn, 0, root, bind->mods, bind->keycode, XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC);
}
/* check for Xinerama */
printf("Checking for Xinerama...\n");
LOG("Checking for Xinerama...\n");
initialize_xinerama(conn);
/* DEBUG: Start a terminal */
@ -469,7 +469,7 @@ int main(int argc, char *argv[], char *env[]) {
/* Get pointer position to see on which screen were starting */
xcb_query_pointer_reply_t *reply;
if ((reply = xcb_query_pointer_reply(conn, xcb_query_pointer(conn, root), NULL)) == NULL) {
printf("Could not get pointer position\n");
LOG("Could not get pointer position\n");
return 1;
}
@ -479,7 +479,7 @@ int main(int argc, char *argv[], char *env[]) {
return 0;
}
if (screen->current_workspace != 0) {
printf("Ok, I need to go to the other workspace\n");
LOG("Ok, I need to go to the other workspace\n");
c_ws = &workspaces[screen->current_workspace];
}

View File

@ -108,7 +108,7 @@ bool cell_exists(int col, int row) {
}
static void move_columns_from(xcb_connection_t *conn, Workspace *workspace, int cols) {
printf("firstly freeing \n");
LOG("firstly freeing \n");
/* Clean up the column to be freed */
for (int rows = 0; rows < workspace->rows; rows++) {
@ -122,10 +122,10 @@ static void move_columns_from(xcb_connection_t *conn, Workspace *workspace, int
for (; cols < workspace->cols; cols++)
for (int rows = 0; rows < workspace->rows; rows++) {
printf("at col = %d, row = %d\n", cols, rows);
LOG("at col = %d, row = %d\n", cols, rows);
Container *new_container = workspace->table[cols][rows];
printf("moving cols = %d to cols -1 = %d\n", cols, cols-1);
LOG("moving cols = %d to cols -1 = %d\n", cols, cols-1);
workspace->table[cols-1][rows] = new_container;
new_container->row = rows;
@ -146,7 +146,7 @@ static void move_rows_from(xcb_connection_t *conn, Workspace *workspace, int row
for (int cols = 0; cols < workspace->cols; cols++) {
Container *new_container = workspace->table[cols][rows];
printf("moving rows = %d to rows -1 = %d\n", rows, rows - 1);
LOG("moving rows = %d to rows -1 = %d\n", rows, rows - 1);
workspace->table[cols][rows-1] = new_container;
new_container->row = rows-1;
@ -155,21 +155,21 @@ static void move_rows_from(xcb_connection_t *conn, Workspace *workspace, int row
}
void dump_table(xcb_connection_t *conn, Workspace *workspace) {
printf("dump_table()\n");
LOG("dump_table()\n");
for (int cols = 0; cols < workspace->cols; cols++) {
for (int rows = 0; rows < workspace->rows; rows++) {
Container *con = workspace->table[cols][rows];
printf("----\n");
printf("at col=%d, row=%d\n", cols, rows);
printf("currently_focused = %p\n", con->currently_focused);
LOG("----\n");
LOG("at col=%d, row=%d\n", cols, rows);
LOG("currently_focused = %p\n", con->currently_focused);
Client *loop;
CIRCLEQ_FOREACH(loop, &(con->clients), clients) {
printf("got client %08x / %s\n", loop->child, loop->name);
LOG("got client %08x / %s\n", loop->child, loop->name);
}
printf("----\n");
LOG("----\n");
}
}
printf("done\n");
LOG("done\n");
}
/*
@ -177,7 +177,7 @@ void dump_table(xcb_connection_t *conn, Workspace *workspace) {
*
*/
void cleanup_table(xcb_connection_t *conn, Workspace *workspace) {
printf("cleanup_table()\n");
LOG("cleanup_table()\n");
/* Check for empty columns if we got more than one column */
for (int cols = 0; (workspace->cols > 1) && (cols < workspace->cols);) {
@ -188,7 +188,7 @@ void cleanup_table(xcb_connection_t *conn, Workspace *workspace) {
break;
}
if (completely_empty) {
printf("Removing completely empty column %d\n", cols);
LOG("Removing completely empty column %d\n", cols);
if (cols < (workspace->cols - 1))
move_columns_from(conn, workspace, cols+1);
shrink_table_cols(workspace);
@ -207,7 +207,7 @@ void cleanup_table(xcb_connection_t *conn, Workspace *workspace) {
break;
}
if (completely_empty) {
printf("Removing completely empty row %d\n", rows);
LOG("Removing completely empty row %d\n", rows);
if (rows < (workspace->rows - 1))
move_rows_from(conn, workspace, rows+1);
shrink_table_rows(workspace);
@ -233,24 +233,24 @@ void cleanup_table(xcb_connection_t *conn, Workspace *workspace) {
*
*/
void fix_colrowspan(xcb_connection_t *conn, Workspace *workspace) {
printf("Fixing col/rowspan\n");
LOG("Fixing col/rowspan\n");
for (int cols = 0; cols < workspace->cols; cols++)
for (int rows = 0; rows < workspace->rows; rows++) {
Container *con = workspace->table[cols][rows];
if (con->colspan > 1) {
printf("gots one with colspan %d\n", con->colspan);
LOG("gots one with colspan %d\n", con->colspan);
while (con->colspan > 1 &&
workspace->table[cols + (con->colspan - 1)][rows]->currently_focused != NULL)
con->colspan--;
printf("fixed it to %d\n", con->colspan);
LOG("fixed it to %d\n", con->colspan);
}
if (con->rowspan > 1) {
printf("gots one with rowspan %d\n", con->rowspan);
LOG("gots one with rowspan %d\n", con->rowspan);
while (con->rowspan > 1 &&
workspace->table[cols][rows + (con->rowspan - 1)]->currently_focused != NULL)
con->rowspan--;
printf("fixed it to %d\n", con->rowspan);
LOG("fixed it to %d\n", con->rowspan);
}
}
}

View File

@ -33,6 +33,27 @@ int max(int a, int 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);
}
/*
* Prints the message (see printf()) to stderr, then exits the program.
*
@ -142,7 +163,7 @@ void set_focus(xcb_connection_t *conn, Client *client) {
current_col = client->container->col;
current_row = client->container->row;
printf("set_focus(frame %08x, child %08x, name %s)\n", client->frame, client->child, client->name);
LOG("set_focus(frame %08x, child %08x, name %s)\n", client->frame, client->child, client->name);
/* Set focus to the entered window, and flush xcb buffer immediately */
xcb_set_input_focus(conn, XCB_INPUT_FOCUS_POINTER_ROOT, client->child, XCB_CURRENT_TIME);
//xcb_warp_pointer(conn, XCB_NONE, client->child, 0, 0, 0, 0, 10, 10);
@ -257,7 +278,7 @@ void toggle_fullscreen(xcb_connection_t *conn, Client *client) {
client->fullscreen = !client->fullscreen;
if (client->fullscreen) {
printf("Entering fullscreen mode...\n");
LOG("Entering fullscreen mode...\n");
/* We just entered fullscreen mode, lets configure the window */
uint32_t mask = XCB_CONFIG_WINDOW_X |
XCB_CONFIG_WINDOW_Y |
@ -268,7 +289,7 @@ void toggle_fullscreen(xcb_connection_t *conn, Client *client) {
workspace->rect.width,
workspace->rect.height};
printf("child itself will be at %dx%d with size %dx%d\n",
LOG("child itself will be at %dx%d with size %dx%d\n",
values[0], values[1], values[2], values[3]);
xcb_configure_window(conn, client->frame, mask, values);
@ -283,7 +304,7 @@ void toggle_fullscreen(xcb_connection_t *conn, Client *client) {
xcb_configure_window(conn, client->frame, XCB_CONFIG_WINDOW_STACK_MODE, values);
} else {
printf("leaving fullscreen mode\n");
LOG("leaving fullscreen mode\n");
/* Because the coordinates of the window havent changed, it would not be
re-configured if we dont set the following flag */
client->force_reconfigure = true;

View File

@ -52,7 +52,7 @@ i3Screen *get_screen_at(int x, int y, struct screens_head *screenlist) {
i3Screen *get_screen_containing(int x, int y) {
i3Screen *screen;
TAILQ_FOREACH(screen, virtual_screens, screens) {
printf("comparing x=%d y=%d with x=%d and y=%d width %d height %d\n",
LOG("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);
if (x >= screen->rect.x && x < (screen->rect.x + screen->rect.width) &&
y >= screen->rect.y && y < (screen->rect.y + screen->rect.height))
@ -92,7 +92,7 @@ static void query_screens(xcb_connection_t *conn, struct screens_head *screenlis
reply = xcb_xinerama_query_screens_reply(conn, xcb_xinerama_query_screens_unchecked(conn), NULL);
if (!reply) {
printf("Couldn't get Xinerama screens\n");
LOG("Couldn't get Xinerama screens\n");
return;
}
screen_info = xcb_xinerama_query_screens_screen_info(reply);
@ -119,7 +119,7 @@ static void query_screens(xcb_connection_t *conn, struct screens_head *screenlis
num_screens++;
}
printf("found Xinerama screen: %d x %d at %d x %d\n",
LOG("found Xinerama screen: %d x %d at %d x %d\n",
screen_info[screen].width, screen_info[screen].height,
screen_info[screen].x_org, screen_info[screen].y_org);
}
@ -146,7 +146,7 @@ static void initialize_screen(xcb_connection_t *conn, i3Screen *screen, Workspac
/* Copy dimensions */
memcpy(&(workspace->rect), &(screen->rect), sizeof(Rect));
printf("that is virtual screen at %d x %d with %d x %d\n",
LOG("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);
}
@ -160,7 +160,7 @@ void initialize_xinerama(xcb_connection_t *conn) {
TAILQ_INIT(virtual_screens);
if (!xcb_get_extension_data(conn, &xcb_xinerama_id)->present) {
printf("Xinerama extension not found, disabling.\n");
LOG("Xinerama extension not found, disabling.\n");
disable_xinerama(conn);
return;
}
@ -169,7 +169,7 @@ void initialize_xinerama(xcb_connection_t *conn) {
reply = xcb_xinerama_is_active_reply(conn, xcb_xinerama_is_active(conn), NULL);
if (!reply->state) {
printf("Xinerama is not active (in your X-Server), disabling.\n");
LOG("Xinerama is not active (in your X-Server), disabling.\n");
free(reply);
disable_xinerama(conn);
return;
@ -199,7 +199,7 @@ void xinerama_requery_screens(xcb_connection_t *conn) {
it change when I move the --right-of video projector to --left-of? */
if (!xinerama_enabled) {
printf("Xinerama is disabled\n");
LOG("Xinerama is disabled\n");
return;
}
@ -218,7 +218,7 @@ void xinerama_requery_screens(xcb_connection_t *conn) {
for (int c = 0; c < 10; c++)
if ((workspaces[c].screen != NULL) &&
(workspaces[c].screen->num == screen_count)) {
printf("Found a matching screen\n");
LOG("Found a matching screen\n");
/* Try to use the same workspace, if its available */
if (workspaces[c].screen->current_workspace)
screen->current_workspace = workspaces[c].screen->current_workspace;
@ -238,7 +238,7 @@ void xinerama_requery_screens(xcb_connection_t *conn) {
/* Create a new workspace for this screen, its new */
for (int c = 0; c < 10; c++)
if (workspaces[c].screen == NULL) {
printf("fix: initializing new workspace, setting num to %d\n", c);
LOG("fix: initializing new workspace, setting num to %d\n", c);
initialize_screen(conn, screen, &(workspaces[c]));
break;
}
@ -250,10 +250,10 @@ void xinerama_requery_screens(xcb_connection_t *conn) {
for (int c = 0; c < 10; c++)
if ((workspaces[c].screen != NULL) &&
(workspaces[c].screen->num >= num_screens)) {
printf("Closing bar window\n");
LOG("Closing bar window\n");
xcb_destroy_window(conn, workspaces[c].screen->bar);
printf("Workspace %d's screen out of bounds, assigning to first screen\n", c+1);
LOG("Workspace %d's screen out of bounds, assigning to first screen\n", c+1);
workspaces[c].screen = first;
memcpy(&(workspaces[c].rect), &(first->rect), sizeof(Rect));
}
@ -268,7 +268,7 @@ void xinerama_requery_screens(xcb_connection_t *conn) {
virtual_screens = new_screens;
printf("Current workspace is now: %d\n", first->current_workspace);
LOG("Current workspace is now: %d\n", first->current_workspace);
render_layout(conn);
}