Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions Sources/App/CmuxMainWindow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,6 @@ final class MainWindowHostingView<Content: View>: NSHostingView<Content> {
@MainActor
final class CmuxMainWindow: NSWindow {
private var isSoftHiddenForVisibilityController = false
private var isClearingNativeTitlebarProxyIcon = false

// cmux renders the workspace directory icon inside its custom titlebar, whose layout follows
// the sidebar. AppKit's native proxy icon is positioned in the standard titlebar instead.
override var representedURL: URL? {
get { nil }
set { clearNativeTitlebarProxyIcon() }
}

override var representedFilename: String {
get { "" }
set { clearNativeTitlebarProxyIcon() }
}

private func clearNativeTitlebarProxyIcon() {
guard !isClearingNativeTitlebarProxyIcon else { return }
isClearingNativeTitlebarProxyIcon = true
defer { isClearingNativeTitlebarProxyIcon = false }
super.representedURL = nil
super.representedFilename = ""
}

Comment thread
austinywang marked this conversation as resolved.
func setSoftHiddenForVisibilityController(_ isSoftHidden: Bool) {
isSoftHiddenForVisibilityController = isSoftHidden
Expand Down
30 changes: 29 additions & 1 deletion Sources/CmuxLifecycleEventPublishing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -218,15 +218,43 @@ extension Workspace {
}
}

@MainActor
private enum MainWindowKeyRegainRefresh {
static func refresh(window: NSWindow, context: AppDelegate.MainWindowContext) {
// Window focus regain owns the redraw invariant. Cursor tracking and
// focused subviews can update themselves only after this invalidation.
invalidateContentDisplayTree(window: window)
_ = context.keyboardFocusCoordinator.restoreTargetAfterWindowBecameKey()
}

private static func invalidateContentDisplayTree(window: NSWindow) {
guard let contentView = window.contentView else { return }
invalidateDisplayTree(rootedAt: contentView)
window.invalidateCursorRects(for: contentView)
}

private static func invalidateDisplayTree(rootedAt view: NSView) {
guard !view.isHidden else { return }
view.needsDisplay = true
view.layer?.setNeedsDisplay()
for subview in view.subviews {
invalidateDisplayTree(rootedAt: subview)
}
}
}

extension AppDelegate {
func handleCmuxWindowBecameKey(_ note: Notification) {
guard let window = note.object as? NSWindow else { return }
MainActor.assumeIsolated {
let context = contextForMainTerminalWindow(window)
setActiveMainWindow(window)
if let windowId = mainWindowId(from: window) {
publishCmuxWindowLifecycle(name: "window.keyed", windowId: windowId, origin: "appkit_key")
}
_ = contextForMainTerminalWindow(window)?.keyboardFocusCoordinator.restoreTargetAfterWindowBecameKey()
if let context {
MainWindowKeyRegainRefresh.refresh(window: window, context: context)
}
}
}

Expand Down
9 changes: 3 additions & 6 deletions Sources/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2297,19 +2297,16 @@ struct ContentView: View {
TitlebarLeadingInsetReader(inset: $titlebarLeadingInset)
.allowsHitTesting(false)

HStack(spacing: TitlebarFolderIconMetrics.iconTitleSpacing) {
HStack(spacing: 8) {
if isFullScreen && !sidebarState.isVisible {
fullscreenControls
}

// Draggable folder icon + focused command name
if let directory = focusedDirectory {
DetachedFolderDragIcon(directory: directory)
.frame(
width: TitlebarFolderIconMetrics.iconSize,
height: TitlebarFolderIconMetrics.iconSize
)
.padding(.leading, TitlebarFolderIconMetrics.iconLeadingPadding)
.frame(width: 16, height: 16)
.padding(.leading, -6)
}

Text(titlebarText)
Expand Down
Loading
Loading