diff options
author | 2015-08-18 23:52:42 -0700 | |
---|---|---|
committer | 2015-08-18 23:52:42 -0700 | |
commit | 1bf02144e558630f36b1efca45d6074be456c0b4 (patch) | |
tree | 4efdf2bddfc4b141bd34e453da2e2e1abdfa2a69 | |
parent | focus to only child (diff) | |
download | sway-1bf02144e558630f36b1efca45d6074be456c0b4.tar.gz sway-1bf02144e558630f36b1efca45d6074be456c0b4.tar.zst sway-1bf02144e558630f36b1efca45d6074be456c0b4.zip |
fixed floating_modifier related things
-rw-r--r-- | sway/container.c | 5 | ||||
-rw-r--r-- | sway/focus.c | 5 | ||||
-rw-r--r-- | sway/handlers.c | 45 |
3 files changed, 41 insertions, 14 deletions
diff --git a/sway/container.c b/sway/container.c index ec4d48b8..9763f381 100644 --- a/sway/container.c +++ b/sway/container.c | |||
@@ -200,8 +200,9 @@ swayc_t *new_floating_view(wlc_handle handle) { | |||
200 | // Set the geometry of the floating view | 200 | // Set the geometry of the floating view |
201 | const struct wlc_geometry* geometry = wlc_view_get_geometry(handle); | 201 | const struct wlc_geometry* geometry = wlc_view_get_geometry(handle); |
202 | 202 | ||
203 | view->x = geometry->origin.x; | 203 | //give it requested geometry, but place in center |
204 | view->y = geometry->origin.y; | 204 | view->x = (active_workspace->width - geometry->size.w) / 2; |
205 | view->y = (active_workspace->height- geometry->size.h) / 2; | ||
205 | view->width = geometry->size.w; | 206 | view->width = geometry->size.w; |
206 | view->height = geometry->size.h; | 207 | view->height = geometry->size.h; |
207 | 208 | ||
diff --git a/sway/focus.c b/sway/focus.c index 1f17dfc9..0ee10694 100644 --- a/sway/focus.c +++ b/sway/focus.c | |||
@@ -168,8 +168,11 @@ void set_focused_container(swayc_t *c) { | |||
168 | } | 168 | } |
169 | // activate current focus | 169 | // activate current focus |
170 | if (p->type == C_VIEW) { | 170 | if (p->type == C_VIEW) { |
171 | wlc_view_focus(p->handle); | ||
172 | wlc_view_set_state(p->handle, WLC_BIT_ACTIVATED, true); | 171 | wlc_view_set_state(p->handle, WLC_BIT_ACTIVATED, true); |
172 | //set focus if view_focus is unlocked | ||
173 | if (!locked_view_focus) { | ||
174 | wlc_view_focus(p->handle); | ||
175 | } | ||
173 | } | 176 | } |
174 | } | 177 | } |
175 | } | 178 | } |
diff --git a/sway/handlers.c b/sway/handlers.c index e785e9c5..d5909c8f 100644 --- a/sway/handlers.c +++ b/sway/handlers.c | |||
@@ -139,35 +139,54 @@ static void handle_output_focused(wlc_handle output, bool focus) { | |||
139 | } | 139 | } |
140 | 140 | ||
141 | static bool handle_view_created(wlc_handle handle) { | 141 | static bool handle_view_created(wlc_handle handle) { |
142 | swayc_t *focused = get_focused_container(&root_container); | 142 | // if view is child of another view, the use that as focused container |
143 | wlc_handle parent = wlc_view_get_parent(handle); | ||
144 | swayc_t *focused = NULL; | ||
143 | swayc_t *newview = NULL; | 145 | swayc_t *newview = NULL; |
146 | |||
147 | // Get parent container, to add view in | ||
148 | if (parent) { | ||
149 | focused = get_swayc_for_handle(parent, &root_container); | ||
150 | } | ||
151 | if (!focused || focused->type == C_OUTPUT) { | ||
152 | focused = get_focused_container(&root_container); | ||
153 | } | ||
154 | sway_log(L_DEBUG, "creating view %ld with type %x, state %x, with parent %ld", | ||
155 | handle, wlc_view_get_type(handle), wlc_view_get_state(handle), parent); | ||
156 | |||
157 | // TODO properly figure out how each window should be handled. | ||
144 | switch (wlc_view_get_type(handle)) { | 158 | switch (wlc_view_get_type(handle)) { |
145 | // regular view created regularly | 159 | // regular view created regularly |
146 | case 0: | 160 | case 0: |
147 | newview = new_view(focused, handle); | 161 | newview = new_view(focused, handle); |
148 | wlc_view_set_state(handle, WLC_BIT_MAXIMIZED, true); | 162 | wlc_view_set_state(handle, WLC_BIT_MAXIMIZED, true); |
149 | break; | 163 | break; |
150 | // takes keyboard focus | 164 | |
165 | // Dmenu keeps viewfocus, but others with this flag dont, for now simulate | ||
166 | // dmenu | ||
151 | case WLC_BIT_OVERRIDE_REDIRECT: | 167 | case WLC_BIT_OVERRIDE_REDIRECT: |
152 | sway_log(L_DEBUG, "view %ld with OVERRIDE_REDIRECT", handle); | 168 | // locked_view_focus = true; |
153 | locked_view_focus = true; | ||
154 | wlc_view_focus(handle); | 169 | wlc_view_focus(handle); |
155 | wlc_view_set_state(handle, WLC_BIT_ACTIVATED, true); | 170 | wlc_view_set_state(handle, WLC_BIT_ACTIVATED, true); |
156 | wlc_view_bring_to_front(handle); | 171 | wlc_view_bring_to_front(handle); |
157 | break; | 172 | break; |
158 | // Takes container focus | 173 | |
174 | // Firefox popups have this flag set. | ||
159 | case WLC_BIT_OVERRIDE_REDIRECT|WLC_BIT_UNMANAGED: | 175 | case WLC_BIT_OVERRIDE_REDIRECT|WLC_BIT_UNMANAGED: |
160 | sway_log(L_DEBUG, "view %ld with OVERRIDE_REDIRECT|WLC_BIT_MANAGED", handle); | ||
161 | wlc_view_bring_to_front(handle); | 176 | wlc_view_bring_to_front(handle); |
162 | locked_container_focus = true; | 177 | locked_container_focus = true; |
163 | break; | 178 | break; |
164 | // set modals as floating containers | 179 | |
180 | // Modals, get focus, popups do not | ||
165 | case WLC_BIT_MODAL: | 181 | case WLC_BIT_MODAL: |
182 | wlc_view_focus(handle); | ||
166 | wlc_view_bring_to_front(handle); | 183 | wlc_view_bring_to_front(handle); |
167 | newview = new_floating_view(handle); | 184 | newview = new_floating_view(handle); |
168 | case WLC_BIT_POPUP: | 185 | case WLC_BIT_POPUP: |
186 | wlc_view_bring_to_front(handle); | ||
169 | break; | 187 | break; |
170 | } | 188 | } |
189 | |||
171 | if (newview) { | 190 | if (newview) { |
172 | set_focused_container(newview); | 191 | set_focused_container(newview); |
173 | swayc_t *output = newview->parent; | 192 | swayc_t *output = newview->parent; |
@@ -187,19 +206,19 @@ static void handle_view_destroyed(wlc_handle handle) { | |||
187 | // regular view created regularly | 206 | // regular view created regularly |
188 | case 0: | 207 | case 0: |
189 | case WLC_BIT_MODAL: | 208 | case WLC_BIT_MODAL: |
209 | case WLC_BIT_POPUP: | ||
190 | if (view) { | 210 | if (view) { |
191 | swayc_t *parent = destroy_view(view); | 211 | swayc_t *parent = destroy_view(view); |
192 | arrange_windows(parent, -1, -1); | 212 | arrange_windows(parent, -1, -1); |
193 | } | 213 | } |
194 | break; | 214 | break; |
195 | // takes keyboard focus | 215 | // DMENU has this flag, and takes view_focus, but other things with this |
216 | // flag dont | ||
196 | case WLC_BIT_OVERRIDE_REDIRECT: | 217 | case WLC_BIT_OVERRIDE_REDIRECT: |
197 | locked_view_focus = false; | 218 | // locked_view_focus = false; |
198 | break; | 219 | break; |
199 | // Takes container focus | ||
200 | case WLC_BIT_OVERRIDE_REDIRECT|WLC_BIT_UNMANAGED: | 220 | case WLC_BIT_OVERRIDE_REDIRECT|WLC_BIT_UNMANAGED: |
201 | locked_container_focus = false; | 221 | locked_container_focus = false; |
202 | case WLC_BIT_POPUP: | ||
203 | break; | 222 | break; |
204 | } | 223 | } |
205 | set_focused_container(get_focused_view(&root_container)); | 224 | set_focused_container(get_focused_view(&root_container)); |
@@ -279,10 +298,12 @@ static bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifier | |||
279 | while (mid < head && keys_pressed[mid] != sym) { | 298 | while (mid < head && keys_pressed[mid] != sym) { |
280 | ++mid; | 299 | ++mid; |
281 | } | 300 | } |
301 | //Add or remove key depending on state | ||
282 | if (state == WLC_KEY_STATE_PRESSED && mid == head && head + 1 < QSIZE) { | 302 | if (state == WLC_KEY_STATE_PRESSED && mid == head && head + 1 < QSIZE) { |
283 | keys_pressed[head++] = sym; | 303 | keys_pressed[head++] = sym; |
284 | } else if (state == WLC_KEY_STATE_RELEASED && mid < head) { | 304 | } else if (state == WLC_KEY_STATE_RELEASED && mid < head) { |
285 | memmove(keys_pressed + mid, keys_pressed + mid + 1, sizeof*keys_pressed * (--head - mid)); | 305 | memmove(keys_pressed + mid, keys_pressed + mid + 1, sizeof*keys_pressed * (--head - mid)); |
306 | keys_pressed[head] = 0; | ||
286 | } | 307 | } |
287 | // TODO: reminder to check conflicts with mod+q+a versus mod+q | 308 | // TODO: reminder to check conflicts with mod+q+a versus mod+q |
288 | int i; | 309 | int i; |
@@ -314,6 +335,7 @@ static bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifier | |||
314 | uint8_t k; | 335 | uint8_t k; |
315 | for (k = 0; k < head; ++k) { | 336 | for (k = 0; k < head; ++k) { |
316 | memmove(keys_pressed + k, keys_pressed + k + 1, sizeof*keys_pressed * (--head - k)); | 337 | memmove(keys_pressed + k, keys_pressed + k + 1, sizeof*keys_pressed * (--head - k)); |
338 | keys_pressed[head] = 0; | ||
317 | break; | 339 | break; |
318 | } | 340 | } |
319 | } | 341 | } |
@@ -469,6 +491,7 @@ static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct w | |||
469 | arrange_windows(pointer->parent, -1, -1); | 491 | arrange_windows(pointer->parent, -1, -1); |
470 | dragging = m1_held; | 492 | dragging = m1_held; |
471 | resizing = m2_held; | 493 | resizing = m2_held; |
494 | return true; | ||
472 | } | 495 | } |
473 | return (pointer && pointer != focused); | 496 | return (pointer && pointer != focused); |
474 | } else { | 497 | } else { |