R6.12, R6.13: the LOK worker has no Dock icon; Show turns slides

R6.12: on macOS the worker sets LibreOffice's own NSApplication to the
accessory policy before the kit starts, so it never shows in the Dock.

R6.13: when the whole slide fits, the wheel and Up/Down (nothing
selected, no text editing) turn slides in the ElyShow editor.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
ZacharyZhang-NYandClaude Opus 5.5 committed 2026-10-15 19:29:10 -04:00
1 parent bb943fb84b
commit fdb8317d24
14 files changed
+312 -19

No files matched your search

+4 -1
View File
@@ -298,7 +298,10 @@ impl LokView {
_: &mut Window,
cx: &mut Context<Self>,
) {
if self.walk(&event.keystroke, cx) || self.key_down(&event.keystroke) {
if self.walk(&event.keystroke, cx)
|| self.turn_key(&event.keystroke, cx)
|| self.key_down(&event.keystroke)
{
cx.stop_propagation();
}
}
+10
View File
@@ -24,6 +24,16 @@ pub fn scheme(dark: bool) -> &'static str {
if dark { DARK } else { LIGHT }
}
/// A page's colour; the kernel's Ely schemes share it.
pub fn paper(cx: &gpui::App) -> gpui::Hsla {
let theme = cx.theme();
if theme.is_dark() {
theme.colors.surface
} else {
theme.colors.paper
}
}
impl LokView {
/// Paints with the app's light or dark scheme.
pub(super) fn follow_theme(&mut self, dark: bool) {
+142
View File
@@ -0,0 +1,142 @@
//! The wheel and Up, Down turn slides (SHOW-01).
use std::time::{Duration, Instant};
use gpui::{Context, EventEmitter, Keystroke, Modifiers, ScrollDelta, ScrollWheelEvent, TouchPhase};
use super::LokView;
/// Asks for the part `step` away from the shown one.
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct Turn(pub i32);
impl EventEmitter<Turn> for LokView {}
/// Trackpad pixels one turn takes.
const SWIPE: f32 = 50.0;
/// A pause this long ends a trackpad gesture.
const PAUSE: Duration = Duration::from_millis(250);
/// The wheel's progress towards a turn.
#[derive(Default)]
pub(super) struct Turning {
lines: f32,
pixels: f32,
/// This gesture already turned.
spent: bool,
last: Option<Instant>,
}
impl Turning {
/// The turn a wheel event makes; 0 for none.
pub(super) fn wheel(&mut self, delta: ScrollDelta, phase: TouchPhase, now: Instant) -> i32 {
let paused = self.last.is_none_or(|last| now.duration_since(last) >= PAUSE);
self.last = Some(now);
let ahead = match delta {
// Each notch turns once.
ScrollDelta::Lines(lines) => {
if paused {
self.lines = 0.0;
}
self.lines += lines.y;
let whole = self.lines.trunc();
self.lines -= whole;
whole
}
// One trackpad gesture turns once, momentum included.
ScrollDelta::Pixels(pixels) => {
if paused || phase == TouchPhase::Started {
(self.pixels, self.spent) = (0.0, false);
}
if self.spent {
return 0;
}
self.pixels += f32::from(pixels.y);
if self.pixels.abs() < SWIPE {
return 0;
}
self.spent = true;
self.pixels.signum()
}
};
// Content moving down shows the part before.
-(ahead as i32)
}
}
impl LokView {
/// The wheel and Up, Down turn parts from now on.
pub fn turn_parts(&mut self) {
self.turning.get_or_insert_default();
}
/// The part shown.
pub fn part(&self) -> usize {
self.part
}
/// Up and Down turn while nothing is picked or edited.
pub(super) fn turn_key(&mut self, keystroke: &Keystroke, cx: &mut Context<Self>) -> bool {
let idle = !self.caret() && self.graphic.is_none() && self.selection.is_empty();
if self.turning.is_none() || !idle || keystroke.modifiers != Modifiers::none() {
return false;
}
let step = match keystroke.key.as_str() {
"down" => 1,
"up" => -1,
_ => return false,
};
cx.emit(Turn(step));
true
}
/// The wheel turns while the whole page shows.
pub(super) fn turn_wheel(&mut self, event: &ScrollWheelEvent, cx: &mut Context<Self>) -> bool {
let (width, height) = self.extent();
// A pixel of slack for rounding.
let whole = self.geom.px_of(width) <= self.viewport.0 + 1.0
&& self.geom.px_of(height) <= self.viewport.1 + 1.0;
let Some(turning) = self.turning.as_mut().filter(|_| whole) else {
return false;
};
let step = turning.wheel(event.delta, event.touch_phase, Instant::now());
if step != 0 {
cx.emit(Turn(step));
}
true
}
}
#[cfg(test)]
mod tests {
use gpui::{ScrollDelta, TouchPhase, point, px};
use super::{PAUSE, Turning};
#[test]
fn each_notch_turns_once() {
let (mut turning, now) = (Turning::default(), std::time::Instant::now());
let notch = |y| ScrollDelta::Lines(point(0.0, y));
assert_eq!(turning.wheel(notch(-1.0), TouchPhase::Moved, now), 1);
assert_eq!(turning.wheel(notch(-1.0), TouchPhase::Moved, now), 1);
assert_eq!(turning.wheel(notch(1.0), TouchPhase::Moved, now), -1);
assert_eq!(turning.wheel(notch(0.5), TouchPhase::Moved, now), 0);
assert_eq!(turning.wheel(notch(0.5), TouchPhase::Moved, now), -1);
}
#[test]
fn a_swipe_turns_once_until_the_next() {
let (mut turning, now) = (Turning::default(), std::time::Instant::now());
let swipe = |y| ScrollDelta::Pixels(point(px(0.0), px(y)));
assert_eq!(turning.wheel(swipe(-30.0), TouchPhase::Started, now), 0);
assert_eq!(turning.wheel(swipe(-30.0), TouchPhase::Moved, now), 1);
// Momentum after the turn turns nothing more.
for _ in 0..20 {
assert_eq!(turning.wheel(swipe(-80.0), TouchPhase::Moved, now), 0);
}
assert_eq!(turning.wheel(swipe(60.0), TouchPhase::Started, now), -1);
// A pause ends a gesture without phases.
let later = now + PAUSE;
assert_eq!(turning.wheel(swipe(60.0), TouchPhase::Moved, later), -1);
}
}
+2 -2
View File
@@ -65,9 +65,9 @@ impl LokView {
cx.notify();
}
/// Ctrl (macOS: Cmd) and the wheel zoom; else scroll.
/// Ctrl (macOS: Cmd) wheel zooms; else it turns or scrolls.
pub(super) fn on_wheel(&mut self, event: &ScrollWheelEvent, window: &mut Window, cx: &mut Context<Self>) {
if !self.wheel_zoom(event, cx) {
if !self.wheel_zoom(event, cx) && !self.turn_wheel(event, cx) {
self.on_scroll(event, window, cx);
}
}