diff options
| -rw-r--r-- | include/extensions.h | 2 | ||||
| -rw-r--r-- | sway/extensions.c | 55 | ||||
| -rw-r--r-- | swaylock/main.c | 14 | 
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 {  struct desktop_shell_state {          list_t *backgrounds;          list_t *panels; +        list_t *lock_surfaces; +        bool is_locked;          enum desktop_shell_panel_position panel_position;          struct wlc_size panel_size;  }; 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 @@  #include <wlc/wlc.h>  #include <wlc/wlc-wayland.h>  #include "wayland-desktop-shell-server-protocol.h" +#include "wayland-swaylock-server-protocol.h"  #include "layout.h"  #include "log.h"  #include "extensions.h" @@ -33,6 +34,20 @@ void panel_surface_destructor(struct wl_resource *resource) {  	}  } +void lock_surface_destructor(struct wl_resource *resource) { +	sway_log(L_DEBUG, "Lock surface killed"); +	int i; +	for (i = 0; i < desktop_shell.lock_surfaces->length; ++i) { +		struct wl_resource *surface = desktop_shell.lock_surfaces->items[i]; +		if (surface == resource) { +			list_del(desktop_shell.lock_surfaces, i); +			arrange_windows(&root_container, -1, -1); +			desktop_shell.is_locked = false; +			break; +		} +	} +} +  static void set_background(struct wl_client *client, struct wl_resource *resource,  		struct wl_resource *_output, struct wl_resource *surface) {  	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,  	arrange_windows(&root_container, -1, -1);  } -static void set_lock_surface(struct wl_client *client, struct wl_resource *resource, struct wl_resource *surface) { +static void desktop_set_lock_surface(struct wl_client *client, struct wl_resource *resource, struct wl_resource *surface) {  	sway_log(L_ERROR, "desktop_set_lock_surface is not currently supported");  } -static void unlock(struct wl_client *client, struct wl_resource *resource) { +static void desktop_unlock(struct wl_client *client, struct wl_resource *resource) {  	sway_log(L_ERROR, "desktop_unlock is not currently supported");  } +static void set_lock_surface(struct wl_client *client, struct wl_resource *resource, +		struct wl_resource *output, struct wl_resource *surface) { +	sway_log(L_ERROR, "set_lock_surface is not currently supported"); +} + +static void unlock(struct wl_client *client, struct wl_resource *resource) { +	sway_log(L_ERROR, "unlock is not currently supported"); +} +  static void set_grab_surface(struct wl_client *client, struct wl_resource *resource, struct wl_resource *surface) {  	sway_log(L_ERROR, "desktop_set_grab_surface is not currently supported");  } @@ -89,13 +113,18 @@ static void set_panel_position(struct wl_client *client, struct wl_resource *res  static struct desktop_shell_interface desktop_shell_implementation = {  	.set_background = set_background,  	.set_panel = set_panel, -	.set_lock_surface = set_lock_surface, -	.unlock = unlock, +	.set_lock_surface = desktop_set_lock_surface, +	.unlock = desktop_unlock,  	.set_grab_surface = set_grab_surface,  	.desktop_ready = desktop_ready,  	.set_panel_position = set_panel_position  }; +static struct lock_interface swaylock_implementation = { +	.set_lock_surface = set_lock_surface, +	.unlock = unlock +}; +  static void desktop_shell_bind(struct wl_client *client, void *data,  		unsigned int version, unsigned int id) {  	if (version > 3) { @@ -111,9 +140,27 @@ static void desktop_shell_bind(struct wl_client *client, void *data,  	wl_resource_set_implementation(resource, &desktop_shell_implementation, NULL, NULL);  } +static void swaylock_bind(struct wl_client *client, void *data, +		unsigned int version, unsigned int id) { +	if (version > 1) { +		// Unsupported version +		return; +	} + +	struct wl_resource *resource = wl_resource_create(client, &lock_interface, version, id); +	if (!resource) { +		wl_client_post_no_memory(client); +	} + +	wl_resource_set_implementation(resource, &swaylock_implementation, NULL, NULL); +} +  void register_extensions(void) {  	wl_global_create(wlc_get_wl_display(), &desktop_shell_interface, 3, NULL, desktop_shell_bind);  	desktop_shell.backgrounds = create_list();  	desktop_shell.panels = create_list();  	desktop_shell.panel_position = DESKTOP_SHELL_PANEL_POSITION_BOTTOM; +	desktop_shell.lock_surfaces = create_list(); +	desktop_shell.is_locked = false; +	wl_global_create(wlc_get_wl_display(), &lock_interface, 3, NULL, swaylock_bind);  } 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) {  }  void notify_key(enum wl_keyboard_key_state state, xkb_keysym_t sym, uint32_t code, uint32_t codepoint) { -	sway_log(L_INFO, "notified of key %c", (char)codepoint);  	if (state == WL_KEYBOARD_KEY_STATE_PRESSED) {  		switch (sym) {  		case XKB_KEY_Return: @@ -81,13 +80,12 @@ void notify_key(enum wl_keyboard_key_state state, xkb_keysym_t sym, uint32_t cod  			}  			break;  		default: -		{ -			int i = strlen(password); -			password[i] = (char)codepoint; -			password[i + 1] = '\0'; -			sway_log(L_INFO, "pw: %s", password); -			break; -		} +			{ +				int i = strlen(password); +				password[i] = (char)codepoint; +				password[i + 1] = '\0'; +				break; +			}  		}  	}  } | 
