session-lock: refactor

- Replaced `session_lock` with `session_lock_manager` which is
  persistent throughout the session.
- Replaced `session_lock->abandoned` with `session_lock_manager->locked`.
  Old `session_lock->abandoned` is equal to
  `!session_lock_manager->lock && session_lock_manager->locked`.
- Eliminated the use of global variables in `session-lock.c`.
- Changed some function names.
This commit is contained in:
tokyo4j 2024-05-30 00:13:34 +09:00 committed by Hiroaki Yamamoto
parent 65f7499f1c
commit a39c8afc10
6 changed files with 111 additions and 110 deletions

View file

@ -314,7 +314,7 @@ struct server {
struct wlr_gamma_control_manager_v1 *gamma_control_manager_v1;
struct wl_listener gamma_control_set_gamma;
struct session_lock *session_lock;
struct session_lock_manager *session_lock_manager;
struct wlr_foreign_toplevel_manager_v1 *foreign_toplevel_manager;

View file

@ -7,20 +7,30 @@
struct output;
struct server;
struct session_lock {
struct wlr_session_lock_v1 *lock;
struct session_lock_manager {
struct server *server;
struct wlr_session_lock_manager_v1 *wlr_manager;
struct wlr_surface *focused;
bool abandoned;
/*
* When not locked: lock=NULL, locked=false
* When locked: lock=non-NULL, locked=true
* When lock is destroyed without being unlocked: lock=NULL, locked=true
*/
struct wlr_session_lock_v1 *lock;
bool locked;
struct wl_list session_lock_outputs;
struct wl_listener new_surface;
struct wl_listener unlock;
struct wl_listener new_lock;
struct wl_listener destroy;
struct wl_listener lock_new_surface;
struct wl_listener lock_unlock;
struct wl_listener lock_destroy;
};
void session_lock_init(struct server *server);
void session_lock_output_create(struct session_lock *lock, struct output *output);
void session_lock_update_for_layout_change(void);
void session_lock_output_create(struct session_lock_manager *manager, struct output *output);
void session_lock_update_for_layout_change(struct server *server);
#endif /* LABWC_SESSION_LOCK_H */