aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/backend/winit.rs61
-rw-r--r--src/handlers/mod.rs7
2 files changed, 31 insertions, 37 deletions
diff --git a/src/backend/winit.rs b/src/backend/winit.rs
index d818d76d..59278982 100644
--- a/src/backend/winit.rs
+++ b/src/backend/winit.rs
@@ -8,9 +8,8 @@ use std::time::Duration;
use smithay::backend::renderer::damage::OutputDamageTracker;
use smithay::backend::renderer::gles::GlesRenderer;
use smithay::backend::renderer::{DebugFlags, Renderer};
-use smithay::backend::winit::{self, WinitError, WinitEvent, WinitGraphicsBackend};
+use smithay::backend::winit::{self, WinitEvent, WinitGraphicsBackend};
use smithay::output::{Mode, Output, PhysicalProperties, Scale, Subpixel};
-use smithay::reexports::calloop::timer::{TimeoutAction, Timer};
use smithay::reexports::calloop::LoopHandle;
use smithay::reexports::wayland_protocols::wp::presentation_time::server::wp_presentation_feedback;
use smithay::reexports::winit::dpi::LogicalSize;
@@ -37,7 +36,7 @@ impl Winit {
.with_inner_size(LogicalSize::new(1280.0, 800.0))
// .with_resizable(false)
.with_title("niri");
- let (backend, mut winit_event_loop) = winit::init_from_builder(builder).unwrap();
+ let (backend, winit) = winit::init_from_builder(builder).unwrap();
let output_config = config
.borrow()
@@ -50,7 +49,7 @@ impl Winit {
let scale = scale.max(1.).round() as i32;
let mode = Mode {
- size: backend.window_size().physical_size,
+ size: backend.window_size(),
refresh: 60_000,
};
@@ -78,40 +77,30 @@ impl Winit {
let damage_tracker = OutputDamageTracker::from_output(&output);
- let timer = Timer::immediate();
event_loop
- .insert_source(timer, move |_, _, state| {
- let res = winit_event_loop.dispatch_new_events(|event| match event {
- WinitEvent::Resized { size, .. } => {
- let winit = state.backend.winit();
- winit.output.change_current_state(
- Some(Mode {
- size,
- refresh: 60_000,
- }),
- None,
- None,
- None,
- );
- state.niri.output_resized(winit.output.clone());
- }
- WinitEvent::Input(event) => state.process_input_event(event),
- WinitEvent::Focus(_) => (),
- WinitEvent::Refresh => state
- .niri
- .queue_redraw(state.backend.winit().output.clone()),
- });
-
- // I want this to stop compiling if more errors are added.
- #[allow(clippy::single_match)]
- match res {
- Err(WinitError::WindowClosed) => {
- state.niri.stop_signal.stop();
- state.niri.remove_output(&state.backend.winit().output);
- }
- Ok(()) => (),
+ .insert_source(winit, move |event, _, state| match event {
+ WinitEvent::Resized { size, .. } => {
+ let winit = state.backend.winit();
+ winit.output.change_current_state(
+ Some(Mode {
+ size,
+ refresh: 60_000,
+ }),
+ None,
+ None,
+ None,
+ );
+ state.niri.output_resized(winit.output.clone());
+ }
+ WinitEvent::Input(event) => state.process_input_event(event),
+ WinitEvent::Focus(_) => (),
+ WinitEvent::Redraw => state
+ .niri
+ .queue_redraw(state.backend.winit().output.clone()),
+ WinitEvent::CloseRequested => {
+ state.niri.stop_signal.stop();
+ state.niri.remove_output(&state.backend.winit().output);
}
- TimeoutAction::ToDuration(Duration::from_micros(16667))
})
.unwrap();
diff --git a/src/handlers/mod.rs b/src/handlers/mod.rs
index 81ef9806..19742fcc 100644
--- a/src/handlers/mod.rs
+++ b/src/handlers/mod.rs
@@ -10,7 +10,7 @@ use std::thread;
use smithay::backend::allocator::dmabuf::Dmabuf;
use smithay::backend::renderer::ImportDma;
-use smithay::desktop::PopupKind;
+use smithay::desktop::{PopupKind, PopupManager};
use smithay::input::pointer::CursorImageStatus;
use smithay::input::{Seat, SeatHandler, SeatState};
use smithay::output::Output;
@@ -75,6 +75,11 @@ impl InputMethodHandler for State {
warn!("error tracking ime popup {err:?}");
}
}
+ fn dismiss_popup(&mut self, surface: PopupSurface) {
+ if let Some(parent) = surface.get_parent().map(|parent| parent.surface.clone()) {
+ let _ = PopupManager::dismiss_popup(&parent, &PopupKind::from(surface));
+ }
+ }
fn parent_geometry(&self, parent: &WlSurface) -> Rectangle<i32, Logical> {
self.niri
.layout