Fixed: Restore key window state when a dialog closed.

This commit is contained in:
Kirurobo
2021-10-17 15:12:55 +09:00
parent bbfd9fec05
commit 187a5f6d96
3 changed files with 41 additions and 12 deletions

View File

@@ -27,7 +27,7 @@
<key>DTCompiler</key>
<string>com.apple.compilers.llvm.clang.1_0</string>
<key>DTPlatformBuild</key>
<string>12E507</string>
<string>13A233</string>
<key>DTPlatformName</key>
<string>macosx</string>
<key>DTPlatformVersion</key>
@@ -37,9 +37,9 @@
<key>DTSDKName</key>
<string>macosx11.3</string>
<key>DTXcode</key>
<string>1251</string>
<string>1300</string>
<key>DTXcodeBuild</key>
<string>12E507</string>
<string>13A233</string>
<key>LSMinimumSystemVersion</key>
<string>10.13</string>
<key>NSHumanReadableCopyright</key>

View File

@@ -89,6 +89,7 @@ public class LibUniWinC : NSObject {
public var backgroundColor: NSColor = NSColor.clear
public var isOpaque: Bool = true
public var hasShadow: Bool = true
public var isKeyWindow: Bool = true
public var contentViewWantsLayer: Bool = true
public var contentViewLayerIsOpaque: Bool = true
public var contentViewLayerBackgroundColor: CGColor? = CGColor.clear
@@ -104,6 +105,7 @@ public class LibUniWinC : NSObject {
self.backgroundColor = window.backgroundColor
self.isOpaque = window.isOpaque
self.hasShadow = window.hasShadow
self.isKeyWindow = window.isKeyWindow
if let view = window.contentView {
self.contentViewWantsLayer = view.wantsLayer
@@ -509,11 +511,12 @@ public class LibUniWinC : NSObject {
} else {
window.styleMask = orgWindowInfo.styleMask
if (!orgWindowInfo.styleMask.contains(.borderless)) {
// .borderless
// .borderless
window.styleMask.remove(.borderless)
}
window.titlebarAppearsTransparent = orgWindowInfo.titlebarAppearsTransparent
window.titleVisibility = orgWindowInfo.titleVisibility
}
}
@@ -556,7 +559,19 @@ public class LibUniWinC : NSObject {
}
}
_setWindowBorderless(window: window, isBorderless: isBorderless)
if (orgWindowInfo.isKeyWindow) {
if (isBorderless) {
//
window.makeKey()
_setWindowBorderless(window: window, isBorderless: isBorderless)
} else {
//
_setWindowBorderless(window: window, isBorderless: isBorderless)
window.makeKey()
}
} else {
_setWindowBorderless(window: window, isBorderless: isBorderless)
}
//
// window.makeMain()
@@ -919,7 +934,7 @@ public class LibUniWinC : NSObject {
if (targetWindow != nil && state.isTopmost) {
targetWindow?.level = NSWindow.Level.floating
}
//panel.parent = targetWindow // Nil if not attatched
panel.parent = targetWindow // Nil if not attatched
panel.allowsMultipleSelection = PanelFlag.AllowMultipleSelection.containedIn(value: ps.flags)
panel.showsHiddenFiles = PanelFlag.ShowHidden.containedIn(value: ps.flags)
panel.allowedFileTypes = fileTypes
@@ -953,8 +968,16 @@ public class LibUniWinC : NSObject {
}
}
}
if (targetWindow != nil && state.isTopmost) {
targetWindow?.level = NSWindow.Level.popUpMenu
if (targetWindow != nil) {
if (state.isTopmost) {
targetWindow?.level = NSWindow.Level.popUpMenu
}
if (state.isBorderless) {
_setWindowBorderless(window: targetWindow!, isBorderless: false)
//targetWindow?.makeKeyAndOrderFront(nil)
targetWindow?.makeKey()
_setWindowBorderless(window: targetWindow!, isBorderless: true)
}
}
return outputToStringBuffer(text: text, lpBuffer: lpBuffer, bufferSize: bufferSize)
@@ -973,11 +996,11 @@ public class LibUniWinC : NSObject {
let initialDir = getStringFromUtf16Array(textPointer: ps.initialDirectory)
let initialFile = getStringFromUtf16Array(textPointer: ps.initialFile) as NSString
let fileTypes = getFileTypesArray(text: getStringFromUtf16Array(textPointer: ps.filterText))
if (targetWindow != nil && state.isTopmost) {
targetWindow?.level = NSWindow.Level.floating
}
//panel.parent = targetWindow // Nil if not attatched
panel.parent = targetWindow // Nil if not attatched
panel.showsHiddenFiles = PanelFlag.ShowHidden.containedIn(value: ps.flags)
panel.message = getStringFromUtf16Array(textPointer: ps.titleText)
panel.title = getStringFromUtf16Array(textPointer: ps.titleText)
@@ -1003,8 +1026,14 @@ public class LibUniWinC : NSObject {
let url: String = panel.url!.path
text = "\"" + url.replacingOccurrences(of: "\"", with: "\"\"") + "\"\n"
}
if (targetWindow != nil && state.isTopmost) {
targetWindow?.level = NSWindow.Level.popUpMenu
if (targetWindow != nil) {
if (state.isTopmost) {
targetWindow?.level = NSWindow.Level.popUpMenu
}
if (state.isBorderless) {
setBorderless(isBorderless: false)
setBorderless(isBorderless: true)
}
}
return outputToStringBuffer(text: text, lpBuffer: lpBuffer, bufferSize: bufferSize)