Skip to content
Open
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
1 change: 1 addition & 0 deletions PATCHES.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Drop a patch when an egui release in use contains it.
| E19 | `d64047bf`, `642b74f7`, `baeb4515` | egui-winit, egui | one letter-key rule for Windows, macOS and Linux (first Latin group); `RawInput::keyboard_layout_is_latin`; `RawInput::latin_layout_chars` (each key's Latin layout character, so a key without a Latin letter is no letter shortcut) | fork-only until winit has the APIs | shortcuts on non-Latin layouts; needs winit `craft/0.30.13-lang` |
| E20 | `23955535` | egui | widget text laid out in the language of its `Ui` | fork-only (goes with E15 and E17) | language support |
| E21 | `a70470b0` | egui-winit, egui | `ImeEvent::DeleteSurroundingBytes`: `TextEdit` deletes the exact bytes an input method replaces, in the commit's undo step | not proposed | macOS press-and-hold and dictation, Wayland input methods; needs winit `craft/0.30.13-lang` |
| E33 | on `craft/system-theme-event` (off `craft/ime-reset-retired`) | egui, egui-winit, eframe | `Event::SystemTheme(Theme)`: the integration reports the OS's light or dark preference as an event when it first knows it and on each change (egui-winit at `State::new` and on `WindowEvent::ThemeChanged`, eframe web at start and on the `prefers-color-scheme` change), beside `RawInput::system_theme` | upstreamable | craft-ui: the runtime's OS appearance reader takes the mode from the event and raises its generation on a change, with no per-frame compare |

E1 changes from `e7e37ad`: the hooks are installed in `init_native`, so `create_native` uses them too, and a
unit test covers installing and replacing them. E2+E3 is the same change as `b02321d` with a `surface_fit`
Expand Down
7 changes: 7 additions & 0 deletions crates/eframe/src/web/app_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,13 @@ impl AppRunner {
.or_default()
.native_pixels_per_point = Some(super::native_pixels_per_point());
runner.input.raw.system_theme = super::system_theme();
if let Some(theme) = runner.input.raw.system_theme {
runner
.input
.raw
.events
.push(egui::Event::SystemTheme(theme));
}

Ok(runner)
}
Expand Down
5 changes: 5 additions & 0 deletions crates/eframe/src/web/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,11 @@ fn install_color_scheme_change_event(
|_event, runner| {
if let Some(theme) = super::system_theme() {
runner.input.raw.system_theme = Some(theme);
runner
.input
.raw
.events
.push(egui::Event::SystemTheme(theme));
runner.needs_repaint.repaint_asap();
}
},
Expand Down
7 changes: 6 additions & 1 deletion crates/egui-winit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,9 @@ impl State {
.or_default()
.native_pixels_per_point = native_pixels_per_point;
slf.egui_input.system_theme = theme.map(to_egui_theme);
if let Some(theme) = slf.egui_input.system_theme {
slf.egui_input.events.push(egui::Event::SystemTheme(theme));
}

if let Some(max_texture_side) = max_texture_side {
slf.set_max_texture_side(max_texture_side);
Expand Down Expand Up @@ -2326,7 +2329,9 @@ impl State {
}
}
WindowEvent::ThemeChanged(winit_theme) => {
self.egui_input.system_theme = Some(to_egui_theme(*winit_theme));
let theme = to_egui_theme(*winit_theme);
self.egui_input.system_theme = Some(theme);
self.egui_input.events.push(egui::Event::SystemTheme(theme));
EventResponse {
repaint: true,
consumed: false,
Expand Down
8 changes: 7 additions & 1 deletion crates/egui/src/data/input/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use epaint::ColorImage;

use crate::MouseWheelSource;
use crate::{
Key,
Key, Theme,
emath::{Pos2, Vec2},
};

Expand Down Expand Up @@ -212,6 +212,12 @@ pub enum Event {
/// The native window gained or lost focused (e.g. the user clicked alt-tab).
WindowFocused(bool),

/// The OS's light or dark preference: sent with the first input once the integration knows
/// it, and again each time the OS reports it (a repeat of the same theme is possible).
///
/// [`crate::RawInput::system_theme`] holds the same value; this event is the change notice.
SystemTheme(Theme),

/// An assistive technology (e.g. screen reader) requested an action.
AccessKitActionRequest(accesskit::ActionRequest),
}
Loading