summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2015-12-18 08:49:04 -0500
committerLibravatar Drew DeVault <sir@cmpwn.com>2015-12-18 08:49:04 -0500
commit7558a274faf46c24449e03d53e01c0cf94a13c78 (patch)
tree043576061b89d25ec7c3837987a3ce520dd9f623
parentMerge pull request #356 from sce/output_vs_workspace_size (diff)
downloadsway-7558a274faf46c24449e03d53e01c0cf94a13c78.tar.gz
sway-7558a274faf46c24449e03d53e01c0cf94a13c78.tar.zst
sway-7558a274faf46c24449e03d53e01c0cf94a13c78.zip
Add shims for swaylock on compositor
-rw-r--r--include/extensions.h2
-rw-r--r--sway/extensions.c55
-rw-r--r--swaylock/main.c14
3 files changed, 59 insertions, 12 deletions
diff --git a/include/extensions.h b/include/extensions.h
index c677798f..311ead1d 100644
--- a/include/extensions.h
+++ b/include/extensions.h
@@ -21,6 +21,8 @@ struct panel_config {
21struct desktop_shell_state { 21struct desktop_shell_state {
22 list_t *backgrounds; 22 list_t *backgrounds;
23 list_t *panels; 23 list_t *panels;
24 list_t *lock_surfaces;
25 bool is_locked;
24 enum desktop_shell_panel_position panel_position; 26 enum desktop_shell_panel_position panel_position;
25 struct wlc_size panel_size; 27 struct wlc_size panel_size;
26}; 28};
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
37void 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
36static void set_background(struct wl_client *client, struct wl_resource *resource, 51static 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
68static void set_lock_surface(struct wl_client *client, struct wl_resource *resource, struct wl_resource *surface) { 83static 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
72static void unlock(struct wl_client *client, struct wl_resource *resource) { 87static 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
91static 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
96static void unlock(struct wl_client *client, struct wl_resource *resource) {
97 sway_log(L_ERROR, "unlock is not currently supported");
98}
99
76static void set_grab_surface(struct wl_client *client, struct wl_resource *resource, struct wl_resource *surface) { 100static 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
89static struct desktop_shell_interface desktop_shell_implementation = { 113static 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
123static struct lock_interface swaylock_implementation = {
124 .set_lock_surface = set_lock_surface,
125 .unlock = unlock
126};
127
99static void desktop_shell_bind(struct wl_client *client, void *data, 128static 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
143static 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
114void register_extensions(void) { 158void 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}
diff --git a/swaylock/main.c b/swaylock/main.c
index c31a4552..fbe2851b 100644
--- a/swaylock/main.c
+++ b/swaylock/main.c
@@ -72,7 +72,6 @@ bool verify_password(char *password) {
72} 72}
73 73
74void notify_key(enum wl_keyboard_key_state state, xkb_keysym_t sym, uint32_t code, uint32_t codepoint) { 74void notify_key(enum wl_keyboard_key_state state, xkb_keysym_t sym, uint32_t code, uint32_t codepoint) {
75 sway_log(L_INFO, "notified of key %c", (char)codepoint);
76 if (state == WL_KEYBOARD_KEY_STATE_PRESSED) { 75 if (state == WL_KEYBOARD_KEY_STATE_PRESSED) {
77 switch (sym) { 76 switch (sym) {
78 case XKB_KEY_Return: 77 case XKB_KEY_Return:
@@ -81,13 +80,12 @@ void notify_key(enum wl_keyboard_key_state state, xkb_keysym_t sym, uint32_t cod
81 } 80 }
82 break; 81 break;
83 default: 82 default:
84 { 83 {
85 int i = strlen(password); 84 int i = strlen(password);
86 password[i] = (char)codepoint; 85 password[i] = (char)codepoint;
87 password[i + 1] = '\0'; 86 password[i + 1] = '\0';
88 sway_log(L_INFO, "pw: %s", password); 87 break;
89 break; 88 }
90 }
91 } 89 }
92 } 90 }
93} 91}