new->type = CT_CON;
new->border_style = config.default_border;
static int cnt = 0;
- LOG("opening window %d\n", cnt);
+ DLOG("opening window %d\n", cnt);
/* TODO: remove window coloring after test-phase */
- LOG("color %s\n", colors[cnt]);
+ DLOG("color %s\n", colors[cnt]);
new->name = strdup(colors[cnt]);
//uint32_t cp = get_colorpixel(colors[cnt]);
cnt++;
*/
bool con_is_floating(Con *con) {
assert(con != NULL);
- LOG("checking if con %p is floating\n", con);
+ DLOG("checking if con %p is floating\n", con);
return (con->floating >= FLOATING_AUTO_ON);
}
Con *con_for_window(i3Window *window, Match **store_match) {
Con *con;
Match *match;
- LOG("searching con for window %p\n", window);
- LOG("class == %s\n", window->class_class);
+ DLOG("searching con for window %p\n", window);
+ DLOG("class == %s\n", window->class_class);
TAILQ_FOREACH(con, &all_cons, all_cons)
TAILQ_FOREACH(match, &(con->swallow_head), matches) {
*/
void con_toggle_fullscreen(Con *con) {
Con *workspace, *fullscreen;
- LOG("toggling fullscreen for %p / %s\n", con, con->name);
+ DLOG("toggling fullscreen for %p / %s\n", con, con->name);
if (con->fullscreen_mode == CF_NONE) {
/* 1: check if there already is a fullscreen con */
workspace = con_get_workspace(con);
/* 1: disable fullscreen */
con->fullscreen_mode = CF_NONE;
}
- LOG("mode now: %d\n", con->fullscreen_mode);
+ DLOG("mode now: %d\n", con->fullscreen_mode);
/* update _NET_WM_STATE if this container has a window */
/* TODO: when a window is assigned to a container which is already
/* 1: get the first parent with the same orientation */
Con *cur = con;
while (con_orientation(cur->parent) != orientation) {
- LOG("need to go one level further up\n");
+ DLOG("need to go one level further up\n");
if (cur->parent->type == CT_WORKSPACE) {
LOG("that's a workspace, we can't go further up\n");
return NULL;
x_draw_decoration(parent);
TAILQ_FOREACH(con, &(parent->nodes_head), nodes) {
- LOG("expose for con %p / %s\n", con, con->name);
+ DLOG("expose for con %p / %s\n", con, con->name);
if (con->window)
x_draw_decoration(con);
}
/* We also need to render the decorations of other Cons nearby the Con
* itself to not get overlapping decorations */
TAILQ_FOREACH(con, &(parent->parent->nodes_head), nodes) {
- LOG("expose for con %p / %s\n", con, con->name);
+ DLOG("expose for con %p / %s\n", con, con->name);
if (con->window)
x_draw_decoration(con);
}
*
*/
void restore_geometry() {
- LOG("Restoring geometry\n");
+ DLOG("Restoring geometry\n");
Con *con;
TAILQ_FOREACH(con, &all_cons, all_cons)
if (con->window) {
- printf("placing window at %d %d\n", con->rect.x, con->rect.y);
+ DLOG("placing window at %d %d\n", con->rect.x, con->rect.y);
xcb_reparent_window(conn, con->window->id, root,
con->rect.x, con->rect.y);
}
xcb_get_geometry_reply_t *geom;
xcb_get_window_attributes_reply_t *attr = 0;
- printf("---> looking at window 0x%08x\n", window);
+ DLOG("---> looking at window 0x%08x\n", window);
xcb_get_property_cookie_t wm_type_cookie, strut_cookie, state_cookie,
utf8_title_cookie, title_cookie,
/* Check if the window is mapped (it could be not mapped when intializing and
calling manage_window() for every window) */
if ((attr = xcb_get_window_attributes_reply(conn, cookie, 0)) == NULL) {
- LOG("Could not get attributes\n");
+ DLOG("Could not get attributes\n");
return;
}
if (needs_to_be_mapped && attr->map_state != XCB_MAP_STATE_VIEWABLE) {
- LOG("map_state unviewable\n");
+ DLOG("map_state unviewable\n");
goto out;
}
/* Don’t manage clients with the override_redirect flag */
- LOG("override_redirect is %d\n", attr->override_redirect);
+ DLOG("override_redirect is %d\n", attr->override_redirect);
if (attr->override_redirect)
goto out;
/* Check if the window is already managed */
if (con_by_window_id(window) != NULL) {
- LOG("already managed (by con %p)\n", con_by_window_id(window));
+ DLOG("already managed (by con %p)\n", con_by_window_id(window));
goto out;
}
/* Get the initial geometry (position, size, …) */
if ((geom = xcb_get_geometry_reply(conn, geomc, 0)) == NULL) {
- LOG("could not get geometry\n");
+ DLOG("could not get geometry\n");
goto out;
}
- LOG("reparenting!\n");
+ DLOG("reparenting!\n");
uint32_t mask = 0;
uint32_t values[1];
if (match != NULL && match->insert_where == M_ACTIVE) {
/* We need to go down the focus stack starting from nc */
while (TAILQ_FIRST(&(nc->focus_head)) != TAILQ_END(&(nc->focus_head))) {
- printf("walking down one step...\n");
+ DLOG("walking down one step...\n");
nc = TAILQ_FIRST(&(nc->focus_head));
}
/* We need to open a new con */
* are bigger than our minimal useful size (75x50). */
nc->rect.width = max(geom->width, 75);
nc->rect.height = max(geom->height, 50);
- LOG("geometry = %d x %d\n", nc->rect.width, nc->rect.height);
+ DLOG("geometry = %d x %d\n", nc->rect.width, nc->rect.height);
floating_enable(nc, false);
}
*
*/
void render_con(Con *con, bool render_fullscreen) {
- printf("currently rendering node %p / %s / layout %d\n",
+ DLOG("currently rendering node %p / %s / layout %d\n",
con, con->name, con->layout);
int children = con_num_children(con);
- printf("children: %d, orientation = %d\n", children, con->orientation);
+ DLOG("children: %d, orientation = %d\n", children, con->orientation);
/* Copy container rect, subtract container border */
/* This is the actually usable space inside this container for clients */
/* Check for fullscreen nodes */
Con *fullscreen = con_get_fullscreen_con(con);
if (fullscreen) {
- LOG("got fs node: %p\n", fullscreen);
+ DLOG("got fs node: %p\n", fullscreen);
fullscreen->rect = rect;
x_raise_con(fullscreen);
render_con(fullscreen, true);
/* first we have the decoration, if this is a leaf node */
if (con_is_leaf(child) && child->border_style == BS_NORMAL) {
- printf("that child is a leaf node, subtracting deco\n");
+ DLOG("that child is a leaf node, subtracting deco\n");
/* TODO: make a function for relative coords? */
child->deco_rect.x = child->rect.x - con->rect.x;
child->deco_rect.y = child->rect.y - con->rect.y;
/* stacked layout */
else if (con->layout == L_STACKED) {
- printf("stacked con\n");
+ DLOG("stacked con\n");
child->rect.x = x;
child->rect.y = y;
child->rect.width = rect.width;
/* tabbed layout */
else if (con->layout == L_TABBED) {
- printf("tabbed con\n");
+ DLOG("tabbed con\n");
child->rect.x = x;
child->rect.y = y;
child->rect.width = rect.width;
}
}
- printf("child at (%d, %d) with (%d x %d)\n",
+ DLOG("child at (%d, %d) with (%d x %d)\n",
child->rect.x, child->rect.y, child->rect.width, child->rect.height);
- printf("x now %d, y now %d\n", x, y);
+ DLOG("x now %d, y now %d\n", x, y);
x_raise_con(child);
render_con(child, false);
i++;
if (con->layout == L_STACKED || con->layout == L_TABBED) {
Con *foc = TAILQ_FIRST(&(con->focus_head));
if (foc != TAILQ_END(&(con->focus_head))) {
- LOG("con %p is stacking, raising %p\n", con, foc);
+ DLOG("con %p is stacking, raising %p\n", con, foc);
x_raise_con(foc);
/* by rendering the stacked container again, we handle the case
* that we have a non-leaf-container inside the stack. */
}
TAILQ_FOREACH(child, &(con->floating_head), floating_windows) {
- LOG("render floating:\n");
- LOG("floating child at (%d,%d) with %d x %d\n", child->rect.x, child->rect.y, child->rect.width, child->rect.height);
+ DLOG("render floating:\n");
+ DLOG("floating child at (%d,%d) with %d x %d\n", child->rect.x, child->rect.y, child->rect.width, child->rect.height);
x_raise_con(child);
render_con(child, false);
}
- printf("-- level up\n");
+ DLOG("-- level up\n");
}
if (croot == NULL)
return;
- printf("-- BEGIN RENDERING --\n");
+ DLOG("-- BEGIN RENDERING --\n");
/* Reset map state for all nodes in tree */
/* TODO: a nicer method to walk all nodes would be good, maybe? */
mark_unmapped(croot);
/* We start rendering at an output */
Con *output;
TAILQ_FOREACH(output, &(croot->nodes_head), nodes) {
- printf("output %p / %s\n", output, output->name);
+ DLOG("output %p / %s\n", output, output->name);
render_con(output, false);
}
x_push_changes(croot);
- printf("-- END RENDERING --\n");
+ DLOG("-- END RENDERING --\n");
}
/*
state->initial = true;
CIRCLEQ_INSERT_HEAD(&state_head, state, state);
CIRCLEQ_INSERT_HEAD(&old_state_head, state, old_state);
- LOG("adding new state for window id 0x%08x\n", state->id);
+ DLOG("adding new state for window id 0x%08x\n", state->id);
}
/*
return;
}
- LOG("resetting state %p to initial\n", state);
+ DLOG("resetting state %p to initial\n", state);
state->initial = true;
state->child_mapped = false;
memset(&(state->window_rect), 0, sizeof(Rect));
memset(&zero, 0, sizeof(Rect));
if (memcmp(&(state_dest->window_rect), &(zero), sizeof(Rect)) == 0) {
memcpy(&(state_dest->window_rect), &(state_src->window_rect), sizeof(Rect));
- LOG("COPYING RECT\n");
+ DLOG("COPYING RECT\n");
}
}
con_state *state;
Rect rect = con->rect;
- LOG("Pushing changes for node %p / %s\n", con, con->name);
+ DLOG("Pushing changes for node %p / %s\n", con, con->name);
state = state_for_frame(con->frame);
if (state->name != NULL) {
/* reparent the child window (when the window was moved due to a sticky
* container) */
if (state->need_reparent && con->window != NULL) {
- LOG("Reparenting child window\n");
+ DLOG("Reparenting child window\n");
/* Temporarily set the event masks to XCB_NONE so that we won’t get
* UnmapNotify events (otherwise the handler would close the container).
bool fake_notify = false;
/* set new position if rect changed */
if (memcmp(&(state->rect), &rect, sizeof(Rect)) != 0) {
- LOG("setting rect (%d, %d, %d, %d)\n", rect.x, rect.y, rect.width, rect.height);
+ DLOG("setting rect (%d, %d, %d, %d)\n", rect.x, rect.y, rect.width, rect.height);
xcb_set_window_rect(conn, con->frame, rect);
memcpy(&(state->rect), &rect, sizeof(Rect));
fake_notify = true;
/* dito, but for child windows */
if (con->window != NULL &&
memcmp(&(state->window_rect), &(con->window_rect), sizeof(Rect)) != 0) {
- LOG("setting window rect (%d, %d, %d, %d)\n",
+ DLOG("setting window rect (%d, %d, %d, %d)\n",
con->window_rect.x, con->window_rect.y, con->window_rect.width, con->window_rect.height);
xcb_set_window_rect(conn, con->window->id, con->window_rect);
memcpy(&(state->window_rect), &(con->window_rect), sizeof(Rect));
if (!state->child_mapped && con->window != NULL) {
cookie = xcb_map_window(conn, con->window->id);
- LOG("mapping child window (serial %d)\n", cookie.sequence);
+ DLOG("mapping child window (serial %d)\n", cookie.sequence);
/* Ignore enter_notifies which are generated when mapping */
add_ignore_event(cookie.sequence);
state->child_mapped = true;
}
cookie = xcb_map_window(conn, con->frame);
- LOG("mapping container (serial %d)\n", cookie.sequence);
+ DLOG("mapping container (serial %d)\n", cookie.sequence);
/* Ignore enter_notifies which are generated when mapping */
add_ignore_event(cookie.sequence);
state->mapped = con->mapped;
}
if (fake_notify) {
- LOG("Sending fake configure notify\n");
+ DLOG("Sending fake configure notify\n");
fake_absolute_configure_notify(con);
}
Con *current;
con_state *state;
- LOG("Pushing changes (with unmaps) for node %p / %s\n", con, con->name);
+ DLOG("Pushing changes (with unmaps) for node %p / %s\n", con, con->name);
state = state_for_frame(con->frame);
/* map/unmap if map state changed, also ensure that the child window
}
cookie = xcb_unmap_window(conn, con->frame);
- LOG("unmapping container (serial %d)\n", cookie.sequence);
+ DLOG("unmapping container (serial %d)\n", cookie.sequence);
/* we need to increase ignore_unmap for this container (if it
* contains a window) and for every window "under" this one which
* contains a window */
void x_push_changes(Con *con) {
con_state *state;
- LOG("\n\n PUSHING CHANGES\n\n");
+ DLOG("\n\n PUSHING CHANGES\n\n");
x_push_node(con);
- LOG("-- PUSHING WINDOW STACK --\n");
+ DLOG("-- PUSHING WINDOW STACK --\n");
bool order_changed = false;
/* X11 correctly represents the stack if we push it from bottom to top */
CIRCLEQ_FOREACH_REVERSE(state, &state_head, state) {
- LOG("stack: 0x%08x\n", state->id);
+ DLOG("stack: 0x%08x\n", state->id);
con_state *prev = CIRCLEQ_PREV(state, state);
con_state *old_prev = CIRCLEQ_PREV(state, old_state);
if (prev != old_prev)
order_changed = true;
if ((state->initial || order_changed) && prev != CIRCLEQ_END(&state_head)) {
- LOG("Stacking 0x%08x above 0x%08x\n", prev->id, state->id);
+ DLOG("Stacking 0x%08x above 0x%08x\n", prev->id, state->id);
uint32_t mask = 0;
mask |= XCB_CONFIG_WINDOW_SIBLING;
mask |= XCB_CONFIG_WINDOW_STACK_MODE;
if (!focused->mapped) {
DLOG("Not updating focus (to %p / %s), focused window is not mapped.\n", focused, focused->name);
} else {
- LOG("Updating focus (focused: %p / %s)\n", focused, focused->name);
+ DLOG("Updating focus (focused: %p / %s)\n", focused, focused->name);
xcb_set_input_focus(conn, XCB_INPUT_FOCUS_POINTER_ROOT, to_focus, XCB_CURRENT_TIME);
focused_id = to_focus;
}
}
xcb_flush(conn);
- LOG("\n\n ENDING CHANGES\n\n");
+ DLOG("\n\n ENDING CHANGES\n\n");
x_push_node_unmaps(con);
CIRCLEQ_INSERT_TAIL(&old_state_head, state, old_state);
}
CIRCLEQ_FOREACH(state, &old_state_head, old_state) {
- LOG("old stack: 0x%08x\n", state->id);
+ DLOG("old stack: 0x%08x\n", state->id);
}
}
*/
void x_raise_con(Con *con) {
con_state *state;
- LOG("raising in new stack: %p / %s\n", con, con->name);
+ DLOG("raising in new stack: %p / %s\n", con, con->name);
state = state_for_frame(con->frame);
CIRCLEQ_REMOVE(&state_head, state, state);