diff options
Diffstat (limited to 'sway/handlers.c')
-rw-r--r-- | sway/handlers.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/sway/handlers.c b/sway/handlers.c index d26ce5f3..0bb4f613 100644 --- a/sway/handlers.c +++ b/sway/handlers.c | |||
@@ -17,6 +17,12 @@ | |||
17 | #include "input_state.h" | 17 | #include "input_state.h" |
18 | #include "resize.h" | 18 | #include "resize.h" |
19 | 19 | ||
20 | // Event should be sent to client | ||
21 | #define EVENT_PASSTHROUGH false | ||
22 | |||
23 | // Event handled by sway and should not be sent to client | ||
24 | #define EVENT_HANDLED true | ||
25 | |||
20 | static bool pointer_test(swayc_t *view, void *_origin) { | 26 | static bool pointer_test(swayc_t *view, void *_origin) { |
21 | const struct mouse_origin *origin = _origin; | 27 | const struct mouse_origin *origin = _origin; |
22 | // Determine the output that the view is under | 28 | // Determine the output that the view is under |
@@ -276,7 +282,7 @@ static bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifier | |||
276 | uint32_t key, uint32_t sym, enum wlc_key_state state) { | 282 | uint32_t key, uint32_t sym, enum wlc_key_state state) { |
277 | 283 | ||
278 | if (locked_view_focus && state == WLC_KEY_STATE_PRESSED) { | 284 | if (locked_view_focus && state == WLC_KEY_STATE_PRESSED) { |
279 | return false; | 285 | return EVENT_PASSTHROUGH; |
280 | } | 286 | } |
281 | 287 | ||
282 | // reset pointer mode on keypress | 288 | // reset pointer mode on keypress |
@@ -289,7 +295,7 @@ static bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifier | |||
289 | if (sym < 70000 /* bullshit made up number */) { | 295 | if (sym < 70000 /* bullshit made up number */) { |
290 | if (!isalnum(sym) && sym != ' ' && sym != XKB_KEY_Escape && sym != XKB_KEY_Tab) { | 296 | if (!isalnum(sym) && sym != ' ' && sym != XKB_KEY_Escape && sym != XKB_KEY_Tab) { |
291 | // God fucking dammit | 297 | // God fucking dammit |
292 | return false; | 298 | return EVENT_PASSTHROUGH; |
293 | } | 299 | } |
294 | } | 300 | } |
295 | 301 | ||
@@ -320,14 +326,14 @@ static bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifier | |||
320 | if (match) { | 326 | if (match) { |
321 | if (state == WLC_KEY_STATE_PRESSED) { | 327 | if (state == WLC_KEY_STATE_PRESSED) { |
322 | handle_command(config, binding->command); | 328 | handle_command(config, binding->command); |
323 | return true; | 329 | return EVENT_HANDLED; |
324 | } else if (state == WLC_KEY_STATE_RELEASED) { | 330 | } else if (state == WLC_KEY_STATE_RELEASED) { |
325 | // TODO: --released | 331 | // TODO: --released |
326 | } | 332 | } |
327 | } | 333 | } |
328 | } | 334 | } |
329 | } | 335 | } |
330 | return false; | 336 | return EVENT_PASSTHROUGH; |
331 | } | 337 | } |
332 | 338 | ||
333 | static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct wlc_origin *origin) { | 339 | static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct wlc_origin *origin) { |
@@ -351,13 +357,12 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct | |||
351 | set_focused_container(pointer_state.view); | 357 | set_focused_container(pointer_state.view); |
352 | } | 358 | } |
353 | } | 359 | } |
354 | return false; | 360 | return EVENT_PASSTHROUGH; |
355 | } | 361 | } |
356 | 362 | ||
357 | 363 | ||
358 | static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct wlc_modifiers *modifiers, | 364 | static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct wlc_modifiers *modifiers, |
359 | uint32_t button, enum wlc_button_state state, const struct wlc_origin *origin) { | 365 | uint32_t button, enum wlc_button_state state, const struct wlc_origin *origin) { |
360 | enum { DONT_SEND_CLICK = true, SEND_CLICK = false }; | ||
361 | 366 | ||
362 | // Update view pointer is on | 367 | // Update view pointer is on |
363 | pointer_state.view = container_under_pointer(); | 368 | pointer_state.view = container_under_pointer(); |
@@ -412,7 +417,7 @@ static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct w | |||
412 | 417 | ||
413 | // dont change focus or mode if fullscreen | 418 | // dont change focus or mode if fullscreen |
414 | if (swayc_is_fullscreen(focused)) { | 419 | if (swayc_is_fullscreen(focused)) { |
415 | return SEND_CLICK; | 420 | return EVENT_PASSTHROUGH; |
416 | } | 421 | } |
417 | 422 | ||
418 | // set pointer mode | 423 | // set pointer mode |
@@ -421,12 +426,12 @@ static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct w | |||
421 | 426 | ||
422 | // Return if mode has been set | 427 | // Return if mode has been set |
423 | if (pointer_state.mode) { | 428 | if (pointer_state.mode) { |
424 | return DONT_SEND_CLICK; | 429 | return EVENT_HANDLED; |
425 | } | 430 | } |
426 | 431 | ||
427 | // Always send mouse release | 432 | // Always send mouse release |
428 | if (state == WLC_BUTTON_STATE_RELEASED) { | 433 | if (state == WLC_BUTTON_STATE_RELEASED) { |
429 | return SEND_CLICK; | 434 | return EVENT_PASSTHROUGH; |
430 | } | 435 | } |
431 | 436 | ||
432 | // Check whether to change focus | 437 | // Check whether to change focus |
@@ -448,7 +453,7 @@ static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct w | |||
448 | } | 453 | } |
449 | 454 | ||
450 | // Finally send click | 455 | // Finally send click |
451 | return SEND_CLICK; | 456 | return EVENT_PASSTHROUGH; |
452 | } | 457 | } |
453 | 458 | ||
454 | static void handle_wlc_ready(void) { | 459 | static void handle_wlc_ready(void) { |