mirror of
				https://github.com/swaywm/sway.git
				synced 2025-11-03 09:01:43 -05:00 
			
		
		
		
	Implement floating
This commit is contained in:
		
							parent
							
								
									1132efe42e
								
							
						
					
					
						commit
						1f2e399ade
					
				
					 21 changed files with 572 additions and 169 deletions
				
			
		| 
						 | 
					@ -75,8 +75,13 @@ struct sway_container {
 | 
				
			||||||
	enum sway_container_layout layout;
 | 
						enum sway_container_layout layout;
 | 
				
			||||||
	enum sway_container_layout prev_layout;
 | 
						enum sway_container_layout prev_layout;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// Allow the container to be automatically removed if it's empty. True by
 | 
				
			||||||
 | 
						// default, false for the magic floating container that each workspace has.
 | 
				
			||||||
 | 
						bool reapable;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Saves us from searching the list of children/floating in the parent
 | 
						// Saves us from searching the list of children/floating in the parent
 | 
				
			||||||
	bool is_floating;
 | 
						bool is_floating;
 | 
				
			||||||
 | 
						bool is_sticky;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// For C_ROOT, this has no meaning
 | 
						// For C_ROOT, this has no meaning
 | 
				
			||||||
	// For C_OUTPUT, this is the output position in layout coordinates
 | 
						// For C_OUTPUT, this is the output position in layout coordinates
 | 
				
			||||||
| 
						 | 
					@ -173,6 +178,13 @@ struct sway_container *container_at(struct sway_container *container,
 | 
				
			||||||
		double ox, double oy, struct wlr_surface **surface,
 | 
							double ox, double oy, struct wlr_surface **surface,
 | 
				
			||||||
		double *sx, double *sy);
 | 
							double *sx, double *sy);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Same as container_at, but only checks floating views and expects coordinates
 | 
				
			||||||
 | 
					 * to be layout coordinates, as that's what floating views use.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					struct sway_container *floating_container_at(double lx, double ly,
 | 
				
			||||||
 | 
							struct wlr_surface **surface, double *sx, double *sy);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Apply the function for each descendant of the container breadth first.
 | 
					 * Apply the function for each descendant of the container breadth first.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
