|
| 1 | +/* |
| 2 | + * Copyright 2026 elementary, Inc. (https://elementary.io) |
| 3 | + * SPDX-License-Identifier: GPL-3.0-or-later |
| 4 | + * |
| 5 | + * Authored by: Leonhard Kargl <leo.kargl@proton.me> |
| 6 | + */ |
| 7 | + |
| 8 | +public class Gala.LockScreen : Clutter.Actor { |
| 9 | + private const WindowGroup[] ALLOWED_WINDOW_GROUPS = { LOCK_SCREEN, LOCK_SCREEN_SHELL, OVERLAY }; |
| 10 | + |
| 11 | + public WindowManager wm { get; construct; } |
| 12 | + |
| 13 | + public Clutter.Actor window_group { get; private set; } |
| 14 | + public Clutter.Actor shell_group { get; private set; } |
| 15 | + |
| 16 | + private bool active; |
| 17 | + private ModalProxy? modal_proxy; |
| 18 | + |
| 19 | + public LockScreen (WindowManager wm) { |
| 20 | + Object (wm: wm); |
| 21 | + } |
| 22 | + |
| 23 | + construct { |
| 24 | + var background = new BackgroundContainer (wm.get_display ()); |
| 25 | + background.add_effect (new BlurEffect (background, 18)); |
| 26 | + |
| 27 | + window_group = new Clutter.Actor (); |
| 28 | + shell_group = new Clutter.Actor (); |
| 29 | + |
| 30 | + add_child (background); |
| 31 | + add_child (window_group); |
| 32 | + add_child (shell_group); |
| 33 | + |
| 34 | + reactive = true; |
| 35 | + visible = true; |
| 36 | + |
| 37 | + active = true; |
| 38 | + update_modal (); |
| 39 | + } |
| 40 | + |
| 41 | + public async void set_active (bool active) { |
| 42 | + if (this.active == active) { |
| 43 | + return; |
| 44 | + } |
| 45 | + |
| 46 | + this.active = active; |
| 47 | + update_modal (); |
| 48 | + |
| 49 | + /* We can and should add a transition here */ |
| 50 | + |
| 51 | + visible = active; |
| 52 | + } |
| 53 | + |
| 54 | + private void update_modal () { |
| 55 | + if (active) { |
| 56 | + assert (modal_proxy == null); |
| 57 | + |
| 58 | + modal_proxy = wm.push_modal (this, false); |
| 59 | + modal_proxy.allow_actions (MEDIA_KEYS | ZOOM | LOCATE_POINTER); |
| 60 | + modal_proxy.allow_window_groups (ALLOWED_WINDOW_GROUPS); |
| 61 | + } else { |
| 62 | + assert (modal_proxy != null); |
| 63 | + |
| 64 | + wm.pop_modal (modal_proxy); |
| 65 | + modal_proxy = null; |
| 66 | + } |
| 67 | + } |
| 68 | +} |
0 commit comments