1
0
mirror of https://github.com/emilk/egui.git synced 2026-06-27 23:13:13 -04:00

Simplify arguments to process_viewport_commands

This commit is contained in:
Emil Ernerfeldt
2023-11-12 10:54:15 +01:00
parent 6e17040539
commit e1f261b079
2 changed files with 16 additions and 13 deletions

View File

@@ -1289,7 +1289,12 @@ mod glow_integration {
viewport.window = None;
viewport.gl_surface = None;
} else if let Some(window) = &viewport.window {
process_viewport_commands(commands, *id, None, &window.borrow());
let is_viewport_focused = false; // TODO
process_viewport_commands(
commands,
&window.borrow(),
is_viewport_focused,
);
}
active_viewports_ids.insert(*id);
false
@@ -1616,11 +1621,11 @@ mod glow_integration {
for (viewport_id, command) in viewport_commands {
if let Some(viewport) = glutin.borrow().viewports.get(&viewport_id) {
if let Some(window) = &viewport.borrow().window {
let is_viewport_focused = self.focused_viewport == Some(viewport_id);
egui_winit::process_viewport_commands(
vec![command],
viewport_id,
self.focused_viewport,
&window.borrow(),
is_viewport_focused,
);
}
}
@@ -2541,7 +2546,8 @@ mod wgpu_integration {
..
}) = viewports.get(&id_pair.this)
{
process_viewport_commands(commands, id_pair.this, None, &window.borrow());
let is_viewport_focused = false; // TODO
process_viewport_commands(commands, &window.borrow(), is_viewport_focused);
}
} else {
viewports.insert(
@@ -2561,11 +2567,11 @@ mod wgpu_integration {
for (viewport_id, command) in viewport_commands {
if let Some(window) = viewports.get(&viewport_id).and_then(|w| w.window.clone()) {
let is_viewport_focused = self.focused_viewport == Some(viewport_id);
egui_winit::process_viewport_commands(
vec![command],
viewport_id,
self.focused_viewport,
&window.borrow(),
is_viewport_focused,
);
}
}

View File

@@ -990,9 +990,8 @@ fn translate_cursor(cursor_icon: egui::CursorIcon) -> Option<winit::window::Curs
pub fn process_viewport_commands(
commands: Vec<ViewportCommand>,
viewport_id: ViewportId,
focused: Option<ViewportId>,
window: &winit::window::Window,
is_viewport_focused: bool,
) {
use winit::window::ResizeDirection;
@@ -1000,11 +999,9 @@ pub fn process_viewport_commands(
match command {
egui::ViewportCommand::Drag => {
// if this is not checked on x11 the input will be permanently taken until the app is killed!
if let Some(focus) = focused {
if focus == viewport_id {
// TODO possible return the error to `egui::Context`
let _ = window.drag_window();
}
if is_viewport_focused {
// TODO possible return the error to `egui::Context`
let _ = window.drag_window();
}
}
egui::ViewportCommand::InnerSize(size) => {