diff options
author | 2015-08-23 15:38:51 -0400 | |
---|---|---|
committer | 2015-08-23 15:38:51 -0400 | |
commit | 9a7f48f87272dea8cb1e678673b2fe95dc993d68 (patch) | |
tree | 1a9e633ead0ff50f55987310621dab39531d2305 /include/input_state.h | |
parent | Refactor keyboard to consider modified keysyms (diff) | |
parent | merge (diff) | |
download | sway-9a7f48f87272dea8cb1e678673b2fe95dc993d68.tar.gz sway-9a7f48f87272dea8cb1e678673b2fe95dc993d68.tar.zst sway-9a7f48f87272dea8cb1e678673b2fe95dc993d68.zip |
Merge pull request #121 from taiyu-len/pointer_mod
Pointer mode clean and fix.
Diffstat (limited to 'include/input_state.h')
-rw-r--r-- | include/input_state.h | 72 |
1 files changed, 47 insertions, 25 deletions
diff --git a/include/input_state.h b/include/input_state.h index 29064fd0..d87ae18c 100644 --- a/include/input_state.h +++ b/include/input_state.h | |||
@@ -15,6 +15,7 @@ void press_key(uint32_t key_sym, uint32_t key_code); | |||
15 | // unsets a key as pressed | 15 | // unsets a key as pressed |
16 | void release_key(uint32_t key_sym, uint32_t key_code); | 16 | void release_key(uint32_t key_sym, uint32_t key_code); |
17 | 17 | ||
18 | |||
18 | /* Pointer state */ | 19 | /* Pointer state */ |
19 | 20 | ||
20 | enum pointer_values { | 21 | enum pointer_values { |
@@ -25,34 +26,55 @@ enum pointer_values { | |||
25 | M_SCROLL_DOWN = 276, | 26 | M_SCROLL_DOWN = 276, |
26 | }; | 27 | }; |
27 | 28 | ||
29 | enum pointer_mode { | ||
30 | // Target | ||
31 | M_FLOATING = 1, | ||
32 | M_TILING = 2, | ||
33 | // Action | ||
34 | M_DRAGGING = 4, | ||
35 | M_RESIZING = 8, | ||
36 | }; | ||
37 | |||
38 | struct pointer_button_state { | ||
39 | bool held; | ||
40 | // state at the point it was pressed | ||
41 | int x, y; | ||
42 | swayc_t *view; | ||
43 | }; | ||
44 | |||
28 | extern struct pointer_state { | 45 | extern struct pointer_state { |
29 | bool l_held; | 46 | // mouse clicks |
30 | bool r_held; | 47 | struct pointer_button_state left; |
31 | struct pointer_floating { | 48 | struct pointer_button_state right; |
32 | bool drag; | 49 | struct pointer_button_state scroll; |
33 | bool resize; | 50 | |
34 | } floating; | 51 | // pointer position |
35 | struct pointer_tiling { | 52 | struct mouse_origin{ |
36 | bool resize; | 53 | int x, y; |
37 | swayc_t *init_view; | 54 | } origin; |
38 | struct wlc_origin lock_pos; | 55 | |
39 | } tiling; | 56 | // change in pointer position |
40 | struct pointer_lock { | 57 | struct { |
41 | // Lock movement for certain edges | 58 | int x, y; |
42 | bool left; | 59 | } delta; |
43 | bool right; | 60 | |
44 | bool top; | 61 | // view pointer is currently over |
45 | bool bottom; | 62 | swayc_t *view; |
46 | // Lock movement in certain directions | 63 | |
47 | bool temp_left; | 64 | // Pointer mode |
48 | bool temp_right; | 65 | int mode; |
49 | bool temp_up; | ||
50 | bool temp_down; | ||
51 | } lock; | ||
52 | } pointer_state; | 66 | } pointer_state; |
53 | 67 | ||
54 | void start_floating(swayc_t *view); | 68 | // on button release unset mode depending on the button. |
55 | void reset_floating(swayc_t *view); | 69 | // on button press set mode conditionally depending on the button |
70 | void pointer_mode_set(uint32_t button, bool condition); | ||
71 | |||
72 | // Update mode in mouse motion | ||
73 | void pointer_mode_update(void); | ||
74 | |||
75 | // Reset mode on any keypress; | ||
76 | void pointer_mode_reset(void); | ||
77 | |||
56 | void input_init(void); | 78 | void input_init(void); |
57 | 79 | ||
58 | #endif | 80 | #endif |