Skip to content

Commit

Permalink
lock: listen to commit signal rather than map
Browse files Browse the repository at this point in the history
  • Loading branch information
Luminiscental committed Sep 12, 2024
1 parent d7a76d3 commit e4e407f
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions sway/lock.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct sway_session_lock_output {

// invalid if surface is NULL
struct wl_listener surface_destroy;
struct wl_listener surface_map;
struct wl_listener surface_commit;
};

static void focus_surface(struct sway_session_lock *lock,
Expand Down Expand Up @@ -59,8 +59,8 @@ static void refocus_output(struct sway_session_lock_output *output) {
}
}

static void handle_surface_map(struct wl_listener *listener, void *data) {
struct sway_session_lock_output *surf = wl_container_of(listener, surf, surface_map);
static void handle_surface_commit(struct wl_listener *listener, void *data) {
struct sway_session_lock_output *surf = wl_container_of(listener, surf, surface_commit);
if (surf->lock->focused == NULL) {
focus_surface(surf->lock, surf->surface->surface);
}
Expand All @@ -75,7 +75,7 @@ static void handle_surface_destroy(struct wl_listener *listener, void *data) {
sway_assert(output->surface, "Trying to destroy a surface that the lock doesn't think exists");
output->surface = NULL;
wl_list_remove(&output->surface_destroy.link);
wl_list_remove(&output->surface_map.link);
wl_list_remove(&output->surface_commit.link);
}

static void lock_output_reconfigure(struct sway_session_lock_output *output) {
Expand Down Expand Up @@ -112,8 +112,8 @@ static void handle_new_surface(struct wl_listener *listener, void *data) {

lock_output->surface_destroy.notify = handle_surface_destroy;
wl_signal_add(&lock_surface->events.destroy, &lock_output->surface_destroy);
lock_output->surface_map.notify = handle_surface_map;
wl_signal_add(&lock_surface->surface->events.map, &lock_output->surface_map);
lock_output->surface_commit.notify = handle_surface_commit;
wl_signal_add(&lock_surface->surface->events.commit, &lock_output->surface_commit);

lock_output_reconfigure(lock_output);
}
Expand All @@ -122,7 +122,7 @@ static void sway_session_lock_output_destroy(struct sway_session_lock_output *ou
if (output->surface) {
refocus_output(output);
wl_list_remove(&output->surface_destroy.link);
wl_list_remove(&output->surface_map.link);
wl_list_remove(&output->surface_commit.link);
}

wl_list_remove(&output->commit.link);
Expand Down

0 comments on commit e4e407f

Please sign in to comment.