mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-19 20:38:08 +01:00
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 <crmafra@gmail.com>
This commit is contained in:
committed by
Carlos R. Mafra
parent
39f6130a28
commit
f40095ac9e
@@ -206,6 +206,11 @@ typedef enum {
|
|||||||
#define WA_OPEN_APPMENU 2
|
#define WA_OPEN_APPMENU 2
|
||||||
#define WA_OPEN_WINLISTMENU 3
|
#define WA_OPEN_WINLISTMENU 3
|
||||||
#define WA_SWITCH_WORKSPACES 4
|
#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 */
|
/* workspace display position */
|
||||||
#define WD_NONE 0
|
#define WD_NONE 0
|
||||||
|
|||||||
@@ -240,12 +240,17 @@ static WOptionEnumeration seMouseButtonActions[] = {
|
|||||||
{"SelectWindows", WA_SELECT_WINDOWS, 0},
|
{"SelectWindows", WA_SELECT_WINDOWS, 0},
|
||||||
{"OpenApplicationsMenu", WA_OPEN_APPMENU, 0},
|
{"OpenApplicationsMenu", WA_OPEN_APPMENU, 0},
|
||||||
{"OpenWindowListMenu", WA_OPEN_WINLISTMENU, 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}
|
{NULL, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
static WOptionEnumeration seMouseWheelActions[] = {
|
static WOptionEnumeration seMouseWheelActions[] = {
|
||||||
{"None", WA_NONE, 0},
|
{"None", WA_NONE, 0},
|
||||||
{"SwitchWorkspaces", WA_SWITCH_WORKSPACES, 0},
|
{"SwitchWorkspaces", WA_SWITCH_WORKSPACES, 0},
|
||||||
|
{"SwitchWindows", WA_SWITCH_WINDOWS, 0},
|
||||||
{NULL, 0, 0}
|
{NULL, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
54
src/event.c
54
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) {
|
switch (action) {
|
||||||
case WA_SELECT_WINDOWS:
|
case WA_SELECT_WINDOWS:
|
||||||
wUnselectWindows(scr);
|
wUnselectWindows(scr);
|
||||||
@@ -728,7 +758,19 @@ static void executeButtonAction(WScreen * scr, XEvent * event, int action)
|
|||||||
event->xbutton.window = scr->switch_menu->frame->core->window;
|
event->xbutton.window = scr->switch_menu->frame->core->window;
|
||||||
}
|
}
|
||||||
break;
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -757,13 +799,13 @@ static void handleButtonPress(XEvent * event)
|
|||||||
}else if (event->xbutton.button == Button9 && wPreferences.mouse_button9 != WA_NONE) {
|
}else if (event->xbutton.button == Button9 && wPreferences.mouse_button9 != WA_NONE) {
|
||||||
executeButtonAction(scr, event, wPreferences.mouse_button9);
|
executeButtonAction(scr, event, wPreferences.mouse_button9);
|
||||||
} else if (event->xbutton.button == Button4 && wPreferences.mouse_wheel_scroll != WA_NONE) {
|
} 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) {
|
} 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) {
|
} 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) {
|
} else if (event->xbutton.button == Button7 && wPreferences.mouse_wheel_tilt != WA_NONE) {
|
||||||
wWorkspaceRelativeChange(scr, 1);
|
executeWheelAction(scr, event, wPreferences.mouse_wheel_tilt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user