mirror of
https://codeberg.org/dwl/dwl.git
synced 2025-10-28 02:34:15 +00:00
Implement Axis mouse bindings
This commit is contained in:
parent
1002ea04fa
commit
7a79ba8df3
@ -173,3 +173,7 @@ static const Button buttons[] = {
|
|||||||
{ MODKEY, BTN_MIDDLE, togglefloating, {0} },
|
{ MODKEY, BTN_MIDDLE, togglefloating, {0} },
|
||||||
{ MODKEY, BTN_RIGHT, moveresize, {.ui = CurResize} },
|
{ MODKEY, BTN_RIGHT, moveresize, {.ui = CurResize} },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const Axis axes[] = {
|
||||||
|
{ MODKEY, AxisUp, spawn, SHCMD("volume-up_EXAMPLE") },
|
||||||
|
};
|
||||||
|
|||||||
30
dwl.c
30
dwl.c
@ -84,6 +84,7 @@
|
|||||||
enum { CurNormal, CurPressed, CurMove, CurResize }; /* cursor */
|
enum { CurNormal, CurPressed, CurMove, CurResize }; /* cursor */
|
||||||
enum { XDGShell, LayerShell, X11 }; /* client types */
|
enum { XDGShell, LayerShell, X11 }; /* client types */
|
||||||
enum { LyrBg, LyrBottom, LyrTile, LyrFloat, LyrTop, LyrFS, LyrOverlay, LyrBlock, NUM_LAYERS }; /* scene layers */
|
enum { LyrBg, LyrBottom, LyrTile, LyrFloat, LyrTop, LyrFS, LyrOverlay, LyrBlock, NUM_LAYERS }; /* scene layers */
|
||||||
|
enum { AxisUp, AxisRight, AxisDown, AxisLeft };
|
||||||
#ifdef XWAYLAND
|
#ifdef XWAYLAND
|
||||||
enum { NetWMWindowTypeDialog, NetWMWindowTypeSplash, NetWMWindowTypeToolbar,
|
enum { NetWMWindowTypeDialog, NetWMWindowTypeSplash, NetWMWindowTypeToolbar,
|
||||||
NetWMWindowTypeUtility, NetLast }; /* EWMH atoms */
|
NetWMWindowTypeUtility, NetLast }; /* EWMH atoms */
|
||||||
@ -96,6 +97,13 @@ typedef union {
|
|||||||
const void *v;
|
const void *v;
|
||||||
} Arg;
|
} Arg;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
unsigned int mod;
|
||||||
|
unsigned int dir;
|
||||||
|
void (*func)(const Arg *);
|
||||||
|
const Arg arg;
|
||||||
|
} Axis;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
unsigned int mod;
|
unsigned int mod;
|
||||||
unsigned int button;
|
unsigned int button;
|
||||||
@ -584,9 +592,27 @@ axisnotify(struct wl_listener *listener, void *data)
|
|||||||
/* This event is forwarded by the cursor when a pointer emits an axis event,
|
/* This event is forwarded by the cursor when a pointer emits an axis event,
|
||||||
* for example when you move the scroll wheel. */
|
* for example when you move the scroll wheel. */
|
||||||
struct wlr_pointer_axis_event *event = data;
|
struct wlr_pointer_axis_event *event = data;
|
||||||
|
const Axis *a;
|
||||||
|
unsigned int adir;
|
||||||
|
struct wlr_keyboard *keyboard;
|
||||||
|
uint32_t mods;
|
||||||
|
|
||||||
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
|
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
|
||||||
/* TODO: allow usage of scroll whell for mousebindings, it can be implemented
|
|
||||||
* checking the event's orientation and the delta of the event */
|
if (event->orientation == WLR_AXIS_ORIENTATION_VERTICAL)
|
||||||
|
adir = event->delta > 0 ? AxisDown : AxisUp;
|
||||||
|
else
|
||||||
|
adir = event->delta > 0 ? AxisRight : AxisLeft;
|
||||||
|
keyboard = wlr_seat_get_keyboard(seat);
|
||||||
|
mods = keyboard ? wlr_keyboard_get_modifiers(keyboard) : 0;
|
||||||
|
for (a = axes; a < END(axes); a++) {
|
||||||
|
if (CLEANMASK(mods) == CLEANMASK(a->mod) &&
|
||||||
|
adir == a->dir && a->func) {
|
||||||
|
a->func(&a->arg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Notify the client with pointer focus of the axis event. */
|
/* Notify the client with pointer focus of the axis event. */
|
||||||
wlr_seat_pointer_notify_axis(seat,
|
wlr_seat_pointer_notify_axis(seat,
|
||||||
event->time_msec, event->orientation, event->delta,
|
event->time_msec, event->orientation, event->delta,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user