macos: added platform checks for ToggleFloatingWindow

Signed-off-by: rawnly <rawnly@users.noreply.github.com>
This commit is contained in:
rawnly authored and Wez Furlong committed 2024-01-21 14:06:01 -07:00
1 parent 8906d03851
commit ae67f85ea3
4 files changed
+16 -5

No files matched your search

+1
View File
@@ -505,6 +505,7 @@ pub enum KeyAssignment {
SpawnTab(SpawnTabDomain),
SpawnWindow,
ToggleFullScreen,
#[cfg(target_os = "macos")]
ToggleFloatingWindow,
CopyTo(ClipboardCopyDestination),
CopyTextTo {
+2
View File
@@ -2024,6 +2024,8 @@ fn compute_default_actions() -> Vec<KeyAssignment> {
ScrollToBottom,
// ----------------- Window
ToggleFullScreen,
#[cfg(target_os = "macos")]
ToggleFloatingWindow,
Hide,
Search(Pattern::CurrentSelectionOrEmptyString),
PaneSelect(PaneSelectArguments {
+11 -5
View File
@@ -2507,15 +2507,21 @@ impl TermWindow {
ToggleFullScreen => {
self.window.as_ref().unwrap().toggle_fullscreen();
}
#[cfg(target_os = "macos")]
ToggleFloatingWindow => {
let window = self.window.clone().unwrap();
promise::spawn::spawn(async move {
if let Ok(level) = window.level().await {
match level {
WindowLevel::Floating => window.set_level(WindowLevel::Normal),
_ => window.set_level(WindowLevel::Floating)
};
match window.level().await {
Ok(level) => {
match level {
WindowLevel::Floating => window.set_level(WindowLevel::Normal),
_ => window.set_level(WindowLevel::Floating)
};
}
Err(e) => {
log::error!("an error has occurred while retriving current window level: {:?}", e);
}
}
})
.detach();
+2
View File
@@ -295,9 +295,11 @@ pub trait WindowOps {
fn set_clipboard(&self, clipboard: Clipboard, text: String);
/// Set window level (macos only!)
#[cfg(target_os = "macos")]
fn set_level(&self, level: WindowLevel);
/// Get window level (macos only!)
#[cfg(target_os = "macos")]
fn level(&self) -> Future<WindowLevel>;
/// Set the icon for the window.