| 
						 | 
					@ -229,4 +241,14 @@ void container_notify_subtree_changed(struct sway_container *container);
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
size_t container_titlebar_height(void);
 | 
					size_t container_titlebar_height(void);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void container_set_floating(struct sway_container *container, bool enable);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void container_set_geometry_from_view(struct sway_container *container);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Determine if the given container is itself floating or has a floating
 | 
				
			||||||
 | 
					 * ancestor.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					bool container_self_or_parent_floating(struct sway_container *container);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -46,9 +46,6 @@ struct sway_container *container_add_sibling(struct sway_container *parent,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct sway_container *container_remove_child(struct sway_container *child);
 | 
					struct sway_container *container_remove_child(struct sway_container *child);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void container_add_floating(struct sway_container *workspace,
 | 
					 | 
				
			||||||
		struct sway_container *child);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
struct sway_container *container_replace_child(struct sway_container *child,
 | 
					struct sway_container *container_replace_child(struct sway_container *child,
 | 
				
			||||||
		struct sway_container *new_child);
 | 
							struct sway_container *new_child);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -32,7 +32,9 @@ struct sway_view_impl {
 | 
				
			||||||
	void (*configure)(struct sway_view *view, double ox, double oy, int width,
 | 
						void (*configure)(struct sway_view *view, double ox, double oy, int width,
 | 
				
			||||||
		int height);
 | 
							int height);
 | 
				
			||||||
	void (*set_activated)(struct sway_view *view, bool activated);
 | 
						void (*set_activated)(struct sway_view *view, bool activated);
 | 
				
			||||||
 | 
						void (*set_maximized)(struct sway_view *view, bool maximized);
 | 
				
			||||||
	void (*set_fullscreen)(struct sway_view *view, bool fullscreen);
 | 
						void (*set_fullscreen)(struct sway_view *view, bool fullscreen);
 | 
				
			||||||
 | 
						bool (*wants_floating)(struct sway_view *view);
 | 
				
			||||||
	void (*for_each_surface)(struct sway_view *view,
 | 
						void (*for_each_surface)(struct sway_view *view,
 | 
				
			||||||
		wlr_surface_iterator_func_t iterator, void *user_data);
 | 
							wlr_surface_iterator_func_t iterator, void *user_data);
 | 
				
			||||||
	void (*close)(struct sway_view *view);
 | 
						void (*close)(struct sway_view *view);
 | 
				
			||||||
| 
						 | 
					@ -50,6 +52,10 @@ struct sway_view {
 | 
				
			||||||
	double x, y;
 | 
						double x, y;
 | 
				
			||||||
	int width, height;
 | 
						int width, height;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// The size the view would want to be if it weren't tiled.
 | 
				
			||||||
 | 
						// Used when changing a view from tiled to floating.
 | 
				
			||||||
 | 
						int natural_width, natural_height;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	bool is_fullscreen;
 | 
						bool is_fullscreen;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	char *title_format;
 | 
						char *title_format;
 | 
				
			||||||
| 
						 | 
					@ -214,6 +220,8 @@ void view_autoconfigure(struct sway_view *view);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void view_set_activated(struct sway_view *view, bool activated);
 | 
					void view_set_activated(struct sway_view *view, bool activated);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void view_set_maximized(struct sway_view *view, bool maximized);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void view_set_fullscreen_raw(struct sway_view *view, bool fullscreen);
 | 
					void view_set_fullscreen_raw(struct sway_view *view, bool fullscreen);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void view_set_fullscreen(struct sway_view *view, bool fullscreen);
 | 
					void view_set_fullscreen(struct sway_view *view, bool fullscreen);
 | 
				
			||||||
| 
						 | 
					@ -236,7 +244,7 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void view_unmap(struct sway_view *view);
 | 
					void view_unmap(struct sway_view *view);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void view_update_position(struct sway_view *view, double ox, double oy);
 | 
					void view_update_position(struct sway_view *view, double lx, double ly);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void view_update_size(struct sway_view *view, int width, int height);
 | 
					void view_update_size(struct sway_view *view, int width, int height);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8,7 +8,7 @@ struct sway_view;
 | 
				
			||||||
struct sway_workspace {
 | 
					struct sway_workspace {
 | 
				
			||||||
	struct sway_container *swayc;
 | 
						struct sway_container *swayc;
 | 
				
			||||||
	struct sway_view *fullscreen;
 | 
						struct sway_view *fullscreen;
 | 
				
			||||||
	list_t *floating;
 | 
						struct sway_container *floating;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern char *prev_workspace_name;
 | 
					extern char *prev_workspace_name;
 | 
				
			||||||
| 
						 | 
					@ -31,4 +31,6 @@ struct sway_container *workspace_prev(struct sway_container *current);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool workspace_is_visible(struct sway_container *ws);
 | 
					bool workspace_is_visible(struct sway_container *ws);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool workspace_is_empty(struct sway_container *ws);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -190,6 +190,7 @@ static struct cmd_handler command_handlers[] = {
 | 
				
			||||||
	{ "splith", cmd_splith },
 | 
						{ "splith", cmd_splith },
 | 
				
			||||||
	{ "splitt", cmd_splitt },
 | 
						{ "splitt", cmd_splitt },
 | 
				
			||||||
	{ "splitv", cmd_splitv },
 | 
						{ "splitv", cmd_splitv },
 | 
				
			||||||
 | 
						{ "sticky", cmd_sticky },
 | 
				
			||||||
	{ "swap", cmd_swap },
 | 
						{ "swap", cmd_swap },
 | 
				
			||||||
	{ "title_format", cmd_title_format },
 | 
						{ "title_format", cmd_title_format },
 | 
				
			||||||
	{ "unmark", cmd_unmark },
 | 
						{ "unmark", cmd_unmark },
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -31,31 +31,10 @@ struct cmd_results *cmd_floating(int argc, char **argv) {
 | 
				
			||||||
		wants_floating = !container->is_floating;
 | 
							wants_floating = !container->is_floating;
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		return cmd_results_new(CMD_FAILURE, "floating",
 | 
							return cmd_results_new(CMD_FAILURE, "floating",
 | 
				
			||||||
			"Expected 'floating <enable|disable|toggle>");
 | 
								"Expected 'floating <enable|disable|toggle>'");
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Change from tiled to floating
 | 
						container_set_floating(container, wants_floating);
 | 
				
			||||||
	if (!container->is_floating && wants_floating) {
 | 
					 | 
				
			||||||
		struct sway_container *workspace = container_parent(
 | 
					 | 
				
			||||||
				container, C_WORKSPACE);
 | 
					 | 
				
			||||||
		container_remove_child(container);
 | 
					 | 
				
			||||||
		container_add_floating(workspace, container);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		struct sway_output *output = workspace->parent->sway_output;
 | 
					 | 
				
			||||||
		output_damage_whole_container(output, container);
 | 
					 | 
				
			||||||
		// Reset to sane size and position
 | 
					 | 
				
			||||||
		container->width = 640;
 | 
					 | 
				
			||||||
		container->height = 480;
 | 
					 | 
				
			||||||
		container->x = workspace->width / 2 - container->width / 2;
 | 
					 | 
				
			||||||
		container->y = workspace->height / 2 - container->height / 2;
 | 
					 | 
				
			||||||
		view_autoconfigure(container->sway_view);
 | 
					 | 
				
			||||||
		output_damage_whole_container(output, container);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		seat_set_focus(config->handler_context.seat, container);
 | 
					 | 
				
			||||||
		arrange_workspace(workspace);
 | 
					 | 
				
			||||||
	} else if (container->is_floating && !wants_floating) {
 | 
					 | 
				
			||||||
		// TODO
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return cmd_results_new(CMD_SUCCESS, NULL, NULL);
 | 
						return cmd_results_new(CMD_SUCCESS, NULL, NULL);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										40
									
								
								sway/commands/sticky.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								sway/commands/sticky.c
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,40 @@
 | 
				
			||||||
 | 
					#include <string.h>
 | 
				
			||||||
 | 
					#include <strings.h>
 | 
				
			||||||
 | 
					#include "sway/commands.h"
 | 
				
			||||||
 | 
					#include "sway/input/seat.h"
 | 
				
			||||||
 | 
					#include "sway/ipc-server.h"
 | 
				
			||||||
 | 
					#include "sway/output.h"
 | 
				
			||||||
 | 
					#include "sway/tree/arrange.h"
 | 
				
			||||||
 | 
					#include "sway/tree/container.h"
 | 
				
			||||||
 | 
					#include "sway/tree/layout.h"
 | 
				
			||||||
 | 
					#include "sway/tree/view.h"
 | 
				
			||||||
 | 
					#include "list.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct cmd_results *cmd_sticky(int argc, char **argv) {
 | 
				
			||||||
 | 
						struct cmd_results *error = NULL;
 | 
				
			||||||
 | 
						if ((error = checkarg(argc, "sticky", EXPECTED_EQUAL_TO, 1))) {
 | 
				
			||||||
 | 
							return error;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						struct sway_container *container =
 | 
				
			||||||
 | 
							config->handler_context.current_container;
 | 
				
			||||||
 | 
						if (!container->is_floating) {
 | 
				
			||||||
 | 
							return cmd_results_new(CMD_FAILURE, "sticky",
 | 
				
			||||||
 | 
								"Can't set sticky on a tiled container");
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						bool wants_sticky;
 | 
				
			||||||
 | 
						if (strcasecmp(argv[0], "enable") == 0) {
 | 
				
			||||||
 | 
							wants_sticky = true;
 | 
				
			||||||
 | 
						} else if (strcasecmp(argv[0], "disable") == 0) {
 | 
				
			||||||
 | 
							wants_sticky = false;
 | 
				
			||||||
 | 
						} else if (strcasecmp(argv[0], "toggle") == 0) {
 | 
				
			||||||
 | 
							wants_sticky = !container->is_sticky;
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							return cmd_results_new(CMD_FAILURE, "sticky",
 | 
				
			||||||
 | 
								"Expected 'sticky <enable|disable|toggle>'");
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						container->is_sticky = wants_sticky;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return cmd_results_new(CMD_SUCCESS, NULL, NULL);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -121,12 +121,15 @@ static bool criteria_matches_view(struct criteria *criteria,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (criteria->floating) {
 | 
						if (criteria->floating) {
 | 
				
			||||||
		// TODO
 | 
							if (!view->swayc->is_floating) {
 | 
				
			||||||
			return false;
 | 
								return false;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (criteria->tiling) {
 | 
						if (criteria->tiling) {
 | 
				
			||||||
		// TODO
 | 
							if (view->swayc->is_floating) {
 | 
				
			||||||
 | 
								return false;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (criteria->urgent) {
 | 
						if (criteria->urgent) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -754,9 +754,87 @@ static void render_container(struct sway_output *output,
 | 
				
			||||||
	case L_TABBED:
 | 
						case L_TABBED:
 | 
				
			||||||
		render_container_tabbed(output, damage, con, parent_focused);
 | 
							render_container_tabbed(output, damage, con, parent_focused);
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
	case L_FLOATING:
 | 
						}
 | 
				
			||||||
		// TODO
 | 
					}
 | 
				
			||||||
		break;
 | 
					
 | 
				
			||||||
 | 
					static bool floater_intersects_output(struct sway_container *floater,
 | 
				
			||||||
 | 
							struct sway_container *output) {
 | 
				
			||||||
 | 
						struct wlr_box box = {
 | 
				
			||||||
 | 
							.x = floater->x,
 | 
				
			||||||
 | 
							.y = floater->y,
 | 
				
			||||||
 | 
							.width = floater->width,
 | 
				
			||||||
 | 
							.height = floater->height,
 | 
				
			||||||
 | 
						};
 | 
				
			||||||
 | 
						return wlr_output_layout_intersects(root_container.sway_root->output_layout,
 | 
				
			||||||
 | 
								output->sway_output->wlr_output, &box);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void container_translate(struct sway_container *con, int x, int y) {
 | 
				
			||||||
 | 
						con->x += x;
 | 
				
			||||||
 | 
						con->y += y;
 | 
				
			||||||
 | 
						if (con->type == C_VIEW) {
 | 
				
			||||||
 | 
							con->sway_view->x += x;
 | 
				
			||||||
 | 
							con->sway_view->y += y;
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							for (int i = 0; i < con->children->length; ++i) {
 | 
				
			||||||
 | 
								struct sway_container *child = con->children->items[i];
 | 
				
			||||||
 | 
								container_translate(child, x, y);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void render_floating_container(struct sway_output *soutput,
 | 
				
			||||||
 | 
							pixman_region32_t *damage, struct sway_container *con) {
 | 
				
			||||||
 | 
						// We need to translate the floating container's coordinates from layout
 | 
				
			||||||
 | 
						// coordinates into output-local coordinates. This needs to happen for all
 | 
				
			||||||
 | 
						// children of the floating container too.
 | 
				
			||||||
 | 
						struct sway_container *output = container_parent(con, C_OUTPUT);
 | 
				
			||||||
 | 
						container_translate(con, -output->x, -output->y);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (con->type == C_VIEW) {
 | 
				
			||||||
 | 
							struct sway_view *view = con->sway_view;
 | 
				
			||||||
 | 
							struct sway_seat *seat = input_manager_current_seat(input_manager);
 | 
				
			||||||
 | 
							struct sway_container *focus = seat_get_focus(seat);
 | 
				
			||||||
 | 
							struct border_colors *colors;
 | 
				
			||||||
 | 
							struct wlr_texture *title_texture;
 | 
				
			||||||
 | 
							struct wlr_texture *marks_texture;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (focus == con) {
 | 
				
			||||||
 | 
								colors = &config->border_colors.focused;
 | 
				
			||||||
 | 
								title_texture = con->title_focused;
 | 
				
			||||||
 | 
								marks_texture = view->marks_focused;
 | 
				
			||||||
 | 
							} else {
 | 
				
			||||||
 | 
								colors = &config->border_colors.unfocused;
 | 
				
			||||||
 | 
								title_texture = con->title_unfocused;
 | 
				
			||||||
 | 
								marks_texture = view->marks_unfocused;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							render_titlebar(soutput, damage, con, con->x, con->y, con->width,
 | 
				
			||||||
 | 
									colors, title_texture, marks_texture);
 | 
				
			||||||
 | 
							render_view(soutput, damage, con, colors);
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							render_container(soutput, damage, con, false);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						// Undo the translation
 | 
				
			||||||
 | 
						container_translate(con, output->x, output->y);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void render_floating(struct sway_output *soutput,
 | 
				
			||||||
 | 
							pixman_region32_t *damage) {
 | 
				
			||||||
 | 
						for (int i = 0; i < root_container.children->length; ++i) {
 | 
				
			||||||
 | 
							struct sway_container *output = root_container.children->items[i];
 | 
				
			||||||
 | 
							for (int j = 0; j < output->children->length; ++j) {
 | 
				
			||||||
 | 
								struct sway_container *workspace = output->children->items[j];
 | 
				
			||||||
 | 
								struct sway_workspace *ws = workspace->sway_workspace;
 | 
				
			||||||
 | 
								bool ws_is_visible = workspace_is_visible(workspace);
 | 
				
			||||||
 | 
								for (int k = 0; k < ws->floating->children->length; ++k) {
 | 
				
			||||||
 | 
									struct sway_container *floater =
 | 
				
			||||||
 | 
										ws->floating->children->items[k];
 | 
				
			||||||
 | 
									if ((ws_is_visible || floater->is_sticky)
 | 
				
			||||||
 | 
											&& floater_intersects_output(floater, soutput->swayc)) {
 | 
				
			||||||
 | 
										render_floating_container(soutput, damage, floater);
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -794,8 +872,6 @@ static void render_output(struct sway_output *output, struct timespec *when,
 | 
				
			||||||
		goto renderer_end;
 | 
							goto renderer_end;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	//wlr_renderer_clear(renderer, (float[]){1, 1, 0, 1});
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	struct sway_container *workspace = output_get_active_workspace(output);
 | 
						struct sway_container *workspace = output_get_active_workspace(output);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (workspace->sway_workspace->fullscreen) {
 | 
						if (workspace->sway_workspace->fullscreen) {
 | 
				
			||||||
| 
						 | 
					@ -818,7 +894,6 @@ static void render_output(struct sway_output *output, struct timespec *when,
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		float clear_color[] = {0.25f, 0.25f, 0.25f, 1.0f};
 | 
							float clear_color[] = {0.25f, 0.25f, 0.25f, 1.0f};
 | 
				
			||||||
		wlr_renderer_clear(renderer, clear_color);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		int nrects;
 | 
							int nrects;
 | 
				
			||||||
		pixman_box32_t *rects = pixman_region32_rectangles(damage, &nrects);
 | 
							pixman_box32_t *rects = pixman_region32_rectangles(damage, &nrects);
 | 
				
			||||||
| 
						 | 
					@ -840,6 +915,8 @@ static void render_output(struct sway_output *output, struct timespec *when,
 | 
				
			||||||
			&root_container.sway_root->xwayland_unmanaged);
 | 
								&root_container.sway_root->xwayland_unmanaged);
 | 
				
			||||||
		render_layer(output, damage,
 | 
							render_layer(output, damage,
 | 
				
			||||||
			&output->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP]);
 | 
								&output->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							render_floating(output, damage);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	render_layer(output, damage,
 | 
						render_layer(output, damage,
 | 
				
			||||||
		&output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]);
 | 
							&output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]);
 | 
				
			||||||
| 
						 | 
					@ -916,6 +993,7 @@ static void send_frame_done(struct sway_output *output, struct timespec *when) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct sway_container *workspace = output_get_active_workspace(output);
 | 
						struct sway_container *workspace = output_get_active_workspace(output);
 | 
				
			||||||
	send_frame_done_container(&data, workspace);
 | 
						send_frame_done_container(&data, workspace);
 | 
				
			||||||
 | 
						send_frame_done_container(&data, workspace->sway_workspace->floating);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	send_frame_done_unmanaged(&data,
 | 
						send_frame_done_unmanaged(&data,
 | 
				
			||||||
		&root_container.sway_root->xwayland_unmanaged);
 | 
							&root_container.sway_root->xwayland_unmanaged);
 | 
				
			||||||
| 
						 | 
					@ -1037,7 +1115,15 @@ static void output_damage_view(struct sway_output *output,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void output_damage_from_view(struct sway_output *output,
 | 
					void output_damage_from_view(struct sway_output *output,
 | 
				
			||||||
		struct sway_view *view) {
 | 
							struct sway_view *view) {
 | 
				
			||||||
 | 
						if (container_self_or_parent_floating(view->swayc)) {
 | 
				
			||||||
 | 
							view->x -= output->swayc->x;
 | 
				
			||||||
 | 
							view->y -= output->swayc->y;
 | 
				
			||||||
		output_damage_view(output, view, false);
 | 
							output_damage_view(output, view, false);
 | 
				
			||||||
 | 
							view->x += output->swayc->x;
 | 
				
			||||||
 | 
							view->y += output->swayc->y;
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							output_damage_view(output, view, false);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void output_damage_whole_container_iterator(struct sway_container *con,
 | 
					static void output_damage_whole_container_iterator(struct sway_container *con,
 | 
				
			||||||
| 
						 | 
					@ -1053,13 +1139,17 @@ static void output_damage_whole_container_iterator(struct sway_container *con,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void output_damage_whole_container(struct sway_output *output,
 | 
					void output_damage_whole_container(struct sway_output *output,
 | 
				
			||||||
		struct sway_container *con) {
 | 
							struct sway_container *con) {
 | 
				
			||||||
	float scale = output->wlr_output->scale;
 | 
					 | 
				
			||||||
	struct wlr_box box = {
 | 
						struct wlr_box box = {
 | 
				
			||||||
		.x = con->x * scale,
 | 
							.x = con->x,
 | 
				
			||||||
		.y = con->y * scale,
 | 
							.y = con->y,
 | 
				
			||||||
		.width = con->width * scale,
 | 
							.width = con->width,
 | 
				
			||||||
		.height = con->height * scale,
 | 
							.height = con->height,
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
						if (con->is_floating) {
 | 
				
			||||||
 | 
							box.x -= output->wlr_output->lx;
 | 
				
			||||||
 | 
							box.y -= output->wlr_output->ly;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						scale_box(&box, output->wlr_output->scale);
 | 
				
			||||||
	wlr_output_damage_add_box(output->damage, &box);
 | 
						wlr_output_damage_add_box(output->damage, &box);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (con->type == C_VIEW) {
 | 
						if (con->type == C_VIEW) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -98,6 +98,7 @@ static void configure(struct sway_view *view, double ox, double oy, int width,
 | 
				
			||||||
	xdg_shell_view->pending_width = width;
 | 
						xdg_shell_view->pending_width = width;
 | 
				
			||||||
	xdg_shell_view->pending_height = height;
 | 
						xdg_shell_view->pending_height = height;
 | 
				
			||||||
	wlr_xdg_toplevel_set_size(view->wlr_xdg_surface, width, height);
 | 
						wlr_xdg_toplevel_set_size(view->wlr_xdg_surface, width, height);
 | 
				
			||||||
 | 
						view_update_position(view, ox, oy);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void set_activated(struct sway_view *view, bool activated) {
 | 
					static void set_activated(struct sway_view *view, bool activated) {
 | 
				
			||||||
| 
						 | 
					@ -110,6 +111,14 @@ static void set_activated(struct sway_view *view, bool activated) {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void set_maximized(struct sway_view *view, bool maximized) {
 | 
				
			||||||
 | 
						if (xdg_shell_view_from_view(view) == NULL) {
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						struct wlr_xdg_surface *surface = view->wlr_xdg_surface;
 | 
				
			||||||
 | 
						wlr_xdg_toplevel_set_maximized(surface, maximized);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void set_fullscreen(struct sway_view *view, bool fullscreen) {
 | 
					static void set_fullscreen(struct sway_view *view, bool fullscreen) {
 | 
				
			||||||
	if (xdg_shell_view_from_view(view) == NULL) {
 | 
						if (xdg_shell_view_from_view(view) == NULL) {
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
| 
						 | 
					@ -118,6 +127,11 @@ static void set_fullscreen(struct sway_view *view, bool fullscreen) {
 | 
				
			||||||
	wlr_xdg_toplevel_set_fullscreen(surface, fullscreen);
 | 
						wlr_xdg_toplevel_set_fullscreen(surface, fullscreen);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static bool wants_floating(struct sway_view *view) {
 | 
				
			||||||
 | 
						// TODO
 | 
				
			||||||
 | 
						return false;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void for_each_surface(struct sway_view *view,
 | 
					static void for_each_surface(struct sway_view *view,
 | 
				
			||||||
		wlr_surface_iterator_func_t iterator, void *user_data) {
 | 
							wlr_surface_iterator_func_t iterator, void *user_data) {
 | 
				
			||||||
	if (xdg_shell_view_from_view(view) == NULL) {
 | 
						if (xdg_shell_view_from_view(view) == NULL) {
 | 
				
			||||||
| 
						 | 
					@ -154,7 +168,9 @@ static const struct sway_view_impl view_impl = {
 | 
				
			||||||
	.get_string_prop = get_string_prop,
 | 
						.get_string_prop = get_string_prop,
 | 
				
			||||||
	.configure = configure,
 | 
						.configure = configure,
 | 
				
			||||||
	.set_activated = set_activated,
 | 
						.set_activated = set_activated,
 | 
				
			||||||
 | 
						.set_maximized = set_maximized,
 | 
				
			||||||
	.set_fullscreen = set_fullscreen,
 | 
						.set_fullscreen = set_fullscreen,
 | 
				
			||||||
 | 
						.wants_floating = wants_floating,
 | 
				
			||||||
	.for_each_surface = for_each_surface,
 | 
						.for_each_surface = for_each_surface,
 | 
				
			||||||
	.close = _close,
 | 
						.close = _close,
 | 
				
			||||||
	.destroy = destroy,
 | 
						.destroy = destroy,
 | 
				
			||||||
| 
						 | 
					@ -164,11 +180,17 @@ static void handle_commit(struct wl_listener *listener, void *data) {
 | 
				
			||||||
	struct sway_xdg_shell_view *xdg_shell_view =
 | 
						struct sway_xdg_shell_view *xdg_shell_view =
 | 
				
			||||||
		wl_container_of(listener, xdg_shell_view, commit);
 | 
							wl_container_of(listener, xdg_shell_view, commit);
 | 
				
			||||||
	struct sway_view *view = &xdg_shell_view->view;
 | 
						struct sway_view *view = &xdg_shell_view->view;
 | 
				
			||||||
	// NOTE: We intentionally discard the view's desired width here
 | 
						struct wlr_box *geometry = &view->wlr_xdg_surface->geometry;
 | 
				
			||||||
	// TODO: Store this for restoration when moving to floating plane
 | 
						if (!view->natural_width && !view->natural_height) {
 | 
				
			||||||
	// TODO: Let floating views do whatever
 | 
							view->natural_width = geometry->width;
 | 
				
			||||||
 | 
							view->natural_height = geometry->height;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if (view->swayc && view->swayc->is_floating) {
 | 
				
			||||||
 | 
							view_update_size(view, geometry->width, geometry->height);
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
		view_update_size(view, xdg_shell_view->pending_width,
 | 
							view_update_size(view, xdg_shell_view->pending_width,
 | 
				
			||||||
				xdg_shell_view->pending_height);
 | 
									xdg_shell_view->pending_height);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	view_update_title(view, false);
 | 
						view_update_title(view, false);
 | 
				
			||||||
	view_damage_from(view);
 | 
						view_damage_from(view);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -97,6 +97,7 @@ static void configure(struct sway_view *view, double ox, double oy, int width,
 | 
				
			||||||
	xdg_shell_v6_view->pending_width = width;
 | 
						xdg_shell_v6_view->pending_width = width;
 | 
				
			||||||
	xdg_shell_v6_view->pending_height = height;
 | 
						xdg_shell_v6_view->pending_height = height;
 | 
				
			||||||
	wlr_xdg_toplevel_v6_set_size(view->wlr_xdg_surface_v6, width, height);
 | 
						wlr_xdg_toplevel_v6_set_size(view->wlr_xdg_surface_v6, width, height);
 | 
				
			||||||
 | 
						view_update_position(view, ox, oy);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void set_activated(struct sway_view *view, bool activated) {
 | 
					static void set_activated(struct sway_view *view, bool activated) {
 | 
				
			||||||
| 
						 | 
					@ -109,6 +110,14 @@ static void set_activated(struct sway_view *view, bool activated) {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void set_maximized(struct sway_view *view, bool maximized) {
 | 
				
			||||||
 | 
						if (xdg_shell_v6_view_from_view(view) == NULL) {
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						struct wlr_xdg_surface_v6 *surface = view->wlr_xdg_surface_v6;
 | 
				
			||||||
 | 
						wlr_xdg_toplevel_v6_set_maximized(surface, maximized);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void set_fullscreen(struct sway_view *view, bool fullscreen) {
 | 
					static void set_fullscreen(struct sway_view *view, bool fullscreen) {
 | 
				
			||||||
	if (xdg_shell_v6_view_from_view(view) == NULL) {
 | 
						if (xdg_shell_v6_view_from_view(view) == NULL) {
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
| 
						 | 
					@ -117,6 +126,11 @@ static void set_fullscreen(struct sway_view *view, bool fullscreen) {
 | 
				
			||||||
	wlr_xdg_toplevel_v6_set_fullscreen(surface, fullscreen);
 | 
						wlr_xdg_toplevel_v6_set_fullscreen(surface, fullscreen);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static bool wants_floating(struct sway_view *view) {
 | 
				
			||||||
 | 
						// TODO
 | 
				
			||||||
 | 
						return false;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void for_each_surface(struct sway_view *view,
 | 
					static void for_each_surface(struct sway_view *view,
 | 
				
			||||||
		wlr_surface_iterator_func_t iterator, void *user_data) {
 | 
							wlr_surface_iterator_func_t iterator, void *user_data) {
 | 
				
			||||||
	if (xdg_shell_v6_view_from_view(view) == NULL) {
 | 
						if (xdg_shell_v6_view_from_view(view) == NULL) {
 | 
				
			||||||
| 
						 | 
					@ -153,7 +167,9 @@ static const struct sway_view_impl view_impl = {
 | 
				
			||||||
	.get_string_prop = get_string_prop,
 | 
						.get_string_prop = get_string_prop,
 | 
				
			||||||
	.configure = configure,
 | 
						.configure = configure,
 | 
				
			||||||
	.set_activated = set_activated,
 | 
						.set_activated = set_activated,
 | 
				
			||||||
 | 
						.set_maximized = set_maximized,
 | 
				
			||||||
	.set_fullscreen = set_fullscreen,
 | 
						.set_fullscreen = set_fullscreen,
 | 
				
			||||||
 | 
						.wants_floating = wants_floating,
 | 
				
			||||||
	.for_each_surface = for_each_surface,
 | 
						.for_each_surface = for_each_surface,
 | 
				
			||||||
	.close = _close,
 | 
						.close = _close,
 | 
				
			||||||
	.destroy = destroy,
 | 
						.destroy = destroy,
 | 
				
			||||||
| 
						 | 
					@ -163,11 +179,17 @@ static void handle_commit(struct wl_listener *listener, void *data) {
 | 
				
			||||||
	struct sway_xdg_shell_v6_view *xdg_shell_v6_view =
 | 
						struct sway_xdg_shell_v6_view *xdg_shell_v6_view =
 | 
				
			||||||
		wl_container_of(listener, xdg_shell_v6_view, commit);
 | 
							wl_container_of(listener, xdg_shell_v6_view, commit);
 | 
				
			||||||
	struct sway_view *view = &xdg_shell_v6_view->view;
 | 
						struct sway_view *view = &xdg_shell_v6_view->view;
 | 
				
			||||||
	// NOTE: We intentionally discard the view's desired width here
 | 
						struct wlr_box *geometry = &view->wlr_xdg_surface_v6->geometry;
 | 
				
			||||||
	// TODO: Store this for restoration when moving to floating plane
 | 
						if (!view->natural_width && !view->natural_height) {
 | 
				
			||||||
	// TODO: Let floating views do whatever
 | 
							view->natural_width = geometry->width;
 | 
				
			||||||
 | 
							view->natural_height = geometry->height;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if (view->swayc && view->swayc->is_floating) {
 | 
				
			||||||
 | 
							view_update_size(view, geometry->width, geometry->height);
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
		view_update_size(view, xdg_shell_v6_view->pending_width,
 | 
							view_update_size(view, xdg_shell_v6_view->pending_width,
 | 
				
			||||||
				xdg_shell_v6_view->pending_height);
 | 
									xdg_shell_v6_view->pending_height);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	view_update_title(view, false);
 | 
						view_update_title(view, false);
 | 
				
			||||||
	view_damage_from(view);
 | 
						view_damage_from(view);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -152,7 +152,9 @@ static uint32_t get_int_prop(struct sway_view *view, enum sway_view_prop prop) {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void configure(struct sway_view *view, double ox, double oy, int width,
 | 
					// The x and y arguments are output-local for tiled views, and layout
 | 
				
			||||||
 | 
					// coordinates for floating views.
 | 
				
			||||||
 | 
					static void configure(struct sway_view *view, double x, double y, int width,
 | 
				
			||||||
		int height) {
 | 
							int height) {
 | 
				
			||||||
	struct sway_xwayland_view *xwayland_view = xwayland_view_from_view(view);
 | 
						struct sway_xwayland_view *xwayland_view = xwayland_view_from_view(view);
 | 
				
			||||||
	if (xwayland_view == NULL) {
 | 
						if (xwayland_view == NULL) {
 | 
				
			||||||
| 
						 | 
					@ -160,6 +162,11 @@ static void configure(struct sway_view *view, double ox, double oy, int width,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface;
 | 
						struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						double lx, ly;
 | 
				
			||||||
 | 
						if (view->swayc->is_floating) {
 | 
				
			||||||
 | 
							lx = x;
 | 
				
			||||||
 | 
							ly = y;
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
		struct sway_container *output = container_parent(view->swayc, C_OUTPUT);
 | 
							struct sway_container *output = container_parent(view->swayc, C_OUTPUT);
 | 
				
			||||||
		if (!sway_assert(output, "view must be within tree to set position")) {
 | 
							if (!sway_assert(output, "view must be within tree to set position")) {
 | 
				
			||||||
			return;
 | 
								return;
 | 
				
			||||||
| 
						 | 
					@ -171,14 +178,17 @@ static void configure(struct sway_view *view, double ox, double oy, int width,
 | 
				
			||||||
		struct wlr_output_layout *layout = root->sway_root->output_layout;
 | 
							struct wlr_output_layout *layout = root->sway_root->output_layout;
 | 
				
			||||||
		struct wlr_output_layout_output *loutput =
 | 
							struct wlr_output_layout_output *loutput =
 | 
				
			||||||
			wlr_output_layout_get(layout, output->sway_output->wlr_output);
 | 
								wlr_output_layout_get(layout, output->sway_output->wlr_output);
 | 
				
			||||||
	if (!sway_assert(loutput, "output must be within layout to set position")) {
 | 
							if (!sway_assert(loutput,
 | 
				
			||||||
 | 
										"output must be within layout to set position")) {
 | 
				
			||||||
			return;
 | 
								return;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
							lx = x + loutput->x;
 | 
				
			||||||
 | 
							ly = y + loutput->y;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	xwayland_view->pending_width = width;
 | 
						xwayland_view->pending_width = width;
 | 
				
			||||||
	xwayland_view->pending_height = height;
 | 
						xwayland_view->pending_height = height;
 | 
				
			||||||
	wlr_xwayland_surface_configure(xsurface, ox + loutput->x, oy + loutput->y,
 | 
						wlr_xwayland_surface_configure(xsurface, lx, ly, width, height);
 | 
				
			||||||
		width, height);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void set_activated(struct sway_view *view, bool activated) {
 | 
					static void set_activated(struct sway_view *view, bool activated) {
 | 
				
			||||||
| 
						 | 
					@ -189,6 +199,14 @@ static void set_activated(struct sway_view *view, bool activated) {
 | 
				
			||||||
	wlr_xwayland_surface_activate(surface, activated);
 | 
						wlr_xwayland_surface_activate(surface, activated);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void set_maximized(struct sway_view *view, bool maximized) {
 | 
				
			||||||
 | 
						if (xwayland_view_from_view(view) == NULL) {
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						struct wlr_xwayland_surface *surface = view->wlr_xwayland_surface;
 | 
				
			||||||
 | 
						wlr_xwayland_surface_set_maximized(surface, maximized);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void set_fullscreen(struct sway_view *view, bool fullscreen) {
 | 
					static void set_fullscreen(struct sway_view *view, bool fullscreen) {
 | 
				
			||||||
	if (xwayland_view_from_view(view) == NULL) {
 | 
						if (xwayland_view_from_view(view) == NULL) {
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
| 
						 | 
					@ -197,6 +215,35 @@ static void set_fullscreen(struct sway_view *view, bool fullscreen) {
 | 
				
			||||||
	wlr_xwayland_surface_set_fullscreen(surface, fullscreen);
 | 
						wlr_xwayland_surface_set_fullscreen(surface, fullscreen);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static bool wants_floating(struct sway_view *view) {
 | 
				
			||||||
 | 
						// TODO:
 | 
				
			||||||
 | 
						// We want to return true if the window type contains any of these:
 | 
				
			||||||
 | 
						// NET_WM_WINDOW_TYPE_DIALOG
 | 
				
			||||||
 | 
						// NET_WM_WINDOW_TYPE_UTILITY
 | 
				
			||||||
 | 
						// NET_WM_WINDOW_TYPE_TOOLBAR
 | 
				
			||||||
 | 
						// NET_WM_WINDOW_TYPE_SPLASH
 | 
				
			||||||
 | 
						//
 | 
				
			||||||
 | 
						// We also want to return true if the NET_WM_STATE is MODAL.
 | 
				
			||||||
 | 
						// wlroots doesn't appear to provide all this information at the moment.
 | 
				
			||||||
 | 
						struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface;
 | 
				
			||||||
 | 
						uint32_t *atom = xsurface->window_type;
 | 
				
			||||||
 | 
						for (size_t i = 0; i < xsurface->window_type_len; ++i) {
 | 
				
			||||||
 | 
							wlr_log(L_DEBUG, "xwayland window type %i", *atom);
 | 
				
			||||||
 | 
							// TODO: Come up with a better way of doing this
 | 
				
			||||||
 | 
							switch (*atom) {
 | 
				
			||||||
 | 
							case 36: // NET_WM_WINDOW_TYPE_UTILITY
 | 
				
			||||||
 | 
							case 44: // NET_WM_WINDOW_TYPE_SPLASH
 | 
				
			||||||
 | 
							case 276: // ? PGP passphrase dialog
 | 
				
			||||||
 | 
							case 337: // ? Firefox open file dialog
 | 
				
			||||||
 | 
							case 338: // ? Firefox open file dialog
 | 
				
			||||||
 | 
								return true;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							++atom;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return false;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void _close(struct sway_view *view) {
 | 
					static void _close(struct sway_view *view) {
 | 
				
			||||||
	if (xwayland_view_from_view(view) == NULL) {
 | 
						if (xwayland_view_from_view(view) == NULL) {
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
| 
						 | 
					@ -225,7 +272,9 @@ static const struct sway_view_impl view_impl = {
 | 
				
			||||||
	.get_int_prop = get_int_prop,
 | 
						.get_int_prop = get_int_prop,
 | 
				
			||||||
	.configure = configure,
 | 
						.configure = configure,
 | 
				
			||||||
	.set_activated = set_activated,
 | 
						.set_activated = set_activated,
 | 
				
			||||||
 | 
						.set_maximized = set_maximized,
 | 
				
			||||||
	.set_fullscreen = set_fullscreen,
 | 
						.set_fullscreen = set_fullscreen,
 | 
				
			||||||
 | 
						.wants_floating = wants_floating,
 | 
				
			||||||
	.close = _close,
 | 
						.close = _close,
 | 
				
			||||||
	.destroy = destroy,
 | 
						.destroy = destroy,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					@ -234,10 +283,18 @@ static void handle_commit(struct wl_listener *listener, void *data) {
 | 
				
			||||||
	struct sway_xwayland_view *xwayland_view =
 | 
						struct sway_xwayland_view *xwayland_view =
 | 
				
			||||||
		wl_container_of(listener, xwayland_view, commit);
 | 
							wl_container_of(listener, xwayland_view, commit);
 | 
				
			||||||
	struct sway_view *view = &xwayland_view->view;
 | 
						struct sway_view *view = &xwayland_view->view;
 | 
				
			||||||
	// NOTE: We intentionally discard the view's desired width here
 | 
						struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface;
 | 
				
			||||||
	// TODO: Let floating views do whatever
 | 
						if (!view->natural_width && !view->natural_height) {
 | 
				
			||||||
 | 
							view->natural_width = xsurface->width;
 | 
				
			||||||
 | 
							view->natural_height = xsurface->height;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if (view->swayc && view->swayc->is_floating) {
 | 
				
			||||||
 | 
							view_update_size(view, xsurface->width, xsurface->height);
 | 
				
			||||||
 | 
							view_update_position(view, xsurface->x, xsurface->y);
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
		view_update_size(view, xwayland_view->pending_width,
 | 
							view_update_size(view, xwayland_view->pending_width,
 | 
				
			||||||
				xwayland_view->pending_height);
 | 
									xwayland_view->pending_height);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	view_damage_from(view);
 | 
						view_damage_from(view);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -108,6 +108,9 @@ static struct sway_container *container_at_coords(
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct sway_container *c;
 | 
						struct sway_container *c;
 | 
				
			||||||
 | 
						if ((c = floating_container_at(x, y, surface, sx, sy))) {
 | 
				
			||||||
 | 
							return c;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	if ((c = container_at(ws, ox, oy, surface, sx, sy))) {
 | 
						if ((c = container_at(ws, ox, oy, surface, sx, sy))) {
 | 
				
			||||||
		return c;
 | 
							return c;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -113,7 +113,14 @@ static void seat_send_focus(struct sway_container *con,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static struct sway_container *seat_get_focus_by_type(struct sway_seat *seat,
 | 
					static struct sway_container *seat_get_focus_by_type(struct sway_seat *seat,
 | 
				
			||||||
		struct sway_container *container, enum sway_container_type type) {
 | 
							struct sway_container *container, enum sway_container_type type) {
 | 
				
			||||||
	if (container->type == C_VIEW || container->children->length == 0) {
 | 
						if (container->type == C_VIEW) {
 | 
				
			||||||
 | 
							return container;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						struct sway_container *floating = container->type == C_WORKSPACE ?
 | 
				
			||||||
 | 
							container->sway_workspace->floating : NULL;
 | 
				
			||||||
 | 
						if (container->children->length == 0 &&
 | 
				
			||||||
 | 
								(!floating || floating->children->length == 0)) {
 | 
				
			||||||
		return container;
 | 
							return container;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -126,6 +133,9 @@ static struct sway_container *seat_get_focus_by_type(struct sway_seat *seat,
 | 
				
			||||||
		if (container_has_child(container, current->container)) {
 | 
							if (container_has_child(container, current->container)) {
 | 
				
			||||||
			return current->container;
 | 
								return current->container;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
							if (floating && container_has_child(floating, current->container)) {
 | 
				
			||||||
 | 
								return current->container;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return NULL;
 | 
						return NULL;
 | 
				
			||||||
| 
						 | 
					@ -568,7 +578,7 @@ void seat_set_focus_warp(struct sway_seat *seat,
 | 
				
			||||||
	// clean up unfocused empty workspace on new output
 | 
						// clean up unfocused empty workspace on new output
 | 
				
			||||||
	if (new_output_last_ws) {
 | 
						if (new_output_last_ws) {
 | 
				
			||||||
		if (!workspace_is_visible(new_output_last_ws)
 | 
							if (!workspace_is_visible(new_output_last_ws)
 | 
				
			||||||
				&& new_output_last_ws->children->length == 0) {
 | 
									&& workspace_is_empty(new_output_last_ws)) {
 | 
				
			||||||
			if (last_workspace == new_output_last_ws) {
 | 
								if (last_workspace == new_output_last_ws) {
 | 
				
			||||||
				last_focus = NULL;
 | 
									last_focus = NULL;
 | 
				
			||||||
				last_workspace = NULL;
 | 
									last_workspace = NULL;
 | 
				
			||||||
| 
						 | 
					@ -581,7 +591,7 @@ void seat_set_focus_warp(struct sway_seat *seat,
 | 
				
			||||||
		if (last_workspace) {
 | 
							if (last_workspace) {
 | 
				
			||||||
			ipc_event_workspace(last_workspace, container, "focus");
 | 
								ipc_event_workspace(last_workspace, container, "focus");
 | 
				
			||||||
			if (!workspace_is_visible(last_workspace)
 | 
								if (!workspace_is_visible(last_workspace)
 | 
				
			||||||
					&& last_workspace->children->length == 0) {
 | 
										&& workspace_is_empty(last_workspace)) {
 | 
				
			||||||
				if (last_workspace == last_focus) {
 | 
									if (last_workspace == last_focus) {
 | 
				
			||||||
					last_focus = NULL;
 | 
										last_focus = NULL;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4,6 +4,7 @@
 | 
				
			||||||
#include "log.h"
 | 
					#include "log.h"
 | 
				
			||||||
#include "sway/ipc-json.h"
 | 
					#include "sway/ipc-json.h"
 | 
				
			||||||
#include "sway/tree/container.h"
 | 
					#include "sway/tree/container.h"
 | 
				
			||||||
 | 
					#include "sway/tree/workspace.h"
 | 
				
			||||||
#include "sway/output.h"
 | 
					#include "sway/output.h"
 | 
				
			||||||
#include "sway/input/input-manager.h"
 | 
					#include "sway/input/input-manager.h"
 | 
				
			||||||
#include "sway/input/seat.h"
 | 
					#include "sway/input/seat.h"
 | 
				
			||||||
| 
						 | 
					@ -150,6 +151,15 @@ static void ipc_json_describe_workspace(struct sway_container *workspace,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const char *layout = ipc_json_layout_description(workspace->layout);
 | 
						const char *layout = ipc_json_layout_description(workspace->layout);
 | 
				
			||||||
	json_object_object_add(object, "layout", json_object_new_string(layout));
 | 
						json_object_object_add(object, "layout", json_object_new_string(layout));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// Floating
 | 
				
			||||||
 | 
						json_object *floating_array = json_object_new_array();
 | 
				
			||||||
 | 
						struct sway_container *floating = workspace->sway_workspace->floating;
 | 
				
			||||||
 | 
						for (int i = 0; i < floating->children->length; ++i) {
 | 
				
			||||||
 | 
							struct sway_container *floater = floating->children->items[i];
 | 
				
			||||||
 | 
							json_object_array_add(floating_array, ipc_json_describe_container_recursive(floater));
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						json_object_object_add(object, "floating_nodes", floating_array);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void ipc_json_describe_view(struct sway_container *c, json_object *object) {
 | 
					static void ipc_json_describe_view(struct sway_container *c, json_object *object) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -65,6 +65,7 @@ sway_sources = files(
 | 
				
			||||||
	'commands/set.c',
 | 
						'commands/set.c',
 | 
				
			||||||
	'commands/show_marks.c',
 | 
						'commands/show_marks.c',
 | 
				
			||||||
	'commands/split.c',
 | 
						'commands/split.c',
 | 
				
			||||||
 | 
						'commands/sticky.c',
 | 
				
			||||||
	'commands/swaybg_command.c',
 | 
						'commands/swaybg_command.c',
 | 
				
			||||||
	'commands/swap.c',
 | 
						'commands/swap.c',
 | 
				
			||||||
	'commands/title_format.c',
 | 
						'commands/title_format.c',
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -247,6 +247,18 @@ void arrange_children_of(struct sway_container *parent) {
 | 
				
			||||||
			arrange_children_of(child);
 | 
								arrange_children_of(child);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// If container is a workspace, process floating containers too
 | 
				
			||||||
 | 
						if (parent->type == C_WORKSPACE) {
 | 
				
			||||||
 | 
							struct sway_workspace *ws = workspace->sway_workspace;
 | 
				
			||||||
 | 
							for (int i = 0; i < ws->floating->children->length; ++i) {
 | 
				
			||||||
 | 
								struct sway_container *child = ws->floating->children->items[i];
 | 
				
			||||||
 | 
								if (child->type != C_VIEW) {
 | 
				
			||||||
 | 
									arrange_children_of(child);
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	container_damage_whole(parent);
 | 
						container_damage_whole(parent);
 | 
				
			||||||
	update_debug_tree();
 | 
						update_debug_tree();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -123,6 +123,7 @@ struct sway_container *container_create(enum sway_container_type type) {
 | 
				
			||||||
	c->layout = L_NONE;
 | 
						c->layout = L_NONE;
 | 
				
			||||||
	c->type = type;
 | 
						c->type = type;
 | 
				
			||||||
	c->alpha = 1.0f;
 | 
						c->alpha = 1.0f;
 | 
				
			||||||
 | 
						c->reapable = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (type != C_VIEW) {
 | 
						if (type != C_VIEW) {
 | 
				
			||||||
		c->children = create_list();
 | 
							c->children = create_list();
 | 
				
			||||||
| 
						 | 
					@ -189,14 +190,13 @@ static struct sway_container *container_workspace_destroy(
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct sway_container *parent = workspace->parent;
 | 
						struct sway_container *parent = workspace->parent;
 | 
				
			||||||
	if (workspace->children->length == 0) {
 | 
						if (workspace_is_empty(workspace)) {
 | 
				
			||||||
		// destroy the WS if there are no children (TODO check for floating)
 | 
							// destroy the WS if there are no children
 | 
				
			||||||
		wlr_log(L_DEBUG, "destroying workspace '%s'", workspace->name);
 | 
							wlr_log(L_DEBUG, "destroying workspace '%s'", workspace->name);
 | 
				
			||||||
		ipc_event_workspace(workspace, NULL, "empty");
 | 
							ipc_event_workspace(workspace, NULL, "empty");
 | 
				
			||||||
	} else if (output) {
 | 
						} else if (output) {
 | 
				
			||||||
		// Move children to a different workspace on this output
 | 
							// Move children to a different workspace on this output
 | 
				
			||||||
		struct sway_container *new_workspace = NULL;
 | 
							struct sway_container *new_workspace = NULL;
 | 
				
			||||||
		// TODO move floating
 | 
					 | 
				
			||||||
		for (int i = 0; i < output->children->length; i++) {
 | 
							for (int i = 0; i < output->children->length; i++) {
 | 
				
			||||||
			if (output->children->items[i] != workspace) {
 | 
								if (output->children->items[i] != workspace) {
 | 
				
			||||||
				new_workspace = output->children->items[i];
 | 
									new_workspace = output->children->items[i];
 | 
				
			||||||
| 
						 | 
					@ -209,6 +209,11 @@ static struct sway_container *container_workspace_destroy(
 | 
				
			||||||
		for (int i = 0; i < workspace->children->length; i++) {
 | 
							for (int i = 0; i < workspace->children->length; i++) {
 | 
				
			||||||
			container_move_to(workspace->children->items[i], new_workspace);
 | 
								container_move_to(workspace->children->items[i], new_workspace);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
							struct sway_container *floating = workspace->sway_workspace->floating;
 | 
				
			||||||
 | 
							for (int i = 0; i < floating->children->length; i++) {
 | 
				
			||||||
 | 
								container_move_to(floating->children->items[i],
 | 
				
			||||||
 | 
										new_workspace->sway_workspace->floating);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	free(workspace->sway_workspace);
 | 
						free(workspace->sway_workspace);
 | 
				
			||||||
| 
						 | 
					@ -275,13 +280,16 @@ static void container_root_finish(struct sway_container *con) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool container_reap_empty(struct sway_container *con) {
 | 
					bool container_reap_empty(struct sway_container *con) {
 | 
				
			||||||
 | 
						if (!con->reapable) {
 | 
				
			||||||
 | 
							return false;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	switch (con->type) {
 | 
						switch (con->type) {
 | 
				
			||||||
	case C_ROOT:
 | 
						case C_ROOT:
 | 
				
			||||||
	case C_OUTPUT:
 | 
						case C_OUTPUT:
 | 
				
			||||||
		// dont reap these
 | 
							// dont reap these
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
	case C_WORKSPACE:
 | 
						case C_WORKSPACE:
 | 
				
			||||||
		if (!workspace_is_visible(con) && con->children->length == 0) {
 | 
							if (!workspace_is_visible(con) && workspace_is_empty(con)) {
 | 
				
			||||||
			wlr_log(L_DEBUG, "Destroying workspace via reaper");
 | 
								wlr_log(L_DEBUG, "Destroying workspace via reaper");
 | 
				
			||||||
			container_workspace_destroy(con);
 | 
								container_workspace_destroy(con);
 | 
				
			||||||
			return true;
 | 
								return true;
 | 
				
			||||||
| 
						 | 
					@ -436,7 +444,6 @@ struct sway_container *container_find(struct sway_container *container,
 | 
				
			||||||
	if (!container->children) {
 | 
						if (!container->children) {
 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	// TODO: floating windows
 | 
					 | 
				
			||||||
	for (int i = 0; i < container->children->length; ++i) {
 | 
						for (int i = 0; i < container->children->length; ++i) {
 | 
				
			||||||
		struct sway_container *child = container->children->items[i];
 | 
							struct sway_container *child = container->children->items[i];
 | 
				
			||||||
		if (test(child, data)) {
 | 
							if (test(child, data)) {
 | 
				
			||||||
| 
						 | 
					@ -448,6 +455,9 @@ struct sway_container *container_find(struct sway_container *container,
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						if (container->type == C_WORKSPACE) {
 | 
				
			||||||
 | 
							return container_find(container->sway_workspace->floating, test, data);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	return NULL;
 | 
						return NULL;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -608,8 +618,6 @@ struct sway_container *container_at(struct sway_container *parent,
 | 
				
			||||||
		return container_at_tabbed(parent, ox, oy, surface, sx, sy);
 | 
							return container_at_tabbed(parent, ox, oy, surface, sx, sy);
 | 
				
			||||||
	case L_STACKED:
 | 
						case L_STACKED:
 | 
				
			||||||
		return container_at_stacked(parent, ox, oy, surface, sx, sy);
 | 
							return container_at_stacked(parent, ox, oy, surface, sx, sy);
 | 
				
			||||||
	case L_FLOATING:
 | 
					 | 
				
			||||||
		return NULL; // TODO
 | 
					 | 
				
			||||||
	case L_NONE:
 | 
						case L_NONE:
 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -617,6 +625,34 @@ struct sway_container *container_at(struct sway_container *parent,
 | 
				
			||||||
	return NULL;
 | 
						return NULL;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct sway_container *floating_container_at(double lx, double ly,
 | 
				
			||||||
 | 
							struct wlr_surface **surface, double *sx, double *sy) {
 | 
				
			||||||
 | 
						for (int i = 0; i < root_container.children->length; ++i) {
 | 
				
			||||||
 | 
							struct sway_container *output = root_container.children->items[i];
 | 
				
			||||||
 | 
							for (int j = 0; j < output->children->length; ++j) {
 | 
				
			||||||
 | 
								struct sway_container *workspace = output->children->items[j];
 | 
				
			||||||
 | 
								struct sway_workspace *ws = workspace->sway_workspace;
 | 
				
			||||||
 | 
								bool ws_is_visible = workspace_is_visible(workspace);
 | 
				
			||||||
 | 
								for (int k = 0; k < ws->floating->children->length; ++k) {
 | 
				
			||||||
 | 
									struct sway_container *floater =
 | 
				
			||||||
 | 
										ws->floating->children->items[k];
 | 
				
			||||||
 | 
									if (ws_is_visible || floater->is_sticky) {
 | 
				
			||||||
 | 
										struct wlr_box box = {
 | 
				
			||||||
 | 
											.x = floater->x,
 | 
				
			||||||
 | 
											.y = floater->y,
 | 
				
			||||||
 | 
											.width = floater->width,
 | 
				
			||||||
 | 
											.height = floater->height,
 | 
				
			||||||
 | 
										};
 | 
				
			||||||
 | 
										if (wlr_box_contains_point(&box, lx, ly)) {
 | 
				
			||||||
 | 
											return container_at(floater, lx, ly, surface, sx, sy);
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return NULL;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void container_for_each_descendant_dfs(struct sway_container *container,
 | 
					void container_for_each_descendant_dfs(struct sway_container *container,
 | 
				
			||||||
		void (*f)(struct sway_container *container, void *data),
 | 
							void (*f)(struct sway_container *container, void *data),
 | 
				
			||||||
		void *data) {
 | 
							void *data) {
 | 
				
			||||||
| 
						 | 
					@ -674,7 +710,7 @@ static bool find_child_func(struct sway_container *con, void *data) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool container_has_child(struct sway_container *con,
 | 
					bool container_has_child(struct sway_container *con,
 | 
				
			||||||
		struct sway_container *child) {
 | 
							struct sway_container *child) {
 | 
				
			||||||
	if (con == NULL || con->type == C_VIEW || con->children->length == 0) {
 | 
						if (con == NULL || con->type == C_VIEW) {
 | 
				
			||||||
		return false;
 | 
							return false;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return container_find(con, find_child_func, child);
 | 
						return container_find(con, find_child_func, child);
 | 
				
			||||||
| 
						 | 
					@ -806,9 +842,6 @@ static size_t get_tree_representation(struct sway_container *parent, char *buffe
 | 
				
			||||||
	case L_STACKED:
 | 
						case L_STACKED:
 | 
				
			||||||
		lenient_strcat(buffer, "S[");
 | 
							lenient_strcat(buffer, "S[");
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
	case L_FLOATING:
 | 
					 | 
				
			||||||
		lenient_strcat(buffer, "F[");
 | 
					 | 
				
			||||||
		break;
 | 
					 | 
				
			||||||
	case L_NONE:
 | 
						case L_NONE:
 | 
				
			||||||
		lenient_strcat(buffer, "D[");
 | 
							lenient_strcat(buffer, "D[");
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
| 
						 | 
					@ -866,3 +899,81 @@ void container_notify_subtree_changed(struct sway_container *container) {
 | 
				
			||||||
size_t container_titlebar_height() {
 | 
					size_t container_titlebar_height() {
 | 
				
			||||||
	return config->font_height + TITLEBAR_V_PADDING * 2;
 | 
						return config->font_height + TITLEBAR_V_PADDING * 2;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void configure_floating_view(struct sway_view *view) {
 | 
				
			||||||
 | 
						struct sway_container *ws = container_parent(view->swayc, C_WORKSPACE);
 | 
				
			||||||
 | 
						int max_width = ws->width * 0.6666;
 | 
				
			||||||
 | 
						int max_height = ws->height * 0.6666;
 | 
				
			||||||
 | 
						int width =
 | 
				
			||||||
 | 
							view->natural_width > max_width ? max_width : view->natural_width;
 | 
				
			||||||
 | 
						int height =
 | 
				
			||||||
 | 
							view->natural_height > max_height ? max_height : view->natural_height;
 | 
				
			||||||
 | 
						struct sway_container *output = ws->parent;
 | 
				
			||||||
 | 
						int lx = output->x + (ws->width - width) / 2;
 | 
				
			||||||
 | 
						int ly = output->y + (ws->height - height) / 2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						view->border_left = view->border_right = view->border_bottom = true;
 | 
				
			||||||
 | 
						view_set_maximized(view, false);
 | 
				
			||||||
 | 
						view_configure(view, lx, ly, width, height);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void container_set_floating(struct sway_container *container, bool enable) {
 | 
				
			||||||
 | 
						if (container->is_floating == enable) {
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						struct sway_container *workspace = container_parent(container, C_WORKSPACE);
 | 
				
			||||||
 | 
						struct sway_seat *seat = input_manager_current_seat(input_manager);
 | 
				
			||||||
 | 
						container_damage_whole(container);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (enable) {
 | 
				
			||||||
 | 
							container_remove_child(container);
 | 
				
			||||||
 | 
							container_add_child(workspace->sway_workspace->floating, container);
 | 
				
			||||||
 | 
							container->is_floating = true;
 | 
				
			||||||
 | 
							if (container->type == C_VIEW) {
 | 
				
			||||||
 | 
								configure_floating_view(container->sway_view);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							seat_set_focus(seat, seat_get_focus_inactive(seat, container));
 | 
				
			||||||
 | 
							container_reap_empty_recursive(workspace);
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							// Returning to tiled
 | 
				
			||||||
 | 
							container_remove_child(container);
 | 
				
			||||||
 | 
							container_add_child(workspace, container);
 | 
				
			||||||
 | 
							container->width = container->parent->width;
 | 
				
			||||||
 | 
							container->height = container->parent->height;
 | 
				
			||||||
 | 
							if (container->type == C_VIEW) {
 | 
				
			||||||
 | 
								view_set_maximized(container->sway_view, true);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							container->is_floating = false;
 | 
				
			||||||
 | 
							container->is_sticky = false;
 | 
				
			||||||
 | 
							container_reap_empty_recursive(workspace->sway_workspace->floating);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						arrange_workspace(workspace);
 | 
				
			||||||
 | 
						container_damage_whole(container);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void container_set_geometry_from_view(struct sway_container *container) {
 | 
				
			||||||
 | 
						if (!sway_assert(container->type == C_VIEW, "Expected a view")) {
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if (!sway_assert(container->is_floating, "Expected a floating view")) {
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						struct sway_view *view = container->sway_view;
 | 
				
			||||||
 | 
						size_t border_width = view->border_thickness * (view->border != B_NONE);
 | 
				
			||||||
 | 
						size_t top =
 | 
				
			||||||
 | 
							view->border == B_NORMAL ? container_titlebar_height() : border_width;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						container->x = view->x - border_width;
 | 
				
			||||||
 | 
						container->y = view->y - top;
 | 
				
			||||||
 | 
						container->width = view->width + border_width * 2;
 | 
				
			||||||
 | 
						container->height = top + view->height + border_width;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool container_self_or_parent_floating(struct sway_container *container) {
 | 
				
			||||||
 | 
						while (container->parent->type != C_WORKSPACE
 | 
				
			||||||
 | 
								&& container->parent->parent->type != C_WORKSPACE) {
 | 
				
			||||||
 | 
							container = container->parent;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return container->is_floating;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -45,21 +45,15 @@ void layout_init(void) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int index_child(const struct sway_container *child) {
 | 
					static int index_child(const struct sway_container *child) {
 | 
				
			||||||
	// TODO handle floating
 | 
					 | 
				
			||||||
	struct sway_container *parent = child->parent;
 | 
						struct sway_container *parent = child->parent;
 | 
				
			||||||
	int i, len;
 | 
						for (int i = 0; i < parent->children->length; ++i) {
 | 
				
			||||||
	len = parent->children->length;
 | 
					 | 
				
			||||||
	for (i = 0; i < len; ++i) {
 | 
					 | 
				
			||||||
		if (parent->children->items[i] == child) {
 | 
							if (parent->children->items[i] == child) {
 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (!sway_assert(i < len, "Stray container")) {
 | 
					 | 
				
			||||||
		return -1;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
			return i;
 | 
								return i;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						// This happens if the child is a floating container
 | 
				
			||||||
 | 
						return -1;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void container_handle_fullscreen_reparent(struct sway_container *viewcon,
 | 
					static void container_handle_fullscreen_reparent(struct sway_container *viewcon,
 | 
				
			||||||
		struct sway_container *old_parent) {
 | 
							struct sway_container *old_parent) {
 | 
				
			||||||
| 
						 | 
					@ -142,59 +136,28 @@ struct sway_container *container_remove_child(struct sway_container *child) {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct sway_container *parent = child->parent;
 | 
						struct sway_container *parent = child->parent;
 | 
				
			||||||
	if (!child->is_floating) {
 | 
					 | 
				
			||||||
	for (int i = 0; i < parent->children->length; ++i) {
 | 
						for (int i = 0; i < parent->children->length; ++i) {
 | 
				
			||||||
		if (parent->children->items[i] == child) {
 | 
							if (parent->children->items[i] == child) {
 | 
				
			||||||
			list_del(parent->children, i);
 | 
								list_del(parent->children, i);
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	} else {
 | 
					 | 
				
			||||||
		if (!sway_assert(parent->type == C_WORKSPACE && child->type == C_VIEW,
 | 
					 | 
				
			||||||
					"Found floating non-view and/or in non-workspace")) {
 | 
					 | 
				
			||||||
			return parent;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		struct sway_workspace *ws = parent->sway_workspace;
 | 
					 | 
				
			||||||
		for (int i = 0; i < ws->floating->length; ++i) {
 | 
					 | 
				
			||||||
			if (ws->floating->items[i] == child) {
 | 
					 | 
				
			||||||
				list_del(ws->floating, i);
 | 
					 | 
				
			||||||
				break;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		child->is_floating = false;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	child->parent = NULL;
 | 
						child->parent = NULL;
 | 
				
			||||||
	container_notify_subtree_changed(parent);
 | 
						container_notify_subtree_changed(parent);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return parent;
 | 
						return parent;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void container_add_floating(struct sway_container *workspace,
 | 
					 | 
				
			||||||
		struct sway_container *child) {
 | 
					 | 
				
			||||||
	if (!sway_assert(workspace->type == C_WORKSPACE && child->type == C_VIEW,
 | 
					 | 
				
			||||||
				"Attempted to float non-view and/or in non-workspace")) {
 | 
					 | 
				
			||||||
		return;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if (!sway_assert(!child->parent,
 | 
					 | 
				
			||||||
				"child already has a parent (invalid call)")) {
 | 
					 | 
				
			||||||
		return;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if (!sway_assert(!child->is_floating,
 | 
					 | 
				
			||||||
				"child is already floating (invalid state)")) {
 | 
					 | 
				
			||||||
		return;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	struct sway_workspace *ws = workspace->sway_workspace;
 | 
					 | 
				
			||||||
	list_add(ws->floating, child);
 | 
					 | 
				
			||||||
	child->parent = workspace;
 | 
					 | 
				
			||||||
	child->is_floating = true;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void container_move_to(struct sway_container *container,
 | 
					void container_move_to(struct sway_container *container,
 | 
				
			||||||
		struct sway_container *destination) {
 | 
							struct sway_container *destination) {
 | 
				
			||||||
	if (container == destination
 | 
						if (container == destination
 | 
				
			||||||
			|| container_has_ancestor(container, destination)) {
 | 
								|| container_has_ancestor(container, destination)) {
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						if (container->is_floating) {
 | 
				
			||||||
 | 
							// TODO
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	struct sway_container *old_parent = container_remove_child(container);
 | 
						struct sway_container *old_parent = container_remove_child(container);
 | 
				
			||||||
	container->width = container->height = 0;
 | 
						container->width = container->height = 0;
 | 
				
			||||||
	container->saved_width = container->saved_height = 0;
 | 
						container->saved_width = container->saved_height = 0;
 | 
				
			||||||
| 
						 | 
					@ -207,8 +170,9 @@ void container_move_to(struct sway_container *container,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	wl_signal_emit(&container->events.reparent, old_parent);
 | 
						wl_signal_emit(&container->events.reparent, old_parent);
 | 
				
			||||||
	if (container->type == C_WORKSPACE) {
 | 
						if (container->type == C_WORKSPACE) {
 | 
				
			||||||
		struct sway_seat *seat = input_manager_get_default_seat(
 | 
							// If moving a workspace to a new output, maybe create a new workspace
 | 
				
			||||||
				input_manager);
 | 
							// on the previous output
 | 
				
			||||||
 | 
							struct sway_seat *seat = input_manager_get_default_seat(input_manager);
 | 
				
			||||||
		if (old_parent->children->length == 0) {
 | 
							if (old_parent->children->length == 0) {
 | 
				
			||||||
			char *ws_name = workspace_next_name(old_parent->name);
 | 
								char *ws_name = workspace_next_name(old_parent->name);
 | 
				
			||||||
			struct sway_container *ws =
 | 
								struct sway_container *ws =
 | 
				
			||||||
| 
						 | 
					@ -754,6 +718,10 @@ struct sway_container *container_get_in_direction(
 | 
				
			||||||
		enum movement_direction dir) {
 | 
							enum movement_direction dir) {
 | 
				
			||||||
	struct sway_container *parent = container->parent;
 | 
						struct sway_container *parent = container->parent;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (container->is_floating) {
 | 
				
			||||||
 | 
							return NULL;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (container->type == C_VIEW && container->sway_view->is_fullscreen) {
 | 
						if (container->type == C_VIEW && container->sway_view->is_fullscreen) {
 | 
				
			||||||
		if (dir == MOVE_PARENT || dir == MOVE_CHILD) {
 | 
							if (dir == MOVE_PARENT || dir == MOVE_CHILD) {
 | 
				
			||||||
			return NULL;
 | 
								return NULL;
 | 
				
			||||||
| 
						 | 
					@ -778,6 +746,9 @@ struct sway_container *container_get_in_direction(
 | 
				
			||||||
		bool can_move = false;
 | 
							bool can_move = false;
 | 
				
			||||||
		int desired;
 | 
							int desired;
 | 
				
			||||||
		int idx = index_child(container);
 | 
							int idx = index_child(container);
 | 
				
			||||||
 | 
							if (idx == -1) {
 | 
				
			||||||
 | 
								return NULL;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
		if (parent->type == C_ROOT) {
 | 
							if (parent->type == C_ROOT) {
 | 
				
			||||||
			enum wlr_direction wlr_dir = 0;
 | 
								enum wlr_direction wlr_dir = 0;
 | 
				
			||||||
			if (!sway_assert(sway_dir_to_wlr(dir, &wlr_dir),
 | 
								if (!sway_assert(sway_dir_to_wlr(dir, &wlr_dir),
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -158,7 +158,6 @@ void view_autoconfigure(struct sway_view *view) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	view->border_top = view->border_bottom = true;
 | 
						view->border_top = view->border_bottom = true;
 | 
				
			||||||
	view->border_left = view->border_right = true;
 | 
						view->border_left = view->border_right = true;
 | 
				
			||||||
	if (view->swayc->layout != L_FLOATING) {
 | 
					 | 
				
			||||||
	if (config->hide_edge_borders == E_BOTH
 | 
						if (config->hide_edge_borders == E_BOTH
 | 
				
			||||||
			|| config->hide_edge_borders == E_VERTICAL
 | 
								|| config->hide_edge_borders == E_VERTICAL
 | 
				
			||||||
			|| (config->hide_edge_borders == E_SMART && !other_views)) {
 | 
								|| (config->hide_edge_borders == E_SMART && !other_views)) {
 | 
				
			||||||
| 
						 | 
					@ -173,7 +172,6 @@ void view_autoconfigure(struct sway_view *view) {
 | 
				
			||||||
		int bottom_y = view->swayc->y + view->swayc->height;
 | 
							int bottom_y = view->swayc->y + view->swayc->height;
 | 
				
			||||||
		view->border_bottom = bottom_y != ws->y + ws->height;
 | 
							view->border_bottom = bottom_y != ws->y + ws->height;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	double x, y, width, height;
 | 
						double x, y, width, height;
 | 
				
			||||||
	x = y = width = height = 0;
 | 
						x = y = width = height = 0;
 | 
				
			||||||
| 
						 | 
					@ -184,11 +182,11 @@ void view_autoconfigure(struct sway_view *view) {
 | 
				
			||||||
	// disable any top border because we'll always have the title bar.
 | 
						// disable any top border because we'll always have the title bar.
 | 
				
			||||||
	if (view->swayc->parent->layout == L_TABBED) {
 | 
						if (view->swayc->parent->layout == L_TABBED) {
 | 
				
			||||||
		y_offset = container_titlebar_height();
 | 
							y_offset = container_titlebar_height();
 | 
				
			||||||
		view->border_top = 0;
 | 
							view->border_top = false;
 | 
				
			||||||
	} else if (view->swayc->parent->layout == L_STACKED) {
 | 
						} else if (view->swayc->parent->layout == L_STACKED) {
 | 
				
			||||||
		y_offset = container_titlebar_height()
 | 
							y_offset = container_titlebar_height()
 | 
				
			||||||
			* view->swayc->parent->children->length;
 | 
								* view->swayc->parent->children->length;
 | 
				
			||||||
		view->border_top = 0;
 | 
							view->border_top = false;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	switch (view->border) {
 | 
						switch (view->border) {
 | 
				
			||||||
| 
						 | 
					@ -237,6 +235,12 @@ void view_set_activated(struct sway_view *view, bool activated) {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void view_set_maximized(struct sway_view *view, bool maximized) {
 | 
				
			||||||
 | 
						if (view->impl->set_maximized) {
 | 
				
			||||||
 | 
							view->impl->set_maximized(view, maximized);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Set fullscreen, but without IPC events or arranging windows.
 | 
					// Set fullscreen, but without IPC events or arranging windows.
 | 
				
			||||||
void view_set_fullscreen_raw(struct sway_view *view, bool fullscreen) {
 | 
					void view_set_fullscreen_raw(struct sway_view *view, bool fullscreen) {
 | 
				
			||||||
	if (view->is_fullscreen == fullscreen) {
 | 
						if (view->is_fullscreen == fullscreen) {
 | 
				
			||||||
| 
						 | 
					@ -452,6 +456,11 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface) {
 | 
				
			||||||
			// TODO: CT_ASSIGN_OUTPUT
 | 
								// TODO: CT_ASSIGN_OUTPUT
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						// If we're about to launch the view into the floating container, then
 | 
				
			||||||
 | 
						// launch it as a tiled view in the root of the workspace instead.
 | 
				
			||||||
 | 
						if (focus->is_floating) {
 | 
				
			||||||
 | 
							focus = focus->parent->parent;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	free(criterias);
 | 
						free(criterias);
 | 
				
			||||||
	cont = container_view_create(focus, view);
 | 
						cont = container_view_create(focus, view);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -468,7 +477,12 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface) {
 | 
				
			||||||
	wl_signal_add(&view->swayc->events.reparent, &view->container_reparent);
 | 
						wl_signal_add(&view->swayc->events.reparent, &view->container_reparent);
 | 
				
			||||||
	view->container_reparent.notify = view_handle_container_reparent;
 | 
						view->container_reparent.notify = view_handle_container_reparent;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (view->impl->wants_floating && view->impl->wants_floating(view)) {
 | 
				
			||||||
 | 
							container_set_floating(view->swayc, true);
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
		arrange_children_of(cont->parent);
 | 
							arrange_children_of(cont->parent);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	input_manager_set_focus(input_manager, cont);
 | 
						input_manager_set_focus(input_manager, cont);
 | 
				
			||||||
	if (workspace) {
 | 
						if (workspace) {
 | 
				
			||||||
		workspace_switch(workspace);
 | 
							workspace_switch(workspace);
 | 
				
			||||||
| 
						 | 
					@ -516,16 +530,14 @@ void view_unmap(struct sway_view *view) {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void view_update_position(struct sway_view *view, double ox, double oy) {
 | 
					void view_update_position(struct sway_view *view, double lx, double ly) {
 | 
				
			||||||
	if (view->swayc->x == ox && view->swayc->y == oy) {
 | 
						if (!view->swayc->is_floating) {
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					 | 
				
			||||||
	// TODO: Only allow this if the view is floating (this function will only be
 | 
					 | 
				
			||||||
	// called in response to wayland clients wanting to reposition themselves).
 | 
					 | 
				
			||||||
	container_damage_whole(view->swayc);
 | 
						container_damage_whole(view->swayc);
 | 
				
			||||||
	view->swayc->x = ox;
 | 
						view->x = lx;
 | 
				
			||||||
	view->swayc->y = oy;
 | 
						view->y = ly;
 | 
				
			||||||
 | 
						container_set_geometry_from_view(view->swayc);
 | 
				
			||||||
	container_damage_whole(view->swayc);
 | 
						container_damage_whole(view->swayc);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -533,15 +545,15 @@ void view_update_size(struct sway_view *view, int width, int height) {
 | 
				
			||||||
	if (view->width == width && view->height == height) {
 | 
						if (view->width == width && view->height == height) {
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					 | 
				
			||||||
	container_damage_whole(view->swayc);
 | 
						container_damage_whole(view->swayc);
 | 
				
			||||||
	// Should we update the swayc width/height here too?
 | 
					 | 
				
			||||||
	view->width = width;
 | 
						view->width = width;
 | 
				
			||||||
	view->height = height;
 | 
						view->height = height;
 | 
				
			||||||
 | 
						if (view->swayc->is_floating) {
 | 
				
			||||||
 | 
							container_set_geometry_from_view(view->swayc);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	container_damage_whole(view->swayc);
 | 
						container_damage_whole(view->swayc);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
static void view_subsurface_create(struct sway_view *view,
 | 
					static void view_subsurface_create(struct sway_view *view,
 | 
				
			||||||
		struct wlr_subsurface *subsurface) {
 | 
							struct wlr_subsurface *subsurface) {
 | 
				
			||||||
	struct sway_view_child *child = calloc(1, sizeof(struct sway_view_child));
 | 
						struct sway_view_child *child = calloc(1, sizeof(struct sway_view_child));
 | 
				
			||||||
| 
						 | 
					@ -888,6 +900,19 @@ bool view_is_visible(struct sway_view *view) {
 | 
				
			||||||
	if (!view->swayc) {
 | 
						if (!view->swayc) {
 | 
				
			||||||
		return false;
 | 
							return false;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						struct sway_container *workspace =
 | 
				
			||||||
 | 
							container_parent(view->swayc, C_WORKSPACE);
 | 
				
			||||||
 | 
						// Determine if view is nested inside a floating container which is sticky.
 | 
				
			||||||
 | 
						// A simple floating view will have this ancestry:
 | 
				
			||||||
 | 
						// C_VIEW (is_floating=true) -> floating -> workspace
 | 
				
			||||||
 | 
						// A more complex ancestry could be:
 | 
				
			||||||
 | 
						// C_VIEW -> C_CONTAINER (tabbed and is_floating) -> floating -> workspace
 | 
				
			||||||
 | 
						struct sway_container *floater = view->swayc;
 | 
				
			||||||
 | 
						while (floater->parent->type != C_WORKSPACE
 | 
				
			||||||
 | 
								&& floater->parent->parent->type != C_WORKSPACE) {
 | 
				
			||||||
 | 
							floater = floater->parent;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						bool is_sticky = floater->is_floating && floater->is_sticky;
 | 
				
			||||||
	// Check view isn't in a tabbed or stacked container on an inactive tab
 | 
						// Check view isn't in a tabbed or stacked container on an inactive tab
 | 
				
			||||||
	struct sway_seat *seat = input_manager_current_seat(input_manager);
 | 
						struct sway_seat *seat = input_manager_current_seat(input_manager);
 | 
				
			||||||
	struct sway_container *container = view->swayc;
 | 
						struct sway_container *container = view->swayc;
 | 
				
			||||||
| 
						 | 
					@ -901,10 +926,12 @@ bool view_is_visible(struct sway_view *view) {
 | 
				
			||||||
		container = container->parent;
 | 
							container = container->parent;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	// Check view isn't hidden by another fullscreen view
 | 
						// Check view isn't hidden by another fullscreen view
 | 
				
			||||||
	struct sway_container *workspace = container;
 | 
					 | 
				
			||||||
	if (workspace->sway_workspace->fullscreen && !view->is_fullscreen) {
 | 
						if (workspace->sway_workspace->fullscreen && !view->is_fullscreen) {
 | 
				
			||||||
		return false;
 | 
							return false;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	// Check the workspace is visible
 | 
						// Check the workspace is visible
 | 
				
			||||||
 | 
						if (!is_sticky) {
 | 
				
			||||||
		return workspace_is_visible(workspace);
 | 
							return workspace_is_visible(workspace);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						return true;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -65,7 +65,9 @@ struct sway_container *workspace_create(struct sway_container *output,
 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	swayws->swayc = workspace;
 | 
						swayws->swayc = workspace;
 | 
				
			||||||
	swayws->floating = create_list();
 | 
						swayws->floating = container_create(C_CONTAINER);
 | 
				
			||||||
 | 
						swayws->floating->parent = swayws->swayc;
 | 
				
			||||||
 | 
						swayws->floating->reapable = false;
 | 
				
			||||||
	workspace->sway_workspace = swayws;
 | 
						workspace->sway_workspace = swayws;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	container_add_child(output, workspace);
 | 
						container_add_child(output, workspace);
 | 
				
			||||||
| 
						 | 
					@ -408,3 +410,16 @@ bool workspace_is_visible(struct sway_container *ws) {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return focus == ws;
 | 
						return focus == ws;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool workspace_is_empty(struct sway_container *ws) {
 | 
				
			||||||
 | 
						if (!sway_assert(ws->type == C_WORKSPACE, "Expected a workspace")) {
 | 
				
			||||||
 | 
							return false;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if (ws->children->length) {
 | 
				
			||||||
 | 
							return false;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if (ws->sway_workspace->floating->children->length) {
 | 
				
			||||||
 | 
							return false;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return true;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue