mirror of
https://github.com/labwc/labwc.git
synced 2026-03-02 01:40:24 -05:00
Decorations: minor refactoring, no logical changes intended
This commit is contained in:
parent
35e71ada82
commit
5ee2ec7fff
4 changed files with 55 additions and 35 deletions
9
include/decorations.h
Normal file
9
include/decorations.h
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||||
|
#ifndef __LAB_DECORATIONS_H
|
||||||
|
#define __LAB_DECORATIONS_H
|
||||||
|
|
||||||
|
struct server;
|
||||||
|
|
||||||
|
void xdg_server_decoration_init(struct server *server);
|
||||||
|
|
||||||
|
#endif /* __LAB_DECORATIONS_H */
|
||||||
|
|
@ -38,7 +38,6 @@
|
||||||
#include <wlr/types/wlr_subcompositor.h>
|
#include <wlr/types/wlr_subcompositor.h>
|
||||||
#include <wlr/types/wlr_xcursor_manager.h>
|
#include <wlr/types/wlr_xcursor_manager.h>
|
||||||
#include <wlr/types/wlr_xdg_activation_v1.h>
|
#include <wlr/types/wlr_xdg_activation_v1.h>
|
||||||
#include <wlr/types/wlr_xdg_decoration_v1.h>
|
|
||||||
#include <wlr/types/wlr_xdg_shell.h>
|
#include <wlr/types/wlr_xdg_shell.h>
|
||||||
#include <wlr/types/wlr_drm_lease_v1.h>
|
#include <wlr/types/wlr_drm_lease_v1.h>
|
||||||
#include <wlr/types/wlr_virtual_pointer_v1.h>
|
#include <wlr/types/wlr_virtual_pointer_v1.h>
|
||||||
|
|
@ -349,8 +348,6 @@ struct idle_inhibitor {
|
||||||
|
|
||||||
void xdg_popup_create(struct view *view, struct wlr_xdg_popup *wlr_popup);
|
void xdg_popup_create(struct view *view, struct wlr_xdg_popup *wlr_popup);
|
||||||
|
|
||||||
void xdg_toplevel_decoration(struct wl_listener *listener, void *data);
|
|
||||||
|
|
||||||
void xdg_activation_handle_request(struct wl_listener *listener, void *data);
|
void xdg_activation_handle_request(struct wl_listener *listener, void *data);
|
||||||
|
|
||||||
void xdg_surface_new(struct wl_listener *listener, void *data);
|
void xdg_surface_new(struct wl_listener *listener, void *data);
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,12 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0-only
|
// SPDX-License-Identifier: GPL-2.0-only
|
||||||
|
#include <wlr/types/wlr_xdg_decoration_v1.h>
|
||||||
#include "common/mem.h"
|
#include "common/mem.h"
|
||||||
|
#include "decorations.h"
|
||||||
#include "labwc.h"
|
#include "labwc.h"
|
||||||
#include "view.h"
|
#include "view.h"
|
||||||
|
|
||||||
struct xdg_deco {
|
struct xdg_deco {
|
||||||
struct wlr_xdg_toplevel_decoration_v1 *wlr_decoration;
|
struct wlr_xdg_toplevel_decoration_v1 *wlr_xdg_decoration;
|
||||||
struct server *server;
|
|
||||||
struct view *view;
|
struct view *view;
|
||||||
struct wl_listener destroy;
|
struct wl_listener destroy;
|
||||||
struct wl_listener request_mode;
|
struct wl_listener request_mode;
|
||||||
|
|
@ -14,8 +15,7 @@ struct xdg_deco {
|
||||||
static void
|
static void
|
||||||
xdg_deco_destroy(struct wl_listener *listener, void *data)
|
xdg_deco_destroy(struct wl_listener *listener, void *data)
|
||||||
{
|
{
|
||||||
struct xdg_deco *xdg_deco =
|
struct xdg_deco *xdg_deco = wl_container_of(listener, xdg_deco, destroy);
|
||||||
wl_container_of(listener, xdg_deco, destroy);
|
|
||||||
wl_list_remove(&xdg_deco->destroy.link);
|
wl_list_remove(&xdg_deco->destroy.link);
|
||||||
wl_list_remove(&xdg_deco->request_mode.link);
|
wl_list_remove(&xdg_deco->request_mode.link);
|
||||||
free(xdg_deco);
|
free(xdg_deco);
|
||||||
|
|
@ -26,7 +26,7 @@ xdg_deco_request_mode(struct wl_listener *listener, void *data)
|
||||||
{
|
{
|
||||||
struct xdg_deco *xdg_deco = wl_container_of(listener, xdg_deco, request_mode);
|
struct xdg_deco *xdg_deco = wl_container_of(listener, xdg_deco, request_mode);
|
||||||
enum wlr_xdg_toplevel_decoration_v1_mode client_mode =
|
enum wlr_xdg_toplevel_decoration_v1_mode client_mode =
|
||||||
xdg_deco->wlr_decoration->requested_mode;
|
xdg_deco->wlr_xdg_decoration->requested_mode;
|
||||||
|
|
||||||
switch (client_mode) {
|
switch (client_mode) {
|
||||||
case WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE:
|
case WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE:
|
||||||
|
|
@ -42,30 +42,52 @@ xdg_deco_request_mode(struct wl_listener *listener, void *data)
|
||||||
: WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE;
|
: WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
wlr_log(WLR_ERROR, "Unspecified decoration variant requested: %u",
|
wlr_log(WLR_ERROR, "Unspecified xdg decoration variant "
|
||||||
client_mode);
|
"requested: %u", client_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_xdg_toplevel_decoration_v1_set_mode(xdg_deco->wlr_decoration, client_mode);
|
wlr_xdg_toplevel_decoration_v1_set_mode(xdg_deco->wlr_xdg_decoration,
|
||||||
|
client_mode);
|
||||||
view_set_decorations(xdg_deco->view,
|
view_set_decorations(xdg_deco->view,
|
||||||
client_mode == WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
|
client_mode == WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
xdg_toplevel_decoration(struct wl_listener *listener, void *data)
|
xdg_toplevel_decoration(struct wl_listener *listener, void *data)
|
||||||
{
|
{
|
||||||
struct server *server =
|
struct wlr_xdg_toplevel_decoration_v1 *wlr_xdg_decoration = data;
|
||||||
wl_container_of(listener, server, xdg_toplevel_decoration);
|
struct wlr_xdg_surface *xdg_surface = wlr_xdg_decoration->surface;
|
||||||
struct wlr_xdg_toplevel_decoration_v1 *wlr_decoration = data;
|
if (!xdg_surface || !xdg_surface->data) {
|
||||||
struct xdg_deco *xdg_deco = znew(*xdg_deco);
|
wlr_log(WLR_ERROR,
|
||||||
xdg_deco->wlr_decoration = wlr_decoration;
|
"Invalid surface supplied for xdg decorations");
|
||||||
xdg_deco->server = server;
|
return;
|
||||||
xdg_deco->view = wlr_decoration->surface->data;
|
}
|
||||||
xdg_deco->destroy.notify = xdg_deco_destroy;
|
|
||||||
wl_signal_add(&wlr_decoration->events.destroy, &xdg_deco->destroy);
|
|
||||||
xdg_deco->request_mode.notify = xdg_deco_request_mode;
|
|
||||||
wl_signal_add(&wlr_decoration->events.request_mode,
|
|
||||||
&xdg_deco->request_mode);
|
|
||||||
|
|
||||||
xdg_deco_request_mode(&xdg_deco->request_mode, wlr_decoration);
|
struct xdg_deco *xdg_deco = znew(*xdg_deco);
|
||||||
|
xdg_deco->wlr_xdg_decoration = wlr_xdg_decoration;
|
||||||
|
xdg_deco->view = (struct view *)xdg_surface->data;
|
||||||
|
|
||||||
|
wl_signal_add(&wlr_xdg_decoration->events.destroy, &xdg_deco->destroy);
|
||||||
|
xdg_deco->destroy.notify = xdg_deco_destroy;
|
||||||
|
|
||||||
|
wl_signal_add(&wlr_xdg_decoration->events.request_mode,
|
||||||
|
&xdg_deco->request_mode);
|
||||||
|
xdg_deco->request_mode.notify = xdg_deco_request_mode;
|
||||||
|
|
||||||
|
xdg_deco_request_mode(&xdg_deco->request_mode, wlr_xdg_decoration);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
xdg_server_decoration_init(struct server *server)
|
||||||
|
{
|
||||||
|
struct wlr_xdg_decoration_manager_v1 *xdg_deco_mgr = NULL;
|
||||||
|
xdg_deco_mgr = wlr_xdg_decoration_manager_v1_create(server->wl_display);
|
||||||
|
if (!xdg_deco_mgr) {
|
||||||
|
wlr_log(WLR_ERROR, "unable to create the XDG deco manager");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
wl_signal_add(&xdg_deco_mgr->events.new_toplevel_decoration,
|
||||||
|
&server->xdg_toplevel_decoration);
|
||||||
|
server->xdg_toplevel_decoration.notify = xdg_toplevel_decoration;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
12
src/server.c
12
src/server.c
|
|
@ -18,6 +18,7 @@
|
||||||
#include "drm-lease-v1-protocol.h"
|
#include "drm-lease-v1-protocol.h"
|
||||||
#include "config/rcxml.h"
|
#include "config/rcxml.h"
|
||||||
#include "config/session.h"
|
#include "config/session.h"
|
||||||
|
#include "decorations.h"
|
||||||
#include "labwc.h"
|
#include "labwc.h"
|
||||||
#include "layers.h"
|
#include "layers.h"
|
||||||
#include "menu/menu.h"
|
#include "menu/menu.h"
|
||||||
|
|
@ -310,16 +311,7 @@ server_init(struct server *server)
|
||||||
&server->new_xdg_surface);
|
&server->new_xdg_surface);
|
||||||
|
|
||||||
/* Disable CSD */
|
/* Disable CSD */
|
||||||
struct wlr_xdg_decoration_manager_v1 *xdg_deco_mgr = NULL;
|
xdg_server_decoration_init(server);
|
||||||
xdg_deco_mgr = wlr_xdg_decoration_manager_v1_create(server->wl_display);
|
|
||||||
if (!xdg_deco_mgr) {
|
|
||||||
wlr_log(WLR_ERROR, "unable to create the XDG deco manager");
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
wl_signal_add(&xdg_deco_mgr->events.new_toplevel_decoration,
|
|
||||||
&server->xdg_toplevel_decoration);
|
|
||||||
server->xdg_toplevel_decoration.notify = xdg_toplevel_decoration;
|
|
||||||
|
|
||||||
struct wlr_server_decoration_manager *deco_mgr = NULL;
|
struct wlr_server_decoration_manager *deco_mgr = NULL;
|
||||||
deco_mgr = wlr_server_decoration_manager_create(server->wl_display);
|
deco_mgr = wlr_server_decoration_manager_create(server->wl_display);
|
||||||
if (!deco_mgr) {
|
if (!deco_mgr) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue