Skip to content

Commit

Permalink
fix: Chrome PWA's
Browse files Browse the repository at this point in the history
findWindow (find windowRef (AX Window) by `SCWindow`) using `_AXUIElementGetWindow`
closes #75
  • Loading branch information
ShlomoCode committed Jul 10, 2024
1 parent 87332c1 commit 00ae43e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions DockDoor.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

/* Begin PBXBuildFile section */
0531F8D22C3CC04600327808 /* AppearanceView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0531F8D12C3CC04600327808 /* AppearanceView.swift */; };
0596C2C32C3E060D00DCABEF /* PrivateApis.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0596C2C22C3E060D00DCABEF /* PrivateApis.swift */; };
3A105FD62C1BED660015EC66 /* BlurView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A105FD52C1BED660015EC66 /* BlurView.swift */; };
3A105FD92C1C049E0015EC66 /* dockStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A105FD82C1C049E0015EC66 /* dockStyle.swift */; };
3A105FDD2C1C0EE20015EC66 /* DynStack.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A105FDC2C1C0EE20015EC66 /* DynStack.swift */; };
Expand Down Expand Up @@ -48,6 +49,7 @@
/* Begin PBXFileReference section */
0531F8D12C3CC04600327808 /* AppearanceView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppearanceView.swift; sourceTree = "<group>"; };
0531F8E22C3CC0E200327808 /* AppearanceView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = AppearanceView.swift; path = DockDoor/Views/Settings/AppearanceView.swift; sourceTree = "<group>"; };
0596C2C22C3E060D00DCABEF /* PrivateApis.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrivateApis.swift; sourceTree = "<group>"; };
3A105FD52C1BED660015EC66 /* BlurView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlurView.swift; sourceTree = "<group>"; };
3A105FD82C1C049E0015EC66 /* dockStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = dockStyle.swift; sourceTree = "<group>"; };
3A105FDC2C1C0EE20015EC66 /* DynStack.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DynStack.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -152,6 +154,7 @@
BB157B6C2C0E31CF00997315 /* Assets.xcassets */,
BB157B712C0E31CF00997315 /* DockDoor.entitlements */,
BB157B6E2C0E31CF00997315 /* Preview Content */,
0596C2C22C3E060D00DCABEF /* PrivateApis.swift */,
);
path = DockDoor;
sourceTree = "<group>";
Expand Down Expand Up @@ -326,6 +329,7 @@
BBA153F82C11604400119C02 /* HoverWindow.swift in Sources */,
BBA153FC2C12356100119C02 /* main.swift in Sources */,
BBF6C6242C1B4B4400BF1D40 /* KeybindHelper.swift in Sources */,
0596C2C32C3E060D00DCABEF /* PrivateApis.swift in Sources */,
3A105FDD2C1C0EE20015EC66 /* DynStack.swift in Sources */,
BB4ED9092C3CD97400BBDD16 /* Traffic Light Buttons.swift in Sources */,
C119BDF22C2AFA7600E06E18 /* WindowSwitcher.swift in Sources */,
Expand Down
13 changes: 13 additions & 0 deletions DockDoor/PrivateApis.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// PrivateApis.swift
// DockDoor
//
// Created by ShlomoCode on 10/07/2024.
//

import Cocoa

// returns the CGWindowID of the provided AXUIElement
// * macOS 10.10+
@_silgen_name("_AXUIElementGetWindow") @discardableResult
func _AXUIElementGetWindow(_ axUiElement: AXUIElement, _ wid: inout CGWindowID) -> AXError
6 changes: 6 additions & 0 deletions DockDoor/Utilities/WindowUtil.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@ final class WindowUtil {
/// Finds a window by its name in the provided AXUIElement windows.
static func findWindow(matchingWindow window: SCWindow, in axWindows: [AXUIElement]) -> AXUIElement? {
for axWindow in axWindows {
var cgWindowId: CGWindowID = 0
let windowIDStatus = _AXUIElementGetWindow(axWindow, &cgWindowId)
if windowIDStatus == .success && window.windowID == cgWindowId {
return axWindow
}

var axTitle: CFTypeRef?
AXUIElementCopyAttributeValue(axWindow, kAXTitleAttribute as CFString, &axTitle)
let axTitleString = (axTitle as? String) ?? ""
Expand Down

0 comments on commit 00ae43e

Please sign in to comment.