Dynamic Popup/Dropdown shortcut

This commit is contained in:
Hariharan Mudaliar 2025-08-12 22:17:23 +05:30
commit e29745f8f4
6 changed files with 139 additions and 19 deletions

View file

@ -17,7 +17,10 @@ class ClipboardWindowManager: ObservableObject {
func showClipboardWindow() {
if let existingWindow = clipboardWindow {
// Ensure window appears above fullscreen apps
existingWindow.level = .screenSaver
existingWindow.makeKeyAndOrderFront(nil)
existingWindow.orderFrontRegardless() // Force window to front even above fullscreen
NSApp.activate(ignoringOtherApps: true)
return
}
@ -32,24 +35,24 @@ class ClipboardWindowManager: ObservableObject {
window.title = "Clipboard Manager"
window.isMovableByWindowBackground = true
window.level = .floating
window.level = .screenSaver // Use screenSaver level to appear above fullscreen apps
window.isReleasedWhenClosed = false
window.hasShadow = true
window.titlebarAppearsTransparent = true
window.styleMask.insert(.fullSizeContentView)
window.collectionBehavior = [.canJoinAllSpaces, .fullScreenAuxiliary] // Allow on all spaces and above fullscreen
// Set minimum and maximum sizes
window.minSize = NSSize(width: 350, height: 250)
window.maxSize = NSSize(width: 600, height: 500)
// Center the window
if let screen = NSScreen.main {
let screenFrame = screen.visibleFrame
let windowFrame = window.frame
let x = (screenFrame.width - windowFrame.width) / 2 + screenFrame.minX
let y = (screenFrame.height - windowFrame.height) / 2 + screenFrame.minY
window.setFrameOrigin(NSPoint(x: x, y: y))
}
// Center the window on the current screen (important for fullscreen apps)
let currentScreen = NSScreen.main ?? NSScreen.screens.first!
let screenFrame = currentScreen.frame // Use full frame instead of visibleFrame for fullscreen compatibility
let windowFrame = window.frame
let x = (screenFrame.width - windowFrame.width) / 2 + screenFrame.minX
let y = (screenFrame.height - windowFrame.height) / 2 + screenFrame.minY
window.setFrameOrigin(NSPoint(x: x, y: y))
// Set the content view
let contentView = ClipboardWindow()
@ -63,6 +66,7 @@ class ClipboardWindowManager: ObservableObject {
self.clipboardWindow = window
window.makeKeyAndOrderFront(nil)
window.orderFrontRegardless() // Force window to front even above fullscreen apps
NSApp.activate(ignoringOtherApps: true)
}