mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-21 16:11:37 +01:00
refactor(kde): Minimize, Close and DebugWindow are methods with the macOS names
The inline router arms become minimize_foreground_window, close_foreground_window and debug_window(window_id, reply) with the bodies they had, so that the three arms are the same text as macOS's (the bodies differ by the platform: the backend and Window::from here, the foreground element and the Accessibility window list there). Pure move, no behaviour change. Verified: KDE cargo check --all-targets and lib tests PASS; tools/format-all --apply --tree kde ran.
This commit is contained in:
1 parent
fe65256659
commit
4811a056e9
1 file changed
+43
-25
@@ -1330,18 +1330,8 @@ impl WindowManager {
|
||||
SocketMessage::ResizeWindowAxis(axis, sizing) => {
|
||||
self.resize_window_axis(axis, sizing)?
|
||||
}
|
||||
SocketMessage::Minimize => {
|
||||
let foreground_window = backend()
|
||||
.foreground_window()
|
||||
.ok_or_eyre("there is no foreground window")?;
|
||||
Window::from(foreground_window).minimize()?;
|
||||
}
|
||||
SocketMessage::Close => {
|
||||
let foreground_window = backend()
|
||||
.foreground_window()
|
||||
.ok_or_eyre("there is no foreground window")?;
|
||||
Window::from(foreground_window).close()?;
|
||||
}
|
||||
SocketMessage::Minimize => self.minimize_foreground_window()?,
|
||||
SocketMessage::Close => self.close_foreground_window()?,
|
||||
SocketMessage::ManageFocusedWindow => {
|
||||
self.manage_focused_window()?;
|
||||
}
|
||||
@@ -1819,19 +1809,7 @@ impl WindowManager {
|
||||
workspace.resize_dimensions = resize;
|
||||
self.update_focused_workspace(false, false)?;
|
||||
}
|
||||
SocketMessage::DebugWindow(window_id) => {
|
||||
// an id that is not a u32 is not a window
|
||||
let window = u32::try_from(window_id).map(Window::from);
|
||||
if let Ok(window) = window
|
||||
&& window.is_valid()
|
||||
{
|
||||
let mut rule_debug = RuleDebug::default();
|
||||
let _ = window.should_manage(None, &mut rule_debug);
|
||||
let schema = serde_json::to_string_pretty(&rule_debug)?;
|
||||
|
||||
reply.write_all(schema.as_bytes())?;
|
||||
}
|
||||
}
|
||||
SocketMessage::DebugWindow(window_id) => self.debug_window(window_id, &mut reply)?,
|
||||
SocketMessage::Border(enable) => {
|
||||
border_manager::BORDER_ENABLED.store(enable, Ordering::SeqCst);
|
||||
if !enable {
|
||||
@@ -1994,6 +1972,46 @@ pub fn read_commands_uds(wm: &Arc<Mutex<WindowManager>>, stream: UnixStream) ->
|
||||
komorebi_transport::read_commands::<WindowManager, _>(wm, stream, &NoPolicy)
|
||||
}
|
||||
|
||||
impl WindowManager {
|
||||
/// Minimizes the window that has the focus
|
||||
pub fn minimize_foreground_window(&mut self) -> eyre::Result<()> {
|
||||
let foreground_window = backend()
|
||||
.foreground_window()
|
||||
.ok_or_eyre("there is no foreground window")?;
|
||||
Window::from(foreground_window).minimize()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Closes the window that has the focus
|
||||
pub fn close_foreground_window(&mut self) -> eyre::Result<()> {
|
||||
let foreground_window = backend()
|
||||
.foreground_window()
|
||||
.ok_or_eyre("there is no foreground window")?;
|
||||
Window::from(foreground_window).close()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Answers with why the window of this id is, or is not, managed
|
||||
pub fn debug_window(
|
||||
&self,
|
||||
window_id: i64,
|
||||
reply: &mut impl std::io::Write,
|
||||
) -> eyre::Result<()> {
|
||||
// an id that is not a u32 is not a window
|
||||
let window = u32::try_from(window_id).map(Window::from);
|
||||
if let Ok(window) = window
|
||||
&& window.is_valid()
|
||||
{
|
||||
let mut rule_debug = RuleDebug::default();
|
||||
let _ = window.should_manage(None, &mut rule_debug);
|
||||
let schema = serde_json::to_string_pretty(&rule_debug)?;
|
||||
|
||||
reply.write_all(schema.as_bytes())?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
/// The window manager as the shared commands of `komorebi_core::command` see it
|
||||
impl komorebi_core::CommandHost for WindowManager {
|
||||
type P = crate::workspace::KdePlatform;
|
||||
|
||||
Reference in new issue
Block a user