From 3892d616cfc3abd395c23c516a55538b82f103c5 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Fri, 12 Aug 2011 22:53:49 +0200 Subject: [PATCH 1/3] Bugfix: Use correct buffer size, quote workspace names This fixes problems with the workspace 'next' and workspace names longer than 40 characters --- i3bar/src/xcb.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/i3bar/src/xcb.c b/i3bar/src/xcb.c index b8ab5ed2..1afa8bd1 100644 --- a/i3bar/src/xcb.c +++ b/i3bar/src/xcb.c @@ -377,8 +377,9 @@ void handle_button(xcb_button_press_event_t *event) { break; } - char buffer[strlen(cur_ws->name) + 11]; - snprintf(buffer, 50, "workspace %s", cur_ws->name); + const size_t len = strlen(cur_ws->name) + strlen("workspace \"\"") + 1; + char buffer[len]; + snprintf(buffer, len, "workspace \"%s\"", cur_ws->name); i3_send_msg(I3_IPC_MESSAGE_TYPE_COMMAND, buffer); } From 72ef8a7c196871e0627a976317297d67e87daa47 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Fri, 12 Aug 2011 23:09:36 +0200 Subject: [PATCH 2/3] Pass NULL to XkbOpenDisplay, it will read $DISPLAY itself --- i3bar/src/xcb.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/i3bar/src/xcb.c b/i3bar/src/xcb.c index 1afa8bd1..ba7d2346 100644 --- a/i3bar/src/xcb.c +++ b/i3bar/src/xcb.c @@ -506,11 +506,7 @@ char *init_xcb(char *fontname) { xkb_major = XkbMajorVersion; xkb_minor = XkbMinorVersion; - char *dispname = getenv("DISPLAY"); - if (dispname == NULL) { - dispname = ":0"; - } - xkb_dpy = XkbOpenDisplay(dispname, + xkb_dpy = XkbOpenDisplay(NULL, &xkb_event_base, &xkb_errbase, &xkb_major, From dddce72bd7c2e532ad83bbf751c2f21a7e21d553 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Fri, 12 Aug 2011 23:09:59 +0200 Subject: [PATCH 3/3] little comment spelling fixes --- i3bar/src/outputs.c | 2 +- i3bar/src/workspaces.c | 4 ++-- i3bar/src/xcb.c | 22 +++++++++++----------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/i3bar/src/outputs.c b/i3bar/src/outputs.c index 8cfdaa98..9daf328d 100644 --- a/i3bar/src/outputs.c +++ b/i3bar/src/outputs.c @@ -40,7 +40,7 @@ static int outputs_null_cb(void *params_) { } /* - * Parse a booleant-value (active) + * Parse a boolean value (active) * */ static int outputs_boolean_cb(void *params_, bool val) { diff --git a/i3bar/src/workspaces.c b/i3bar/src/workspaces.c index db812673..eeb9ca34 100644 --- a/i3bar/src/workspaces.c +++ b/i3bar/src/workspaces.c @@ -26,7 +26,7 @@ struct workspaces_json_params { }; /* - * Parse a booleant-value (visible, focused, urgent) + * Parse a boolean value (visible, focused, urgent) * */ static int workspaces_boolean_cb(void *params_, bool val) { @@ -119,7 +119,7 @@ static int workspaces_string_cb(void *params_, const unsigned char *val, unsigne strncpy(params->workspaces_walk->name, (const char*) val, len); params->workspaces_walk->name[len] = '\0'; - /* Convert the name to ucs2, save it's length in glyphs and calculate it'srendered width */ + /* Convert the name to ucs2, save its length in glyphs and calculate its rendered width */ int ucs2_len; xcb_char2b_t *ucs2_name = (xcb_char2b_t*) convert_utf8_to_ucs2(params->workspaces_walk->name, &ucs2_len); params->workspaces_walk->ucs2_name = ucs2_name; diff --git a/i3bar/src/xcb.c b/i3bar/src/xcb.c index ba7d2346..28ef3ea2 100644 --- a/i3bar/src/xcb.c +++ b/i3bar/src/xcb.c @@ -306,8 +306,8 @@ void init_colors(const struct xcb_color_strings_t *new_colors) { } /* - * Handle a button-press-event (i.c. a mouse click on one of our bars). - * We determine, wether the click occured on a ws-button or if the scroll- + * Handle a button-press-event (i.e. a mouse click on one of our bars). + * We determine, whether the click occured on a ws-button or if the scroll- * wheel was used and change the workspace appropriately * */ @@ -384,7 +384,7 @@ void handle_button(xcb_button_press_event_t *event) { } /* - * This function is called immediately bevor the main loop locks. We flush xcb + * This function is called immediately before the main loop locks. We flush xcb * then (and only then) * */ @@ -395,7 +395,7 @@ void xcb_prep_cb(struct ev_loop *loop, ev_prepare *watcher, int revents) { /* * This function is called immediately after the main loop locks, so when one * of the watchers registered an event. - * We check wether an X-Event arrived and handle it. + * We check whether an X-Event arrived and handle it. * */ void xcb_chk_cb(struct ev_loop *loop, ev_check *watcher, int revents) { @@ -492,7 +492,7 @@ char *init_xcb(char *fontname) { strlen(fontname), fontname); - /* We need to save info about the font, because we need the fonts height and + /* We need to save info about the font, because we need the font's height and * information about the width of characters */ xcb_query_font_cookie_t query_font_cookie; query_font_cookie = xcb_query_font(xcb_connection, @@ -570,7 +570,7 @@ char *init_xcb(char *fontname) { xcb_screen->height_in_pixels); - /* The varios Watchers to communicate with xcb */ + /* The various Watchers to communicate with xcb */ xcb_io = malloc(sizeof(ev_io)); xcb_prep = malloc(sizeof(ev_prepare)); xcb_chk = malloc(sizeof(ev_check)); @@ -583,7 +583,7 @@ char *init_xcb(char *fontname) { ev_prepare_start(main_loop, xcb_prep); ev_check_start(main_loop, xcb_chk); - /* Now we get the atoms and save them in a nice data-structure */ + /* Now we get the atoms and save them in a nice data structure */ get_atoms(); xcb_get_property_cookie_t path_cookie; @@ -594,7 +594,7 @@ char *init_xcb(char *fontname) { XCB_GET_PROPERTY_TYPE_ANY, 0, PATH_MAX); - /* We check, if i3 set it's socket-path */ + /* We check, if i3 set its socket-path */ xcb_get_property_reply_t *path_reply = xcb_get_property_reply(xcb_connection, path_cookie, NULL); @@ -663,7 +663,7 @@ void clean_xcb() { } /* - * Get the earlier requested atoms and save them in the prepared data-structure + * Get the earlier requested atoms and save them in the prepared data structure * */ void get_atoms() { @@ -738,7 +738,7 @@ void realloc_sl_buffer() { } /* - * Reconfigure all bars and create new for newly activated outputs + * Reconfigure all bars and create new bars for recently activated outputs * */ void reconfig_windows() { @@ -748,7 +748,7 @@ void reconfig_windows() { i3_output *walk; SLIST_FOREACH(walk, outputs, slist) { if (!walk->active) { - /* If an output is not active, we destroy it's bar */ + /* If an output is not active, we destroy its bar */ /* FIXME: Maybe we rather want to unmap? */ DLOG("Destroying window for output %s\n", walk->name); destroy_window(walk);