From f40095ac9e6e1c27b9d50d4a05a2e08d44758f48 Mon Sep 17 00:00:00 2001 From: David Maciejak Date: Thu, 11 Sep 2014 07:19:12 +0700 Subject: [PATCH] wmaker: add new button and wheel mouse actions This patch is adding atomic mouse actions to mouse buttons to: -focus on previous or next window -move to previous or next workspace and adding wheel action to -switch between windows Signed-off-by: Carlos R. Mafra --- src/WindowMaker.h | 5 +++++ src/defaults.c | 5 +++++ src/event.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++------ 3 files changed, 58 insertions(+), 6 deletions(-) diff --git a/src/WindowMaker.h b/src/WindowMaker.h index 5d850dbe..9af3a394 100644 --- a/src/WindowMaker.h +++ b/src/WindowMaker.h @@ -206,6 +206,11 @@ typedef enum { #define WA_OPEN_APPMENU 2 #define WA_OPEN_WINLISTMENU 3 #define WA_SWITCH_WORKSPACES 4 +#define WA_MOVE_PREVWORKSPACE 5 +#define WA_MOVE_NEXTWORKSPACE 6 +#define WA_SWITCH_WINDOWS 7 +#define WA_MOVE_PREVWINDOW 8 +#define WA_MOVE_NEXTWINDOW 9 /* workspace display position */ #define WD_NONE 0 diff --git a/src/defaults.c b/src/defaults.c index df7e9191..72c8b6f3 100644 --- a/src/defaults.c +++ b/src/defaults.c @@ -240,12 +240,17 @@ static WOptionEnumeration seMouseButtonActions[] = { {"SelectWindows", WA_SELECT_WINDOWS, 0}, {"OpenApplicationsMenu", WA_OPEN_APPMENU, 0}, {"OpenWindowListMenu", WA_OPEN_WINLISTMENU, 0}, + {"MoveToPrevWorkspace", WA_MOVE_PREVWORKSPACE, 0}, + {"MoveToNextWorkspace", WA_MOVE_NEXTWORKSPACE, 0}, + {"MoveToPrevWindow", WA_MOVE_PREVWINDOW, 0}, + {"MoveToNextWindow", WA_MOVE_NEXTWINDOW, 0}, {NULL, 0, 0} }; static WOptionEnumeration seMouseWheelActions[] = { {"None", WA_NONE, 0}, {"SwitchWorkspaces", WA_SWITCH_WORKSPACES, 0}, + {"SwitchWindows", WA_SWITCH_WINDOWS, 0}, {NULL, 0, 0} }; diff --git a/src/event.c b/src/event.c index 0ec1b770..6e50affc 100644 --- a/src/event.c +++ b/src/event.c @@ -702,8 +702,38 @@ static void handleExpose(XEvent * event) } } -static void executeButtonAction(WScreen * scr, XEvent * event, int action) +static void executeWheelAction(WScreen *scr, XEvent *event, int action) { + WWindow *wwin; + Bool next_direction; + + if (event->xbutton.button == Button5 || event->xbutton.button == Button6) + next_direction = False; + else + next_direction = True; + + switch (action) { + case WA_SWITCH_WORKSPACES: + if (next_direction) + wWorkspaceRelativeChange(scr, 1); + else + wWorkspaceRelativeChange(scr, -1); + break; + + case WA_SWITCH_WINDOWS: + wwin = scr->focused_window; + if (next_direction) + wWindowFocusNext(wwin, True); + else + wWindowFocusPrev(wwin, True); + break; + } +} + +static void executeButtonAction(WScreen *scr, XEvent *event, int action) +{ + WWindow *wwin; + switch (action) { case WA_SELECT_WINDOWS: wUnselectWindows(scr); @@ -728,7 +758,19 @@ static void executeButtonAction(WScreen * scr, XEvent * event, int action) event->xbutton.window = scr->switch_menu->frame->core->window; } break; - default: + case WA_MOVE_PREVWORKSPACE: + wWorkspaceRelativeChange(scr, -1); + break; + case WA_MOVE_NEXTWORKSPACE: + wWorkspaceRelativeChange(scr, 1); + break; + case WA_MOVE_PREVWINDOW: + wwin = scr->focused_window; + wWindowFocusPrev(wwin, True); + break; + case WA_MOVE_NEXTWINDOW: + wwin = scr->focused_window; + wWindowFocusNext(wwin, True); break; } } @@ -757,13 +799,13 @@ static void handleButtonPress(XEvent * event) }else if (event->xbutton.button == Button9 && wPreferences.mouse_button9 != WA_NONE) { executeButtonAction(scr, event, wPreferences.mouse_button9); } else if (event->xbutton.button == Button4 && wPreferences.mouse_wheel_scroll != WA_NONE) { - wWorkspaceRelativeChange(scr, 1); + executeWheelAction(scr, event, wPreferences.mouse_wheel_scroll); } else if (event->xbutton.button == Button5 && wPreferences.mouse_wheel_scroll != WA_NONE) { - wWorkspaceRelativeChange(scr, -1); + executeWheelAction(scr, event, wPreferences.mouse_wheel_scroll); } else if (event->xbutton.button == Button6 && wPreferences.mouse_wheel_tilt != WA_NONE) { - wWorkspaceRelativeChange(scr, -1); + executeWheelAction(scr, event, wPreferences.mouse_wheel_tilt); } else if (event->xbutton.button == Button7 && wPreferences.mouse_wheel_tilt != WA_NONE) { - wWorkspaceRelativeChange(scr, 1); + executeWheelAction(scr, event, wPreferences.mouse_wheel_tilt); } } -- 2.11.4.GIT