mirror of
https://github.com/swaywm/sway.git
synced 2024-11-25 17:31:28 +00:00
Handle views created after decoration mode is sent for xdg-shell
This commit is contained in:
parent
700941dde8
commit
9d578e0a0f
|
@ -5,9 +5,13 @@
|
|||
|
||||
struct sway_server_decoration {
|
||||
struct wlr_server_decoration *wlr_server_decoration;
|
||||
struct wl_list link;
|
||||
|
||||
struct wl_listener destroy;
|
||||
struct wl_listener mode;
|
||||
};
|
||||
|
||||
struct sway_server_decoration *decoration_from_surface(
|
||||
struct wlr_surface *surface);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -52,6 +52,7 @@ struct sway_server {
|
|||
|
||||
struct wlr_server_decoration_manager *server_decoration_manager;
|
||||
struct wl_listener server_decoration;
|
||||
struct wl_list decorations; // sway_server_decoration::link
|
||||
|
||||
bool debug_txn_timings;
|
||||
|
||||
|
|
|
@ -118,6 +118,8 @@ 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;
|
||||
|
@ -134,6 +136,8 @@ 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;
|
||||
|
|
|
@ -9,6 +9,8 @@ static void server_decoration_handle_destroy(struct wl_listener *listener,
|
|||
struct sway_server_decoration *deco =
|
||||
wl_container_of(listener, deco, destroy);
|
||||
wl_list_remove(&deco->destroy.link);
|
||||
wl_list_remove(&deco->mode.link);
|
||||
wl_list_remove(&deco->link);
|
||||
free(deco);
|
||||
}
|
||||
|
||||
|
@ -18,9 +20,24 @@ static void server_decoration_handle_mode(struct wl_listener *listener,
|
|||
wl_container_of(listener, deco, mode);
|
||||
struct sway_view *view =
|
||||
view_from_wlr_surface(deco->wlr_server_decoration->surface);
|
||||
if (view == NULL || view->surface != deco->wlr_server_decoration->surface) {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO
|
||||
wlr_log(WLR_ERROR, "%p %d", view, deco->wlr_server_decoration->mode);
|
||||
switch (view->type) {
|
||||
case SWAY_VIEW_XDG_SHELL_V6:;
|
||||
struct sway_xdg_shell_v6_view *xdg_shell_v6_view =
|
||||
(struct sway_xdg_shell_v6_view *)view;
|
||||
xdg_shell_v6_view->deco_mode = deco->wlr_server_decoration->mode;
|
||||
break;
|
||||
case SWAY_VIEW_XDG_SHELL:;
|
||||
struct sway_xdg_shell_view *xdg_shell_view =
|
||||
(struct sway_xdg_shell_view *)view;
|
||||
xdg_shell_view->deco_mode = deco->wlr_server_decoration->mode;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void handle_server_decoration(struct wl_listener *listener, void *data) {
|
||||
|
@ -38,4 +55,17 @@ void handle_server_decoration(struct wl_listener *listener, void *data) {
|
|||
|
||||
wl_signal_add(&wlr_deco->events.mode, &deco->mode);
|
||||
deco->mode.notify = server_decoration_handle_mode;
|
||||
|
||||
wl_list_insert(&server.decorations, &deco->link);
|
||||
}
|
||||
|
||||
struct sway_server_decoration *decoration_from_surface(
|
||||
struct wlr_surface *surface) {
|
||||
struct sway_server_decoration *deco;
|
||||
wl_list_for_each(deco, &server.decorations, link) {
|
||||
if (deco->wlr_server_decoration->surface == surface) {
|
||||
return deco;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include <wlr/types/wlr_xdg_shell.h>
|
||||
#include <wlr/util/edges.h>
|
||||
#include "log.h"
|
||||
#include "sway/decoration.h"
|
||||
#include "sway/input/input-manager.h"
|
||||
#include "sway/input/seat.h"
|
||||
#include "sway/server.h"
|
||||
|
@ -170,6 +171,15 @@ static bool wants_floating(struct sway_view *view) {
|
|||
|| toplevel->parent;
|
||||
}
|
||||
|
||||
static bool has_client_side_decorations(struct sway_view *view) {
|
||||
struct sway_xdg_shell_view *xdg_shell_view =
|
||||
xdg_shell_view_from_view(view);
|
||||
if (xdg_shell_view == NULL) {
|
||||
return true;
|
||||
}
|
||||
return xdg_shell_view->deco_mode != WLR_SERVER_DECORATION_MANAGER_MODE_SERVER;
|
||||
}
|
||||
|
||||
static void for_each_surface(struct sway_view *view,
|
||||
wlr_surface_iterator_func_t iterator, void *user_data) {
|
||||
if (xdg_shell_view_from_view(view) == NULL) {
|
||||
|
@ -226,6 +236,7 @@ static const struct sway_view_impl view_impl = {
|
|||
.set_tiled = set_tiled,
|
||||
.set_fullscreen = set_fullscreen,
|
||||
.wants_floating = wants_floating,
|
||||
.has_client_side_decorations = has_client_side_decorations,
|
||||
.for_each_surface = for_each_surface,
|
||||
.for_each_popup = for_each_popup,
|
||||
.close = _close,
|
||||
|
@ -357,6 +368,14 @@ static void handle_map(struct wl_listener *listener, void *data) {
|
|||
view->natural_height = view->wlr_xdg_surface->surface->current.height;
|
||||
}
|
||||
|
||||
struct sway_server_decoration *deco =
|
||||
decoration_from_surface(xdg_surface->surface);
|
||||
if (deco != NULL) {
|
||||
xdg_shell_view->deco_mode = deco->wlr_server_decoration->mode;
|
||||
} else {
|
||||
xdg_shell_view->deco_mode = WLR_SERVER_DECORATION_MANAGER_MODE_CLIENT;
|
||||
}
|
||||
|
||||
view_map(view, view->wlr_xdg_surface->surface);
|
||||
|
||||
if (xdg_surface->toplevel->client_pending.fullscreen) {
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#include <wlr/types/wlr_xcursor_manager.h>
|
||||
#include <wlr/types/wlr_xdg_output.h>
|
||||
#include <wlr/util/log.h>
|
||||
// TODO WLR: make Xwayland optional
|
||||
#include "list.h"
|
||||
#include "sway/config.h"
|
||||
#include "sway/desktop/idle_inhibit_v1.h"
|
||||
|
@ -85,7 +84,6 @@ bool server_init(struct sway_server *server) {
|
|||
&server->xdg_shell_surface);
|
||||
server->xdg_shell_surface.notify = handle_xdg_shell_surface;
|
||||
|
||||
// TODO make xwayland optional
|
||||
#ifdef HAVE_XWAYLAND
|
||||
server->xwayland.wlr_xwayland =
|
||||
wlr_xwayland_create(server->wl_display, server->compositor, true);
|
||||
|
@ -117,6 +115,7 @@ bool server_init(struct sway_server *server) {
|
|||
wl_signal_add(&server->server_decoration_manager->events.new_decoration,
|
||||
&server->server_decoration);
|
||||
server->server_decoration.notify = handle_server_decoration;
|
||||
wl_list_init(&server->decorations);
|
||||
|
||||
wlr_linux_dmabuf_v1_create(server->wl_display, renderer);
|
||||
wlr_export_dmabuf_manager_v1_create(server->wl_display);
|
||||
|
|
Loading…
Reference in a new issue