Add initial layer shell skeleton
This commit is contained in:
parent
9070950eec
commit
0c8a64942e
24
include/sway/layers.h
Normal file
24
include/sway/layers.h
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
#ifndef _SWAY_LAYERS_H
|
||||||
|
#define _SWAY_LAYERS_H
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <wlr/types/wlr_box.h>
|
||||||
|
#include <wlr/types/wlr_surface.h>
|
||||||
|
#include <wlr/types/wlr_layer_shell.h>
|
||||||
|
|
||||||
|
struct sway_layer_surface {
|
||||||
|
struct wlr_layer_surface *layer_surface;
|
||||||
|
struct wl_list link;
|
||||||
|
|
||||||
|
struct wl_listener destroy;
|
||||||
|
struct wl_listener map;
|
||||||
|
struct wl_listener unmap;
|
||||||
|
struct wl_listener surface_commit;
|
||||||
|
struct wl_listener output_destroy;
|
||||||
|
struct wl_listener output_mode;
|
||||||
|
struct wl_listener output_transform;
|
||||||
|
|
||||||
|
bool configured;
|
||||||
|
struct wlr_box geo;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -2,6 +2,7 @@
|
||||||
#define _SWAY_OUTPUT_H
|
#define _SWAY_OUTPUT_H
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <wayland-server.h>
|
#include <wayland-server.h>
|
||||||
|
#include <wlr/types/wlr_box.h>
|
||||||
#include <wlr/types/wlr_output.h>
|
#include <wlr/types/wlr_output.h>
|
||||||
|
|
||||||
struct sway_server;
|
struct sway_server;
|
||||||
|
@ -13,6 +14,9 @@ struct sway_output {
|
||||||
struct sway_server *server;
|
struct sway_server *server;
|
||||||
struct timespec last_frame;
|
struct timespec last_frame;
|
||||||
|
|
||||||
|
struct wl_list layers[4]; // sway_layer_surface::link
|
||||||
|
struct wlr_box usable_area;
|
||||||
|
|
||||||
struct wl_listener frame;
|
struct wl_listener frame;
|
||||||
struct wl_listener output_destroy;
|
struct wl_listener output_destroy;
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include <wlr/backend/session.h>
|
#include <wlr/backend/session.h>
|
||||||
#include <wlr/types/wlr_compositor.h>
|
#include <wlr/types/wlr_compositor.h>
|
||||||
#include <wlr/types/wlr_data_device.h>
|
#include <wlr/types/wlr_data_device.h>
|
||||||
|
#include <wlr/types/wlr_layer_shell.h>
|
||||||
#include <wlr/types/wlr_xdg_shell_v6.h>
|
#include <wlr/types/wlr_xdg_shell_v6.h>
|
||||||
#include <wlr/render/wlr_renderer.h>
|
#include <wlr/render/wlr_renderer.h>
|
||||||
// TODO WLR: make Xwayland optional
|
// TODO WLR: make Xwayland optional
|
||||||
|
@ -27,6 +28,9 @@ struct sway_server {
|
||||||
struct wl_listener new_output;
|
struct wl_listener new_output;
|
||||||
struct wl_listener output_frame;
|
struct wl_listener output_frame;
|
||||||
|
|
||||||
|
struct wlr_layer_shell *layer_shell;
|
||||||
|
struct wl_listener layer_shell_surface;
|
||||||
|
|
||||||
struct wlr_xdg_shell_v6 *xdg_shell_v6;
|
struct wlr_xdg_shell_v6 *xdg_shell_v6;
|
||||||
struct wl_listener xdg_shell_v6_surface;
|
struct wl_listener xdg_shell_v6_surface;
|
||||||
|
|
||||||
|
@ -46,6 +50,7 @@ void server_run(struct sway_server *server);
|
||||||
|
|
||||||
void handle_new_output(struct wl_listener *listener, void *data);
|
void handle_new_output(struct wl_listener *listener, void *data);
|
||||||
|
|
||||||
|
void handle_layer_shell_surface(struct wl_listener *listener, void *data);
|
||||||
void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data);
|
void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data);
|
||||||
void handle_xwayland_surface(struct wl_listener *listener, void *data);
|
void handle_xwayland_surface(struct wl_listener *listener, void *data);
|
||||||
void handle_wl_shell_surface(struct wl_listener *listener, void *data);
|
void handle_wl_shell_surface(struct wl_listener *listener, void *data);
|
||||||
|
|
|
@ -14,24 +14,57 @@ wayland_scanner_client = generator(
|
||||||
arguments: ['client-header', '@INPUT@', '@OUTPUT@'],
|
arguments: ['client-header', '@INPUT@', '@OUTPUT@'],
|
||||||
)
|
)
|
||||||
|
|
||||||
protocols = [
|
wayland_scanner_server = generator(
|
||||||
|
wayland_scanner,
|
||||||
|
output: '@BASENAME@-protocol.h',
|
||||||
|
arguments: ['server-header', '@INPUT@', '@OUTPUT@'],
|
||||||
|
)
|
||||||
|
|
||||||
|
client_protocols = [
|
||||||
[wl_protocol_dir, 'stable/xdg-shell/xdg-shell.xml'],
|
[wl_protocol_dir, 'stable/xdg-shell/xdg-shell.xml'],
|
||||||
['wlr-layer-shell-unstable-v1.xml']
|
['wlr-layer-shell-unstable-v1.xml']
|
||||||
]
|
]
|
||||||
|
|
||||||
wl_protos_src = []
|
server_protocols = [
|
||||||
wl_protos_headers = []
|
['wlr-layer-shell-unstable-v1.xml']
|
||||||
|
]
|
||||||
|
|
||||||
foreach p : protocols
|
client_protos_src = []
|
||||||
|
client_protos_headers = []
|
||||||
|
|
||||||
|
server_protos_src = []
|
||||||
|
server_protos_headers = []
|
||||||
|
|
||||||
|
foreach p : client_protocols
|
||||||
xml = join_paths(p)
|
xml = join_paths(p)
|
||||||
wl_protos_src += wayland_scanner_code.process(xml)
|
client_protos_src += wayland_scanner_code.process(xml)
|
||||||
wl_protos_headers += wayland_scanner_client.process(xml)
|
client_protos_headers += wayland_scanner_client.process(xml)
|
||||||
endforeach
|
endforeach
|
||||||
|
|
||||||
lib_wl_protos = static_library('wl_protos', wl_protos_src + wl_protos_headers,
|
foreach p : server_protocols
|
||||||
dependencies: [wayland_client]) # for the include directory
|
xml = join_paths(p)
|
||||||
|
server_protos_src += wayland_scanner_code.process(xml)
|
||||||
|
server_protos_headers += wayland_scanner_server.process(xml)
|
||||||
|
endforeach
|
||||||
|
|
||||||
sway_protos = declare_dependency(
|
lib_client_protos = static_library(
|
||||||
link_with: lib_wl_protos,
|
'client_protos',
|
||||||
sources: wl_protos_headers,
|
client_protos_src + client_protos_headers,
|
||||||
|
dependencies: [wayland_client]
|
||||||
|
) # for the include directory
|
||||||
|
|
||||||
|
client_protos = declare_dependency(
|
||||||
|
link_with: lib_client_protos,
|
||||||
|
sources: client_protos_headers,
|
||||||
|
)
|
||||||
|
|
||||||
|
lib_server_protos = static_library(
|
||||||
|
'server_protos',
|
||||||
|
server_protos_src + server_protos_headers,
|
||||||
|
dependencies: [wayland_client]
|
||||||
|
) # for the include directory
|
||||||
|
|
||||||
|
server_protos = declare_dependency(
|
||||||
|
link_with: lib_server_protos,
|
||||||
|
sources: server_protos_headers,
|
||||||
)
|
)
|
||||||
|
|
96
sway/desktop/layer_shell.c
Normal file
96
sway/desktop/layer_shell.c
Normal file
|
@ -0,0 +1,96 @@
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <wayland-server.h>
|
||||||
|
#include <wlr/util/log.h>
|
||||||
|
#include "sway/layers.h"
|
||||||
|
#include "sway/output.h"
|
||||||
|
#include "sway/server.h"
|
||||||
|
|
||||||
|
static void arrange_layers(struct sway_output *output) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
static void handle_output_destroy(struct wl_listener *listener, void *data) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
static void handle_output_mode(struct wl_listener *listener, void *data) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
static void handle_output_transform(struct wl_listener *listener, void *data) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
static void handle_surface_commit(struct wl_listener *listener, void *data) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
static void handle_destroy(struct wl_listener *listener, void *data) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
static void handle_map(struct wl_listener *listener, void *data) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
static void handle_unmap(struct wl_listener *listener, void *data) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
void handle_layer_shell_surface(struct wl_listener *listener, void *data) {
|
||||||
|
struct wlr_layer_surface *layer_surface = data;
|
||||||
|
struct sway_server *server =
|
||||||
|
wl_container_of(listener, server, layer_shell_surface);
|
||||||
|
wlr_log(L_DEBUG, "new layer surface: namespace %s layer %d anchor %d "
|
||||||
|
"size %dx%d margin %d,%d,%d,%d",
|
||||||
|
layer_surface->namespace, layer_surface->layer, layer_surface->layer,
|
||||||
|
layer_surface->client_pending.desired_width,
|
||||||
|
layer_surface->client_pending.desired_height,
|
||||||
|
layer_surface->client_pending.margin.top,
|
||||||
|
layer_surface->client_pending.margin.right,
|
||||||
|
layer_surface->client_pending.margin.bottom,
|
||||||
|
layer_surface->client_pending.margin.left);
|
||||||
|
|
||||||
|
struct sway_layer_surface *sway_layer =
|
||||||
|
calloc(1, sizeof(struct sway_layer_surface));
|
||||||
|
if (!sway_layer) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
sway_layer->surface_commit.notify = handle_surface_commit;
|
||||||
|
wl_signal_add(&layer_surface->surface->events.commit,
|
||||||
|
&sway_layer->surface_commit);
|
||||||
|
|
||||||
|
sway_layer->output_destroy.notify = handle_output_destroy;
|
||||||
|
wl_signal_add(&layer_surface->output->events.destroy,
|
||||||
|
&sway_layer->output_destroy);
|
||||||
|
|
||||||
|
sway_layer->output_mode.notify = handle_output_mode;
|
||||||
|
wl_signal_add(&layer_surface->output->events.mode,
|
||||||
|
&sway_layer->output_mode);
|
||||||
|
|
||||||
|
sway_layer->output_transform.notify = handle_output_transform;
|
||||||
|
wl_signal_add(&layer_surface->output->events.transform,
|
||||||
|
&sway_layer->output_transform);
|
||||||
|
|
||||||
|
sway_layer->destroy.notify = handle_destroy;
|
||||||
|
wl_signal_add(&layer_surface->events.destroy, &sway_layer->destroy);
|
||||||
|
sway_layer->map.notify = handle_map;
|
||||||
|
wl_signal_add(&layer_surface->events.map, &sway_layer->map);
|
||||||
|
sway_layer->unmap.notify = handle_unmap;
|
||||||
|
wl_signal_add(&layer_surface->events.unmap, &sway_layer->unmap);
|
||||||
|
// TODO: Listen for subsurfaces
|
||||||
|
|
||||||
|
sway_layer->layer_surface = layer_surface;
|
||||||
|
layer_surface->data = sway_layer;
|
||||||
|
|
||||||
|
struct sway_output *output = layer_surface->output->data;
|
||||||
|
wl_list_insert(&output->layers[layer_surface->layer], &sway_layer->link);
|
||||||
|
|
||||||
|
// Temporarily set the layer's current state to client_pending
|
||||||
|
// So that we can easily arrange it
|
||||||
|
struct wlr_layer_surface_state old_state = layer_surface->current;
|
||||||
|
layer_surface->current = layer_surface->client_pending;
|
||||||
|
arrange_layers(output);
|
||||||
|
layer_surface->current = old_state;
|
||||||
|
}
|
|
@ -236,6 +236,7 @@ void handle_new_output(struct wl_listener *listener, void *data) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
output->wlr_output = wlr_output;
|
output->wlr_output = wlr_output;
|
||||||
|
wlr_output->data = output;
|
||||||
output->server = server;
|
output->server = server;
|
||||||
|
|
||||||
if (!wl_list_empty(&wlr_output->modes)) {
|
if (!wl_list_empty(&wlr_output->modes)) {
|
||||||
|
@ -250,6 +251,11 @@ void handle_new_output(struct wl_listener *listener, void *data) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t len = sizeof(output->layers) / sizeof(output->layers[0]);
|
||||||
|
for (size_t i = 0; i < len; ++i) {
|
||||||
|
wl_list_init(&output->layers[i]);
|
||||||
|
}
|
||||||
|
|
||||||
sway_input_manager_configure_xcursor(input_manager);
|
sway_input_manager_configure_xcursor(input_manager);
|
||||||
|
|
||||||
wl_signal_add(&wlr_output->events.frame, &output->frame);
|
wl_signal_add(&wlr_output->events.frame, &output->frame);
|
||||||
|
|
|
@ -46,6 +46,7 @@ sway_sources = files(
|
||||||
'ipc-json.c',
|
'ipc-json.c',
|
||||||
'ipc-server.c',
|
'ipc-server.c',
|
||||||
'desktop/output.c',
|
'desktop/output.c',
|
||||||
|
'desktop/layer_shell.c',
|
||||||
'desktop/wl_shell.c',
|
'desktop/wl_shell.c',
|
||||||
'desktop/xdg_shell_v6.c',
|
'desktop/xdg_shell_v6.c',
|
||||||
'desktop/xwayland.c',
|
'desktop/xwayland.c',
|
||||||
|
@ -57,14 +58,15 @@ sway_sources = files(
|
||||||
)
|
)
|
||||||
|
|
||||||
sway_deps = [
|
sway_deps = [
|
||||||
|
jsonc,
|
||||||
|
libcap,
|
||||||
|
libinput,
|
||||||
|
math,
|
||||||
pcre,
|
pcre,
|
||||||
pixman,
|
pixman,
|
||||||
|
server_protos,
|
||||||
wayland_server,
|
wayland_server,
|
||||||
jsonc,
|
|
||||||
wlroots,
|
wlroots,
|
||||||
libcap,
|
|
||||||
math,
|
|
||||||
libinput,
|
|
||||||
xkbcommon,
|
xkbcommon,
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include <wlr/render/wlr_renderer.h>
|
#include <wlr/render/wlr_renderer.h>
|
||||||
#include <wlr/render/gles2.h>
|
#include <wlr/render/gles2.h>
|
||||||
#include <wlr/types/wlr_compositor.h>
|
#include <wlr/types/wlr_compositor.h>
|
||||||
|
#include <wlr/types/wlr_layer_shell.h>
|
||||||
#include <wlr/types/wlr_wl_shell.h>
|
#include <wlr/types/wlr_wl_shell.h>
|
||||||
// TODO WLR: make Xwayland optional
|
// TODO WLR: make Xwayland optional
|
||||||
#include <wlr/xwayland.h>
|
#include <wlr/xwayland.h>
|
||||||
|
@ -51,6 +52,11 @@ bool server_init(struct sway_server *server) {
|
||||||
server->new_output.notify = handle_new_output;
|
server->new_output.notify = handle_new_output;
|
||||||
wl_signal_add(&server->backend->events.new_output, &server->new_output);
|
wl_signal_add(&server->backend->events.new_output, &server->new_output);
|
||||||
|
|
||||||
|
server->layer_shell = wlr_layer_shell_create(server->wl_display);
|
||||||
|
wl_signal_add(&server->layer_shell->events.new_surface,
|
||||||
|
&server->layer_shell_surface);
|
||||||
|
server->layer_shell_surface.notify = handle_layer_shell_surface;
|
||||||
|
|
||||||
server->xdg_shell_v6 = wlr_xdg_shell_v6_create(server->wl_display);
|
server->xdg_shell_v6 = wlr_xdg_shell_v6_create(server->wl_display);
|
||||||
wl_signal_add(&server->xdg_shell_v6->events.new_surface,
|
wl_signal_add(&server->xdg_shell_v6->events.new_surface,
|
||||||
&server->xdg_shell_v6_surface);
|
&server->xdg_shell_v6_surface);
|
||||||
|
|
|
@ -4,12 +4,12 @@ executable(
|
||||||
include_directories: [sway_inc],
|
include_directories: [sway_inc],
|
||||||
dependencies: [
|
dependencies: [
|
||||||
cairo,
|
cairo,
|
||||||
|
client_protos,
|
||||||
gdk_pixbuf,
|
gdk_pixbuf,
|
||||||
jsonc,
|
jsonc,
|
||||||
math,
|
math,
|
||||||
pango,
|
pango,
|
||||||
pangocairo,
|
pangocairo,
|
||||||
sway_protos,
|
|
||||||
wayland_client,
|
wayland_client,
|
||||||
wlroots,
|
wlroots,
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in a new issue