From bf0e8c2862631d41963fdb6bcb3f41667a7eccc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingo=20B=C3=BCrk?= Date: Wed, 11 Feb 2015 20:34:19 +0100 Subject: [PATCH 1/2] Remove one level of indentation #1465 --- i3bar/src/child.c | 54 ++++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/i3bar/src/child.c b/i3bar/src/child.c index 8645a664..31b99d42 100644 --- a/i3bar/src/child.c +++ b/i3bar/src/child.c @@ -520,33 +520,35 @@ void child_click_events_key(const char *key) { * */ void send_block_clicked(int button, const char *name, const char *instance, int x, int y) { - if (child.click_events) { - child_click_events_initialize(); - - yajl_gen_map_open(gen); - - if (name) { - child_click_events_key("name"); - yajl_gen_string(gen, (const unsigned char *)name, strlen(name)); - } - - if (instance) { - child_click_events_key("instance"); - yajl_gen_string(gen, (const unsigned char *)instance, strlen(instance)); - } - - child_click_events_key("button"); - yajl_gen_integer(gen, button); - - child_click_events_key("x"); - yajl_gen_integer(gen, x); - - child_click_events_key("y"); - yajl_gen_integer(gen, y); - - yajl_gen_map_close(gen); - child_write_output(); + if (!child.click_events) { + return; } + + child_click_events_initialize(); + + yajl_gen_map_open(gen); + + if (name) { + child_click_events_key("name"); + yajl_gen_string(gen, (const unsigned char *)name, strlen(name)); + } + + if (instance) { + child_click_events_key("instance"); + yajl_gen_string(gen, (const unsigned char *)instance, strlen(instance)); + } + + child_click_events_key("button"); + yajl_gen_integer(gen, button); + + child_click_events_key("x"); + yajl_gen_integer(gen, x); + + child_click_events_key("y"); + yajl_gen_integer(gen, y); + + yajl_gen_map_close(gen); + child_write_output(); } /* From 594b29f83d73b9d4a781d2c33cc6fb06f649dc45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingo=20B=C3=BCrk?= Date: Wed, 11 Feb 2015 20:34:43 +0100 Subject: [PATCH 2/2] Make click events on status blocks work if 'workspace_buttons no' is set. 1. Always subscribe to click events for i3bar. 2. Exit the click event handler if no current workspace was found only after clicks on status blocks have been handled. fixes #1430 --- i3bar/src/xcb.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/i3bar/src/xcb.c b/i3bar/src/xcb.c index 2d33919e..b417110a 100644 --- a/i3bar/src/xcb.c +++ b/i3bar/src/xcb.c @@ -314,18 +314,6 @@ void handle_button(xcb_button_press_event_t *event) { return; } - /* TODO: Move this to extern get_ws_for_output() */ - TAILQ_FOREACH (cur_ws, walk->workspaces, tailq) { - if (cur_ws->visible) { - break; - } - } - - if (cur_ws == NULL) { - DLOG("No Workspace active?\n"); - return; - } - int32_t x = event->event_x >= 0 ? event->event_x : 0; int32_t original_x = x; @@ -364,6 +352,18 @@ void handle_button(xcb_button_press_event_t *event) { x = original_x; } + /* TODO: Move this to extern get_ws_for_output() */ + TAILQ_FOREACH (cur_ws, walk->workspaces, tailq) { + if (cur_ws->visible) { + break; + } + } + + if (cur_ws == NULL) { + DLOG("No Workspace active?\n"); + return; + } + switch (event->detail) { case 4: /* Mouse wheel up. We select the previous ws, if any. @@ -1460,10 +1460,8 @@ void reconfig_windows(bool redraw_bars) { * BUTTON_PRESS, to handle clicks on the workspace buttons * */ values[2] = XCB_EVENT_MASK_EXPOSURE | - XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT; - if (!config.disable_ws) { - values[2] |= XCB_EVENT_MASK_BUTTON_PRESS; - } + XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | + XCB_EVENT_MASK_BUTTON_PRESS; xcb_void_cookie_t win_cookie = xcb_create_window_checked(xcb_connection, root_screen->root_depth, walk->bar,