-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
update winit to 0.30.3 #4702
Changes from all commits
2bf1f02
c283ce6
f6e5d00
80f1b93
4b76e82
c1f1746
eb873d5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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}, | ||
}; | ||
|
||
|
@@ -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)> { | ||
|
@@ -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 { | ||
|
@@ -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()) { | ||
|
@@ -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 { | ||
|
@@ -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)); | ||
|
@@ -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(); | ||
|
@@ -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!(); | ||
|
@@ -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!(); | ||
|
||
|
@@ -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(), | ||
|
@@ -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") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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:?}"); | ||
|
||
|
@@ -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(); | ||
|
@@ -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!(); | ||
|
||
|
@@ -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, | ||
|
@@ -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") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't want crashes. Return errors instead. Here and everywhere. |
||
.as_raw(), | ||
width_px, | ||
height_px, | ||
) | ||
}; | ||
|
||
log::trace!("creating surface with attributes: {surface_attributes:?}"); | ||
|
@@ -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>, | ||
) { | ||
|
@@ -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>, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rm dead code