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 winit to 0.30.3 #4702

Closed
wants to merge 7 commits into from
Closed
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
648 changes: 436 additions & 212 deletions Cargo.lock

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,27 +75,27 @@ bytemuck = "1.7.2"
criterion = { version = "0.5.1", default-features = false }
document-features = " 0.2.8"
glow = "0.13"
glutin = "0.31"
glutin-winit = "0.4"
glutin = "0.32.0"
glutin-winit = "0.5.0"
image = { version = "0.25", default-features = false }
log = { version = "0.4", features = ["std"] }
nohash-hasher = "0.2"
parking_lot = "0.12"
puffin = "0.19"
puffin_http = "0.16"
ron = "0.8"
raw-window-handle = "0.6.0"
raw-window-handle = "0.6.2"
serde = { version = "1", features = ["derive"] }
thiserror = "1.0.37"
web-time = "0.2" # Timekeeping for native and web
wasm-bindgen = "0.2"
wasm-bindgen-futures = "0.4"
web-sys = "0.3.58"
wgpu = { version = "0.20.0", default-features = false, features = [
wgpu = { version = "0.20.1", default-features = false, features = [
# Make the renderer `Sync` even on wasm32, because it makes the code simpler:
"fragile-send-sync-non-atomic-wasm",
] }
winit = { version = "0.29.4", default-features = false }
winit = { version = "0.30.3", default-features = false }


[workspace.lints.rust]
Expand Down
15 changes: 4 additions & 11 deletions crates/eframe/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,7 @@ android-native-activity = ["egui-winit/android-native-activity"]
default_fonts = ["egui/default_fonts"]

## Use [`glow`](https://github.com/grovesNL/glow) for painting, via [`egui_glow`](https://github.com/emilk/egui/tree/master/crates/egui_glow).
glow = [
"dep:egui_glow",
"dep:glow",
"dep:glutin-winit",
"dep:glutin",
"dep:rwh_05",
"winit/rwh_05",
]
glow = ["dep:egui_glow", "dep:glow", "dep:glutin-winit", "dep:glutin"]

## Enable saving app state to disk.
persistence = [
Expand Down Expand Up @@ -142,9 +135,9 @@ web-time.workspace = true
egui_glow = { workspace = true, optional = true, default-features = false }
glow = { workspace = true, optional = true }
# glutin stuck on old version of raw-window-handle:
rwh_05 = { package = "raw-window-handle", version = "0.5.2", optional = true, features = [
"std",
] }
#rwh_06 = { package = "raw-window-handle", version = "0.6.2", optional = true, features = [
# "std",
#] }
Comment on lines +138 to +140
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rm dead code

ron = { workspace = true, optional = true, features = ["integer128"] }
serde = { workspace = true, optional = true }

Expand Down
2 changes: 1 addition & 1 deletion crates/eframe/src/epi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use static_assertions::assert_not_impl_any;

#[cfg(not(target_arch = "wasm32"))]
#[cfg(any(feature = "glow", feature = "wgpu"))]
pub use winit::{event_loop::EventLoopBuilder, window::WindowBuilder};
pub use winit::event_loop::EventLoopBuilder;

/// Hook into the building of an event loop before it is run
///
Expand Down
13 changes: 5 additions & 8 deletions crates/eframe/src/native/epi_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use web_time::Instant;

use std::path::PathBuf;
use winit::event_loop::EventLoopWindowTarget;
use winit::event_loop::ActiveEventLoop;

use raw_window_handle::{HasDisplayHandle as _, HasWindowHandle as _};

Expand All @@ -12,9 +12,9 @@ use egui_winit::{EventResponse, WindowSettings};

use crate::{epi, Theme};

pub fn viewport_builder<E>(
pub fn viewport_builder(
egui_zoom_factor: f32,
event_loop: &EventLoopWindowTarget<E>,
event_loop: &ActiveEventLoop,
native_options: &mut epi::NativeOptions,
window_settings: Option<WindowSettings>,
) -> ViewportBuilder {
Expand Down Expand Up @@ -95,10 +95,7 @@ pub fn apply_window_settings(
}
}

fn largest_monitor_point_size<E>(
egui_zoom_factor: f32,
event_loop: &EventLoopWindowTarget<E>,
) -> egui::Vec2 {
fn largest_monitor_point_size(egui_zoom_factor: f32, event_loop: &ActiveEventLoop) -> egui::Vec2 {
crate::profile_function!();

let mut max_size = egui::Vec2::ZERO;
Expand Down Expand Up @@ -232,7 +229,7 @@ impl EpiIntegration {
}

#[cfg(feature = "accesskit")]
pub fn init_accesskit<E: From<egui_winit::accesskit_winit::ActionRequestEvent> + Send>(
pub fn init_accesskit<E: From<egui_winit::accesskit_winit::Event> + Send>(
&self,
egui_winit: &mut egui_winit::State,
window: &winit::window::Window,
Expand Down
57 changes: 33 additions & 24 deletions crates/eframe/src/native/glow_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ use glutin::{
prelude::{GlDisplay, PossiblyCurrentGlContext},
surface::GlSurface,
};
use raw_window_handle::HasWindowHandle;
use winit::{
event_loop::{EventLoop, EventLoopProxy, EventLoopWindowTarget},
event_loop::{ActiveEventLoop, EventLoop, EventLoopProxy},
window::{Window, WindowId},
};

Expand Down Expand Up @@ -145,7 +146,7 @@ impl GlowWinitApp {
#[allow(unsafe_code)]
fn create_glutin_windowed_context(
egui_ctx: &egui::Context,
event_loop: &EventLoopWindowTarget<UserEvent>,
event_loop: &ActiveEventLoop,
storage: Option<&dyn Storage>,
native_options: &mut NativeOptions,
) -> Result<(GlutinWindowContext, egui_glow::Painter)> {
Expand Down Expand Up @@ -189,10 +190,7 @@ impl GlowWinitApp {
Ok((glutin_window_context, painter))
}

fn init_run_state(
&mut self,
event_loop: &EventLoopWindowTarget<UserEvent>,
) -> Result<&mut GlowWinitRunning> {
fn init_run_state(&mut self, event_loop: &ActiveEventLoop) -> Result<&mut GlowWinitRunning> {
crate::profile_function!();

let storage = if let Some(file) = &self.native_options.persistence_path {
Expand Down Expand Up @@ -325,7 +323,7 @@ impl GlowWinitApp {
let painter = Rc::downgrade(&painter);
let beginning = integration.beginning;

let event_loop: *const EventLoopWindowTarget<UserEvent> = event_loop;
let event_loop: *const ActiveEventLoop = event_loop;

egui::Context::set_immediate_viewport_renderer(move |egui_ctx, immediate_viewport| {
if let (Some(glutin), Some(painter)) = (glutin.upgrade(), painter.upgrade()) {
Expand Down Expand Up @@ -396,7 +394,7 @@ impl WinitApp for GlowWinitApp {

fn run_ui_and_paint(
&mut self,
event_loop: &EventLoopWindowTarget<UserEvent>,
event_loop: &ActiveEventLoop,
window_id: WindowId,
) -> EventResult {
if let Some(running) = &mut self.running {
Expand All @@ -408,7 +406,7 @@ impl WinitApp for GlowWinitApp {

fn on_event(
&mut self,
event_loop: &EventLoopWindowTarget<UserEvent>,
event_loop: &ActiveEventLoop,
event: &winit::event::Event<UserEvent>,
) -> Result<EventResult> {
crate::profile_function!(winit_integration::short_event_description(event));
Expand Down Expand Up @@ -476,7 +474,10 @@ impl WinitApp for GlowWinitApp {

#[cfg(feature = "accesskit")]
winit::event::Event::UserEvent(UserEvent::AccessKitActionRequest(
accesskit_winit::ActionRequestEvent { request, window_id },
accesskit_winit::Event {
window_id,
window_event: accesskit_winit::WindowEvent::ActionRequested(request),
},
)) => {
if let Some(running) = &self.running {
let mut glutin = running.glutin.borrow_mut();
Expand All @@ -503,7 +504,7 @@ impl WinitApp for GlowWinitApp {
impl GlowWinitRunning {
fn run_ui_and_paint(
&mut self,
event_loop: &EventLoopWindowTarget<UserEvent>,
event_loop: &ActiveEventLoop,
window_id: WindowId,
) -> EventResult {
crate::profile_function!();
Expand Down Expand Up @@ -898,7 +899,7 @@ impl GlutinWindowContext {
egui_ctx: &egui::Context,
viewport_builder: ViewportBuilder,
native_options: &NativeOptions,
event_loop: &EventLoopWindowTarget<UserEvent>,
event_loop: &ActiveEventLoop,
) -> Result<Self> {
crate::profile_function!();

Expand Down Expand Up @@ -947,7 +948,7 @@ impl GlutinWindowContext {
let display_builder = glutin_winit::DisplayBuilder::new()
// we might want to expose this option to users in the future. maybe using an env var or using native_options.
.with_preference(glutin_winit::ApiPreference::FallbackEgl) // https://github.com/emilk/egui/issues/2520#issuecomment-1367841150
.with_window_builder(Some(egui_winit::create_winit_window_builder(
.with_window_attributes(Some(egui_winit::create_winit_window_attributes(
egui_ctx,
event_loop,
viewport_builder.clone(),
Expand Down Expand Up @@ -983,8 +984,9 @@ impl GlutinWindowContext {
gl_display.supported_features()
);
let glutin_raw_window_handle = window.as_ref().map(|w| {
use rwh_05::HasRawWindowHandle as _; // glutin stuck on old version of raw-window-handle
w.raw_window_handle()
w.window_handle()
.expect("failed to get window handle")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Return errors

.as_raw()
});
log::debug!("creating gl context using raw window handle: {glutin_raw_window_handle:?}");

Expand Down Expand Up @@ -1070,7 +1072,7 @@ impl GlutinWindowContext {
/// Create a surface, window, and winit integration for all viewports lacking any of that.
///
/// Errors will be logged.
fn initialize_all_windows(&mut self, event_loop: &EventLoopWindowTarget<UserEvent>) {
fn initialize_all_windows(&mut self, event_loop: &ActiveEventLoop) {
crate::profile_function!();

let viewports: Vec<ViewportId> = self.viewports.keys().copied().collect();
Expand All @@ -1087,7 +1089,7 @@ impl GlutinWindowContext {
pub(crate) fn initialize_window(
&mut self,
viewport_id: ViewportId,
event_loop: &EventLoopWindowTarget<UserEvent>,
event_loop: &ActiveEventLoop,
) -> Result {
crate::profile_function!();

Expand All @@ -1100,17 +1102,18 @@ impl GlutinWindowContext {
window
} else {
log::debug!("Creating a window for viewport {viewport_id:?}");
let window_builder = egui_winit::create_winit_window_builder(
let window_attributes = egui_winit::create_winit_window_attributes(
&self.egui_ctx,
event_loop,
viewport.builder.clone(),
);
if window_builder.transparent() && self.gl_config.supports_transparency() == Some(false)
if window_attributes.transparent()
&& self.gl_config.supports_transparency() == Some(false)
{
log::error!("Cannot create transparent window: the GL config does not support it");
}
let window =
glutin_winit::finalize_window(event_loop, window_builder, &self.gl_config)?;
glutin_winit::finalize_window(event_loop, window_attributes, &self.gl_config)?;
egui_winit::apply_viewport_builder_to_window(
&self.egui_ctx,
&window,
Expand Down Expand Up @@ -1140,9 +1143,15 @@ impl GlutinWindowContext {
let width_px = NonZeroU32::new(width_px).unwrap_or(NonZeroU32::MIN);
let height_px = NonZeroU32::new(height_px).unwrap_or(NonZeroU32::MIN);
let surface_attributes = {
use rwh_05::HasRawWindowHandle as _; // glutin stuck on old version of raw-window-handle
glutin::surface::SurfaceAttributesBuilder::<glutin::surface::WindowSurface>::new()
.build(window.raw_window_handle(), width_px, height_px)
.build(
window
.window_handle()
.expect("failed to get window handle")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want crashes. Return errors instead. Here and everywhere.
Add a case to eframe::Error if needed

.as_raw(),
width_px,
height_px,
)
};

log::trace!("creating surface with attributes: {surface_attributes:?}");
Expand Down Expand Up @@ -1253,7 +1262,7 @@ impl GlutinWindowContext {

fn handle_viewport_output(
&mut self,
event_loop: &EventLoopWindowTarget<UserEvent>,
event_loop: &ActiveEventLoop,
egui_ctx: &egui::Context,
viewport_output: &ViewportIdMap<ViewportOutput>,
) {
Expand Down Expand Up @@ -1375,7 +1384,7 @@ fn initialize_or_update_viewport(
/// This is called (via a callback) by user code to render immediate viewports,
/// i.e. viewport that are directly nested inside a parent viewport.
fn render_immediate_viewport(
event_loop: &EventLoopWindowTarget<UserEvent>,
event_loop: &ActiveEventLoop,
egui_ctx: &egui::Context,
glutin: &RefCell<GlutinWindowContext>,
painter: &RefCell<egui_glow::Painter>,
Expand Down
2 changes: 1 addition & 1 deletion crates/eframe/src/native/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fn create_event_loop_builder(
native_options: &mut epi::NativeOptions,
) -> EventLoopBuilder<UserEvent> {
crate::profile_function!();
let mut event_loop_builder = winit::event_loop::EventLoopBuilder::with_user_event();
let mut event_loop_builder = winit::event_loop::EventLoopBuilder::default();

if let Some(hook) = std::mem::take(&mut native_options.event_loop_builder) {
hook(&mut event_loop_builder);
Expand Down
Loading
Loading