summaryrefslogtreecommitdiffstats
path: root/include/sway
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2018-10-03 13:03:06 +0200
committerLibravatar GitHub <noreply@github.com>2018-10-03 13:03:06 +0200
commit06c214a800cab9119ae4b04371e3f6bbca8a0550 (patch)
treeeed325e37d02fa71858a33e71ef33961395dd16f /include/sway
parentMerge pull request #2755 from RyanDwyer/fix-tiling-criteria (diff)
parentRemove server-decoration assumption if view supports xdg-decoration (diff)
downloadsway-06c214a800cab9119ae4b04371e3f6bbca8a0550.tar.gz
sway-06c214a800cab9119ae4b04371e3f6bbca8a0550.tar.zst
sway-06c214a800cab9119ae4b04371e3f6bbca8a0550.zip
Merge pull request #2703 from RyanDwyer/csd-border
Add CSD to border modes
Diffstat (limited to 'include/sway')
-rw-r--r--include/sway/server.h5
-rw-r--r--include/sway/tree/container.h2
-rw-r--r--include/sway/tree/view.h32
-rw-r--r--include/sway/xdg_decoration.h19
4 files changed, 51 insertions, 7 deletions
diff --git a/include/sway/server.h b/include/sway/server.h
index 5dabb61f..3e1cbb33 100644
--- a/include/sway/server.h
+++ b/include/sway/server.h
@@ -54,6 +54,10 @@ struct sway_server {
54 struct wl_listener server_decoration; 54 struct wl_listener server_decoration;
55 struct wl_list decorations; // sway_server_decoration::link 55 struct wl_list decorations; // sway_server_decoration::link
56 56
57 struct wlr_xdg_decoration_manager_v1 *xdg_decoration_manager;
58 struct wl_listener xdg_decoration;
59 struct wl_list xdg_decorations; // sway_xdg_decoration::link
60
57 size_t txn_timeout_ms; 61 size_t txn_timeout_ms;
58 list_t *transactions; 62 list_t *transactions;
59 list_t *dirty_nodes; 63 list_t *dirty_nodes;
@@ -78,5 +82,6 @@ void handle_xdg_shell_surface(struct wl_listener *listener, void *data);
78void handle_xwayland_surface(struct wl_listener *listener, void *data); 82void handle_xwayland_surface(struct wl_listener *listener, void *data);
79#endif 83#endif
80void handle_server_decoration(struct wl_listener *listener, void *data); 84void handle_server_decoration(struct wl_listener *listener, void *data);
85void handle_xdg_decoration(struct wl_listener *listener, void *data);
81 86
82#endif 87#endif
diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h
index b865a0f2..da6592b4 100644
--- a/include/sway/tree/container.h
+++ b/include/sway/tree/container.h
@@ -28,6 +28,7 @@ enum sway_container_border {
28 B_NONE, 28 B_NONE,
29 B_PIXEL, 29 B_PIXEL,
30 B_NORMAL, 30 B_NORMAL,
31 B_CSD,
31}; 32};
32 33
33struct sway_root; 34struct sway_root;
@@ -63,7 +64,6 @@ struct sway_container_state {
63 bool border_bottom; 64 bool border_bottom;
64 bool border_left; 65 bool border_left;
65 bool border_right; 66 bool border_right;
66 bool using_csd;
67}; 67};
68 68
69struct sway_container { 69struct sway_container {
diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h
index 56ccbc6c..028be536 100644
--- a/include/sway/tree/view.h
+++ b/include/sway/tree/view.h
@@ -11,6 +11,7 @@
11#include "sway/input/seat.h" 11#include "sway/input/seat.h"
12 12
13struct sway_container; 13struct sway_container;
14struct sway_xdg_decoration;
14 15
15enum sway_view_type { 16enum sway_view_type {
16 SWAY_VIEW_XDG_SHELL_V6, 17 SWAY_VIEW_XDG_SHELL_V6,
@@ -44,7 +45,6 @@ struct sway_view_impl {
44 void (*set_tiled)(struct sway_view *view, bool tiled); 45 void (*set_tiled)(struct sway_view *view, bool tiled);
45 void (*set_fullscreen)(struct sway_view *view, bool fullscreen); 46 void (*set_fullscreen)(struct sway_view *view, bool fullscreen);
46 bool (*wants_floating)(struct sway_view *view); 47 bool (*wants_floating)(struct sway_view *view);
47 bool (*has_client_side_decorations)(struct sway_view *view);
48 void (*for_each_surface)(struct sway_view *view, 48 void (*for_each_surface)(struct sway_view *view,
49 wlr_surface_iterator_func_t iterator, void *user_data); 49 wlr_surface_iterator_func_t iterator, void *user_data);
50 void (*for_each_popup)(struct sway_view *view, 50 void (*for_each_popup)(struct sway_view *view,
@@ -60,6 +60,7 @@ struct sway_view {
60 60
61 struct sway_container *container; // NULL if unmapped and transactions finished 61 struct sway_container *container; // NULL if unmapped and transactions finished
62 struct wlr_surface *surface; // NULL for unmapped views 62 struct wlr_surface *surface; // NULL for unmapped views
63 struct sway_xdg_decoration *xdg_decoration;
63 64
64 pid_t pid; 65 pid_t pid;
65 66
@@ -75,13 +76,24 @@ struct sway_view {
75 int natural_width, natural_height; 76 int natural_width, natural_height;
76 77
77 char *title_format; 78 char *title_format;
79
80 // Our border types are B_NONE, B_PIXEL, B_NORMAL and B_CSD. We normally
81 // just assign this to the border property and ignore the other two.
82 // However, when a view using CSD is tiled, we want to render our own
83 // borders as well. So in this case the border property becomes one of the
84 // first three, and using_csd is true.
85 // Lastly, views can change their decoration mode at any time. When an SSD
86 // view becomes CSD without our approval, we save the SSD border type so it
87 // can be restored if/when the view returns from CSD to SSD.
78 enum sway_container_border border; 88 enum sway_container_border border;
89 enum sway_container_border saved_border;
90 bool using_csd;
91
79 int border_thickness; 92 int border_thickness;
80 bool border_top; 93 bool border_top;
81 bool border_bottom; 94 bool border_bottom;
82 bool border_left; 95 bool border_left;
83 bool border_right; 96 bool border_right;
84 bool using_csd;
85 97
86 struct timespec urgent; 98 struct timespec urgent;
87 bool allow_request_urgent; 99 bool allow_request_urgent;
@@ -127,8 +139,6 @@ struct sway_view {
127struct sway_xdg_shell_v6_view { 139struct sway_xdg_shell_v6_view {
128 struct sway_view view; 140 struct sway_view view;
129 141
130 enum wlr_server_decoration_manager_mode deco_mode;
131
132 struct wl_listener commit; 142 struct wl_listener commit;
133 struct wl_listener request_move; 143 struct wl_listener request_move;
134 struct wl_listener request_resize; 144 struct wl_listener request_resize;
@@ -145,8 +155,6 @@ struct sway_xdg_shell_v6_view {
145struct sway_xdg_shell_view { 155struct sway_xdg_shell_view {
146 struct sway_view view; 156 struct sway_view view;
147 157
148 enum wlr_server_decoration_manager_mode deco_mode;
149
150 struct wl_listener commit; 158 struct wl_listener commit;
151 struct wl_listener request_move; 159 struct wl_listener request_move;
152 struct wl_listener request_resize; 160 struct wl_listener request_resize;
@@ -175,6 +183,7 @@ struct sway_xwayland_view {
175 struct wl_listener set_role; 183 struct wl_listener set_role;
176 struct wl_listener set_window_type; 184 struct wl_listener set_window_type;
177 struct wl_listener set_hints; 185 struct wl_listener set_hints;
186 struct wl_listener set_decorations;
178 struct wl_listener map; 187 struct wl_listener map;
179 struct wl_listener unmap; 188 struct wl_listener unmap;
180 struct wl_listener destroy; 189 struct wl_listener destroy;
@@ -275,6 +284,17 @@ void view_set_activated(struct sway_view *view, bool activated);
275 */ 284 */
276void view_request_activate(struct sway_view *view); 285void view_request_activate(struct sway_view *view);
277 286
287/**
288 * If possible, instructs the client to change their decoration mode.
289 */
290void view_set_csd_from_server(struct sway_view *view, bool enabled);
291
292/**
293 * Updates the view's border setting when the client unexpectedly changes their
294 * decoration mode.
295 */
296void view_update_csd_from_client(struct sway_view *view, bool enabled);
297
278void view_set_tiled(struct sway_view *view, bool tiled); 298void view_set_tiled(struct sway_view *view, bool tiled);
279 299
280void view_close(struct sway_view *view); 300void view_close(struct sway_view *view);
diff --git a/include/sway/xdg_decoration.h b/include/sway/xdg_decoration.h
new file mode 100644
index 00000000..8bef4c6d
--- /dev/null
+++ b/include/sway/xdg_decoration.h
@@ -0,0 +1,19 @@
1#ifndef _SWAY_XDG_DECORATION_H
2#define _SWAY_XDG_DECORATION_H
3
4#include <wlr/types/wlr_xdg_decoration_v1.h>
5
6struct sway_xdg_decoration {
7 struct wlr_xdg_toplevel_decoration_v1 *wlr_xdg_decoration;
8 struct wl_list link;
9
10 struct sway_view *view;
11
12 struct wl_listener destroy;
13 struct wl_listener request_mode;
14};
15
16struct sway_xdg_decoration *xdg_decoration_from_surface(
17 struct wlr_surface *surface);
18
19#endif