diff options
author | Drew DeVault <sir@cmpwn.com> | 2015-12-18 08:49:04 -0500 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2015-12-18 08:49:04 -0500 |
commit | 7558a274faf46c24449e03d53e01c0cf94a13c78 (patch) | |
tree | 043576061b89d25ec7c3837987a3ce520dd9f623 /sway | |
parent | Merge pull request #356 from sce/output_vs_workspace_size (diff) | |
download | sway-7558a274faf46c24449e03d53e01c0cf94a13c78.tar.gz sway-7558a274faf46c24449e03d53e01c0cf94a13c78.tar.zst sway-7558a274faf46c24449e03d53e01c0cf94a13c78.zip |
Add shims for swaylock on compositor
Diffstat (limited to 'sway')
-rw-r--r-- | sway/extensions.c | 55 |
1 files changed, 51 insertions, 4 deletions
diff --git a/sway/extensions.c b/sway/extensions.c index 18621015..7769f86e 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 "wayland-swaylock-server-protocol.h" | ||
5 | #include "layout.h" | 6 | #include "layout.h" |
6 | #include "log.h" | 7 | #include "log.h" |
7 | #include "extensions.h" | 8 | #include "extensions.h" |
@@ -33,6 +34,20 @@ void panel_surface_destructor(struct wl_resource *resource) { | |||
33 | } | 34 | } |
34 | } | 35 | } |
35 | 36 | ||
37 | void lock_surface_destructor(struct wl_resource *resource) { | ||
38 | sway_log(L_DEBUG, "Lock surface killed"); | ||
39 | int i; | ||
40 | for (i = 0; i < desktop_shell.lock_surfaces->length; ++i) { | ||
41 | struct wl_resource *surface = desktop_shell.lock_surfaces->items[i]; | ||
42 | if (surface == resource) { | ||
43 | list_del(desktop_shell.lock_surfaces, i); | ||
44 | arrange_windows(&root_container, -1, -1); | ||
45 | desktop_shell.is_locked = false; | ||
46 | break; | ||
47 | } | ||
48 | } | ||
49 | } | ||
50 | |||
36 | static void set_background(struct wl_client *client, struct wl_resource *resource, | 51 | static void set_background(struct wl_client *client, struct wl_resource *resource, |
37 | struct wl_resource *_output, struct wl_resource *surface) { | 52 | struct wl_resource *_output, struct wl_resource *surface) { |
38 | wlc_handle output = wlc_handle_from_wl_output_resource(_output); | 53 | wlc_handle output = wlc_handle_from_wl_output_resource(_output); |
@@ -65,14 +80,23 @@ static void set_panel(struct wl_client *client, struct wl_resource *resource, | |||
65 | arrange_windows(&root_container, -1, -1); | 80 | arrange_windows(&root_container, -1, -1); |
66 | } | 81 | } |
67 | 82 | ||
68 | static void set_lock_surface(struct wl_client *client, struct wl_resource *resource, struct wl_resource *surface) { | 83 | static void desktop_set_lock_surface(struct wl_client *client, struct wl_resource *resource, struct wl_resource *surface) { |
69 | sway_log(L_ERROR, "desktop_set_lock_surface is not currently supported"); | 84 | sway_log(L_ERROR, "desktop_set_lock_surface is not currently supported"); |
70 | } | 85 | } |
71 | 86 | ||
72 | static void unlock(struct wl_client *client, struct wl_resource *resource) { | 87 | static void desktop_unlock(struct wl_client *client, struct wl_resource *resource) { |
73 | sway_log(L_ERROR, "desktop_unlock is not currently supported"); | 88 | sway_log(L_ERROR, "desktop_unlock is not currently supported"); |
74 | } | 89 | } |
75 | 90 | ||
91 | static void set_lock_surface(struct wl_client *client, struct wl_resource *resource, | ||
92 | struct wl_resource *output, struct wl_resource *surface) { | ||
93 | sway_log(L_ERROR, "set_lock_surface is not currently supported"); | ||
94 | } | ||
95 | |||
96 | static void unlock(struct wl_client *client, struct wl_resource *resource) { | ||
97 | sway_log(L_ERROR, "unlock is not currently supported"); | ||
98 | } | ||
99 | |||
76 | static void set_grab_surface(struct wl_client *client, struct wl_resource *resource, struct wl_resource *surface) { | 100 | static void set_grab_surface(struct wl_client *client, struct wl_resource *resource, struct wl_resource *surface) { |
77 | sway_log(L_ERROR, "desktop_set_grab_surface is not currently supported"); | 101 | sway_log(L_ERROR, "desktop_set_grab_surface is not currently supported"); |
78 | } | 102 | } |
@@ -89,13 +113,18 @@ static void set_panel_position(struct wl_client *client, struct wl_resource *res | |||
89 | static struct desktop_shell_interface desktop_shell_implementation = { | 113 | static struct desktop_shell_interface desktop_shell_implementation = { |
90 | .set_background = set_background, | 114 | .set_background = set_background, |
91 | .set_panel = set_panel, | 115 | .set_panel = set_panel, |
92 | .set_lock_surface = set_lock_surface, | 116 | .set_lock_surface = desktop_set_lock_surface, |
93 | .unlock = unlock, | 117 | .unlock = desktop_unlock, |
94 | .set_grab_surface = set_grab_surface, | 118 | .set_grab_surface = set_grab_surface, |
95 | .desktop_ready = desktop_ready, | 119 | .desktop_ready = desktop_ready, |
96 | .set_panel_position = set_panel_position | 120 | .set_panel_position = set_panel_position |
97 | }; | 121 | }; |
98 | 122 | ||
123 | static struct lock_interface swaylock_implementation = { | ||
124 | .set_lock_surface = set_lock_surface, | ||
125 | .unlock = unlock | ||
126 | }; | ||
127 | |||
99 | static void desktop_shell_bind(struct wl_client *client, void *data, | 128 | static void desktop_shell_bind(struct wl_client *client, void *data, |
100 | unsigned int version, unsigned int id) { | 129 | unsigned int version, unsigned int id) { |
101 | if (version > 3) { | 130 | if (version > 3) { |
@@ -111,9 +140,27 @@ static void desktop_shell_bind(struct wl_client *client, void *data, | |||
111 | wl_resource_set_implementation(resource, &desktop_shell_implementation, NULL, NULL); | 140 | wl_resource_set_implementation(resource, &desktop_shell_implementation, NULL, NULL); |
112 | } | 141 | } |
113 | 142 | ||
143 | static void swaylock_bind(struct wl_client *client, void *data, | ||
144 | unsigned int version, unsigned int id) { | ||
145 | if (version > 1) { | ||
146 | // Unsupported version | ||
147 | return; | ||
148 | } | ||
149 | |||
150 | struct wl_resource *resource = wl_resource_create(client, &lock_interface, version, id); | ||
151 | if (!resource) { | ||
152 | wl_client_post_no_memory(client); | ||
153 | } | ||
154 | |||
155 | wl_resource_set_implementation(resource, &swaylock_implementation, NULL, NULL); | ||
156 | } | ||
157 | |||
114 | void register_extensions(void) { | 158 | void register_extensions(void) { |
115 | wl_global_create(wlc_get_wl_display(), &desktop_shell_interface, 3, NULL, desktop_shell_bind); | 159 | wl_global_create(wlc_get_wl_display(), &desktop_shell_interface, 3, NULL, desktop_shell_bind); |
116 | desktop_shell.backgrounds = create_list(); | 160 | desktop_shell.backgrounds = create_list(); |
117 | desktop_shell.panels = create_list(); | 161 | desktop_shell.panels = create_list(); |
118 | desktop_shell.panel_position = DESKTOP_SHELL_PANEL_POSITION_BOTTOM; | 162 | desktop_shell.panel_position = DESKTOP_SHELL_PANEL_POSITION_BOTTOM; |
163 | desktop_shell.lock_surfaces = create_list(); | ||
164 | desktop_shell.is_locked = false; | ||
165 | wl_global_create(wlc_get_wl_display(), &lock_interface, 3, NULL, swaylock_bind); | ||
119 | } | 166 | } |