diff options
Diffstat (limited to 'sway/handlers.c')
-rw-r--r-- | sway/handlers.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/sway/handlers.c b/sway/handlers.c index 78f8927d..8dc409e1 100644 --- a/sway/handlers.c +++ b/sway/handlers.c | |||
@@ -86,7 +86,7 @@ static bool handle_output_created(wlc_handle output) { | |||
86 | swayc_t *op = new_output(output); | 86 | swayc_t *op = new_output(output); |
87 | 87 | ||
88 | // Switch to workspace if we need to | 88 | // Switch to workspace if we need to |
89 | if (active_workspace == NULL) { | 89 | if (swayc_active_workspace() == NULL) { |
90 | swayc_t *ws = op->children->items[0]; | 90 | swayc_t *ws = op->children->items[0]; |
91 | workspace_switch(ws); | 91 | workspace_switch(ws); |
92 | } | 92 | } |
@@ -104,9 +104,7 @@ static void handle_output_destroyed(wlc_handle output) { | |||
104 | if (i < list->length) { | 104 | if (i < list->length) { |
105 | destroy_output(list->items[i]); | 105 | destroy_output(list->items[i]); |
106 | } | 106 | } |
107 | if (list->length == 0) { | 107 | if (list->length > 0) { |
108 | active_workspace = NULL; | ||
109 | } else { | ||
110 | // switch to other outputs active workspace | 108 | // switch to other outputs active workspace |
111 | workspace_switch(((swayc_t *)root_container.children->items[0])->focused); | 109 | workspace_switch(((swayc_t *)root_container.children->items[0])->focused); |
112 | } | 110 | } |
@@ -114,7 +112,7 @@ static void handle_output_destroyed(wlc_handle output) { | |||
114 | 112 | ||
115 | static void handle_output_resolution_change(wlc_handle output, const struct wlc_size *from, const struct wlc_size *to) { | 113 | static void handle_output_resolution_change(wlc_handle output, const struct wlc_size *from, const struct wlc_size *to) { |
116 | sway_log(L_DEBUG, "Output %u resolution changed to %d x %d", (unsigned int)output, to->w, to->h); | 114 | sway_log(L_DEBUG, "Output %u resolution changed to %d x %d", (unsigned int)output, to->w, to->h); |
117 | swayc_t *c = get_swayc_for_handle(output, &root_container); | 115 | swayc_t *c = swayc_by_handle(output); |
118 | if (!c) return; | 116 | if (!c) return; |
119 | c->width = to->w; | 117 | c->width = to->w; |
120 | c->height = to->h; | 118 | c->height = to->h; |
@@ -122,7 +120,7 @@ static void handle_output_resolution_change(wlc_handle output, const struct wlc_ | |||
122 | } | 120 | } |
123 | 121 | ||
124 | static void handle_output_focused(wlc_handle output, bool focus) { | 122 | static void handle_output_focused(wlc_handle output, bool focus) { |
125 | swayc_t *c = get_swayc_for_handle(output, &root_container); | 123 | swayc_t *c = swayc_by_handle(output); |
126 | // if for some reason this output doesnt exist, create it. | 124 | // if for some reason this output doesnt exist, create it. |
127 | if (!c) { | 125 | if (!c) { |
128 | handle_output_created(output); | 126 | handle_output_created(output); |
@@ -140,7 +138,7 @@ static bool handle_view_created(wlc_handle handle) { | |||
140 | 138 | ||
141 | // Get parent container, to add view in | 139 | // Get parent container, to add view in |
142 | if (parent) { | 140 | if (parent) { |
143 | focused = get_swayc_for_handle(parent, &root_container); | 141 | focused = swayc_by_handle(parent); |
144 | } | 142 | } |
145 | if (!focused || focused->type == C_OUTPUT) { | 143 | if (!focused || focused->type == C_OUTPUT) { |
146 | focused = get_focused_container(&root_container); | 144 | focused = get_focused_container(&root_container); |
@@ -197,7 +195,7 @@ static bool handle_view_created(wlc_handle handle) { | |||
197 | 195 | ||
198 | static void handle_view_destroyed(wlc_handle handle) { | 196 | static void handle_view_destroyed(wlc_handle handle) { |
199 | sway_log(L_DEBUG, "Destroying window %lu", handle); | 197 | sway_log(L_DEBUG, "Destroying window %lu", handle); |
200 | swayc_t *view = get_swayc_for_handle(handle, &root_container); | 198 | swayc_t *view = swayc_by_handle(handle); |
201 | 199 | ||
202 | switch (wlc_view_get_type(handle)) { | 200 | switch (wlc_view_get_type(handle)) { |
203 | // regular view created regularly | 201 | // regular view created regularly |
@@ -231,7 +229,7 @@ static void handle_view_geometry_request(wlc_handle handle, const struct wlc_geo | |||
231 | // If the view is floating, then apply the geometry. | 229 | // If the view is floating, then apply the geometry. |
232 | // Otherwise save the desired width/height for the view. | 230 | // Otherwise save the desired width/height for the view. |
233 | // This will not do anything for the time being as WLC improperly sends geometry requests | 231 | // This will not do anything for the time being as WLC improperly sends geometry requests |
234 | swayc_t *view = get_swayc_for_handle(handle, &root_container); | 232 | swayc_t *view = swayc_by_handle(handle); |
235 | if (view) { | 233 | if (view) { |
236 | view->desired_width = geometry->size.w; | 234 | view->desired_width = geometry->size.w; |
237 | view->desired_height = geometry->size.h; | 235 | view->desired_height = geometry->size.h; |
@@ -247,7 +245,7 @@ static void handle_view_geometry_request(wlc_handle handle, const struct wlc_geo | |||
247 | } | 245 | } |
248 | 246 | ||
249 | static void handle_view_state_request(wlc_handle view, enum wlc_view_state_bit state, bool toggle) { | 247 | static void handle_view_state_request(wlc_handle view, enum wlc_view_state_bit state, bool toggle) { |
250 | swayc_t *c = get_swayc_for_handle(view, &root_container); | 248 | swayc_t *c = swayc_by_handle(view); |
251 | switch (state) { | 249 | switch (state) { |
252 | case WLC_BIT_FULLSCREEN: | 250 | case WLC_BIT_FULLSCREEN: |
253 | // i3 just lets it become fullscreen | 251 | // i3 just lets it become fullscreen |
@@ -342,7 +340,7 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct | |||
342 | bool changed_tiling = false; | 340 | bool changed_tiling = false; |
343 | int min_sane_w = 100; | 341 | int min_sane_w = 100; |
344 | int min_sane_h = 60; | 342 | int min_sane_h = 60; |
345 | if (!active_workspace) { | 343 | if (!swayc_active_workspace()) { |
346 | return false; | 344 | return false; |
347 | } | 345 | } |
348 | // Do checks to determine if proper keys are being held | 346 | // Do checks to determine if proper keys are being held |
@@ -518,7 +516,7 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct | |||
518 | } | 516 | } |
519 | } | 517 | } |
520 | } | 518 | } |
521 | arrange_windows(active_workspace, -1, -1); | 519 | arrange_windows(swayc_active_workspace(), -1, -1); |
522 | } | 520 | } |
523 | } | 521 | } |
524 | if (config->focus_follows_mouse && prev_handle != handle) { | 522 | if (config->focus_follows_mouse && prev_handle != handle) { |