summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Luminarys <kizunanohikari@gmail.com>2015-08-15 13:55:06 -0500
committerLibravatar Luminarys <kizunanohikari@gmail.com>2015-08-15 13:55:06 -0500
commit618b3df0513dd2c63f6e64db1e125a609e1ec6b9 (patch)
tree994deaa15dbb04cc6e7cd7a0a79cf44fa18dbdeb
parentAdded layout debugger back in and fixed mutlimonitor layout issues (diff)
downloadsway-618b3df0513dd2c63f6e64db1e125a609e1ec6b9.tar.gz
sway-618b3df0513dd2c63f6e64db1e125a609e1ec6b9.tar.zst
sway-618b3df0513dd2c63f6e64db1e125a609e1ec6b9.zip
Fixed workspace switching in multimonitor layouts
-rw-r--r--sway/container.c10
-rw-r--r--sway/handlers.c8
-rw-r--r--sway/layout.c2
-rw-r--r--sway/workspace.c110
4 files changed, 70 insertions, 60 deletions
diff --git a/sway/container.c b/sway/container.c
index 1c17e92f..3fa9f490 100644
--- a/sway/container.c
+++ b/sway/container.c
@@ -69,7 +69,7 @@ swayc_t *new_workspace(swayc_t * output, const char *name) {
69 workspace->layout = L_HORIZ; // TODO:default layout 69 workspace->layout = L_HORIZ; // TODO:default layout
70 workspace->width = output->width; 70 workspace->width = output->width;
71 workspace->height = output->height; 71 workspace->height = output->height;
72 workspace->name = strdup(name); 72 workspace->name = strdup(name);
73 workspace->visible = true; 73 workspace->visible = true;
74 74
75 add_child(output, workspace); 75 add_child(output, workspace);
@@ -82,10 +82,10 @@ swayc_t *new_container(swayc_t *child, enum swayc_layouts layout) {
82 sway_log(L_DEBUG, "creating container %p around %p", cont, child); 82 sway_log(L_DEBUG, "creating container %p around %p", cont, child);
83 83
84 cont->layout = layout; 84 cont->layout = layout;
85 cont->width = child->width; 85 cont->width = child->width;
86 cont->height = child->height; 86 cont->height = child->height;
87 cont->x = child->x; 87 cont->x = child->x;
88 cont->y = child->y; 88 cont->y = child->y;
89 cont->visible = child->visible; 89 cont->visible = child->visible;
90 90
91 swayc_t *parent = replace_child(child, cont); 91 swayc_t *parent = replace_child(child, cont);
@@ -110,7 +110,7 @@ swayc_t *new_view(swayc_t *sibling, wlc_handle handle) {
110 handle, title, type, sibling, sibling?sibling->type:0); 110 handle, title, type, sibling, sibling?sibling->type:0);
111 //Setup values 111 //Setup values
112 view->handle = handle; 112 view->handle = handle;
113 view->name = strdup(title); 113 view->name = strdup(title);
114 view->visible = true; 114 view->visible = true;
115 115
116 //Case of focused workspace, just create as child of it 116 //Case of focused workspace, just create as child of it
diff --git a/sway/handlers.c b/sway/handlers.c
index a85eb681..4b1216bc 100644
--- a/sway/handlers.c
+++ b/sway/handlers.c
@@ -15,7 +15,7 @@ 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 18 //Determine the output that the view is under
19 swayc_t *parent = view; 19 swayc_t *parent = view;
20 while (parent->type != C_OUTPUT) { 20 while (parent->type != C_OUTPUT) {
21 parent = parent->parent; 21 parent = parent->parent;
@@ -192,9 +192,9 @@ static bool handle_pointer_motion(wlc_handle view, uint32_t time, const struct w
192 swayc_t *c = find_container(&root_container, pointer_test, (void *)origin); 192 swayc_t *c = find_container(&root_container, pointer_test, (void *)origin);
193 swayc_t *focused = get_focused_container(&root_container); 193 swayc_t *focused = get_focused_container(&root_container);
194 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); 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); 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); 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);
198 sway_log(L_DEBUG, "Switching focus to %p", c); 198 sway_log(L_DEBUG, "Switching focus to %p", c);
199 unfocus_all(&root_container); 199 unfocus_all(&root_container);
200 focus_view(c); 200 focus_view(c);
diff --git a/sway/layout.c b/sway/layout.c
index 4fd6aff9..3fd7f5c1 100644
--- a/sway/layout.c
+++ b/sway/layout.c
@@ -179,7 +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 layout_log(&root_container, 0);
183} 183}
184 184
185swayc_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 3f4590e2..1f7aeb64 100644
--- a/sway/workspace.c
+++ b/sway/workspace.c
@@ -94,70 +94,80 @@ swayc_t *workspace_find_by_name(const char* name) {
94} 94}
95 95
96void workspace_switch(swayc_t *workspace) { 96void workspace_switch(swayc_t *workspace) {
97 if (workspace != active_workspace && active_workspace) { 97 swayc_t *parent = workspace;
98 sway_log(L_DEBUG, "workspace: changing from '%s' to '%s'", active_workspace->name, workspace->name); 98 while (parent->type != C_OUTPUT) {
99 parent = parent->parent;
100 }
101 // The current workspace of the output our target workspace is in
102 swayc_t *c_workspace = parent->focused;
103 if (workspace != c_workspace && c_workspace) {
104 sway_log(L_DEBUG, "workspace: changing from '%s' to '%s'", c_workspace->name, workspace->name);
99 uint32_t mask = 1; 105 uint32_t mask = 1;
100 // set all c_views in the old workspace to the invisible mask
101 container_map(active_workspace, set_mask, &mask);
102 106
103 // and c_views in the new workspace to the visible mask 107 // set all c_views in the old workspace to the invisible mask if the workspace
108 // is in the same output & c_views in the new workspace to the visible mask
109
110 container_map(c_workspace, set_mask, &mask);
104 mask = 2; 111 mask = 2;
105 container_map(workspace, set_mask, &mask); 112 container_map(workspace, set_mask, &mask);
106
107 wlc_output_set_mask(wlc_get_focused_output(), 2); 113 wlc_output_set_mask(wlc_get_focused_output(), 2);
114
115
116 //wlc_output_set_mask(wlc_get_focused_output(), 2);
108 unfocus_all(&root_container); 117 unfocus_all(&root_container);
109 focus_view(workspace); 118 focus_view(workspace);
110 destroy_workspace(active_workspace); 119
120 destroy_workspace(c_workspace);
111 } 121 }
112 active_workspace = workspace; 122 active_workspace = workspace;
113} 123}
114 124
115/* XXX:DEBUG:XXX */ 125/* XXX:DEBUG:XXX */
116static void container_log(const swayc_t *c) { 126static void container_log(const swayc_t *c) {
117 fprintf(stderr, "focus:%c|", 127 fprintf(stderr, "focus:%c|",
118 c == get_focused_container(&root_container) ? 'F' : //Focused 128 c == get_focused_container(&root_container) ? 'F' : //Focused
119 c == active_workspace ? 'W' : //active workspace 129 c == active_workspace ? 'W' : //active workspace
120 c == &root_container ? 'R' : //root 130 c == &root_container ? 'R' : //root
121 'X');//not any others 131 'X');//not any others
122 fprintf(stderr,"(%p)",c); 132 fprintf(stderr,"(%p)",c);
123 fprintf(stderr,"(p:%p)",c->parent); 133 fprintf(stderr,"(p:%p)",c->parent);
124 fprintf(stderr,"(f:%p)",c->focused); 134 fprintf(stderr,"(f:%p)",c->focused);
125 fprintf(stderr,"Type:"); 135 fprintf(stderr,"Type:");
126 fprintf(stderr, 136 fprintf(stderr,
127 c->type == C_ROOT ? "Root|" : 137 c->type == C_ROOT ? "Root|" :
128 c->type == C_OUTPUT ? "Output|" : 138 c->type == C_OUTPUT ? "Output|" :
129 c->type == C_WORKSPACE ? "Workspace|" : 139 c->type == C_WORKSPACE ? "Workspace|" :
130 c->type == C_CONTAINER ? "Container|" : 140 c->type == C_CONTAINER ? "Container|" :
131 c->type == C_VIEW ? "View|" : 141 c->type == C_VIEW ? "View|" :
132 "Unknown|"); 142 "Unknown|");
133 fprintf(stderr,"layout:"); 143 fprintf(stderr,"layout:");
134 fprintf(stderr, 144 fprintf(stderr,
135 c->layout == L_NONE ? "NONE|" : 145 c->layout == L_NONE ? "NONE|" :
136 c->layout == L_HORIZ ? "Horiz|": 146 c->layout == L_HORIZ ? "Horiz|":
137 c->layout == L_VERT ? "Vert|": 147 c->layout == L_VERT ? "Vert|":
138 c->layout == L_STACKED ? "Stacked|": 148 c->layout == L_STACKED ? "Stacked|":
139 c->layout == L_FLOATING ? "Floating|": 149 c->layout == L_FLOATING ? "Floating|":
140 "Unknown|"); 150 "Unknown|");
141 fprintf(stderr, "w:%d|h:%d|", c->width, c->height); 151 fprintf(stderr, "w:%d|h:%d|", c->width, c->height);
142 fprintf(stderr, "x:%d|y:%d|", c->x, c->y); 152 fprintf(stderr, "x:%d|y:%d|", c->x, c->y);
143 fprintf(stderr, "vis:%c|", c->visible?'t':'f'); 153 fprintf(stderr, "vis:%c|", c->visible?'t':'f');
144 fprintf(stderr, "wgt:%d|", c->weight); 154 fprintf(stderr, "wgt:%d|", c->weight);
145 fprintf(stderr, "name:%.16s|", c->name); 155 fprintf(stderr, "name:%.16s|", c->name);
146 fprintf(stderr, "children:%d\n",c->children?c->children->length:0); 156 fprintf(stderr, "children:%d\n",c->children?c->children->length:0);
147} 157}
148void layout_log(const swayc_t *c, int depth) { 158void layout_log(const swayc_t *c, int depth) {
149 int i; 159 int i;
150 int e = c->children?c->children->length:0; 160 int e = c->children?c->children->length:0;
151 for (i = 0; i < depth; ++i) fputc(' ', stderr); 161 for (i = 0; i < depth; ++i) fputc(' ', stderr);
152 container_log(c); 162 container_log(c);
153 if (e) { 163 if (e) {
154 for (i = 0; i < depth; ++i) fputc(' ', stderr); 164 for (i = 0; i < depth; ++i) fputc(' ', stderr);
155 fprintf(stderr,"(\n"); 165 fprintf(stderr,"(\n");
156 for (i = 0; i < e; ++i) { 166 for (i = 0; i < e; ++i) {
157 layout_log(c->children->items[i], depth + 1); 167 layout_log(c->children->items[i], depth + 1);
158 } 168 }
159 for (i = 0; i < depth; ++i) fputc(' ', stderr); 169 for (i = 0; i < depth; ++i) fputc(' ', stderr);
160 fprintf(stderr,")\n"); 170 fprintf(stderr,")\n");
161 } 171 }
162} 172}
163/* XXX:DEBUG:XXX */ 173/* XXX:DEBUG:XXX */