Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 52 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ name = "TeXora"
path = "src/main.rs"

[dependencies]
eframe = { version = "0.37", default-features = false, features = ["glow", "default_fonts", "wayland", "x11", "clipboard", "links", "system_fonts"] }
eframe = { version = "0.37", default-features = false, features = ["default_fonts", "wayland", "x11", "clipboard", "links", "system_fonts"] }
egui = "0.37"
pdfium-render = "0.9.5"
image = { version = "0.25", default-features = false, features = ["png", "gif", "jpeg", "tiff", "bmp", "webp"] }
Expand All @@ -32,6 +32,17 @@ avif-decode = { version = "3", default-features = false }
jxl-oxide = { version = "0.12", default-features = false }
toml = { version = "0.9", default-features = false, features = ["parse", "serde"] }

# Use Metal on macOS to avoid OpenGL texture creation failures when opening a second viewport.
[target.'cfg(target_os = "macos")'.dependencies]
eframe = { version = "0.37", default-features = false, features = ["wgpu_no_default_features"] }
objc2 = "0.6"
objc2-app-kit = { version = "0.3", default-features = false, features = ["NSApplication", "NSScreen", "NSWindow"] }
objc2-foundation = { version = "0.3", default-features = false, features = ["NSValue"] }
wgpu = { version = "30", default-features = false, features = ["metal"] }

[target.'cfg(not(target_os = "macos"))'.dependencies]
eframe = { version = "0.37", default-features = false, features = ["glow"] }

# Fonts for other writing systems (Arabic, Hebrew, Chinese, Japanese, Korean, Hindi, Thai...) come from
# the computer itself. On Linux, fontconfig is opened when the program runs instead of being linked, so
# the program starts even on a system without it, and the cross-build needs no fontconfig files.
Expand Down
5 changes: 4 additions & 1 deletion THIRD-PARTY-LICENSES.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ffmpeg and VLC have their own licences (LGPL/GPL), which apply to the copies you
| Inter font (Rasmus Andersson) | SIL Open Font License 1.1 | https://rsms.me/inter/ |
| Hack and Ubuntu Light fonts (inside egui) | MIT; Ubuntu Font Licence | https://github.com/emilk/egui |

## Rust libraries built into the program (432)
## Rust libraries built into the program (435)

