Compare commits

..

1 Commits

Author SHA1 Message Date
LGUG2Z
ddfc44a788 fix(wm): hard code unreal engine ws handling
This commit introduces a temporary hard-coded fix for handling
minimizing and restoration for UnrealEditor.exe when switching
workspaces.

re #211
2022-08-23 10:46:51 -07:00
9 changed files with 53 additions and 96 deletions

10
Cargo.lock generated
View File

@@ -464,7 +464,7 @@ dependencies = [
[[package]]
name = "komorebi"
version = "0.1.13"
version = "0.1.12"
dependencies = [
"bitflags",
"clap",
@@ -500,7 +500,7 @@ dependencies = [
[[package]]
name = "komorebi-core"
version = "0.1.13"
version = "0.1.12"
dependencies = [
"clap",
"color-eyre",
@@ -514,7 +514,7 @@ dependencies = [
[[package]]
name = "komorebic"
version = "0.1.13"
version = "0.1.12"
dependencies = [
"clap",
"color-eyre",
@@ -1255,9 +1255,9 @@ dependencies = [
[[package]]
name = "time"
version = "0.3.14"
version = "0.3.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c3f9a28b618c3a6b9251b6908e9c99e04b9e5c02e6581ccbb67d59c34ef7f9b"
checksum = "db76ff9fa4b1458b3c7f077f3ff9887394058460d21e634355b273aaf11eea45"
dependencies = [
"itoa",
"libc",

View File

@@ -1,6 +1,6 @@
[package]
name = "komorebi-core"
version = "0.1.13"
version = "0.1.12"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@@ -311,11 +311,6 @@ Run, komorebic.exe float-rule exe "TranslucentTB.exe", , Hide
; If you have disabled minimize/close to tray for this application, you can delete/comment out the next line
Run, komorebic.exe identify-tray-application exe "TranslucentTB.exe", , Hide
; Unreal Editor
Run, komorebic.exe identify-border-overflow-application exe "UnrealEditor.exe", , Hide
; If you have disabled minimize/close to tray for this application, you can delete/comment out the next line
Run, komorebic.exe identify-tray-application exe "UnrealEditor.exe", , Hide
; Visual Studio Code
Run, komorebic.exe identify-border-overflow-application exe "Code.exe", , Hide

View File

@@ -1,6 +1,6 @@
[package]
name = "komorebi"
version = "0.1.13"
version = "0.1.12"
authors = ["Jade Iqbal <jadeiqbal@fastmail.com>"]
description = "A tiling window manager for Windows"
categories = ["tiling-window-manager", "windows"]

View File

@@ -87,11 +87,7 @@ impl Border {
}
pub fn hide(self) -> Result<()> {
if self.hwnd == 0 {
Ok(())
} else {
WindowsApi::hide_border_window(self.hwnd())
}
WindowsApi::hide_border_window(self.hwnd())
}
pub fn set_position(
@@ -100,33 +96,29 @@ impl Border {
invisible_borders: &Rect,
activate: bool,
) -> Result<()> {
if self.hwnd == 0 {
Ok(())
} else {
let mut should_expand_border = false;
let mut should_expand_border = false;
let mut rect = WindowsApi::window_rect(window.hwnd())?;
rect.top -= invisible_borders.bottom;
rect.bottom += invisible_borders.bottom;
let mut rect = WindowsApi::window_rect(window.hwnd())?;
rect.top -= invisible_borders.bottom;
rect.bottom += invisible_borders.bottom;
let border_overflows = BORDER_OVERFLOW_IDENTIFIERS.lock();
if border_overflows.contains(&window.title()?)
|| border_overflows.contains(&window.exe()?)
|| border_overflows.contains(&window.class()?)
{
should_expand_border = true;
}
if should_expand_border {
rect.left -= invisible_borders.left;
rect.top -= invisible_borders.top;
rect.right += invisible_borders.right;
rect.bottom += invisible_borders.bottom;
}
*BORDER_RECT.lock() = rect;
WindowsApi::position_border_window(self.hwnd(), &rect, activate)
let border_overflows = BORDER_OVERFLOW_IDENTIFIERS.lock();
if border_overflows.contains(&window.title()?)
|| border_overflows.contains(&window.exe()?)
|| border_overflows.contains(&window.class()?)
{
should_expand_border = true;
}
if should_expand_border {
rect.left -= invisible_borders.left;
rect.top -= invisible_borders.top;
rect.right += invisible_borders.right;
rect.bottom += invisible_borders.bottom;
}
*BORDER_RECT.lock() = rect;
WindowsApi::position_border_window(self.hwnd(), &rect, activate)
}
}

View File

@@ -135,7 +135,7 @@ impl WindowManager {
match event {
WindowManagerEvent::Raise(window) => {
window.raise();
window.raise()?;
self.has_pending_raise_op = false;
}
WindowManagerEvent::Destroy(_, window) | WindowManagerEvent::Unmanage(window) => {
@@ -503,12 +503,6 @@ impl WindowManager {
WindowsApi::raise_window(border.hwnd())?;
};
if let Some(monocle_container) = self.focused_workspace()?.monocle_container() {
if let Some(window) = monocle_container.focused_window() {
target_window = Option::from(*window);
}
}
if target_window.is_none() {
match self.focused_container() {
// if there is no focused container, the desktop is empty

View File

@@ -187,55 +187,25 @@ impl Window {
WindowsApi::unmaximize_window(self.hwnd());
}
pub fn raise(self) {
pub fn raise(self) -> Result<()> {
// Attach komorebi thread to Window thread
let (_, window_thread_id) = WindowsApi::window_thread_process_id(self.hwnd());
let current_thread_id = WindowsApi::current_thread_id();
// This can be allowed to fail if a window doesn't have a message queue or if a journal record
// hook has been installed
// https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-attachthreadinput#remarks
match WindowsApi::attach_thread_input(current_thread_id, window_thread_id, true) {
Ok(()) => {}
Err(error) => {
tracing::error!(
"could not attach to window thread input processing mechanism, but continuing execution of raise(): {}",
error
);
}
};
WindowsApi::attach_thread_input(current_thread_id, window_thread_id, true)?;
// Raise Window to foreground
match WindowsApi::set_foreground_window(self.hwnd()) {
Ok(_) => {}
Err(error) => {
tracing::error!(
"could not set as foreground window, but continuing execution of raise(): {}",
"could not set as foreground window, but continuing execution of focus(): {}",
error
);
}
};
// This isn't really needed when the above command works as expected via AHK
match WindowsApi::set_focus(self.hwnd()) {
Ok(_) => {}
Err(error) => {
tracing::error!(
"could not set focus, but continuing execution of raise(): {}",
error
);
}
};
match WindowsApi::attach_thread_input(current_thread_id, window_thread_id, false) {
Ok(()) => {}
Err(error) => {
tracing::error!(
"could not detach from window thread input processing mechanism, but continuing execution of raise(): {}",
error
);
}
};
WindowsApi::set_focus(self.hwnd())
}
pub fn focus(self, mouse_follows_focus: bool) -> Result<()> {
@@ -283,16 +253,6 @@ impl Window {
}
};
match WindowsApi::attach_thread_input(current_thread_id, window_thread_id, false) {
Ok(()) => {}
Err(error) => {
tracing::error!(
"could not detach from window thread input processing mechanism, but continuing execution of focus(): {}",
error
);
}
};
Ok(())
}

View File

@@ -88,7 +88,15 @@ impl Workspace {
pub fn hide(&mut self) {
for container in self.containers_mut() {
for window in container.windows_mut() {
window.hide();
if let (Ok(exe), Ok(title)) = (window.exe(), window.title()) {
if exe == "UnrealEditor.exe" {
if title.ends_with(" - Unreal Editor") {
window.hide();
}
} else {
window.hide();
}
}
}
}
@@ -112,7 +120,15 @@ impl Workspace {
let mut to_focus = None;
for (i, container) in self.containers_mut().iter_mut().enumerate() {
if let Some(window) = container.focused_window_mut() {
window.restore();
if let (Ok(exe), Ok(title)) = (window.exe(), window.title()) {
if exe == "UnrealEditor.exe" {
if title.ends_with(" - Unreal Editor") {
window.restore();
}
} else {
window.restore();
}
}
if idx == i {
to_focus = Option::from(*window);

View File

@@ -1,6 +1,6 @@
[package]
name = "komorebic"
version = "0.1.13"
version = "0.1.12"
authors = ["Jade Iqbal <jadeiqbal@fastmail.com>"]
description = "The command-line interface for Komorebi, a tiling window manager for Windows"
categories = ["cli", "tiling-window-manager", "windows"]