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