Skip to content

Commit 629d912

Browse files
committed
feat: impl X11::hidden_window
1 parent 663abd0 commit 629d912

File tree

5 files changed

+19
-11
lines changed

5 files changed

+19
-11
lines changed

src/gui/app.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,9 @@ fn create_window(
140140
cx.open_window(
141141
WindowOptions {
142142
window_bounds: Some(WindowBounds::Windowed(bounds)),
143-
#[cfg(target_os = "linux")]
144-
kind: WindowKind::Normal,
145-
#[cfg(not(target_os = "linux"))]
143+
// #[cfg(target_os = "linux")]
144+
// kind: WindowKind::Normal,
145+
// #[cfg(not(target_os = "linux"))]
146146
kind: WindowKind::PopUp,
147147
titlebar: None,
148148
show: !is_silent, // When silent mode, do not show the window initially

src/gui/board/actions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl RopyBoard {
6565
window.focus(&self.focus_handle);
6666
return;
6767
}
68-
hide_window(window, cx, true);
68+
hide_window(window, cx);
6969
self.pinned = false;
7070
}
7171

src/gui/board/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ impl RopyBoard {
7676
cx.on_focus_out(&focus_handle, window, move |this, _event, window, cx| {
7777
// When the window loses focus, hide the window
7878
if !this.pinned {
79-
hide_window(window, cx, false);
79+
hide_window(window, cx);
8080
}
8181
});
8282

@@ -213,7 +213,7 @@ impl RopyBoard {
213213
};
214214
self.copy_to_clipboard(&content, &content_type);
215215
if !self.pinned {
216-
hide_window(window, cx, false);
216+
hide_window(window, cx);
217217
}
218218
if index != 0 {
219219
self.delete_record(id);
@@ -241,7 +241,7 @@ impl RopyBoard {
241241

242242
// Get current max_history_records from settings as fallback
243243
let current_max_history = self.settings.read().unwrap().storage.max_history_records;
244-
244+
245245
let max_history = self
246246
.settings_max_history_input
247247
.read(cx)

src/gui/utils.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use windows_sys::Win32::UI::WindowsAndMessaging::{
1414
use objc2::{msg_send, runtime::AnyObject};
1515

1616
/// Hide the window based on the platform
17-
pub fn hide_window<T>(_window: &mut Window, _cx: &mut Context<T>, _is_keybinding: bool) {
17+
pub fn hide_window<T>(_window: &mut Window, _cx: &mut Context<T>) {
1818
#[cfg(target_os = "windows")]
1919
if let Ok(handle) = _window.window_handle() {
2020
if let RawWindowHandle::Win32(handle) = handle.as_raw() {
@@ -28,8 +28,10 @@ pub fn hide_window<T>(_window: &mut Window, _cx: &mut Context<T>, _is_keybinding
2828
_cx.hide();
2929

3030
#[cfg(target_os = "linux")]
31-
if _is_keybinding {
32-
_window.minimize_window();
31+
if let Some(x11) = crate::gui::app::X11.get() {
32+
if let Err(e) = x11.hidden_window() {
33+
eprintln!("[ropy] Failed to hide window: {e}")
34+
}
3335
}
3436
}
3537

@@ -55,7 +57,6 @@ pub fn active_window<T>(_window: &mut Window, _cx: &mut Context<T>) {
5557
}
5658
}
5759
}
58-
5960
}
6061

6162
/// Set the window to be always on top

src/gui/x11.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,11 @@ impl X11 {
131131

132132
Ok(())
133133
}
134+
135+
pub fn hidden_window(&self) -> Result<(), Box<dyn Error>> {
136+
self.connection.unmap_window(self.window_id)?;
137+
self.connection.sync()?;
138+
139+
Ok(())
140+
}
134141
}

0 commit comments

Comments
 (0)