Skip to content
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

feat: add window effects for hiding title bar and changing corner style #735

Merged
merged 2 commits into from
Sep 30, 2024

Conversation

JonasWischeropp
Copy link
Contributor

@JonasWischeropp JonasWischeropp commented Sep 21, 2024

This PR adds the command set-title-bar-visibility <true|false> to enable hiding title bars.
This closes #504.

For example all title bars can then be deactivated with:

window_rules:
  - commands: ['set-title-bar-visibility false']
    match:
      - window_class: { regex: '.*' }

Windows that have custom titlebars are uneffected.

@lars-berger
Copy link
Member

Ay this is great, thanks for the pr 🙌

Reckon it'd be best to instead add it as a window effect like we've got with window borders, e.g.

window_effects:
  focused_window:
    hide_title_bar:
      enabled: true

  other_windows:
    hide_title_bar:
      enabled: true

If you're down to make the change, modify the apply_window_effects fn in platform_sync

@JonasWischeropp
Copy link
Contributor Author

I will look into it.

@JonasWischeropp
Copy link
Contributor Author

The current version is now functional and is using window_effects.
Furthermore I have added the ability to change the corner style of windows.

focused_window:
  hide_title_bar:
    enabled: true
  corner:
    enabled: true
    # Allowed values: 'windows_default', 'square', 'round', 'small_round'
    style: 'square'

But I have noticed that removing the title bar of some windows can cause problems, e.g:

  • notepad: visuals of the title bar are wrong
  • windows file explorer: tabs in the title bar no longer fully work

Therefore it would be nice to have the ability to match like with window_rules (like discussed in #653).

But I think it could be beneficial to use window_rules instead of window_effects.
This would require the introduction of WindowRuleEvent::Unfocus.
For example instead of using:

window_effects:
  focused_window:
    border:
      enabled: true
      color: '#8dbcff'
    hide_title_bar:
      enabled: false

  other_windows:
    border:
      enabled: true
      color: '#a1a1a1'
    hide_title_bar:
      enabled: true

One could use:

window_rules:
  - commands: ['set-title-bar-visibility true', 'set-border-color #8dbcf']
  # (set-border-color would need to be implemented)
    on: 'focus'
    run_once: false
    match:
      - window_class: { equals: 'example' }

  - commands: ['set-title-bar-visibility false', 'set-border-color #a1a1a1']
    on: 'unfocus'
    run_once: false
    match:
      - window_class: { equals: 'example' }

(Could be made cleaner by making match optional and matching everything when it is not provided.)

I think this system would be more extendable.
It would be easier to introduce new rules what effects should be applied when.
Because it allows to change effects not only when the focus changes but also on other WindowRuleEvents.
Currently there are only three but others could be exposed in the future.
For example with a WindowRuleEvent like BecameFloating one could have round corners in floating mode and square corners in tiling mode.
This would probably also require new MatchTypes but what I am trying to say is that I think that using window_rules would be more flexible in the future.

What do you think?

@JonasWischeropp
Copy link
Contributor Author

Matching in window_effects can also only enable/disable the effect but not apply it differently to windows. For example different border colors for different windows.

@lars-berger lars-berger changed the title feat: add command to hide the title bar of windows feat: add window effects for hiding title bar and changing corner style Sep 30, 2024
@lars-berger
Copy link
Member

Will merge as is but will likely do some naming tweaks before release. There's a bug with the border color not being set reliably, so gonna do some changes to how window effects work after the merge

But I think it could be beneficial to use window_rules instead of window_effects.
This would require the introduction of WindowRuleEvent::Unfocus.

True that's a good point. If we added an unfocus events, window effects could essentially be entirely implemented via window rules. The big upside with having a separate window effects config imo though is that it's a lot simpler to configure, and someone wouldn't have to figure how commands and window rule triggers work. Ideally it should be as simple as possible - e.g. just flip a boolean for whether to remove title bars. Still think that a window effects config has its place but would absolutely be down to add an unfocus window rule event 👍

@lars-berger lars-berger merged commit 4e5c662 into glzr-io:main Sep 30, 2024
2 checks passed
@DreamMaoMao
Copy link
Contributor

DreamMaoMao commented Oct 1, 2024

There was a bug where the win11 window animation would disappear after disable the titlebar .

refer to :

ptazithos/glazewm-extra#11

@lars-berger
Copy link
Member

There was a bug where the win11 window animation would disappear after disable the titlebar .

refer to :

ptazithos/glazewm-extra#11

Not sure whether we'd be able to change that behavior unfortunately. The animations are built into the OS and we don't do anything on our side to trigger the animation

Copy link

github-actions bot commented Oct 1, 2024

🎉 This PR is included in version 3.3.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

[Feature Request] Remove title bars from windows
3 participants