From: Michael Stapelberg Date: Tue, 11 Aug 2009 13:23:58 +0000 (+0200) Subject: More log cleanups X-Git-Tag: 3.c~11 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=44d9111d65691854360de67f9a7afa1a0d9a6e22;p=i3%2Fi3 More log cleanups --- diff --git a/include/client.h b/include/client.h index 9d47edaf..e43f81b9 100644 --- a/include/client.h +++ b/include/client.h @@ -101,6 +101,8 @@ void client_map(xcb_connection_t *conn, Client *client); * Pretty-prints the client’s information into the logfile. * */ -void client_log(Client *client); +#define CLIENT_LOG(client) do { \ + LOG("Window: frame 0x%08x, child 0x%08x\n", client->frame, client->child); \ + } while (0) #endif diff --git a/src/client.c b/src/client.c index 12125d8b..a4269805 100644 --- a/src/client.c +++ b/src/client.c @@ -314,11 +314,3 @@ void client_map(xcb_connection_t *conn, Client *client) { xcb_map_window(conn, client->frame); } - -/* - * Pretty-prints the client’s information into the logfile. - * - */ -void client_log(Client *client) { - LOG("Window: frame 0x%08x, child 0x%08x\n", client->frame, client->child); -} diff --git a/src/commands.c b/src/commands.c index afb16704..802f0fd4 100644 --- a/src/commands.c +++ b/src/commands.c @@ -1069,6 +1069,4 @@ void parse_command(xcb_connection_t *conn, const char *command) { continue; } } - - LOG("--- done ---\n"); } diff --git a/src/config.c b/src/config.c index 65bfd67d..0bd67808 100644 --- a/src/config.c +++ b/src/config.c @@ -50,9 +50,7 @@ static void replace_variable(char *buffer, const char *key, const char *value) { /* To prevent endless recursions when the user makes an error configuring, * we stop after 100 replacements. That should be vastly more than enough. */ int c = 0; - LOG("Replacing %s with %s\n", key, value); while ((pos = strcasestr(buffer, key)) != NULL && c++ < 100) { - LOG("replacing variable %s in \"%s\" with \"%s\"\n", key, buffer, value); char *rest = pos + strlen(key); *pos = '\0'; char *replaced; @@ -103,7 +101,6 @@ void grab_all_keys(xcb_connection_t *conn) { } /* We need to translate the symbol to a keycode */ - LOG("Translating symbol to keycode (\"%s\")\n", bind->symbol); xcb_keysym_t keysym = XStringToKeysym(bind->symbol); if (keysym == NoSymbol) { LOG("Could not translate string to key symbol: \"%s\"\n", bind->symbol); @@ -127,7 +124,7 @@ void grab_all_keys(xcb_connection_t *conn) { last_keycode = *walk; bind->number_keycodes++; } - LOG("Got %d different keycodes\n", bind->number_keycodes); + LOG("Translated symbol \"%s\" to %d keycode\n", bind->symbol, bind->number_keycodes); bind->translated_to = smalloc(bind->number_keycodes * sizeof(xcb_keycode_t)); memcpy(bind->translated_to, keycodes, bind->number_keycodes * sizeof(xcb_keycode_t)); free(keycodes); diff --git a/src/handlers.c b/src/handlers.c index 1e10705a..61d1b711 100644 --- a/src/handlers.c +++ b/src/handlers.c @@ -48,8 +48,6 @@ static void add_ignore_event(const int sequence) { event->sequence = sequence; event->added = time(NULL); - LOG("Adding sequence %d to ignorelist\n", sequence); - SLIST_INSERT_HEAD(&ignore_events, event, ignore_events); } @@ -71,7 +69,6 @@ static bool event_is_ignored(const int sequence) { SLIST_FOREACH(event, &ignore_events, ignore_events) { if (event->sequence == sequence) { - LOG("Ignoring event (sequence %d)\n", sequence); SLIST_REMOVE(&ignore_events, event, Ignore_Event, ignore_events); free(event); return true; @@ -87,7 +84,6 @@ static bool event_is_ignored(const int sequence) { * */ int handle_key_release(void *ignored, xcb_connection_t *conn, xcb_key_release_event_t *event) { - LOG("got key release, just passing\n"); xcb_allow_events(conn, XCB_ALLOW_REPLAY_KEYBOARD, event->time); xcb_flush(conn); return 1; @@ -608,13 +604,12 @@ int handle_configure_request(void *prophs, xcb_connection_t *conn, xcb_configure 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; - LOG("event->x = %d, ->y = %d, ->width = %d, ->height = %d\n", event->x, event->y, event->width, event->height); - /* We ignore this sequence twice because events for child and frame should be ignored */ add_ignore_event(event->sequence); add_ignore_event(event->sequence); if (event->event == root) { + LOG("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"); /* FIXME: Somehow, this is occuring too often. Therefore, we check for 0/0, but is there a better way? */ @@ -640,7 +635,6 @@ 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) { - LOG("Dropping this unmap request, it was generated by reparenting\n"); client->awaiting_useless_unmap = false; return 1; } @@ -877,10 +871,8 @@ int handle_windowclass_change(void *data, xcb_connection_t *conn, uint8_t state, client->window_class = new_class; FREE(old_class); - if (!client->initialized) { - LOG("Client is not yet initialized, not putting it to floating\n"); + if (!client->initialized) return 1; - } if (strcmp(new_class, "tools") == 0 || strcmp(new_class, "Dialog") == 0) { LOG("tool/dialog window, should we put it floating?\n"); @@ -1007,7 +999,7 @@ int handle_normal_hints(void *data, xcb_connection_t *conn, uint8_t state, xcb_w } xcb_size_hints_t size_hints; - client_log(client); + CLIENT_LOG(client); /* If the hints were already in this event, use them, if not, request them */ if (reply != NULL) @@ -1016,7 +1008,8 @@ int handle_normal_hints(void *data, xcb_connection_t *conn, uint8_t state, xcb_w xcb_get_wm_normal_hints_reply(conn, xcb_get_wm_normal_hints_unchecked(conn, client->child), &size_hints, NULL); if ((size_hints.flags & XCB_SIZE_HINT_P_MIN_SIZE)) { - LOG("Minimum size: %d (width) x %d (height)\n", size_hints.min_width, size_hints.min_height); + // TODO: Minimum size is not yet implemented + //LOG("Minimum size: %d (width) x %d (height)\n", size_hints.min_width, size_hints.min_height); } if ((size_hints.flags & XCB_SIZE_HINT_P_RESIZE_INC)) { @@ -1024,9 +1017,6 @@ int handle_normal_hints(void *data, xcb_connection_t *conn, uint8_t state, xcb_w client->width_increment = size_hints.width_inc; if (size_hints.height_inc > 0) client->height_increment = size_hints.height_inc; - - LOG("Updated client's width_increment to %d px, heigh_increment to %d px\n", - client->width_increment, client->height_increment); } /* If no aspect ratio was set or if it was invalid, we ignore the hints */ @@ -1132,7 +1122,7 @@ int handle_clientleader_change(void *data, xcb_connection_t *conn, uint8_t state return 1; xcb_window_t *leader = xcb_get_property_value(prop); - if (leader == NULL) + if (leader == NULL || *leader == 0) return 1; LOG("Client leader changed to %08x\n", *leader); diff --git a/src/layout.c b/src/layout.c index d628ef8f..1d58097d 100644 --- a/src/layout.c +++ b/src/layout.c @@ -109,7 +109,6 @@ void decorate_window(xcb_connection_t *conn, Client *client, xcb_drawable_t draw if (client->dock) return; - LOG("redecorating child %08x\n", client->child); last_focused = SLIST_FIRST(&(client->workspace->focus_stack)); if (client_is_floating(client)) { if (last_focused == client) @@ -209,7 +208,6 @@ void reposition_client(xcb_connection_t *conn, Client *client) { LOG("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); floating_assign_to_workspace(client, &workspaces[screen->current_workspace]); - LOG("fixed that\n"); } /* @@ -325,7 +323,6 @@ void render_container(xcb_connection_t *conn, Container *container) { num_clients++; if (container->mode == MODE_DEFAULT) { - LOG("got %d clients in this default container.\n", num_clients); CIRCLEQ_FOREACH(client, &(container->clients), clients) { /* If the client is in fullscreen mode, it does not get reconfigured */ if (container->workspace->fullscreen_client == client) { @@ -535,8 +532,6 @@ void render_workspace(xcb_connection_t *conn, i3Screen *screen, Workspace *r_ws) /* Space for the internal bar */ height -= (font->height + 6); - LOG("got %d rows and %d cols\n", r_ws->rows, r_ws->cols); - int xoffset[r_ws->rows]; int yoffset[r_ws->cols]; /* Initialize offsets */ @@ -545,19 +540,12 @@ void render_workspace(xcb_connection_t *conn, i3Screen *screen, Workspace *r_ws) for (int rows = 0; rows < r_ws->rows; rows++) xoffset[rows] = r_ws->rect.x; - dump_table(conn, r_ws); - ignore_enter_notify_forall(conn, r_ws, true); /* Go through the whole table and render what’s necessary */ FOR_TABLE(r_ws) { Container *container = r_ws->table[cols][rows]; int single_width = -1, single_height; - LOG("\n"); - LOG("========\n"); - LOG("container has %d colspan, %d rowspan\n", - container->colspan, container->rowspan); - LOG("container at %d, %d\n", xoffset[rows], yoffset[cols]); /* Update position of the container */ container->row = rows; container->col = cols; @@ -585,7 +573,6 @@ void render_workspace(xcb_connection_t *conn, i3Screen *screen, Workspace *r_ws) xoffset[rows] += single_width; yoffset[cols] += single_height; - LOG("==========\n"); } ignore_enter_notify_forall(conn, r_ws, false); @@ -605,10 +592,8 @@ void render_workspace(xcb_connection_t *conn, i3Screen *screen, Workspace *r_ws) void render_layout(xcb_connection_t *conn) { i3Screen *screen; - TAILQ_FOREACH(screen, virtual_screens, screens) { - LOG("Rendering screen %d\n", screen->num); + TAILQ_FOREACH(screen, virtual_screens, screens) render_workspace(conn, screen, &(workspaces[screen->current_workspace])); - } xcb_flush(conn); } diff --git a/src/manage.c b/src/manage.c index af83d069..dd726c6e 100644 --- a/src/manage.c +++ b/src/manage.c @@ -68,7 +68,6 @@ void manage_existing_windows(xcb_connection_t *conn, xcb_property_handlers_t *pr void manage_window(xcb_property_handlers_t *prophs, xcb_connection_t *conn, xcb_window_t window, xcb_get_window_attributes_cookie_t cookie, bool needs_to_be_mapped) { - LOG("managing window.\n"); xcb_drawable_t d = { window }; xcb_get_geometry_cookie_t geomc; xcb_get_geometry_reply_t *geom; @@ -83,16 +82,12 @@ void manage_window(xcb_property_handlers_t *prophs, xcb_connection_t *conn, return; } - if (needs_to_be_mapped && attr->map_state != XCB_MAP_STATE_VIEWABLE) { - LOG("Window not mapped, not managing\n"); + if (needs_to_be_mapped && attr->map_state != XCB_MAP_STATE_VIEWABLE) goto out; - } /* Don’t manage clients with the override_redirect flag */ - if (attr->override_redirect) { - LOG("override_redirect set, not managing\n"); + if (attr->override_redirect) goto out; - } /* Check if the window is already managed */ if (table_get(&by_child, window)) @@ -158,7 +153,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); - LOG("reparenting new client\n"); + LOG("Reparenting window 0x%08x\n", child); LOG("x = %d, y = %d, width = %d, height = %d\n", x, y, width, height); new = calloc(sizeof(Client), 1); new->force_reconfigure = true; @@ -194,8 +189,6 @@ void reparent_window(xcb_connection_t *conn, xcb_window_t child, mask |= XCB_CW_EVENT_MASK; values[1] = FRAME_EVENT_MASK; - 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); height = min(height, c_ws->rect.y + c_ws->rect.height); @@ -315,7 +308,6 @@ void reparent_window(xcb_connection_t *conn, xcb_window_t child, preply = xcb_get_property_reply(conn, leader_cookie, NULL); handle_clientleader_change(NULL, conn, 0, new->child, atoms[WM_CLIENT_LEADER], preply); - LOG("DEBUG: should have all infos now\n"); struct Assignment *assign; TAILQ_FOREACH(assign, &assignments, assignments) { if (get_matching_client(conn, assign->windowclass_title, new) == NULL) @@ -437,10 +429,9 @@ void reparent_window(xcb_connection_t *conn, xcb_window_t child, /* Map the window first to avoid flickering */ xcb_map_window(conn, child); - if (map_frame) { - LOG("Mapping client\n"); + if (map_frame) client_map(conn, new); - } + if (CUR_CELL->workspace->fullscreen_client == NULL && !new->dock) { /* Focus the new window if we’re not in fullscreen mode and if it is not a dock window */ if (new->workspace->fullscreen_client == NULL) { diff --git a/src/util.c b/src/util.c index d1acc744..8cb5409c 100644 --- a/src/util.c +++ b/src/util.c @@ -240,10 +240,8 @@ void set_focus(xcb_connection_t *conn, Client *client, bool set_anyways) { Client *old_client = SLIST_FIRST(&(c_ws->focus_stack)); /* Check if the focus needs to be changed at all */ - if (!set_anyways && (old_client == client)) { - LOG("old_client == client, not changing focus\n"); + if (!set_anyways && (old_client == client)) return; - } /* Store current_row/current_col */ c_ws->current_row = current_row; @@ -261,7 +259,7 @@ void set_focus(xcb_connection_t *conn, Client *client, bool set_anyways) { current_row = client->container->row; } - LOG("set_focus(frame %08x, child %08x, name %s)\n", client->frame, client->child, client->name); + CLIENT_LOG(client); /* 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); diff --git a/src/xcb.c b/src/xcb.c index 3f5d4280..4ed2f1aa 100644 --- a/src/xcb.c +++ b/src/xcb.c @@ -181,8 +181,6 @@ void fake_configure_notify(xcb_connection_t *conn, Rect r, xcb_window_t window) xcb_send_event(conn, false, window, XCB_EVENT_MASK_STRUCTURE_NOTIFY, (char*)&generated_event); xcb_flush(conn); - - LOG("Told the client it is at %dx%d with %dx%d\n", r.x, r.y, r.width, r.height); } /*