2018-03-30 14:41:33 +11:00
|
|
|
#ifndef _SWAY_CONTAINER_H
|
|
|
|
#define _SWAY_CONTAINER_H
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <sys/types.h>
|
2022-04-28 07:33:23 +10:00
|
|
|
#include <wlr/types/wlr_compositor.h>
|
2018-03-30 14:41:33 +11: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 21:00:10 +10:00
|
|
|
#include "sway/tree/node.h"
|
2018-03-30 14:41:33 +11: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 20:54:57 +10:00
|
|
|
B_CSD,
|
2018-03-30 14:41:33 +11:00
|
|
|
};
|
|
|
|
|
2019-01-25 09:29:21 +11:00
|
|
|
enum sway_fullscreen_mode {
|
|
|
|
FULLSCREEN_NONE,
|
|
|
|
FULLSCREEN_WORKSPACE,
|
|
|
|
FULLSCREEN_GLOBAL,
|
|
|
|
};
|
|
|
|
|
2018-03-30 14:41:33 +11:00
|
|
|
struct sway_root;
|
|
|
|
struct sway_output;
|
2018-04-17 09:31:34 +10:00
|
|
|
struct sway_workspace;
|
2018-03-30 14:41:33 +11:00
|
|
|
struct sway_view;
|
|
|
|
|
2018-08-26 12:05:16 +10:00
|
|
|
enum wlr_direction;
|
|
|
|
|
2018-06-03 16:35:06 +10: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 21:00:10 +10:00
|
|
|
// Container properties
|
2018-06-03 16:35:06 +10:00
|
|
|
enum sway_container_layout layout;
|
2020-01-16 03:52:33 +11:00
|
|
|
double x, y;
|
|
|
|
double width, height;
|
2018-06-03 16:35:06 +10:00
|
|
|
|
2019-01-25 09:29:21 +11:00
|
|
|
enum sway_fullscreen_mode fullscreen_mode;
|
2018-07-25 20:56:23 +10:00
|
|
|
|
2021-02-13 09:22:51 +11: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 16:35:06 +10:00
|
|
|
|
2018-07-15 15:20:21 +10:00
|
|
|
struct sway_container *focused_inactive_child;
|
|
|
|
bool focused;
|
|
|
|
|
2018-06-03 16:35:06 +10:00
|
|
|
enum sway_container_border border;
|
|
|
|
int border_thickness;
|
|
|
|
bool border_top;
|
|
|
|
bool border_bottom;
|
|
|
|
bool border_left;
|
|
|
|
bool border_right;
|
2018-10-31 21:28:36 +11:00
|
|
|
|
2021-02-13 09:22:51 +11:00
|
|
|
// These are in layout coordinates.
|
2020-01-16 03:52:33 +11:00
|
|
|
double content_x, content_y;
|
|
|
|
double content_width, content_height;
|
2018-06-03 16:35:06 +10:00
|
|
|
};
|
|
|
|
|
2018-03-30 14:41:33 +11: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 21:00:10 +10:00
|
|
|
struct sway_node node;
|
|
|
|
struct sway_view *view;
|
2018-03-30 14:41:33 +11:00
|
|
|
|
2018-06-06 19:19:30 +10:00
|
|
|
struct sway_container_state current;
|
2021-02-13 09:22:51 +11:00
|
|
|
struct sway_container_state pending;
|
2018-06-03 16:35:06 +10: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 21:00:10 +10:00
|
|
|
char *title; // The view's title (unformatted)
|
2018-05-05 12:36:50 +10:00
|
|
|
char *formatted_title; // The title displayed in the title bar
|
2018-03-30 14:41:33 +11:00
|
|
|
|
2018-08-02 01:03:37 +10:00
|
|
|
enum sway_container_layout prev_split_layout;
|
2018-03-30 14:41:33 +11:00
|
|
|
|
2020-11-03 16:16:15 +11: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 22:30:44 +10:00
|
|
|
bool is_sticky;
|
2018-05-04 22:24:25 +10:00
|
|
|
|
2018-04-03 04:35:43 +10:00
|
|
|
// For C_ROOT, this has no meaning
|
2018-05-26 16:26:10 +10:00
|
|
|
// For other types, this is the position in layout coordinates
|
2018-04-30 21:24:13 +10:00
|
|
|
// Includes borders
|
2020-01-16 03:52:33 +11:00
|
|
|
double saved_x, saved_y;
|
|
|
|
double saved_width, saved_height;
|
2018-03-30 14:41:33 +11:00
|
|
|
|
2021-02-13 09:22:51 +11: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-29 07:21:20 +10:00
|
|
|
// The share of the space of parent container this container occupies
|
|
|
|
double width_fraction;
|
|
|
|
double height_fraction;
|
|
|
|
|
2019-07-28 20:17:33 +10: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 17:00:34 +11: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-16 03:52:33 +11:00
|
|
|
double surface_x, surface_y;
|
2019-01-28 17:00:34 +11:00
|
|
|
|
2018-08-19 11:01:51 +10:00
|
|
|
// Outputs currently being intersected
|
|
|
|
list_t *outputs; // struct sway_output
|
|
|
|
|
2018-07-22 14:10:40 +10: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;
|
|
|
|
|
2018-04-03 14:47:45 +10:00
|
|
|
float alpha;
|
|
|
|
|
2018-05-02 23:07:52 +10:00
|
|
|
struct wlr_texture *title_focused;
|
|
|
|
struct wlr_texture *title_focused_inactive;
|
2021-12-11 02:09:29 +11:00
|
|
|
struct wlr_texture *title_focused_tab_title;
|
2018-05-02 23:07:52 +10:00
|
|
|
struct wlr_texture *title_unfocused;
|
|
|
|
struct wlr_texture *title_urgent;
|
|
|
|
|
2018-10-31 22:27:38 +11:00
|
|
|
list_t *marks; // char *
|
|
|
|
struct wlr_texture *marks_focused;
|
|
|
|
struct wlr_texture *marks_focused_inactive;
|
2021-12-11 02:09:29 +11:00
|
|
|
struct wlr_texture *marks_focused_tab_title;
|
2018-10-31 22:27:38 +11:00
|
|
|
struct wlr_texture *marks_unfocused;
|
|
|
|
struct wlr_texture *marks_urgent;
|
|
|
|
|
2018-03-30 14:41:33 +11: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 21:00:10 +10:00
|
|
|
struct sway_container *container_create(struct sway_view *view);
|
2018-03-30 14:41:33 +11:00
|
|
|
|
2018-08-20 15:54:30 +10:00
|
|
|
void container_destroy(struct sway_container *con);
|
2018-06-23 16:24:11 +10:00
|
|
|
|
2018-08-20 15:54:30 +10:00
|
|
|
void container_begin_destroy(struct sway_container *con);
|
2018-04-04 02:25:19 +10:00
|
|
|
|
2018-03-30 14:41:33 +11:00
|
|
|
/**
|
2018-04-01 10:52:34 +10:00
|
|
|
* Search a container's descendants a container based on test criteria. Returns
|
|
|
|
* the first container that passes the test.
|
2018-03-30 14:41:33 +11:00
|
|
|
*/
|
2018-08-17 19:48:34 +10:00
|
|
|
struct sway_container *container_find_child(struct sway_container *container,
|
2018-03-30 14:41:33 +11:00
|
|
|
bool (*test)(struct sway_container *view, void *data), void *data);
|
|
|
|
|
|
|
|
/**
|
2020-05-16 15:20:13 +10:00
|
|
|
* Find a container at the given coordinates. Returns the surface and
|
2018-04-01 10:52:34 +10: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 14:41:33 +11: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 21:00:10 +10:00
|
|
|
struct sway_container *container_at(struct sway_workspace *workspace,
|
2018-08-02 23:30:26 +10:00
|
|
|
double lx, double ly, struct wlr_surface **surface,
|
2018-03-30 14:41:33 +11:00
|
|
|
double *sx, double *sy);
|
|
|
|
|
2018-08-03 18:08:20 +10: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 21:00:10 +10:00
|
|
|
struct sway_node *parent, double lx, double ly,
|
2018-08-03 18:08:20 +10:00
|
|
|
struct wlr_surface **surface, double *sx, double *sy);
|
2018-08-03 07:48:43 +10:00
|
|
|
|
2018-08-17 19:48:34 +10:00
|
|
|
void container_for_each_child(struct sway_container *container,
|
2018-03-30 14:41:33 +11:00
|
|
|
void (*f)(struct sway_container *container, void *data), void *data);
|
|
|
|
|
2021-01-21 08:20:00 +11: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 10:52:34 +10:00
|
|
|
/**
|
|
|
|
* Returns true if the given container is an ancestor of this container.
|
|
|
|
*/
|
2018-05-28 12:45:42 +10:00
|
|
|
bool container_has_ancestor(struct sway_container *container,
|
|
|
|
struct sway_container *ancestor);
|
2018-03-31 01:31:21 +11:00
|
|
|
|
2018-07-30 15:59:20 +10:00
|
|
|
void container_update_textures_recursive(struct sway_container *con);
|
|
|
|
|
2018-04-06 08:31:19 +10: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 21:00:10 +10:00
|
|
|
void container_reap_empty(struct sway_container *con);
|
2018-04-03 03:49:37 +10:00
|
|
|
|
|
|
|
struct sway_container *container_flatten(struct sway_container *container);
|
|
|
|
|
2018-05-02 23:07:52 +10: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 21:00:10 +10: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 15:02:16 +10:00
|
|
|
|
2018-05-22 08:27:42 +10:00
|
|
|
/**
|
|
|
|
* Return the height of a regular title bar.
|
|
|
|
*/
|
2018-05-22 09:44:34 +10:00
|
|
|
size_t container_titlebar_height(void);
|
2018-05-22 08:27:42 +10:00
|
|
|
|
2019-03-02 18:29:28 +11:00
|
|
|
void floating_calculate_constraints(int *min_width, int *max_width,
|
|
|
|
int *min_height, int *max_height);
|
|
|
|
|
2019-03-28 05:00:19 +11:00
|
|
|
void container_floating_resize_and_center(struct sway_container *con);
|
2018-07-26 18:36:46 +10:00
|
|
|
|
2019-03-30 03:26:08 +11:00
|
|
|
void container_floating_set_default_size(struct sway_container *con);
|
|
|
|
|
2020-07-07 16:57:48 +10:00
|
|
|
void container_set_resizing(struct sway_container *con, bool resizing);
|
|
|
|
|
2018-05-24 22:30:44 +10: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 19:32:03 +11:00
|
|
|
void container_set_geometry_from_content(struct sway_container *con);
|
2018-05-24 22:30:44 +10:00
|
|
|
|
|
|
|
/**
|
2018-05-25 09:26:23 +10:00
|
|
|
* Determine if the given container is itself floating.
|
|
|
|
* This will return false for any descendants of a floating container.
|
2021-02-23 05:33:08 +11:00
|
|
|
*
|
|
|
|
* Uses pending container state.
|
2018-05-25 09:26:23 +10:00
|
|
|
*/
|
|
|
|
bool container_is_floating(struct sway_container *container);
|
|
|
|
|
2021-02-23 05:33:08 +11:00
|
|
|
/**
|
|
|
|
* Same as above, but for current container state.
|
|
|
|
*/
|
|
|
|
bool container_is_current_floating(struct sway_container *container);
|
|
|
|
|
2018-06-03 16:35:06 +10:00
|
|
|
/**
|
|
|
|
* Get a container's box in layout coordinates.
|
|
|
|
*/
|
2018-06-27 17:47:41 +10:00
|
|
|
void container_get_box(struct sway_container *container, struct wlr_box *box);
|
2018-06-03 16:35:06 +10:00
|
|
|
|
2018-07-18 16:13:28 +10: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 09:30:27 +10: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 21:00:10 +10:00
|
|
|
struct sway_output *container_floating_find_output(struct sway_container *con);
|
2018-08-07 09:30:27 +10:00
|
|
|
|
2018-07-07 18:36:20 +10: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 14:46:27 +10:00
|
|
|
/**
|
|
|
|
* Move a floating container to the center of the workspace.
|
|
|
|
*/
|
|
|
|
void container_floating_move_to_center(struct sway_container *con);
|
|
|
|
|
2018-07-16 14:30:31 +10:00
|
|
|
bool container_has_urgent_child(struct sway_container *container);
|
|
|
|
|
2018-07-18 16:13:28 +10: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-25 09:29:21 +11: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 20:56:23 +10:00
|
|
|
|
2020-06-05 04:28:43 +10: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 18:36:46 +10: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 20:56:23 +10: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 10:37:52 +10:00
|
|
|
/**
|
|
|
|
* Return the output which will be used for scale purposes.
|
|
|
|
* This is the most recently entered output.
|
2021-02-25 07:15:22 +11:00
|
|
|
* If the container is not on any output, return NULL.
|
2018-08-20 10:37:52 +10:00
|
|
|
*/
|
|
|
|
struct sway_output *container_get_effective_output(struct sway_container *con);
|
|
|
|
|
2018-08-19 11:01:51 +10: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 21:00:10 +10: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 20:06:42 +11: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 21:00:10 +10:00
|
|
|
|
2019-01-28 20:06:42 +11:00
|
|
|
int container_sibling_index(struct sway_container *child);
|
2018-08-25 12:09:42 +10: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 21:00:10 +10:00
|
|
|
list_t *container_get_current_siblings(struct sway_container *container);
|
|
|
|
|
|
|
|
void container_handle_fullscreen_reparent(struct sway_container *con);
|
2018-08-26 12:05:16 +10: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 21:34:21 +10: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 21:00:10 +10:00
|
|
|
void container_add_sibling(struct sway_container *parent,
|
2018-09-12 08:46:46 +10:00
|
|
|
struct sway_container *child, bool after);
|
2018-08-26 12:05:16 +10: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 21:00:10 +10:00
|
|
|
void container_detach(struct sway_container *child);
|
2018-08-26 12:05:16 +10: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 21:00:10 +10:00
|
|
|
void container_replace(struct sway_container *container,
|
|
|
|
struct sway_container *replacement);
|
2018-08-26 12:05:16 +10:00
|
|
|
|
2019-07-09 06:29:04 +10:00
|
|
|
void container_swap(struct sway_container *con1, struct sway_container *con2);
|
|
|
|
|
2018-08-26 12:05:16 +10:00
|
|
|
struct sway_container *container_split(struct sway_container *child,
|
|
|
|
enum sway_container_layout layout);
|
|
|
|
|
2018-10-09 00:00:36 +11:00
|
|
|
bool container_is_transient_for(struct sway_container *child,
|
|
|
|
struct sway_container *ancestor);
|
|
|
|
|
2018-10-31 22:27:38 +11: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 23:04:42 +11:00
|
|
|
void container_raise_floating(struct sway_container *con);
|
|
|
|
|
2019-01-28 20:06:42 +11:00
|
|
|
bool container_is_scratchpad_hidden(struct sway_container *con);
|
|
|
|
|
2020-01-15 11:08:01 +11:00
|
|
|
bool container_is_scratchpad_hidden_or_child(struct sway_container *con);
|
|
|
|
|
2020-11-03 16:16:15 +11:00
|
|
|
bool container_is_sticky(struct sway_container *con);
|
|
|
|
|
|
|
|
bool container_is_sticky_or_child(struct sway_container *con);
|
|
|
|
|
2020-11-02 17:43:07 +11: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-04-28 07:33:23 +10:00
|
|
|
* on the V[ con. It's grandchildren are added to its parent.
|
2020-11-02 17:43:07 +11: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 14:41:33 +11:00
|
|
|
#endif
|