mirror of
https://github.com/wizbright/waybox.git
synced 2025-11-02 09:01:42 -05:00
xdg-decoration support
This commit is contained in:
parent
87c32d58ab
commit
1bf513d9d6
11 changed files with 92 additions and 22 deletions
43
waybox/decoration.c
Normal file
43
waybox/decoration.c
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
#include "decoration.h"
|
||||
|
||||
static void destroy_xdg_toplevel_decoration(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct wb_decoration *decoration = wl_container_of(listener, decoration, toplevel_decoration_destroy);
|
||||
wl_list_remove(&decoration->toplevel_decoration_destroy.link);
|
||||
free(decoration);
|
||||
}
|
||||
|
||||
static void free_xdg_decoration_mode(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct wb_decoration *decoration = wl_container_of(listener, decoration, mode_destroy);
|
||||
wl_list_remove(&decoration->mode_destroy.link);
|
||||
wl_list_remove(&decoration->request_mode.link);
|
||||
}
|
||||
|
||||
static void handle_xdg_decoration_mode(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct wlr_xdg_toplevel_decoration_v1 *toplevel_decoration = data;
|
||||
wlr_xdg_toplevel_decoration_v1_set_mode(toplevel_decoration, WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE);
|
||||
}
|
||||
|
||||
static void handle_new_xdg_toplevel_decoration(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct wb_decoration *decoration = (struct wb_decoration *) calloc(1, sizeof(struct wb_decoration));
|
||||
handle_xdg_decoration_mode(&decoration->request_mode, data);
|
||||
struct wb_server *server = wl_container_of(listener, server, new_xdg_decoration);
|
||||
decoration->server = server;
|
||||
struct wlr_xdg_toplevel_decoration_v1 *toplevel_decoration = data;
|
||||
decoration->toplevel_decoration_destroy.notify = destroy_xdg_toplevel_decoration;
|
||||
wl_signal_add(&toplevel_decoration->manager->events.destroy, &decoration->toplevel_decoration_destroy);
|
||||
decoration->request_mode.notify = handle_xdg_decoration_mode;
|
||||
wl_signal_add(&toplevel_decoration->events.request_mode, &decoration->request_mode);
|
||||
decoration->mode_destroy.notify = free_xdg_decoration_mode;
|
||||
wl_signal_add(&toplevel_decoration->events.destroy, &decoration->mode_destroy);
|
||||
}
|
||||
|
||||
void init_xdg_decoration(struct wb_server *server)
|
||||
{
|
||||
struct wlr_xdg_decoration_manager_v1 *decoration = wlr_xdg_decoration_manager_v1_create(server->wl_display);
|
||||
server->new_xdg_decoration.notify = handle_new_xdg_toplevel_decoration;
|
||||
wl_signal_add(&decoration->events.new_toplevel_decoration, &server->new_xdg_decoration);
|
||||
}
|
||||
20
waybox/decoration.h
Normal file
20
waybox/decoration.h
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#ifndef _WB_DECORATION_H
|
||||
#define _WB_DECORATION_H
|
||||
|
||||
#include <wlr/types/wlr_xdg_decoration_v1.h>
|
||||
|
||||
#include "waybox/server.h"
|
||||
|
||||
struct wb_decoration {
|
||||
struct wb_server *server;
|
||||
struct wlr_xdg_decoration_manager_v1 *decoration_manager;
|
||||
struct wlr_xdg_toplevel_decoration_v1 *toplevel_decoration;
|
||||
|
||||
struct wl_listener toplevel_decoration_destroy;
|
||||
struct wl_listener request_mode;
|
||||
struct wl_listener mode_destroy;
|
||||
int yes;
|
||||
};
|
||||
|
||||
void init_xdg_decoration(struct wb_server *server);
|
||||
#endif
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <wayland-server.h>
|
||||
|
||||
#include "waybox/server.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
wb_src = files(
|
||||
'cursor.c',
|
||||
'decoration.c',
|
||||
'main.c',
|
||||
'output.c',
|
||||
'seat.c',
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ bool wb_start_server(struct wb_server* server) {
|
|||
|
||||
wlr_data_device_manager_create(server->wl_display);
|
||||
wl_list_init(&server->views);
|
||||
init_xdg_decoration(server);
|
||||
init_xdg_shell(server);
|
||||
|
||||
return true;
|
||||
|
|
@ -76,6 +77,7 @@ bool wb_start_server(struct wb_server* server) {
|
|||
|
||||
bool wb_terminate(struct wb_server* server) {
|
||||
wb_cursor_destroy(server->cursor);
|
||||
wl_list_remove(&server->new_xdg_decoration.link); /* wb_decoration_destroy */
|
||||
wb_seat_destroy(server->seat);
|
||||
wl_display_destroy_clients(server->wl_display);
|
||||
wl_display_destroy(server->wl_display);
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ static void begin_interactive(struct wb_view *view,
|
|||
struct wb_server *server = view->server;
|
||||
struct wlr_surface *focused_surface =
|
||||
server->seat->seat->pointer_state.focused_surface;
|
||||
if (view->xdg_surface->surface != focused_surface) {
|
||||
if (view->xdg_surface->surface != wlr_surface_get_root_surface(focused_surface)) {
|
||||
/* Deny move/resize requests from unfocused clients. */
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue