mirror of
https://github.com/emilk/egui.git
synced 2026-08-31 05:40:03 -04:00
Simplify and move CloseRequested
This commit is contained in:
@@ -450,9 +450,7 @@ impl State {
|
|||||||
|
|
||||||
// Things that may require repaint:
|
// Things that may require repaint:
|
||||||
WindowEvent::CloseRequested => {
|
WindowEvent::CloseRequested => {
|
||||||
self.egui_input
|
self.egui_input.viewport.close_requested = true;
|
||||||
.events
|
|
||||||
.push(egui::Event::WindowEvent(egui::WindowEvent::CloseRequested));
|
|
||||||
EventResponse {
|
EventResponse {
|
||||||
consumed: true,
|
consumed: true,
|
||||||
repaint: true,
|
repaint: true,
|
||||||
|
|||||||
@@ -226,7 +226,6 @@ impl ContextImpl {
|
|||||||
self.memory.begin_frame(
|
self.memory.begin_frame(
|
||||||
self.input.get(&viewport_id).unwrap_or(&Default::default()),
|
self.input.get(&viewport_id).unwrap_or(&Default::default()),
|
||||||
&new_raw_input,
|
&new_raw_input,
|
||||||
viewport_id,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
let input = self
|
let input = self
|
||||||
|
|||||||
@@ -83,8 +83,8 @@ impl Default for RawInput {
|
|||||||
events: vec![],
|
events: vec![],
|
||||||
hovered_files: Default::default(),
|
hovered_files: Default::default(),
|
||||||
dropped_files: Default::default(),
|
dropped_files: Default::default(),
|
||||||
focused: true,
|
focused: true, // integrations opt into global focus tracking
|
||||||
viewport: ViewportInfo::default(), // integrations opt into global focus tracking
|
viewport: ViewportInfo::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -152,6 +152,9 @@ pub struct ViewportInfo {
|
|||||||
/// Viewport outer position and size, drowable area + decorations
|
/// Viewport outer position and size, drowable area + decorations
|
||||||
/// unit = physical pixels
|
/// unit = physical pixels
|
||||||
pub outer_rect: Option<Rect>,
|
pub outer_rect: Option<Rect>,
|
||||||
|
|
||||||
|
/// Viewport should close?
|
||||||
|
pub close_requested: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ViewportInfo {
|
impl ViewportInfo {
|
||||||
@@ -331,14 +334,6 @@ pub enum Event {
|
|||||||
/// An assistive technology (e.g. screen reader) requested an action.
|
/// An assistive technology (e.g. screen reader) requested an action.
|
||||||
#[cfg(feature = "accesskit")]
|
#[cfg(feature = "accesskit")]
|
||||||
AccessKitActionRequest(accesskit::ActionRequest),
|
AccessKitActionRequest(accesskit::ActionRequest),
|
||||||
|
|
||||||
WindowEvent(WindowEvent),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
|
||||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
|
||||||
pub enum WindowEvent {
|
|
||||||
CloseRequested,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Mouse button (or similar for touch input)
|
/// Mouse button (or similar for touch input)
|
||||||
|
|||||||
@@ -162,7 +162,6 @@ impl InputState {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let screen_rect = new.screen_rect.unwrap_or(self.screen_rect);
|
let screen_rect = new.screen_rect.unwrap_or(self.screen_rect);
|
||||||
|
|
||||||
self.create_touch_states_for_new_devices(&new.events);
|
self.create_touch_states_for_new_devices(&new.events);
|
||||||
for touch_state in self.touch_states.values_mut() {
|
for touch_state in self.touch_states.values_mut() {
|
||||||
touch_state.begin_frame(time, &new, self.pointer.interact_pos);
|
touch_state.begin_frame(time, &new, self.pointer.interact_pos);
|
||||||
|
|||||||
@@ -543,19 +543,18 @@ impl Memory {
|
|||||||
&mut self,
|
&mut self,
|
||||||
prev_input: &crate::input_state::InputState,
|
prev_input: &crate::input_state::InputState,
|
||||||
new_input: &crate::data::input::RawInput,
|
new_input: &crate::data::input::RawInput,
|
||||||
viewport_id: ViewportId,
|
|
||||||
) {
|
) {
|
||||||
crate::profile_function!();
|
crate::profile_function!();
|
||||||
|
|
||||||
self.viewport_id = viewport_id;
|
self.viewport_id = new_input.viewport.id_pair.this;
|
||||||
self.interactions
|
self.interactions
|
||||||
.entry(viewport_id)
|
.entry(self.viewport_id)
|
||||||
.or_default()
|
.or_default()
|
||||||
.begin_frame(prev_input, new_input);
|
.begin_frame(prev_input, new_input);
|
||||||
self.areas.entry(viewport_id).or_default();
|
self.areas.entry(self.viewport_id).or_default();
|
||||||
|
|
||||||
if !prev_input.pointer.any_down() {
|
if !prev_input.pointer.any_down() {
|
||||||
self.window_interactions.remove(&viewport_id);
|
self.window_interactions.remove(&self.viewport_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user