mirror of
				https://github.com/swaywm/sway.git
				synced 2025-11-03 09:01:43 -05:00 
			
		
		
		
	Tabbed and stacked layout
This commit is contained in:
		
							parent
							
								
									7efa9ab34a
								
							
						
					
					
						commit
						ec7ff769c7
					
				
					 6 changed files with 254 additions and 80 deletions
				
			
		| 
						 | 
					@ -91,7 +91,7 @@ int get_font_text_height(const char *font) {
 | 
				
			||||||
	return height;
 | 
						return height;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void render_borders(swayc_t *view, cairo_t *cr, struct border_colors *colors) {
 | 
					static void render_borders(swayc_t *view, cairo_t *cr, struct border_colors *colors, bool top) {
 | 
				
			||||||
	struct wlc_geometry *b = &view->border_geometry;
 | 
						struct wlc_geometry *b = &view->border_geometry;
 | 
				
			||||||
	struct wlc_geometry *v = &view->actual_geometry;
 | 
						struct wlc_geometry *v = &view->actual_geometry;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -118,7 +118,7 @@ static void render_borders(swayc_t *view, cairo_t *cr, struct border_colors *col
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// top border
 | 
						// top border
 | 
				
			||||||
	int top_border = v->origin.y - b->origin.y;
 | 
						int top_border = v->origin.y - b->origin.y;
 | 
				
			||||||
	if (top_border > 0) {
 | 
						if (top && top_border > 0) {
 | 
				
			||||||
		render_sharp_line(cr,
 | 
							render_sharp_line(cr,
 | 
				
			||||||
				colors->child_border,
 | 
									colors->child_border,
 | 
				
			||||||
				0, 0,
 | 
									0, 0,
 | 
				
			||||||
| 
						 | 
					@ -138,38 +138,69 @@ static void render_borders(swayc_t *view, cairo_t *cr, struct border_colors *col
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void render_with_title_bar(swayc_t *view, cairo_t *cr, struct border_colors *colors) {
 | 
					static void render_title_bar(swayc_t *view, cairo_t *cr, struct border_colors *colors) {
 | 
				
			||||||
	struct wlc_geometry *tb = &view->title_bar_geometry;
 | 
						struct wlc_geometry *tb = &view->title_bar_geometry;
 | 
				
			||||||
	struct wlc_geometry *b = &view->border_geometry;
 | 
						struct wlc_geometry *b = &view->border_geometry;
 | 
				
			||||||
	int title_y = MIN(view->actual_geometry.origin.y - (int)tb->size.h, 0);
 | 
						int title_y = MIN(view->actual_geometry.origin.y - (int)tb->size.h, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// borders
 | 
						// borders
 | 
				
			||||||
	render_borders(view, cr, colors);
 | 
						/* render_borders(view, cr, colors); */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						int x = tb->origin.x - b->origin.x;
 | 
				
			||||||
 | 
						int y = tb->origin.y - b->origin.y;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/* // title bar background */
 | 
				
			||||||
 | 
						/* cairo_set_source_u32(cr, colors->child_border); */
 | 
				
			||||||
 | 
						/* cairo_rectangle(cr, x, y, tb->size.w, tb->size.h); */
 | 
				
			||||||
 | 
						/* cairo_fill(cr); */
 | 
				
			||||||
	// title bar background
 | 
						// title bar background
 | 
				
			||||||
	cairo_set_source_u32(cr, colors->background);
 | 
						cairo_set_source_u32(cr, colors->background);
 | 
				
			||||||
	cairo_rectangle(cr, 0, title_y, tb->size.w, tb->size.h);
 | 
						cairo_rectangle(cr, 0, title_y, tb->size.w, tb->size.h);
 | 
				
			||||||
	cairo_fill(cr);
 | 
						cairo_fill(cr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// header top line
 | 
						// header top line
 | 
				
			||||||
 | 
						/* render_sharp_line(cr, colors->border, x, y, tb->size.w, 1); */
 | 
				
			||||||
	render_sharp_line(cr, colors->border, 0, title_y, tb->size.w, 1);
 | 
						render_sharp_line(cr, colors->border, 0, title_y, tb->size.w, 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// text
 | 
						// text
 | 
				
			||||||
	if (view->name) {
 | 
						if (view->name) {
 | 
				
			||||||
		int width, height;
 | 
							int width, height;
 | 
				
			||||||
		get_text_size(cr, config->font, &width, &height, false, "%s", view->name);
 | 
							get_text_size(cr, config->font, &width, &height, false, "%s", view->name);
 | 
				
			||||||
		int x = MIN(view->actual_geometry.origin.x, view->border_thickness);
 | 
							int x_text = MIN(view->actual_geometry.origin.x, view->border_thickness);
 | 
				
			||||||
		int y = MIN(view->actual_geometry.origin.y - height - 2, 2);
 | 
							int y_text = MIN(view->actual_geometry.origin.y - height - 2, 2);
 | 
				
			||||||
		cairo_move_to(cr, x, y);
 | 
							cairo_move_to(cr, x_text, y_text);
 | 
				
			||||||
		cairo_set_source_u32(cr, colors->text);
 | 
							cairo_set_source_u32(cr, colors->text);
 | 
				
			||||||
		pango_printf(cr, config->font, false, "%s", view->name);
 | 
							pango_printf(cr, config->font, false, "%s", view->name);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// titlebars has a border all around for tabbed layouts
 | 
				
			||||||
 | 
						if (view->parent->layout == L_TABBED) {
 | 
				
			||||||
 | 
							// header bottom line
 | 
				
			||||||
 | 
							render_sharp_line(cr, colors->border, x, y + tb->size.h - 1,
 | 
				
			||||||
 | 
									tb->size.w, 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							// left border
 | 
				
			||||||
 | 
							render_sharp_line(cr, colors->border, x, y, 1, tb->size.h);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							// right border
 | 
				
			||||||
 | 
							render_sharp_line(cr, colors->border, x + tb->size.w - 1, y,
 | 
				
			||||||
 | 
									1, tb->size.h);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if ((uint32_t)(view->actual_geometry.origin.y - tb->origin.y) == tb->size.h) {
 | 
				
			||||||
		// header bottom line
 | 
							// header bottom line
 | 
				
			||||||
		render_sharp_line(cr, colors->border,
 | 
							render_sharp_line(cr, colors->border,
 | 
				
			||||||
			view->actual_geometry.origin.x - b->origin.x,
 | 
									x + view->actual_geometry.origin.x - b->origin.x,
 | 
				
			||||||
			title_y + tb->size.h - 1,
 | 
									y + tb->size.h - 1,
 | 
				
			||||||
				view->actual_geometry.size.w, 1);
 | 
									view->actual_geometry.size.w, 1);
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							// header bottom line
 | 
				
			||||||
 | 
							render_sharp_line(cr, colors->border, x,
 | 
				
			||||||
 | 
									title_y + tb->size.h - 1,
 | 
				
			||||||
 | 
									tb->size.w, 1);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void map_update_view_border(swayc_t *view, void *data) {
 | 
					void map_update_view_border(swayc_t *view, void *data) {
 | 
				
			||||||
| 
						 | 
					@ -179,6 +210,10 @@ void map_update_view_border(swayc_t *view, void *data) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void update_view_border(swayc_t *view) {
 | 
					void update_view_border(swayc_t *view) {
 | 
				
			||||||
 | 
						if (!view->visible) {
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cairo_t *cr = NULL;
 | 
						cairo_t *cr = NULL;
 | 
				
			||||||
	cairo_surface_t *surface = NULL;
 | 
						cairo_surface_t *surface = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -187,6 +222,7 @@ void update_view_border(swayc_t *view) {
 | 
				
			||||||
		view->border = NULL;
 | 
							view->border = NULL;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// get focused and focused_intactive views
 | 
				
			||||||
	swayc_t *focused = get_focused_view(&root_container);
 | 
						swayc_t *focused = get_focused_view(&root_container);
 | 
				
			||||||
	swayc_t *container = swayc_parent_by_type(view, C_CONTAINER);
 | 
						swayc_t *container = swayc_parent_by_type(view, C_CONTAINER);
 | 
				
			||||||
	swayc_t *focused_inactive = NULL;
 | 
						swayc_t *focused_inactive = NULL;
 | 
				
			||||||
| 
						 | 
					@ -199,6 +235,31 @@ void update_view_border(swayc_t *view) {
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						swayc_t *p = view->parent;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (p->layout == L_TABBED || p->layout == L_STACKED) {
 | 
				
			||||||
 | 
							cr = create_border_buffer(view, view->border_geometry, &surface);
 | 
				
			||||||
 | 
							if (focused == view) {
 | 
				
			||||||
 | 
								render_borders(view, cr, &config->border_colors.focused, false);
 | 
				
			||||||
 | 
							} else if (focused_inactive == view) {
 | 
				
			||||||
 | 
								render_borders(view, cr, &config->border_colors.focused_inactive, false);
 | 
				
			||||||
 | 
							} else {
 | 
				
			||||||
 | 
								render_borders(view, cr, &config->border_colors.unfocused, false);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							int i;
 | 
				
			||||||
 | 
							for (i = 0; i < p->children->length; ++i) {
 | 
				
			||||||
 | 
								swayc_t *child = p->children->items[i];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if (focused == child) {
 | 
				
			||||||
 | 
									render_title_bar(child, cr, &config->border_colors.focused);
 | 
				
			||||||
 | 
								} else if (focused_inactive == child) {
 | 
				
			||||||
 | 
									render_title_bar(child, cr, &config->border_colors.focused_inactive);
 | 
				
			||||||
 | 
								} else {
 | 
				
			||||||
 | 
									render_title_bar(child, cr, &config->border_colors.unfocused);
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
		switch (view->border_type) {
 | 
							switch (view->border_type) {
 | 
				
			||||||
		case B_NONE:
 | 
							case B_NONE:
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
| 
						 | 
					@ -209,11 +270,11 @@ void update_view_border(swayc_t *view) {
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if (focused == view) {
 | 
								if (focused == view) {
 | 
				
			||||||
			render_borders(view, cr, &config->border_colors.focused);
 | 
									render_borders(view, cr, &config->border_colors.focused, true);
 | 
				
			||||||
			} else if (focused_inactive == view) {
 | 
								} else if (focused_inactive == view) {
 | 
				
			||||||
			render_borders(view, cr, &config->border_colors.focused_inactive);
 | 
									render_borders(view, cr, &config->border_colors.focused_inactive, true);
 | 
				
			||||||
			} else {
 | 
								} else {
 | 
				
			||||||
			render_borders(view, cr, &config->border_colors.unfocused);
 | 
									render_borders(view, cr, &config->border_colors.unfocused, true);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
| 
						 | 
					@ -224,15 +285,20 @@ void update_view_border(swayc_t *view) {
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if (focused == view) {
 | 
								if (focused == view) {
 | 
				
			||||||
			render_with_title_bar(view, cr, &config->border_colors.focused);
 | 
									render_borders(view, cr, &config->border_colors.focused, false);
 | 
				
			||||||
 | 
									render_title_bar(view, cr, &config->border_colors.focused);
 | 
				
			||||||
			} else if (focused_inactive == view) {
 | 
								} else if (focused_inactive == view) {
 | 
				
			||||||
			render_with_title_bar(view, cr, &config->border_colors.focused_inactive);
 | 
									render_borders(view, cr, &config->border_colors.focused_inactive, false);
 | 
				
			||||||
 | 
									render_title_bar(view, cr, &config->border_colors.focused_inactive);
 | 
				
			||||||
			} else {
 | 
								} else {
 | 
				
			||||||
			render_with_title_bar(view, cr, &config->border_colors.unfocused);
 | 
									render_borders(view, cr, &config->border_colors.unfocused, false);
 | 
				
			||||||
 | 
									render_title_bar(view, cr, &config->border_colors.unfocused);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (surface) {
 | 
						if (surface) {
 | 
				
			||||||
		cairo_surface_flush(surface);
 | 
							cairo_surface_flush(surface);
 | 
				
			||||||
		cairo_surface_destroy(surface);
 | 
							cairo_surface_destroy(surface);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1759,7 +1759,15 @@ static struct cmd_results *cmd_layout(int argc, char **argv) {
 | 
				
			||||||
		parent = parent->parent;
 | 
							parent = parent->parent;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (strcasecmp(argv[0], "splith") == 0) {
 | 
						if (strcasecmp(argv[0], "default") == 0) {
 | 
				
			||||||
 | 
							// TODO: determine default from default_orientation and
 | 
				
			||||||
 | 
							// cmd_workspace_layout
 | 
				
			||||||
 | 
							parent->layout = L_HORIZ;
 | 
				
			||||||
 | 
						} else if (strcasecmp(argv[0], "tabbed") == 0) {
 | 
				
			||||||
 | 
							parent->layout = L_TABBED;
 | 
				
			||||||
 | 
						} else if (strcasecmp(argv[0], "stacking") == 0) {
 | 
				
			||||||
 | 
							parent->layout = L_STACKED;
 | 
				
			||||||
 | 
						} else if (strcasecmp(argv[0], "splith") == 0) {
 | 
				
			||||||
		parent->layout = L_HORIZ;
 | 
							parent->layout = L_HORIZ;
 | 
				
			||||||
	} else if (strcasecmp(argv[0], "splitv") == 0) {
 | 
						} else if (strcasecmp(argv[0], "splitv") == 0) {
 | 
				
			||||||
		parent->layout = L_VERT;
 | 
							parent->layout = L_VERT;
 | 
				
			||||||
| 
						 | 
					@ -1770,6 +1778,7 @@ static struct cmd_results *cmd_layout(int argc, char **argv) {
 | 
				
			||||||
			parent->layout = L_VERT;
 | 
								parent->layout = L_VERT;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	arrange_windows(parent, parent->width, parent->height);
 | 
						arrange_windows(parent, parent->width, parent->height);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return cmd_results_new(CMD_SUCCESS, NULL, NULL);
 | 
						return cmd_results_new(CMD_SUCCESS, NULL, NULL);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -160,7 +160,7 @@ static void config_defaults(struct sway_config *config) {
 | 
				
			||||||
	config->dragging_key = M_LEFT_CLICK;
 | 
						config->dragging_key = M_LEFT_CLICK;
 | 
				
			||||||
	config->resizing_key = M_RIGHT_CLICK;
 | 
						config->resizing_key = M_RIGHT_CLICK;
 | 
				
			||||||
	config->floating_scroll = FSB_GAPS_INNER;
 | 
						config->floating_scroll = FSB_GAPS_INNER;
 | 
				
			||||||
	config->default_layout = L_NONE;
 | 
						config->default_layout = L_HORIZ;
 | 
				
			||||||
	config->default_orientation = L_NONE;
 | 
						config->default_orientation = L_NONE;
 | 
				
			||||||
	config->font = strdup("monospace 10");
 | 
						config->font = strdup("monospace 10");
 | 
				
			||||||
	config->font_height = get_font_text_height(config->font);
 | 
						config->font_height = get_font_text_height(config->font);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -725,7 +725,7 @@ void update_visibility_output(swayc_t *container, wlc_handle output) {
 | 
				
			||||||
	if (parent->type == C_OUTPUT
 | 
						if (parent->type == C_OUTPUT
 | 
				
			||||||
			|| parent->layout == L_TABBED
 | 
								|| parent->layout == L_TABBED
 | 
				
			||||||
			|| parent->layout == L_STACKED) {
 | 
								|| parent->layout == L_STACKED) {
 | 
				
			||||||
		container->visible = parent->focused == container;
 | 
							container->visible = parent->focused == container && parent->visible;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	// Set visibility and output for view
 | 
						// Set visibility and output for view
 | 
				
			||||||
	if (container->type == C_VIEW) {
 | 
						if (container->type == C_VIEW) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -141,9 +141,17 @@ bool set_focused_container(swayc_t *c) {
 | 
				
			||||||
			// set focus if view_focus is unlocked
 | 
								// set focus if view_focus is unlocked
 | 
				
			||||||
			if (!locked_view_focus) {
 | 
								if (!locked_view_focus) {
 | 
				
			||||||
				wlc_view_focus(p->handle);
 | 
									wlc_view_focus(p->handle);
 | 
				
			||||||
 | 
									if (p->parent->layout != L_TABBED
 | 
				
			||||||
 | 
										&& p->parent->layout != L_STACKED) {
 | 
				
			||||||
					update_view_border(p);
 | 
										update_view_border(p);
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							// rearrange if parent container is tabbed/stacked
 | 
				
			||||||
 | 
							if (p->parent->layout == L_TABBED || p->parent->layout == L_STACKED) {
 | 
				
			||||||
 | 
								arrange_windows(p->parent, -1, -1);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	} else if (p->type == C_WORKSPACE) {
 | 
						} else if (p->type == C_WORKSPACE) {
 | 
				
			||||||
		// remove previous focus if view_focus is unlocked
 | 
							// remove previous focus if view_focus is unlocked
 | 
				
			||||||
		if (!locked_view_focus) {
 | 
							if (!locked_view_focus) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										109
									
								
								sway/layout.c
									
										
									
									
									
								
							
							
						
						
									
										109
									
								
								sway/layout.c
									
										
									
									
									
								
							| 
						 | 
					@ -453,14 +453,24 @@ void update_geometry(swayc_t *container) {
 | 
				
			||||||
		gap -= 1;
 | 
							gap -= 1;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						int width = container->width;
 | 
				
			||||||
 | 
						int height = container->height;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// use parent size if window is in a stacked/tabbed layout
 | 
				
			||||||
 | 
						swayc_t *parent = container->parent;
 | 
				
			||||||
 | 
						if (parent->layout == L_STACKED || parent->layout == L_TABBED) {
 | 
				
			||||||
 | 
							width = parent->width;
 | 
				
			||||||
 | 
							height = parent->height;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct wlc_geometry geometry = {
 | 
						struct wlc_geometry geometry = {
 | 
				
			||||||
		.origin = {
 | 
							.origin = {
 | 
				
			||||||
			.x = container->x + gap/2 < op->width  ? container->x + gap/2 : op->width-1,
 | 
								.x = container->x + gap/2 < op->width  ? container->x + gap/2 : op->width-1,
 | 
				
			||||||
			.y = container->y + gap/2 < op->height ? container->y + gap/2 : op->height-1
 | 
								.y = container->y + gap/2 < op->height ? container->y + gap/2 : op->height-1
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		.size = {
 | 
							.size = {
 | 
				
			||||||
			.w = container->width > gap ? container->width - gap : 1,
 | 
								.w = width > gap ? width - gap : 1,
 | 
				
			||||||
			.h = container->height > gap ? container->height - gap : 1,
 | 
								.h = height > gap ? height - gap : 1,
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
	if (swayc_is_fullscreen(container)) {
 | 
						if (swayc_is_fullscreen(container)) {
 | 
				
			||||||
| 
						 | 
					@ -480,16 +490,16 @@ void update_geometry(swayc_t *container) {
 | 
				
			||||||
		// with gap, and align correctly).
 | 
							// with gap, and align correctly).
 | 
				
			||||||
		if (container->x - gap <= ws->x) {
 | 
							if (container->x - gap <= ws->x) {
 | 
				
			||||||
			geometry.origin.x = ws->x;
 | 
								geometry.origin.x = ws->x;
 | 
				
			||||||
			geometry.size.w = container->width - gap/2;
 | 
								geometry.size.w = width - gap/2;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if (container->y - gap <= ws->y) {
 | 
							if (container->y - gap <= ws->y) {
 | 
				
			||||||
			geometry.origin.y = ws->y;
 | 
								geometry.origin.y = ws->y;
 | 
				
			||||||
			geometry.size.h = container->height - gap/2;
 | 
								geometry.size.h = height - gap/2;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if (container->x + container->width + gap >= ws->x + ws->width) {
 | 
							if (container->x + width + gap >= ws->x + ws->width) {
 | 
				
			||||||
			geometry.size.w = ws->x + ws->width - geometry.origin.x;
 | 
								geometry.size.w = ws->x + ws->width - geometry.origin.x;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if (container->y + container->height + gap >= ws->y + ws->height) {
 | 
							if (container->y + height + gap >= ws->y + ws->height) {
 | 
				
			||||||
			geometry.size.h = ws->y + ws->height - geometry.origin.y;
 | 
								geometry.size.h = ws->y + ws->height - geometry.origin.y;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -533,6 +543,65 @@ void update_geometry(swayc_t *container) {
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							int title_bar_height = config->font_height + 4; //borders + padding
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (parent->layout == L_TABBED) {
 | 
				
			||||||
 | 
								int i, x = 0, w, l, r;
 | 
				
			||||||
 | 
								l = parent->children->length;
 | 
				
			||||||
 | 
								w = geometry.size.w / l;
 | 
				
			||||||
 | 
								r = geometry.size.w % l;
 | 
				
			||||||
 | 
								for (i = 0; i < parent->children->length; ++i) {
 | 
				
			||||||
 | 
									swayc_t *view = parent->children->items[i];
 | 
				
			||||||
 | 
									if (view == container) {
 | 
				
			||||||
 | 
										x = w * i;
 | 
				
			||||||
 | 
										if (i == l - 1) {
 | 
				
			||||||
 | 
											w += r;
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
										break;
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								struct wlc_geometry title_bar = {
 | 
				
			||||||
 | 
									.origin = {
 | 
				
			||||||
 | 
										.x = container->border_geometry.origin.x + x,
 | 
				
			||||||
 | 
										.y = container->border_geometry.origin.y
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									.size = {
 | 
				
			||||||
 | 
										.w = w,
 | 
				
			||||||
 | 
										.h = title_bar_height
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								};
 | 
				
			||||||
 | 
								geometry.origin.x += border_left;
 | 
				
			||||||
 | 
								geometry.origin.y += title_bar.size.h;
 | 
				
			||||||
 | 
								geometry.size.w -= (border_left + border_right);
 | 
				
			||||||
 | 
								geometry.size.h -= (border_bottom + title_bar.size.h);
 | 
				
			||||||
 | 
								container->title_bar_geometry = title_bar;
 | 
				
			||||||
 | 
							} else if (parent->layout == L_STACKED) {
 | 
				
			||||||
 | 
								int i, y;
 | 
				
			||||||
 | 
								for (i = 0; i < parent->children->length; ++i) {
 | 
				
			||||||
 | 
									swayc_t *view = parent->children->items[i];
 | 
				
			||||||
 | 
									if (view == container) {
 | 
				
			||||||
 | 
										y = title_bar_height * i;
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								struct wlc_geometry title_bar = {
 | 
				
			||||||
 | 
									.origin = {
 | 
				
			||||||
 | 
										.x = container->border_geometry.origin.x,
 | 
				
			||||||
 | 
										.y = container->border_geometry.origin.y + y
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									.size = {
 | 
				
			||||||
 | 
										.w = container->border_geometry.size.w,
 | 
				
			||||||
 | 
										.h = title_bar_height
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								};
 | 
				
			||||||
 | 
								title_bar_height = title_bar_height * parent->children->length;
 | 
				
			||||||
 | 
								geometry.origin.x += border_left;
 | 
				
			||||||
 | 
								geometry.origin.y += title_bar_height;
 | 
				
			||||||
 | 
								geometry.size.w -= (border_left + border_right);
 | 
				
			||||||
 | 
								geometry.size.h -= (border_bottom + title_bar_height);
 | 
				
			||||||
 | 
								container->title_bar_geometry = title_bar;
 | 
				
			||||||
 | 
							} else {
 | 
				
			||||||
			switch (container->border_type) {
 | 
								switch (container->border_type) {
 | 
				
			||||||
			case B_NONE:
 | 
								case B_NONE:
 | 
				
			||||||
				break;
 | 
									break;
 | 
				
			||||||
| 
						 | 
					@ -551,7 +620,7 @@ void update_geometry(swayc_t *container) {
 | 
				
			||||||
						},
 | 
											},
 | 
				
			||||||
						.size = {
 | 
											.size = {
 | 
				
			||||||
							.w = container->border_geometry.size.w,
 | 
												.w = container->border_geometry.size.w,
 | 
				
			||||||
						.h = config->font_height + 4 // borders + padding
 | 
												.h = title_bar_height
 | 
				
			||||||
						}
 | 
											}
 | 
				
			||||||
					};
 | 
										};
 | 
				
			||||||
					geometry.origin.x += border_left;
 | 
										geometry.origin.x += border_left;
 | 
				
			||||||
| 
						 | 
					@ -562,6 +631,7 @@ void update_geometry(swayc_t *container) {
 | 
				
			||||||
					break;
 | 
										break;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		container->actual_geometry = geometry;
 | 
							container->actual_geometry = geometry;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -683,6 +753,7 @@ static void arrange_windows_r(swayc_t *container, double width, double height) {
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			scale += *old_width;
 | 
								scale += *old_width;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// Resize windows
 | 
							// Resize windows
 | 
				
			||||||
		if (scale > 0.1) {
 | 
							if (scale > 0.1) {
 | 
				
			||||||
			scale = width / scale;
 | 
								scale = width / scale;
 | 
				
			||||||
| 
						 | 
					@ -734,6 +805,26 @@ static void arrange_windows_r(swayc_t *container, double width, double height) {
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
 | 
						case L_TABBED:
 | 
				
			||||||
 | 
						case L_STACKED:
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								swayc_t *focused = NULL;
 | 
				
			||||||
 | 
								for (i = 0; i < container->children->length; ++i) {
 | 
				
			||||||
 | 
									swayc_t *child = container->children->items[i];
 | 
				
			||||||
 | 
									child->x = x;
 | 
				
			||||||
 | 
									child->y = y;
 | 
				
			||||||
 | 
									if (child == container->focused) {
 | 
				
			||||||
 | 
										focused = child;
 | 
				
			||||||
 | 
									} else {
 | 
				
			||||||
 | 
										arrange_windows_r(child, -1, -1);
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if (focused) {
 | 
				
			||||||
 | 
									arrange_windows_r(focused, -1, -1);
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								break;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Arrage floating layouts for workspaces last
 | 
						// Arrage floating layouts for workspaces last
 | 
				
			||||||
| 
						 | 
					@ -840,12 +931,12 @@ swayc_t *get_swayc_in_direction_under(swayc_t *container, enum movement_directio
 | 
				
			||||||
			return get_swayc_in_output_direction(output, dir);
 | 
								return get_swayc_in_output_direction(output, dir);
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			if (dir == MOVE_LEFT || dir == MOVE_RIGHT) {
 | 
								if (dir == MOVE_LEFT || dir == MOVE_RIGHT) {
 | 
				
			||||||
				if (parent->layout == L_HORIZ) {
 | 
									if (parent->layout == L_HORIZ || parent->layout == L_TABBED) {
 | 
				
			||||||
					can_move = true;
 | 
										can_move = true;
 | 
				
			||||||
					diff = dir == MOVE_LEFT ? -1 : 1;
 | 
										diff = dir == MOVE_LEFT ? -1 : 1;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			} else {
 | 
								} else {
 | 
				
			||||||
				if (parent->layout == L_VERT) {
 | 
									if (parent->layout == L_VERT || parent->layout == L_STACKED) {
 | 
				
			||||||
					can_move = true;
 | 
										can_move = true;
 | 
				
			||||||
					diff = dir == MOVE_UP ? -1 : 1;
 | 
										diff = dir == MOVE_UP ? -1 : 1;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue