diff options
Diffstat (limited to 'sway/handlers.c')
-rw-r--r-- | sway/handlers.c | 49 |
1 files changed, 37 insertions, 12 deletions
diff --git a/sway/handlers.c b/sway/handlers.c index 78ca1363..fe7de75b 100644 --- a/sway/handlers.c +++ b/sway/handlers.c | |||
@@ -9,16 +9,16 @@ | |||
9 | #include "commands.h" | 9 | #include "commands.h" |
10 | #include "handlers.h" | 10 | #include "handlers.h" |
11 | 11 | ||
12 | bool handle_output_created(wlc_handle output) { | 12 | static bool handle_output_created(wlc_handle output) { |
13 | add_output(output); | 13 | add_output(output); |
14 | return true; | 14 | return true; |
15 | } | 15 | } |
16 | 16 | ||
17 | void handle_output_destroyed(wlc_handle output) { | 17 | static void handle_output_destroyed(wlc_handle output) { |
18 | destroy_output(output); | 18 | destroy_output(output); |
19 | } | 19 | } |
20 | 20 | ||
21 | void handle_output_resolution_change(wlc_handle output, const struct wlc_size *from, const struct wlc_size *to) { | 21 | static void handle_output_resolution_change(wlc_handle output, const struct wlc_size *from, const struct wlc_size *to) { |
22 | sway_log(L_DEBUG, "Output %d resolution changed to %d x %d", output, to->w, to->h); | 22 | sway_log(L_DEBUG, "Output %d resolution changed to %d x %d", output, to->w, to->h); |
23 | swayc_t *c = get_swayc_for_handle(output, &root_container); | 23 | swayc_t *c = get_swayc_for_handle(output, &root_container); |
24 | if (!c) return; | 24 | if (!c) return; |
@@ -27,7 +27,7 @@ void handle_output_resolution_change(wlc_handle output, const struct wlc_size *f | |||
27 | arrange_windows(&root_container, -1, -1); | 27 | arrange_windows(&root_container, -1, -1); |
28 | } | 28 | } |
29 | 29 | ||
30 | void handle_output_focused(wlc_handle output, bool focus) { | 30 | static void handle_output_focused(wlc_handle output, bool focus) { |
31 | swayc_t *c = get_swayc_for_handle(output, &root_container); | 31 | swayc_t *c = get_swayc_for_handle(output, &root_container); |
32 | if (!c) return; | 32 | if (!c) return; |
33 | if (focus) { | 33 | if (focus) { |
@@ -36,27 +36,26 @@ void handle_output_focused(wlc_handle output, bool focus) { | |||
36 | } | 36 | } |
37 | } | 37 | } |
38 | 38 | ||
39 | bool handle_view_created(wlc_handle view) { | 39 | static bool handle_view_created(wlc_handle view) { |
40 | add_view(view); | 40 | add_view(view); |
41 | return true; | 41 | return true; |
42 | } | 42 | } |
43 | 43 | ||
44 | void handle_view_destroyed(wlc_handle view) { | 44 | static void handle_view_destroyed(wlc_handle view) { |
45 | sway_log(L_DEBUG, "Destroying window %d", view); | 45 | sway_log(L_DEBUG, "Destroying window %d", view); |
46 | destroy_view(get_swayc_for_handle(view, &root_container)); | 46 | destroy_view(get_swayc_for_handle(view, &root_container)); |
47 | return true; | ||
48 | } | 47 | } |
49 | 48 | ||
50 | void handle_view_focus(wlc_handle view, bool focus) { | 49 | static void handle_view_focus(wlc_handle view, bool focus) { |
51 | return; | 50 | return; |
52 | } | 51 | } |
53 | 52 | ||
54 | void handle_view_geometry_request(wlc_handle view, const struct wlc_geometry* geometry) { | 53 | static void handle_view_geometry_request(wlc_handle view, const struct wlc_geometry* geometry) { |
55 | // deny that shit | 54 | // deny that shit |
56 | } | 55 | } |
57 | 56 | ||
58 | 57 | ||
59 | bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifiers | 58 | static bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifiers |
60 | *modifiers, uint32_t key, uint32_t sym, enum wlc_key_state state) { | 59 | *modifiers, uint32_t key, uint32_t sym, enum wlc_key_state state) { |
61 | enum { QSIZE = 32 }; | 60 | enum { QSIZE = 32 }; |
62 | static uint8_t head = 0; | 61 | static uint8_t head = 0; |
@@ -133,7 +132,7 @@ bool pointer_test(swayc_t *view, void *_origin) { | |||
133 | 132 | ||
134 | struct wlc_origin mouse_origin; | 133 | struct wlc_origin mouse_origin; |
135 | 134 | ||
136 | bool handle_pointer_motion(wlc_handle view, uint32_t time, const struct wlc_origin *origin) { | 135 | static bool handle_pointer_motion(wlc_handle view, uint32_t time, const struct wlc_origin *origin) { |
137 | mouse_origin = *origin; | 136 | mouse_origin = *origin; |
138 | if (!config->focus_follows_mouse) { | 137 | if (!config->focus_follows_mouse) { |
139 | return true; | 138 | return true; |
@@ -148,7 +147,7 @@ bool handle_pointer_motion(wlc_handle view, uint32_t time, const struct wlc_orig | |||
148 | return true; | 147 | return true; |
149 | } | 148 | } |
150 | 149 | ||
151 | bool handle_pointer_button(wlc_handle view, uint32_t time, const struct wlc_modifiers *modifiers, | 150 | static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct wlc_modifiers *modifiers, |
152 | uint32_t button, enum wlc_button_state state) { | 151 | uint32_t button, enum wlc_button_state state) { |
153 | if (state == WLC_BUTTON_STATE_PRESSED) { | 152 | if (state == WLC_BUTTON_STATE_PRESSED) { |
154 | swayc_t *c = find_container(&root_container, pointer_test, &mouse_origin); | 153 | swayc_t *c = find_container(&root_container, pointer_test, &mouse_origin); |
@@ -163,3 +162,29 @@ bool handle_pointer_button(wlc_handle view, uint32_t time, const struct wlc_modi | |||
163 | } | 162 | } |
164 | return true; | 163 | return true; |
165 | } | 164 | } |
165 | |||
166 | |||
167 | struct wlc_interface interface = { | ||
168 | .output = { | ||
169 | .created = handle_output_created, | ||
170 | .destroyed = handle_output_destroyed, | ||
171 | .resolution = handle_output_resolution_change, | ||
172 | .focus = handle_output_focused | ||
173 | }, | ||
174 | .view = { | ||
175 | .created = handle_view_created, | ||
176 | .destroyed = handle_view_destroyed, | ||
177 | .focus = handle_view_focus, | ||
178 | .request = { | ||
179 | .geometry = handle_view_geometry_request | ||
180 | } | ||
181 | }, | ||
182 | .keyboard = { | ||
183 | .key = handle_key | ||
184 | }, | ||
185 | .pointer = { | ||
186 | .motion = handle_pointer_motion, | ||
187 | .button = handle_pointer_button | ||
188 | } | ||
189 | }; | ||
190 | |||