Skip to content

Commit

Permalink
Merge pull request #37 from peterklingelhofer/bugfix/Initial_window_f…
Browse files Browse the repository at this point in the history
…lash_off_screen

bugfix(swift): Initial window flash off screen
  • Loading branch information
peterklingelhofer authored Oct 16, 2024
2 parents 59b8734 + 25e5813 commit b769a53
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
8 changes: 4 additions & 4 deletions swift/exhale.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@
CODE_SIGN_ENTITLEMENTS = exhale/exhale.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 158;
CURRENT_PROJECT_VERSION = 159;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"exhale/Preview Content\"";
DEVELOPMENT_TEAM = VZCHHV7VNW;
Expand All @@ -464,7 +464,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 1.5.8;
MARKETING_VERSION = 1.5.9;
PRODUCT_BUNDLE_IDENTIFIER = peterklingelhofer.exhale;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = macosx;
Expand All @@ -483,7 +483,7 @@
CODE_SIGN_ENTITLEMENTS = exhale/exhale.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 158;
CURRENT_PROJECT_VERSION = 159;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"exhale/Preview Content\"";
DEVELOPMENT_TEAM = VZCHHV7VNW;
Expand All @@ -497,7 +497,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 1.5.8;
MARKETING_VERSION = 1.5.9;
PRODUCT_BUNDLE_IDENTIFIER = peterklingelhofer.exhale;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = macosx;
Expand Down
23 changes: 17 additions & 6 deletions swift/exhale/EmptyClosingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,26 @@ struct EmptyClosingView: NSViewRepresentable {
return view
}

func updateNSView(_ nsView: NSView, context: Context) {}
func updateNSView(_ nsView: NSView, context: Context) {
}

class SelfClosingView: NSView {
override func viewDidMoveToWindow() {
super.viewDidMoveToWindow()
override func viewWillMove(toWindow newWindow: NSWindow?) {
super.viewWillMove(toWindow: newWindow)

// Ensure the closure happens before the window is displayed
DispatchQueue.main.async {
if let window = self.window {
window.close()
}
guard let window = newWindow else { return }

// 1. Make the window fully transparent
window.alphaValue = 0

// 2. Move the window offscreen
let offscreenOrigin = NSPoint(x: -2000, y: -2000)
window.setFrameOrigin(offscreenOrigin)

// 3. Close the window immediately
window.close()
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion swift/exhale/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ struct SettingsView: View {
VStack {
HStack {
Spacer()
Text("Build: \(getAppVersion())")
Text("\(getAppVersion())")
.font(.footnote)
.padding([.trailing, .top], 20)
}
Expand Down

0 comments on commit b769a53

Please sign in to comment.