From: Michael Stapelberg Date: Tue, 4 Aug 2009 20:27:01 +0000 (+0200) Subject: Fix clicking on workspaces in internal bar (with named workspaces) (Thanks bapt) X-Git-Tag: 3.c~32 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=4c373c2128cbb60a6d6623f5b6a7deac498bcabc;p=i3%2Fi3 Fix clicking on workspaces in internal bar (with named workspaces) (Thanks bapt) --- diff --git a/src/handlers.c b/src/handlers.c index cf56ab6d..a667628c 100644 --- a/src/handlers.c +++ b/src/handlers.c @@ -276,16 +276,22 @@ static bool button_press_bar(xcb_connection_t *conn, xcb_button_press_event_t *e } return true; } - i3Font *font = load_font(conn, config.font); - int workspace = event->event_x / (font->height + 6), - c = 0; + int drawn = 0; /* Because workspaces can be on different screens, we need to loop through all of them and decide to count it based on its ->screen */ - for (int i = 0; i < 10; i++) - if ((workspaces[i].screen == screen) && (c++ == workspace)) { + for (int i = 0; i < 10; i++) { + if (workspaces[i].screen != screen) + continue; + LOG("Checking if click was on workspace %d with drawn = %d, tw = %d\n", + i, drawn, workspaces[i].text_width); + if (event->event_x > (drawn + 1) && + event->event_x <= (drawn + 1 + workspaces[i].text_width + 5 + 5)) { show_workspace(conn, i+1); return true; } + + drawn += workspaces[i].text_width + 5 + 5 + 2; + } return true; }