From f3ab895916ca1a0f004b5ceaefa90eee90676532 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Fri, 4 May 2018 08:24:25 -0400 Subject: Implement `floating enable` --- include/sway/tree/container.h | 3 +++ include/sway/tree/layout.h | 3 +++ include/sway/tree/workspace.h | 1 + 3 files changed, 7 insertions(+) (limited to 'include/sway') diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h index bb6c04a6..fa2f9286 100644 --- a/include/sway/tree/container.h +++ b/include/sway/tree/container.h @@ -76,6 +76,9 @@ struct sway_container { enum sway_container_layout layout; enum sway_container_layout prev_layout; + // Saves us from searching the list of children/floating in the parent + bool is_floating; + // For C_ROOT, this has no meaning // For C_OUTPUT, this is the output position in layout coordinates // For other types, this is the position in output-local coordinates diff --git a/include/sway/tree/layout.h b/include/sway/tree/layout.h index 2e0f2abf..33d0a5d0 100644 --- a/include/sway/tree/layout.h +++ b/include/sway/tree/layout.h @@ -46,6 +46,9 @@ struct sway_container *container_add_sibling(struct sway_container *parent, 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 *new_child); diff --git a/include/sway/tree/workspace.h b/include/sway/tree/workspace.h index 35e1df3b..ece0ab5c 100644 --- a/include/sway/tree/workspace.h +++ b/include/sway/tree/workspace.h @@ -8,6 +8,7 @@ struct sway_view; struct sway_workspace { struct sway_container *swayc; struct sway_view *fullscreen; + list_t *floating; }; extern char *prev_workspace_name; -- cgit v1.2.3 From 1132efe42e8086216c7bab6b405d09a22231dde5 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Fri, 4 May 2018 08:41:16 -0400 Subject: Send frame done to floating views Also centers them on the screen when initially floated In the future we'll need a more sophisticated solution than that --- include/sway/tree/container.h | 1 - 1 file changed, 1 deletion(-) (limited to 'include/sway') diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h index fa2f9286..a4ffd25b 100644 --- a/include/sway/tree/container.h +++ b/include/sway/tree/container.h @@ -40,7 +40,6 @@ enum sway_container_layout { L_VERT, L_STACKED, L_TABBED, - L_FLOATING, }; enum sway_container_border { -- cgit v1.2.3 From 1f2e399ade77070a2d0b82856ad9a3eef96b8676 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Thu, 24 May 2018 22:30:44 +1000 Subject: Implement floating --- include/sway/tree/container.h | 22 ++++++++++++++++++++++ include/sway/tree/layout.h | 3 --- include/sway/tree/view.h | 10 +++++++++- include/sway/tree/workspace.h | 4 +++- 4 files changed, 34 insertions(+), 5 deletions(-) (limited to 'include/sway') diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h index a4ffd25b..b802e1d1 100644 --- a/include/sway/tree/container.h +++ b/include/sway/tree/container.h @@ -75,8 +75,13 @@ struct sway_container { enum sway_container_layout 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 bool is_floating; + bool is_sticky; // For C_ROOT, this has no meaning // 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 *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. */ @@ -229,4 +241,14 @@ void container_notify_subtree_changed(struct sway_container *container); */ 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 diff --git a/include/sway/tree/layout.h b/include/sway/tree/layout.h index 33d0a5d0..2e0f2abf 100644 --- a/include/sway/tree/layout.h +++ b/include/sway/tree/layout.h @@ -46,9 +46,6 @@ struct sway_container *container_add_sibling(struct sway_container *parent, 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 *new_child); diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index a8bf4955..6990e5b6 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h @@ -32,7 +32,9 @@ struct sway_view_impl { void (*configure)(struct sway_view *view, double ox, double oy, int width, int height); 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); + bool (*wants_floating)(struct sway_view *view); void (*for_each_surface)(struct sway_view *view, wlr_surface_iterator_func_t iterator, void *user_data); void (*close)(struct sway_view *view); @@ -50,6 +52,10 @@ struct sway_view { double x, y; 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; 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_maximized(struct sway_view *view, bool maximized); + void view_set_fullscreen_raw(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_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); diff --git a/include/sway/tree/workspace.h b/include/sway/tree/workspace.h index ece0ab5c..81321fc8 100644 --- a/include/sway/tree/workspace.h +++ b/include/sway/tree/workspace.h @@ -8,7 +8,7 @@ struct sway_view; struct sway_workspace { struct sway_container *swayc; struct sway_view *fullscreen; - list_t *floating; + struct sway_container *floating; }; 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_empty(struct sway_container *ws); + #endif -- cgit v1.2.3 From 34f35f0badc767d9b0cbaf2fd429af1d30592d08 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Fri, 25 May 2018 09:10:35 +1000 Subject: Use L_FLOATING instead of reapable boolean --- include/sway/tree/container.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'include/sway') diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h index b802e1d1..906088f0 100644 --- a/include/sway/tree/container.h +++ b/include/sway/tree/container.h @@ -40,6 +40,7 @@ enum sway_container_layout { L_VERT, L_STACKED, L_TABBED, + L_FLOATING, }; enum sway_container_border { @@ -75,10 +76,6 @@ struct sway_container { enum sway_container_layout 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 bool is_floating; bool is_sticky; -- cgit v1.2.3 From aaba7642b3e4e9a63aea49412b10221f399b17af Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Fri, 25 May 2018 09:26:23 +1000 Subject: Replace is_floating boolean with function --- include/sway/tree/container.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'include/sway') diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h index 906088f0..71935697 100644 --- a/include/sway/tree/container.h +++ b/include/sway/tree/container.h @@ -76,8 +76,6 @@ struct sway_container { enum sway_container_layout layout; enum sway_container_layout prev_layout; - // Saves us from searching the list of children/floating in the parent - bool is_floating; bool is_sticky; // For C_ROOT, this has no meaning @@ -243,8 +241,14 @@ 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. + * Determine if the given container is itself floating. + * This will return false for any descendants of a floating container. + */ +bool container_is_floating(struct sway_container *container); + +/** + * Determine if the given container is itself floating or is a child of a + * floating container. */ bool container_self_or_parent_floating(struct sway_container *container); -- cgit v1.2.3 From 13a4b0512e25b8da6e16ca1286f8b62fcc24c5cc Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Fri, 25 May 2018 11:15:43 +1000 Subject: Fix unfullscreening a floating view --- include/sway/tree/container.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/sway') diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h index 71935697..e4f74b08 100644 --- a/include/sway/tree/container.h +++ b/include/sway/tree/container.h @@ -84,6 +84,7 @@ struct sway_container { // Includes borders double x, y; double width, height; + double saved_x, saved_y; double saved_width, saved_height; list_t *children; -- cgit v1.2.3 From 02de2a6f65c189bf563cca5b4d3fbc11826ea7f7 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sat, 26 May 2018 09:22:10 +1000 Subject: Rename set_maximized functions to set_tiled --- include/sway/tree/view.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include/sway') diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index 6990e5b6..7a94b2c2 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h @@ -32,7 +32,7 @@ struct sway_view_impl { void (*configure)(struct sway_view *view, double ox, double oy, int width, int height); void (*set_activated)(struct sway_view *view, bool activated); - void (*set_maximized)(struct sway_view *view, bool maximized); + void (*set_tiled)(struct sway_view *view, bool tiled); void (*set_fullscreen)(struct sway_view *view, bool fullscreen); bool (*wants_floating)(struct sway_view *view); void (*for_each_surface)(struct sway_view *view, @@ -220,7 +220,7 @@ void view_autoconfigure(struct sway_view *view); void view_set_activated(struct sway_view *view, bool activated); -void view_set_maximized(struct sway_view *view, bool maximized); +void view_set_tiled(struct sway_view *view, bool tiled); void view_set_fullscreen_raw(struct sway_view *view, bool fullscreen); -- cgit v1.2.3 From e4e912ea91a5a36d9f17c1730ffbf29707984399 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sat, 26 May 2018 16:26:10 +1000 Subject: Store swayc coordinates as layout-local --- include/sway/tree/container.h | 3 +-- include/sway/tree/view.h | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'include/sway') diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h index e4f74b08..4b686040 100644 --- a/include/sway/tree/container.h +++ b/include/sway/tree/container.h @@ -79,8 +79,7 @@ struct sway_container { bool is_sticky; // For C_ROOT, this has no meaning - // For C_OUTPUT, this is the output position in layout coordinates - // For other types, this is the position in output-local coordinates + // For other types, this is the position in layout coordinates // Includes borders double x, y; double width, height; diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index 7a94b2c2..65a23902 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h @@ -29,7 +29,7 @@ struct sway_view_impl { const char *(*get_string_prop)(struct sway_view *view, enum sway_view_prop prop); uint32_t (*get_int_prop)(struct sway_view *view, enum sway_view_prop prop); - void (*configure)(struct sway_view *view, double ox, double oy, int width, + void (*configure)(struct sway_view *view, double lx, double ly, int width, int height); void (*set_activated)(struct sway_view *view, bool activated); void (*set_tiled)(struct sway_view *view, bool tiled); @@ -48,7 +48,7 @@ struct sway_view { struct sway_container *swayc; // NULL for unmapped views struct wlr_surface *surface; // NULL for unmapped views - // Geometry of the view itself (excludes borders) + // Geometry of the view itself (excludes borders) in layout coordinates double x, y; int width, height; -- cgit v1.2.3 From 70f5d6fcf3219f122077b7e8d0b43a464f4e3fd4 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sat, 26 May 2018 16:32:24 +1000 Subject: Rename container_set_geometry_from_view --- include/sway/tree/container.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/sway') diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h index 4b686040..38c0f35d 100644 --- a/include/sway/tree/container.h +++ b/include/sway/tree/container.h @@ -238,7 +238,7 @@ 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); +void container_set_geometry_from_floating_view(struct sway_container *con); /** * Determine if the given container is itself floating. -- cgit v1.2.3 From d4ed204d4da742ccabae29db2c90a62d90244a90 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sat, 26 May 2018 16:34:15 +1000 Subject: Remove container_self_or_parent_floating --- include/sway/tree/container.h | 6 ------ 1 file changed, 6 deletions(-) (limited to 'include/sway') diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h index 38c0f35d..7ed6aab1 100644 --- a/include/sway/tree/container.h +++ b/include/sway/tree/container.h @@ -246,10 +246,4 @@ void container_set_geometry_from_floating_view(struct sway_container *con); */ bool container_is_floating(struct sway_container *container); -/** - * Determine if the given container is itself floating or is a child of a - * floating container. - */ -bool container_self_or_parent_floating(struct sway_container *container); - #endif -- cgit v1.2.3 From 5b1601c2e32b43cbb253fcd396ab9096f51b7e6c Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sat, 26 May 2018 21:33:18 +1000 Subject: Don't let xwayland views set position unless unmanaged --- include/sway/tree/view.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/sway') diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index 65a23902..5c2f759c 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h @@ -137,6 +137,7 @@ struct sway_xwayland_view { struct wl_listener unmap; struct wl_listener destroy; + int pending_lx, pending_ly; int pending_width, pending_height; }; -- cgit v1.2.3 From 97672295ed50d1d6272876c4a3b6b5607cab05c6 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sun, 27 May 2018 23:43:05 +1000 Subject: Don't unmaximize floating views --- include/sway/tree/view.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'include/sway') diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index 5c2f759c..7362df5c 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h @@ -32,7 +32,6 @@ struct sway_view_impl { void (*configure)(struct sway_view *view, double lx, double ly, int width, int height); void (*set_activated)(struct sway_view *view, bool activated); - void (*set_tiled)(struct sway_view *view, bool tiled); void (*set_fullscreen)(struct sway_view *view, bool fullscreen); bool (*wants_floating)(struct sway_view *view); void (*for_each_surface)(struct sway_view *view, @@ -221,8 +220,6 @@ void view_autoconfigure(struct sway_view *view); void view_set_activated(struct sway_view *view, bool activated); -void view_set_tiled(struct sway_view *view, bool tiled); - void view_set_fullscreen_raw(struct sway_view *view, bool fullscreen); void view_set_fullscreen(struct sway_view *view, bool fullscreen); -- cgit v1.2.3 From a2c1cb9072b990de9181bffeb69e43f9b3030804 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Thu, 31 May 2018 18:21:49 +1000 Subject: Fix mpv damage issue when unfullscreening into floating --- include/sway/tree/view.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include/sway') diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index 7362df5c..3df38e2d 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h @@ -51,6 +51,9 @@ struct sway_view { double x, y; int width, height; + double saved_x, saved_y; + int saved_width, saved_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; -- cgit v1.2.3