mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-21 08:01:39 +01:00
fix(wm): a title change does not make the daemon look at a window again
This commit is contained in:
1 parent
4920650155
commit
84080f879e
3 files changed
+31
-33
No files matched your search
@@ -709,10 +709,10 @@ the workspaces in front; `SessionFloatRule` adds a float rule made of the focuse
|
||||
executable, title and class, all three to be equal, and floats it, and `ClearSessionFloatRules`
|
||||
takes those rules out again. `GlobalState` answers with the ignore and the manage rules
|
||||
([`GlobalState`]), and `DebugWindow` with what [`Window::should_manage`] read of a window and
|
||||
which rules matched ([`RuleDebug`]). A rule decides when a window is shown; the bridge reports
|
||||
a title change (`caption`), which is a `TitleUpdate` event, and a `TitleUpdate` about a window
|
||||
the index does not have, and that is not minimized, is sent again as a `Show`, so that a rule
|
||||
about the title it has now decides.
|
||||
which rules matched ([`RuleDebug`]). A rule decides when a window is shown, by the title it has
|
||||
then; the bridge reports a title change (`caption`), which is a `TitleUpdate` event, and the
|
||||
window manager does nothing with it, so a window an ignore rule matched stays unmanaged when its
|
||||
title changes, as in kfw.
|
||||
|
||||
`TogglePause` sets [`WindowManager::is_paused`]: while it is set, `handle_event` returns at once
|
||||
for every event, and [`read_commands_uds`] hands only `TogglePause`, `State`, `GlobalState` and
|
||||
|
||||
@@ -41,8 +41,8 @@
|
||||
//! of its own ([`WindowManager::adopt_maximize_change`]). The maximize and the restore that
|
||||
//! `ToggleMaximize` asks for come back as this event too, and change nothing. A window that
|
||||
//! opens maximized is taken the same way, after its Show.
|
||||
//! - **TitleUpdate**: a window komorebi does not have, and that was not minimized, is announced
|
||||
//! again as a Show, so that a rule that matches on the title it has now decides.
|
||||
//! - **TitleUpdate**: nothing. The rules decide when a window opens; a window an ignore rule
|
||||
//! matched stays unmanaged when its title changes, and a managed one stays managed, as in kfw.
|
||||
//! - **MoveStart** and **MoveEnd**: the user dragged a window with the pointer. When they let go
|
||||
//! on another monitor, the window's container goes there and takes the place of the container
|
||||
//! whose tile the pointer is on ([`WindowManager::transfer_window`]). When they let go on the
|
||||
@@ -112,10 +112,7 @@ use crate::window::live_resize_ends;
|
||||
use crate::window::should_act;
|
||||
use crate::window_manager::LiveResize;
|
||||
use crate::window_manager::WindowManager;
|
||||
use crate::window_manager_event::KWinNotification;
|
||||
use crate::window_manager_event::SystemNotification;
|
||||
use crate::window_manager_event::WindowManagerEvent;
|
||||
use crate::window_manager_event_listener;
|
||||
use crate::workspace::WorkspaceLayer;
|
||||
use color_eyre::eyre;
|
||||
use color_eyre::eyre::OptionExt;
|
||||
@@ -556,17 +553,9 @@ impl WindowManager {
|
||||
}
|
||||
},
|
||||
WindowManagerEvent::TitleUpdate(_, _) => {
|
||||
// Windows are routinely announced before their title is set. Now that it is, a rule
|
||||
// that matches on the title can finally decide, so a window that was not picked up
|
||||
// gets another chance to be.
|
||||
if !self.known_window_ids.contains_key(&window_id)
|
||||
&& !self.minimized_windows.contains_key(&window_id)
|
||||
{
|
||||
window_manager_event_listener::send_notification(WindowManagerEvent::Show(
|
||||
SystemNotification::KWin(KWinNotification::WindowAdded),
|
||||
window,
|
||||
));
|
||||
}
|
||||
// The rules decide when a window opens, by the title it has then. A later title
|
||||
// change does not make the daemon look at the window again: one an ignore rule
|
||||
// matched stays unmanaged, and one that is managed stays so. kfw does the same.
|
||||
}
|
||||
WindowManagerEvent::MoveStart(_, window) => {
|
||||
let window_id = window.id;
|
||||
|
||||
@@ -176,7 +176,7 @@ fn a_session_float_rule_floats_the_focused_window_and_the_ones_like_it_until_it_
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_window_whose_title_no_longer_matches_an_ignore_rule_is_tiled_when_the_title_changes() {
|
||||
fn a_window_an_ignore_rule_matched_stays_unmanaged_when_its_title_changes() {
|
||||
let (fake, mut wm) = desktop();
|
||||
send(
|
||||
&fake,
|
||||
@@ -195,19 +195,28 @@ fn a_window_whose_title_no_longer_matches_an_ignore_rule_is_tiled_when_the_title
|
||||
with_backend(fake.clone(), || wm.process_event(title_changed(29_031))).unwrap();
|
||||
forget_ignore_rule("pending-29");
|
||||
|
||||
// the title update announces the window again, on the channel the events thread reads
|
||||
// the title change announces nothing: the window is not looked at again
|
||||
let events = window_manager_event_listener::event_rx();
|
||||
let shown = loop {
|
||||
let event = events
|
||||
.recv_timeout(Duration::from_secs(5))
|
||||
.expect("the window is announced again");
|
||||
if event.window_id() == Some(29_031) {
|
||||
break event;
|
||||
}
|
||||
};
|
||||
assert!(matches!(shown, WindowManagerEvent::Show(..)), "{shown:?}");
|
||||
with_backend(fake.clone(), || wm.process_event(shown)).unwrap();
|
||||
assert_eq!(tiled(&wm), [29_031]);
|
||||
let announced = std::iter::from_fn(|| events.recv_timeout(Duration::from_millis(300)).ok())
|
||||
.any(|event| event.window_id() == Some(29_031));
|
||||
assert!(!announced, "the window is not announced again");
|
||||
assert!(tiled(&wm).is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_managed_window_stays_managed_when_its_title_changes() {
|
||||
let (fake, mut wm) = desktop();
|
||||
open(
|
||||
&fake,
|
||||
&mut wm,
|
||||
29_032,
|
||||
("browser-29", "org.example.browser", "a page"),
|
||||
);
|
||||
assert_eq!(tiled(&wm), [29_032]);
|
||||
|
||||
fake.set_title(29_032, "another page");
|
||||
with_backend(fake.clone(), || wm.process_event(title_changed(29_032))).unwrap();
|
||||
assert_eq!(tiled(&wm), [29_032]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in new issue
Block a user