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

[GTK4] Disallow tab bar focussing #4885

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

danudey
Copy link
Contributor

@danudey danudey commented Jan 9, 2025

~Adds configuration to allow/~Disallow the Adwaita tab bar from gaining focus with an additional click. This is the default behaviour of the tab bar, and it allows users to use the arrow keys to navigate the tabs and then the tab key to move to the window surface.

Personally, I hate when this happens and don't ever want my tabs focussed by accident, so I thought it might make sense to add a configuration option functionality to prevent this from happening.

Works great with adwaita 1.5 (Ubuntu 24.04) and adwaita 1.1 (Ubuntu 22.04). Tab bars in 22.04 are showing up above the window title bar, but I'm not sure if that's related to this change that seems to be unrelated to this change that is resolved separately in #5410.

@tristan957
Copy link
Collaborator

I can't say that I agree with the premise. Why can't you just use keybinds with next_tab/previous_tab actions to fit your workflow?

@tristan957
Copy link
Collaborator

Tab bars in 22.04 are showing up above the window title bar, but I'm not sure if that's related to this change that seems to be unrelated to this change.

Known problem if you're interested in fixing it in a separate PR. Would be good to have a fix before the next release. I tried reproducing the issue but never could.

@jcollie
Copy link
Collaborator

jcollie commented Jan 21, 2025

Tab bars in 22.04 are showing up above the window title bar, but I'm not sure if that's related to this change that seems to be unrelated to this change.

Known problem if you're interested in fixing it in a separate PR. Would be good to have a fix before the next release. I tried reproducing the issue but never could.

I think that I solved that along with my menu reorganization PR (#4952), but that'll have to wait until Mitchell finishes his GTK App/Window refactor because I need to touch some of the same code.

@mitchellh
Copy link
Contributor

I don't love the configuration on this.

I think my question instead would be: is it desirable for the tab bar to EVER have keyboard focus? Is that a common thing? Tab navigation is already heavily bindable in Ghostty and I do agree with the premise that the tab bar getting focus from an extra click is not ideal.

@tristan957
Copy link
Collaborator

tristan957 commented Jan 24, 2025

I don't love the configuration on this.

I think my question instead would be: is it desirable for the tab bar to EVER have keyboard focus? Is that a common thing? Tab navigation is already heavily bindable in Ghostty and I do agree with the premise that the tab bar getting focus from an extra click is not ideal.

You know I checked what GNOME Text Editor does, and they seem to make the tab bar not focusable if you click on a tab. Though you can still tab through the widget tree to focus it if you try hard enough. I would say matching that behavior makes sense. Instead of call gtk_widget_can_focus() or whatever. The tab page contents should instead grab the focus.

The feature request makes sense to me, and we should definitely get it in for 1.1!

@mitchellh
Copy link
Contributor

The feature request makes sense to me, and we should definitely get it in for 1.1!

Fantastic. Thanks for doing the research. I agree. I think at least for 1.1, making the tab bar not focusable at all (as this PR does -- but without the config) seems fine. I think its far far far less desirable for that to ever gain focus than the incidental case you actually want it to via the keyboard or something.

@danudey
Copy link
Contributor Author

danudey commented Jan 28, 2025

Sorry for the delay, but I've taken out the configuration option and made it so that the "don't focus" functionality is the only behavior. PTAL and let me know if there's anything else you think could be improved.

@danudey
Copy link
Contributor Author

danudey commented Jan 28, 2025

Tab bars in 22.04 are showing up above the window title bar, but I'm not sure if that's related to this change that seems to be unrelated to this change.

Known problem if you're interested in fixing it in a separate PR. Would be good to have a fix before the next release. I tried reproducing the issue but never could.

@tristan957 Fixed in #5410

@danudey danudey changed the title [GTK4] Add config to disallow tab bar focussing [GTK4] Disallow tab bar focussing Jan 28, 2025
@danudey
Copy link
Contributor Author

danudey commented Jan 30, 2025

@mitchellh I think this PR is ready for review, and pairs well with the recently merged PR to fix the Adwaita <1.4 tab bar issue as well. Hoping we can get this in for 1.1, whenever that is planned for.

@tristan957
Copy link
Collaborator

tristan957 commented Jan 30, 2025

How come when I click tabs on my system the tab bar is not focused? Libadwaita version is 1.6.2. Is it possible that this was a bug in a previous version of libadw?

@danudey
Copy link
Contributor Author

danudey commented Jan 31, 2025

How come when I click tabs on my system the tab bar is not focused? Libadwaita version is 1.6.2. Is it possible that this was a bug in a previous version of libadw?

Do you mean without this patch? I'm not certain, it's possible that the default behavior was changed. I'll see if I can reproduce. Either way, I think this PR makes sense for people on 22.04 and below.

@tristan957
Copy link
Collaborator

tristan957 commented Jan 31, 2025

How come when I click tabs on my system the tab bar is not focused? Libadwaita version is 1.6.2. Is it possible that this was a bug in a previous version of libadw?

Do you mean without this patch? I'm not certain, it's possible that the default behavior was changed. I'll see if I can reproduce. Either way, I think this PR makes sense for people on 22.04 and below.

I have not tested this PR. Ghostty is just doing what you want automatically for me. Please do report back with your findings though.

@mitchellh
Copy link
Contributor

I'd like to see a decision on this PR so we don't have it lingering.

I can't get my tab bar to focus on my machine, but maybe I'm doing something wrong.

I also see very little down side to the one-line patch of explicitly making the tab bar non-focusable with GTK, so all things equal, I wouldn't mind just merging that even if it does nothing if @danudey claims it works for them.

cc @ghostty-org/gtk

@tristan957
Copy link
Collaborator

I also see very little down side to the one-line patch of explicitly making the tab bar non-focusable with GTK

It breaks the tab focus hierarchy if you do that.

@mitchellh
Copy link
Contributor

It breaks the tab focus hierarchy if you do that.

@mitchellh
Copy link
Contributor

It breaks the tab focus hierarchy if you do that.

Then let's just close this? I haven't ever seen any other discussion complaining about this issue so while I'm appreciative of the PR, I'd be willing to just wait until there's something more apparent here.

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.

None yet

4 participants