Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

Center windows on macOS with error handling

Richie McIlroy3e5221c14f85
diff --git a/apps/desktop/src-tauri/src/windows.rs b/apps/desktop/src-tauri/src/windows.rs
index 230dce20d..ecd719f1a 100644
--- a/apps/desktop/src-tauri/src/windows.rs
+++ b/apps/desktop/src-tauri/src/windows.rs
@@ -315,7 +315,6 @@ impl ShowCapWindow {
.always_on_top(true)
.visible_on_all_workspaces(true)
.content_protected(should_protect)
- .center()
.initialization_script(format!(
"
window.__CAP__ = window.__CAP__ ?? {{}};
@@ -326,6 +325,13 @@ impl ShowCapWindow {
))
.build()?;
+ #[cfg(target_os = "macos")]
+ {
+ if let Err(e) = window.center() {
+ warn!("Failed to center Main window on macOS: {}", e);
+ }
+ }
+
#[cfg(target_os = "macos")]
crate::platform::set_window_level(window.as_ref().window(), 50);
@@ -448,9 +454,15 @@ impl ShowCapWindow {
.min_inner_size(600.0, 465.0)
.resizable(true)
.maximized(false)
- .center()
.build()?;
+ #[cfg(target_os = "macos")]
+ {
+ if let Err(e) = window.center() {
+ warn!("Failed to center Settings window on macOS: {}", e);
+ }
+ }
+
#[cfg(windows)]
{
use tauri::LogicalSize;
@@ -561,9 +573,15 @@ impl ShowCapWindow {
.always_on_top(true)
.maximized(false)
.shadow(true)
- .center()
.build()?;
+ #[cfg(target_os = "macos")]
+ {
+ if let Err(e) = window.center() {
+ warn!("Failed to center Upgrade window on macOS: {}", e);
+ }
+ }
+
#[cfg(windows)]
{
use tauri::LogicalSize;
@@ -589,11 +607,17 @@ impl ShowCapWindow {
.resizable(false)
.maximized(false)
.maximizable(false)
- .center()
.focused(true)
.shadow(true)
.build()?;
+ #[cfg(target_os = "macos")]
+ {
+ if let Err(e) = window.center() {
+ warn!("Failed to center ModeSelect window on macOS: {}", e);
+ }
+ }
+
#[cfg(windows)]
{
use tauri::LogicalSize;