Skip to content

Commit

Permalink
fix: app - fixed a bug for ventura preventing windows from opening
Browse files Browse the repository at this point in the history
  • Loading branch information
davide-baldo committed Dec 12, 2023
1 parent 02abca5 commit aee5ff0
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@
INFOPLIST_KEY_CFBundleDisplayName = Ockam;
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities";
"LIBRARY_SEARCH_PATHS[arch=*]" = ../../../../target/debug/;
MACOSX_DEPLOYMENT_TARGET = 13.1;
MACOSX_DEPLOYMENT_TARGET = 13.5;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -412,7 +412,7 @@
INFOPLIST_KEY_CFBundleDisplayName = Ockam;
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities";
"LIBRARY_SEARCH_PATHS[arch=*]" = ../../../../target/release/;
MACOSX_DEPLOYMENT_TARGET = 13.1;
MACOSX_DEPLOYMENT_TARGET = 13.5;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -449,7 +449,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 13.1;
MACOSX_DEPLOYMENT_TARGET = 13.5;
MARKETING_VERSION = 0.1;
PRODUCT_BUNDLE_IDENTIFIER = io.ockam.Ockam;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down Expand Up @@ -485,7 +485,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 13.1;
MACOSX_DEPLOYMENT_TARGET = 13.5;
MARKETING_VERSION = 0.1;
MTL_ENABLE_DEBUG_INFO = YES;
PRODUCT_BUNDLE_IDENTIFIER = io.ockam.Ockam;
Expand Down
6 changes: 6 additions & 0 deletions implementations/swift/ockam/ockam_app/Ockam/GuidedIntro.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ For more information check out the [user guide](https://docs.ockam.io/reference/
height: VerticalSpacingUnit*4
)
}
.controlSize(.large)
.keyboardShortcut(.defaultAction)
.padding(.vertical, VerticalSpacingUnit)
} else if status == OrchestratorStatus.Connecting ||
Expand All @@ -128,6 +129,7 @@ For more information check out the [user guide](https://docs.ockam.io/reference/
)
.focusable()
}
.controlSize(.large)
.keyboardShortcut(.defaultAction)
.padding(.vertical, VerticalSpacingUnit)
}
Expand All @@ -147,6 +149,7 @@ For more information check out the [user guide](https://docs.ockam.io/reference/
height: VerticalSpacingUnit*4
)
}
.controlSize(.large)

Button(action: {
page += 1
Expand All @@ -158,6 +161,7 @@ For more information check out the [user guide](https://docs.ockam.io/reference/
height: VerticalSpacingUnit*4
)
}
.controlSize(.large)
.keyboardShortcut(.defaultAction)
}
Spacer()
Expand All @@ -173,6 +177,7 @@ For more information check out the [user guide](https://docs.ockam.io/reference/
height: VerticalSpacingUnit*4
)
}
.controlSize(.large)
.keyboardShortcut(.defaultAction)
Spacer()
} else {
Expand All @@ -189,6 +194,7 @@ For more information check out the [user guide](https://docs.ockam.io/reference/
)
.focusable()
}
.controlSize(.large)
.keyboardShortcut(.defaultAction)
.padding(.vertical, VerticalSpacingUnit)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ struct LocalPortalView: View {
ClickableMenuEntry(
text: "Share…",
action: {
openWindow(id: "invite-to-portal", value: localService.id)
OpenWindowWorkaround.shared.openWindow(
windowName: "invite-to-portal",
value: localService.id
)
bringInFront()
self.closeWindow()
})
Expand Down
13 changes: 8 additions & 5 deletions implementations/swift/ockam/ockam_app/Ockam/MainView.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import SwiftUI

struct MainView: View {
@Environment(\.openWindow) private var openWindow
@EnvironmentObject private var appDelegate: AppDelegate

@Binding var state: ApplicationState
Expand Down Expand Up @@ -73,7 +72,7 @@ struct MainView: View {
)
}
}
.scrollIndicators(ScrollIndicatorVisibility.hidden)
.scrollIndicators(ScrollIndicatorVisibility.never)
.frame(maxHeight: 250)

Divider()
Expand All @@ -84,7 +83,9 @@ struct MainView: View {
ClickableMenuEntry(
text: "Open a portal…",
action: {
openWindow(id: "open-portal")
OpenWindowWorkaround.shared.openWindow(
windowName: "open-portal"
)
bringInFront()
}
)
Expand Down Expand Up @@ -117,7 +118,7 @@ struct MainView: View {
}
}
}
.scrollIndicators(ScrollIndicatorVisibility.hidden)
.scrollIndicators(ScrollIndicatorVisibility.never)
.frame(maxHeight: selectedGroup == "" ? 175 : 500)

}
Expand Down Expand Up @@ -171,7 +172,9 @@ struct MainView: View {
ClickableMenuEntry(
text: "About", icon: "questionmark.circle",
action: {
openWindow(id: "about")
OpenWindowWorkaround.shared.openWindow(
windowName: "about"
)
bringInFront()
})
ClickableMenuEntry(
Expand Down
48 changes: 43 additions & 5 deletions implementations/swift/ockam/ockam_app/Ockam/OckamApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,29 @@ class InvitationContainer: ObservableObject {
}
}

// On macOS ventura openWindow() doesn't work since the SwiftUI
// lifecycle is not recognized for some reason when using NSHostingView,
// this has been fixed in sonoma.
// The idea is to trigger an event to trigger an openWindow from another
// context where NSHostingView is a parent view.
// Only openWindow() used within the PopOver is affected.
class OpenWindowWorkaround: ObservableObject {
static var shared = OpenWindowWorkaround()
@Published var windowName = ""
@Published var value = ""

func openWindow(windowName: String) {
self.windowName = windowName;
self.value = "";
}

func openWindow(windowName: String, value: String) {
self.windowName = windowName;
self.value = value;
}
}


// when the application initialization fails to load we enter a broken state
// where we only propose a reset to the user
var broken = false
Expand Down Expand Up @@ -217,15 +240,30 @@ struct OckamApp: App {
openWindow(id: "accepting-invitation")
}
})
// hack for ventura, see OpenWindowWorkaround comment
.onReceive(OpenWindowWorkaround.shared.$windowName) { _ in
if OpenWindowWorkaround.shared.value == "" {
openWindow(
id: OpenWindowWorkaround.shared.windowName
)
} else {
openWindow(
id: OpenWindowWorkaround.shared.windowName,
value: OpenWindowWorkaround.shared.value
)
}
}
}
.windowResizability(.contentSize)

WindowGroup("Confirmation", id: "delete-portal-confirmation", for: Service.ID.self) { $serviceId in
DeleteIncomingPortalView(
service: StateContainer.shared.state.lookupIncomingServiceById(
serviceId.unsafelyUnwrapped
).unsafelyUnwrapped.1
)
if let serviceId = serviceId {
DeleteIncomingPortalView(
service: StateContainer.shared.state.lookupIncomingServiceById(
serviceId
).unsafelyUnwrapped.1
)
}
}
.windowResizability(.contentSize)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,10 @@ struct RemotePortalView: View {
ClickableMenuEntry(
text: "Delete",
action: {
openWindow(id: "delete-portal-confirmation", value: service.id)
OpenWindowWorkaround.shared.openWindow(
windowName: "delete-portal-confirmation",
value: service.id
)
})
}
.padding(.leading, HorizontalSpacingUnit*2)
Expand Down

0 comments on commit aee5ff0

Please sign in to comment.