From a43acae0005ec4d635f1477376fad2ff5d12d611 Mon Sep 17 00:00:00 2001 From: emersion Date: Fri, 27 Oct 2017 00:02:30 +0200 Subject: [PATCH] Send server-decoration ack event automatically --- include/rootston/desktop.h | 2 ++ include/wlr/types/wlr_server_decoration.h | 9 ++------- rootston/desktop.c | 9 ++++++++- rootston/meson.build | 2 +- types/wlr_server_decoration.c | 22 ++++++++-------------- 5 files changed, 21 insertions(+), 23 deletions(-) diff --git a/include/rootston/desktop.h b/include/rootston/desktop.h index c3859afb..376412fb 100644 --- a/include/rootston/desktop.h +++ b/include/rootston/desktop.h @@ -37,11 +37,13 @@ struct roots_desktop { struct wlr_xdg_shell_v6 *xdg_shell_v6; struct wlr_gamma_control_manager *gamma_control_manager; struct wlr_screenshooter *screenshooter; + struct wlr_server_decoration_manager *server_decoration_manager; struct wl_listener output_add; struct wl_listener output_remove; struct wl_listener xdg_shell_v6_surface; struct wl_listener wl_shell_surface; + struct wl_listener decoration_new; #ifdef HAS_XWAYLAND struct wlr_xwayland *xwayland; diff --git a/include/wlr/types/wlr_server_decoration.h b/include/wlr/types/wlr_server_decoration.h index 059aa77f..b4cac5b7 100644 --- a/include/wlr/types/wlr_server_decoration.h +++ b/include/wlr/types/wlr_server_decoration.h @@ -22,13 +22,11 @@ struct wlr_server_decoration { struct wlr_surface *surface; struct wl_list link; - // enum org_kde_kwin_server_decoration_manager_mode - uint32_t requested_mode; - uint32_t sent_mode; + uint32_t mode; // enum org_kde_kwin_server_decoration_manager_mode struct { struct wl_signal destroy; - struct wl_signal request_mode; + struct wl_signal mode; } events; struct wl_listener surface_destroy_listener; @@ -43,7 +41,4 @@ void wlr_server_decoration_manager_set_default_mode( void wlr_server_decoration_manager_destroy( struct wlr_server_decoration_manager *manager); -void wlr_server_decoration_send_mode(struct wlr_server_decoration *decoration, - uint32_t mode); - #endif diff --git a/rootston/desktop.c b/rootston/desktop.c index 40d088b8..a9d38353 100644 --- a/rootston/desktop.c +++ b/rootston/desktop.c @@ -7,11 +7,13 @@ #include #include #include +#include #include #include #include #include -#include "rootston/desktop.h" +#include +#include "rootston/server.h" #include "rootston/server.h" void view_destroy(struct roots_view *view) { @@ -252,6 +254,11 @@ struct roots_desktop *desktop_create(struct roots_server *server, server->wl_display); desktop->screenshooter = wlr_screenshooter_create(server->wl_display, server->renderer); + desktop->server_decoration_manager = + wlr_server_decoration_manager_create(server->wl_display); + wlr_server_decoration_manager_set_default_mode( + desktop->server_decoration_manager, + ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_CLIENT); return desktop; } diff --git a/rootston/meson.build b/rootston/meson.build index f2621450..53cab62d 100644 --- a/rootston/meson.build +++ b/rootston/meson.build @@ -17,5 +17,5 @@ if get_option('enable_xwayland') sources += ['xwayland.c'] endif executable( - 'rootston', sources, dependencies: wlroots + 'rootston', sources, dependencies: [wlroots, wlr_protos] ) diff --git a/types/wlr_server_decoration.c b/types/wlr_server_decoration.c index 0d276445..0664edfb 100644 --- a/types/wlr_server_decoration.c +++ b/types/wlr_server_decoration.c @@ -14,17 +14,13 @@ static void server_decoration_handle_request_mode(struct wl_client *client, struct wl_resource *resource, uint32_t mode) { struct wlr_server_decoration *decoration = wl_resource_get_user_data(resource); - decoration->requested_mode = mode; - wl_signal_emit(&decoration->events.request_mode, decoration); -} - -void wlr_server_decoration_send_mode(struct wlr_server_decoration *decoration, - uint32_t mode) { - if (decoration->sent_mode == mode) { + if (decoration->mode == mode) { return; } - org_kde_kwin_server_decoration_send_mode(decoration->resource, mode); - decoration->sent_mode = mode; + decoration->mode = mode; + wl_signal_emit(&decoration->events.mode, decoration); + org_kde_kwin_server_decoration_send_mode(decoration->resource, + decoration->mode); } static void server_decoration_destroy( @@ -71,8 +67,7 @@ static void server_decoration_manager_handle_create(struct wl_client *client, return; } decoration->surface = surface; - decoration->requested_mode = - ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_NONE; + decoration->mode = manager->default_mode; int version = wl_resource_get_version(manager_resource); decoration->resource = wl_resource_create(client, @@ -90,7 +85,7 @@ static void server_decoration_manager_handle_create(struct wl_client *client, decoration->resource); wl_signal_init(&decoration->events.destroy); - wl_signal_init(&decoration->events.request_mode); + wl_signal_init(&decoration->events.mode); wl_signal_add(&surface->events.destroy, &decoration->surface_destroy_listener); @@ -100,8 +95,7 @@ static void server_decoration_manager_handle_create(struct wl_client *client, wl_list_insert(&manager->decorations, &decoration->link); org_kde_kwin_server_decoration_send_mode(decoration->resource, - manager->default_mode); - decoration->sent_mode = manager->default_mode; + decoration->mode); wl_signal_emit(&manager->events.new_decoration, decoration); }