aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/view.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-06-06 19:19:30 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-06-09 10:08:43 +1000
commitf9e6d703d298dbdee0770fd9e0c64ab2d7ac7deb (patch)
tree8c8ffd879e368aff3d749a637aabfa784800db5c /sway/tree/view.c
parentWIP: Atomic layout updates ground work (diff)
downloadsway-f9e6d703d298dbdee0770fd9e0c64ab2d7ac7deb.tar.gz
sway-f9e6d703d298dbdee0770fd9e0c64ab2d7ac7deb.tar.zst
sway-f9e6d703d298dbdee0770fd9e0c64ab2d7ac7deb.zip
Make main properties be the pending state
Diffstat (limited to 'sway/tree/view.c')
-rw-r--r--sway/tree/view.c90
1 files changed, 43 insertions, 47 deletions
diff --git a/sway/tree/view.c b/sway/tree/view.c
index 40fe2740..dbf803c6 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -187,23 +187,23 @@ void view_autoconfigure(struct sway_view *view) {
187 } 187 }
188 } 188 }
189 189
190 struct sway_container_state *state = &view->swayc->pending; 190 struct sway_container *con = view->swayc;
191 191
192 state->border_top = state->border_bottom = true; 192 view->border_top = view->border_bottom = true;
193 state->border_left = state->border_right = true; 193 view->border_left = view->border_right = true;
194 if (config->hide_edge_borders == E_BOTH 194 if (config->hide_edge_borders == E_BOTH
195 || config->hide_edge_borders == E_VERTICAL 195 || config->hide_edge_borders == E_VERTICAL
196 || (config->hide_edge_borders == E_SMART && !other_views)) { 196 || (config->hide_edge_borders == E_SMART && !other_views)) {
197 state->border_left = state->swayc_x != ws->x; 197 view->border_left = con->x != ws->x;
198 int right_x = state->swayc_x + state->swayc_width; 198 int right_x = con->x + con->width;
199 state->border_right = right_x != ws->x + ws->width; 199 view->border_right = right_x != ws->x + ws->width;
200 } 200 }
201 if (config->hide_edge_borders == E_BOTH 201 if (config->hide_edge_borders == E_BOTH
202 || config->hide_edge_borders == E_HORIZONTAL 202 || config->hide_edge_borders == E_HORIZONTAL
203 || (config->hide_edge_borders == E_SMART && !other_views)) { 203 || (config->hide_edge_borders == E_SMART && !other_views)) {
204 state->border_top = state->swayc_y != ws->y; 204 view->border_top = con->y != ws->y;
205 int bottom_y = state->swayc_y + state->swayc_height; 205 int bottom_y = con->y + con->height;
206 state->border_bottom = bottom_y != ws->y + ws->height; 206 view->border_bottom = bottom_y != ws->y + ws->height;
207 } 207 }
208 208
209 double x, y, width, height; 209 double x, y, width, height;
@@ -213,54 +213,53 @@ void view_autoconfigure(struct sway_view *view) {
213 // In a tabbed or stacked container, the swayc's y is the top of the title 213 // In a tabbed or stacked container, the swayc's y is the top of the title
214 // area. We have to offset the surface y by the height of the title bar, and 214 // area. We have to offset the surface y by the height of the title bar, and
215 // disable any top border because we'll always have the title bar. 215 // disable any top border because we'll always have the title bar.
216 if (view->swayc->parent->pending.layout == L_TABBED) { 216 if (con->parent->layout == L_TABBED) {
217 y_offset = container_titlebar_height(); 217 y_offset = container_titlebar_height();
218 state->border_top = false; 218 view->border_top = false;
219 } else if (view->swayc->parent->pending.layout == L_STACKED) { 219 } else if (con->parent->layout == L_STACKED) {
220 y_offset = container_titlebar_height() 220 y_offset = container_titlebar_height() * con->parent->children->length;
221 * view->swayc->parent->children->length;
222 view->border_top = false; 221 view->border_top = false;
223 } 222 }
224 223
225 switch (state->border) { 224 switch (view->border) {
226 case B_NONE: 225 case B_NONE:
227 x = state->swayc_x; 226 x = con->x;
228 y = state->swayc_y + y_offset; 227 y = con->y + y_offset;
229 width = state->swayc_width; 228 width = con->width;
230 height = state->swayc_height - y_offset; 229 height = con->height - y_offset;
231 break; 230 break;
232 case B_PIXEL: 231 case B_PIXEL:
233 x = state->swayc_x + state->border_thickness * state->border_left; 232 x = con->x + view->border_thickness * view->border_left;
234 y = state->swayc_y + state->border_thickness * state->border_top + y_offset; 233 y = con->y + view->border_thickness * view->border_top + y_offset;
235 width = state->swayc_width 234 width = con->width
236 - state->border_thickness * state->border_left 235 - view->border_thickness * view->border_left
237 - state->border_thickness * state->border_right; 236 - view->border_thickness * view->border_right;
238 height = state->swayc_height - y_offset 237 height = con->height - y_offset
239 - state->border_thickness * state->border_top 238 - view->border_thickness * view->border_top
240 - state->border_thickness * state->border_bottom; 239 - view->border_thickness * view->border_bottom;
241 break; 240 break;
242 case B_NORMAL: 241 case B_NORMAL:
243 // Height is: 1px border + 3px pad + title height + 3px pad + 1px border 242 // Height is: 1px border + 3px pad + title height + 3px pad + 1px border
244 x = state->swayc_x + state->border_thickness * state->border_left; 243 x = con->x + view->border_thickness * view->border_left;
245 width = state->swayc_width 244 width = con->width
246 - state->border_thickness * state->border_left 245 - view->border_thickness * view->border_left
247 - state->border_thickness * state->border_right; 246 - view->border_thickness * view->border_right;
248 if (y_offset) { 247 if (y_offset) {
249 y = state->swayc_y + y_offset; 248 y = con->y + y_offset;
250 height = state->swayc_height - y_offset 249 height = con->height - y_offset
251 - state->border_thickness * state->border_bottom; 250 - view->border_thickness * view->border_bottom;
252 } else { 251 } else {
253 y = state->swayc_y + container_titlebar_height(); 252 y = con->y + container_titlebar_height();
254 height = state->swayc_height - container_titlebar_height() 253 height = con->height - container_titlebar_height()
255 - state->border_thickness * state->border_bottom; 254 - view->border_thickness * view->border_bottom;
256 } 255 }
257 break; 256 break;
258 } 257 }
259 258
260 state->view_x = x; 259 view->x = x;
261 state->view_y = y; 260 view->y = y;
262 state->view_width = width; 261 view->width = width;
263 state->view_height = height; 262 view->height = height;
264} 263}
265 264
266void view_set_activated(struct sway_view *view, bool activated) { 265void view_set_activated(struct sway_view *view, bool activated) {
@@ -319,9 +318,8 @@ void view_set_fullscreen_raw(struct sway_view *view, bool fullscreen) {
319 view_configure(view, view->saved_x, view->saved_y, 318 view_configure(view, view->saved_x, view->saved_y,
320 view->saved_width, view->saved_height); 319 view->saved_width, view->saved_height);
321 } else { 320 } else {
322 view->swayc->width = view->swayc->saved_width; 321 view->swayc->width = view->swayc->saved_width;
323 view->swayc->height = view->swayc->saved_height; 322 view->swayc->height = view->swayc->saved_height;
324 view_autoconfigure(view);
325 } 323 }
326 } 324 }
327} 325}
@@ -508,8 +506,6 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface) {
508 view->swayc = cont; 506 view->swayc = cont;
509 view->border = config->border; 507 view->border = config->border;
510 view->border_thickness = config->border_thickness; 508 view->border_thickness = config->border_thickness;
511 view->swayc->pending.border = config->border;
512 view->swayc->pending.border_thickness = config->border_thickness;
513 509
514 view_init_subsurfaces(view, wlr_surface); 510 view_init_subsurfaces(view, wlr_surface);
515 wl_signal_add(&wlr_surface->events.new_subsurface, 511 wl_signal_add(&wlr_surface->events.new_subsurface,
@@ -977,7 +973,7 @@ bool view_is_visible(struct sway_view *view) {
977 } 973 }
978 // Check the workspace is visible 974 // Check the workspace is visible
979 if (!is_sticky) { 975 if (!is_sticky) {
980 return workspace_is_visible(workspace); 976 return workspace_is_visible(workspace);
981 } 977 }
982 return true; 978 return true;
983} 979}