-
Notifications
You must be signed in to change notification settings - Fork 16
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
New keyboard interactivity options #105
Conversation
New setting allows "normal" keyboard focus semantics for windows on any layer. Proposed for new version of the protocol.
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.
A few nits, but the idea looks good. I only reviewed the library, not the examples. Of course merging is blocked on the upstream PR getting merged, so no rush to fix these things.
include/gtk-layer-shell.h
Outdated
*/ | ||
void gtk_layer_set_keyboard_interactivity (GtkWindow *window, gboolean interacitvity); | ||
void gtk_layer_set_keyboard_interactivity (GtkWindow *window, GtkLayerShellKeyboardInteractivity interactivity); |
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 and the below function break backwards compatibility. We'll want to deprecate the old functions but keep them around.
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.
Since true == 1 and false == 0, this breaks ABI but doesn't break API. Depending on the project policy, this may or may not be okay.
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 am trying to keep the ABI stable (various versions are shipped with various distros, and apps should ideally work with all of them). It might even be ABI-compatible (enum types seem to be implementation defined), but no reason to play with fire here. Renaming the new function gtk_layer_set_keyboard_interactivity_type
(or something) and keeping the old one marked as deprecated is not a great burden.
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.
Makes sense.
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.
Sure, I've added new functions that are called by these.
src/api.c
Outdated
g_warning ("Invalid value for keyboard interactivity setting!\n"); | ||
return; | ||
} | ||
if (version <= 3 && interactivity == GTK_LAYER_SHELL_KEYBOARD_ON_DEMAND) |
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.
Might be a little cleaner to make this check in layer-surface.c. I think getting the version from the zwlr_layer_surface_v1
(which you'll have access to in that file) instead of from the layer shell global would be slightly preferable.
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.
zwlr_layer_surface_v1_get_version
can be used for this purpose. EDIT: ah, you're already using a similar function, cool. Some people aren't aware that these exist.
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.
Moved the check there. The problem is that self->layer_surface
can be NULL when this is called, so in that case, we still have to use the global object as fallback (I think it is cleaner to have the warning here and not have to make this check when committing the surface later).
examples/demo/gtk-layer-demo.c
Outdated
default_keyboard_interactivity = GTK_LAYER_SHELL_KEYBOARD_NONE; | ||
} else if (value[0] == '1' && value[1] == 0) { | ||
default_keyboard_interactivity = GTK_LAYER_SHELL_KEYBOARD_EXCLUSIVE; | ||
} else if (value[0] == '2' && value[1] == 0) { |
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.
0/1 could be handled to retain old behavior, but I wonder if it makes sense to handle 2. Using enum names is clearer.
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.
Handling numbers seems unnecisarry. Just handling names should be fine. (I still haven't reviewed the changes to the examples fully)
aa1b9b9
to
9ebafd2
Compare
@wmww Ack on merging the wlr-protocols PR? |
Now that the upstream PR has merged I'll give this a full review when I have time. These don't block my initial review, but they will need to be done before merging:
P.S. let me know if anything about writing tests could be documented better. |
Done already :)
I'm not sure what you mean; the new files are part of the demo, just separated for clarity (I can merge them with one of the other ones).
I did a first try at this by adding the following two files: To make this work, I had to update the mock server to advertise version 4 of the protocol. I'm wondering if there should be an extra test that gtk-layer-shell behaves as expected on a lower server version and if that's easily achievable with the current setup. |
Also, I'm marking this ready for review since the protocol and wlroots PRs have merged and the main functionality is implemented. |
gtk_layer_set_keyboard_interactivity_type(window, GTK_LAYER_SHELL_KEYBOARD_ON_DEMAND); | ||
ASSERT_EQ(gtk_layer_get_keyboard_interactivity_type(window), version >= 4 ? GTK_LAYER_SHELL_KEYBOARD_ON_DEMAND : GTK_LAYER_SHELL_KEYBOARD_NONE, "%d"); | ||
gtk_widget_show_all(GTK_WIDGET(window)); | ||
ASSERT_EQ(gtk_layer_get_keyboard_interactivity_type(window), version >= 4 ? GTK_LAYER_SHELL_KEYBOARD_ON_DEMAND : GTK_LAYER_SHELL_KEYBOARD_NONE, "%d"); |
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.
Since this will always be run against the mock server, no need for the version checks. We can assume it's on the expected version.
EDIT: I did that
To answer your question, yes, ideally we'd have additional tests for different protocols versions but we're not set up to easily implement that right now, so don't bother. I'll add those tests if/when I set up a way to make the mock server use different versions of protocols.
Either the thing I was talking about was removed or I was just confused. Either way it's fine now. |
…ely being used incorrectly
All right as you can see I've added a bunch of changes, including notably changing the names from "keyboard_interactivity_type" to "keyboard_mode". That diverges from the protocol terminology, but I think it's a little clearer, much shorter and less likely to be confused with the deprecated functions. Much appreciated if you want to give the PR a review in it's current state. It seems ready to merge to me. |
Rename keyboard interactivity enum
All seems good, I've only added a minor edit in one place where the documentation was inconsistent. Otherwise, I've just tested a bit and seems to work well. |
Awesome! Thanks! |
Support more settings for keyboard interactivity, according to the changes suggested to the protocol here: swaywm/wlr-protocols#100
By opening this pull request, I agree for my modifications to be licensed under whatever licenses are indicated at the start of the files I modified