mirror of
https://github.com/swaywm/sway.git
synced 2026-03-16 05:34:10 -04:00
Merge 996570a835 into 40aabb80c6
This commit is contained in:
commit
c9ffb69e96
1 changed files with 37 additions and 1 deletions
38
sway/lock.c
38
sway/lock.c
|
|
@ -26,6 +26,7 @@ struct sway_session_lock_output {
|
||||||
// invalid if surface is NULL
|
// invalid if surface is NULL
|
||||||
struct wl_listener surface_destroy;
|
struct wl_listener surface_destroy;
|
||||||
struct wl_listener surface_map;
|
struct wl_listener surface_map;
|
||||||
|
struct wl_listener surface_commit;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void focus_surface(struct sway_session_lock *lock,
|
static void focus_surface(struct sway_session_lock *lock,
|
||||||
|
|
@ -64,7 +65,16 @@ static void handle_surface_map(struct wl_listener *listener, void *data) {
|
||||||
if (surf->lock->focused == NULL) {
|
if (surf->lock->focused == NULL) {
|
||||||
focus_surface(surf->lock, surf->surface->surface);
|
focus_surface(surf->lock, surf->surface->surface);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void handle_surface_commit(struct wl_listener *listener, void *data) {
|
||||||
|
// We have to rebase cursor after the surface is commited.
|
||||||
|
// If we rebase cursor earlier(e.g. after the surface is mapped),
|
||||||
|
// the lock surface is still 0x0 in size.
|
||||||
cursor_rebase_all();
|
cursor_rebase_all();
|
||||||
|
struct sway_session_lock_output *surf = wl_container_of(listener, surf, surface_commit);
|
||||||
|
wl_list_remove(&surf->surface_commit.link);
|
||||||
|
wl_list_init(&surf->surface_commit.link);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_surface_destroy(struct wl_listener *listener, void *data) {
|
static void handle_surface_destroy(struct wl_listener *listener, void *data) {
|
||||||
|
|
@ -76,6 +86,7 @@ static void handle_surface_destroy(struct wl_listener *listener, void *data) {
|
||||||
output->surface = NULL;
|
output->surface = NULL;
|
||||||
wl_list_remove(&output->surface_destroy.link);
|
wl_list_remove(&output->surface_destroy.link);
|
||||||
wl_list_remove(&output->surface_map.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) {
|
static void lock_output_reconfigure(struct sway_session_lock_output *output) {
|
||||||
|
|
@ -125,6 +136,8 @@ static void handle_new_surface(struct wl_listener *listener, void *data) {
|
||||||
wl_signal_add(&lock_surface->events.destroy, &lock_output->surface_destroy);
|
wl_signal_add(&lock_surface->events.destroy, &lock_output->surface_destroy);
|
||||||
lock_output->surface_map.notify = handle_surface_map;
|
lock_output->surface_map.notify = handle_surface_map;
|
||||||
wl_signal_add(&lock_surface->surface->events.map, &lock_output->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);
|
lock_output_reconfigure(lock_output);
|
||||||
}
|
}
|
||||||
|
|
@ -134,6 +147,7 @@ static void sway_session_lock_output_destroy(struct sway_session_lock_output *ou
|
||||||
refocus_output(output);
|
refocus_output(output);
|
||||||
wl_list_remove(&output->surface_destroy.link);
|
wl_list_remove(&output->surface_destroy.link);
|
||||||
wl_list_remove(&output->surface_map.link);
|
wl_list_remove(&output->surface_map.link);
|
||||||
|
wl_list_remove(&output->surface_commit.link);
|
||||||
}
|
}
|
||||||
|
|
||||||
wl_list_remove(&output->destroy.link);
|
wl_list_remove(&output->destroy.link);
|
||||||
|
|
@ -237,6 +251,8 @@ static void handle_unlock(struct wl_listener *listener, void *data) {
|
||||||
|
|
||||||
// Views are now visible, so check if we need to activate inhibition again.
|
// Views are now visible, so check if we need to activate inhibition again.
|
||||||
sway_idle_inhibit_v1_check_active();
|
sway_idle_inhibit_v1_check_active();
|
||||||
|
|
||||||
|
cursor_rebase_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_abandon(struct wl_listener *listener, void *data) {
|
static void handle_abandon(struct wl_listener *listener, void *data) {
|
||||||
|
|
@ -332,11 +348,31 @@ void sway_session_lock_add_output(struct sway_session_lock *lock,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct is_lock_surface_data {
|
||||||
|
struct wlr_surface *surface;
|
||||||
|
bool is_lock_surface;
|
||||||
|
};
|
||||||
|
|
||||||
|
static void is_lock_surface(struct wlr_surface *surface, int sx, int sy, void *data) {
|
||||||
|
struct is_lock_surface_data *is_lock_surface_data = data;
|
||||||
|
if (is_lock_surface_data->surface == surface) {
|
||||||
|
is_lock_surface_data->is_lock_surface = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool sway_session_lock_has_surface(struct sway_session_lock *lock,
|
bool sway_session_lock_has_surface(struct sway_session_lock *lock,
|
||||||
struct wlr_surface *surface) {
|
struct wlr_surface *surface) {
|
||||||
struct sway_session_lock_output *lock_output;
|
struct sway_session_lock_output *lock_output;
|
||||||
wl_list_for_each(lock_output, &lock->outputs, link) {
|
wl_list_for_each(lock_output, &lock->outputs, link) {
|
||||||
if (lock_output->surface && lock_output->surface->surface == surface) {
|
if (!lock_output->surface) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
struct is_lock_surface_data data = {
|
||||||
|
.surface = surface,
|
||||||
|
.is_lock_surface = false,
|
||||||
|
};
|
||||||
|
wlr_surface_for_each_surface(lock_output->surface->surface, is_lock_surface, &data);
|
||||||
|
if (data.is_lock_surface) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue