aboutsummaryrefslogtreecommitdiffstats
path: root/sway/handlers.c
diff options
context:
space:
mode:
authorLibravatar S. Christoffer Eliesen <christoffer@eliesen.no>2015-10-28 00:22:52 +0100
committerLibravatar S. Christoffer Eliesen <christoffer@eliesen.no>2015-10-29 16:37:19 +0100
commit865b30f13814beb798f49d6e2372cc44d8103b29 (patch)
tree7047b1bbfe38f581f46cc6a92a75320631e8ee35 /sway/handlers.c
parentMerge pull request #211 from sce/fix_get_swayc_in_direction (diff)
downloadsway-865b30f13814beb798f49d6e2372cc44d8103b29.tar.gz
sway-865b30f13814beb798f49d6e2372cc44d8103b29.tar.zst
sway-865b30f13814beb798f49d6e2372cc44d8103b29.zip
container: Move container_under_pointer here from handlers.
Diffstat (limited to 'sway/handlers.c')
-rw-r--r--sway/handlers.c62
1 files changed, 0 insertions, 62 deletions
diff --git a/sway/handlers.c b/sway/handlers.c
index 1c5abca6..cb342f69 100644
--- a/sway/handlers.c
+++ b/sway/handlers.c
@@ -24,68 +24,6 @@
24// Event handled by sway and should not be sent to client 24// Event handled by sway and should not be sent to client
25#define EVENT_HANDLED true 25#define EVENT_HANDLED true
26 26
27static bool pointer_test(swayc_t *view, void *_origin) {
28 const struct mouse_origin *origin = _origin;
29 // Determine the output that the view is under
30 swayc_t *parent = swayc_parent_by_type(view, C_OUTPUT);
31 if (origin->x >= view->x && origin->y >= view->y
32 && origin->x < view->x + view->width && origin->y < view->y + view->height
33 && view->visible && parent == root_container.focused) {
34 return true;
35 }
36 return false;
37}
38
39swayc_t *container_under_pointer(void) {
40 // root.output->workspace
41 if (!root_container.focused || !root_container.focused->focused) {
42 return NULL;
43 }
44 swayc_t *lookup = root_container.focused->focused;
45 // Case of empty workspace
46 if (lookup->children == 0) {
47 return NULL;
48 }
49 while (lookup->type != C_VIEW) {
50 int i;
51 int len;
52 // if tabbed/stacked go directly to focused container, otherwise search
53 // children
54 if (lookup->layout == L_TABBED || lookup->layout == L_STACKED) {
55 lookup = lookup->focused;
56 continue;
57 }
58 // if workspace, search floating
59 if (lookup->type == C_WORKSPACE) {
60 i = len = lookup->floating->length;
61 bool got_floating = false;
62 while (--i > -1) {
63 if (pointer_test(lookup->floating->items[i], &pointer_state.origin)) {
64 lookup = lookup->floating->items[i];
65 got_floating = true;
66 break;
67 }
68 }
69 if (got_floating) {
70 continue;
71 }
72 }
73 // search children
74 len = lookup->children->length;
75 for (i = 0; i < len; ++i) {
76 if (pointer_test(lookup->children->items[i], &pointer_state.origin)) {
77 lookup = lookup->children->items[i];
78 break;
79 }
80 }
81 // when border and titles are done, this could happen
82 if (i == len) {
83 break;
84 }
85 }
86 return lookup;
87}
88
89/* Handles */ 27/* Handles */
90 28
91static bool handle_output_created(wlc_handle output) { 29static bool handle_output_created(wlc_handle output) {