mirror of
https://github.com/swaywm/sway.git
synced 2025-11-02 09:01:40 -05:00
Add CSD to border modes
This replaces view.using_csd with a new border mode: B_CSD. This also
removes sway_xdg_shell{_v6}_view.deco_mode and
view->has_client_side_decorations as we can now get these from the
border.
You can use `border toggle` to cycle through the modes including CSD, or
use `border csd` to set it directly. The client must support the
xdg-decoration protocol, and the only client I know of that does is the
example in wlroots.
If the client switches from SSD to CSD without us expecting it (via the
server-decoration protocol), we stash the previous border type into
view.saved_border so we can restore it if the client returns to SSD. I
haven't found a way to test this though.
This commit is contained in:
parent
58af001517
commit
7b138e5ef0
18 changed files with 251 additions and 141 deletions
|
|
@ -54,6 +54,10 @@ struct sway_server {
|
|||
struct wl_listener server_decoration;
|
||||
struct wl_list decorations; // sway_server_decoration::link
|
||||
|
||||
struct wlr_xdg_decoration_manager_v1 *xdg_decoration_manager;
|
||||
struct wl_listener xdg_decoration;
|
||||
struct wl_list xdg_decorations; // sway_xdg_decoration::link
|
||||
|
||||
size_t txn_timeout_ms;
|
||||
list_t *transactions;
|
||||
list_t *dirty_nodes;
|
||||
|
|
@ -78,5 +82,6 @@ void handle_xdg_shell_surface(struct wl_listener *listener, void *data);
|
|||
void handle_xwayland_surface(struct wl_listener *listener, void *data);
|
||||
#endif
|
||||
void handle_server_decoration(struct wl_listener *listener, void *data);
|
||||
void handle_xdg_decoration(struct wl_listener *listener, void *data);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ enum sway_container_border {
|
|||
B_NONE,
|
||||
B_PIXEL,
|
||||
B_NORMAL,
|
||||
B_CSD,
|
||||
};
|
||||
|
||||
struct sway_root;
|
||||
|
|
@ -63,7 +64,6 @@ struct sway_container_state {
|
|||
bool border_bottom;
|
||||
bool border_left;
|
||||
bool border_right;
|
||||
bool using_csd;
|
||||
};
|
||||
|
||||
struct sway_container {
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
#include "sway/input/seat.h"
|
||||
|
||||
struct sway_container;
|
||||
struct sway_xdg_decoration;
|
||||
|
||||
enum sway_view_type {
|
||||
SWAY_VIEW_XDG_SHELL_V6,
|
||||
|
|
@ -44,7 +45,6 @@ struct sway_view_impl {
|
|||
void (*set_tiled)(struct sway_view *view, bool tiled);
|
||||
void (*set_fullscreen)(struct sway_view *view, bool fullscreen);
|
||||
bool (*wants_floating)(struct sway_view *view);
|
||||
bool (*has_client_side_decorations)(struct sway_view *view);
|
||||
void (*for_each_surface)(struct sway_view *view,
|
||||
wlr_surface_iterator_func_t iterator, void *user_data);
|
||||
void (*for_each_popup)(struct sway_view *view,
|
||||
|
|
@ -60,6 +60,7 @@ struct sway_view {
|
|||
|
||||
struct sway_container *container; // NULL if unmapped and transactions finished
|
||||
struct wlr_surface *surface; // NULL for unmapped views
|
||||
struct sway_xdg_decoration *xdg_decoration;
|
||||
|
||||
pid_t pid;
|
||||
|
||||
|
|
@ -76,12 +77,12 @@ struct sway_view {
|
|||
|
||||
char *title_format;
|
||||
enum sway_container_border border;
|
||||
enum sway_container_border saved_border;
|
||||
int border_thickness;
|
||||
bool border_top;
|
||||
bool border_bottom;
|
||||
bool border_left;
|
||||
bool border_right;
|
||||
bool using_csd;
|
||||
|
||||
struct timespec urgent;
|
||||
bool allow_request_urgent;
|
||||
|
|
@ -127,8 +128,6 @@ struct sway_view {
|
|||
struct sway_xdg_shell_v6_view {
|
||||
struct sway_view view;
|
||||
|
||||
enum wlr_server_decoration_manager_mode deco_mode;
|
||||
|
||||
struct wl_listener commit;
|
||||
struct wl_listener request_move;
|
||||
struct wl_listener request_resize;
|
||||
|
|
@ -145,8 +144,6 @@ struct sway_xdg_shell_v6_view {
|
|||
struct sway_xdg_shell_view {
|
||||
struct sway_view view;
|
||||
|
||||
enum wlr_server_decoration_manager_mode deco_mode;
|
||||
|
||||
struct wl_listener commit;
|
||||
struct wl_listener request_move;
|
||||
struct wl_listener request_resize;
|
||||
|
|
@ -175,6 +172,7 @@ struct sway_xwayland_view {
|
|||
struct wl_listener set_role;
|
||||
struct wl_listener set_window_type;
|
||||
struct wl_listener set_hints;
|
||||
struct wl_listener set_decorations;
|
||||
struct wl_listener map;
|
||||
struct wl_listener unmap;
|
||||
struct wl_listener destroy;
|
||||
|
|
@ -268,6 +266,17 @@ void view_set_activated(struct sway_view *view, bool activated);
|
|||
*/
|
||||
void view_request_activate(struct sway_view *view);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
void view_set_csd_from_client(struct sway_view *view, bool enabled);
|
||||
|
||||
void view_set_tiled(struct sway_view *view, bool tiled);
|
||||
|
||||
void view_close(struct sway_view *view);
|
||||
|
|
|
|||
19
include/sway/xdg_decoration.h
Normal file
19
include/sway/xdg_decoration.h
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#ifndef _SWAY_XDG_DECORATION_H
|
||||
#define _SWAY_XDG_DECORATION_H
|
||||
|
||||
#include <wlr/types/wlr_xdg_decoration_v1.h>
|
||||
|
||||
struct sway_xdg_decoration {
|
||||
struct wlr_xdg_toplevel_decoration_v1 *wlr_xdg_decoration;
|
||||
struct wl_list link;
|
||||
|
||||
struct sway_view *view;
|
||||
|
||||
struct wl_listener destroy;
|
||||
struct wl_listener surface_commit;
|
||||
};
|
||||
|
||||
struct sway_xdg_decoration *xdg_decoration_from_surface(
|
||||
struct wlr_surface *surface);
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue