diff options
author | 2015-08-15 15:13:24 -0400 | |
---|---|---|
committer | 2015-08-15 15:13:24 -0400 | |
commit | 8b90f283bc58d50288325097b3aeea617277d7a3 (patch) | |
tree | 3fe673b4372f019f9ed28e1e1c5d5ff9eb81a237 | |
parent | Merge pull request #30 from taiyu-len/master (diff) | |
parent | Minor style fix (diff) | |
download | sway-8b90f283bc58d50288325097b3aeea617277d7a3.tar.gz sway-8b90f283bc58d50288325097b3aeea617277d7a3.tar.zst sway-8b90f283bc58d50288325097b3aeea617277d7a3.zip |
Merge pull request #31 from Luminarys/master
Multi output fixes
-rw-r--r-- | sway/container.c | 30 | ||||
-rw-r--r-- | sway/handlers.c | 8 | ||||
-rw-r--r-- | sway/layout.c | 1 | ||||
-rw-r--r-- | sway/workspace.c | 71 | ||||
-rw-r--r-- | sway/workspace.h | 1 |
5 files changed, 87 insertions, 24 deletions
diff --git a/sway/container.c b/sway/container.c index b52ffd8c..189f064b 100644 --- a/sway/container.c +++ b/sway/container.c | |||
@@ -47,9 +47,9 @@ swayc_t *new_output(wlc_handle handle) { | |||
47 | const struct wlc_size* size = wlc_output_get_resolution(handle); | 47 | const struct wlc_size* size = wlc_output_get_resolution(handle); |
48 | 48 | ||
49 | swayc_t *output = new_swayc(C_OUTPUT); | 49 | swayc_t *output = new_swayc(C_OUTPUT); |
50 | output->width = size->w; | 50 | output->width = size->w; |
51 | output->height = size->h; | 51 | output->height = size->h; |
52 | output->handle = handle; | 52 | output->handle = handle; |
53 | 53 | ||
54 | add_child(&root_container, output); | 54 | add_child(&root_container, output); |
55 | 55 | ||
@@ -69,10 +69,10 @@ swayc_t *new_workspace(swayc_t * output, const char *name) { | |||
69 | sway_log(L_DEBUG, "Added workspace %s for output %d", name, output->handle); | 69 | sway_log(L_DEBUG, "Added workspace %s for output %d", name, output->handle); |
70 | swayc_t *workspace = new_swayc(C_WORKSPACE); | 70 | swayc_t *workspace = new_swayc(C_WORKSPACE); |
71 | 71 | ||
72 | workspace->layout = L_HORIZ; // TODO:default layout | 72 | workspace->layout = L_HORIZ; // TODO:default layout |
73 | workspace->width = output->width; | 73 | workspace->width = output->width; |
74 | workspace->height = output->height; | 74 | workspace->height = output->height; |
75 | workspace->name = strdup(name); | 75 | workspace->name = strdup(name); |
76 | workspace->visible = true; | 76 | workspace->visible = true; |
77 | 77 | ||
78 | add_child(output, workspace); | 78 | add_child(output, workspace); |
@@ -84,12 +84,12 @@ swayc_t *new_container(swayc_t *child, enum swayc_layouts layout) { | |||
84 | 84 | ||
85 | sway_log(L_DEBUG, "creating container %p around %p", cont, child); | 85 | sway_log(L_DEBUG, "creating container %p around %p", cont, child); |
86 | 86 | ||
87 | cont->layout = layout; | 87 | cont->layout = layout; |
88 | cont->width = child->width; | 88 | cont->width = child->width; |
89 | cont->height = child->height; | 89 | cont->height = child->height; |
90 | cont->x = child->x; | 90 | cont->x = child->x; |
91 | cont->y = child->y; | 91 | cont->y = child->y; |
92 | cont->visible = child->visible; | 92 | cont->visible = child->visible; |
93 | 93 | ||
94 | /* Container inherits all of workspaces children, layout and whatnot */ | 94 | /* Container inherits all of workspaces children, layout and whatnot */ |
95 | if (child->type == C_WORKSPACE) { | 95 | if (child->type == C_WORKSPACE) { |
@@ -131,8 +131,8 @@ swayc_t *new_view(swayc_t *sibling, wlc_handle handle) { | |||
131 | sway_log(L_DEBUG, "Adding new view %d:%s:%d to container %p %d", | 131 | sway_log(L_DEBUG, "Adding new view %d:%s:%d to container %p %d", |
132 | handle, title, type, sibling, sibling?sibling->type:0); | 132 | handle, title, type, sibling, sibling?sibling->type:0); |
133 | //Setup values | 133 | //Setup values |
134 | view->handle = handle; | 134 | view->handle = handle; |
135 | view->name = strdup(title); | 135 | view->name = strdup(title); |
136 | view->visible = true; | 136 | view->visible = true; |
137 | 137 | ||
138 | //Case of focused workspace, just create as child of it | 138 | //Case of focused workspace, just create as child of it |
diff --git a/sway/handlers.c b/sway/handlers.c index 393a2181..f95683d0 100644 --- a/sway/handlers.c +++ b/sway/handlers.c | |||
@@ -15,9 +15,14 @@ static struct wlc_origin mouse_origin; | |||
15 | 15 | ||
16 | static bool pointer_test(swayc_t *view, void *_origin) { | 16 | static 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; |
@@ -254,4 +259,3 @@ struct wlc_interface interface = { | |||
254 | .ready = handle_wlc_ready | 259 | .ready = handle_wlc_ready |
255 | } | 260 | } |
256 | }; | 261 | }; |
257 | |||
diff --git a/sway/layout.c b/sway/layout.c index e2e91593..3fd7f5c1 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 | ||
184 | swayc_t *get_swayc_for_handle(wlc_handle handle, swayc_t *parent) { | 185 | swayc_t *get_swayc_for_handle(wlc_handle handle, swayc_t *parent) { |
diff --git a/sway/workspace.c b/sway/workspace.c index cd5472e3..9748c23f 100644 --- a/sway/workspace.c +++ b/sway/workspace.c | |||
@@ -94,20 +94,77 @@ swayc_t *workspace_find_by_name(const char* name) { | |||
94 | } | 94 | } |
95 | 95 | ||
96 | void workspace_switch(swayc_t *workspace) { | 96 | void 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 | container_map(c_workspace, set_mask, &mask); | ||
104 | mask = 2; | 110 | mask = 2; |
105 | container_map(workspace, set_mask, &mask); | 111 | container_map(workspace, set_mask, &mask); |
106 | |||
107 | wlc_output_set_mask(wlc_get_focused_output(), 2); | 112 | wlc_output_set_mask(wlc_get_focused_output(), 2); |
113 | |||
108 | unfocus_all(&root_container); | 114 | unfocus_all(&root_container); |
109 | focus_view(workspace); | 115 | focus_view(workspace); |
110 | destroy_workspace(active_workspace); | 116 | |
117 | destroy_workspace(c_workspace); | ||
111 | } | 118 | } |
112 | active_workspace = workspace; | 119 | active_workspace = workspace; |
113 | } | 120 | } |
121 | |||
122 | /* XXX:DEBUG:XXX */ | ||
123 | static void container_log(const swayc_t *c) { | ||
124 | fprintf(stderr, "focus:%c|", | ||
125 | c == get_focused_container(&root_container) ? 'F' : //Focused | ||
126 | c == active_workspace ? 'W' : //active workspace | ||
127 | c == &root_container ? 'R' : //root | ||
128 | 'X');//not any others | ||
129 | fprintf(stderr,"(%p)",c); | ||
130 | fprintf(stderr,"(p:%p)",c->parent); | ||
131 | fprintf(stderr,"(f:%p)",c->focused); | ||
132 | fprintf(stderr,"Type:"); | ||
133 | fprintf(stderr, | ||
134 | c->type == C_ROOT ? "Root|" : | ||
135 | c->type == C_OUTPUT ? "Output|" : | ||
136 | c->type == C_WORKSPACE ? "Workspace|" : | ||
137 | c->type == C_CONTAINER ? "Container|" : | ||
138 | c->type == C_VIEW ? "View|" : | ||
139 | "Unknown|"); | ||
140 | fprintf(stderr,"layout:"); | ||
141 | fprintf(stderr, | ||
142 | c->layout == L_NONE ? "NONE|" : | ||
143 | c->layout == L_HORIZ ? "Horiz|": | ||
144 | c->layout == L_VERT ? "Vert|": | ||
145 | c->layout == L_STACKED ? "Stacked|": | ||
146 | c->layout == L_FLOATING ? "Floating|": | ||
147 | "Unknown|"); | ||
148 | fprintf(stderr, "w:%d|h:%d|", c->width, c->height); | ||
149 | fprintf(stderr, "x:%d|y:%d|", c->x, c->y); | ||
150 | fprintf(stderr, "vis:%c|", c->visible?'t':'f'); | ||
151 | fprintf(stderr, "wgt:%d|", c->weight); | ||
152 | fprintf(stderr, "name:%.16s|", c->name); | ||
153 | fprintf(stderr, "children:%d\n",c->children?c->children->length:0); | ||
154 | } | ||
155 | void layout_log(const swayc_t *c, int depth) { | ||
156 | int i; | ||
157 | int e = c->children?c->children->length:0; | ||
158 | for (i = 0; i < depth; ++i) fputc(' ', stderr); | ||
159 | container_log(c); | ||
160 | if (e) { | ||
161 | for (i = 0; i < depth; ++i) fputc(' ', stderr); | ||
162 | fprintf(stderr,"(\n"); | ||
163 | for (i = 0; i < e; ++i) { | ||
164 | layout_log(c->children->items[i], depth + 1); | ||
165 | } | ||
166 | for (i = 0; i < depth; ++i) fputc(' ', stderr); | ||
167 | fprintf(stderr,")\n"); | ||
168 | } | ||
169 | } | ||
170 | /* 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); | |||
11 | swayc_t *workspace_create(const char*); | 11 | swayc_t *workspace_create(const char*); |
12 | swayc_t *workspace_find_by_name(const char*); | 12 | swayc_t *workspace_find_by_name(const char*); |
13 | void workspace_switch(swayc_t*); | 13 | void workspace_switch(swayc_t*); |
14 | void layout_log(const swayc_t *c, int depth); | ||
14 | 15 | ||
15 | #endif | 16 | #endif |