diff options
-rw-r--r-- | include/client/registry.h | 2 | ||||
-rw-r--r-- | swaybg/main.c | 1 | ||||
-rw-r--r-- | swaylock/main.c | 31 | ||||
-rw-r--r-- | wayland/registry.c | 3 |
4 files changed, 34 insertions, 3 deletions
diff --git a/include/client/registry.h b/include/client/registry.h index 68a9bc02..a6901990 100644 --- a/include/client/registry.h +++ b/include/client/registry.h | |||
@@ -3,6 +3,7 @@ | |||
3 | 3 | ||
4 | #include <wayland-client.h> | 4 | #include <wayland-client.h> |
5 | #include "wayland-desktop-shell-client-protocol.h" | 5 | #include "wayland-desktop-shell-client-protocol.h" |
6 | #include "wayland-swaylock-client-protocol.h" | ||
6 | #include "list.h" | 7 | #include "list.h" |
7 | 8 | ||
8 | struct output_state { | 9 | struct output_state { |
@@ -19,6 +20,7 @@ struct registry { | |||
19 | struct wl_shell *shell; | 20 | struct wl_shell *shell; |
20 | struct wl_shm *shm; | 21 | struct wl_shm *shm; |
21 | struct desktop_shell *desktop_shell; | 22 | struct desktop_shell *desktop_shell; |
23 | struct lock *swaylock; | ||
22 | list_t *outputs; | 24 | list_t *outputs; |
23 | }; | 25 | }; |
24 | 26 | ||
diff --git a/swaybg/main.c b/swaybg/main.c index 6b81d97c..0bb83396 100644 --- a/swaybg/main.c +++ b/swaybg/main.c | |||
@@ -11,7 +11,6 @@ | |||
11 | #include "list.h" | 11 | #include "list.h" |
12 | 12 | ||
13 | list_t *surfaces; | 13 | list_t *surfaces; |
14 | |||
15 | struct registry *registry; | 14 | struct registry *registry; |
16 | 15 | ||
17 | enum scaling_mode { | 16 | enum scaling_mode { |
diff --git a/swaylock/main.c b/swaylock/main.c index 4f77dfec..a7a15533 100644 --- a/swaylock/main.c +++ b/swaylock/main.c | |||
@@ -1,16 +1,43 @@ | |||
1 | #include "wayland-desktop-shell-client-protocol.h" | 1 | #include "wayland-swaylock-client-protocol.h" |
2 | #include <stdio.h> | 2 | #include <stdio.h> |
3 | #include <stdlib.h> | 3 | #include <stdlib.h> |
4 | #include "client/window.h" | 4 | #include "client/window.h" |
5 | #include "client/registry.h" | 5 | #include "client/registry.h" |
6 | #include "log.h" | 6 | #include "log.h" |
7 | 7 | ||
8 | list_t *surfaces; | ||
9 | struct registry *registry; | ||
10 | |||
11 | enum scaling_mode { | ||
12 | SCALING_MODE_STRETCH, | ||
13 | SCALING_MODE_FILL, | ||
14 | SCALING_MODE_FIT, | ||
15 | SCALING_MODE_CENTER, | ||
16 | SCALING_MODE_TILE, | ||
17 | }; | ||
18 | |||
8 | void sway_terminate(void) { | 19 | void sway_terminate(void) { |
9 | exit(EXIT_FAILURE); | 20 | exit(EXIT_FAILURE); |
10 | } | 21 | } |
11 | 22 | ||
12 | int main(int argc, char **argv) { | 23 | int main(int argc, char **argv) { |
13 | init_log(L_INFO); | 24 | init_log(L_INFO); |
14 | sway_log(L_INFO, "Hello world"); | 25 | surfaces = create_list(); |
26 | registry = registry_poll(); | ||
27 | |||
28 | if (!registry->swaylock) { | ||
29 | sway_abort("swaylock requires the compositor to support the swaylock extension."); | ||
30 | } | ||
31 | |||
32 | int i; | ||
33 | for (i = 0; i < registry->outputs->length; ++i) { | ||
34 | struct output_state *output = registry->outputs->items[i]; | ||
35 | struct window *window = window_setup(registry, output->width, output->height, false); | ||
36 | if (!window) { | ||
37 | sway_abort("Failed to create surfaces."); | ||
38 | } | ||
39 | lock_set_lock_surface(registry->swaylock, output->output, window->surface); | ||
40 | list_add(surfaces, window); | ||
41 | } | ||
15 | return 0; | 42 | return 0; |
16 | } | 43 | } |
diff --git a/wayland/registry.c b/wayland/registry.c index 3c869d25..11e6e51d 100644 --- a/wayland/registry.c +++ b/wayland/registry.c | |||
@@ -2,6 +2,7 @@ | |||
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | #include <string.h> | 3 | #include <string.h> |
4 | #include "wayland-desktop-shell-client-protocol.h" | 4 | #include "wayland-desktop-shell-client-protocol.h" |
5 | #include "wayland-swaylock-client-protocol.h" | ||
5 | #include "client/registry.h" | 6 | #include "client/registry.h" |
6 | #include "stringop.h" | 7 | #include "stringop.h" |
7 | #include "log.h" | 8 | #include "log.h" |
@@ -58,6 +59,8 @@ static void registry_global(void *data, struct wl_registry *registry, | |||
58 | list_add(reg->outputs, ostate); | 59 | list_add(reg->outputs, ostate); |
59 | } else if (strcmp(interface, desktop_shell_interface.name) == 0) { | 60 | } else if (strcmp(interface, desktop_shell_interface.name) == 0) { |
60 | reg->desktop_shell = wl_registry_bind(registry, name, &desktop_shell_interface, version); | 61 | reg->desktop_shell = wl_registry_bind(registry, name, &desktop_shell_interface, version); |
62 | } else if (strcmp(interface, lock_interface.name) == 0) { | ||
63 | reg->swaylock = wl_registry_bind(registry, name, &lock_interface, version); | ||
61 | } | 64 | } |
62 | } | 65 | } |
63 | 66 | ||