-
Notifications
You must be signed in to change notification settings - Fork 562
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: reposition darwin traffic-lights in title bar
- Loading branch information
Showing
6 changed files
with
426 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[package] | ||
name = "tauri-plugin-trafficlights-positioner" | ||
version = "1.0.0" | ||
authors = ["ItsEeleeya"] | ||
description = "A Tauri v2 plugin to help setting the position of the window traffic lights on macOS." | ||
edition = "2021" | ||
rust-version = "1.60" | ||
exclude = ["/example", ".github"] | ||
license = "MIT" | ||
repository = "https://github.com/itseeleeya/tauri-plugin-trafficlights-positioner/" | ||
keywords = ["tauri", "tauri-plugin", "tauri-plugin-macos"] | ||
|
||
[dependencies] | ||
tauri = { version = "2.1.1" } | ||
|
||
[target.'cfg(target_os = "macos")'.dependencies] | ||
cocoa = "0.26.0" | ||
objc = "0.2.7" | ||
rand = "0.8.5" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use tauri::{LogicalPosition, Runtime, Window}; | ||
|
||
#[cfg(target_os = "macos")] | ||
mod positioner; | ||
|
||
#[cfg(target_os = "macos")] | ||
#[macro_use] | ||
extern crate cocoa; | ||
|
||
#[cfg(target_os = "macos")] | ||
pub trait WindowExt { | ||
fn setup_traffic_lights_inset(&self, offset: LogicalPosition<f64>) -> tauri::Result<()>; | ||
} | ||
|
||
#[cfg(target_os = "macos")] | ||
impl<R: Runtime> WindowExt for Window<R> { | ||
fn setup_traffic_lights_inset(&self, inset: LogicalPosition<f64>) -> tauri::Result<()> { | ||
let win = self.clone(); | ||
self.on_window_event(move |event| { | ||
if let tauri::WindowEvent::ThemeChanged(_) = event { | ||
let win_clone = win.clone(); | ||
|
||
let _ = win.clone().run_on_main_thread(move || { | ||
positioner::update(&win_clone, &inset); | ||
}); | ||
} | ||
}); | ||
|
||
let win = self.clone(); | ||
self.run_on_main_thread(move || { | ||
positioner::setup_nswindow_delegates(win, inset); | ||
}) | ||
} | ||
} |
Oops, something went wrong.