diff options
author | Drew DeVault <sir@cmpwn.com> | 2015-11-29 12:03:13 -0500 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2015-11-29 12:03:13 -0500 |
commit | e59cffcea2a881f16de3716c6b24d93aceb8c79a (patch) | |
tree | a09447b6eb903573edb598c7b80ac7c3c492dee5 /sway/extensions.c | |
parent | Add swaybar basics (diff) | |
download | sway-e59cffcea2a881f16de3716c6b24d93aceb8c79a.tar.gz sway-e59cffcea2a881f16de3716c6b24d93aceb8c79a.tar.zst sway-e59cffcea2a881f16de3716c6b24d93aceb8c79a.zip |
Support desktop shell panels in compositor
Diffstat (limited to 'sway/extensions.c')
-rw-r--r-- | sway/extensions.c | 51 |
1 files changed, 48 insertions, 3 deletions
diff --git a/sway/extensions.c b/sway/extensions.c index aa51b474..1f8e9a7c 100644 --- a/sway/extensions.c +++ b/sway/extensions.c | |||
@@ -2,6 +2,7 @@ | |||
2 | #include <wlc/wlc.h> | 2 | #include <wlc/wlc.h> |
3 | #include <wlc/wlc-wayland.h> | 3 | #include <wlc/wlc-wayland.h> |
4 | #include "wayland-desktop-shell-server-protocol.h" | 4 | #include "wayland-desktop-shell-server-protocol.h" |
5 | #include "layout.h" | ||
5 | #include "log.h" | 6 | #include "log.h" |
6 | #include "extensions.h" | 7 | #include "extensions.h" |
7 | 8 | ||
@@ -20,13 +21,55 @@ static void set_background(struct wl_client *client, struct wl_resource *resourc | |||
20 | list_add(desktop_shell.backgrounds, config); | 21 | list_add(desktop_shell.backgrounds, config); |
21 | } | 22 | } |
22 | 23 | ||
24 | static void set_panel(struct wl_client *client, struct wl_resource *resource, | ||
25 | struct wl_resource *_output, struct wl_resource *surface) { | ||
26 | wlc_handle output = wlc_handle_from_wl_output_resource(_output); | ||
27 | if (!output) { | ||
28 | return; | ||
29 | } | ||
30 | sway_log(L_DEBUG, "Setting surface %p as panel for output %d", surface, (int)output); | ||
31 | struct panel_config *config = malloc(sizeof(struct panel_config)); | ||
32 | config->output = output; | ||
33 | config->surface = wlc_resource_from_wl_surface_resource(surface); | ||
34 | list_add(desktop_shell.panels, config); | ||
35 | desktop_shell.panel_size = *wlc_surface_get_size(config->surface); | ||
36 | arrange_windows(&root_container, -1, -1); | ||
37 | } | ||
38 | |||
39 | static void set_lock_surface(struct wl_client *client, struct wl_resource *resource, struct wl_resource *surface) { | ||
40 | sway_log(L_ERROR, "desktop_set_lock_surface is not currently supported"); | ||
41 | } | ||
42 | |||
43 | static void unlock(struct wl_client *client, struct wl_resource *resource) { | ||
44 | sway_log(L_ERROR, "desktop_unlock is not currently supported"); | ||
45 | } | ||
46 | |||
47 | static void set_grab_surface(struct wl_client *client, struct wl_resource *resource, struct wl_resource *surface) { | ||
48 | sway_log(L_ERROR, "desktop_set_grab_surface is not currently supported"); | ||
49 | } | ||
50 | |||
51 | static void desktop_ready(struct wl_client *client, struct wl_resource *resource) { | ||
52 | // nop | ||
53 | } | ||
54 | |||
55 | static void set_panel_position(struct wl_client *client, struct wl_resource *resource, uint32_t position) { | ||
56 | desktop_shell.panel_position = position; | ||
57 | arrange_windows(&root_container, -1, -1); | ||
58 | } | ||
59 | |||
23 | static struct desktop_shell_interface desktop_shell_implementation = { | 60 | static struct desktop_shell_interface desktop_shell_implementation = { |
24 | .set_background = set_background | 61 | .set_background = set_background, |
62 | .set_panel = set_panel, | ||
63 | .set_lock_surface = set_lock_surface, | ||
64 | .unlock = unlock, | ||
65 | .set_grab_surface = set_grab_surface, | ||
66 | .desktop_ready = desktop_ready, | ||
67 | .set_panel_position = set_panel_position | ||
25 | }; | 68 | }; |
26 | 69 | ||
27 | static void desktop_shell_bind(struct wl_client *client, void *data, | 70 | static void desktop_shell_bind(struct wl_client *client, void *data, |
28 | unsigned int version, unsigned int id) { | 71 | unsigned int version, unsigned int id) { |
29 | if (version > 1) { | 72 | if (version > 3) { |
30 | // Unsupported version | 73 | // Unsupported version |
31 | return; | 74 | return; |
32 | } | 75 | } |
@@ -40,6 +83,8 @@ static void desktop_shell_bind(struct wl_client *client, void *data, | |||
40 | } | 83 | } |
41 | 84 | ||
42 | void register_extensions(void) { | 85 | void register_extensions(void) { |
43 | wl_global_create(wlc_get_wl_display(), &desktop_shell_interface, 1, NULL, desktop_shell_bind); | 86 | wl_global_create(wlc_get_wl_display(), &desktop_shell_interface, 3, NULL, desktop_shell_bind); |
44 | desktop_shell.backgrounds = create_list(); | 87 | desktop_shell.backgrounds = create_list(); |
88 | desktop_shell.panels = create_list(); | ||
89 | desktop_shell.panel_position = DESKTOP_SHELL_PANEL_POSITION_BOTTOM; | ||
45 | } | 90 | } |