-
-
Notifications
You must be signed in to change notification settings - Fork 354
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reorganize how window validity exceptions are checked and add ColorSlurp exception #1871
Conversation
windowChecks.contains(where: { element in | ||
element.check(opts) | ||
})) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should have a similar short-circuiting effect compared to the old ORing method. If the checking order matters, it can be changed by rearranging the items in the windowChecks
array.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you lost some of the nuances of the checks in the process of uniform-ing the checks. Apps like Books and Keynote are at a different level of the boolean chain than the apps later on. Same thing for Jetbrains.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, you're right. I added in an isValidLevel()
function to WindowCheck
in the latest push.
let windowChecks: [WindowCheck] = [ | ||
JetBrainsWindowCheck(), | ||
IINAWindowCheck(), | ||
KeyNoteWindowCheck(), | ||
OpenBoardWindowCheck(), | ||
AdobeAuditionWindowCheck(), | ||
BooksWindowCheck(), | ||
WorldOfWarcraftWindowCheck(), | ||
BattleNetBootstrapperWindowCheck(), | ||
DrBetotteWindowCheck(), | ||
DVDFabWindowCheck(), | ||
SanGuoShaAirWDWindowCheck(), | ||
SteamWindowCheck(), | ||
FirefoxFullscreenVideoWindowCheck(), | ||
VLCFullscreenVideoWindowCheck(), | ||
AndroidEmulatorWindowCheck(), | ||
ColorSlurpWindowCheck() | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not too familiar with Swift so there may be a better way collect all the subclasses.
func isValidSize(_ size: CGSize?) -> Bool { | ||
return size != nil && size!.width > AXUIElement.minWindowSize && size!.height > AXUIElement.minWindowSize | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be useful for #1466
I also have the Ventura workaround commit here, but it should be possible to cherry-pick the other two commits. |
873537b
to
d5c7542
Compare
@zacharee thank you for sharing this work. I would like to see what you see in this refactor, but I'm afraid I don't. The business logic is moved from simple functions into something more complex involving a class hierarchy with subclass overriding methods, instantiating classes, etc. I think if you find the current |
The issue I was having with the original setup was parsing all of the nested groups of disjunctions and conjunctions and where a new exception should be added (for example, the JetBrains check was inverted vs. the rest). There is more code, but imo now it's clearer how and when each step is checked, and adding a new exception just requires a new class and instantiating that class in the list, without needing to step through the parentheses to make sure it's placed correctly. My inspiration was the Strategy pattern, which does have the drawback of needing more generic arguments, but the advantage of encapsulating similar functions into a predictable structure, i.e., prioritizing knowing where and when each one is used vs. knowing what each one does specifically. Definitely up for more discussion on this. |
796a3c3
to
a67d123
Compare
Closing this PR as the ColorSlurp got merged from the other PR 👍 |
This PR has 2 changes: