Add server side decoration to the window
This commit is contained in:
parent
11fbabb326
commit
2c4e03cc82
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
.idea/
|
||||
surface
|
||||
xdg-shell*
|
||||
xdg-decoration*
|
||||
|
14
Makefile
14
Makefile
@ -4,9 +4,10 @@ WAYLAND_SCANNER = $(shell pkg-config --variable=wayland_scanner wayland-scanner)
|
||||
CFLAGS ?= -std=c11 -Wall -Wextra -Werror -Wno-unused-parameter -ggdb
|
||||
|
||||
XDG_SHELL_PROTOCOL = $(WAYLAND_PROTOCOLS_DIR)/stable/xdg-shell/xdg-shell.xml
|
||||
XDG_DECORATION_PROTOCOL = $(WAYLAND_PROTOCOLS_DIR)/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml
|
||||
|
||||
HEADERS=xdg-shell-client-protocol.h
|
||||
SOURCES=surface.c xdg-shell-protocol.c
|
||||
HEADERS=xdg-shell-client-protocol.h xdg-decoration-client-protocol.h
|
||||
SOURCES=surface.c xdg-shell-protocol.c xdg-decoration-protocol.c
|
||||
|
||||
all: surface
|
||||
|
||||
@ -19,7 +20,14 @@ xdg-shell-client-protocol.h:
|
||||
xdg-shell-protocol.c:
|
||||
$(WAYLAND_SCANNER) private-code $(XDG_SHELL_PROTOCOL) xdg-shell-protocol.c
|
||||
|
||||
xdg-decoration-client-protocol.h:
|
||||
$(WAYLAND_SCANNER) client-header $(XDG_DECORATION_PROTOCOL) xdg-decoration-client-protocol.h
|
||||
|
||||
xdg-decoration-protocol.c:
|
||||
$(WAYLAND_SCANNER) private-code $(XDG_DECORATION_PROTOCOL) xdg-decoration-protocol.c
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
$(RM) surface xdg-shell-protocol.c xdg-shell-client-protocol.h
|
||||
$(RM) surface \
|
||||
xdg-shell-protocol.c xdg-shell-client-protocol.h \
|
||||
xdg-decoration-protocol.c xdg-decoration-client-protocol.h
|
17
surface.c
17
surface.c
@ -6,6 +6,7 @@
|
||||
//#include <wayland-server.h>
|
||||
#include <wayland-client-protocol.h>
|
||||
#include "xdg-shell-client-protocol.h"
|
||||
#include "xdg-decoration-client-protocol.h"
|
||||
#include <fcntl.h>
|
||||
#include <sys/mman.h>
|
||||
#include <errno.h>
|
||||
@ -20,6 +21,7 @@ struct client_state {
|
||||
struct wl_compositor *wl_compositor;
|
||||
struct wl_shm *wl_shm;
|
||||
struct xdg_wm_base *xdg_wm_base;
|
||||
struct zxdg_decoration_manager_v1 *zxdg_decoration_manager_v1;
|
||||
/* Objects */
|
||||
struct wl_buffer *wl_buffer;
|
||||
struct wl_surface *wl_surface;
|
||||
@ -202,6 +204,9 @@ global_registry_handler(void *data, struct wl_registry *registry, uint32_t id,
|
||||
state->xdg_wm_base = wl_registry_bind(registry, id,
|
||||
&xdg_wm_base_interface, 1);
|
||||
xdg_wm_base_add_listener(state->xdg_wm_base, &xdg_wm_base_listener, state);
|
||||
} else if (strcmp(interface, zxdg_decoration_manager_v1_interface.name) == 0) {
|
||||
state->zxdg_decoration_manager_v1 = wl_registry_bind(registry, id,
|
||||
&zxdg_decoration_manager_v1_interface, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -304,6 +309,18 @@ int main(int argc, char **argv) {
|
||||
} else {
|
||||
fprintf(stderr, "got xdg_toplevel\n");
|
||||
}
|
||||
|
||||
if (state.zxdg_decoration_manager_v1 != NULL){
|
||||
struct zxdg_toplevel_decoration_v1 *decoration = \
|
||||
zxdg_decoration_manager_v1_get_toplevel_decoration(state.zxdg_decoration_manager_v1,
|
||||
state.xdg_toplevel);
|
||||
zxdg_toplevel_decoration_v1_set_mode(decoration, ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
|
||||
fprintf(stderr, "Using serverside decorations");
|
||||
} else {
|
||||
fprintf(stderr, "Serverside decoration not available");
|
||||
}
|
||||
|
||||
|
||||
xdg_toplevel_add_listener(state.xdg_toplevel, &xdg_toplevel_listener, &state);
|
||||
xdg_toplevel_set_title(state.xdg_toplevel, "A surface");
|
||||
wl_surface_commit(state.wl_surface);
|
||||
|
Loading…
Reference in New Issue
Block a user