| Library | Version | Licence | Source |
|---|---|---|---|
Expand Down Expand Up @@ -267,6 +267,7 @@ ffmpeg and VLC have their own licences (LGPL/GPL), which apply to the copies you
| poll-promise | 0.3.0 | MIT OR Apache-2.0 | https://github.com/EmbarkStudios/poll-promise |
| polling | 3.11.0 | Apache-2.0 OR MIT | https://github.com/smol-rs/polling |
| pollster | 0.4.0 | Apache-2.0/MIT | https://github.com/zesterer/pollster |
| pollster | 1.0.3 | MIT OR Apache-2.0 | https://github.com/zesterer/pollster |
| polycool | 0.4.0 | MIT OR Apache-2.0 | https://github.com/linebender/kurbo |
| portable-atomic | 1.15.0 | Apache-2.0 OR MIT | https://github.com/taiki-e/portable-atomic |
| portable-atomic-util | 0.2.8 | Apache-2.0 OR MIT | https://github.com/taiki-e/portable-atomic-util |
Expand All @@ -283,6 +284,7 @@ ffmpeg and VLC have their own licences (LGPL/GPL), which apply to the copies you
| rav1d | 1.1.0 | BSD-2-Clause | https://github.com/memorysafety/rav1d |
| raw-cpuid | 11.6.0 | MIT | https://github.com/gz/rust-cpuid |
| raw-window-handle | 0.6.2 | MIT OR Apache-2.0 OR Zlib | https://github.com/rust-windowing/raw-window-handle |
| raw-window-metal | 1.1.0 | MIT OR Apache-2.0 | https://github.com/rust-windowing/raw-window-metal |
| read-fonts | 0.41.0 | MIT OR Apache-2.0 | https://github.com/googlefonts/fontations |
| redox_syscall | 0.4.1 | MIT | https://gitlab.redox-os.org/redox-os/syscall |
| redox_syscall | 0.5.18 | MIT | https://gitlab.redox-os.org/redox-os/syscall |
Expand Down Expand Up @@ -395,6 +397,7 @@ ffmpeg and VLC have their own licences (LGPL/GPL), which apply to the copies you
| weezl | 0.1.12 | MIT OR Apache-2.0 | https://github.com/image-rs/weezl |
| wgpu | 30.0.1 | MIT OR Apache-2.0 | https://github.com/gfx-rs/wgpu |
| wgpu-core | 30.0.1 | MIT OR Apache-2.0 | https://github.com/gfx-rs/wgpu |
| wgpu-core-deps-apple | 30.0.2 | MIT OR Apache-2.0 | https://github.com/gfx-rs/wgpu |
| wgpu-core-deps-windows-linux-android | 30.0.1 | MIT OR Apache-2.0 | https://github.com/gfx-rs/wgpu |
| wgpu-hal | 30.0.1 | MIT OR Apache-2.0 | https://github.com/gfx-rs/wgpu |
| wgpu-naga-bridge | 30.0.1 | MIT OR Apache-2.0 | https://github.com/gfx-rs/wgpu |
Expand Down
6 changes: 4 additions & 2 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1856,7 +1856,7 @@ impl App {
self.audience_open = true;
self.audience_tab = self.active_id();
self.audience_age = 0;
self.audience_full = false;
self.audience_full = cfg!(target_os = "macos") && self.displays.len() >= 2;
self.start_timer();
if self.displays.len() < 2 {
self.status = "One display found. Press F11 for fullscreen slides.".to_string();
Expand All @@ -1866,7 +1866,9 @@ impl App {
Fullscreen => {
if self.audience_open {
self.audience_full = !self.audience_full;
ctx.send_viewport_cmd_to(audience_id(), ViewportCommand::Fullscreen(self.audience_full));
if !cfg!(target_os = "macos") || self.displays.len() < 2 {
ctx.send_viewport_cmd_to(audience_id(), ViewportCommand::Fullscreen(self.audience_full));
}
} else {
let on = ctx.input(|i| i.viewport().fullscreen.unwrap_or(false));
ctx.send_viewport_cmd_to(ViewportId::ROOT, ViewportCommand::Fullscreen(!on));
Expand Down
6 changes: 6 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ impl eframe::App for Root {
self.app.script_input(raw);
}

#[cfg(target_os = "macos")]
fn on_exit(&mut self) {
self.app.on_exit();
}

#[cfg(not(target_os = "macos"))]
fn on_exit(&mut self, _gl: Option<&eframe::glow::Context>) {
self.app.on_exit();
}
Expand Down
63 changes: 59 additions & 4 deletions src/ui_present.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,46 @@ fn soft_button(ui: &Ui, r: Rect, id: &str, tip: &str, enabled: bool, active: boo
resp
}

#[cfg(target_os = "macos")]
fn set_macos_audience_fullscreen(title: &str, display_id: u32, fullscreen: bool) {
use objc2::MainThreadMarker;
use objc2_app_kit::{NSApplication, NSScreen, NSWindowStyleMask, NSMainMenuWindowLevel, NSNormalWindowLevel};
use objc2_foundation::{NSNumber, NSString};

let Some(mtm) = MainThreadMarker::new() else { return };
let title = NSString::from_str(title);
let windows = NSApplication::sharedApplication(mtm).windows();
let fullscreen_level = NSMainMenuWindowLevel + 1;
let Some(window) = windows.iter().find(|window| {
window.title().isEqualToString(&title)
&& (window.level() == fullscreen_level
|| !window.styleMask().intersects(NSWindowStyleMask::Titled | NSWindowStyleMask::FullScreen))
}) else { return };
if !fullscreen {
if window.level() == fullscreen_level {
window.setLevel(NSNormalWindowLevel);
}
return;
}

let screen_number = NSString::from_str("NSScreenNumber");
let screens = NSScreen::screens(mtm);
let Some(screen) = screens.iter().find(|screen| {
screen.deviceDescription().objectForKey(&screen_number)
.and_then(|number| number.downcast::<NSNumber>().ok())
.is_some_and(|number| number.unsignedIntValue() == display_id)
}) else { return };

// Above the menu bar, AppKit can use the display frame instead of its visible work area.
if window.level() != fullscreen_level {
window.setLevel(fullscreen_level);
}
let frame = screen.frame();
if window.frame() != frame {
window.setFrame_display(frame, true);
}
}

impl App {
/// Draws one PDF page region. Returns false while no picture is available yet.
pub fn paint_page(&mut self, ui: &Ui, rect: Rect, page: usize, region: Region, uv: Rect) -> bool {
Expand Down Expand Up @@ -1797,6 +1837,7 @@ impl App {
}

pub fn audience_window(&mut self, ctx: &Context) {
const TITLE: &str = "TeXora Audience View";
if !self.audience_open {
return;
}
Expand All @@ -1807,15 +1848,23 @@ impl App {
self.activate(i);
}
let multi = self.displays.len() >= 2;
let mut vb = ViewportBuilder::default().with_title("TeXora Audience View").with_inner_size([960.0, 720.0]);
let mut vb = ViewportBuilder::default().with_title(TITLE)
.with_decorations(true).with_inner_size([960.0, 720.0]);
if multi {
if let Some(d) = self.displays.get(self.display) {
let scale = if cfg!(target_os = "macos") { 1.0 } else { d.scale_factor.max(1.0) };
vb = vb.with_position(pos2(d.x as f32 / scale + 20.0, d.y as f32 / scale + 20.0));
let scale = if cfg!(target_os = "macos") { ctx.zoom_factor() } else { d.scale_factor.max(1.0) };
let origin = pos2(d.x as f32 / scale, d.y as f32 / scale);
if cfg!(target_os = "macos") && self.audience_full {
// A native fullscreen Space can hide the presenter on the other display.
vb = vb.with_decorations(false).with_position(origin)
.with_inner_size([d.width as f32 / scale, d.height as f32 / scale]);
} else {
vb = vb.with_position(origin + vec2(20.0, 20.0));
}
}
}
let id = audience_id();
if multi && self.audience_age == 12 && !self.audience_full {
if !cfg!(target_os = "macos") && multi && self.audience_age == 12 && !self.audience_full {
self.audience_full = true;
ctx.send_viewport_cmd_to(id, ViewportCommand::Fullscreen(true));
}
Expand All @@ -1834,6 +1883,12 @@ impl App {
c.set_cursor_icon(CursorIcon::None);
}
});
#[cfg(target_os = "macos")]
if multi && self.audience_open {
if let Some(display) = self.displays.get(self.display) {
set_macos_audience_fullscreen(TITLE, display.id, self.audience_full);
}
}
if let Some(i) = self.tab_index(front) {
self.activate(i);
}
Expand Down
Loading