aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/sway/layers.h24
-rw-r--r--include/sway/output.h4
-rw-r--r--include/sway/server.h5
-rw-r--r--protocols/meson.build55
-rw-r--r--sway/desktop/layer_shell.c96
-rw-r--r--sway/desktop/output.c6
-rw-r--r--sway/meson.build10
-rw-r--r--sway/server.c6
-rw-r--r--swaybg/meson.build2
9 files changed, 192 insertions, 16 deletions
diff --git a/include/sway/layers.h b/include/sway/layers.h
new file mode 100644
index 00000000..73fb7cb8
--- /dev/null
+++ b/include/sway/layers.h
@@ -0,0 +1,24 @@
1#ifndef _SWAY_LAYERS_H
2#define _SWAY_LAYERS_H
3#include <stdbool.h>
4#include <wlr/types/wlr_box.h>
5#include <wlr/types/wlr_surface.h>
6#include <wlr/types/wlr_layer_shell.h>
7
8struct sway_layer_surface {
9 struct wlr_layer_surface *layer_surface;
10 struct wl_list link;
11
12 struct wl_listener destroy;
13 struct wl_listener map;
14 struct wl_listener unmap;
15 struct wl_listener surface_commit;
16 struct wl_listener output_destroy;
17 struct wl_listener output_mode;
18 struct wl_listener output_transform;
19
20 bool configured;
21 struct wlr_box geo;
22};
23
24#endif
diff --git a/include/sway/output.h b/include/sway/output.h
index 95d64705..769d44d0 100644
--- a/include/sway/output.h
+++ b/include/sway/output.h
@@ -2,6 +2,7 @@
2#define _SWAY_OUTPUT_H 2#define _SWAY_OUTPUT_H
3#include <time.h> 3#include <time.h>
4#include <wayland-server.h> 4#include <wayland-server.h>
5#include <wlr/types/wlr_box.h>
5#include <wlr/types/wlr_output.h> 6#include <wlr/types/wlr_output.h>
6 7
7struct sway_server; 8struct sway_server;
@@ -13,6 +14,9 @@ struct sway_output {
13 struct sway_server *server; 14 struct sway_server *server;
14 struct timespec last_frame; 15 struct timespec last_frame;
15 16
17 struct wl_list layers[4]; // sway_layer_surface::link
18 struct wlr_box usable_area;
19
16 struct wl_listener frame; 20 struct wl_listener frame;
17 struct wl_listener output_destroy; 21 struct wl_listener output_destroy;
18}; 22};
diff --git a/include/sway/server.h b/include/sway/server.h
index eb7fa2ff..25eb64fe 100644
--- a/include/sway/server.h
+++ b/include/sway/server.h
@@ -6,6 +6,7 @@
6#include <wlr/backend/session.h> 6#include <wlr/backend/session.h>
7#include <wlr/types/wlr_compositor.h> 7#include <wlr/types/wlr_compositor.h>
8#include <wlr/types/wlr_data_device.h> 8#include <wlr/types/wlr_data_device.h>
9#include <wlr/types/wlr_layer_shell.h>
9#include <wlr/types/wlr_xdg_shell_v6.h> 10#include <wlr/types/wlr_xdg_shell_v6.h>
10#include <wlr/render/wlr_renderer.h> 11#include <wlr/render/wlr_renderer.h>
11// TODO WLR: make Xwayland optional 12// TODO WLR: make Xwayland optional
@@ -27,6 +28,9 @@ struct sway_server {
27 struct wl_listener new_output; 28 struct wl_listener new_output;
28 struct wl_listener output_frame; 29 struct wl_listener output_frame;
29 30
31 struct wlr_layer_shell *layer_shell;
32 struct wl_listener layer_shell_surface;
33
30 struct wlr_xdg_shell_v6 *xdg_shell_v6; 34 struct wlr_xdg_shell_v6 *xdg_shell_v6;
31 struct wl_listener xdg_shell_v6_surface; 35 struct wl_listener xdg_shell_v6_surface;
32 36
@@ -46,6 +50,7 @@ void server_run(struct sway_server *server);
46 50
47void handle_new_output(struct wl_listener *listener, void *data); 51void handle_new_output(struct wl_listener *listener, void *data);
48 52
53void handle_layer_shell_surface(struct wl_listener *listener, void *data);
49void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data); 54void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data);
50void handle_xwayland_surface(struct wl_listener *listener, void *data); 55void handle_xwayland_surface(struct wl_listener *listener, void *data);
51void handle_wl_shell_surface(struct wl_listener *listener, void *data); 56void handle_wl_shell_surface(struct wl_listener *listener, void *data);
diff --git a/protocols/meson.build b/protocols/meson.build
index 1fda600e..3f79e719 100644
--- a/protocols/meson.build
+++ b/protocols/meson.build
@@ -14,24 +14,57 @@ wayland_scanner_client = generator(
14 arguments: ['client-header', '@INPUT@', '@OUTPUT@'], 14 arguments: ['client-header', '@INPUT@', '@OUTPUT@'],
15) 15)
16 16
17protocols = [ 17wayland_scanner_server = generator(
18 wayland_scanner,
19 output: '@BASENAME@-protocol.h',
20 arguments: ['server-header', '@INPUT@', '@OUTPUT@'],
21)
22
23client_protocols = [
18 [wl_protocol_dir, 'stable/xdg-shell/xdg-shell.xml'], 24 [wl_protocol_dir, 'stable/xdg-shell/xdg-shell.xml'],
19 ['wlr-layer-shell-unstable-v1.xml'] 25 ['wlr-layer-shell-unstable-v1.xml']
20] 26]
21 27
22wl_protos_src = [] 28server_protocols = [
23wl_protos_headers = [] 29 ['wlr-layer-shell-unstable-v1.xml']
30]
31
32client_protos_src = []
33client_protos_headers = []
34
35server_protos_src = []
36server_protos_headers = []
24 37
25foreach p : protocols 38foreach p : client_protocols
26 xml = join_paths(p) 39 xml = join_paths(p)
27 wl_protos_src += wayland_scanner_code.process(xml) 40 client_protos_src += wayland_scanner_code.process(xml)
28 wl_protos_headers += wayland_scanner_client.process(xml) 41 client_protos_headers += wayland_scanner_client.process(xml)
29endforeach 42endforeach
30 43
31lib_wl_protos = static_library('wl_protos', wl_protos_src + wl_protos_headers, 44foreach p : server_protocols
32 dependencies: [wayland_client]) # for the include directory 45 xml = join_paths(p)
46 server_protos_src += wayland_scanner_code.process(xml)
47 server_protos_headers += wayland_scanner_server.process(xml)
48endforeach
49
50lib_client_protos = static_library(
51 'client_protos',
52 client_protos_src + client_protos_headers,
53 dependencies: [wayland_client]
54) # for the include directory
55
56client_protos = declare_dependency(
57 link_with: lib_client_protos,
58 sources: client_protos_headers,
59)
60
61lib_server_protos = static_library(
62 'server_protos',
63 server_protos_src + server_protos_headers,
64 dependencies: [wayland_client]
65) # for the include directory
33 66
34sway_protos = declare_dependency( 67server_protos = declare_dependency(
35 link_with: lib_wl_protos, 68 link_with: lib_server_protos,
36 sources: wl_protos_headers, 69 sources: server_protos_headers,
37) 70)
diff --git a/sway/desktop/layer_shell.c b/sway/desktop/layer_shell.c
new file mode 100644
index 00000000..3cf171bd
--- /dev/null
+++ b/sway/desktop/layer_shell.c
@@ -0,0 +1,96 @@
1#include <stdlib.h>
2#include <wayland-server.h>
3#include <wlr/util/log.h>
4#include "sway/layers.h"
5#include "sway/output.h"
6#include "sway/server.h"
7
8static void arrange_layers(struct sway_output *output) {
9 // TODO
10}
11
12static void handle_output_destroy(struct wl_listener *listener, void *data) {
13 // TODO
14}
15
16static void handle_output_mode(struct wl_listener *listener, void *data) {
17 // TODO
18}
19
20static void handle_output_transform(struct wl_listener *listener, void *data) {
21 // TODO
22}
23
24static void handle_surface_commit(struct wl_listener *listener, void *data) {
25 // TODO
26}
27
28static void handle_destroy(struct wl_listener *listener, void *data) {
29 // TODO
30}
31
32static void handle_map(struct wl_listener *listener, void *data) {
33 // TODO
34}
35
36static void handle_unmap(struct wl_listener *listener, void *data) {
37 // TODO
38}
39
40void handle_layer_shell_surface(struct wl_listener *listener, void *data) {
41 struct wlr_layer_surface *layer_surface = data;
42 struct sway_server *server =
43 wl_container_of(listener, server, layer_shell_surface);
44 wlr_log(L_DEBUG, "new layer surface: namespace %s layer %d anchor %d "
45 "size %dx%d margin %d,%d,%d,%d",
46 layer_surface->namespace, layer_surface->layer, layer_surface->layer,
47 layer_surface->client_pending.desired_width,
48 layer_surface->client_pending.desired_height,
49 layer_surface->client_pending.margin.top,
50 layer_surface->client_pending.margin.right,
51 layer_surface->client_pending.margin.bottom,
52 layer_surface->client_pending.margin.left);
53
54 struct sway_layer_surface *sway_layer =
55 calloc(1, sizeof(struct sway_layer_surface));
56 if (!sway_layer) {
57 return;
58 }
59
60 sway_layer->surface_commit.notify = handle_surface_commit;
61 wl_signal_add(&layer_surface->surface->events.commit,
62 &sway_layer->surface_commit);
63
64 sway_layer->output_destroy.notify = handle_output_destroy;
65 wl_signal_add(&layer_surface->output->events.destroy,
66 &sway_layer->output_destroy);
67
68 sway_layer->output_mode.notify = handle_output_mode;
69 wl_signal_add(&layer_surface->output->events.mode,
70 &sway_layer->output_mode);
71
72 sway_layer->output_transform.notify = handle_output_transform;
73 wl_signal_add(&layer_surface->output->events.transform,
74 &sway_layer->output_transform);
75
76 sway_layer->destroy.notify = handle_destroy;
77 wl_signal_add(&layer_surface->events.destroy, &sway_layer->destroy);
78 sway_layer->map.notify = handle_map;
79 wl_signal_add(&layer_surface->events.map, &sway_layer->map);
80 sway_layer->unmap.notify = handle_unmap;
81 wl_signal_add(&layer_surface->events.unmap, &sway_layer->unmap);
82 // TODO: Listen for subsurfaces
83
84 sway_layer->layer_surface = layer_surface;
85 layer_surface->data = sway_layer;
86
87 struct sway_output *output = layer_surface->output->data;
88 wl_list_insert(&output->layers[layer_surface->layer], &sway_layer->link);
89
90 // Temporarily set the layer's current state to client_pending
91 // So that we can easily arrange it
92 struct wlr_layer_surface_state old_state = layer_surface->current;
93 layer_surface->current = layer_surface->client_pending;
94 arrange_layers(output);
95 layer_surface->current = old_state;
96}
diff --git a/sway/desktop/output.c b/sway/desktop/output.c
index 6c990c47..a9aa47a6 100644
--- a/sway/desktop/output.c
+++ b/sway/desktop/output.c
@@ -236,6 +236,7 @@ void handle_new_output(struct wl_listener *listener, void *data) {
236 return; 236 return;
237 } 237 }
238 output->wlr_output = wlr_output; 238 output->wlr_output = wlr_output;
239 wlr_output->data = output;
239 output->server = server; 240 output->server = server;
240 241
241 if (!wl_list_empty(&wlr_output->modes)) { 242 if (!wl_list_empty(&wlr_output->modes)) {
@@ -250,6 +251,11 @@ void handle_new_output(struct wl_listener *listener, void *data) {
250 return; 251 return;
251 } 252 }
252 253
254 size_t len = sizeof(output->layers) / sizeof(output->layers[0]);
255 for (size_t i = 0; i < len; ++i) {
256 wl_list_init(&output->layers[i]);
257 }
258
253 sway_input_manager_configure_xcursor(input_manager); 259 sway_input_manager_configure_xcursor(input_manager);
254 260
255 wl_signal_add(&wlr_output->events.frame, &output->frame); 261 wl_signal_add(&wlr_output->events.frame, &output->frame);
diff --git a/sway/meson.build b/sway/meson.build
index 26e56ad2..8bddb11b 100644
--- a/sway/meson.build
+++ b/sway/meson.build
@@ -46,6 +46,7 @@ sway_sources = files(
46 'ipc-json.c', 46 'ipc-json.c',
47 'ipc-server.c', 47 'ipc-server.c',
48 'desktop/output.c', 48 'desktop/output.c',
49 'desktop/layer_shell.c',
49 'desktop/wl_shell.c', 50 'desktop/wl_shell.c',
50 'desktop/xdg_shell_v6.c', 51 'desktop/xdg_shell_v6.c',
51 'desktop/xwayland.c', 52 'desktop/xwayland.c',
@@ -57,14 +58,15 @@ sway_sources = files(
57) 58)
58 59
59sway_deps = [ 60sway_deps = [
61 jsonc,
62 libcap,
63 libinput,
64 math,
60 pcre, 65 pcre,
61 pixman, 66 pixman,
67 server_protos,
62 wayland_server, 68 wayland_server,
63 jsonc,
64 wlroots, 69 wlroots,
65 libcap,
66 math,
67 libinput,
68 xkbcommon, 70 xkbcommon,
69] 71]
70 72
diff --git a/sway/server.c b/sway/server.c
index ca08d7fb..92f72f13 100644
--- a/sway/server.c
+++ b/sway/server.c
@@ -7,6 +7,7 @@
7#include <wlr/render/wlr_renderer.h> 7#include <wlr/render/wlr_renderer.h>
8#include <wlr/render/gles2.h> 8#include <wlr/render/gles2.h>
9#include <wlr/types/wlr_compositor.h> 9#include <wlr/types/wlr_compositor.h>
10#include <wlr/types/wlr_layer_shell.h>
10#include <wlr/types/wlr_wl_shell.h> 11#include <wlr/types/wlr_wl_shell.h>
11// TODO WLR: make Xwayland optional 12// TODO WLR: make Xwayland optional
12#include <wlr/xwayland.h> 13#include <wlr/xwayland.h>
@@ -51,6 +52,11 @@ bool server_init(struct sway_server *server) {
51 server->new_output.notify = handle_new_output; 52 server->new_output.notify = handle_new_output;
52 wl_signal_add(&server->backend->events.new_output, &server->new_output); 53 wl_signal_add(&server->backend->events.new_output, &server->new_output);
53 54
55 server->layer_shell = wlr_layer_shell_create(server->wl_display);
56 wl_signal_add(&server->layer_shell->events.new_surface,
57 &server->layer_shell_surface);
58 server->layer_shell_surface.notify = handle_layer_shell_surface;
59
54 server->xdg_shell_v6 = wlr_xdg_shell_v6_create(server->wl_display); 60 server->xdg_shell_v6 = wlr_xdg_shell_v6_create(server->wl_display);
55 wl_signal_add(&server->xdg_shell_v6->events.new_surface, 61 wl_signal_add(&server->xdg_shell_v6->events.new_surface,
56 &server->xdg_shell_v6_surface); 62 &server->xdg_shell_v6_surface);
diff --git a/swaybg/meson.build b/swaybg/meson.build
index 5e10f3c7..8704de6d 100644
--- a/swaybg/meson.build
+++ b/swaybg/meson.build
@@ -4,12 +4,12 @@ executable(
4 include_directories: [sway_inc], 4 include_directories: [sway_inc],
5 dependencies: [ 5 dependencies: [
6 cairo, 6 cairo,
7 client_protos,
7 gdk_pixbuf, 8 gdk_pixbuf,
8 jsonc, 9 jsonc,
9 math, 10 math,
10 pango, 11 pango,
11 pangocairo, 12 pangocairo,
12 sway_protos,
13 wayland_client, 13 wayland_client,
14 wlroots, 14 wlroots,
15 ], 15 ],