diff options
author | Drew DeVault <sir@cmpwn.com> | 2015-12-18 19:29:44 -0500 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2015-12-18 19:30:19 -0500 |
commit | 3282163f64291cfd63611110ab63e37051e80501 (patch) | |
tree | 7e89557c10e4bcc8415e482ad37106cc2e334236 | |
parent | Fix lock extension setup in compositor (diff) | |
download | sway-3282163f64291cfd63611110ab63e37051e80501.tar.gz sway-3282163f64291cfd63611110ab63e37051e80501.tar.zst sway-3282163f64291cfd63611110ab63e37051e80501.zip |
Implement compositor support for swaylock
This makes swaylock more or less work.
-rw-r--r-- | sway/extensions.c | 19 | ||||
-rw-r--r-- | sway/handlers.c | 8 | ||||
-rw-r--r-- | swaylock/main.c | 13 |
3 files changed, 36 insertions, 4 deletions
diff --git a/sway/extensions.c b/sway/extensions.c index 1ca66468..5e09bdbb 100644 --- a/sway/extensions.c +++ b/sway/extensions.c | |||
@@ -89,12 +89,27 @@ static void desktop_unlock(struct wl_client *client, struct wl_resource *resourc | |||
89 | } | 89 | } |
90 | 90 | ||
91 | static void set_lock_surface(struct wl_client *client, struct wl_resource *resource, | 91 | static void set_lock_surface(struct wl_client *client, struct wl_resource *resource, |
92 | struct wl_resource *output, struct wl_resource *surface) { | 92 | struct wl_resource *_output, struct wl_resource *surface) { |
93 | sway_log(L_ERROR, "set_lock_surface is not currently supported"); | 93 | swayc_t *output = swayc_by_handle(wlc_handle_from_wl_output_resource(_output)); |
94 | swayc_t *view = swayc_by_handle(wlc_handle_from_wl_surface_resource(surface)); | ||
95 | if (view && output) { | ||
96 | swayc_t *workspace = output->focused; | ||
97 | if (!swayc_is_child_of(view, workspace)) { | ||
98 | move_container_to(view, workspace); | ||
99 | } | ||
100 | wlc_view_set_state(view->handle, WLC_BIT_FULLSCREEN, true); | ||
101 | workspace->fullscreen = view; | ||
102 | desktop_shell.is_locked = true; | ||
103 | set_focused_container(view); | ||
104 | arrange_windows(view, -1, -1); | ||
105 | } else { | ||
106 | sway_log(L_ERROR, "Attempted to set lock surface to non-view"); | ||
107 | } | ||
94 | } | 108 | } |
95 | 109 | ||
96 | static void unlock(struct wl_client *client, struct wl_resource *resource) { | 110 | static void unlock(struct wl_client *client, struct wl_resource *resource) { |
97 | sway_log(L_ERROR, "unlock is not currently supported"); | 111 | sway_log(L_ERROR, "unlock is not currently supported"); |
112 | // This isn't really necessary, we just unlock when the client exits. | ||
98 | } | 113 | } |
99 | 114 | ||
100 | static void set_grab_surface(struct wl_client *client, struct wl_resource *resource, struct wl_resource *surface) { | 115 | static void set_grab_surface(struct wl_client *client, struct wl_resource *resource, struct wl_resource *surface) { |
diff --git a/sway/handlers.c b/sway/handlers.c index 136ef577..3161c677 100644 --- a/sway/handlers.c +++ b/sway/handlers.c | |||
@@ -331,6 +331,10 @@ static void handle_view_state_request(wlc_handle view, enum wlc_view_state_bit s | |||
331 | static bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifiers *modifiers, | 331 | static bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifiers *modifiers, |
332 | uint32_t key, enum wlc_key_state state) { | 332 | uint32_t key, enum wlc_key_state state) { |
333 | 333 | ||
334 | if (desktop_shell.is_locked) { | ||
335 | return EVENT_PASSTHROUGH; | ||
336 | } | ||
337 | |||
334 | if (locked_view_focus && state == WLC_KEY_STATE_PRESSED) { | 338 | if (locked_view_focus && state == WLC_KEY_STATE_PRESSED) { |
335 | return EVENT_PASSTHROUGH; | 339 | return EVENT_PASSTHROUGH; |
336 | } | 340 | } |
@@ -383,6 +387,10 @@ static bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifier | |||
383 | } | 387 | } |
384 | 388 | ||
385 | static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct wlc_point *origin) { | 389 | static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct wlc_point *origin) { |
390 | if (desktop_shell.is_locked) { | ||
391 | return EVENT_PASSTHROUGH; | ||
392 | } | ||
393 | |||
386 | struct wlc_point new_origin = *origin; | 394 | struct wlc_point new_origin = *origin; |
387 | // Switch to adjacent output if touching output edge. | 395 | // Switch to adjacent output if touching output edge. |
388 | // | 396 | // |
diff --git a/swaylock/main.c b/swaylock/main.c index 4073da99..82b88731 100644 --- a/swaylock/main.c +++ b/swaylock/main.c | |||
@@ -108,7 +108,6 @@ int main(int argc, char **argv) { | |||
108 | if (!window) { | 108 | if (!window) { |
109 | sway_abort("Failed to create surfaces."); | 109 | sway_abort("Failed to create surfaces."); |
110 | } | 110 | } |
111 | lock_set_lock_surface(registry->swaylock, output->output, window->surface); | ||
112 | list_add(surfaces, window); | 111 | list_add(surfaces, window); |
113 | } | 112 | } |
114 | 113 | ||
@@ -217,7 +216,17 @@ int main(int argc, char **argv) { | |||
217 | 216 | ||
218 | cairo_surface_destroy(image); | 217 | cairo_surface_destroy(image); |
219 | 218 | ||
220 | while (wl_display_dispatch(registry->display) != -1); | 219 | bool locked = false; |
220 | while (wl_display_dispatch(registry->display) != -1) { | ||
221 | if (!locked) { | ||
222 | for (i = 0; i < registry->outputs->length; ++i) { | ||
223 | struct output_state *output = registry->outputs->items[i]; | ||
224 | struct window *window = surfaces->items[i]; | ||
225 | lock_set_lock_surface(registry->swaylock, output->output, window->surface); | ||
226 | } | ||
227 | locked = true; | ||
228 | } | ||
229 | } | ||
221 | 230 | ||
222 | for (i = 0; i < surfaces->length; ++i) { | 231 | for (i = 0; i < surfaces->length; ++i) { |
223 | struct window *window = surfaces->items[i]; | 232 | struct window *window = surfaces->items[i]; |