mirror of
https://github.com/swaywm/sway.git
synced 2024-12-28 07:56:31 +01:00
Listen to server-decoration mode changes
This commit is contained in:
parent
0cd418ba42
commit
700941dde8
5 changed files with 72 additions and 6 deletions
13
include/sway/decoration.h
Normal file
13
include/sway/decoration.h
Normal file
|
@ -0,0 +1,13 @@
|
|||
#ifndef _SWAY_DECORATION_H
|
||||
#define _SWAY_DECORATION_H
|
||||
|
||||
#include <wlr/types/wlr_server_decoration.h>
|
||||
|
||||
struct sway_server_decoration {
|
||||
struct wlr_server_decoration *wlr_server_decoration;
|
||||
|
||||
struct wl_listener destroy;
|
||||
struct wl_listener mode;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -4,12 +4,13 @@
|
|||
#include <wayland-server.h>
|
||||
#include <wlr/backend.h>
|
||||
#include <wlr/backend/session.h>
|
||||
#include <wlr/render/wlr_renderer.h>
|
||||
#include <wlr/types/wlr_compositor.h>
|
||||
#include <wlr/types/wlr_data_device.h>
|
||||
#include <wlr/types/wlr_layer_shell.h>
|
||||
#include <wlr/types/wlr_server_decoration.h>
|
||||
#include <wlr/types/wlr_xdg_shell_v6.h>
|
||||
#include <wlr/types/wlr_xdg_shell.h>
|
||||
#include <wlr/render/wlr_renderer.h>
|
||||
// TODO WLR: make Xwayland optional
|
||||
#include "list.h"
|
||||
#include "config.h"
|
||||
|
@ -42,11 +43,16 @@ struct sway_server {
|
|||
|
||||
struct wlr_xdg_shell *xdg_shell;
|
||||
struct wl_listener xdg_shell_surface;
|
||||
|
||||
#ifdef HAVE_XWAYLAND
|
||||
struct sway_xwayland xwayland;
|
||||
struct wl_listener xwayland_surface;
|
||||
struct wl_listener xwayland_ready;
|
||||
#endif
|
||||
|
||||
struct wlr_server_decoration_manager *server_decoration_manager;
|
||||
struct wl_listener server_decoration;
|
||||
|
||||
bool debug_txn_timings;
|
||||
|
||||
list_t *transactions;
|
||||
|
@ -71,4 +77,6 @@ void handle_xdg_shell_surface(struct wl_listener *listener, void *data);
|
|||
#ifdef HAVE_XWAYLAND
|
||||
void handle_xwayland_surface(struct wl_listener *listener, void *data);
|
||||
#endif
|
||||
void handle_server_decoration(struct wl_listener *listener, void *data);
|
||||
|
||||
#endif
|
||||
|
|
41
sway/decoration.c
Normal file
41
sway/decoration.c
Normal file
|
@ -0,0 +1,41 @@
|
|||
#include <stdlib.h>
|
||||
#include "sway/decoration.h"
|
||||
#include "sway/server.h"
|
||||
#include "sway/tree/view.h"
|
||||
#include "log.h"
|
||||
|
||||
static void server_decoration_handle_destroy(struct wl_listener *listener,
|
||||
void *data) {
|
||||
struct sway_server_decoration *deco =
|
||||
wl_container_of(listener, deco, destroy);
|
||||
wl_list_remove(&deco->destroy.link);
|
||||
free(deco);
|
||||
}
|
||||
|
||||
static void server_decoration_handle_mode(struct wl_listener *listener,
|
||||
void *data) {
|
||||
struct sway_server_decoration *deco =
|
||||
wl_container_of(listener, deco, mode);
|
||||
struct sway_view *view =
|
||||
view_from_wlr_surface(deco->wlr_server_decoration->surface);
|
||||
|
||||
// TODO
|
||||
wlr_log(WLR_ERROR, "%p %d", view, deco->wlr_server_decoration->mode);
|
||||
}
|
||||
|
||||
void handle_server_decoration(struct wl_listener *listener, void *data) {
|
||||
struct wlr_server_decoration *wlr_deco = data;
|
||||
|
||||
struct sway_server_decoration *deco = calloc(1, sizeof(*deco));
|
||||
if (deco == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
deco->wlr_server_decoration = wlr_deco;
|
||||
|
||||
wl_signal_add(&wlr_deco->events.destroy, &deco->destroy);
|
||||
deco->destroy.notify = server_decoration_handle_destroy;
|
||||
|
||||
wl_signal_add(&wlr_deco->events.mode, &deco->mode);
|
||||
deco->mode.notify = server_decoration_handle_mode;
|
||||
}
|
|
@ -1,13 +1,14 @@
|
|||
sway_sources = files(
|
||||
'main.c',
|
||||
'server.c',
|
||||
'commands.c',
|
||||
'config.c',
|
||||
'criteria.c',
|
||||
'debug-tree.c',
|
||||
'decoration.c',
|
||||
'ipc-json.c',
|
||||
'ipc-server.c',
|
||||
'main.c',
|
||||
'security.c',
|
||||
'server.c',
|
||||
'swaynag.c',
|
||||
|
||||
'desktop/desktop.c',
|
||||
|
|
|
@ -109,11 +109,14 @@ bool server_init(struct sway_server *server) {
|
|||
}
|
||||
#endif
|
||||
|
||||
// TODO: Integration with sway borders
|
||||
struct wlr_server_decoration_manager *deco_manager =
|
||||
server->server_decoration_manager =
|
||||
wlr_server_decoration_manager_create(server->wl_display);
|
||||
wlr_server_decoration_manager_set_default_mode(
|
||||
deco_manager, WLR_SERVER_DECORATION_MANAGER_MODE_SERVER);
|
||||
server->server_decoration_manager,
|
||||
WLR_SERVER_DECORATION_MANAGER_MODE_SERVER);
|
||||
wl_signal_add(&server->server_decoration_manager->events.new_decoration,
|
||||
&server->server_decoration);
|
||||
server->server_decoration.notify = handle_server_decoration;
|
||||
|
||||
wlr_linux_dmabuf_v1_create(server->wl_display, renderer);
|
||||
wlr_export_dmabuf_manager_v1_create(server->wl_display);
|
||||
|
|
Loading…
Reference in a new issue