-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Refactor window handling, improve theme support, and update dependencies #1807
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ItsEeleeya
wants to merge
78
commits into
CapSoftware:main
Choose a base branch
from
ItsEeleeya:next-base-improvements
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 31 commits
Commits
Show all changes
78 commits
Select commit
Hold shift + click to select a range
a49b55a
no NSPanel for main, fix traffic lights, editor header height
ItsEeleeya 49ba3b6
Bump versions for tauri, tauri-cli, objc2-app-kit
ItsEeleeya 75ba1b3
Fix theme change, rename AppTheme to Appearance
ItsEeleeya 5faa712
Correctly display crop options context menu onMouseDown
ItsEeleeya fca4ebf
Add more associated file info like UTTypeConformsTo and UTTypeIdentif…
ItsEeleeya 33bab32
Use non activating style mask on NSPanels and don't make them focused.
ItsEeleeya 5fea9e1
no NSPanel for main, fix traffic lights, editor header height
ItsEeleeya 8eb3360
Bump versions for tauri, tauri-cli, objc2-app-kit
ItsEeleeya 46b007b
Fix theme change, rename AppTheme to Appearance
ItsEeleeya ed3c86b
Correctly display crop options context menu onMouseDown
ItsEeleeya 819f9d9
Add more associated file info like UTTypeConformsTo and UTTypeIdentif…
ItsEeleeya 4a1fad4
Use non activating style mask on NSPanels and don't make them focused.
ItsEeleeya 4f19b49
Merge branch 'next-base-improvements' of https://github.com/ItsEeleey…
ItsEeleeya 750783a
Merge branch 'main' into next-base-improvements
ItsEeleeya 2b0a417
update tauri-build
ItsEeleeya 3b39cf9
Use `data-tauri-drag-region="deep"`
ItsEeleeya 7643967
Merge branch 'main' into next-base-improvements
ItsEeleeya 038ba02
Merge remote-tracking branch 'upstream/main' into next-base-improvements
ItsEeleeya 79c5f56
Rename ShowCapWindow to CapWindow
ItsEeleeya 31f364f
Move display math into display_utils.rs, remove now unused is_system_…
ItsEeleeya b92ed38
Better window auto show handling
ItsEeleeya 2827347
Merge remote-tracking branch 'upstream/main' into next-base-improvements
ItsEeleeya aea51c7
clippy
ItsEeleeya acb8758
Update windows.rs
ItsEeleeya 233041d
Remove now unused command `set_theme`
ItsEeleeya 0717879
Merge remote-tracking branch 'upstream/main' into next-base-improvements
ItsEeleeya 222096d
fix: no longer show invisible target_select_overlay when closing sett…
ItsEeleeya 079fe32
Remove ensure_settings_window_bounds and Settings window from tauri_p…
ItsEeleeya 3321f9f
Improve window reveal + a little nicer debug window + format
ItsEeleeya 4eda736
Merge remote-tracking branch 'upstream/main' into next-base-improvements
ItsEeleeya fa494bc
fix: no longer show invisible target_select_overlay when closing upgrade
ItsEeleeya 661850a
nitpicks
ItsEeleeya 55fa566
Don't force center Editors and Main window
ItsEeleeya 9be649b
Merge remote-tracking branch 'upstream/main' into next-base-improvements
ItsEeleeya e56df0a
Use objc2_application_services and remove the old core-foundation and…
ItsEeleeya 8a1203c
Use writeClipboardString for desktop frontend.
ItsEeleeya 94c2ec6
more better theme handling
ItsEeleeya 87d8df1
Use _doAfterNextPresentationUpdate on macOS
ItsEeleeya 648d930
Remove editors from tauri_plugin_window_state's denylist
ItsEeleeya d440364
Remove incorrect/unused at apps/src/utils/tauri.ts
ItsEeleeya ca55501
remove unused window_transparency command and setting + format + lint
ItsEeleeya 2d56b9a
Merge remote-tracking branch 'upstream/main' into next-base-improvements
ItsEeleeya a4df7d2
cargo fmt + lint
ItsEeleeya 794d4c1
Merge remote-tracking branch 'upstream/main' into next-base-improvements
ItsEeleeya d6dca98
fix webview process leak due to use of `with_webview` + bump tauri ve…
ItsEeleeya b05caed
Merge remote-tracking branch 'upstream/main' into next-base-improvements
ItsEeleeya ccd2d9d
Merge remote-tracking branch 'upstream/main' into next-base-improvements
ItsEeleeya ab0175a
Fix after merge (need objc and cocoa back)
ItsEeleeya 6be6ffb
Merge remote-tracking branch 'upstream/main' into next-base-improvements
ItsEeleeya c9b913f
clippy + format
ItsEeleeya 9c4b4ef
Fix tauri plugin version mismatch
ItsEeleeya be21f71
(again) remove fake traffic lights
ItsEeleeya 22b4998
Merge remote-tracking branch 'upstream/main' into next-base-improvements
ItsEeleeya 17c43f3
Merge remote-tracking branch 'upstream/main' into next-base-improvements
ItsEeleeya 15204c1
Clean up + clippy + cargo fmt
ItsEeleeya d9d35c9
Update windows.rs
ItsEeleeya 7d06f5a
Merge remote-tracking branch 'upstream/main' into next-base-improvements
ItsEeleeya 8d58472
Ensure size constraints when opening windows + cleanup
ItsEeleeya 76bb400
Add tauri-plugin-prevent-default + clippy
ItsEeleeya 31431ba
Merge remote-tracking branch 'upstream/main' into next-base-improvements
ItsEeleeya 0b761d5
cleanup
ItsEeleeya 38390a7
Update windows.rs
ItsEeleeya 479ca6d
Merge remote-tracking branch 'upstream/main' into next-base-improvements
ItsEeleeya 7b083dc
fix missed passing fallback into RevealWindowWithSuspense
ItsEeleeya b44d4dc
Update lib.rs
ItsEeleeya ca82940
Merge remote-tracking branch 'upstream/main' into next-base-improvements
ItsEeleeya 971ae1e
Merge remote-tracking branch 'upstream/main' into next-base-improvements
ItsEeleeya 913df6f
Merge remote-tracking branch 'upstream/main' into next-base-improvements
ItsEeleeya fd875c2
JSDoc for AutoRevealWindowOnReady and RevealWindowWithSuspense
ItsEeleeya 391d163
Patch about menu, and help menu items + remove install_macos_native_t…
ItsEeleeya 1b420b1
Ensure window is revealed when ErrorBoundary is reached
ItsEeleeya 67000e2
bring back modified install_macos_native_terminate_handler + fix quit…
ItsEeleeya d858a06
Remove redundant `inner_size` and `min_inner_size` in windows.rs + bi…
ItsEeleeya 4d67fef
Merge remote-tracking branch 'upstream/main' into next-base-improvements
ItsEeleeya 20d0f92
Update to tauri_nspanel 2.1 + main is a panel again + use correct NSC…
ItsEeleeya 47830d6
Use AppKit's frame autosave for main panel
ItsEeleeya 22114ba
Fix cropper bounds
ItsEeleeya db7a8a2
Merge remote-tracking branch 'upstream/main' into next-base-improvements
ItsEeleeya File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,168 @@ | ||
| use scap_targets::Display; | ||
| use tauri::{PhysicalPosition, PhysicalSize}; | ||
|
|
||
| // Credits: tauri-plugin-window-state | ||
| pub trait MonitorExt { | ||
| fn intersects( | ||
| &self, | ||
| position: PhysicalPosition<i32>, | ||
| size: PhysicalSize<u32>, | ||
| scale: f64, | ||
| ) -> bool; | ||
|
|
||
| fn intersects_window(&self, window: tauri::Window) -> tauri::Result<bool>; | ||
| } | ||
|
|
||
| impl MonitorExt for Display { | ||
| fn intersects_window(&self, window: tauri::Window) -> tauri::Result<bool> { | ||
| Ok(self.intersects( | ||
| window.outer_position()?, | ||
| window.outer_size()?, | ||
| window.scale_factor()?, | ||
| )) | ||
| } | ||
|
|
||
| fn intersects( | ||
| &self, | ||
| position: PhysicalPosition<i32>, | ||
| size: PhysicalSize<u32>, | ||
| _scale: f64, | ||
| ) -> bool { | ||
| #[cfg(target_os = "macos")] | ||
| { | ||
| let Some(bounds) = self.raw_handle().logical_bounds() else { | ||
| return false; | ||
| }; | ||
|
|
||
| let left = (bounds.position().x() * _scale) as i32; | ||
| let right = left + (bounds.size().width() * _scale) as i32; | ||
| let top = (bounds.position().y() * _scale) as i32; | ||
| let bottom = top + (bounds.size().height() * _scale) as i32; | ||
|
|
||
| [ | ||
| (position.x, position.y), | ||
| (position.x + size.width as i32, position.y), | ||
| (position.x, position.y + size.height as i32), | ||
| ( | ||
| position.x + size.width as i32, | ||
| position.y + size.height as i32, | ||
| ), | ||
| ] | ||
| .into_iter() | ||
| .any(|(x, y)| x >= left && x < right && y >= top && y < bottom) | ||
| } | ||
|
|
||
| #[cfg(windows)] | ||
| { | ||
| let Some(bounds) = self.raw_handle().physical_bounds() else { | ||
| return false; | ||
| }; | ||
|
|
||
| let left = bounds.position().x() as i32; | ||
| let right = left + bounds.size().width() as i32; | ||
| let top = bounds.position().y() as i32; | ||
| let bottom = top + bounds.size().height() as i32; | ||
|
|
||
| [ | ||
| (position.x, position.y), | ||
| (position.x + size.width as i32, position.y), | ||
| (position.x, position.y + size.height as i32), | ||
| ( | ||
| position.x + size.width as i32, | ||
| position.y + size.height as i32, | ||
| ), | ||
| ] | ||
| .into_iter() | ||
| .any(|(x, y)| x >= left && x < right && y >= top && y < bottom) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| const DEFAULT_FALLBACK_DISPLAY_WIDTH: f64 = 1920.0; | ||
| const DEFAULT_FALLBACK_DISPLAY_HEIGHT: f64 = 1080.0; | ||
| pub struct CursorMonitorInfo { | ||
| pub x: f64, | ||
| pub y: f64, | ||
| pub width: f64, | ||
| pub height: f64, | ||
| } | ||
|
|
||
| impl CursorMonitorInfo { | ||
| pub fn get() -> Self { | ||
| let display = Display::get_containing_cursor().unwrap_or_else(Display::primary); | ||
| let bounds = display.raw_handle().logical_bounds(); | ||
| let (x, y, width, height) = bounds | ||
| .map(|b| { | ||
| ( | ||
| b.position().x(), | ||
| b.position().y(), | ||
| b.size().width(), | ||
| b.size().height(), | ||
| ) | ||
| }) | ||
| .unwrap_or(( | ||
| 0.0, | ||
| 0.0, | ||
| DEFAULT_FALLBACK_DISPLAY_WIDTH, | ||
| DEFAULT_FALLBACK_DISPLAY_HEIGHT, | ||
| )); | ||
|
|
||
| Self { | ||
| x, | ||
| y, | ||
| width, | ||
| height, | ||
| } | ||
| } | ||
|
|
||
| pub fn center_position(&self, window_width: f64, window_height: f64) -> (f64, f64) { | ||
| let pos_x = self.x + (self.width - window_width) / 2.0; | ||
| let pos_y = self.y + (self.height - window_height) / 2.0; | ||
| (pos_x, pos_y) | ||
| } | ||
|
|
||
| pub fn bottom_center_position( | ||
| &self, | ||
| window_width: f64, | ||
| window_height: f64, | ||
| offset_y: f64, | ||
| ) -> (f64, f64) { | ||
| let pos_x = self.x + (self.width - window_width) / 2.0; | ||
| let pos_y = self.y + self.height - window_height - offset_y; | ||
| (pos_x, pos_y) | ||
| } | ||
|
|
||
| pub fn from_window(window: &tauri::WebviewWindow) -> Self { | ||
| let window_pos = window | ||
| .outer_position() | ||
| .ok() | ||
| .map(|p| (p.x as f64, p.y as f64)) | ||
| .unwrap_or((0.0, 0.0)); | ||
|
|
||
| for display in Display::list() { | ||
| if let Some(bounds) = display.raw_handle().logical_bounds() { | ||
| let (x, y, width, height) = ( | ||
| bounds.position().x(), | ||
| bounds.position().y(), | ||
| bounds.size().width(), | ||
| bounds.size().height(), | ||
| ); | ||
|
|
||
| if window_pos.0 >= x | ||
| && window_pos.0 < x + width | ||
| && window_pos.1 >= y | ||
| && window_pos.1 < y + height | ||
| { | ||
| return Self { | ||
| x, | ||
| y, | ||
| width, | ||
| height, | ||
| }; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| Self::get() | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.