diff options
Diffstat (limited to 'sway/desktop/layer_shell.c')
-rw-r--r-- | sway/desktop/layer_shell.c | 96 |
1 files changed, 96 insertions, 0 deletions
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 | |||
8 | static void arrange_layers(struct sway_output *output) { | ||
9 | // TODO | ||
10 | } | ||
11 | |||
12 | static void handle_output_destroy(struct wl_listener *listener, void *data) { | ||
13 | // TODO | ||
14 | } | ||
15 | |||
16 | static void handle_output_mode(struct wl_listener *listener, void *data) { | ||
17 | // TODO | ||
18 | } | ||
19 | |||
20 | static void handle_output_transform(struct wl_listener *listener, void *data) { | ||
21 | // TODO | ||
22 | } | ||
23 | |||
24 | static void handle_surface_commit(struct wl_listener *listener, void *data) { | ||
25 | // TODO | ||
26 | } | ||
27 | |||
28 | static void handle_destroy(struct wl_listener *listener, void *data) { | ||
29 | // TODO | ||
30 | } | ||
31 | |||
32 | static void handle_map(struct wl_listener *listener, void *data) { | ||
33 | // TODO | ||
34 | } | ||
35 | |||
36 | static void handle_unmap(struct wl_listener *listener, void *data) { | ||
37 | // TODO | ||
38 | } | ||
39 | |||
40 | void 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 | } | ||