diff options
author | taiyu <taiyu.len@gmail.com> | 2015-08-20 09:52:54 -0700 |
---|---|---|
committer | taiyu <taiyu.len@gmail.com> | 2015-08-20 09:52:54 -0700 |
commit | 36e07e9ebc55b3fc8a8b8cd76ee743202691ad56 (patch) | |
tree | e9e2a9d9db46044ab7cd7bd4dcb7ca2650a89f70 /sway/handlers.c | |
parent | 84f01a67bdaef4dbff787caa4b076ed60e257c51 (diff) |
find_parent_by_type
Diffstat (limited to 'sway/handlers.c')
-rw-r--r-- | sway/handlers.c | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/sway/handlers.c b/sway/handlers.c index 5993223d..79628fe5 100644 --- a/sway/handlers.c +++ b/sway/handlers.c @@ -20,10 +20,7 @@ static struct wlc_origin mouse_origin; static bool pointer_test(swayc_t *view, void *_origin) { const struct wlc_origin *origin = _origin; // Determine the output that the view is under - swayc_t *parent = view; - while (parent->type != C_OUTPUT) { - parent = parent->parent; - } + swayc_t *parent = swayc_parent_by_type(view, C_OUTPUT); if (origin->x >= view->x && origin->y >= view->y && origin->x < view->x + view->width && origin->y < view->y + view->height && view->visible && parent == root_container.focused) { @@ -191,10 +188,7 @@ static bool handle_view_created(wlc_handle handle) { if (newview) { set_focused_container(newview); - swayc_t *output = newview->parent; - while (output && output->type != C_OUTPUT) { - output = output->parent; - } + swayc_t *output = swayc_parent_by_type(newview, C_OUTPUT); arrange_windows(output, -1, -1); } return true; @@ -262,10 +256,7 @@ static void handle_view_state_request(wlc_handle view, enum wlc_view_state_bit s arrange_windows(c->parent, -1, -1); // Set it as focused window for that workspace if its going fullscreen if (toggle) { - swayc_t *ws = c; - while (ws->type != C_WORKSPACE) { - ws = ws->parent; - } + swayc_t *ws = swayc_parent_by_type(c, C_WORKSPACE); // Set ws focus to c set_focused_container_for(ws, c); } |