2018-03-30 05:41:33 +02:00
|
|
|
#ifndef _SWAY_CONTAINER_H
|
|
|
|
#define _SWAY_CONTAINER_H
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <sys/types.h>
|
2022-01-13 11:15:39 +01:00
|
|
|
#include <wlr/types/wlr_compositor.h>
|
2018-03-30 05:41:33 +02:00
|
|
|
#include "list.h"
|
Implement type safe arguments and demote sway_container
This commit changes the meaning of sway_container so that it only refers
to layout containers and view containers. Workspaces, outputs and the
root are no longer known as containers. Instead, root, outputs,
workspaces and containers are all a type of node, and containers come in
two types: layout containers and view containers.
In addition to the above, this implements type safe variables. This
means we use specific types such as sway_output and sway_workspace
instead of generic containers or nodes. However, it's worth noting that
in a few places places (eg. seat focus and transactions) referring to
them in a generic way is unavoidable which is why we still use nodes in
some places.
If you want a TL;DR, look at node.h, as well as the struct definitions
for root, output, workspace and container. Note that sway_output now
contains a workspaces list, and workspaces now contain a tiling and
floating list, and containers now contain a pointer back to the
workspace.
There are now functions for seat_get_focused_workspace and
seat_get_focused_container. The latter will return NULL if a workspace
itself is focused. Most other seat functions like seat_get_focus and
seat_set_focus now accept and return nodes.
In the config->handler_context struct, current_container has been
replaced with three pointers: node, container and workspace. node is the
same as what current_container was, while workspace is the workspace
that the node resides on and container is the actual container, which
may be NULL if a workspace itself is focused.
The global root_container variable has been replaced with one simply
called root, which is a pointer to the sway_root instance.
The way outputs are created, enabled, disabled and destroyed has
changed. Previously we'd wrap the sway_output in a container when it is
enabled, but as we don't have containers any more it needs a different
approach. The output_create and output_destroy functions previously
created/destroyed the container, but now they create/destroy the
sway_output. There is a new function output_disable to disable an output
without destroying it.
Containers have a new view property. If this is populated then the
container is a view container, otherwise it's a layout container. Like
before, this property is immutable for the life of the container.
Containers have both a `sway_container *parent` and
`sway_workspace *workspace`. As we use specific types now, parent cannot
point to a workspace so it'll be NULL for containers which are direct
children of the workspace. The workspace property is set for all
containers, except those which are hidden in the scratchpad as they have
no workspace.
In some cases we need to refer to workspaces in a container-like way.
For example, workspaces have layout and children, but when using
specific types this makes it difficult. Likewise, it's difficult for a
container to get its parent's layout when the parent could be another
container or a workspace. To make it easier, some helper functions have
been created: container_parent_layout and container_get_siblings.
container_remove_child has been renamed to container_detach and
container_replace_child has been renamed to container_replace.
`container_handle_fullscreen_reparent(con, old_parent)` has had the
old_parent removed. We now unfullscreen the workspace when detaching the
container, so this function is simplified and only needs one argument
now.
container_notify_subtree_changed has been renamed to
container_update_representation. This is more descriptive of its
purpose. I also wanted to be able to call it with whatever container was
changed rather than the container's parent, which makes bubbling up to
the workspace easier.
There are now state structs per node thing. ie. sway_output_state,
sway_workspace_state and sway_container_state.
The focus, move and layout commands have been completely refactored to
work with the specific types. I considered making these a separate PR,
but I'd be backporting my changes only to replace them again, and it's
easier just to test everything at once.
2018-08-30 13:00:10 +02:00
|
|
|
#include "sway/tree/node.h"
|
2018-03-30 05:41:33 +02:00
|
|
|
|
|
|
|
struct sway_view;
|
|
|
|
struct sway_seat;
|
|
|
|
|
|
|
|
enum sway_container_layout {
|
|
|
|
L_NONE,
|
|
|
|
L_HORIZ,
|
|
|
|
L_VERT,
|
|
|
|
L_STACKED,
|
|
|
|
L_TABBED,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum sway_container_border {
|
|
|
|
B_NONE,
|
|
|
|
B_PIXEL,
|
|
|
|
B_NORMAL,
|
2018-09-24 12:54:57 +02:00
|
|
|
B_CSD,
|
2018-03-30 05:41:33 +02:00
|
|
|
};
|
|
|
|
|
2019-01-24 23:29:21 +01:00
|
|
|
enum sway_fullscreen_mode {
|
|
|
|
FULLSCREEN_NONE,
|
|
|
|
FULLSCREEN_WORKSPACE,
|
|
|
|
FULLSCREEN_GLOBAL,
|
|
|
|
};
|
|
|
|
|
2018-03-30 05:41:33 +02:00
|
|
|
struct sway_root;
|
|
|
|
struct sway_output;
|
2018-04-17 01:31:34 +02:00
|
|
|
struct sway_workspace;
|
2018-03-30 05:41:33 +02:00
|
|
|
struct sway_view;
|
|
|
|
|
2018-08-26 04:05:16 +02:00
|
|
|
enum wlr_direction;
|
|
|
|
|
2018-06-03 08:35:06 +02:00
|
|
|
struct sway_container_state {
|
Implement type safe arguments and demote sway_container
This commit changes the meaning of sway_container so that it only refers
to layout containers and view containers. Workspaces, outputs and the
root are no longer known as containers. Instead, root, outputs,
workspaces and containers are all a type of node, and containers come in
two types: layout containers and view containers.
In addition to the above, this implements type safe variables. This
means we use specific types such as sway_output and sway_workspace
instead of generic containers or nodes. However, it's worth noting that
in a few places places (eg. seat focus and transactions) referring to
them in a generic way is unavoidable which is why we still use nodes in
some places.
If you want a TL;DR, look at node.h, as well as the struct definitions
for root, output, workspace and container. Note that sway_output now
contains a workspaces list, and workspaces now contain a tiling and
floating list, and containers now contain a pointer back to the
workspace.
There are now functions for seat_get_focused_workspace and
seat_get_focused_container. The latter will return NULL if a workspace
itself is focused. Most other seat functions like seat_get_focus and
seat_set_focus now accept and return nodes.
In the config->handler_context struct, current_container has been
replaced with three pointers: node, container and workspace. node is the
same as what current_container was, while workspace is the workspace
that the node resides on and container is the actual container, which
may be NULL if a workspace itself is focused.
The global root_container variable has been replaced with one simply
called root, which is a pointer to the sway_root instance.
The way outputs are created, enabled, disabled and destroyed has
changed. Previously we'd wrap the sway_output in a container when it is
enabled, but as we don't have containers any more it needs a different
approach. The output_create and output_destroy functions previously
created/destroyed the container, but now they create/destroy the
sway_output. There is a new function output_disable to disable an output
without destroying it.
Containers have a new view property. If this is populated then the
container is a view container, otherwise it's a layout container. Like
before, this property is immutable for the life of the container.
Containers have both a `sway_container *parent` and
`sway_workspace *workspace`. As we use specific types now, parent cannot
point to a workspace so it'll be NULL for containers which are direct
children of the workspace. The workspace property is set for all
containers, except those which are hidden in the scratchpad as they have
no workspace.
In some cases we need to refer to workspaces in a container-like way.
For example, workspaces have layout and children, but when using
specific types this makes it difficult. Likewise, it's difficult for a
container to get its parent's layout when the parent could be another
container or a workspace. To make it easier, some helper functions have
been created: container_parent_layout and container_get_siblings.
container_remove_child has been renamed to container_detach and
container_replace_child has been renamed to container_replace.
`container_handle_fullscreen_reparent(con, old_parent)` has had the
old_parent removed. We now unfullscreen the workspace when detaching the
container, so this function is simplified and only needs one argument
now.
container_notify_subtree_changed has been renamed to
container_update_representation. This is more descriptive of its
purpose. I also wanted to be able to call it with whatever container was
changed rather than the container's parent, which makes bubbling up to
the workspace easier.
There are now state structs per node thing. ie. sway_output_state,
sway_workspace_state and sway_container_state.
The focus, move and layout commands have been completely refactored to
work with the specific types. I considered making these a separate PR,
but I'd be backporting my changes only to replace them again, and it's
easier just to test everything at once.
2018-08-30 13:00:10 +02:00
|
|
|
// Container properties
|
2018-06-03 08:35:06 +02:00
|
|
|
enum sway_container_layout layout;
|
2020-01-15 17:52:33 +01:00
|
|
|
double x, y;
|
|
|
|
double width, height;
|
2018-06-03 08:35:06 +02:00
|
|
|
|
2019-01-24 23:29:21 +01:00
|
|
|
enum sway_fullscreen_mode fullscreen_mode;
|
2018-07-25 12:56:23 +02:00
|
|
|
|
2021-02-12 23:22:51 +01:00
|
|
|
struct sway_workspace *workspace; // NULL when hidden in the scratchpad
|
|
|
|
struct sway_container *parent; // NULL if container in root of workspace
|
|
|
|
list_t *children; // struct sway_container
|
2018-06-03 08:35:06 +02:00
|
|
|
|
2018-07-15 07:20:21 +02:00
|
|
|
struct sway_container *focused_inactive_child;
|
|
|
|
bool focused;
|
|
|
|
|
2018-06-03 08:35:06 +02:00
|
|
|
enum sway_container_border border;
|
|
|
|
int border_thickness;
|
|
|
|
bool border_top;
|
|
|
|
bool border_bottom;
|
|
|
|
bool border_left;
|
|
|
|
bool border_right;
|
2018-10-31 11:28:36 +01:00
|
|
|
|
2021-02-12 23:22:51 +01:00
|
|
|
// These are in layout coordinates.
|
2020-01-15 17:52:33 +01:00
|
|
|
double content_x, content_y;
|
|
|
|
double content_width, content_height;
|
2018-06-03 08:35:06 +02:00
|
|
|
};
|
|
|
|
|
2018-03-30 05:41:33 +02:00
|
|
|
struct sway_container {
|
Implement type safe arguments and demote sway_container
This commit changes the meaning of sway_container so that it only refers
to layout containers and view containers. Workspaces, outputs and the
root are no longer known as containers. Instead, root, outputs,
workspaces and containers are all a type of node, and containers come in
two types: layout containers and view containers.
In addition to the above, this implements type safe variables. This
means we use specific types such as sway_output and sway_workspace
instead of generic containers or nodes. However, it's worth noting that
in a few places places (eg. seat focus and transactions) referring to
them in a generic way is unavoidable which is why we still use nodes in
some places.
If you want a TL;DR, look at node.h, as well as the struct definitions
for root, output, workspace and container. Note that sway_output now
contains a workspaces list, and workspaces now contain a tiling and
floating list, and containers now contain a pointer back to the
workspace.
There are now functions for seat_get_focused_workspace and
seat_get_focused_container. The latter will return NULL if a workspace
itself is focused. Most other seat functions like seat_get_focus and
seat_set_focus now accept and return nodes.
In the config->handler_context struct, current_container has been
replaced with three pointers: node, container and workspace. node is the
same as what current_container was, while workspace is the workspace
that the node resides on and container is the actual container, which
may be NULL if a workspace itself is focused.
The global root_container variable has been replaced with one simply
called root, which is a pointer to the sway_root instance.
The way outputs are created, enabled, disabled and destroyed has
changed. Previously we'd wrap the sway_output in a container when it is
enabled, but as we don't have containers any more it needs a different
approach. The output_create and output_destroy functions previously
created/destroyed the container, but now they create/destroy the
sway_output. There is a new function output_disable to disable an output
without destroying it.
Containers have a new view property. If this is populated then the
container is a view container, otherwise it's a layout container. Like
before, this property is immutable for the life of the container.
Containers have both a `sway_container *parent` and
`sway_workspace *workspace`. As we use specific types now, parent cannot
point to a workspace so it'll be NULL for containers which are direct
children of the workspace. The workspace property is set for all
containers, except those which are hidden in the scratchpad as they have
no workspace.
In some cases we need to refer to workspaces in a container-like way.
For example, workspaces have layout and children, but when using
specific types this makes it difficult. Likewise, it's difficult for a
container to get its parent's layout when the parent could be another
container or a workspace. To make it easier, some helper functions have
been created: container_parent_layout and container_get_siblings.
container_remove_child has been renamed to container_detach and
container_replace_child has been renamed to container_replace.
`container_handle_fullscreen_reparent(con, old_parent)` has had the
old_parent removed. We now unfullscreen the workspace when detaching the
container, so this function is simplified and only needs one argument
now.
container_notify_subtree_changed has been renamed to
container_update_representation. This is more descriptive of its
purpose. I also wanted to be able to call it with whatever container was
changed rather than the container's parent, which makes bubbling up to
the workspace easier.
There are now state structs per node thing. ie. sway_output_state,
sway_workspace_state and sway_container_state.
The focus, move and layout commands have been completely refactored to
work with the specific types. I considered making these a separate PR,
but I'd be backporting my changes only to replace them again, and it's
easier just to test everything at once.
2018-08-30 13:00:10 +02:00
|
|
|
struct sway_node node;
|
|
|
|
struct sway_view *view;
|
2018-03-30 05:41:33 +02:00
|
|
|
|
2018-06-06 11:19:30 +02:00
|
|
|
struct sway_container_state current;
|
2021-02-12 23:22:51 +01:00
|
|
|
struct sway_container_state pending;
|
2018-06-03 08:35:06 +02:00
|
|
|
|
Implement type safe arguments and demote sway_container
This commit changes the meaning of sway_container so that it only refers
to layout containers and view containers. Workspaces, outputs and the
root are no longer known as containers. Instead, root, outputs,
workspaces and containers are all a type of node, and containers come in
two types: layout containers and view containers.
In addition to the above, this implements type safe variables. This
means we use specific types such as sway_output and sway_workspace
instead of generic containers or nodes. However, it's worth noting that
in a few places places (eg. seat focus and transactions) referring to
them in a generic way is unavoidable which is why we still use nodes in
some places.
If you want a TL;DR, look at node.h, as well as the struct definitions
for root, output, workspace and container. Note that sway_output now
contains a workspaces list, and workspaces now contain a tiling and
floating list, and containers now contain a pointer back to the
workspace.
There are now functions for seat_get_focused_workspace and
seat_get_focused_container. The latter will return NULL if a workspace
itself is focused. Most other seat functions like seat_get_focus and
seat_set_focus now accept and return nodes.
In the config->handler_context struct, current_container has been
replaced with three pointers: node, container and workspace. node is the
same as what current_container was, while workspace is the workspace
that the node resides on and container is the actual container, which
may be NULL if a workspace itself is focused.
The global root_container variable has been replaced with one simply
called root, which is a pointer to the sway_root instance.
The way outputs are created, enabled, disabled and destroyed has
changed. Previously we'd wrap the sway_output in a container when it is
enabled, but as we don't have containers any more it needs a different
approach. The output_create and output_destroy functions previously
created/destroyed the container, but now they create/destroy the
sway_output. There is a new function output_disable to disable an output
without destroying it.
Containers have a new view property. If this is populated then the
container is a view container, otherwise it's a layout container. Like
before, this property is immutable for the life of the container.
Containers have both a `sway_container *parent` and
`sway_workspace *workspace`. As we use specific types now, parent cannot
point to a workspace so it'll be NULL for containers which are direct
children of the workspace. The workspace property is set for all
containers, except those which are hidden in the scratchpad as they have
no workspace.
In some cases we need to refer to workspaces in a container-like way.
For example, workspaces have layout and children, but when using
specific types this makes it difficult. Likewise, it's difficult for a
container to get its parent's layout when the parent could be another
container or a workspace. To make it easier, some helper functions have
been created: container_parent_layout and container_get_siblings.
container_remove_child has been renamed to container_detach and
container_replace_child has been renamed to container_replace.
`container_handle_fullscreen_reparent(con, old_parent)` has had the
old_parent removed. We now unfullscreen the workspace when detaching the
container, so this function is simplified and only needs one argument
now.
container_notify_subtree_changed has been renamed to
container_update_representation. This is more descriptive of its
purpose. I also wanted to be able to call it with whatever container was
changed rather than the container's parent, which makes bubbling up to
the workspace easier.
There are now state structs per node thing. ie. sway_output_state,
sway_workspace_state and sway_container_state.
The focus, move and layout commands have been completely refactored to
work with the specific types. I considered making these a separate PR,
but I'd be backporting my changes only to replace them again, and it's
easier just to test everything at once.
2018-08-30 13:00:10 +02:00
|
|
|
char *title; // The view's title (unformatted)
|
2018-05-05 04:36:50 +02:00
|
|
|
char *formatted_title; // The title displayed in the title bar
|
2018-03-30 05:41:33 +02:00
|
|
|
|
2018-08-01 17:03:37 +02:00
|
|
|
enum sway_container_layout prev_split_layout;
|
2018-03-30 05:41:33 +02:00
|
|
|
|
2020-11-03 06:16:15 +01:00
|
|
|
// Whether stickiness has been enabled on this container. Use
|
|
|
|
// `container_is_sticky_[or_child]` rather than accessing this field
|
|
|
|
// directly; it'll also check that the container is floating.
|
2018-05-24 14:30:44 +02:00
|
|
|
bool is_sticky;
|
2018-05-04 14:24:25 +02:00
|
|
|
|
2018-04-02 20:35:43 +02:00
|
|
|
// For C_ROOT, this has no meaning
|
2018-05-26 08:26:10 +02:00
|
|
|
// For other types, this is the position in layout coordinates
|
2018-04-30 13:24:13 +02:00
|
|
|
// Includes borders
|
2020-01-15 17:52:33 +01:00
|
|
|
double saved_x, saved_y;
|
|
|
|
double saved_width, saved_height;
|
2018-03-30 05:41:33 +02:00
|
|
|
|
2021-02-12 23:22:51 +01:00
|
|
|
// Used when the view changes to CSD unexpectedly. This will be a non-B_CSD
|
|
|
|
// border which we use to restore when the view returns to SSD.
|
|
|
|
enum sway_container_border saved_border;
|
|
|
|
|
2019-06-28 23:21:20 +02:00
|
|
|
// The share of the space of parent container this container occupies
|
|
|
|
double width_fraction;
|
|
|
|
double height_fraction;
|
|
|
|
|
2019-07-28 12:17:33 +02:00
|
|
|
// The share of space of the parent container that all children occupy
|
|
|
|
// Used for doing the resize calculations
|
|
|
|
double child_total_width;
|
|
|
|
double child_total_height;
|
|
|
|
|
2019-01-28 07:00:34 +01:00
|
|
|
// In most cases this is the same as the content x and y, but if the view
|
|
|
|
// refuses to resize to the content dimensions then it can be smaller.
|
|
|
|
// These are in layout coordinates.
|
2020-01-15 17:52:33 +01:00
|
|
|
double surface_x, surface_y;
|
2019-01-28 07:00:34 +01:00
|
|
|
|
2018-08-19 03:01:51 +02:00
|
|
|
// Outputs currently being intersected
|
|
|
|
list_t *outputs; // struct sway_output
|
|
|
|
|
2018-07-22 06:10:40 +02:00
|
|
|
// Indicates that the container is a scratchpad container.
|
|
|
|
// Both hidden and visible scratchpad containers have scratchpad=true.
|
|
|
|
// Hidden scratchpad containers have a NULL parent.
|
|
|
|
bool scratchpad;
|
|
|
|
|
2022-12-12 01:44:48 +01:00
|
|
|
// Stores last output size and position for adjusting coordinates of
|
|
|
|
// scratchpad windows.
|
|
|
|
// Unused for non-scratchpad windows.
|
|
|
|
struct wlr_box transform;
|
|
|
|
|
2018-04-03 06:47:45 +02:00
|
|
|
float alpha;
|
|
|
|
|
2018-05-02 15:07:52 +02:00
|
|
|
struct wlr_texture *title_focused;
|
|
|
|
struct wlr_texture *title_focused_inactive;
|
2021-12-10 16:09:29 +01:00
|
|
|
struct wlr_texture *title_focused_tab_title;
|
2018-05-02 15:07:52 +02:00
|
|
|
struct wlr_texture *title_unfocused;
|
|
|
|
struct wlr_texture *title_urgent;
|
|
|
|
|
2018-10-31 12:27:38 +01:00
|
|
|
list_t *marks; // char *
|
|
|
|
struct wlr_texture *marks_focused;
|
|
|
|
struct wlr_texture *marks_focused_inactive;
|
2021-12-10 16:09:29 +01:00
|
|
|
struct wlr_texture *marks_focused_tab_title;
|
2018-10-31 12:27:38 +01:00
|
|
|
struct wlr_texture *marks_unfocused;
|
|
|
|
struct wlr_texture *marks_urgent;
|
|
|
|
|
2018-03-30 05:41:33 +02:00
|
|
|
struct {
|
|
|
|
struct wl_signal destroy;
|
|
|
|
} events;
|
|
|
|
};
|
|
|
|
|
Implement type safe arguments and demote sway_container
This commit changes the meaning of sway_container so that it only refers
to layout containers and view containers. Workspaces, outputs and the
root are no longer known as containers. Instead, root, outputs,
workspaces and containers are all a type of node, and containers come in
two types: layout containers and view containers.
In addition to the above, this implements type safe variables. This
means we use specific types such as sway_output and sway_workspace
instead of generic containers or nodes. However, it's worth noting that
in a few places places (eg. seat focus and transactions) referring to
them in a generic way is unavoidable which is why we still use nodes in
some places.
If you want a TL;DR, look at node.h, as well as the struct definitions
for root, output, workspace and container. Note that sway_output now
contains a workspaces list, and workspaces now contain a tiling and
floating list, and containers now contain a pointer back to the
workspace.
There are now functions for seat_get_focused_workspace and
seat_get_focused_container. The latter will return NULL if a workspace
itself is focused. Most other seat functions like seat_get_focus and
seat_set_focus now accept and return nodes.
In the config->handler_context struct, current_container has been
replaced with three pointers: node, container and workspace. node is the
same as what current_container was, while workspace is the workspace
that the node resides on and container is the actual container, which
may be NULL if a workspace itself is focused.
The global root_container variable has been replaced with one simply
called root, which is a pointer to the sway_root instance.
The way outputs are created, enabled, disabled and destroyed has
changed. Previously we'd wrap the sway_output in a container when it is
enabled, but as we don't have containers any more it needs a different
approach. The output_create and output_destroy functions previously
created/destroyed the container, but now they create/destroy the
sway_output. There is a new function output_disable to disable an output
without destroying it.
Containers have a new view property. If this is populated then the
container is a view container, otherwise it's a layout container. Like
before, this property is immutable for the life of the container.
Containers have both a `sway_container *parent` and
`sway_workspace *workspace`. As we use specific types now, parent cannot
point to a workspace so it'll be NULL for containers which are direct
children of the workspace. The workspace property is set for all
containers, except those which are hidden in the scratchpad as they have
no workspace.
In some cases we need to refer to workspaces in a container-like way.
For example, workspaces have layout and children, but when using
specific types this makes it difficult. Likewise, it's difficult for a
container to get its parent's layout when the parent could be another
container or a workspace. To make it easier, some helper functions have
been created: container_parent_layout and container_get_siblings.
container_remove_child has been renamed to container_detach and
container_replace_child has been renamed to container_replace.
`container_handle_fullscreen_reparent(con, old_parent)` has had the
old_parent removed. We now unfullscreen the workspace when detaching the
container, so this function is simplified and only needs one argument
now.
container_notify_subtree_changed has been renamed to
container_update_representation. This is more descriptive of its
purpose. I also wanted to be able to call it with whatever container was
changed rather than the container's parent, which makes bubbling up to
the workspace easier.
There are now state structs per node thing. ie. sway_output_state,
sway_workspace_state and sway_container_state.
The focus, move and layout commands have been completely refactored to
work with the specific types. I considered making these a separate PR,
but I'd be backporting my changes only to replace them again, and it's
easier just to test everything at once.
2018-08-30 13:00:10 +02:00
|
|
|
struct sway_container *container_create(struct sway_view *view);
|
2018-03-30 05:41:33 +02:00
|
|
|
|
2018-08-20 07:54:30 +02:00
|
|
|
void container_destroy(struct sway_container *con);
|
2018-06-23 08:24:11 +02:00
|
|
|
|
2018-08-20 07:54:30 +02:00
|
|
|
void container_begin_destroy(struct sway_container *con);
|
2018-04-03 18:25:19 +02:00
|
|
|
|
2018-03-30 05:41:33 +02:00
|
|
|
/**
|
2018-04-01 02:52:34 +02:00
|
|
|
* Search a container's descendants a container based on test criteria. Returns
|
|
|
|
* the first container that passes the test.
|
2018-03-30 05:41:33 +02:00
|
|
|
*/
|
2018-08-17 11:48:34 +02:00
|
|
|
struct sway_container *container_find_child(struct sway_container *container,
|
2018-03-30 05:41:33 +02:00
|
|
|
bool (*test)(struct sway_container *view, void *data), void *data);
|
|
|
|
|
|
|
|
/**
|
2020-05-16 07:20:13 +02:00
|
|
|
* Find a container at the given coordinates. Returns the surface and
|
2018-04-01 02:52:34 +02:00
|
|
|
* surface-local coordinates of the given layout coordinates if the container
|
|
|
|
* is a view and the view contains a surface at those coordinates.
|
2018-03-30 05:41:33 +02:00
|
|
|
*/
|
Implement type safe arguments and demote sway_container
This commit changes the meaning of sway_container so that it only refers
to layout containers and view containers. Workspaces, outputs and the
root are no longer known as containers. Instead, root, outputs,
workspaces and containers are all a type of node, and containers come in
two types: layout containers and view containers.
In addition to the above, this implements type safe variables. This
means we use specific types such as sway_output and sway_workspace
instead of generic containers or nodes. However, it's worth noting that
in a few places places (eg. seat focus and transactions) referring to
them in a generic way is unavoidable which is why we still use nodes in
some places.
If you want a TL;DR, look at node.h, as well as the struct definitions
for root, output, workspace and container. Note that sway_output now
contains a workspaces list, and workspaces now contain a tiling and
floating list, and containers now contain a pointer back to the
workspace.
There are now functions for seat_get_focused_workspace and
seat_get_focused_container. The latter will return NULL if a workspace
itself is focused. Most other seat functions like seat_get_focus and
seat_set_focus now accept and return nodes.
In the config->handler_context struct, current_container has been
replaced with three pointers: node, container and workspace. node is the
same as what current_container was, while workspace is the workspace
that the node resides on and container is the actual container, which
may be NULL if a workspace itself is focused.
The global root_container variable has been replaced with one simply
called root, which is a pointer to the sway_root instance.
The way outputs are created, enabled, disabled and destroyed has
changed. Previously we'd wrap the sway_output in a container when it is
enabled, but as we don't have containers any more it needs a different
approach. The output_create and output_destroy functions previously
created/destroyed the container, but now they create/destroy the
sway_output. There is a new function output_disable to disable an output
without destroying it.
Containers have a new view property. If this is populated then the
container is a view container, otherwise it's a layout container. Like
before, this property is immutable for the life of the container.
Containers have both a `sway_container *parent` and
`sway_workspace *workspace`. As we use specific types now, parent cannot
point to a workspace so it'll be NULL for containers which are direct
children of the workspace. The workspace property is set for all
containers, except those which are hidden in the scratchpad as they have
no workspace.
In some cases we need to refer to workspaces in a container-like way.
For example, workspaces have layout and children, but when using
specific types this makes it difficult. Likewise, it's difficult for a
container to get its parent's layout when the parent could be another
container or a workspace. To make it easier, some helper functions have
been created: container_parent_layout and container_get_siblings.
container_remove_child has been renamed to container_detach and
container_replace_child has been renamed to container_replace.
`container_handle_fullscreen_reparent(con, old_parent)` has had the
old_parent removed. We now unfullscreen the workspace when detaching the
container, so this function is simplified and only needs one argument
now.
container_notify_subtree_changed has been renamed to
container_update_representation. This is more descriptive of its
purpose. I also wanted to be able to call it with whatever container was
changed rather than the container's parent, which makes bubbling up to
the workspace easier.
There are now state structs per node thing. ie. sway_output_state,
sway_workspace_state and sway_container_state.
The focus, move and layout commands have been completely refactored to
work with the specific types. I considered making these a separate PR,
but I'd be backporting my changes only to replace them again, and it's
easier just to test everything at once.
2018-08-30 13:00:10 +02:00
|
|
|
struct sway_container *container_at(struct sway_workspace *workspace,
|
2018-08-02 15:30:26 +02:00
|
|
|
double lx, double ly, struct wlr_surface **surface,
|
2018-03-30 05:41:33 +02:00
|
|
|
double *sx, double *sy);
|
|
|
|
|
2018-08-03 10:08:20 +02:00
|
|
|
struct sway_container *tiling_container_at(
|
Implement type safe arguments and demote sway_container
This commit changes the meaning of sway_container so that it only refers
to layout containers and view containers. Workspaces, outputs and the
root are no longer known as containers. Instead, root, outputs,
workspaces and containers are all a type of node, and containers come in
two types: layout containers and view containers.
In addition to the above, this implements type safe variables. This
means we use specific types such as sway_output and sway_workspace
instead of generic containers or nodes. However, it's worth noting that
in a few places places (eg. seat focus and transactions) referring to
them in a generic way is unavoidable which is why we still use nodes in
some places.
If you want a TL;DR, look at node.h, as well as the struct definitions
for root, output, workspace and container. Note that sway_output now
contains a workspaces list, and workspaces now contain a tiling and
floating list, and containers now contain a pointer back to the
workspace.
There are now functions for seat_get_focused_workspace and
seat_get_focused_container. The latter will return NULL if a workspace
itself is focused. Most other seat functions like seat_get_focus and
seat_set_focus now accept and return nodes.
In the config->handler_context struct, current_container has been
replaced with three pointers: node, container and workspace. node is the
same as what current_container was, while workspace is the workspace
that the node resides on and container is the actual container, which
may be NULL if a workspace itself is focused.
The global root_container variable has been replaced with one simply
called root, which is a pointer to the sway_root instance.
The way outputs are created, enabled, disabled and destroyed has
changed. Previously we'd wrap the sway_output in a container when it is
enabled, but as we don't have containers any more it needs a different
approach. The output_create and output_destroy functions previously
created/destroyed the container, but now they create/destroy the
sway_output. There is a new function output_disable to disable an output
without destroying it.
Containers have a new view property. If this is populated then the
container is a view container, otherwise it's a layout container. Like
before, this property is immutable for the life of the container.
Containers have both a `sway_container *parent` and
`sway_workspace *workspace`. As we use specific types now, parent cannot
point to a workspace so it'll be NULL for containers which are direct
children of the workspace. The workspace property is set for all
containers, except those which are hidden in the scratchpad as they have
no workspace.
In some cases we need to refer to workspaces in a container-like way.
For example, workspaces have layout and children, but when using
specific types this makes it difficult. Likewise, it's difficult for a
container to get its parent's layout when the parent could be another
container or a workspace. To make it easier, some helper functions have
been created: container_parent_layout and container_get_siblings.
container_remove_child has been renamed to container_detach and
container_replace_child has been renamed to container_replace.
`container_handle_fullscreen_reparent(con, old_parent)` has had the
old_parent removed. We now unfullscreen the workspace when detaching the
container, so this function is simplified and only needs one argument
now.
container_notify_subtree_changed has been renamed to
container_update_representation. This is more descriptive of its
purpose. I also wanted to be able to call it with whatever container was
changed rather than the container's parent, which makes bubbling up to
the workspace easier.
There are now state structs per node thing. ie. sway_output_state,
sway_workspace_state and sway_container_state.
The focus, move and layout commands have been completely refactored to
work with the specific types. I considered making these a separate PR,
but I'd be backporting my changes only to replace them again, and it's
easier just to test everything at once.
2018-08-30 13:00:10 +02:00
|
|
|
struct sway_node *parent, double lx, double ly,
|
2018-08-03 10:08:20 +02:00
|
|
|
struct wlr_surface **surface, double *sx, double *sy);
|
2018-08-02 23:48:43 +02:00
|
|
|
|
2018-08-17 11:48:34 +02:00
|
|
|
void container_for_each_child(struct sway_container *container,
|
2018-03-30 05:41:33 +02:00
|
|
|
void (*f)(struct sway_container *container, void *data), void *data);
|
|
|
|
|
2021-01-20 22:20:00 +01:00
|
|
|
/**
|
|
|
|
* Returns the fullscreen container obstructing this container if it exists.
|
|
|
|
*/
|
|
|
|
struct sway_container *container_obstructing_fullscreen_container(struct sway_container *container);
|
|
|
|
|
2018-04-01 02:52:34 +02:00
|
|
|
/**
|
|
|
|
* Returns true if the given container is an ancestor of this container.
|
|
|
|
*/
|
2018-05-28 04:45:42 +02:00
|
|
|
bool container_has_ancestor(struct sway_container *container,
|
|
|
|
struct sway_container *ancestor);
|
2018-03-30 16:31:21 +02:00
|
|
|
|
2018-07-30 07:59:20 +02:00
|
|
|
void container_update_textures_recursive(struct sway_container *con);
|
|
|
|
|
2018-04-06 00:31:19 +02:00
|
|
|
void container_damage_whole(struct sway_container *container);
|
|
|
|
|
Implement type safe arguments and demote sway_container
This commit changes the meaning of sway_container so that it only refers
to layout containers and view containers. Workspaces, outputs and the
root are no longer known as containers. Instead, root, outputs,
workspaces and containers are all a type of node, and containers come in
two types: layout containers and view containers.
In addition to the above, this implements type safe variables. This
means we use specific types such as sway_output and sway_workspace
instead of generic containers or nodes. However, it's worth noting that
in a few places places (eg. seat focus and transactions) referring to
them in a generic way is unavoidable which is why we still use nodes in
some places.
If you want a TL;DR, look at node.h, as well as the struct definitions
for root, output, workspace and container. Note that sway_output now
contains a workspaces list, and workspaces now contain a tiling and
floating list, and containers now contain a pointer back to the
workspace.
There are now functions for seat_get_focused_workspace and
seat_get_focused_container. The latter will return NULL if a workspace
itself is focused. Most other seat functions like seat_get_focus and
seat_set_focus now accept and return nodes.
In the config->handler_context struct, current_container has been
replaced with three pointers: node, container and workspace. node is the
same as what current_container was, while workspace is the workspace
that the node resides on and container is the actual container, which
may be NULL if a workspace itself is focused.
The global root_container variable has been replaced with one simply
called root, which is a pointer to the sway_root instance.
The way outputs are created, enabled, disabled and destroyed has
changed. Previously we'd wrap the sway_output in a container when it is
enabled, but as we don't have containers any more it needs a different
approach. The output_create and output_destroy functions previously
created/destroyed the container, but now they create/destroy the
sway_output. There is a new function output_disable to disable an output
without destroying it.
Containers have a new view property. If this is populated then the
container is a view container, otherwise it's a layout container. Like
before, this property is immutable for the life of the container.
Containers have both a `sway_container *parent` and
`sway_workspace *workspace`. As we use specific types now, parent cannot
point to a workspace so it'll be NULL for containers which are direct
children of the workspace. The workspace property is set for all
containers, except those which are hidden in the scratchpad as they have
no workspace.
In some cases we need to refer to workspaces in a container-like way.
For example, workspaces have layout and children, but when using
specific types this makes it difficult. Likewise, it's difficult for a
container to get its parent's layout when the parent could be another
container or a workspace. To make it easier, some helper functions have
been created: container_parent_layout and container_get_siblings.
container_remove_child has been renamed to container_detach and
container_replace_child has been renamed to container_replace.
`container_handle_fullscreen_reparent(con, old_parent)` has had the
old_parent removed. We now unfullscreen the workspace when detaching the
container, so this function is simplified and only needs one argument
now.
container_notify_subtree_changed has been renamed to
container_update_representation. This is more descriptive of its
purpose. I also wanted to be able to call it with whatever container was
changed rather than the container's parent, which makes bubbling up to
the workspace easier.
There are now state structs per node thing. ie. sway_output_state,
sway_workspace_state and sway_container_state.
The focus, move and layout commands have been completely refactored to
work with the specific types. I considered making these a separate PR,
but I'd be backporting my changes only to replace them again, and it's
easier just to test everything at once.
2018-08-30 13:00:10 +02:00
|
|
|
void container_reap_empty(struct sway_container *con);
|
2018-04-02 19:49:37 +02:00
|
|
|
|
|
|
|
struct sway_container *container_flatten(struct sway_container *container);
|
|
|
|
|
2018-05-02 15:07:52 +02:00
|
|
|
void container_update_title_textures(struct sway_container *container);
|
|
|
|
|
Implement type safe arguments and demote sway_container
This commit changes the meaning of sway_container so that it only refers
to layout containers and view containers. Workspaces, outputs and the
root are no longer known as containers. Instead, root, outputs,
workspaces and containers are all a type of node, and containers come in
two types: layout containers and view containers.
In addition to the above, this implements type safe variables. This
means we use specific types such as sway_output and sway_workspace
instead of generic containers or nodes. However, it's worth noting that
in a few places places (eg. seat focus and transactions) referring to
them in a generic way is unavoidable which is why we still use nodes in
some places.
If you want a TL;DR, look at node.h, as well as the struct definitions
for root, output, workspace and container. Note that sway_output now
contains a workspaces list, and workspaces now contain a tiling and
floating list, and containers now contain a pointer back to the
workspace.
There are now functions for seat_get_focused_workspace and
seat_get_focused_container. The latter will return NULL if a workspace
itself is focused. Most other seat functions like seat_get_focus and
seat_set_focus now accept and return nodes.
In the config->handler_context struct, current_container has been
replaced with three pointers: node, container and workspace. node is the
same as what current_container was, while workspace is the workspace
that the node resides on and container is the actual container, which
may be NULL if a workspace itself is focused.
The global root_container variable has been replaced with one simply
called root, which is a pointer to the sway_root instance.
The way outputs are created, enabled, disabled and destroyed has
changed. Previously we'd wrap the sway_output in a container when it is
enabled, but as we don't have containers any more it needs a different
approach. The output_create and output_destroy functions previously
created/destroyed the container, but now they create/destroy the
sway_output. There is a new function output_disable to disable an output
without destroying it.
Containers have a new view property. If this is populated then the
container is a view container, otherwise it's a layout container. Like
before, this property is immutable for the life of the container.
Containers have both a `sway_container *parent` and
`sway_workspace *workspace`. As we use specific types now, parent cannot
point to a workspace so it'll be NULL for containers which are direct
children of the workspace. The workspace property is set for all
containers, except those which are hidden in the scratchpad as they have
no workspace.
In some cases we need to refer to workspaces in a container-like way.
For example, workspaces have layout and children, but when using
specific types this makes it difficult. Likewise, it's difficult for a
container to get its parent's layout when the parent could be another
container or a workspace. To make it easier, some helper functions have
been created: container_parent_layout and container_get_siblings.
container_remove_child has been renamed to container_detach and
container_replace_child has been renamed to container_replace.
`container_handle_fullscreen_reparent(con, old_parent)` has had the
old_parent removed. We now unfullscreen the workspace when detaching the
container, so this function is simplified and only needs one argument
now.
container_notify_subtree_changed has been renamed to
container_update_representation. This is more descriptive of its
purpose. I also wanted to be able to call it with whatever container was
changed rather than the container's parent, which makes bubbling up to
the workspace easier.
There are now state structs per node thing. ie. sway_output_state,
sway_workspace_state and sway_container_state.
The focus, move and layout commands have been completely refactored to
work with the specific types. I considered making these a separate PR,
but I'd be backporting my changes only to replace them again, and it's
easier just to test everything at once.
2018-08-30 13:00:10 +02:00
|
|
|
size_t container_build_representation(enum sway_container_layout layout,
|
|
|
|
list_t *children, char *buffer);
|
|
|
|
|
|
|
|
void container_update_representation(struct sway_container *container);
|
2018-05-03 07:02:16 +02:00
|
|
|
|
2018-05-22 00:27:42 +02:00
|
|
|
/**
|
|
|
|
* Return the height of a regular title bar.
|
|
|
|
*/
|
2018-05-22 01:44:34 +02:00
|
|
|
size_t container_titlebar_height(void);
|
2018-05-22 00:27:42 +02:00
|
|
|
|
2019-03-02 08:29:28 +01:00
|
|
|
void floating_calculate_constraints(int *min_width, int *max_width,
|
|
|
|
int *min_height, int *max_height);
|
|
|
|
|
2022-12-12 01:44:48 +01:00
|
|
|
void floating_fix_coordinates(struct sway_container *con,
|
|
|
|
struct wlr_box *old, struct wlr_box *new);
|
|
|
|
|
2019-03-27 19:00:19 +01:00
|
|
|
void container_floating_resize_and_center(struct sway_container *con);
|
2018-07-26 10:36:46 +02:00
|
|
|
|
2019-03-29 17:26:08 +01:00
|
|
|
void container_floating_set_default_size(struct sway_container *con);
|
|
|
|
|
2020-07-07 08:57:48 +02:00
|
|
|
void container_set_resizing(struct sway_container *con, bool resizing);
|
|
|
|
|
2018-05-24 14:30:44 +02:00
|
|
|
void container_set_floating(struct sway_container *container, bool enable);
|
|
|
|
|
Move view {x,y,width,height} into container struct
This renames/moves the following properties:
* sway_view.{x,y,width,height} ->
sway_container.content_{x,y,width,height}
* This is required to support placeholder containers as they don't
have a view.
* sway_container_state.view_{x,y,width,height} ->
sway_container_state.content_{x,y,width,height}
* To remain consistent with the above.
* sway_container_state.con_{x,y,width,height} ->
sway_container_state.{x,y,width,height}
* The con prefix was there to give it contrast from the view
properties, and is no longer useful.
The function container_set_geometry_from_floating_view has also been
renamed to container_set_geometry_from_content.
2018-11-17 09:32:03 +01:00
|
|
|
void container_set_geometry_from_content(struct sway_container *con);
|
2018-05-24 14:30:44 +02:00
|
|
|
|
|
|
|
/**
|
2018-05-25 01:26:23 +02:00
|
|
|
* Determine if the given container is itself floating.
|
|
|
|
* This will return false for any descendants of a floating container.
|
2021-02-22 19:33:08 +01:00
|
|
|
*
|
|
|
|
* Uses pending container state.
|
2018-05-25 01:26:23 +02:00
|
|
|
*/
|
|
|
|
bool container_is_floating(struct sway_container *container);
|
|
|
|
|
2021-02-22 19:33:08 +01:00
|
|
|
/**
|
|
|
|
* Same as above, but for current container state.
|
|
|
|
*/
|
|
|
|
bool container_is_current_floating(struct sway_container *container);
|
|
|
|
|
2018-06-03 08:35:06 +02:00
|
|
|
/**
|
|
|
|
* Get a container's box in layout coordinates.
|
|
|
|
*/
|
2018-06-27 09:47:41 +02:00
|
|
|
void container_get_box(struct sway_container *container, struct wlr_box *box);
|
2018-06-03 08:35:06 +02:00
|
|
|
|
2018-07-18 08:13:28 +02:00
|
|
|
/**
|
|
|
|
* Move a floating container by the specified amount.
|
|
|
|
*/
|
|
|
|
void container_floating_translate(struct sway_container *con,
|
|
|
|
double x_amount, double y_amount);
|
|
|
|
|
2018-08-07 01:30:27 +02:00
|
|
|
/**
|
|
|
|
* Choose an output for the floating container's new position.
|
|
|
|
*/
|
Implement type safe arguments and demote sway_container
This commit changes the meaning of sway_container so that it only refers
to layout containers and view containers. Workspaces, outputs and the
root are no longer known as containers. Instead, root, outputs,
workspaces and containers are all a type of node, and containers come in
two types: layout containers and view containers.
In addition to the above, this implements type safe variables. This
means we use specific types such as sway_output and sway_workspace
instead of generic containers or nodes. However, it's worth noting that
in a few places places (eg. seat focus and transactions) referring to
them in a generic way is unavoidable which is why we still use nodes in
some places.
If you want a TL;DR, look at node.h, as well as the struct definitions
for root, output, workspace and container. Note that sway_output now
contains a workspaces list, and workspaces now contain a tiling and
floating list, and containers now contain a pointer back to the
workspace.
There are now functions for seat_get_focused_workspace and
seat_get_focused_container. The latter will return NULL if a workspace
itself is focused. Most other seat functions like seat_get_focus and
seat_set_focus now accept and return nodes.
In the config->handler_context struct, current_container has been
replaced with three pointers: node, container and workspace. node is the
same as what current_container was, while workspace is the workspace
that the node resides on and container is the actual container, which
may be NULL if a workspace itself is focused.
The global root_container variable has been replaced with one simply
called root, which is a pointer to the sway_root instance.
The way outputs are created, enabled, disabled and destroyed has
changed. Previously we'd wrap the sway_output in a container when it is
enabled, but as we don't have containers any more it needs a different
approach. The output_create and output_destroy functions previously
created/destroyed the container, but now they create/destroy the
sway_output. There is a new function output_disable to disable an output
without destroying it.
Containers have a new view property. If this is populated then the
container is a view container, otherwise it's a layout container. Like
before, this property is immutable for the life of the container.
Containers have both a `sway_container *parent` and
`sway_workspace *workspace`. As we use specific types now, parent cannot
point to a workspace so it'll be NULL for containers which are direct
children of the workspace. The workspace property is set for all
containers, except those which are hidden in the scratchpad as they have
no workspace.
In some cases we need to refer to workspaces in a container-like way.
For example, workspaces have layout and children, but when using
specific types this makes it difficult. Likewise, it's difficult for a
container to get its parent's layout when the parent could be another
container or a workspace. To make it easier, some helper functions have
been created: container_parent_layout and container_get_siblings.
container_remove_child has been renamed to container_detach and
container_replace_child has been renamed to container_replace.
`container_handle_fullscreen_reparent(con, old_parent)` has had the
old_parent removed. We now unfullscreen the workspace when detaching the
container, so this function is simplified and only needs one argument
now.
container_notify_subtree_changed has been renamed to
container_update_representation. This is more descriptive of its
purpose. I also wanted to be able to call it with whatever container was
changed rather than the container's parent, which makes bubbling up to
the workspace easier.
There are now state structs per node thing. ie. sway_output_state,
sway_workspace_state and sway_container_state.
The focus, move and layout commands have been completely refactored to
work with the specific types. I considered making these a separate PR,
but I'd be backporting my changes only to replace them again, and it's
easier just to test everything at once.
2018-08-30 13:00:10 +02:00
|
|
|
struct sway_output *container_floating_find_output(struct sway_container *con);
|
2018-08-07 01:30:27 +02:00
|
|
|
|
2018-07-07 10:36:20 +02:00
|
|
|
/**
|
|
|
|
* Move a floating container to a new layout-local position.
|
|
|
|
*/
|
|
|
|
void container_floating_move_to(struct sway_container *con,
|
|
|
|
double lx, double ly);
|
|
|
|
|
2018-08-04 06:46:27 +02:00
|
|
|
/**
|
|
|
|
* Move a floating container to the center of the workspace.
|
|
|
|
*/
|
|
|
|
void container_floating_move_to_center(struct sway_container *con);
|
|
|
|
|
2018-07-16 06:30:31 +02:00
|
|
|
bool container_has_urgent_child(struct sway_container *container);
|
|
|
|
|
2018-07-18 08:13:28 +02:00
|
|
|
/**
|
|
|
|
* If the container is involved in a drag or resize operation via a mouse, this
|
|
|
|
* ends the operation.
|
|
|
|
*/
|
|
|
|
void container_end_mouse_operation(struct sway_container *container);
|
|
|
|
|
2019-01-24 23:29:21 +01:00
|
|
|
void container_set_fullscreen(struct sway_container *con,
|
|
|
|
enum sway_fullscreen_mode mode);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convenience function.
|
|
|
|
*/
|
|
|
|
void container_fullscreen_disable(struct sway_container *con);
|
2018-07-25 12:56:23 +02:00
|
|
|
|
2020-06-04 20:28:43 +02:00
|
|
|
/**
|
|
|
|
* Walk up the container tree branch starting at the given container, and return
|
|
|
|
* its earliest ancestor.
|
|
|
|
*/
|
|
|
|
struct sway_container *container_toplevel_ancestor(
|
|
|
|
struct sway_container *container);
|
|
|
|
|
2018-07-26 10:36:46 +02:00
|
|
|
/**
|
|
|
|
* Return true if the container is floating, or a child of a floating split
|
|
|
|
* container.
|
|
|
|
*/
|
|
|
|
bool container_is_floating_or_child(struct sway_container *container);
|
|
|
|
|
2018-07-25 12:56:23 +02:00
|
|
|
/**
|
|
|
|
* Return true if the container is fullscreen, or a child of a fullscreen split
|
|
|
|
* container.
|
|
|
|
*/
|
|
|
|
bool container_is_fullscreen_or_child(struct sway_container *container);
|
|
|
|
|
2018-08-20 02:37:52 +02:00
|
|
|
/**
|
|
|
|
* Return the output which will be used for scale purposes.
|
|
|
|
* This is the most recently entered output.
|
2021-02-24 21:15:22 +01:00
|
|
|
* If the container is not on any output, return NULL.
|
2018-08-20 02:37:52 +02:00
|
|
|
*/
|
|
|
|
struct sway_output *container_get_effective_output(struct sway_container *con);
|
|
|
|
|
2018-08-19 03:01:51 +02:00
|
|
|
void container_discover_outputs(struct sway_container *con);
|
|
|
|
|
Implement type safe arguments and demote sway_container
This commit changes the meaning of sway_container so that it only refers
to layout containers and view containers. Workspaces, outputs and the
root are no longer known as containers. Instead, root, outputs,
workspaces and containers are all a type of node, and containers come in
two types: layout containers and view containers.
In addition to the above, this implements type safe variables. This
means we use specific types such as sway_output and sway_workspace
instead of generic containers or nodes. However, it's worth noting that
in a few places places (eg. seat focus and transactions) referring to
them in a generic way is unavoidable which is why we still use nodes in
some places.
If you want a TL;DR, look at node.h, as well as the struct definitions
for root, output, workspace and container. Note that sway_output now
contains a workspaces list, and workspaces now contain a tiling and
floating list, and containers now contain a pointer back to the
workspace.
There are now functions for seat_get_focused_workspace and
seat_get_focused_container. The latter will return NULL if a workspace
itself is focused. Most other seat functions like seat_get_focus and
seat_set_focus now accept and return nodes.
In the config->handler_context struct, current_container has been
replaced with three pointers: node, container and workspace. node is the
same as what current_container was, while workspace is the workspace
that the node resides on and container is the actual container, which
may be NULL if a workspace itself is focused.
The global root_container variable has been replaced with one simply
called root, which is a pointer to the sway_root instance.
The way outputs are created, enabled, disabled and destroyed has
changed. Previously we'd wrap the sway_output in a container when it is
enabled, but as we don't have containers any more it needs a different
approach. The output_create and output_destroy functions previously
created/destroyed the container, but now they create/destroy the
sway_output. There is a new function output_disable to disable an output
without destroying it.
Containers have a new view property. If this is populated then the
container is a view container, otherwise it's a layout container. Like
before, this property is immutable for the life of the container.
Containers have both a `sway_container *parent` and
`sway_workspace *workspace`. As we use specific types now, parent cannot
point to a workspace so it'll be NULL for containers which are direct
children of the workspace. The workspace property is set for all
containers, except those which are hidden in the scratchpad as they have
no workspace.
In some cases we need to refer to workspaces in a container-like way.
For example, workspaces have layout and children, but when using
specific types this makes it difficult. Likewise, it's difficult for a
container to get its parent's layout when the parent could be another
container or a workspace. To make it easier, some helper functions have
been created: container_parent_layout and container_get_siblings.
container_remove_child has been renamed to container_detach and
container_replace_child has been renamed to container_replace.
`container_handle_fullscreen_reparent(con, old_parent)` has had the
old_parent removed. We now unfullscreen the workspace when detaching the
container, so this function is simplified and only needs one argument
now.
container_notify_subtree_changed has been renamed to
container_update_representation. This is more descriptive of its
purpose. I also wanted to be able to call it with whatever container was
changed rather than the container's parent, which makes bubbling up to
the workspace easier.
There are now state structs per node thing. ie. sway_output_state,
sway_workspace_state and sway_container_state.
The focus, move and layout commands have been completely refactored to
work with the specific types. I considered making these a separate PR,
but I'd be backporting my changes only to replace them again, and it's
easier just to test everything at once.
2018-08-30 13:00:10 +02:00
|
|
|
enum sway_container_layout container_parent_layout(struct sway_container *con);
|
|
|
|
|
|
|
|
enum sway_container_layout container_current_parent_layout(
|
|
|
|
struct sway_container *con);
|
|
|
|
|
2019-01-28 10:06:42 +01:00
|
|
|
list_t *container_get_siblings(struct sway_container *container);
|
Implement type safe arguments and demote sway_container
This commit changes the meaning of sway_container so that it only refers
to layout containers and view containers. Workspaces, outputs and the
root are no longer known as containers. Instead, root, outputs,
workspaces and containers are all a type of node, and containers come in
two types: layout containers and view containers.
In addition to the above, this implements type safe variables. This
means we use specific types such as sway_output and sway_workspace
instead of generic containers or nodes. However, it's worth noting that
in a few places places (eg. seat focus and transactions) referring to
them in a generic way is unavoidable which is why we still use nodes in
some places.
If you want a TL;DR, look at node.h, as well as the struct definitions
for root, output, workspace and container. Note that sway_output now
contains a workspaces list, and workspaces now contain a tiling and
floating list, and containers now contain a pointer back to the
workspace.
There are now functions for seat_get_focused_workspace and
seat_get_focused_container. The latter will return NULL if a workspace
itself is focused. Most other seat functions like seat_get_focus and
seat_set_focus now accept and return nodes.
In the config->handler_context struct, current_container has been
replaced with three pointers: node, container and workspace. node is the
same as what current_container was, while workspace is the workspace
that the node resides on and container is the actual container, which
may be NULL if a workspace itself is focused.
The global root_container variable has been replaced with one simply
called root, which is a pointer to the sway_root instance.
The way outputs are created, enabled, disabled and destroyed has
changed. Previously we'd wrap the sway_output in a container when it is
enabled, but as we don't have containers any more it needs a different
approach. The output_create and output_destroy functions previously
created/destroyed the container, but now they create/destroy the
sway_output. There is a new function output_disable to disable an output
without destroying it.
Containers have a new view property. If this is populated then the
container is a view container, otherwise it's a layout container. Like
before, this property is immutable for the life of the container.
Containers have both a `sway_container *parent` and
`sway_workspace *workspace`. As we use specific types now, parent cannot
point to a workspace so it'll be NULL for containers which are direct
children of the workspace. The workspace property is set for all
containers, except those which are hidden in the scratchpad as they have
no workspace.
In some cases we need to refer to workspaces in a container-like way.
For example, workspaces have layout and children, but when using
specific types this makes it difficult. Likewise, it's difficult for a
container to get its parent's layout when the parent could be another
container or a workspace. To make it easier, some helper functions have
been created: container_parent_layout and container_get_siblings.
container_remove_child has been renamed to container_detach and
container_replace_child has been renamed to container_replace.
`container_handle_fullscreen_reparent(con, old_parent)` has had the
old_parent removed. We now unfullscreen the workspace when detaching the
container, so this function is simplified and only needs one argument
now.
container_notify_subtree_changed has been renamed to
container_update_representation. This is more descriptive of its
purpose. I also wanted to be able to call it with whatever container was
changed rather than the container's parent, which makes bubbling up to
the workspace easier.
There are now state structs per node thing. ie. sway_output_state,
sway_workspace_state and sway_container_state.
The focus, move and layout commands have been completely refactored to
work with the specific types. I considered making these a separate PR,
but I'd be backporting my changes only to replace them again, and it's
easier just to test everything at once.
2018-08-30 13:00:10 +02:00
|
|
|
|
2019-01-28 10:06:42 +01:00
|
|
|
int container_sibling_index(struct sway_container *child);
|
2018-08-25 04:09:42 +02:00
|
|
|
|
Implement type safe arguments and demote sway_container
This commit changes the meaning of sway_container so that it only refers
to layout containers and view containers. Workspaces, outputs and the
root are no longer known as containers. Instead, root, outputs,
workspaces and containers are all a type of node, and containers come in
two types: layout containers and view containers.
In addition to the above, this implements type safe variables. This
means we use specific types such as sway_output and sway_workspace
instead of generic containers or nodes. However, it's worth noting that
in a few places places (eg. seat focus and transactions) referring to
them in a generic way is unavoidable which is why we still use nodes in
some places.
If you want a TL;DR, look at node.h, as well as the struct definitions
for root, output, workspace and container. Note that sway_output now
contains a workspaces list, and workspaces now contain a tiling and
floating list, and containers now contain a pointer back to the
workspace.
There are now functions for seat_get_focused_workspace and
seat_get_focused_container. The latter will return NULL if a workspace
itself is focused. Most other seat functions like seat_get_focus and
seat_set_focus now accept and return nodes.
In the config->handler_context struct, current_container has been
replaced with three pointers: node, container and workspace. node is the
same as what current_container was, while workspace is the workspace
that the node resides on and container is the actual container, which
may be NULL if a workspace itself is focused.
The global root_container variable has been replaced with one simply
called root, which is a pointer to the sway_root instance.
The way outputs are created, enabled, disabled and destroyed has
changed. Previously we'd wrap the sway_output in a container when it is
enabled, but as we don't have containers any more it needs a different
approach. The output_create and output_destroy functions previously
created/destroyed the container, but now they create/destroy the
sway_output. There is a new function output_disable to disable an output
without destroying it.
Containers have a new view property. If this is populated then the
container is a view container, otherwise it's a layout container. Like
before, this property is immutable for the life of the container.
Containers have both a `sway_container *parent` and
`sway_workspace *workspace`. As we use specific types now, parent cannot
point to a workspace so it'll be NULL for containers which are direct
children of the workspace. The workspace property is set for all
containers, except those which are hidden in the scratchpad as they have
no workspace.
In some cases we need to refer to workspaces in a container-like way.
For example, workspaces have layout and children, but when using
specific types this makes it difficult. Likewise, it's difficult for a
container to get its parent's layout when the parent could be another
container or a workspace. To make it easier, some helper functions have
been created: container_parent_layout and container_get_siblings.
container_remove_child has been renamed to container_detach and
container_replace_child has been renamed to container_replace.
`container_handle_fullscreen_reparent(con, old_parent)` has had the
old_parent removed. We now unfullscreen the workspace when detaching the
container, so this function is simplified and only needs one argument
now.
container_notify_subtree_changed has been renamed to
container_update_representation. This is more descriptive of its
purpose. I also wanted to be able to call it with whatever container was
changed rather than the container's parent, which makes bubbling up to
the workspace easier.
There are now state structs per node thing. ie. sway_output_state,
sway_workspace_state and sway_container_state.
The focus, move and layout commands have been completely refactored to
work with the specific types. I considered making these a separate PR,
but I'd be backporting my changes only to replace them again, and it's
easier just to test everything at once.
2018-08-30 13:00:10 +02:00
|
|
|
list_t *container_get_current_siblings(struct sway_container *container);
|
|
|
|
|
|
|
|
void container_handle_fullscreen_reparent(struct sway_container *con);
|
2018-08-26 04:05:16 +02:00
|
|
|
|
|
|
|
void container_add_child(struct sway_container *parent,
|
|
|
|
struct sway_container *child);
|
|
|
|
|
|
|
|
void container_insert_child(struct sway_container *parent,
|
|
|
|
struct sway_container *child, int i);
|
|
|
|
|
2018-09-11 13:34:21 +02:00
|
|
|
/**
|
|
|
|
* Side should be 0 to add before, or 1 to add after.
|
|
|
|
*/
|
Implement type safe arguments and demote sway_container
This commit changes the meaning of sway_container so that it only refers
to layout containers and view containers. Workspaces, outputs and the
root are no longer known as containers. Instead, root, outputs,
workspaces and containers are all a type of node, and containers come in
two types: layout containers and view containers.
In addition to the above, this implements type safe variables. This
means we use specific types such as sway_output and sway_workspace
instead of generic containers or nodes. However, it's worth noting that
in a few places places (eg. seat focus and transactions) referring to
them in a generic way is unavoidable which is why we still use nodes in
some places.
If you want a TL;DR, look at node.h, as well as the struct definitions
for root, output, workspace and container. Note that sway_output now
contains a workspaces list, and workspaces now contain a tiling and
floating list, and containers now contain a pointer back to the
workspace.
There are now functions for seat_get_focused_workspace and
seat_get_focused_container. The latter will return NULL if a workspace
itself is focused. Most other seat functions like seat_get_focus and
seat_set_focus now accept and return nodes.
In the config->handler_context struct, current_container has been
replaced with three pointers: node, container and workspace. node is the
same as what current_container was, while workspace is the workspace
that the node resides on and container is the actual container, which
may be NULL if a workspace itself is focused.
The global root_container variable has been replaced with one simply
called root, which is a pointer to the sway_root instance.
The way outputs are created, enabled, disabled and destroyed has
changed. Previously we'd wrap the sway_output in a container when it is
enabled, but as we don't have containers any more it needs a different
approach. The output_create and output_destroy functions previously
created/destroyed the container, but now they create/destroy the
sway_output. There is a new function output_disable to disable an output
without destroying it.
Containers have a new view property. If this is populated then the
container is a view container, otherwise it's a layout container. Like
before, this property is immutable for the life of the container.
Containers have both a `sway_container *parent` and
`sway_workspace *workspace`. As we use specific types now, parent cannot
point to a workspace so it'll be NULL for containers which are direct
children of the workspace. The workspace property is set for all
containers, except those which are hidden in the scratchpad as they have
no workspace.
In some cases we need to refer to workspaces in a container-like way.
For example, workspaces have layout and children, but when using
specific types this makes it difficult. Likewise, it's difficult for a
container to get its parent's layout when the parent could be another
container or a workspace. To make it easier, some helper functions have
been created: container_parent_layout and container_get_siblings.
container_remove_child has been renamed to container_detach and
container_replace_child has been renamed to container_replace.
`container_handle_fullscreen_reparent(con, old_parent)` has had the
old_parent removed. We now unfullscreen the workspace when detaching the
container, so this function is simplified and only needs one argument
now.
container_notify_subtree_changed has been renamed to
container_update_representation. This is more descriptive of its
purpose. I also wanted to be able to call it with whatever container was
changed rather than the container's parent, which makes bubbling up to
the workspace easier.
There are now state structs per node thing. ie. sway_output_state,
sway_workspace_state and sway_container_state.
The focus, move and layout commands have been completely refactored to
work with the specific types. I considered making these a separate PR,
but I'd be backporting my changes only to replace them again, and it's
easier just to test everything at once.
2018-08-30 13:00:10 +02:00
|
|
|
void container_add_sibling(struct sway_container *parent,
|
2018-09-12 00:46:46 +02:00
|
|
|
struct sway_container *child, bool after);
|
2018-08-26 04:05:16 +02:00
|
|
|
|
Implement type safe arguments and demote sway_container
This commit changes the meaning of sway_container so that it only refers
to layout containers and view containers. Workspaces, outputs and the
root are no longer known as containers. Instead, root, outputs,
workspaces and containers are all a type of node, and containers come in
two types: layout containers and view containers.
In addition to the above, this implements type safe variables. This
means we use specific types such as sway_output and sway_workspace
instead of generic containers or nodes. However, it's worth noting that
in a few places places (eg. seat focus and transactions) referring to
them in a generic way is unavoidable which is why we still use nodes in
some places.
If you want a TL;DR, look at node.h, as well as the struct definitions
for root, output, workspace and container. Note that sway_output now
contains a workspaces list, and workspaces now contain a tiling and
floating list, and containers now contain a pointer back to the
workspace.
There are now functions for seat_get_focused_workspace and
seat_get_focused_container. The latter will return NULL if a workspace
itself is focused. Most other seat functions like seat_get_focus and
seat_set_focus now accept and return nodes.
In the config->handler_context struct, current_container has been
replaced with three pointers: node, container and workspace. node is the
same as what current_container was, while workspace is the workspace
that the node resides on and container is the actual container, which
may be NULL if a workspace itself is focused.
The global root_container variable has been replaced with one simply
called root, which is a pointer to the sway_root instance.
The way outputs are created, enabled, disabled and destroyed has
changed. Previously we'd wrap the sway_output in a container when it is
enabled, but as we don't have containers any more it needs a different
approach. The output_create and output_destroy functions previously
created/destroyed the container, but now they create/destroy the
sway_output. There is a new function output_disable to disable an output
without destroying it.
Containers have a new view property. If this is populated then the
container is a view container, otherwise it's a layout container. Like
before, this property is immutable for the life of the container.
Containers have both a `sway_container *parent` and
`sway_workspace *workspace`. As we use specific types now, parent cannot
point to a workspace so it'll be NULL for containers which are direct
children of the workspace. The workspace property is set for all
containers, except those which are hidden in the scratchpad as they have
no workspace.
In some cases we need to refer to workspaces in a container-like way.
For example, workspaces have layout and children, but when using
specific types this makes it difficult. Likewise, it's difficult for a
container to get its parent's layout when the parent could be another
container or a workspace. To make it easier, some helper functions have
been created: container_parent_layout and container_get_siblings.
container_remove_child has been renamed to container_detach and
container_replace_child has been renamed to container_replace.
`container_handle_fullscreen_reparent(con, old_parent)` has had the
old_parent removed. We now unfullscreen the workspace when detaching the
container, so this function is simplified and only needs one argument
now.
container_notify_subtree_changed has been renamed to
container_update_representation. This is more descriptive of its
purpose. I also wanted to be able to call it with whatever container was
changed rather than the container's parent, which makes bubbling up to
the workspace easier.
There are now state structs per node thing. ie. sway_output_state,
sway_workspace_state and sway_container_state.
The focus, move and layout commands have been completely refactored to
work with the specific types. I considered making these a separate PR,
but I'd be backporting my changes only to replace them again, and it's
easier just to test everything at once.
2018-08-30 13:00:10 +02:00
|
|
|
void container_detach(struct sway_container *child);
|
2018-08-26 04:05:16 +02:00
|
|
|
|
Implement type safe arguments and demote sway_container
This commit changes the meaning of sway_container so that it only refers
to layout containers and view containers. Workspaces, outputs and the
root are no longer known as containers. Instead, root, outputs,
workspaces and containers are all a type of node, and containers come in
two types: layout containers and view containers.
In addition to the above, this implements type safe variables. This
means we use specific types such as sway_output and sway_workspace
instead of generic containers or nodes. However, it's worth noting that
in a few places places (eg. seat focus and transactions) referring to
them in a generic way is unavoidable which is why we still use nodes in
some places.
If you want a TL;DR, look at node.h, as well as the struct definitions
for root, output, workspace and container. Note that sway_output now
contains a workspaces list, and workspaces now contain a tiling and
floating list, and containers now contain a pointer back to the
workspace.
There are now functions for seat_get_focused_workspace and
seat_get_focused_container. The latter will return NULL if a workspace
itself is focused. Most other seat functions like seat_get_focus and
seat_set_focus now accept and return nodes.
In the config->handler_context struct, current_container has been
replaced with three pointers: node, container and workspace. node is the
same as what current_container was, while workspace is the workspace
that the node resides on and container is the actual container, which
may be NULL if a workspace itself is focused.
The global root_container variable has been replaced with one simply
called root, which is a pointer to the sway_root instance.
The way outputs are created, enabled, disabled and destroyed has
changed. Previously we'd wrap the sway_output in a container when it is
enabled, but as we don't have containers any more it needs a different
approach. The output_create and output_destroy functions previously
created/destroyed the container, but now they create/destroy the
sway_output. There is a new function output_disable to disable an output
without destroying it.
Containers have a new view property. If this is populated then the
container is a view container, otherwise it's a layout container. Like
before, this property is immutable for the life of the container.
Containers have both a `sway_container *parent` and
`sway_workspace *workspace`. As we use specific types now, parent cannot
point to a workspace so it'll be NULL for containers which are direct
children of the workspace. The workspace property is set for all
containers, except those which are hidden in the scratchpad as they have
no workspace.
In some cases we need to refer to workspaces in a container-like way.
For example, workspaces have layout and children, but when using
specific types this makes it difficult. Likewise, it's difficult for a
container to get its parent's layout when the parent could be another
container or a workspace. To make it easier, some helper functions have
been created: container_parent_layout and container_get_siblings.
container_remove_child has been renamed to container_detach and
container_replace_child has been renamed to container_replace.
`container_handle_fullscreen_reparent(con, old_parent)` has had the
old_parent removed. We now unfullscreen the workspace when detaching the
container, so this function is simplified and only needs one argument
now.
container_notify_subtree_changed has been renamed to
container_update_representation. This is more descriptive of its
purpose. I also wanted to be able to call it with whatever container was
changed rather than the container's parent, which makes bubbling up to
the workspace easier.
There are now state structs per node thing. ie. sway_output_state,
sway_workspace_state and sway_container_state.
The focus, move and layout commands have been completely refactored to
work with the specific types. I considered making these a separate PR,
but I'd be backporting my changes only to replace them again, and it's
easier just to test everything at once.
2018-08-30 13:00:10 +02:00
|
|
|
void container_replace(struct sway_container *container,
|
|
|
|
struct sway_container *replacement);
|
2018-08-26 04:05:16 +02:00
|
|
|
|
2019-07-08 22:29:04 +02:00
|
|
|
void container_swap(struct sway_container *con1, struct sway_container *con2);
|
|
|
|
|
2018-08-26 04:05:16 +02:00
|
|
|
struct sway_container *container_split(struct sway_container *child,
|
|
|
|
enum sway_container_layout layout);
|
|
|
|
|
2018-10-08 15:00:36 +02:00
|
|
|
bool container_is_transient_for(struct sway_container *child,
|
|
|
|
struct sway_container *ancestor);
|
|
|
|
|
2018-10-31 12:27:38 +01:00
|
|
|
/**
|
|
|
|
* Find any container that has the given mark and return it.
|
|
|
|
*/
|
|
|
|
struct sway_container *container_find_mark(char *mark);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Find any container that has the given mark and remove the mark from the
|
|
|
|
* container. Returns true if it matched a container.
|
|
|
|
*/
|
|
|
|
bool container_find_and_unmark(char *mark);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove all marks from the container.
|
|
|
|
*/
|
|
|
|
void container_clear_marks(struct sway_container *container);
|
|
|
|
|
|
|
|
bool container_has_mark(struct sway_container *container, char *mark);
|
|
|
|
|
|
|
|
void container_add_mark(struct sway_container *container, char *mark);
|
|
|
|
|
|
|
|
void container_update_marks_textures(struct sway_container *container);
|
|
|
|
|
2019-01-10 13:04:42 +01:00
|
|
|
void container_raise_floating(struct sway_container *con);
|
|
|
|
|
2019-01-28 10:06:42 +01:00
|
|
|
bool container_is_scratchpad_hidden(struct sway_container *con);
|
|
|
|
|
2020-01-15 01:08:01 +01:00
|
|
|
bool container_is_scratchpad_hidden_or_child(struct sway_container *con);
|
|
|
|
|
2020-11-03 06:16:15 +01:00
|
|
|
bool container_is_sticky(struct sway_container *con);
|
|
|
|
|
|
|
|
bool container_is_sticky_or_child(struct sway_container *con);
|
|
|
|
|
2020-11-02 07:43:07 +01:00
|
|
|
/**
|
|
|
|
* This will destroy pairs of redundant H/V splits
|
|
|
|
* e.g. H[V[H[app app]] app] -> H[app app app]
|
|
|
|
* The middle "V[H[" are eliminated by a call to container_squash
|
2022-02-22 08:13:18 +01:00
|
|
|
* on the V[ con. It's grandchildren are added to its parent.
|
2020-11-02 07:43:07 +01:00
|
|
|
*
|
|
|
|
* This function is roughly equivalent to i3's tree_flatten here:
|
|
|
|
* https://github.com/i3/i3/blob/1f0c628cde40cf87371481041b7197344e0417c6/src/tree.c#L651
|
|
|
|
*
|
|
|
|
* Returns the number of new containers added to the parent
|
|
|
|
*/
|
|
|
|
int container_squash(struct sway_container *con);
|
|
|
|
|
2018-03-30 05:41:33 +02:00
|
|
|
#endif
|