Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to winit 0.29 #3649

Merged
merged 51 commits into from
Dec 18, 2023
Merged
Changes from 1 commit
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
fc7d37e
Update to winit 0.29
fornwall Nov 27, 2023
c863714
Use 0.29.4 also in eframe and egui-wgpu
fornwall Nov 27, 2023
fc43372
Revert accidental change
fornwall Nov 27, 2023
12a27ce
Fix accidental change
fornwall Nov 27, 2023
7746482
Revert empty line removal
fornwall Nov 27, 2023
3eb6d91
Fix accidental commit reversal
fornwall Nov 27, 2023
e5d5076
Fix accidental commit reversal
fornwall Nov 27, 2023
258e49f
Revert accidental change
fornwall Nov 27, 2023
2191a3b
Fix accidental reversal
fornwall Nov 27, 2023
fc2c142
Fix accidental reversal
fornwall Nov 27, 2023
3e55b1e
Update links in docs
fornwall Nov 28, 2023
a8e3c95
Merge branch 'master' into winit-0.29
emilk Nov 28, 2023
8c8f2f6
Update to cocoa 0.25.0
emilk Nov 28, 2023
3dc23de
Update to smithay-clipboard 0.7.0
emilk Nov 28, 2023
0d822c9
Updating plist v1.5.0 -> v1.5.1
emilk Nov 28, 2023
7c89b67
Simplify egui_extras dependency list for the svg feature
emilk Nov 28, 2023
0dbd597
Update deny.toml
emilk Nov 28, 2023
b4e6246
Fix svg-related build problem
emilk Nov 28, 2023
bb5e077
Return errors when creating event loop
emilk Nov 28, 2023
fefa5af
Move warning comment
emilk Nov 28, 2023
1df781d
Remove noop responses to ScaleFactorChanged
emilk Nov 28, 2023
6b714a7
Remove `Prefence` typo exception
emilk Nov 28, 2023
87870b3
Rename `ViewportCommand::IMEPosition` to `IMERect`
emilk Nov 28, 2023
fca3690
Log result of request_inner_size
emilk Nov 28, 2023
b5fcda1
Fix event loop and improve trace logging
emilk Nov 28, 2023
5914871
Code cleanup
emilk Nov 28, 2023
d7c57d4
Clean up modifiers code
emilk Nov 28, 2023
9b997a5
Fix IME output
emilk Nov 28, 2023
98ae3ef
Fix typo
emilk Nov 28, 2023
9d0037f
Don't treat `cmd+C` etc as text input on Mac
emilk Nov 28, 2023
dc1a95e
Output logical keys from winit, and document that fact
emilk Nov 28, 2023
054cedc
Fix Windows build
emilk Nov 28, 2023
4cfa02a
Fix windows build for real
emilk Nov 28, 2023
9805317
No really, fix the Windows issue
emilk Nov 28, 2023
dfa6676
Remove outdated(?) windows hack
emilk Nov 28, 2023
666e099
Add `wgpu` feature to `multiple_viewports` example
emilk Nov 28, 2023
b74bfd9
Code cleanup and better logging
emilk Nov 28, 2023
9976c7b
Fix secondary viewports with glow backend
emilk Nov 28, 2023
9cb45f1
Clean up code around window creation
emilk Nov 28, 2023
43b18ce
Add warning when failing to create transparent window
emilk Nov 28, 2023
58a9621
Add `Key::from_name` helper
emilk Nov 28, 2023
edaf2a3
Add keys: period, comma, colon, semicolon
emilk Nov 28, 2023
70ed053
Improve docstring
emilk Nov 28, 2023
a624f74
Ignore text on key release and when ctrl is down
emilk Nov 30, 2023
3dd8604
Merge branch 'master' into winit-0.29
emilk Nov 30, 2023
d076bdc
Only register printable text
emilk Dec 1, 2023
bc5c6d1
Merge branch 'master' into winit-0.29
emilk Dec 6, 2023
a13959a
Fix modifiers on Linux
emilk Dec 6, 2023
68ff3ec
Merge branch 'master' into winit-0.29
emilk Dec 18, 2023
d63deb7
Update deny.toml
emilk Dec 18, 2023
1c14bd9
Merge branch 'master' into winit-0.29
emilk Dec 18, 2023
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
Prev Previous commit
Next Next commit
Fix IME output
emilk committed Nov 28, 2023
commit 9b997a5957deca8054f3ae36b09e93e7a762fe0f
12 changes: 6 additions & 6 deletions crates/eframe/src/web/app_runner.rs
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ pub struct AppRunner {
app: Box<dyn epi::App>,
pub(crate) needs_repaint: std::sync::Arc<NeedRepaint>,
last_save_time: f64,
pub(crate) text_cursor_pos: Option<egui::Pos2>,
pub(crate) ime: Option<egui::output::IMEOutput>,
pub(crate) mutable_text_under_cursor: bool,

// Output for the last run:
@@ -112,7 +112,7 @@ impl AppRunner {
app,
needs_repaint,
last_save_time: now_sec(),
text_cursor_pos: None,
ime: None,
mutable_text_under_cursor: false,
textures_delta: Default::default(),
clipped_primitives: None,
@@ -244,7 +244,7 @@ impl AppRunner {
copied_text,
events: _, // already handled
mutable_text_under_cursor,
text_cursor_pos,
ime,
#[cfg(feature = "accesskit")]
accesskit_update: _, // not currently implemented
} = platform_output;
@@ -264,9 +264,9 @@ impl AppRunner {

self.mutable_text_under_cursor = mutable_text_under_cursor;

if self.text_cursor_pos != text_cursor_pos {
super::text_agent::move_text_cursor(text_cursor_pos, self.canvas_id());
self.text_cursor_pos = text_cursor_pos;
if self.ime != ime {
super::text_agent::move_text_cursor(ime, self.canvas_id());
self.ime = ime;
}
}
}
8 changes: 5 additions & 3 deletions crates/eframe/src/web/text_agent.rs
Original file line number Diff line number Diff line change
@@ -205,11 +205,13 @@ fn is_mobile() -> Option<bool> {
// candidate window moves following text element (agent),
// so it appears that the IME candidate window moves with text cursor.
// On mobile devices, there is no need to do that.
pub fn move_text_cursor(cursor: Option<egui::Pos2>, canvas_id: &str) -> Option<()> {
pub fn move_text_cursor(ime: Option<egui::output::IMEOutput>, canvas_id: &str) -> Option<()> {
let style = text_agent().style();
// Note: movint agent on mobile devices will lead to unpredictable scroll.
// Note: moving agent on mobile devices will lead to unpredictable scroll.
if is_mobile() == Some(false) {
cursor.as_ref().and_then(|&egui::Pos2 { x, y }| {
ime.as_ref().and_then(|ime| {
let egui::Pos2 { x, y } = ime.cursor_rect.left_top();

let canvas = canvas_element(canvas_id)?;
let bounding_rect = text_agent().get_bounding_client_rect();
let y = (y + (canvas.scroll_top() + canvas.offset_top()) as f32)
20 changes: 12 additions & 8 deletions crates/egui-winit/src/lib.rs
Original file line number Diff line number Diff line change
@@ -702,7 +702,7 @@ impl State {
copied_text,
events: _, // handled elsewhere
mutable_text_under_cursor: _, // only used in eframe web
text_cursor_pos,
ime,
#[cfg(feature = "accesskit")]
accesskit_update,
} = platform_output;
@@ -719,19 +719,23 @@ impl State {
self.clipboard.set(copied_text);
}

let allow_ime = text_cursor_pos.is_some();
let allow_ime = ime.is_some();
if self.allow_ime != allow_ime {
self.allow_ime = allow_ime;
window.set_ime_allowed(allow_ime);
}

if let Some(egui::Pos2 { x, y }) = text_cursor_pos {
if let Some(ime) = ime {
let rect = ime.rect;
let pixels_per_point = self.pixels_per_point();
window.set_ime_cursor_area(
winit::dpi::LogicalPosition { x, y },
winit::dpi::LogicalSize {
// TODO: What size to use? New size arg in winit 0.29
width: 10,
height: 10,
winit::dpi::PhysicalPosition {
x: pixels_per_point * rect.min.x,
y: pixels_per_point * rect.min.y,
},
winit::dpi::PhysicalSize {
width: pixels_per_point * rect.width(),
height: pixels_per_point * rect.height(),
},
);
}
25 changes: 20 additions & 5 deletions crates/egui/src/data/output.rs
Original file line number Diff line number Diff line change
@@ -62,6 +62,21 @@
}
}

/// Information about text beeing edited.

Check warning on line 65 in crates/egui/src/data/output.rs

GitHub Actions / typos

"beeing" should be "being" or "been".
///
/// Useful for IME.
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct IMEOutput {
/// Where the [`crate::TextEdit`] is located on screen.
pub rect: crate::Rect,

/// Where the cursor is.
///
/// This is a very thin rectangle.
pub cursor_rect: crate::Rect,
}

/// The non-rendering part of what egui emits each frame.
///
/// You can access (and modify) this with [`crate::Context::output`].
@@ -96,10 +111,10 @@
/// Use by `eframe` web to show/hide mobile keyboard and IME agent.
pub mutable_text_under_cursor: bool,

/// Screen-space position of text edit cursor (used for IME).
/// This is et if, and only if, the user is currently editing text.
///
/// Iff `Some`, the user is editing text.
pub text_cursor_pos: Option<crate::Pos2>,
/// Useful for IME.
pub ime: Option<IMEOutput>,

/// The difference in the widget tree since last frame.
///
@@ -143,7 +158,7 @@
copied_text,
mut events,
mutable_text_under_cursor,
text_cursor_pos,
ime,
#[cfg(feature = "accesskit")]
accesskit_update,
} = newer;
@@ -157,7 +172,7 @@
}
self.events.append(&mut events);
self.mutable_text_under_cursor = mutable_text_under_cursor;
self.text_cursor_pos = text_cursor_pos.or(self.text_cursor_pos);
self.ime = ime.or(self.ime);

#[cfg(feature = "accesskit")]
{
21 changes: 6 additions & 15 deletions crates/egui/src/widgets/text_edit/builder.rs
Original file line number Diff line number Diff line change
@@ -688,7 +688,7 @@ impl<'t> TextEdit<'t> {
paint_cursor_selection(ui, &painter, text_draw_pos, &galley, &cursor_range);

if text.is_mutable() {
let cursor_pos = paint_cursor_end(
let cursor_rect = paint_cursor_end(
ui,
row_height,
&painter,
@@ -699,23 +699,14 @@ impl<'t> TextEdit<'t> {

let is_fully_visible = ui.clip_rect().contains_rect(rect); // TODO: remove this HACK workaround for https://github.com/emilk/egui/issues/1531
if (response.changed || selection_changed) && !is_fully_visible {
ui.scroll_to_rect(cursor_pos, None); // keep cursor in view
ui.scroll_to_rect(cursor_rect, None); // keep cursor in view
}

if interactive {
// eframe web uses `text_cursor_pos` when showing IME,
// so only set it when text is editable and visible!
// But `winit` and `egui_web` differs in how to set the
// position of IME.
if cfg!(target_arch = "wasm32") {
ui.ctx().output_mut(|o| {
o.text_cursor_pos = Some(cursor_pos.left_top());
});
} else {
ui.ctx().output_mut(|o| {
o.text_cursor_pos = Some(cursor_pos.left_bottom());
});
}
// For IME, so only set it when text is editable and visible!
ui.ctx().output_mut(|o| {
o.ime = Some(crate::output::IMEOutput { rect, cursor_rect });
});
}
}
}