Implement compositor support for swaylock
This makes swaylock more or less work.
This commit is contained in:
parent
eefc93db43
commit
3282163f64
|
@ -89,12 +89,27 @@ static void desktop_unlock(struct wl_client *client, struct wl_resource *resourc
|
|||
}
|
||||
|
||||
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");
|
||||
struct wl_resource *_output, struct wl_resource *surface) {
|
||||
swayc_t *output = swayc_by_handle(wlc_handle_from_wl_output_resource(_output));
|
||||
swayc_t *view = swayc_by_handle(wlc_handle_from_wl_surface_resource(surface));
|
||||
if (view && output) {
|
||||
swayc_t *workspace = output->focused;
|
||||
if (!swayc_is_child_of(view, workspace)) {
|
||||
move_container_to(view, workspace);
|
||||
}
|
||||
wlc_view_set_state(view->handle, WLC_BIT_FULLSCREEN, true);
|
||||
workspace->fullscreen = view;
|
||||
desktop_shell.is_locked = true;
|
||||
set_focused_container(view);
|
||||
arrange_windows(view, -1, -1);
|
||||
} else {
|
||||
sway_log(L_ERROR, "Attempted to set lock surface to non-view");
|
||||
}
|
||||
}
|
||||
|
||||
static void unlock(struct wl_client *client, struct wl_resource *resource) {
|
||||
sway_log(L_ERROR, "unlock is not currently supported");
|
||||
// This isn't really necessary, we just unlock when the client exits.
|
||||
}
|
||||
|
||||
static void set_grab_surface(struct wl_client *client, struct wl_resource *resource, struct wl_resource *surface) {
|
||||
|
|
|
@ -331,6 +331,10 @@ static void handle_view_state_request(wlc_handle view, enum wlc_view_state_bit s
|
|||
static bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifiers *modifiers,
|
||||
uint32_t key, enum wlc_key_state state) {
|
||||
|
||||
if (desktop_shell.is_locked) {
|
||||
return EVENT_PASSTHROUGH;
|
||||
}
|
||||
|
||||
if (locked_view_focus && state == WLC_KEY_STATE_PRESSED) {
|
||||
return EVENT_PASSTHROUGH;
|
||||
}
|
||||
|
@ -383,6 +387,10 @@ static bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifier
|
|||
}
|
||||
|
||||
static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct wlc_point *origin) {
|
||||
if (desktop_shell.is_locked) {
|
||||
return EVENT_PASSTHROUGH;
|
||||
}
|
||||
|
||||
struct wlc_point new_origin = *origin;
|
||||
// Switch to adjacent output if touching output edge.
|
||||
//
|
||||
|
|
|
@ -108,7 +108,6 @@ int main(int argc, char **argv) {
|
|||
if (!window) {
|
||||
sway_abort("Failed to create surfaces.");
|
||||
}
|
||||
lock_set_lock_surface(registry->swaylock, output->output, window->surface);
|
||||
list_add(surfaces, window);
|
||||
}
|
||||
|
||||
|
@ -217,7 +216,17 @@ int main(int argc, char **argv) {
|
|||
|
||||
cairo_surface_destroy(image);
|
||||
|
||||
while (wl_display_dispatch(registry->display) != -1);
|
||||
bool locked = false;
|
||||
while (wl_display_dispatch(registry->display) != -1) {
|
||||
if (!locked) {
|
||||
for (i = 0; i < registry->outputs->length; ++i) {
|
||||
struct output_state *output = registry->outputs->items[i];
|
||||
struct window *window = surfaces->items[i];
|
||||
lock_set_lock_surface(registry->swaylock, output->output, window->surface);
|
||||
}
|
||||
locked = true;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < surfaces->length; ++i) {
|
||||
struct window *window = surfaces->items[i];
|
||||
|
|
Loading…
Reference in a new issue