Skip to content

Conversation

rgeraskin
Copy link
Contributor

Add Window Limit Hotkey Controls and Enhanced HUD System

🚀 Summary

This PR introduces keyboard hotkey controls for adjusting the window limit feature and enhances the existing HUD system to be more universal and responsive. Users can now dynamically increase/decrease the maximum window count per screen using keyboard shortcuts, with immediate visual feedback through an improved HUD display.

Closes #1799

🎯 What's Changed

1. Universal HUD System Refactor (cf34654)

  • Enhanced LayoutNameWindow with dynamic width sizing

    • Added displayNotification(title:description:) method for flexible HUD content
    • Implemented resizeToFitText() for automatic window sizing based on text length
    • Supports min/max width constraints (200px - 500px) with padding
  • Improved ScreenManager with universal HUD capabilities

    • Added displayCustomHUD(title:description:) for reusable HUD functionality
    • Refactored existing displayLayoutHUD() to use the new universal system
    • Better separation of concerns between HUD display logic and content

2. Window Count Hotkey Controls (ac5ae4a)

  • New Hotkey Commands

    • increase-window-max-count: Increment window limit by 1
    • decrease-window-max-count: Decrement window limit by 1 (minimum 0 for unlimited)
  • Enhanced User Configuration

    • Added increaseWindowMaxCount() and decreaseWindowMaxCount() methods
    • Implemented KVO-compliant updates for real-time UI synchronization
    • Added enablesWindowCountHUD() configuration option
  • Window Count HUD Display

    • Added displayWindowCountHUD() method in WindowManager
    • Shows current limit as "Window Max Count: X" or "Unlimited" when set to 0
    • Utilizes the new universal HUD system for consistent styling
  • UI Integration

    • Extended General Preferences view with new hotkey options
    • Updated default configuration and documentation

🎮 How to Use

  1. Configure Hotkeys: Go to Preferences → Shortcuts and set your preferred key combinations for:

    • "Increase window max count"
    • "Decrease window max count"
  2. Enable HUD Feedback: In General preferences, enable "Notify when changing maximum window count" to see visual feedback when adjusting limits

  3. Adjust Window Limits: Use your configured hotkeys to dynamically adjust the maximum window count

    • Current count is displayed in a centered HUD
    • Setting to 0 shows "Unlimited"
    • Changes take effect immediately with automatic screen reflow

🔧 Technical Details

  • Architecture: Builds upon the existing window limit foundation documented in docs/window-limit.md
  • HUD System: Centralized, reusable HUD component with dynamic sizing
  • Configuration: KVO-compliant for real-time preference updates

📝 Configuration

The feature adds these new configuration options:

  • enables-window-count-hud: Boolean to enable/disable HUD feedback
  • increase-window-max-count: Hotkey binding for incrementing limit
  • decrease-window-max-count: Hotkey binding for decrementing limit

✨ Benefits

  • Enhanced UX: Quick adjustment of window limits without opening preferences
  • Visual Feedback: Immediate confirmation of current window limit settings
  • Flexible HUD: Reusable HUD system for future notification needs
  • Accessibility: Keyboard-driven workflow for power users

This enhancement makes the existing window limit feature more accessible and user-friendly, providing a smooth workflow for users who frequently adjust their workspace constraints.

Copy link
Owner

@ianyh ianyh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea of modifying the config by command is an interesting one, but I'm not sold on the change in hud. I do think that making it more general is a good idea, but I don't want to make config values for each possible hud value. I think the general solution is to take a list of values to display changes in the hud. Maybe you can split this out in to two changes?

}
}

func decreaseWindowMaxCount() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how I feel about modifying the configuration state like this, so I will have to think about it more.

Comment on lines +712 to +714
UserDefaults.standard.willChangeValue(forKey: ConfigurationKey.windowMaxCount.rawValue)
storage.set(Float(newCount), forKey: .windowMaxCount)
UserDefaults.standard.didChangeValue(forKey: ConfigurationKey.windowMaxCount.rawValue)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assumes that the UserDefaults is the standard one, and it could be a private one. You could maybe just cast it and call the kvo methods directly.

if let userDefaults = storage as? UserDefaults {
   ...
} else {
   ...
}

It's probably also worth generalizing this a bit in a separate function if it is going to be a common pattern.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Hotkeys for Adjusting Maximum Window Count Setting
2 participants