4
4
#include <wlr/config.h>
5
5
#include <wlr/backend/multi.h>
6
6
#include <wlr/interfaces/wlr_keyboard.h>
7
+ #include <wlr/types/wlr_cursor.h>
7
8
#include <wlr/types/wlr_keyboard.h>
8
9
#include <wlr/types/wlr_keyboard_group.h>
9
10
#include <xkbcommon/xkbcommon-names.h>
@@ -267,6 +268,7 @@ static bool keyboard_execute_compositor_binding(struct sway_keyboard *keyboard,
267
268
const xkb_keysym_t * pressed_keysyms , uint32_t modifiers , size_t keysyms_len ) {
268
269
for (size_t i = 0 ; i < keysyms_len ; ++ i ) {
269
270
xkb_keysym_t keysym = pressed_keysyms [i ];
271
+
270
272
if (keysym >= XKB_KEY_XF86Switch_VT_1 &&
271
273
keysym <= XKB_KEY_XF86Switch_VT_12 ) {
272
274
#if WLR_HAS_SESSION
@@ -282,6 +284,36 @@ static bool keyboard_execute_compositor_binding(struct sway_keyboard *keyboard,
282
284
return false;
283
285
}
284
286
287
+ static bool keyboard_execute_pointer_keysyms (struct sway_keyboard * keyboard ,
288
+ uint32_t time , const xkb_keysym_t * pressed_keysyms , size_t keysyms_len ,
289
+ enum wl_keyboard_key_state state ) {
290
+ struct sway_cursor * cursor = keyboard -> seat_device -> sway_seat -> cursor ;
291
+
292
+ for (size_t i = 0 ; i < keysyms_len ; ++ i ) {
293
+ xkb_keysym_t keysym = pressed_keysyms [i ];
294
+
295
+ uint32_t button = wlr_keyboard_keysym_to_pointer_button (keysym );
296
+ if (button != 0 ) {
297
+ dispatch_cursor_button (cursor , & keyboard -> wlr -> base , time , button ,
298
+ (enum wl_pointer_button_state )state );
299
+ wlr_seat_pointer_notify_frame (cursor -> seat -> wlr_seat );
300
+ return true;
301
+ }
302
+
303
+ int dx , dy ;
304
+ wlr_keyboard_keysym_to_pointer_motion (keysym , & dx , & dy );
305
+ if (state == WL_KEYBOARD_KEY_STATE_PRESSED && (dx != 0 || dy != 0 )) {
306
+ dx *= 10 ;
307
+ dy *= 10 ;
308
+ pointer_motion (cursor , time , & keyboard -> wlr -> base , dx , dy , dx , dy );
309
+ wlr_seat_pointer_notify_frame (cursor -> seat -> wlr_seat );
310
+ return true;
311
+ }
312
+ }
313
+
314
+ return false;
315
+ }
316
+
285
317
/**
286
318
* Get keysyms and modifiers from the keyboard as xkb sees them.
287
319
*
@@ -507,6 +539,11 @@ static void handle_key_event(struct sway_keyboard *keyboard,
507
539
keyboard , keyinfo .raw_keysyms , keyinfo .raw_modifiers ,
508
540
keyinfo .raw_keysyms_len );
509
541
}
542
+ if (!handled ) {
543
+ handled = keyboard_execute_pointer_keysyms (keyboard , event -> time_msec ,
544
+ keyinfo .translated_keysyms , keyinfo .translated_keysyms_len ,
545
+ event -> state );
546
+ }
510
547
511
548
if (event -> state == WL_KEYBOARD_KEY_STATE_RELEASED ) {
512
549
// If the pressed event was sent to a client and we have a focused
0 commit comments