Skip to content

Commit

Permalink
style: minor linting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lars-berger committed Nov 5, 2024
1 parent 45a9255 commit a25e988
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 29 deletions.
8 changes: 3 additions & 5 deletions packages/wm/src/app_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,12 +533,10 @@ impl InvokeCommand {
_ => Ok(()),
}
}
InvokeCommand::ShellExec {
InvokeCommand::ShellExec {
hide_window,
command
} => {
shell_exec(&command.join(" "), hide_window.clone())
}
command,
} => shell_exec(&command.join(" "), hide_window.clone()),
InvokeCommand::Size(args) => {
match subject_container.as_window_container() {
Ok(window) => set_window_size(
Expand Down
15 changes: 9 additions & 6 deletions packages/wm/src/common/events/handle_window_destroyed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ use anyhow::Context;
use tracing::info;

use crate::{
common::platform::NativeWindow, windows::commands::unmanage_window,
wm_state::WmState,
containers::traits::CommonGetters,
workspaces::commands::deactivate_workspace
common::platform::NativeWindow, containers::traits::CommonGetters,
windows::commands::unmanage_window, wm_state::WmState,
workspaces::commands::deactivate_workspace,
};

pub fn handle_window_destroyed(
Expand All @@ -22,8 +21,12 @@ pub fn handle_window_destroyed(
info!("Window closed");
unmanage_window(window, state)?;

// Destroy parent workspace if window was killed while its workspace was not displayed (e.g. via task manager).
if !workspace.config().keep_alive && !workspace.has_children() && !workspace.is_displayed() {
// Destroy parent workspace if window was killed while its workspace
// was not displayed (e.g. via task manager).
if !workspace.config().keep_alive
&& !workspace.has_children()
&& !workspace.is_displayed()
{
deactivate_workspace(workspace, state)?;
}
}
Expand Down
5 changes: 1 addition & 4 deletions packages/wm/src/common/events/handle_window_focused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ use anyhow::Context;
use tracing::info;

use crate::{
common::{
platform::{NativeWindow, Platform},
DisplayState,
},
common::{platform::NativeWindow, DisplayState},
containers::{commands::set_focused_descendant, traits::CommonGetters},
user_config::{UserConfig, WindowRuleEvent},
windows::{commands::run_window_rules, traits::WindowGetters},
Expand Down
36 changes: 22 additions & 14 deletions packages/wm/src/common/platform/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ use windows::{
},
WindowsAndMessaging::{
CreateWindowExW, DispatchMessageW, GetAncestor, GetCursorPos,
GetDesktopWindow, GetForegroundWindow, GetMessageW, MessageBoxW,
PeekMessageW, PostThreadMessageW, RegisterClassW, SetCursorPos,
SystemParametersInfoW, TranslateMessage, WindowFromPoint, GetShellWindow,
ANIMATIONINFO, CS_HREDRAW, CS_VREDRAW, CW_USEDEFAULT, GA_ROOT,
MB_ICONERROR, MB_OK, MB_SYSTEMMODAL, MSG, PM_REMOVE,
SPI_GETANIMATION, SPI_SETANIMATION, SW_NORMAL, SW_HIDE,
GetDesktopWindow, GetForegroundWindow, GetMessageW,
GetShellWindow, MessageBoxW, PeekMessageW, PostThreadMessageW,
RegisterClassW, SetCursorPos, SystemParametersInfoW,
TranslateMessage, WindowFromPoint, ANIMATIONINFO, CS_HREDRAW,
CS_VREDRAW, CW_USEDEFAULT, GA_ROOT, MB_ICONERROR, MB_OK,
MB_SYSTEMMODAL, MSG, PM_REMOVE, SPI_GETANIMATION,
SPI_SETANIMATION, SW_HIDE, SW_NORMAL,
SYSTEM_PARAMETERS_INFO_UPDATE_FLAGS, WM_QUIT, WNDCLASSW, WNDPROC,
WS_OVERLAPPEDWINDOW,
},
Expand All @@ -49,14 +50,17 @@ impl Platform {
NativeWindow::new(handle.0)
}

// Get Explorer wallpaper window (i.e. "Progman"). Default to the
// desktop window on which the wallpaper window sits above for edge
// case where Explorer isn't running.
/// Gets the `NativeWindow` instance of the desktop window.
///
/// This is the explorer.exe wallpaper window (i.e. "Progman"). If
/// explorer.exe isn't running, then default to the desktop window below
/// the wallpaper window.
pub fn desktop_window() -> NativeWindow {
let mut handle = unsafe { GetShellWindow() };
if handle == HWND(0) {
handle = unsafe { GetDesktopWindow() };
}
let handle = match unsafe { GetShellWindow() } {
HWND(0) => unsafe { GetDesktopWindow() },
handle => handle,
};

NativeWindow::new(handle.0)
}

Expand Down Expand Up @@ -416,7 +420,11 @@ impl Platform {
}

/// Runs the specified program with the given arguments.
pub fn run_command(program: &str, args: &str, hide_window: bool) -> anyhow::Result<()> {
pub fn run_command(
program: &str,
args: &str,
hide_window: bool,
) -> anyhow::Result<()> {
let home_dir = home::home_dir()
.context("Unable to get home directory.")?
.to_str()
Expand Down

0 comments on commit a25e988

Please sign in to comment.