summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Luminarys <kizunanohikari@gmail.com>2015-08-15 13:22:03 -0500
committerLibravatar Luminarys <kizunanohikari@gmail.com>2015-08-15 13:22:03 -0500
commitb01a04f22b8eaacfbcee099797b4c664cfb97b97 (patch)
tree9951f0232b63afbd6d1c32472a56f1919afdf088
parentMerge pull request #29 from taiyu-len/master (diff)
downloadsway-b01a04f22b8eaacfbcee099797b4c664cfb97b97.tar.gz
sway-b01a04f22b8eaacfbcee099797b4c664cfb97b97.tar.zst
sway-b01a04f22b8eaacfbcee099797b4c664cfb97b97.zip
Added layout debugger back in and fixed mutlimonitor layout issues
-rw-r--r--sway/handlers.c11
-rw-r--r--sway/layout.c1
-rw-r--r--sway/workspace.c50
-rw-r--r--sway/workspace.h1
4 files changed, 61 insertions, 2 deletions
diff --git a/sway/handlers.c b/sway/handlers.c
index 393a2181..a85eb681 100644
--- a/sway/handlers.c
+++ b/sway/handlers.c
@@ -15,9 +15,14 @@ static struct wlc_origin mouse_origin;
15 15
16static bool pointer_test(swayc_t *view, void *_origin) { 16static bool pointer_test(swayc_t *view, void *_origin) {
17 const struct wlc_origin *origin = _origin; 17 const struct wlc_origin *origin = _origin;
18 //Determine the output that the view is under
19 swayc_t *parent = view;
20 while (parent->type != C_OUTPUT) {
21 parent = parent->parent;
22 }
18 if (view->type == C_VIEW && origin->x >= view->x && origin->y >= view->y 23 if (view->type == C_VIEW && origin->x >= view->x && origin->y >= view->y
19 && origin->x < view->x + view->width && origin->y < view->y + view->height 24 && origin->x < view->x + view->width && origin->y < view->y + view->height
20 && view->visible) { 25 && view->visible && parent == root_container.focused) {
21 return true; 26 return true;
22 } 27 }
23 return false; 28 return false;
@@ -187,6 +192,9 @@ static bool handle_pointer_motion(wlc_handle view, uint32_t time, const struct w
187 swayc_t *c = find_container(&root_container, pointer_test, (void *)origin); 192 swayc_t *c = find_container(&root_container, pointer_test, (void *)origin);
188 swayc_t *focused = get_focused_container(&root_container); 193 swayc_t *focused = get_focused_container(&root_container);
189 if (c && c != focused) { 194 if (c && c != focused) {
195 sway_log(L_DEBUG, "Mouse pointer at X: %d, Y: %d", origin->x, origin->y);
196 sway_log(L_DEBUG, "Container to focus on is at X: %d, Y: %d, with W: %d, H: %d", c->x, c->y, c->width, c->height);
197 sway_log(L_DEBUG, "Focused container is at X: %d, Y: %d, with W: %d, H: %d", c->x, c->y, c->width, c->height);
190 sway_log(L_DEBUG, "Switching focus to %p", c); 198 sway_log(L_DEBUG, "Switching focus to %p", c);
191 unfocus_all(&root_container); 199 unfocus_all(&root_container);
192 focus_view(c); 200 focus_view(c);
@@ -254,4 +262,3 @@ struct wlc_interface interface = {
254 .ready = handle_wlc_ready 262 .ready = handle_wlc_ready
255 } 263 }
256}; 264};
257
diff --git a/sway/layout.c b/sway/layout.c
index e2e91593..4fd6aff9 100644
--- a/sway/layout.c
+++ b/sway/layout.c
@@ -179,6 +179,7 @@ void arrange_windows(swayc_t *container, int width, int height) {
179 } 179 }
180 break; 180 break;
181 } 181 }
182 layout_log(&root_container, 0);
182} 183}
183 184
184swayc_t *get_swayc_for_handle(wlc_handle handle, swayc_t *parent) { 185swayc_t *get_swayc_for_handle(wlc_handle handle, swayc_t *parent) {
diff --git a/sway/workspace.c b/sway/workspace.c
index cd5472e3..3f4590e2 100644
--- a/sway/workspace.c
+++ b/sway/workspace.c
@@ -111,3 +111,53 @@ void workspace_switch(swayc_t *workspace) {
111 } 111 }
112 active_workspace = workspace; 112 active_workspace = workspace;
113} 113}
114
115/* XXX:DEBUG:XXX */
116static void container_log(const swayc_t *c) {
117 fprintf(stderr, "focus:%c|",
118 c == get_focused_container(&root_container) ? 'F' : //Focused
119 c == active_workspace ? 'W' : //active workspace
120 c == &root_container ? 'R' : //root
121 'X');//not any others
122 fprintf(stderr,"(%p)",c);
123 fprintf(stderr,"(p:%p)",c->parent);
124 fprintf(stderr,"(f:%p)",c->focused);
125 fprintf(stderr,"Type:");
126 fprintf(stderr,
127 c->type == C_ROOT ? "Root|" :
128 c->type == C_OUTPUT ? "Output|" :
129 c->type == C_WORKSPACE ? "Workspace|" :
130 c->type == C_CONTAINER ? "Container|" :
131 c->type == C_VIEW ? "View|" :
132 "Unknown|");
133 fprintf(stderr,"layout:");
134 fprintf(stderr,
135 c->layout == L_NONE ? "NONE|" :
136 c->layout == L_HORIZ ? "Horiz|":
137 c->layout == L_VERT ? "Vert|":
138 c->layout == L_STACKED ? "Stacked|":
139 c->layout == L_FLOATING ? "Floating|":
140 "Unknown|");
141 fprintf(stderr, "w:%d|h:%d|", c->width, c->height);
142 fprintf(stderr, "x:%d|y:%d|", c->x, c->y);
143 fprintf(stderr, "vis:%c|", c->visible?'t':'f');
144 fprintf(stderr, "wgt:%d|", c->weight);
145 fprintf(stderr, "name:%.16s|", c->name);
146 fprintf(stderr, "children:%d\n",c->children?c->children->length:0);
147}
148void layout_log(const swayc_t *c, int depth) {
149 int i;
150 int e = c->children?c->children->length:0;
151 for (i = 0; i < depth; ++i) fputc(' ', stderr);
152 container_log(c);
153 if (e) {
154 for (i = 0; i < depth; ++i) fputc(' ', stderr);
155 fprintf(stderr,"(\n");
156 for (i = 0; i < e; ++i) {
157 layout_log(c->children->items[i], depth + 1);
158 }
159 for (i = 0; i < depth; ++i) fputc(' ', stderr);
160 fprintf(stderr,")\n");
161 }
162}
163/* XXX:DEBUG:XXX */
diff --git a/sway/workspace.h b/sway/workspace.h
index 523ce633..59a6d526 100644
--- a/sway/workspace.h
+++ b/sway/workspace.h
@@ -11,5 +11,6 @@ char *workspace_next_name(void);
11swayc_t *workspace_create(const char*); 11swayc_t *workspace_create(const char*);
12swayc_t *workspace_find_by_name(const char*); 12swayc_t *workspace_find_by_name(const char*);
13void workspace_switch(swayc_t*); 13void workspace_switch(swayc_t*);
14void layout_log(const swayc_t *c, int depth);
14 15
15#endif 16#endif