+ /* It was no scrolling, so we calculate the destination client by
+ dividing the Y position of the event through the height of a window
+ decoration and then set the focus to this client. */
+ i3Font *font = load_font(conn, config.font);
+ int decoration_height = (font->height + 2 + 2);
+ int destination = (event->event_y / decoration_height),
+ c = 0,
+ num_clients = 0;
+ Client *client;
+ Container *container = stack_win->container;
+
+ CIRCLEQ_FOREACH(client, &(container->clients), clients)
+ num_clients++;
+
+ if (container->mode == MODE_TABBED)
+ destination = (event->event_x / (container->width / num_clients));
+ else if (container->mode == MODE_STACK &&
+ container->stack_limit != STACK_LIMIT_NONE) {
+ if (container->stack_limit == STACK_LIMIT_COLS) {
+ int wrap = ceil((float)num_clients / container->stack_limit_value);
+ int clicked_column = (event->event_x / (stack_win->rect.width / container->stack_limit_value));
+ int clicked_row = (event->event_y / decoration_height);
+ LOG("clicked on column %d, row %d\n", clicked_column, clicked_row);
+ destination = (wrap * clicked_column) + clicked_row;
+ } else {
+ int width = (stack_win->rect.width / ceil((float)num_clients / container->stack_limit_value));
+ int clicked_column = (event->event_x / width);
+ int clicked_row = (event->event_y / decoration_height);
+ LOG("clicked on column %d, row %d\n", clicked_column, clicked_row);
+ destination = (container->stack_limit_value * clicked_column) + clicked_row;
+ }
+ }
+
+ LOG("Click on stack_win for client %d\n", destination);
+ CIRCLEQ_FOREACH(client, &(stack_win->container->clients), clients)
+ if (c++ == destination) {
+ set_focus(conn, client, true);
+ return true;
+ }
+
+ return true;