diff options
author | 2015-08-12 20:59:43 -0700 | |
---|---|---|
committer | 2015-08-12 20:59:43 -0700 | |
commit | 0f387483fd6b4ce40514578ab008bfabc84b015d (patch) | |
tree | cb47c80760d565ab69503dec86129045a7c0011b | |
parent | Merge pull request #18 from taiyu-len/master (diff) | |
download | sway-0f387483fd6b4ce40514578ab008bfabc84b015d.tar.gz sway-0f387483fd6b4ce40514578ab008bfabc84b015d.tar.zst sway-0f387483fd6b4ce40514578ab008bfabc84b015d.zip |
moving stuff around
-rw-r--r-- | sway/handlers.c | 49 | ||||
-rw-r--r-- | sway/handlers.h | 17 | ||||
-rw-r--r-- | sway/main.c | 25 |
3 files changed, 38 insertions, 53 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 | |||
diff --git a/sway/handlers.h b/sway/handlers.h index 9792b6d7..798b3b50 100644 --- a/sway/handlers.h +++ b/sway/handlers.h | |||
@@ -4,21 +4,6 @@ | |||
4 | #include <stdbool.h> | 4 | #include <stdbool.h> |
5 | #include <wlc/wlc.h> | 5 | #include <wlc/wlc.h> |
6 | 6 | ||
7 | bool handle_output_created(wlc_handle output); | 7 | extern struct wlc_interface interface; |
8 | void handle_output_destroyed(wlc_handle output); | ||
9 | void handle_output_resolution_change(wlc_handle output, const struct wlc_size *from, const struct wlc_size *to); | ||
10 | void handle_output_focused(wlc_handle output, bool focus); | ||
11 | |||
12 | bool handle_view_created(wlc_handle view); | ||
13 | void handle_view_destroyed(wlc_handle view); | ||
14 | void handle_view_focus(wlc_handle view, bool focus); | ||
15 | void handle_view_geometry_request(wlc_handle view, const struct wlc_geometry* geometry); | ||
16 | |||
17 | bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifiers | ||
18 | *modifiers, uint32_t key, uint32_t sym, enum wlc_key_state state); | ||
19 | |||
20 | bool handle_pointer_motion(wlc_handle view, uint32_t time, const struct wlc_origin *origin); | ||
21 | bool handle_pointer_button(wlc_handle view, uint32_t time, const struct wlc_modifiers *modifiers, | ||
22 | uint32_t button, enum wlc_button_state state); | ||
23 | 8 | ||
24 | #endif | 9 | #endif |
diff --git a/sway/main.c b/sway/main.c index a7814364..7661551d 100644 --- a/sway/main.c +++ b/sway/main.c | |||
@@ -12,31 +12,6 @@ int main(int argc, char **argv) { | |||
12 | init_log(L_DEBUG); // TODO: Control this with command line arg | 12 | init_log(L_DEBUG); // TODO: Control this with command line arg |
13 | init_layout(); | 13 | init_layout(); |
14 | 14 | ||
15 | static struct wlc_interface interface = { | ||
16 | .output = { | ||
17 | .created = handle_output_created, | ||
18 | .destroyed = handle_output_destroyed, | ||
19 | .resolution = handle_output_resolution_change, | ||
20 | .focus = handle_output_focused | ||
21 | }, | ||
22 | .view = { | ||
23 | .created = handle_view_created, | ||
24 | .destroyed = handle_view_destroyed, | ||
25 | .focus = handle_view_focus, | ||
26 | .request = { | ||
27 | .geometry = handle_view_geometry_request | ||
28 | } | ||
29 | }, | ||
30 | .keyboard = { | ||
31 | .key = handle_key | ||
32 | }, | ||
33 | .pointer = { | ||
34 | .motion = handle_pointer_motion, | ||
35 | .button = handle_pointer_button | ||
36 | } | ||
37 | |||
38 | }; | ||
39 | |||
40 | setenv("WLC_DIM", "0", 0); | 15 | setenv("WLC_DIM", "0", 0); |
41 | if (!wlc_init(&interface, argc, argv)) { | 16 | if (!wlc_init(&interface, argc, argv)) { |
42 | return 1; | 17 | return 1; |