mirror of
https://github.com/pinnacle-comp/pinnacle.git
synced 2024-12-26 21:58:10 +01:00
Don't focus windows on inactive tags
This commit is contained in:
parent
5afd58fb74
commit
feeb139b05
6 changed files with 32 additions and 61 deletions
|
@ -753,7 +753,7 @@ impl tag_service_server::TagService for TagService {
|
|||
state.pinnacle.fixup_xwayland_window_layering();
|
||||
|
||||
state.pinnacle.request_layout(&output);
|
||||
state.update_focus(&output);
|
||||
state.update_keyboard_focus(&output);
|
||||
state.schedule_render(&output);
|
||||
})
|
||||
.await
|
||||
|
@ -784,7 +784,7 @@ impl tag_service_server::TagService for TagService {
|
|||
state.pinnacle.fixup_xwayland_window_layering();
|
||||
|
||||
state.pinnacle.request_layout(&output);
|
||||
state.update_focus(&output);
|
||||
state.update_keyboard_focus(&output);
|
||||
state.schedule_render(&output);
|
||||
})
|
||||
.await
|
||||
|
|
|
@ -21,10 +21,7 @@ use smithay::{
|
|||
use tonic::{Request, Response, Status};
|
||||
use tracing::{error, warn};
|
||||
|
||||
use crate::{
|
||||
focus::keyboard::KeyboardFocusTarget, output::OutputName, state::WithState, tag::TagId,
|
||||
window::window_state::WindowId,
|
||||
};
|
||||
use crate::{output::OutputName, state::WithState, tag::TagId, window::window_state::WindowId};
|
||||
|
||||
use super::{run_unary, run_unary_no_response, StateFnSender};
|
||||
|
||||
|
@ -313,13 +310,7 @@ impl window_service_server::WindowService for WindowService {
|
|||
window.set_activate(true);
|
||||
output.with_state_mut(|state| state.focus_stack.set_focus(window.clone()));
|
||||
state.pinnacle.output_focus_stack.set_focus(output.clone());
|
||||
if let Some(keyboard) = state.pinnacle.seat.get_keyboard() {
|
||||
keyboard.set_focus(
|
||||
state,
|
||||
Some(KeyboardFocusTarget::Window(window)),
|
||||
SERIAL_COUNTER.next_serial(),
|
||||
);
|
||||
}
|
||||
state.update_keyboard_focus(&output);
|
||||
}
|
||||
SetOrToggle::Unset => {
|
||||
if state.pinnacle.focused_window(&output) == Some(window) {
|
||||
|
@ -339,13 +330,7 @@ impl window_service_server::WindowService for WindowService {
|
|||
window.set_activate(true);
|
||||
output.with_state_mut(|state| state.focus_stack.set_focus(window.clone()));
|
||||
state.pinnacle.output_focus_stack.set_focus(output.clone());
|
||||
if let Some(keyboard) = state.pinnacle.seat.get_keyboard() {
|
||||
keyboard.set_focus(
|
||||
state,
|
||||
Some(KeyboardFocusTarget::Window(window)),
|
||||
SERIAL_COUNTER.next_serial(),
|
||||
);
|
||||
}
|
||||
state.update_keyboard_focus(&output);
|
||||
}
|
||||
}
|
||||
SetOrToggle::Unspecified => unreachable!(),
|
||||
|
|
14
src/focus.rs
14
src/focus.rs
|
@ -1,6 +1,6 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
use smithay::{output::Output, utils::SERIAL_COUNTER};
|
||||
use smithay::{desktop::space::SpaceElement, output::Output, utils::SERIAL_COUNTER};
|
||||
use tracing::warn;
|
||||
|
||||
use crate::{
|
||||
|
@ -13,12 +13,22 @@ pub mod pointer;
|
|||
|
||||
impl State {
|
||||
/// Update the keyboard focus.
|
||||
pub fn update_focus(&mut self, output: &Output) {
|
||||
pub fn update_keyboard_focus(&mut self, output: &Output) {
|
||||
let current_focus = self.pinnacle.focused_window(output);
|
||||
|
||||
if let Some(win) = ¤t_focus {
|
||||
assert!(!win.is_x11_override_redirect());
|
||||
|
||||
let wins = output.with_state(|state| state.focus_stack.stack.clone());
|
||||
|
||||
for win in wins.iter() {
|
||||
win.set_activate(false);
|
||||
if let Some(toplevel) = win.toplevel() {
|
||||
toplevel.send_configure();
|
||||
}
|
||||
}
|
||||
|
||||
win.set_activate(true);
|
||||
if let Some(toplevel) = win.toplevel() {
|
||||
toplevel.send_configure();
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ use smithay::{
|
|||
Client, Resource,
|
||||
},
|
||||
},
|
||||
utils::{Logical, Point, Rectangle, SERIAL_COUNTER},
|
||||
utils::{Logical, Point, Rectangle},
|
||||
wayland::{
|
||||
buffer::BufferHandler,
|
||||
compositor::{
|
||||
|
@ -190,20 +190,11 @@ impl CompositorHandler for State {
|
|||
Some(Duration::ZERO),
|
||||
surface_primary_scanout_output,
|
||||
);
|
||||
}
|
||||
|
||||
self.pinnacle.loop_handle.insert_idle(move |state| {
|
||||
state
|
||||
.pinnacle
|
||||
.seat
|
||||
.get_keyboard()
|
||||
.expect("Seat had no keyboard") // FIXME: actually handle error
|
||||
.set_focus(
|
||||
state,
|
||||
Some(KeyboardFocusTarget::Window(new_window)),
|
||||
SERIAL_COUNTER.next_serial(),
|
||||
);
|
||||
});
|
||||
self.pinnacle.loop_handle.insert_idle(move |state| {
|
||||
state.update_keyboard_focus(&focused_output);
|
||||
});
|
||||
}
|
||||
} else if new_window.toplevel().is_some() {
|
||||
new_window.on_commit();
|
||||
self.pinnacle.ensure_initial_configure(surface);
|
||||
|
|
|
@ -13,7 +13,7 @@ use smithay::{
|
|||
Resource,
|
||||
},
|
||||
},
|
||||
utils::{Serial, SERIAL_COUNTER},
|
||||
utils::Serial,
|
||||
wayland::{
|
||||
seat::WaylandFocus,
|
||||
shell::xdg::{
|
||||
|
@ -76,23 +76,21 @@ impl XdgShellHandler for State {
|
|||
|
||||
if let Some(output) = window.output(&self.pinnacle) {
|
||||
self.pinnacle.request_layout(&output);
|
||||
|
||||
let focus = self
|
||||
.pinnacle
|
||||
.focused_window(&output)
|
||||
.map(KeyboardFocusTarget::Window);
|
||||
|
||||
if let Some(KeyboardFocusTarget::Window(window)) = &focus {
|
||||
tracing::debug!("Focusing on prev win");
|
||||
// TODO:
|
||||
self.pinnacle.raise_window(window.clone(), true);
|
||||
if let Some(toplevel) = window.toplevel() {
|
||||
toplevel.send_configure();
|
||||
}
|
||||
}
|
||||
self.pinnacle
|
||||
.seat
|
||||
.get_keyboard()
|
||||
.expect("Seat had no keyboard")
|
||||
.set_focus(self, focus, SERIAL_COUNTER.next_serial());
|
||||
|
||||
self.update_keyboard_focus(&output);
|
||||
|
||||
self.schedule_render(&output);
|
||||
}
|
||||
|
|
|
@ -114,20 +114,11 @@ impl XwmHandler for State {
|
|||
if let Some(output) = window.output(&self.pinnacle) {
|
||||
output.with_state_mut(|state| state.focus_stack.set_focus(window.clone()));
|
||||
self.pinnacle.request_layout(&output);
|
||||
}
|
||||
|
||||
self.pinnacle.loop_handle.insert_idle(move |state| {
|
||||
state
|
||||
.pinnacle
|
||||
.seat
|
||||
.get_keyboard()
|
||||
.expect("Seat had no keyboard") // FIXME: actually handle error
|
||||
.set_focus(
|
||||
state,
|
||||
Some(KeyboardFocusTarget::Window(window)),
|
||||
SERIAL_COUNTER.next_serial(),
|
||||
);
|
||||
});
|
||||
self.pinnacle.loop_handle.insert_idle(move |state| {
|
||||
state.update_keyboard_focus(&output);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
fn mapped_override_redirect_window(&mut self, _xwm: XwmId, surface: X11Surface) {
|
||||
|
@ -470,11 +461,7 @@ impl State {
|
|||
}
|
||||
}
|
||||
|
||||
self.pinnacle
|
||||
.seat
|
||||
.get_keyboard()
|
||||
.expect("Seat had no keyboard")
|
||||
.set_focus(self, focus, SERIAL_COUNTER.next_serial());
|
||||
self.update_keyboard_focus(&output);
|
||||
|
||||
self.schedule_render(&output);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue