diff options
Diffstat (limited to 'sway/handlers.c')
-rw-r--r-- | sway/handlers.c | 49 |
1 files changed, 24 insertions, 25 deletions
diff --git a/sway/handlers.c b/sway/handlers.c index ebfd22ad..cd97ab43 100644 --- a/sway/handlers.c +++ b/sway/handlers.c | |||
@@ -23,7 +23,7 @@ static bool m2_held = false; | |||
23 | 23 | ||
24 | static bool pointer_test(swayc_t *view, void *_origin) { | 24 | static bool pointer_test(swayc_t *view, void *_origin) { |
25 | const struct wlc_origin *origin = _origin; | 25 | const struct wlc_origin *origin = _origin; |
26 | //Determine the output that the view is under | 26 | // Determine the output that the view is under |
27 | swayc_t *parent = view; | 27 | swayc_t *parent = view; |
28 | while (parent->type != C_OUTPUT) { | 28 | while (parent->type != C_OUTPUT) { |
29 | parent = parent->parent; | 29 | parent = parent->parent; |
@@ -37,25 +37,25 @@ static bool pointer_test(swayc_t *view, void *_origin) { | |||
37 | } | 37 | } |
38 | 38 | ||
39 | swayc_t *container_under_pointer(void) { | 39 | swayc_t *container_under_pointer(void) { |
40 | //root.output->workspace | 40 | // root.output->workspace |
41 | if (!root_container.focused || !root_container.focused->focused) { | 41 | if (!root_container.focused || !root_container.focused->focused) { |
42 | return NULL; | 42 | return NULL; |
43 | } | 43 | } |
44 | swayc_t *lookup = root_container.focused->focused; | 44 | swayc_t *lookup = root_container.focused->focused; |
45 | //Case of empty workspace | 45 | // Case of empty workspace |
46 | if (lookup->children == 0) { | 46 | if (lookup->children == 0) { |
47 | return NULL; | 47 | return NULL; |
48 | } | 48 | } |
49 | while (lookup->type != C_VIEW) { | 49 | while (lookup->type != C_VIEW) { |
50 | int i; | 50 | int i; |
51 | int len; | 51 | int len; |
52 | //if tabbed/stacked go directly to focused container, otherwise search | 52 | // if tabbed/stacked go directly to focused container, otherwise search |
53 | //children | 53 | // children |
54 | if (lookup->layout == L_TABBED || lookup->layout == L_STACKED) { | 54 | if (lookup->layout == L_TABBED || lookup->layout == L_STACKED) { |
55 | lookup = lookup->focused; | 55 | lookup = lookup->focused; |
56 | continue; | 56 | continue; |
57 | } | 57 | } |
58 | //if workspace, search floating | 58 | // if workspace, search floating |
59 | if (lookup->type == C_WORKSPACE) { | 59 | if (lookup->type == C_WORKSPACE) { |
60 | len = lookup->floating->length; | 60 | len = lookup->floating->length; |
61 | for (i = 0; i < len; ++i) { | 61 | for (i = 0; i < len; ++i) { |
@@ -68,7 +68,7 @@ swayc_t *container_under_pointer(void) { | |||
68 | continue; | 68 | continue; |
69 | } | 69 | } |
70 | } | 70 | } |
71 | //search children | 71 | // search children |
72 | len = lookup->children->length; | 72 | len = lookup->children->length; |
73 | for (i = 0; i < len; ++i) { | 73 | for (i = 0; i < len; ++i) { |
74 | if (pointer_test(lookup->children->items[i], &mouse_origin)) { | 74 | if (pointer_test(lookup->children->items[i], &mouse_origin)) { |
@@ -76,7 +76,7 @@ swayc_t *container_under_pointer(void) { | |||
76 | break; | 76 | break; |
77 | } | 77 | } |
78 | } | 78 | } |
79 | //when border and titles are done, this could happen | 79 | // when border and titles are done, this could happen |
80 | if (i == len) { | 80 | if (i == len) { |
81 | break; | 81 | break; |
82 | } | 82 | } |
@@ -119,7 +119,7 @@ static void handle_output_resolution_change(wlc_handle output, const struct wlc_ | |||
119 | 119 | ||
120 | static void handle_output_focused(wlc_handle output, bool focus) { | 120 | static void handle_output_focused(wlc_handle output, bool focus) { |
121 | swayc_t *c = get_swayc_for_handle(output, &root_container); | 121 | swayc_t *c = get_swayc_for_handle(output, &root_container); |
122 | //if for some reason this output doesnt exist, create it. | 122 | // if for some reason this output doesnt exist, create it. |
123 | if (!c) { | 123 | if (!c) { |
124 | handle_output_created(output); | 124 | handle_output_created(output); |
125 | } | 125 | } |
@@ -132,12 +132,12 @@ static bool handle_view_created(wlc_handle handle) { | |||
132 | swayc_t *focused = get_focused_container(&root_container); | 132 | swayc_t *focused = get_focused_container(&root_container); |
133 | swayc_t *newview = NULL; | 133 | swayc_t *newview = NULL; |
134 | switch (wlc_view_get_type(handle)) { | 134 | switch (wlc_view_get_type(handle)) { |
135 | //regular view created regularly | 135 | // regular view created regularly |
136 | case 0: | 136 | case 0: |
137 | newview = new_view(focused, handle); | 137 | newview = new_view(focused, handle); |
138 | wlc_view_set_state(handle, WLC_BIT_MAXIMIZED, true); | 138 | wlc_view_set_state(handle, WLC_BIT_MAXIMIZED, true); |
139 | break; | 139 | break; |
140 | //takes keyboard focus | 140 | // takes keyboard focus |
141 | case WLC_BIT_OVERRIDE_REDIRECT: | 141 | case WLC_BIT_OVERRIDE_REDIRECT: |
142 | sway_log(L_DEBUG, "view %ld with OVERRIDE_REDIRECT", handle); | 142 | sway_log(L_DEBUG, "view %ld with OVERRIDE_REDIRECT", handle); |
143 | locked_view_focus = true; | 143 | locked_view_focus = true; |
@@ -145,13 +145,13 @@ static bool handle_view_created(wlc_handle handle) { | |||
145 | wlc_view_set_state(handle, WLC_BIT_ACTIVATED, true); | 145 | wlc_view_set_state(handle, WLC_BIT_ACTIVATED, true); |
146 | wlc_view_bring_to_front(handle); | 146 | wlc_view_bring_to_front(handle); |
147 | break; | 147 | break; |
148 | //Takes container focus | 148 | // Takes container focus |
149 | case WLC_BIT_OVERRIDE_REDIRECT|WLC_BIT_UNMANAGED: | 149 | case WLC_BIT_OVERRIDE_REDIRECT|WLC_BIT_UNMANAGED: |
150 | sway_log(L_DEBUG, "view %ld with OVERRIDE_REDIRECT|WLC_BIT_MANAGED", handle); | 150 | sway_log(L_DEBUG, "view %ld with OVERRIDE_REDIRECT|WLC_BIT_MANAGED", handle); |
151 | wlc_view_bring_to_front(handle); | 151 | wlc_view_bring_to_front(handle); |
152 | locked_container_focus = true; | 152 | locked_container_focus = true; |
153 | break; | 153 | break; |
154 | //set modals as floating containers | 154 | // set modals as floating containers |
155 | case WLC_BIT_MODAL: | 155 | case WLC_BIT_MODAL: |
156 | wlc_view_bring_to_front(handle); | 156 | wlc_view_bring_to_front(handle); |
157 | newview = new_floating_view(handle); | 157 | newview = new_floating_view(handle); |
@@ -170,7 +170,7 @@ static void handle_view_destroyed(wlc_handle handle) { | |||
170 | swayc_t *view = get_swayc_for_handle(handle, &root_container); | 170 | swayc_t *view = get_swayc_for_handle(handle, &root_container); |
171 | 171 | ||
172 | switch (wlc_view_get_type(handle)) { | 172 | switch (wlc_view_get_type(handle)) { |
173 | //regular view created regularly | 173 | // regular view created regularly |
174 | case 0: | 174 | case 0: |
175 | case WLC_BIT_MODAL: | 175 | case WLC_BIT_MODAL: |
176 | if (view) { | 176 | if (view) { |
@@ -178,11 +178,11 @@ static void handle_view_destroyed(wlc_handle handle) { | |||
178 | arrange_windows(parent, -1, -1); | 178 | arrange_windows(parent, -1, -1); |
179 | } | 179 | } |
180 | break; | 180 | break; |
181 | //takes keyboard focus | 181 | // takes keyboard focus |
182 | case WLC_BIT_OVERRIDE_REDIRECT: | 182 | case WLC_BIT_OVERRIDE_REDIRECT: |
183 | locked_view_focus = false; | 183 | locked_view_focus = false; |
184 | break; | 184 | break; |
185 | //Takes container focus | 185 | // Takes container focus |
186 | case WLC_BIT_OVERRIDE_REDIRECT|WLC_BIT_UNMANAGED: | 186 | case WLC_BIT_OVERRIDE_REDIRECT|WLC_BIT_UNMANAGED: |
187 | locked_container_focus = false; | 187 | locked_container_focus = false; |
188 | case WLC_BIT_POPUP: | 188 | case WLC_BIT_POPUP: |
@@ -195,7 +195,7 @@ static void handle_view_focus(wlc_handle view, bool focus) { | |||
195 | return; | 195 | return; |
196 | } | 196 | } |
197 | 197 | ||
198 | static void handle_view_geometry_request(wlc_handle handle, const struct wlc_geometry* geometry) { | 198 | static void handle_view_geometry_request(wlc_handle handle, const struct wlc_geometry *geometry) { |
199 | sway_log(L_DEBUG, "geometry request %d x %d : %d x %d", | 199 | sway_log(L_DEBUG, "geometry request %d x %d : %d x %d", |
200 | geometry->origin.x, geometry->origin.y, geometry->size.w,geometry->size.h); | 200 | geometry->origin.x, geometry->origin.y, geometry->size.w,geometry->size.h); |
201 | // If the view is floating, then apply the geometry. | 201 | // If the view is floating, then apply the geometry. |
@@ -220,20 +220,19 @@ static void handle_view_state_request(wlc_handle view, enum wlc_view_state_bit s | |||
220 | swayc_t *c = NULL; | 220 | swayc_t *c = NULL; |
221 | switch(state) { | 221 | switch(state) { |
222 | case WLC_BIT_FULLSCREEN: | 222 | case WLC_BIT_FULLSCREEN: |
223 | //I3 just lets it become fullscreen | 223 | // i3 just lets it become fullscreen |
224 | wlc_view_set_state(view, state, toggle); | 224 | wlc_view_set_state(view, state, toggle); |
225 | c = get_swayc_for_handle(view, &root_container); | 225 | c = get_swayc_for_handle(view, &root_container); |
226 | sway_log(L_DEBUG, "setting view %ld %s, fullscreen %d",view,c->name,toggle); | 226 | sway_log(L_DEBUG, "setting view %ld %s, fullscreen %d",view,c->name,toggle); |
227 | if (c) { | 227 | if (c) { |
228 | arrange_windows(c->parent, -1, -1); | 228 | arrange_windows(c->parent, -1, -1); |
229 | //Set it as focused window for that workspace if its going | 229 | // Set it as focused window for that workspace if its going fullscreen |
230 | //fullscreen | ||
231 | if (toggle) { | 230 | if (toggle) { |
232 | swayc_t *ws = c; | 231 | swayc_t *ws = c; |
233 | while (ws->type != C_WORKSPACE) { | 232 | while (ws->type != C_WORKSPACE) { |
234 | ws = ws->parent; | 233 | ws = ws->parent; |
235 | } | 234 | } |
236 | //Set ws focus to c | 235 | // Set ws focus to c |
237 | set_focused_container_for(ws, c); | 236 | set_focused_container_for(ws, c); |
238 | } | 237 | } |
239 | } | 238 | } |
@@ -248,8 +247,8 @@ static void handle_view_state_request(wlc_handle view, enum wlc_view_state_bit s | |||
248 | } | 247 | } |
249 | 248 | ||
250 | 249 | ||
251 | static bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifiers | 250 | static bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifiers *modifiers, |
252 | *modifiers, uint32_t key, uint32_t sym, enum wlc_key_state state) { | 251 | uint32_t key, uint32_t sym, enum wlc_key_state state) { |
253 | enum { QSIZE = 32 }; | 252 | enum { QSIZE = 32 }; |
254 | if (locked_view_focus && state == WLC_KEY_STATE_PRESSED) { | 253 | if (locked_view_focus && state == WLC_KEY_STATE_PRESSED) { |
255 | return false; | 254 | return false; |
@@ -261,7 +260,7 @@ static bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifier | |||
261 | // Lowercase if necessary | 260 | // Lowercase if necessary |
262 | sym = tolower(sym); | 261 | sym = tolower(sym); |
263 | 262 | ||
264 | //Find key, if it has been pressed | 263 | // Find key, if it has been pressed |
265 | int mid = 0; | 264 | int mid = 0; |
266 | while (mid < head && keys_pressed[mid] != sym) { | 265 | while (mid < head && keys_pressed[mid] != sym) { |
267 | ++mid; | 266 | ++mid; |
@@ -295,7 +294,7 @@ static bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifier | |||
295 | } | 294 | } |
296 | 295 | ||
297 | if (match) { | 296 | if (match) { |
298 | //Remove matched keys from keys_pressed | 297 | // Remove matched keys from keys_pressed |
299 | int j; | 298 | int j; |
300 | for (j = 0; j < binding->keys->length; ++j) { | 299 | for (j = 0; j < binding->keys->length; ++j) { |
301 | uint8_t k; | 300 | uint8_t k; |