Fix: make sure always_on_top is respected on glow again
This commit is contained in:
parent
449dd1c23c
commit
0fc25c2680
2 changed files with 18 additions and 11 deletions
|
@ -64,6 +64,7 @@ pub fn read_window_info(
|
||||||
monitor_size,
|
monitor_size,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn window_builder<E>(
|
pub fn window_builder<E>(
|
||||||
event_loop: &EventLoopWindowTarget<E>,
|
event_loop: &EventLoopWindowTarget<E>,
|
||||||
title: &str,
|
title: &str,
|
||||||
|
@ -159,23 +160,17 @@ pub fn window_builder<E>(
|
||||||
}
|
}
|
||||||
window_builder
|
window_builder
|
||||||
}
|
}
|
||||||
pub fn build_window<E>(
|
|
||||||
event_loop: &EventLoopWindowTarget<E>,
|
|
||||||
title: &str,
|
|
||||||
native_options: &epi::NativeOptions,
|
|
||||||
window_settings: Option<WindowSettings>,
|
|
||||||
) -> Result<winit::window::Window, winit::error::OsError> {
|
|
||||||
let window_builder = window_builder(event_loop, title, native_options, window_settings);
|
|
||||||
let window = window_builder.build(event_loop)?;
|
|
||||||
|
|
||||||
|
pub fn apply_native_options_to_window(
|
||||||
|
window: &winit::window::Window,
|
||||||
|
native_options: &crate::NativeOptions,
|
||||||
|
) {
|
||||||
use winit::window::WindowLevel;
|
use winit::window::WindowLevel;
|
||||||
window.set_window_level(if native_options.always_on_top {
|
window.set_window_level(if native_options.always_on_top {
|
||||||
WindowLevel::AlwaysOnTop
|
WindowLevel::AlwaysOnTop
|
||||||
} else {
|
} else {
|
||||||
WindowLevel::Normal
|
WindowLevel::Normal
|
||||||
});
|
});
|
||||||
|
|
||||||
Ok(window)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn largest_monitor_point_size<E>(event_loop: &EventLoopWindowTarget<E>) -> egui::Vec2 {
|
fn largest_monitor_point_size<E>(event_loop: &EventLoopWindowTarget<E>) -> egui::Vec2 {
|
||||||
|
|
|
@ -457,6 +457,7 @@ mod glow_integration {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let not_current_gl_context = Some(gl_context);
|
let not_current_gl_context = Some(gl_context);
|
||||||
|
|
||||||
// the fun part with opengl gl is that we never know whether there is an error. the context creation might have failed, but
|
// the fun part with opengl gl is that we never know whether there is an error. the context creation might have failed, but
|
||||||
// it could keep working until we try to make surface current or swap buffers or something else. future glutin improvements might
|
// it could keep working until we try to make surface current or swap buffers or something else. future glutin improvements might
|
||||||
// help us start from scratch again if we fail context creation and go back to preferEgl or try with different config etc..
|
// help us start from scratch again if we fail context creation and go back to preferEgl or try with different config etc..
|
||||||
|
@ -471,6 +472,7 @@ mod glow_integration {
|
||||||
not_current_gl_context,
|
not_current_gl_context,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This will be run after `new`. on android, it might be called multiple times over the course of the app's lifetime.
|
/// This will be run after `new`. on android, it might be called multiple times over the course of the app's lifetime.
|
||||||
/// roughly,
|
/// roughly,
|
||||||
/// 1. check if window already exists. otherwise, create one now.
|
/// 1. check if window already exists. otherwise, create one now.
|
||||||
|
@ -546,6 +548,7 @@ mod glow_integration {
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn window(&self) -> &winit::window::Window {
|
fn window(&self) -> &winit::window::Window {
|
||||||
self.window.as_ref().expect("winit window doesn't exist")
|
self.window.as_ref().expect("winit window doesn't exist")
|
||||||
}
|
}
|
||||||
|
@ -631,6 +634,11 @@ mod glow_integration {
|
||||||
GlutinWindowContext::new(winit_window_builder, native_options, event_loop)?
|
GlutinWindowContext::new(winit_window_builder, native_options, event_loop)?
|
||||||
};
|
};
|
||||||
glutin_window_context.on_resume(event_loop)?;
|
glutin_window_context.on_resume(event_loop)?;
|
||||||
|
|
||||||
|
if let Some(window) = &glutin_window_context.window {
|
||||||
|
epi_integration::apply_native_options_to_window(window, native_options);
|
||||||
|
}
|
||||||
|
|
||||||
let gl = unsafe {
|
let gl = unsafe {
|
||||||
glow::Context::from_loader_function(|s| {
|
glow::Context::from_loader_function(|s| {
|
||||||
let s = std::ffi::CString::new(s)
|
let s = std::ffi::CString::new(s)
|
||||||
|
@ -1047,7 +1055,11 @@ mod wgpu_integration {
|
||||||
native_options: &NativeOptions,
|
native_options: &NativeOptions,
|
||||||
) -> std::result::Result<winit::window::Window, winit::error::OsError> {
|
) -> std::result::Result<winit::window::Window, winit::error::OsError> {
|
||||||
let window_settings = epi_integration::load_window_settings(storage);
|
let window_settings = epi_integration::load_window_settings(storage);
|
||||||
epi_integration::build_window(event_loop, title, native_options, window_settings)
|
let window_builder =
|
||||||
|
epi_integration::window_builder(event_loop, title, native_options, window_settings);
|
||||||
|
let window = window_builder.build(event_loop)?;
|
||||||
|
epi_integration::apply_native_options_to_window(&window, native_options);
|
||||||
|
Ok(window)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
|
|
Loading…
Reference in a new issue