- Lock the session from the power button or `chandra-ctl lock` - Unlock with a face or the password; the password always works - Add compositor lock module with tests, and a polkit unlock policy (org.chandra.unlock) - Document the lock flow in docs/lock.md and link it from the README - Add generated interface bindings for the compositor and widget components
This commit is contained in:
1 parent
7501fc3ad9
commit
c790f96e58
131 files changed
+4693
-274
No files matched your search
@@ -153,6 +153,14 @@ pub(all) struct ChandraCompositor {
|
||||
mut screen_off : Bool
|
||||
mut manual_screen_off : Bool
|
||||
mut idle_suspended : Bool
|
||||
/// The session is locked (lock.mbt): the desktop is hidden and input only reaches the unlock
|
||||
/// dialog until a face or password unlocks it.
|
||||
mut locked : Bool
|
||||
/// Whether turning the screen off (power button) also locks the session. `chandra-ctl lock`
|
||||
/// locks regardless. Off by default; CHANDRA_LOCK=1 or the setting turns it on.
|
||||
mut lock_on_blank : Bool
|
||||
/// An unlock request is out to the agent and we are waiting (don't ask again every wake).
|
||||
mut unlock_pending : Bool
|
||||
mut output_w : Int
|
||||
mut output_h : Int
|
||||
mut work_area : @wm.Rect
|
||||
@@ -367,6 +375,8 @@ pub fn ChandraCompositor::new(
|
||||
)
|
||||
let work_area = work_area_for(output_w, output_h, theme)
|
||||
let shell = @shell.DesktopShell::new(socket_path)
|
||||
let init_rot = initial_rotation_from_env()
|
||||
shell.rotation = init_rot
|
||||
shell.set_output(theme, output_w, output_h)
|
||||
let comp : ChandraCompositor = {
|
||||
server,
|
||||
@@ -400,6 +410,9 @@ pub fn ChandraCompositor::new(
|
||||
screen_off: false,
|
||||
manual_screen_off: false,
|
||||
idle_suspended: false,
|
||||
locked: false,
|
||||
lock_on_blank: @sys.getenv("CHANDRA_LOCK") == "1",
|
||||
unlock_pending: false,
|
||||
output_w,
|
||||
output_h,
|
||||
work_area,
|
||||
@@ -493,7 +506,7 @@ pub fn ChandraCompositor::new(
|
||||
osk_pressed: None,
|
||||
osk_hover: None,
|
||||
osk_pointer_grab: false,
|
||||
rotation: initial_rotation_from_env(),
|
||||
rotation: init_rot,
|
||||
pending_rotation: None,
|
||||
vol_run: None,
|
||||
vol_queue: [],
|
||||
@@ -568,6 +581,7 @@ fn initial_rotation_from_env() -> Int {
|
||||
pub fn ChandraCompositor::request_rotation(self : ChandraCompositor, rot : Int) -> Unit {
|
||||
let r = (rot % 4 + 4) % 4
|
||||
self.pending_rotation = Some(r)
|
||||
self.shell.rotation = r
|
||||
self.damage.mark_full()
|
||||
}
|
||||
|
||||
@@ -1235,8 +1249,9 @@ fn ChandraCompositor::build_scene(
|
||||
self.overview_sync()
|
||||
let scene = @scene.SceneGraph::new(self.output_w, self.output_h)
|
||||
let order = self.wm.stacking_order()
|
||||
// The overview draws the windows itself, as previews.
|
||||
let shown = if self.overview is Some(_) { [] } else { order }
|
||||
// The overview draws the windows itself, as previews. A locked session hides every window
|
||||
// behind the unlock dialog (lock.mbt).
|
||||
let shown = if self.overview is Some(_) || self.locked { [] } else { order }
|
||||
|
||||
for wid in shown {
|
||||
self.push_window_node(scene, wid)
|
||||
@@ -1266,17 +1281,19 @@ fn ChandraCompositor::build_scene(
|
||||
}
|
||||
}
|
||||
|
||||
// Client menus would draw above the auth dialog: none while it is up.
|
||||
for p in (if self.auth is Some(_) { [] } else { self.popups }) {
|
||||
// Client menus would draw above the auth dialog: none while it is up or the session is locked.
|
||||
for p in (if self.auth is Some(_) || self.locked { [] } else { self.popups }) {
|
||||
match p.surface {
|
||||
Some(snap) => if self.overview is None { scene.popups.push((self.popup_rect(p), snap)) }
|
||||
None => ()
|
||||
}
|
||||
}
|
||||
// The drag icon, over every window and menu.
|
||||
match self.dnd_icon_node() {
|
||||
Some(n) => scene.popups.push(n)
|
||||
None => ()
|
||||
if !self.locked {
|
||||
match self.dnd_icon_node() {
|
||||
Some(n) => scene.popups.push(n)
|
||||
None => ()
|
||||
}
|
||||
}
|
||||
|
||||
self.shell.layout_sel = match self.layout_mode {
|
||||
@@ -1287,6 +1304,8 @@ fn ChandraCompositor::build_scene(
|
||||
self.sync_shell_windows()
|
||||
self.shell.screenshot_state = (if self.rec is Some(_) { 1 } else { 0 }) |
|
||||
(if self.rec_pointer { 2 } else { 0 })
|
||||
self.shell.osk_visible = self.osk_visible
|
||||
self.shell.rotation = self.pending_rotation.unwrap_or(self.rotation)
|
||||
// A window over the whole desktop (maximized, fullscreen, monocle) pauses a desktop module's
|
||||
// animation: nobody can see it.
|
||||
self.shell.set_desktop_covered(self.desktop_covered())
|
||||
@@ -1294,24 +1313,34 @@ fn ChandraCompositor::build_scene(
|
||||
let (bg_ops, shell_ops) = self.shell.render(self.output_w, self.output_h, self.theme)
|
||||
// The overview goes under the panel and the launcher.
|
||||
self.overview_sync()
|
||||
let panel_ops = self.overview_ops()
|
||||
panel_ops.append(shell_ops)
|
||||
if self.switcher_on {
|
||||
panel_ops.append(self.switcher_ops())
|
||||
let panel_ops = if self.locked {
|
||||
let ops = self.lock_ops()
|
||||
ops.append(self.auth_ops())
|
||||
ops.append(self.auth_notice_ops())
|
||||
ops.append(self.osk_ops())
|
||||
ops.append(self.volume_ops())
|
||||
ops
|
||||
} else {
|
||||
let ops = self.overview_ops()
|
||||
ops.append(shell_ops)
|
||||
if self.switcher_on {
|
||||
ops.append(self.switcher_ops())
|
||||
}
|
||||
ops.append(self.screenshot_ops())
|
||||
ops.append(self.emoji_ops())
|
||||
ops.append(self.face_window_ops())
|
||||
ops.append(self.auth_ops())
|
||||
ops.append(self.auth_notice_ops())
|
||||
ops.append(self.osk_ops())
|
||||
ops.append(self.volume_ops())
|
||||
ops
|
||||
}
|
||||
panel_ops.append(self.screenshot_ops())
|
||||
panel_ops.append(self.emoji_ops())
|
||||
panel_ops.append(self.face_window_ops())
|
||||
panel_ops.append(self.auth_ops())
|
||||
panel_ops.append(self.auth_notice_ops())
|
||||
panel_ops.append(self.osk_ops())
|
||||
panel_ops.append(self.volume_ops())
|
||||
self.frames_built = self.frames_built + 1
|
||||
self.run_shell_actions()
|
||||
// The wallpaper (the first ops) is cached by the renderer; the desktop card after it changes.
|
||||
let n_wall = if self.shell.wallpaper_len <= bg_ops.length() { self.shell.wallpaper_len } else { 0 }
|
||||
scene.wallpaper_ops = Array::makei(n_wall, i => bg_ops[i])
|
||||
scene.background_ops = Array::makei(bg_ops.length() - n_wall, i => bg_ops[n_wall + i])
|
||||
scene.background_ops = if self.locked { [] } else { Array::makei(bg_ops.length() - n_wall, i => bg_ops[n_wall + i]) }
|
||||
scene.panel_ops = panel_ops
|
||||
let damaged = self.damage.take_damage(self.output_w, self.output_h).length() > 0
|
||||
let sig : FrameSig = {
|
||||
@@ -1964,6 +1993,8 @@ fn ChandraCompositor::run_shell_actions(self : ChandraCompositor) -> Unit {
|
||||
self.frame_changed = true
|
||||
self.damage.mark_full()
|
||||
}
|
||||
@shell.ShellAction::SetOskVisible(v) => self.osk_set_manual_visible(v)
|
||||
@shell.ShellAction::SetRotation(r) => self.request_rotation(r)
|
||||
@shell.ShellAction::SetLayout(m) =>
|
||||
match m {
|
||||
0 => self.set_layout_mode(@wm.LayoutMode::Tiling)
|
||||
@@ -2231,11 +2262,10 @@ fn ChandraCompositor::handle_input_inner(
|
||||
Key(116U, pressed) => {
|
||||
if pressed {
|
||||
if self.screen_off || self.manual_screen_off {
|
||||
self.manual_screen_off = false
|
||||
self.note_activity(@sys.monotonic_ms())
|
||||
self.set_manual_screen_off(false)
|
||||
} else {
|
||||
self.manual_screen_off = true
|
||||
self.stop_volume_repeat()
|
||||
self.set_manual_screen_off(true)
|
||||
}
|
||||
}
|
||||
return
|
||||
@@ -2256,6 +2286,20 @@ fn ChandraCompositor::handle_input_inner(
|
||||
}
|
||||
if self.screen_off {
|
||||
self.note_activity(@sys.monotonic_ms())
|
||||
if self.locked {
|
||||
self.request_unlock()
|
||||
}
|
||||
return
|
||||
}
|
||||
// Locked: input only reaches the unlock dialog (dispatch_input_inner -> grab_input -> auth).
|
||||
// Before the dialog is up, swallow everything so nothing leaks to the desktop or apps, and
|
||||
// take the chance to (re-)raise the prompt only on a key or button press (not hover or release).
|
||||
if self.locked && self.auth is None {
|
||||
self.note_activity(@sys.monotonic_ms())
|
||||
match ev {
|
||||
Key(_, true) | PointerButton(_, true) => self.request_unlock()
|
||||
_ => ()
|
||||
}
|
||||
return
|
||||
}
|
||||
self.note_activity(@sys.monotonic_ms())
|
||||
|
||||
Reference in new issue
Block a user