diff --git a/deploy-notes.md b/deploy-notes.md
index 5a287532..1ef1a2f9 100644
--- a/deploy-notes.md
+++ b/deploy-notes.md
@@ -1,5 +1,7 @@
# Unreleased
+- Needs jay-config release.
+- Needs jay-toml-config release.
- Needs jay-compositor release.
# 1.1.0
diff --git a/jay-config/src/_private/client.rs b/jay-config/src/_private/client.rs
index fcc42e91..8675d299 100644
--- a/jay-config/src/_private/client.rs
+++ b/jay-config/src/_private/client.rs
@@ -10,7 +10,10 @@ use {
logging, Config, ConfigEntry, ConfigEntryGen, PollableId, WireMode, VERSION,
},
exec::Command,
- input::{acceleration::AccelProfile, capability::Capability, InputDevice, Seat},
+ input::{
+ acceleration::AccelProfile, capability::Capability, FocusFollowsMouseMode, InputDevice,
+ Seat,
+ },
keyboard::{
mods::{Modifiers, RELEASE},
syms::KeySym,
@@ -924,6 +927,10 @@ impl Client {
self.send(&ClientMessage::SetForward { seat, forward })
}
+ pub fn set_focus_follows_mouse_mode(&self, seat: Seat, mode: FocusFollowsMouseMode) {
+ self.send(&ClientMessage::SetFocusFollowsMouseMode { seat, mode })
+ }
+
pub fn parse_keymap(&self, keymap: &str) -> Keymap {
let res = self.send_with_response(&ClientMessage::ParseKeymap { keymap });
get_response!(res, Keymap(0), ParseKeymap { keymap });
diff --git a/jay-config/src/_private/ipc.rs b/jay-config/src/_private/ipc.rs
index 4d170c9a..f0bc6e91 100644
--- a/jay-config/src/_private/ipc.rs
+++ b/jay-config/src/_private/ipc.rs
@@ -1,6 +1,9 @@
use {
crate::{
- input::{acceleration::AccelProfile, capability::Capability, InputDevice, Seat},
+ input::{
+ acceleration::AccelProfile, capability::Capability, FocusFollowsMouseMode, InputDevice,
+ Seat,
+ },
keyboard::{mods::Modifiers, syms::KeySym, Keymap},
logging::LogLevel,
theme::{colors::Colorable, sized::Resizable, Color},
@@ -464,6 +467,10 @@ pub enum ClientMessage<'a> {
mod_mask: Modifiers,
sym: KeySym,
},
+ SetFocusFollowsMouseMode {
+ seat: Seat,
+ mode: FocusFollowsMouseMode,
+ },
}
#[derive(Serialize, Deserialize, Debug)]
diff --git a/jay-config/src/input.rs b/jay-config/src/input.rs
index e42b5787..ace0f0fe 100644
--- a/jay-config/src/input.rs
+++ b/jay-config/src/input.rs
@@ -390,6 +390,21 @@ impl Seat {
pub fn consume(self) {
self.set_forward(false)
}
+
+ /// Sets the focus-follows-mouse mode.
+ pub fn set_focus_follows_mouse_mode(self, mode: FocusFollowsMouseMode) {
+ get!().set_focus_follows_mouse_mode(self, mode);
+ }
+}
+
+/// A focus-follows-mouse mode.
+#[derive(Serialize, Deserialize, Copy, Clone, Debug, Hash, Eq, PartialEq)]
+pub enum FocusFollowsMouseMode {
+ /// When the mouse moves and enters a toplevel, that toplevel gets the keyboard focus.
+ True,
+ /// The keyboard focus changes only when clicking on a window or the previously
+ /// focused window becomes invisible.
+ False,
}
/// Returns all seats.
diff --git a/release-notes.md b/release-notes.md
index 7e377eee..5652ff38 100644
--- a/release-notes.md
+++ b/release-notes.md
@@ -4,6 +4,7 @@
- Add support for xdg-dialog-v1.
- Add support for ext-transient-seat-v1.
- Add support for wp-drm-lease-v1.
+- Focus-follows-mouse can now be disabled.
# 1.1.0 (2024-04-22)
diff --git a/src/config/handler.rs b/src/config/handler.rs
index a3061c8d..a5e74c19 100644
--- a/src/config/handler.rs
+++ b/src/config/handler.rs
@@ -41,7 +41,7 @@ use {
Capability, CAP_GESTURE, CAP_KEYBOARD, CAP_POINTER, CAP_SWITCH, CAP_TABLET_PAD,
CAP_TABLET_TOOL, CAP_TOUCH,
},
- InputDevice, Seat,
+ FocusFollowsMouseMode, InputDevice, Seat,
},
keyboard::{mods::Modifiers, syms::KeySym, Keymap},
logging::LogLevel,
@@ -324,6 +324,20 @@ impl ConfigProxyHandler {
Ok(())
}
+ fn handle_set_focus_follows_mouse_mode(
+ &self,
+ seat: Seat,
+ mode: FocusFollowsMouseMode,
+ ) -> Result<(), CphError> {
+ let seat = self.get_seat(seat)?;
+ let focus_follows_mouse = match mode {
+ FocusFollowsMouseMode::True => true,
+ FocusFollowsMouseMode::False => false,
+ };
+ seat.set_focus_follows_mouse(focus_follows_mouse);
+ Ok(())
+ }
+
fn handle_set_status(&self, status: &str) {
self.state.set_status(status);
}
@@ -1791,6 +1805,9 @@ impl ConfigProxyHandler {
} => self
.handle_add_shortcut(seat, mod_mask, mods, sym)
.wrn("add_shortcut")?,
+ ClientMessage::SetFocusFollowsMouseMode { seat, mode } => self
+ .handle_set_focus_follows_mouse_mode(seat, mode)
+ .wrn("set_focus_follows_mouse_mode")?,
}
Ok(())
}
diff --git a/src/ifs/wl_seat.rs b/src/ifs/wl_seat.rs
index abfda057..eae653fa 100644
--- a/src/ifs/wl_seat.rs
+++ b/src/ifs/wl_seat.rs
@@ -181,6 +181,7 @@ pub struct WlSeatGlobal {
input_method: CloneCell