2017-11-12 10:06:50 +11:00
|
|
|
#ifndef _SWAY_VIEW_H
|
|
|
|
#define _SWAY_VIEW_H
|
2019-07-28 06:02:56 +10:00
|
|
|
#include <wayland-server-core.h>
|
2022-04-28 07:33:23 +10:00
|
|
|
#include <wlr/types/wlr_compositor.h>
|
2018-07-25 21:32:20 +10:00
|
|
|
#include "config.h"
|
2018-11-18 10:33:06 +11:00
|
|
|
#if HAVE_XWAYLAND
|
2017-12-04 22:19:36 +11:00
|
|
|
#include <wlr/xwayland.h>
|
2018-07-25 06:16:06 +10:00
|
|
|
#endif
|
2018-04-01 07:49:40 +10:00
|
|
|
#include "sway/input/input-manager.h"
|
|
|
|
#include "sway/input/seat.h"
|
2017-11-12 10:06:50 +11:00
|
|
|
|
|
|
|
struct sway_container;
|
2018-09-24 20:54:57 +10:00
|
|
|
struct sway_xdg_decoration;
|
2017-11-12 10:06:50 +11:00
|
|
|
|
2018-04-06 01:38:14 +10:00
|
|
|
enum sway_view_type {
|
2018-05-14 01:38:56 +10:00
|
|
|
SWAY_VIEW_XDG_SHELL,
|
2018-11-18 10:33:06 +11:00
|
|
|
#if HAVE_XWAYLAND
|
2018-04-06 01:38:14 +10:00
|
|
|
SWAY_VIEW_XWAYLAND,
|
2018-07-25 07:37:41 +10:00
|
|
|
#endif
|
2018-04-06 01:38:14 +10:00
|
|
|
};
|
|
|
|
|
|
|
|
enum sway_view_prop {
|
|
|
|
VIEW_PROP_TITLE,
|
|
|
|
VIEW_PROP_APP_ID,
|
|
|
|
VIEW_PROP_CLASS,
|
|
|
|
VIEW_PROP_INSTANCE,
|
2018-05-13 08:16:36 +10:00
|
|
|
VIEW_PROP_WINDOW_TYPE,
|
|
|
|
VIEW_PROP_WINDOW_ROLE,
|
2018-11-18 10:33:06 +11:00
|
|
|
#if HAVE_XWAYLAND
|
2018-05-13 08:16:36 +10:00
|
|
|
VIEW_PROP_X11_WINDOW_ID,
|
2018-10-23 06:17:27 +11:00
|
|
|
VIEW_PROP_X11_PARENT_ID,
|
2018-07-25 07:37:41 +10:00
|
|
|
#endif
|
2018-04-06 01:38:14 +10:00
|
|
|
};
|
|
|
|
|
|
|
|
struct sway_view_impl {
|
2018-07-21 12:13:00 +10:00
|
|
|
void (*get_constraints)(struct sway_view *view, double *min_width,
|
|
|
|
double *max_width, double *min_height, double *max_height);
|
2018-05-13 08:16:36 +10:00
|
|
|
const char *(*get_string_prop)(struct sway_view *view,
|
2018-04-06 01:38:14 +10:00
|
|
|
enum sway_view_prop prop);
|
2018-05-13 08:16:36 +10:00
|
|
|
uint32_t (*get_int_prop)(struct sway_view *view, enum sway_view_prop prop);
|
2018-06-03 16:35:06 +10:00
|
|
|
uint32_t (*configure)(struct sway_view *view, double lx, double ly,
|
|
|
|
int width, int height);
|
2018-04-06 01:38:14 +10:00
|
|
|
void (*set_activated)(struct sway_view *view, bool activated);
|
2018-06-28 02:53:13 +10:00
|
|
|
void (*set_tiled)(struct sway_view *view, bool tiled);
|
2018-04-16 20:36:40 +10:00
|
|
|
void (*set_fullscreen)(struct sway_view *view, bool fullscreen);
|
2020-07-07 16:57:48 +10:00
|
|
|
void (*set_resizing)(struct sway_view *view, bool resizing);
|
2018-05-24 22:30:44 +10:00
|
|
|
bool (*wants_floating)(struct sway_view *view);
|
2018-04-07 00:26:32 +10:00
|
|
|
void (*for_each_surface)(struct sway_view *view,
|
|
|
|
wlr_surface_iterator_func_t iterator, void *user_data);
|
2021-01-08 20:46:12 +11:00
|
|
|
void (*for_each_popup_surface)(struct sway_view *view,
|
2018-08-02 23:30:26 +10:00
|
|
|
wlr_surface_iterator_func_t iterator, void *user_data);
|
2018-10-07 21:40:05 +11:00
|
|
|
bool (*is_transient_for)(struct sway_view *child,
|
|
|
|
struct sway_view *ancestor);
|
2018-04-06 01:38:14 +10:00
|
|
|
void (*close)(struct sway_view *view);
|
2018-07-31 19:58:34 +10:00
|
|
|
void (*close_popups)(struct sway_view *view);
|
2018-06-26 13:18:33 +10:00
|
|
|
void (*destroy)(struct sway_view *view);
|
2018-04-06 01:38:14 +10:00
|
|
|
};
|
|
|
|
|
2020-05-31 09:37:43 +10:00
|
|
|
struct sway_saved_buffer {
|
|
|
|
struct wlr_client_buffer *buffer;
|
|
|
|
int x, y;
|
|
|
|
int width, height;
|
2020-06-05 22:13:18 +10:00
|
|
|
enum wl_output_transform transform;
|
2020-04-28 00:41:54 +10:00
|
|
|
struct wlr_fbox source_box;
|
2020-05-31 09:37:43 +10:00
|
|
|
struct wl_list link; // sway_view::saved_buffers
|
|
|
|
};
|
|
|
|
|
2018-04-06 01:38:14 +10:00
|
|
|
struct sway_view {
|
|
|
|
enum sway_view_type type;
|
|
|
|
const struct sway_view_impl *impl;
|
|
|
|
|
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; // NULL if unmapped and transactions finished
|
2018-04-06 01:38:14 +10:00
|
|
|
struct wlr_surface *surface; // NULL for unmapped views
|
2018-09-24 20:54:57 +10:00
|
|
|
struct sway_xdg_decoration *xdg_decoration;
|
2018-04-30 21:24:13 +10:00
|
|
|
|
2018-09-20 07:21:09 +10:00
|
|
|
pid_t pid;
|
|
|
|
|
2018-05-24 22:30:44 +10:00
|
|
|
// The size the view would want to be if it weren't tiled.
|
|
|
|
// Used when changing a view from tiled to floating.
|
|
|
|
int natural_width, natural_height;
|
|
|
|
|
2018-05-05 12:36:50 +10:00
|
|
|
char *title_format;
|
2018-09-27 22:44:57 +10:00
|
|
|
|
|
|
|
bool using_csd;
|
|
|
|
|
2018-07-15 22:43:33 +10:00
|
|
|
struct timespec urgent;
|
|
|
|
bool allow_request_urgent;
|
|
|
|
struct wl_event_source *urgent_timer;
|
|
|
|
|
2020-05-31 09:37:43 +10:00
|
|
|
struct wl_list saved_buffers; // sway_saved_buffer::link
|
2018-08-18 15:10:06 +10:00
|
|
|
|
|
|
|
// The geometry for whatever the client is committing, regardless of
|
|
|
|
// transaction state. Updated on every commit.
|
|
|
|
struct wlr_box geometry;
|
|
|
|
|
|
|
|
// The "old" geometry during a transaction. Used to damage the old location
|
|
|
|
// when a transaction is applied.
|
|
|
|
struct wlr_box saved_geometry;
|
Correctly track saved surfaces during multiple transactions
Fixes #2364.
Suppose a view is 600px wide, and we tell it to resize to 601px during a
resize operation. We create a transaction, save the 600px buffer and
send the configure. This buffer is saved into the associated
instruction, and is rendered while we wait for the view to commit a
601px buffer.
Before the view commits the 601px buffer, suppose we tell it to resize
to 602px. The new transaction will also save the buffer, but it's still
the 600px buffer because we haven't received a new one yet.
Then suppose the view commits its original 601px buffer. This completes
the first transaction, so we apply the 601px width to the container.
There's still the second (now only) transaction remaining, so we render
the saved buffer from that. But this is still the 600px buffer, and we
believe it's 601px. Whoops.
The problem here is we can't stack buffers like this. So this commit
removes the saved buffer from the instructions, places it in the view
instead, and re-saves the latest buffer every time the view completes a
transaction and still has further pending transactions.
As saved buffers are now specific to views rather than instructions, the
functions for saving and removing the saved buffer have been moved to
view.c.
The calls to save and restore the buffer have been relocated to more
appropriate functions too, favouring transaction_commit and
transaction_apply rather than transaction_add_container and
transaction_destroy.
2018-08-01 16:23:11 +10:00
|
|
|
|
2019-08-20 19:30:09 +10:00
|
|
|
struct wlr_foreign_toplevel_handle_v1 *foreign_toplevel;
|
|
|
|
struct wl_listener foreign_activate_request;
|
2020-07-31 09:31:52 +10:00
|
|
|
struct wl_listener foreign_fullscreen_request;
|
2019-08-20 19:30:09 +10:00
|
|
|
struct wl_listener foreign_close_request;
|
2020-08-04 05:22:03 +10:00
|
|
|
struct wl_listener foreign_destroy;
|
2021-10-18 12:56:25 +11:00
|
|
|
struct wl_listener foreign_minimize;
|
2019-08-20 19:30:09 +10:00
|
|
|
|
2018-06-23 16:24:11 +10:00
|
|
|
bool destroying;
|
|
|
|
|
2018-05-14 22:47:10 +10:00
|
|
|
list_t *executed_criteria; // struct criteria *
|
2018-05-15 13:14:18 +10:00
|
|
|
|
2018-04-06 01:38:14 +10:00
|
|
|
union {
|
2022-04-28 07:33:23 +10:00
|
|
|
struct wlr_xdg_toplevel *wlr_xdg_toplevel;
|
2018-11-18 10:33:06 +11:00
|
|
|
#if HAVE_XWAYLAND
|
2018-04-06 01:38:14 +10:00
|
|
|
struct wlr_xwayland_surface *wlr_xwayland_surface;
|
2018-07-25 07:37:41 +10:00
|
|
|
#endif
|
2018-04-06 01:38:14 +10:00
|
|
|
};
|
2018-04-06 04:46:02 +10:00
|
|
|
|
|
|
|
struct {
|
|
|
|
struct wl_signal unmap;
|
|
|
|
} events;
|
|
|
|
|
|
|
|
struct wl_listener surface_new_subsurface;
|
2019-09-26 00:35:41 +10:00
|
|
|
|
|
|
|
int max_render_time; // In milliseconds
|
2020-03-13 08:10:04 +11:00
|
|
|
|
|
|
|
enum seat_config_shortcuts_inhibit shortcuts_inhibit;
|
2018-04-06 01:38:14 +10:00
|
|
|
};
|
|
|
|
|
2018-05-14 01:38:56 +10:00
|
|
|
struct sway_xdg_shell_view {
|
|
|
|
struct sway_view view;
|
|
|
|
|
|
|
|
struct wl_listener commit;
|
|
|
|
struct wl_listener request_move;
|
|
|
|
struct wl_listener request_resize;
|
|
|
|
struct wl_listener request_fullscreen;
|
2018-07-23 07:20:07 +10:00
|
|
|
struct wl_listener set_title;
|
|
|
|
struct wl_listener set_app_id;
|
2018-05-14 01:38:56 +10:00
|
|
|
struct wl_listener new_popup;
|
|
|
|
struct wl_listener map;
|
|
|
|
struct wl_listener unmap;
|
|
|
|
struct wl_listener destroy;
|
|
|
|
};
|
2018-11-18 10:33:06 +11:00
|
|
|
#if HAVE_XWAYLAND
|
2018-04-06 01:38:14 +10:00
|
|
|
struct sway_xwayland_view {
|
|
|
|
struct sway_view view;
|
2017-12-04 22:19:36 +11:00
|
|
|
|
|
|
|
struct wl_listener commit;
|
|
|
|
struct wl_listener request_move;
|
|
|
|
struct wl_listener request_resize;
|
|
|
|
struct wl_listener request_maximize;
|
2020-07-19 05:26:15 +10:00
|
|
|
struct wl_listener request_minimize;
|
2017-12-04 22:19:36 +11:00
|
|
|
struct wl_listener request_configure;
|
2018-04-16 20:36:40 +10:00
|
|
|
struct wl_listener request_fullscreen;
|
2018-09-02 15:03:58 +10:00
|
|
|
struct wl_listener request_activate;
|
2018-05-13 08:16:36 +10:00
|
|
|
struct wl_listener set_title;
|
|
|
|
struct wl_listener set_class;
|
2018-09-02 20:06:25 +10:00
|
|
|
struct wl_listener set_role;
|
2018-05-13 08:16:36 +10:00
|
|
|
struct wl_listener set_window_type;
|
2018-07-19 21:08:51 +10:00
|
|
|
struct wl_listener set_hints;
|
2018-09-24 20:54:57 +10:00
|
|
|
struct wl_listener set_decorations;
|
2018-03-31 04:34:25 +11:00
|
|
|
struct wl_listener map;
|
2018-03-31 08:43:43 +11:00
|
|
|
struct wl_listener unmap;
|
2017-12-04 22:19:36 +11:00
|
|
|
struct wl_listener destroy;
|
2020-08-30 01:14:55 +10:00
|
|
|
struct wl_listener override_redirect;
|
2017-12-04 22:19:36 +11:00
|
|
|
};
|
|
|
|
|
2018-04-03 04:35:43 +10:00
|
|
|
struct sway_xwayland_unmanaged {
|
|
|
|
struct wlr_xwayland_surface *wlr_xwayland_surface;
|
|
|
|
struct wl_list link;
|
|
|
|
|
2018-04-06 08:48:35 +10:00
|
|
|
int lx, ly;
|
|
|
|
|
2022-04-28 07:33:23 +10:00
|
|
|
struct wl_listener request_activate;
|
2018-04-06 07:22:39 +10:00
|
|
|
struct wl_listener request_configure;
|
2018-04-16 20:36:40 +10:00
|
|
|
struct wl_listener request_fullscreen;
|
2018-04-06 07:08:30 +10:00
|
|
|
struct wl_listener commit;
|
2020-10-18 15:07:41 +11:00
|
|
|
struct wl_listener set_geometry;
|
2018-04-06 07:08:30 +10:00
|
|
|
struct wl_listener map;
|
|
|
|
struct wl_listener unmap;
|
2018-04-03 04:35:43 +10:00
|
|
|
struct wl_listener destroy;
|
2020-08-30 01:14:55 +10:00
|
|
|
struct wl_listener override_redirect;
|
2018-04-03 04:35:43 +10:00
|
|
|
};
|
2018-07-25 06:16:06 +10:00
|
|
|
#endif
|
2018-04-06 04:46:02 +10:00
|
|
|
struct sway_view_child;
|
|
|
|
|
|
|
|
struct sway_view_child_impl {
|
2021-09-07 23:12:21 +10:00
|
|
|
void (*get_view_coords)(struct sway_view_child *child, int *sx, int *sy);
|
2018-04-06 04:46:02 +10:00
|
|
|
void (*destroy)(struct sway_view_child *child);
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A view child is a surface in the view tree, such as a subsurface or a popup.
|
|
|
|
*/
|
|
|
|
struct sway_view_child {
|
|
|
|
const struct sway_view_child_impl *impl;
|
2019-05-30 00:08:48 +10:00
|
|
|
struct wl_list link;
|
2018-04-06 04:46:02 +10:00
|
|
|
|
|
|
|
struct sway_view *view;
|
2019-05-30 00:08:48 +10:00
|
|
|
struct sway_view_child *parent;
|
|
|
|
struct wl_list children; // sway_view_child::link
|
2018-04-06 04:46:02 +10:00
|
|
|
struct wlr_surface *surface;
|
2018-11-29 00:08:20 +11:00
|
|
|
bool mapped;
|
2018-04-06 04:46:02 +10:00
|
|
|
|
|
|
|
struct wl_listener surface_commit;
|
|
|
|
struct wl_listener surface_new_subsurface;
|
2018-10-06 14:49:33 +10:00
|
|
|
struct wl_listener surface_map;
|
|
|
|
struct wl_listener surface_unmap;
|
2018-04-06 04:46:02 +10:00
|
|
|
struct wl_listener surface_destroy;
|
2019-03-09 18:23:20 +11:00
|
|
|
struct wl_listener view_unmap;
|
2018-04-06 04:46:02 +10:00
|
|
|
};
|
|
|
|
|
2018-11-27 09:57:33 +11:00
|
|
|
struct sway_subsurface {
|
|
|
|
struct sway_view_child child;
|
|
|
|
|
|
|
|
struct wl_listener destroy;
|
|
|
|
};
|
|
|
|
|
2018-05-14 01:38:56 +10:00
|
|
|
struct sway_xdg_popup {
|
|
|
|
struct sway_view_child child;
|
|
|
|
|
2022-04-28 07:33:23 +10:00
|
|
|
struct wlr_xdg_popup *wlr_xdg_popup;
|
2018-05-14 01:38:56 +10:00
|
|
|
|
|
|
|
struct wl_listener new_popup;
|
|
|
|
struct wl_listener destroy;
|
|
|
|
};
|
|
|
|
|
2018-01-22 01:09:53 +11:00
|
|
|
const char *view_get_title(struct sway_view *view);
|
|
|
|
|
|
|
|
const char *view_get_app_id(struct sway_view *view);
|
|
|
|
|
|
|
|
const char *view_get_class(struct sway_view *view);
|
|
|
|
|
|
|
|
const char *view_get_instance(struct sway_view *view);
|
|
|
|
|
2018-05-13 08:16:36 +10:00
|
|
|
uint32_t view_get_x11_window_id(struct sway_view *view);
|
|
|
|
|
2018-10-23 06:17:27 +11:00
|
|
|
uint32_t view_get_x11_parent_id(struct sway_view *view);
|
|
|
|
|
2018-05-13 08:17:46 +10:00
|
|
|
const char *view_get_window_role(struct sway_view *view);
|
|
|
|
|
2018-05-13 08:16:36 +10:00
|
|
|
uint32_t view_get_window_type(struct sway_view *view);
|
|
|
|
|
2018-05-27 21:59:38 +10:00
|
|
|
const char *view_get_shell(struct sway_view *view);
|
2018-05-05 12:36:50 +10:00
|
|
|
|
2018-07-21 12:13:00 +10:00
|
|
|
void view_get_constraints(struct sway_view *view, double *min_width,
|
|
|
|
double *max_width, double *min_height, double *max_height);
|
|
|
|
|
2018-06-03 16:35:06 +10:00
|
|
|
uint32_t view_configure(struct sway_view *view, double lx, double ly, int width,
|
2018-04-03 00:57:45 +10:00
|
|
|
int height);
|
2018-01-22 01:09:53 +11:00
|
|
|
|
2020-05-06 02:35:03 +10:00
|
|
|
bool view_inhibit_idle(struct sway_view *view);
|
|
|
|
|
2018-10-01 23:41:15 +10:00
|
|
|
/**
|
2020-06-01 09:03:42 +10:00
|
|
|
* Whether or not this view's most distant ancestor (possibly itself) is the
|
|
|
|
* only visible node in its tree. If the view is tiling, there may be floating
|
|
|
|
* views. If the view is floating, there may be tiling views or views in a
|
|
|
|
* different floating container.
|
2018-10-01 23:41:15 +10:00
|
|
|
*/
|
2020-06-01 09:03:42 +10:00
|
|
|
bool view_ancestor_is_only_visible(struct sway_view *view);
|
2018-10-01 23:41:15 +10:00
|
|
|
|
2018-05-01 17:36:12 +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
|
|
|
* Configure the view's position and size based on the container's position and
|
2018-05-01 17:36:12 +10:00
|
|
|
* size, taking borders into consideration.
|
|
|
|
*/
|
2018-04-30 21:24:13 +10:00
|
|
|
void view_autoconfigure(struct sway_view *view);
|
|
|
|
|
2018-01-22 01:09:53 +11:00
|
|
|
void view_set_activated(struct sway_view *view, bool activated);
|
|
|
|
|
2018-09-02 15:03:58 +10:00
|
|
|
/**
|
|
|
|
* Called when the view requests to be focused.
|
|
|
|
*/
|
|
|
|
void view_request_activate(struct sway_view *view);
|
|
|
|
|
2018-09-24 20:54:57 +10:00
|
|
|
/**
|
|
|
|
* If possible, instructs the client to change their decoration mode.
|
|
|
|
*/
|
|
|
|
void view_set_csd_from_server(struct sway_view *view, bool enabled);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Updates the view's border setting when the client unexpectedly changes their
|
|
|
|
* decoration mode.
|
|
|
|
*/
|
2018-09-27 17:09:05 +10:00
|
|
|
void view_update_csd_from_client(struct sway_view *view, bool enabled);
|
2018-09-24 20:54:57 +10:00
|
|
|
|
2018-06-28 02:53:13 +10:00
|
|
|
void view_set_tiled(struct sway_view *view, bool tiled);
|
|
|
|
|
2018-01-22 01:09:53 +11:00
|
|
|
void view_close(struct sway_view *view);
|
|
|
|
|
2018-07-31 19:58:34 +10:00
|
|
|
void view_close_popups(struct sway_view *view);
|
|
|
|
|
2018-05-06 04:43:12 +10:00
|
|
|
void view_damage_from(struct sway_view *view);
|
2018-04-03 00:57:45 +10:00
|
|
|
|
2018-08-02 23:30:26 +10:00
|
|
|
/**
|
|
|
|
* Iterate all surfaces of a view (toplevels + popups).
|
|
|
|
*/
|
2018-04-07 00:26:32 +10:00
|
|
|
void view_for_each_surface(struct sway_view *view,
|
|
|
|
wlr_surface_iterator_func_t iterator, void *user_data);
|
|
|
|
|
2018-08-02 23:30:26 +10:00
|
|
|
/**
|
2021-01-08 20:46:12 +11:00
|
|
|
* Iterate all popup surfaces of a view.
|
2018-08-02 23:30:26 +10:00
|
|
|
*/
|
2021-01-08 20:46:12 +11:00
|
|
|
void view_for_each_popup_surface(struct sway_view *view,
|
2018-08-02 23:30:26 +10:00
|
|
|
wlr_surface_iterator_func_t iterator, void *user_data);
|
|
|
|
|
2018-04-03 00:57:45 +10:00
|
|
|
// view implementation
|
|
|
|
|
2018-04-06 01:38:14 +10:00
|
|
|
void view_init(struct sway_view *view, enum sway_view_type type,
|
|
|
|
const struct sway_view_impl *impl);
|
|
|
|
|
|
|
|
void view_destroy(struct sway_view *view);
|
|
|
|
|
2018-08-20 15:54:30 +10:00
|
|
|
void view_begin_destroy(struct sway_view *view);
|
|
|
|
|
2021-08-12 08:15:04 +10:00
|
|
|
/**
|
|
|
|
* Map a view, ie. make it visible in the tree.
|
|
|
|
*
|
|
|
|
* `fullscreen` should be set to true (and optionally `fullscreen_output`
|
|
|
|
* should be populated) if the view should be made fullscreen immediately.
|
|
|
|
*
|
|
|
|
* `decoration` should be set to true if the client prefers CSD. The client's
|
|
|
|
* preference may be ignored.
|
|
|
|
*/
|
2018-10-14 06:01:02 +11:00
|
|
|
void view_map(struct sway_view *view, struct wlr_surface *wlr_surface,
|
2019-03-25 14:24:02 +11:00
|
|
|
bool fullscreen, struct wlr_output *fullscreen_output, bool decoration);
|
2018-04-01 07:49:40 +10:00
|
|
|
|
2018-06-26 13:15:45 +10:00
|
|
|
void view_unmap(struct sway_view *view);
|
2018-02-26 09:23:36 +11:00
|
|
|
|
2021-02-08 11:45:50 +11:00
|
|
|
void view_update_size(struct sway_view *view);
|
2021-02-08 11:03:44 +11:00
|
|
|
void view_center_surface(struct sway_view *view);
|
2018-08-18 15:10:06 +10:00
|
|
|
|
2018-04-06 04:46:02 +10:00
|
|
|
void view_child_init(struct sway_view_child *child,
|
|
|
|
const struct sway_view_child_impl *impl, struct sway_view *view,
|
|
|
|
struct wlr_surface *surface);
|
|
|
|
|
|
|
|
void view_child_destroy(struct sway_view_child *child);
|
|
|
|
|
2018-06-30 15:00:24 +10:00
|
|
|
|
|
|
|
struct sway_view *view_from_wlr_xdg_surface(
|
|
|
|
struct wlr_xdg_surface *xdg_surface);
|
2018-11-18 10:33:06 +11:00
|
|
|
#if HAVE_XWAYLAND
|
2018-06-30 15:00:24 +10:00
|
|
|
struct sway_view *view_from_wlr_xwayland_surface(
|
|
|
|
struct wlr_xwayland_surface *xsurface);
|
2018-07-25 06:16:06 +10:00
|
|
|
#endif
|
2018-06-30 15:00:24 +10:00
|
|
|
struct sway_view *view_from_wlr_surface(struct wlr_surface *surface);
|
|
|
|
|
2018-05-05 12:36:50 +10:00
|
|
|
/**
|
|
|
|
* Re-read the view's title property and update any relevant title bars.
|
|
|
|
* The force argument makes it recreate the title bars even if the title hasn't
|
|
|
|
* changed.
|
|
|
|
*/
|
|
|
|
void view_update_title(struct sway_view *view, bool force);
|
|
|
|
|
2018-05-13 08:16:36 +10:00
|
|
|
/**
|
|
|
|
* Run any criteria that match the view and haven't been run on this view
|
|
|
|
* before.
|
|
|
|
*/
|
|
|
|
void view_execute_criteria(struct sway_view *view);
|
|
|
|
|
2018-05-20 09:11:55 +10:00
|
|
|
/**
|
|
|
|
* Returns true if there's a possibility the view may be rendered on screen.
|
|
|
|
* Intended for damage tracking.
|
|
|
|
*/
|
|
|
|
bool view_is_visible(struct sway_view *view);
|
|
|
|
|
2018-07-15 22:43:33 +10:00
|
|
|
void view_set_urgent(struct sway_view *view, bool enable);
|
|
|
|
|
|
|
|
bool view_is_urgent(struct sway_view *view);
|
|
|
|
|
Correctly track saved surfaces during multiple transactions
Fixes #2364.
Suppose a view is 600px wide, and we tell it to resize to 601px during a
resize operation. We create a transaction, save the 600px buffer and
send the configure. This buffer is saved into the associated
instruction, and is rendered while we wait for the view to commit a
601px buffer.
Before the view commits the 601px buffer, suppose we tell it to resize
to 602px. The new transaction will also save the buffer, but it's still
the 600px buffer because we haven't received a new one yet.
Then suppose the view commits its original 601px buffer. This completes
the first transaction, so we apply the 601px width to the container.
There's still the second (now only) transaction remaining, so we render
the saved buffer from that. But this is still the 600px buffer, and we
believe it's 601px. Whoops.
The problem here is we can't stack buffers like this. So this commit
removes the saved buffer from the instructions, places it in the view
instead, and re-saves the latest buffer every time the view completes a
transaction and still has further pending transactions.
As saved buffers are now specific to views rather than instructions, the
functions for saving and removing the saved buffer have been moved to
view.c.
The calls to save and restore the buffer have been relocated to more
appropriate functions too, favouring transaction_commit and
transaction_apply rather than transaction_add_container and
transaction_destroy.
2018-08-01 16:23:11 +10:00
|
|
|
void view_remove_saved_buffer(struct sway_view *view);
|
|
|
|
|
|
|
|
void view_save_buffer(struct sway_view *view);
|
|
|
|
|
2018-10-07 21:40:05 +11:00
|
|
|
bool view_is_transient_for(struct sway_view *child, struct sway_view *ancestor);
|
|
|
|
|
2017-11-12 10:06:50 +11:00
|
|
|
#endif
|