aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/config.rs19
-rw-r--r--src/handlers/compositor.rs3
-rw-r--r--src/input.rs12
-rw-r--r--src/main.rs9
-rw-r--r--src/niri.rs22
-rw-r--r--src/pw_utils.rs14
-rw-r--r--src/utils.rs2
7 files changed, 47 insertions, 34 deletions
diff --git a/src/config.rs b/src/config.rs
index dd664ff8..3818ed68 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -4,7 +4,8 @@ use std::str::FromStr;
use bitflags::bitflags;
use directories::ProjectDirs;
use miette::{miette, Context, IntoDiagnostic};
-use smithay::input::keyboard::xkb::{keysym_from_name, KEY_NoSymbol, KEYSYM_CASE_INSENSITIVE};
+use smithay::input::keyboard::keysyms::KEY_NoSymbol;
+use smithay::input::keyboard::xkb::{keysym_from_name, KEYSYM_CASE_INSENSITIVE};
use smithay::input::keyboard::Keysym;
#[derive(knuffel::Decode, Debug, PartialEq)]
@@ -248,7 +249,7 @@ impl FromStr for Key {
}
let keysym = keysym_from_name(key, KEYSYM_CASE_INSENSITIVE);
- if keysym == KEY_NoSymbol {
+ if keysym.raw() == KEY_NoSymbol {
return Err(miette!("invalid key: {key}"));
}
@@ -258,8 +259,6 @@ impl FromStr for Key {
#[cfg(test)]
mod tests {
- use smithay::input::keyboard::xkb::keysyms::*;
-
use super::*;
#[track_caller]
@@ -336,42 +335,42 @@ mod tests {
binds: Binds(vec![
Bind {
key: Key {
- keysym: KEY_t,
+ keysym: Keysym::t,
modifiers: Modifiers::COMPOSITOR,
},
actions: vec![Action::Spawn(vec!["alacritty".to_owned()])],
},
Bind {
key: Key {
- keysym: KEY_q,
+ keysym: Keysym::q,
modifiers: Modifiers::COMPOSITOR,
},
actions: vec![Action::CloseWindow],
},
Bind {
key: Key {
- keysym: KEY_h,
+ keysym: Keysym::h,
modifiers: Modifiers::COMPOSITOR | Modifiers::SHIFT,
},
actions: vec![Action::FocusMonitorLeft],
},
Bind {
key: Key {
- keysym: KEY_l,
+ keysym: Keysym::l,
modifiers: Modifiers::COMPOSITOR | Modifiers::SHIFT | Modifiers::CTRL,
},
actions: vec![Action::MoveWindowToMonitorRight],
},
Bind {
key: Key {
- keysym: KEY_comma,
+ keysym: Keysym::comma,
modifiers: Modifiers::COMPOSITOR,
},
actions: vec![Action::ConsumeWindowIntoColumn],
},
Bind {
key: Key {
- keysym: KEY_1,
+ keysym: Keysym::_1,
modifiers: Modifiers::COMPOSITOR,
},
actions: vec![Action::FocusWorkspace(1)],
diff --git a/src/handlers/compositor.rs b/src/handlers/compositor.rs
index 4ddde3fb..404f98a4 100644
--- a/src/handlers/compositor.rs
+++ b/src/handlers/compositor.rs
@@ -48,9 +48,10 @@ impl CompositorHandler for State {
.niri
.event_loop
.insert_source(source, move |_, _, data| {
+ let display_handle = data.state.niri.display_handle.clone();
data.state
.client_compositor_state(&client)
- .blocker_cleared(&mut data.state, &data.display.handle());
+ .blocker_cleared(&mut data.state, &display_handle);
Ok(())
});
if res.is_ok() {
diff --git a/src/input.rs b/src/input.rs
index 3cc13a5f..888bf785 100644
--- a/src/input.rs
+++ b/src/input.rs
@@ -43,7 +43,7 @@ fn action(
// Handle hardcoded binds.
#[allow(non_upper_case_globals)] // wat
- match keysym.modified_sym() {
+ match keysym.modified_sym().raw() {
modified @ KEY_XF86Switch_VT_1..=KEY_XF86Switch_VT_12 => {
let vt = (modified - KEY_XF86Switch_VT_1 + 1) as i32;
return Action::ChangeVt(vt);
@@ -383,6 +383,8 @@ impl State {
},
);
+ pointer.frame(self);
+
// Redraw to update the cursor position.
// FIXME: redraw only outputs overlapping the cursor.
self.niri.queue_redraw_all();
@@ -412,6 +414,8 @@ impl State {
},
);
+ pointer.frame(self);
+
// Redraw to update the cursor position.
// FIXME: redraw only outputs overlapping the cursor.
self.niri.queue_redraw_all();
@@ -479,7 +483,9 @@ impl State {
}
}
- self.niri.seat.get_pointer().unwrap().axis(self, frame);
+ let pointer = &self.niri.seat.get_pointer().unwrap();
+ pointer.axis(self, frame);
+ pointer.frame(self);
}
InputEvent::TabletToolAxis { event, .. } => {
// FIXME: allow mapping tablet to different outputs.
@@ -506,6 +512,7 @@ impl State {
time: event.time_msec(),
},
);
+ pointer.frame(self);
let tablet_seat = self.niri.seat.tablet_seat();
let tablet = tablet_seat.get_tablet(&TabletDescriptor::from(&event.device()));
@@ -593,6 +600,7 @@ impl State {
time: event.time_msec(),
},
);
+ pointer.frame(self);
let tablet_seat = self.niri.seat.tablet_seat();
let tool = tablet_seat.add_tool::<Self>(&self.niri.display_handle, &event.tool());
diff --git a/src/main.rs b/src/main.rs
index 3ec8b323..5d1ec72e 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -39,7 +39,6 @@ struct Cli {
}
pub struct LoopData {
- display: Display<State>,
state: State,
}
@@ -68,14 +67,14 @@ fn main() {
let spawn_at_startup = mem::take(&mut config.spawn_at_startup);
let mut event_loop = EventLoop::try_new().unwrap();
- let mut display = Display::new().unwrap();
+ let display = Display::new().unwrap();
let state = State::new(
config,
event_loop.handle(),
event_loop.get_signal(),
- &mut display,
+ display,
);
- let mut data = LoopData { display, state };
+ let mut data = LoopData { state };
// Spawn commands from cli and auto-start.
if let Some((command, args)) = cli.command.split_first() {
@@ -99,7 +98,7 @@ fn main() {
{
let _span = tracy_client::span!("flush_clients");
- data.display.flush_clients().unwrap();
+ data.state.niri.display_handle.flush_clients().unwrap();
}
})
.unwrap();
diff --git a/src/niri.rs b/src/niri.rs
index 35346bd7..762b062c 100644
--- a/src/niri.rs
+++ b/src/niri.rs
@@ -1,7 +1,6 @@
use std::cell::RefCell;
use std::cmp::max;
use std::collections::HashMap;
-use std::os::unix::io::AsRawFd;
use std::path::PathBuf;
use std::process::Command;
use std::rc::Rc;
@@ -142,7 +141,7 @@ impl State {
config: Config,
event_loop: LoopHandle<'static, LoopData>,
stop_signal: LoopSignal,
- display: &mut Display<State>,
+ display: Display<State>,
) -> Self {
let config = Rc::new(RefCell::new(config));
@@ -163,7 +162,8 @@ impl State {
pub fn move_cursor(&mut self, location: Point<f64, Logical>) {
let under = self.niri.surface_under_and_global_space(location);
- self.niri.seat.get_pointer().unwrap().motion(
+ let pointer = &self.niri.seat.get_pointer().unwrap();
+ pointer.motion(
self,
under,
&MotionEvent {
@@ -172,6 +172,7 @@ impl State {
time: get_monotonic_time().as_millis() as u32,
},
);
+ pointer.frame(self);
// FIXME: granular
self.niri.queue_redraw_all();
}
@@ -202,7 +203,7 @@ impl Niri {
config: Rc<RefCell<Config>>,
event_loop: LoopHandle<'static, LoopData>,
stop_signal: LoopSignal,
- display: &mut Display<State>,
+ display: Display<State>,
backend: &Backend,
) -> Self {
let display_handle = display.handle();
@@ -533,14 +534,13 @@ impl Niri {
zbus_conn = Some(conn);
}
- let display_source = Generic::new(
- display.backend().poll_fd().as_raw_fd(),
- Interest::READ,
- Mode::Level,
- );
+ let display_source = Generic::new(display, Interest::READ, Mode::Level);
event_loop
- .insert_source(display_source, |_, _, data| {
- data.display.dispatch_clients(&mut data.state).unwrap();
+ .insert_source(display_source, |_, display, data| {
+ // SAFETY: we don't drop the display.
+ unsafe {
+ display.get_mut().dispatch_clients(&mut data.state).unwrap();
+ }
Ok(PostAction::Continue)
})
.unwrap();
diff --git a/src/pw_utils.rs b/src/pw_utils.rs
index ffcf6b67..61a03af0 100644
--- a/src/pw_utils.rs
+++ b/src/pw_utils.rs
@@ -2,7 +2,7 @@ use std::cell::{Cell, RefCell};
use std::collections::HashMap;
use std::io::Cursor;
use std::mem;
-use std::os::fd::AsRawFd;
+use std::os::fd::{AsFd, AsRawFd, BorrowedFd};
use std::rc::Rc;
use std::time::Duration;
@@ -63,11 +63,17 @@ impl PipeWire {
.register();
mem::forget(listener);
- let generic = Generic::new(main_loop.fd().as_raw_fd(), Interest::READ, Mode::Level);
+ struct AsFdWrapper(MainLoop);
+ impl AsFd for AsFdWrapper {
+ fn as_fd(&self) -> BorrowedFd<'_> {
+ self.0.fd()
+ }
+ }
+ let generic = Generic::new(AsFdWrapper(main_loop), Interest::READ, Mode::Level);
event_loop
- .insert_source(generic, move |_, _, _| {
+ .insert_source(generic, move |_, wrapper, _| {
let _span = tracy_client::span!("pipewire iteration");
- main_loop.iterate(Duration::ZERO);
+ wrapper.0.iterate(Duration::ZERO);
Ok(PostAction::Continue)
})
.unwrap();
diff --git a/src/utils.rs b/src/utils.rs
index e5ba895c..f1aca8b2 100644
--- a/src/utils.rs
+++ b/src/utils.rs
@@ -8,10 +8,10 @@ use std::time::Duration;
use anyhow::{anyhow, Context};
use directories::UserDirs;
+use nix::time::{clock_gettime, ClockId};
use smithay::backend::allocator::Fourcc;
use smithay::backend::renderer::element::texture::TextureBuffer;
use smithay::backend::renderer::gles::{GlesRenderer, GlesTexture};
-use smithay::reexports::nix::time::{clock_gettime, ClockId};
use smithay::utils::{Logical, Physical, Point, Rectangle, Transform};
use time::OffsetDateTime;
use xcursor::parser::parse_xcursor;