aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/sway/decoration.h4
-rw-r--r--include/sway/server.h1
-rw-r--r--include/sway/tree/view.h4
-rw-r--r--sway/decoration.c34
-rw-r--r--sway/desktop/xdg_shell.c19
-rw-r--r--sway/server.c3
6 files changed, 61 insertions, 4 deletions
diff --git a/include/sway/decoration.h b/include/sway/decoration.h
index c77c04c7..7916746e 100644
--- a/include/sway/decoration.h
+++ b/include/sway/decoration.h
@@ -5,9 +5,13 @@
5 5
6struct sway_server_decoration { 6struct sway_server_decoration {
7 struct wlr_server_decoration *wlr_server_decoration; 7 struct wlr_server_decoration *wlr_server_decoration;
8 struct wl_list link;
8 9
9 struct wl_listener destroy; 10 struct wl_listener destroy;
10 struct wl_listener mode; 11 struct wl_listener mode;
11}; 12};
12 13
14struct sway_server_decoration *decoration_from_surface(
15 struct wlr_surface *surface);
16
13#endif 17#endif
diff --git a/include/sway/server.h b/include/sway/server.h
index 7e73fb4f..b93584b6 100644
--- a/include/sway/server.h
+++ b/include/sway/server.h
@@ -52,6 +52,7 @@ struct sway_server {
52 52
53 struct wlr_server_decoration_manager *server_decoration_manager; 53 struct wlr_server_decoration_manager *server_decoration_manager;
54 struct wl_listener server_decoration; 54 struct wl_listener server_decoration;
55 struct wl_list decorations; // sway_server_decoration::link
55 56
56 bool debug_txn_timings; 57 bool debug_txn_timings;
57 58
diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h
index 37fd02bc..e91d2a20 100644
--- a/include/sway/tree/view.h
+++ b/include/sway/tree/view.h
@@ -118,6 +118,8 @@ struct sway_view {
118struct sway_xdg_shell_v6_view { 118struct sway_xdg_shell_v6_view {
119 struct sway_view view; 119 struct sway_view view;
120 120
121 enum wlr_server_decoration_manager_mode deco_mode;
122
121 struct wl_listener commit; 123 struct wl_listener commit;
122 struct wl_listener request_move; 124 struct wl_listener request_move;
123 struct wl_listener request_resize; 125 struct wl_listener request_resize;
@@ -134,6 +136,8 @@ struct sway_xdg_shell_v6_view {
134struct sway_xdg_shell_view { 136struct sway_xdg_shell_view {
135 struct sway_view view; 137 struct sway_view view;
136 138
139 enum wlr_server_decoration_manager_mode deco_mode;
140
137 struct wl_listener commit; 141 struct wl_listener commit;
138 struct wl_listener request_move; 142 struct wl_listener request_move;
139 struct wl_listener request_resize; 143 struct wl_listener request_resize;
diff --git a/sway/decoration.c b/sway/decoration.c
index 73b3f45d..0e3e67ac 100644
--- a/sway/decoration.c
+++ b/sway/decoration.c
@@ -9,6 +9,8 @@ static void server_decoration_handle_destroy(struct wl_listener *listener,
9 struct sway_server_decoration *deco = 9 struct sway_server_decoration *deco =
10 wl_container_of(listener, deco, destroy); 10 wl_container_of(listener, deco, destroy);
11 wl_list_remove(&deco->destroy.link); 11 wl_list_remove(&deco->destroy.link);
12 wl_list_remove(&deco->mode.link);
13 wl_list_remove(&deco->link);
12 free(deco); 14 free(deco);
13} 15}
14 16
@@ -18,9 +20,24 @@ static void server_decoration_handle_mode(struct wl_listener *listener,
18 wl_container_of(listener, deco, mode); 20 wl_container_of(listener, deco, mode);
19 struct sway_view *view = 21 struct sway_view *view =
20 view_from_wlr_surface(deco->wlr_server_decoration->surface); 22 view_from_wlr_surface(deco->wlr_server_decoration->surface);
23 if (view == NULL || view->surface != deco->wlr_server_decoration->surface) {
24 return;
25 }
21 26
22 // TODO 27 switch (view->type) {
23 wlr_log(WLR_ERROR, "%p %d", view, deco->wlr_server_decoration->mode); 28 case SWAY_VIEW_XDG_SHELL_V6:;
29 struct sway_xdg_shell_v6_view *xdg_shell_v6_view =
30 (struct sway_xdg_shell_v6_view *)view;
31 xdg_shell_v6_view->deco_mode = deco->wlr_server_decoration->mode;
32 break;
33 case SWAY_VIEW_XDG_SHELL:;
34 struct sway_xdg_shell_view *xdg_shell_view =
35 (struct sway_xdg_shell_view *)view;
36 xdg_shell_view->deco_mode = deco->wlr_server_decoration->mode;
37 break;
38 default:
39 break;
40 }
24} 41}
25 42
26void handle_server_decoration(struct wl_listener *listener, void *data) { 43void handle_server_decoration(struct wl_listener *listener, void *data) {
@@ -38,4 +55,17 @@ void handle_server_decoration(struct wl_listener *listener, void *data) {
38 55
39 wl_signal_add(&wlr_deco->events.mode, &deco->mode); 56 wl_signal_add(&wlr_deco->events.mode, &deco->mode);
40 deco->mode.notify = server_decoration_handle_mode; 57 deco->mode.notify = server_decoration_handle_mode;
58
59 wl_list_insert(&server.decorations, &deco->link);
60}
61
62struct sway_server_decoration *decoration_from_surface(
63 struct wlr_surface *surface) {
64 struct sway_server_decoration *deco;
65 wl_list_for_each(deco, &server.decorations, link) {
66 if (deco->wlr_server_decoration->surface == surface) {
67 return deco;
68 }
69 }
70 return NULL;
41} 71}
diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c
index b364663d..3b73f99c 100644
--- a/sway/desktop/xdg_shell.c
+++ b/sway/desktop/xdg_shell.c
@@ -6,6 +6,7 @@
6#include <wlr/types/wlr_xdg_shell.h> 6#include <wlr/types/wlr_xdg_shell.h>
7#include <wlr/util/edges.h> 7#include <wlr/util/edges.h>
8#include "log.h" 8#include "log.h"
9#include "sway/decoration.h"
9#include "sway/input/input-manager.h" 10#include "sway/input/input-manager.h"
10#include "sway/input/seat.h" 11#include "sway/input/seat.h"
11#include "sway/server.h" 12#include "sway/server.h"
@@ -170,6 +171,15 @@ static bool wants_floating(struct sway_view *view) {
170 || toplevel->parent; 171 || toplevel->parent;
171} 172}
172 173
174static bool has_client_side_decorations(struct sway_view *view) {
175 struct sway_xdg_shell_view *xdg_shell_view =
176 xdg_shell_view_from_view(view);
177 if (xdg_shell_view == NULL) {
178 return true;
179 }
180 return xdg_shell_view->deco_mode != WLR_SERVER_DECORATION_MANAGER_MODE_SERVER;
181}
182
173static void for_each_surface(struct sway_view *view, 183static void for_each_surface(struct sway_view *view,
174 wlr_surface_iterator_func_t iterator, void *user_data) { 184 wlr_surface_iterator_func_t iterator, void *user_data) {
175 if (xdg_shell_view_from_view(view) == NULL) { 185 if (xdg_shell_view_from_view(view) == NULL) {
@@ -226,6 +236,7 @@ static const struct sway_view_impl view_impl = {
226 .set_tiled = set_tiled, 236 .set_tiled = set_tiled,
227 .set_fullscreen = set_fullscreen, 237 .set_fullscreen = set_fullscreen,
228 .wants_floating = wants_floating, 238 .wants_floating = wants_floating,
239 .has_client_side_decorations = has_client_side_decorations,
229 .for_each_surface = for_each_surface, 240 .for_each_surface = for_each_surface,
230 .for_each_popup = for_each_popup, 241 .for_each_popup = for_each_popup,
231 .close = _close, 242 .close = _close,
@@ -357,6 +368,14 @@ static void handle_map(struct wl_listener *listener, void *data) {
357 view->natural_height = view->wlr_xdg_surface->surface->current.height; 368 view->natural_height = view->wlr_xdg_surface->surface->current.height;
358 } 369 }
359 370
371 struct sway_server_decoration *deco =
372 decoration_from_surface(xdg_surface->surface);
373 if (deco != NULL) {
374 xdg_shell_view->deco_mode = deco->wlr_server_decoration->mode;
375 } else {
376 xdg_shell_view->deco_mode = WLR_SERVER_DECORATION_MANAGER_MODE_CLIENT;
377 }
378
360 view_map(view, view->wlr_xdg_surface->surface); 379 view_map(view, view->wlr_xdg_surface->surface);
361 380
362 if (xdg_surface->toplevel->client_pending.fullscreen) { 381 if (xdg_surface->toplevel->client_pending.fullscreen) {
diff --git a/sway/server.c b/sway/server.c
index bf6255bc..e8dc63be 100644
--- a/sway/server.c
+++ b/sway/server.c
@@ -19,7 +19,6 @@
19#include <wlr/types/wlr_xcursor_manager.h> 19#include <wlr/types/wlr_xcursor_manager.h>
20#include <wlr/types/wlr_xdg_output.h> 20#include <wlr/types/wlr_xdg_output.h>
21#include <wlr/util/log.h> 21#include <wlr/util/log.h>
22// TODO WLR: make Xwayland optional
23#include "list.h" 22#include "list.h"
24#include "sway/config.h" 23#include "sway/config.h"
25#include "sway/desktop/idle_inhibit_v1.h" 24#include "sway/desktop/idle_inhibit_v1.h"
@@ -85,7 +84,6 @@ bool server_init(struct sway_server *server) {
85 &server->xdg_shell_surface); 84 &server->xdg_shell_surface);
86 server->xdg_shell_surface.notify = handle_xdg_shell_surface; 85 server->xdg_shell_surface.notify = handle_xdg_shell_surface;
87 86
88 // TODO make xwayland optional
89#ifdef HAVE_XWAYLAND 87#ifdef HAVE_XWAYLAND
90 server->xwayland.wlr_xwayland = 88 server->xwayland.wlr_xwayland =
91 wlr_xwayland_create(server->wl_display, server->compositor, true); 89 wlr_xwayland_create(server->wl_display, server->compositor, true);
@@ -117,6 +115,7 @@ bool server_init(struct sway_server *server) {
117 wl_signal_add(&server->server_decoration_manager->events.new_decoration, 115 wl_signal_add(&server->server_decoration_manager->events.new_decoration,
118 &server->server_decoration); 116 &server->server_decoration);
119 server->server_decoration.notify = handle_server_decoration; 117 server->server_decoration.notify = handle_server_decoration;
118 wl_list_init(&server->decorations);
120 119
121 wlr_linux_dmabuf_v1_create(server->wl_display, renderer); 120 wlr_linux_dmabuf_v1_create(server->wl_display, renderer);
122 wlr_export_dmabuf_manager_v1_create(server->wl_display); 121 wlr_export_dmabuf_manager_v1_create(server->wl_display);