Implement scrolling on stack windows and on the bar. This implements ticket #18
This commit is contained in:
parent
75a35319c9
commit
755540817e
@ -13,6 +13,7 @@
|
|||||||
#ifndef _COMMANDS_H
|
#ifndef _COMMANDS_H
|
||||||
#define _COMMANDS_H
|
#define _COMMANDS_H
|
||||||
|
|
||||||
|
bool focus_window_in_container(xcb_connection_t *conn, Container *container, direction_t direction);
|
||||||
void show_workspace(xcb_connection_t *conn, int workspace);
|
void show_workspace(xcb_connection_t *conn, int workspace);
|
||||||
void parse_command(xcb_connection_t *conn, const char *command);
|
void parse_command(xcb_connection_t *conn, const char *command);
|
||||||
|
|
||||||
|
@ -24,8 +24,7 @@
|
|||||||
#include "i3.h"
|
#include "i3.h"
|
||||||
#include "xinerama.h"
|
#include "xinerama.h"
|
||||||
|
|
||||||
static bool focus_window_in_container(xcb_connection_t *conn, Container *container,
|
bool focus_window_in_container(xcb_connection_t *conn, Container *container, direction_t direction) {
|
||||||
direction_t direction) {
|
|
||||||
/* If this container is empty, we’re done */
|
/* If this container is empty, we’re done */
|
||||||
if (container->currently_focused == NULL)
|
if (container->currently_focused == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
@ -199,9 +199,19 @@ int handle_enter_notify(void *ignored, xcb_connection_t *conn, xcb_enter_notify_
|
|||||||
*/
|
*/
|
||||||
static bool button_press_stackwin(xcb_connection_t *conn, xcb_button_press_event_t *event) {
|
static bool button_press_stackwin(xcb_connection_t *conn, xcb_button_press_event_t *event) {
|
||||||
struct Stack_Window *stack_win;
|
struct Stack_Window *stack_win;
|
||||||
SLIST_FOREACH(stack_win, &stack_wins, stack_windows)
|
SLIST_FOREACH(stack_win, &stack_wins, stack_windows) {
|
||||||
if (stack_win->window == event->event) {
|
if (stack_win->window != event->event)
|
||||||
/* A stack window was clicked. We calculate the destination client by
|
continue;
|
||||||
|
|
||||||
|
/* A stack window was clicked, we check if it was button4 or button5
|
||||||
|
which are scroll up / scroll down. */
|
||||||
|
if (event->detail == XCB_BUTTON_INDEX_4 || event->detail == XCB_BUTTON_INDEX_5) {
|
||||||
|
direction_t direction = (event->detail == XCB_BUTTON_INDEX_4 ? D_UP : D_DOWN);
|
||||||
|
focus_window_in_container(conn, CUR_CELL, direction);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* It was no scrolling, so we calculate the destination client by
|
||||||
dividing the Y position of the event through the height of a window
|
dividing the Y position of the event through the height of a window
|
||||||
decoration and then set the focus to this client. */
|
decoration and then set the focus to this client. */
|
||||||
i3Font *font = load_font(conn, config.font);
|
i3Font *font = load_font(conn, config.font);
|
||||||
@ -230,9 +240,21 @@ static bool button_press_stackwin(xcb_connection_t *conn, xcb_button_press_event
|
|||||||
*/
|
*/
|
||||||
static bool button_press_bar(xcb_connection_t *conn, xcb_button_press_event_t *event) {
|
static bool button_press_bar(xcb_connection_t *conn, xcb_button_press_event_t *event) {
|
||||||
i3Screen *screen;
|
i3Screen *screen;
|
||||||
TAILQ_FOREACH(screen, virtual_screens, screens)
|
TAILQ_FOREACH(screen, virtual_screens, screens) {
|
||||||
if (screen->bar == event->event) {
|
if (screen->bar != event->event)
|
||||||
|
continue;
|
||||||
|
|
||||||
LOG("Click on a bar\n");
|
LOG("Click on a bar\n");
|
||||||
|
|
||||||
|
/* Check if the button was one of button4 or button5 (scroll up / scroll down) */
|
||||||
|
if (event->detail == XCB_BUTTON_INDEX_4 || event->detail == XCB_BUTTON_INDEX_5) {
|
||||||
|
int dest_workspace = (event->detail == XCB_BUTTON_INDEX_4 ?
|
||||||
|
c_ws->num - 1 :
|
||||||
|
c_ws->num + 1);
|
||||||
|
if ((dest_workspace >= 0) && (dest_workspace < 10))
|
||||||
|
show_workspace(conn, dest_workspace+1);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
i3Font *font = load_font(conn, config.font);
|
i3Font *font = load_font(conn, config.font);
|
||||||
int workspace = event->event_x / (font->height + 6),
|
int workspace = event->event_x / (font->height + 6),
|
||||||
c = 0;
|
c = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user