add feature override green button#1777
Conversation
|
Thanks! Click event monitors can trip up other apps, so it might make sense to keep only one instance running at a time, although this might be something that I will address post-merge. I do think the checkbox label and the description could use some improvement (although this is a minor thing). Maximize is the nomenclature used elsewhere in Rectangle (rather than fill screen). And I typically always see the button referred to as the green stoplight button. Any thoughts/improvements here are welcome. Also worth noting: I have a bit of rearranging of the settings that I'll be doing for an upcoming release, so this setting might get moved around when that time comes. I'll give this a little more testing, but at first look I don't see much getting in the way of merging. |
Added a new setting that overrides the macOS green button behavior. When enabled, clicking a window's green button maximizes it to fill the screen instead of entering native macOS full screen. Holding any modifier key or using the button's menu restores the default macOS behavior.
Core manager responsible for intercepting and handling green button clicks.
ActiveEventMonitorforleftMouseDownandleftMouseUpeventsmouseDown: detects clicks on the full-screen button (with no modifier keys held), captures the window element and button frame, and consumes the event to prevent native full screenmouseUp: if the cursor is still within the button bounds, dispatches a maximize or restore action based on the window's last recorded Rectangle actiongreenButtonOverrideandconfigImportednotifications to start or stop the monitor dynamicallyModified Files
Rectangle/AccessibilityElement.swiftisFullScreenButtoncomputed property that returnstruewhen the element's subrole is.fullScreenButtonRectangle/AppDelegate.swiftgreenButtonManager: GreenButtonManagerpropertyGreenButtonManager()during app startup alongside other managersRectangle/Defaults.swiftgreenButtonOverrideas a newBoolDefaultwith key"greenButtonOverride"greenButtonOverridein thearrayof all defaultsRectangle/PrefsWindow/SettingsViewController.swiftgreenButtonOverrideCheckboxoutlettoggleGreenButtonOverride(_:)action that saves the setting and posts thegreenButtonOverridenotificationinitializeGreenButtonOverrideCheckbox()that programmatically inserts the checkbox and a description label into the settings stack view afterdoubleClickTitleBarCheckboxinitializeToggles()to sync the checkbox state on loadRectangle/Utilities/NotificationExtension.swiftNotification.Name.greenButtonOverridefor broadcasting setting changes toGreenButtonManagerRectangle/mul.lproj/Main.xcstrings