After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 772437 - Keyboard navigation shortcuts sometimes do not work in Epiphany/Web
Keyboard navigation shortcuts sometimes do not work in Epiphany/Web
Status: RESOLVED FIXED
Product: epiphany
Classification: Core
Component: Interface
3.22.x (obsolete)
Other Linux
: Normal normal
: ---
Assigned To: Epiphany Maintainers
Epiphany Maintainers
: 775417 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2016-10-05 05:18 UTC by Robert Felmey
Modified: 2018-01-30 22:32 UTC
See Also:
GNOME target: ---
GNOME version: 3.19/3.20


Attachments
window: Fix key event state comparisons (1.80 KB, patch)
2016-11-23 00:39 UTC, Michael Catanzaro
committed Details | Review
window: Don't filter Ctrl+Shift+N unnecessarily (1.06 KB, patch)
2016-12-18 17:08 UTC, Michael Catanzaro
committed Details | Review
window: fix alt-left/right keyboard shortcuts (5.26 KB, patch)
2016-12-18 17:08 UTC, Michael Catanzaro
committed Details | Review

Description Robert Felmey 2016-10-05 05:18:13 UTC
Description:

Keyboard navigation shortcuts do not work in Xorg session. Specifically [alt+left arrow] does nothing and [alt+right arrow] does nothing when expected behaviour is for the browser to go backward for forward a page. Other keyboard shortcuts do work. These are the only ones I can find that fail, and obviously they are pretty important.

Using the same system, logging into Wayland causes this bug to disappear and all shortcuts work properly in Epiphany/Web.

Additional info:
epiphany 3.20.3-2
Gnome 3-Shell
Arch Linux


Steps to reproduce:
Log into Gnome-3 Shell using Xorg
Open Web/Epiphany
Open a few web pages and attempt to go forward/backward using the [alt + left arrow] and [alt + right arrow] keyboard shortcuts
Comment 1 Robert Felmey 2016-10-05 05:34:55 UTC
Update:  After a while the navigation key shortcuts stop working in Wayland as well.
Comment 2 Michael Catanzaro 2016-10-05 11:18:30 UTC
Hm, it works for me. Can you reproduce with some specific set of web sites, or does it seem random?
Comment 3 Robert Felmey 2016-10-05 16:07:44 UTC
On my system, this problem isn't dependent on any specific website and the problem is consistent throughout the entire session logging in via Gnome 3 using Xorg.  In other words, the alt left/right arrow shortcuts never work when logged in through Xorg regardless of the website.  However, using Wayland, the alt left/right arrow sometimes work initially and then stop, so at this point it appears to be random in Wayland sessions.

I am using a Lenovo T450S.
Comment 4 Michael Catanzaro 2016-10-05 21:33:11 UTC
OK, since I can't reproduce, I think we need to add some print statements to the code to have any clue what's going on here. Are you willing to build Epiphany from source so we can do that on your machine (since I can't reproduce)? It won't be quick or easy, but I don't see another way to debug this. You'll want to follow the instructions on https://wiki.gnome.org/Newcomers/BuildGnome replacing "gnome-weather" with "epiphany" in all cases.

First, build git master and see if the problem has disappeared. Since 3.22 all the code that handles keyboard shortcuts has been rewritten, so good chance the bug could have been fixed in that transition.

Now, if the bug still exists, please add a g_warning() statement at the top of window_cmd_navigation() in src/window-commands.c. When you're in the broken state, does the function get called at all when you press the keyboard shortcuts?

If not, let me know and I'll try to come up with a gdbus command that you can use to trigger the action manually, to see if that works.
Comment 5 Michael Catanzaro 2016-10-05 21:34:31 UTC
(In reply to Michael Catanzaro from comment #4)
> First, build git master and see if the problem has disappeared.

Which reminds me that jhbuild is probably set up to build gnome-3-22 at the moment. You'll need to add this line to ~/.config/jhbuildrc:

moduleset = 'gnome-apps-3.24'
Comment 6 Robert Felmey 2016-10-06 01:53:17 UTC
I am willing to attempt this but it might take me a day to get time.

Thanks.
Comment 7 Adrian Perez 2016-10-17 13:01:20 UTC
I can consistently reproduce this _in Wayland_, though the shortcuts
are working fine here under X11. JFTR, my versions here are:

  GNOME 3.22.1
  Epiphany 3.22.1
  WebKitGTK+ 2.14.1

Just in case it might have something to do: I have the CapsLock key
enabled as an additional Ctrl key (can be done from GNOME Tweak Tool:
Typing → Caps Lock Key Behaviour → Caps Lock is also Ctrl).
Comment 8 Adrian Perez 2016-10-17 19:25:15 UTC
(In reply to Adrian Perez from comment #7)
> I can consistently reproduce this _in Wayland_, [...]

One more data point: right now Alt-Left and Alt-Right are working. Let's
see for how long. This is the same Wayland session is before where the
shortcuts were not working, the difference is that the following happened
in the meanwhile:

 1. I unplugged the external keyboard (USB) and the Ethernet cable from
    the NIC (both connected through a stattion).
 2. The external display was disconnected (which was on the HDMI port,
    directly on the laptop).
 3. Suspended the laptop.
 4. Went home.
 5. Resumed the laptop.

This is a bit puzzling, but tomorrow I will be going to the office again,
and there I have the USB keyboard and external display, so I can check a
few more combinations of plug/unplug/suspend/resume and watch the system
logs to see if something catches my eye.
Comment 9 Adrian Perez 2016-11-11 20:19:31 UTC
Well, funny story: the issue showed randomly for a few days after my
previous comment, but I couldn't figure out the circumstances that cause
the issue to happen. Then at some point the issue vanished, maybe because
of the 3.22.1 or 3.22.2 updates, dunno. During all these days I have been 
alternating between using X11 and Wayland sessions, both with 1) a single
external monitor, 2) laptop screen only, 3) both the external monitor and
the laptop screen... to no avail.

I have no clue what to try next :-\
Comment 11 Michael Catanzaro 2016-11-22 22:22:20 UTC
OK I upgraded to F25 and now I can reproduce with Epiphany 3.22.1, WebKitGTK+ 2.14.1, GTK+ 3.22.2.
Comment 12 Michael Catanzaro 2016-11-23 00:15:05 UTC
I can also reproduce with git master versions of everything in F25. Strange.
Comment 13 Michael Catanzaro 2016-11-23 00:39:46 UTC
Created attachment 340568 [details] [review]
window: Fix key event state comparisons

GDK can set random bits in the state to indicate internal stuff. We have
to use GDK_MODIFIER_MASK to mask out its reserved values before trying
to look at the state.

This DOES NOT fix the bug -- the broken code was introduced just last week -- but it's an essential first step.
Comment 14 Michael Catanzaro 2016-11-23 02:36:51 UTC
OK, the problem is that the key event state is GDK_META_MASK | GDK_MOD1_MASK, which is not correct; it should be just GTK_MOD1_MASK. We need to figure out why GTK+ thinks the meta key (which doesn't exist unless you're using a Space Cadet keyboard :) is being pressed along with Alt. At any rate, this problem is way lower level than Epiphany. I'm reassigning to GTK+ even though I don't know that it's actually a GTK+ bug, it could certainly be a problem in some dependency.

I'm also going to push this patch because it's correct, though it doesn't fix this issue.
Comment 15 Michael Catanzaro 2016-11-23 02:39:49 UTC
Actually maaaybe it's intended to send the META for some inexplicable reason...? Then it would indeed be Epiphany's fault for expecting it to not be set. Another problem is that WebKit always handles the event when received, even though it doesn't do anything with it here; that's why we have to filter it in the first place. But again, none of that can explain why the issue is two months old while the key event filtering was introduced just last week.
Comment 16 Michael Catanzaro 2016-11-23 02:40:26 UTC
Comment on attachment 340568 [details] [review]
window: Fix key event state comparisons

Attachment 340568 [details] pushed as 7ba5e64 - window: Fix key event state comparisons
Comment 17 Christian Hergert 2016-11-23 02:42:28 UTC
Can you try using gtk_accelerator_get_default_mod_mask() instead of GDK_MODIFIER_MASK?
Comment 18 Michael Catanzaro 2016-11-23 02:46:50 UTC
I wish you had commented two minutes sooner. Why is that a thing. :(
Comment 19 Michael Catanzaro 2016-11-23 02:52:53 UTC
OK, if I add at the start of main:

gtk_accelerator_set_default_mod_mask (GDK_CONTROL_MASK | GDK_SHIFT_MASK | GDK_MOD1_MASK);

Then of course the shortcut works again. But surely it's wrong to do that.

Am I supposed to use gtk_accelerator_get_default_mod_mask instead of GDK_MODIFIER_MASK in should_web_view_receive_key_press_event? That makes no difference to this bug but of course I want to get the code right.
Comment 20 Christian Hergert 2016-11-23 02:55:49 UTC
Well essentially you are doing the work of a shortcut engine by manually checking keyvals. GtkBindingSet already does that type of stuff for you if you use it.

See gtkbindings.c

#define BINDING_MOD_MASK() (gtk_accelerator_get_default_mod_mask () | GDK_RELEASE_MASK)

and gtk_binding_set_activate().

Also note tracking the keyval as uppercase/lowercase (i haven't checked to see if that is done).

> I wish you had commented two minutes sooner. Why is that a thing. :(

No worries, the only reason is that this is fresh in my mind while working on Builder's new shortcut engine.
Comment 21 Michael Catanzaro 2016-11-23 03:04:50 UTC
I don't see how GtkBindingSet would help with deciding whether or not to propagate a key event to the web view.
Comment 22 Christian Hergert 2016-11-23 04:42:18 UTC
I mean that it might be possible to replace should_web_view_receive_key_press_event() with a binding set and call:

  if (gtk_binding_set_activate (cannot_override_binding_set, event->keyval, event->state, toplevel))
    return GDK_EVENT_STOP;
Comment 23 Michael Catanzaro 2016-11-30 16:37:10 UTC
*** Bug 775417 has been marked as a duplicate of this bug. ***
Comment 24 Loren Dias 2016-12-08 04:44:16 UTC
I also am experiencing this bug on Arch Linux, I am using Ephiphany 3.22.3-1 from the official [extra] repository.

At the moment the controls Alt+Left and Alt+Right appear to be completly non-functional and not in a working/broken state as others seem to be reporting.

If there is any information I could gather to help narrow it down let me know what logs to attach, also I can install the git version if it helps.
Comment 25 Michael Catanzaro 2016-12-08 12:21:53 UTC
(In reply to Loren Dias from comment #24)
> At the moment the controls Alt+Left and Alt+Right appear to be completly
> non-functional and not in a working/broken state as others seem to be
> reporting.

So there are two problems here:

 * The key event filtering I added in 3.22.3 is resulting in the Meta modifier being sent with Mod1 (Alt), hence your key press is being sent to the web view, which consumes it for some unknown reason (WebKit bug?). This perfectly explains why Alt+Left and Alt+Right are not working right now, that's no mystery. But I do not expect the meta modifier to be set. That seems crazy and a bug, so I'm not going to change the code to expect it unless someone can explain why it should be expected (maybe I'm wrong!). Hence this bug is assigned to GTK+ and not Epiphany in the meantime.

 * This issue was reported long before 3.22.3, so once that's fixed we go back to the original issue "it doesn't work sometimes" which is probably also a lower-level problem.
Comment 26 Christian Hergert 2016-12-08 21:32:59 UTC
I wouldn't be surprised if there are certain interstitial GdkEventKeys that should be delivered in both cases for state management (such as modifier only keys) essentially ignoring the "handled" case.
Comment 27 Michael Catanzaro 2016-12-13 18:38:50 UTC
Turns out this the GDK_META_MASK behavior is expected:

Company:  somebody explained that to me once
Company:  but I forgot
Company:  I just wanted to say that I believe there's a reason for it
Company:  it might be a stupid reason
Company:  or a backwards compatibility reason

So Epiphany's key event filter needs to change to respect that. I'll push fixes for that, but this bug remains open and assigned to GTK+ because the original complaint here predates the key event filter by about a month.
Comment 28 Michael Catanzaro 2016-12-18 17:08:54 UTC
Created attachment 342175 [details] [review]
window: Don't filter Ctrl+Shift+N unnecessarily

I thought we had both Ctrl+I and Ctrl+Shift+N shortcuts for New
Incognito Window, but we don't, we only have Ctrl+I.
Comment 29 Michael Catanzaro 2016-12-18 17:08:59 UTC
Created attachment 342176 [details] [review]
window: fix alt-left/right keyboard shortcuts

The call to gdk_keymap_translate_keyboard_state doesn't seem to really
do much here, except change the way we have to test for Ctrl+Shift+T by
consuming GDK_SHIFT_MASK. In particular, the keyval returned is already
the keyval in the key event, so that's not really doing anything for us.
But this is what the GDK documentation tells us to do, so why not. The
important change here, as shown in the GDK documentation, is to mask out
all the modifiers except Ctrl/Shift/Mod1 so that we ignore virtual
modifiers like Meta that we really don't want to see.

This mostly but not completely fixes the bug where the alt-left/right
shortcuts for back/forward stop working. It fixes the regression where
these shortcuts stopped working after I introduced key event filtering.
It *does not* fix the issue that was originally reported, which is that
the shortcuts mysteriously stop working sometimes; it cannot fix that
original bug, because the key event filtering was not added until a
month after that bug was reported. Hence, I am not closing the issue
here. Something seems to be wrong in either GTK+ or in mutter, as
sometimes GTK+ apps stop receiving any input at all; it might or might
not be related.
Comment 30 Michael Catanzaro 2016-12-18 17:09:22 UTC
Attachment 342175 [details] pushed as 500dbd4 - window: Don't filter Ctrl+Shift+N unnecessarily
Attachment 342176 [details] pushed as 02ff0be - window: fix alt-left/right keyboard shortcuts
Comment 31 Michael Catanzaro 2017-01-07 19:10:29 UTC
I found another bug for the GTK+ issue, bug #770112.

To reduce confusion, since we have two unrelated issues with the same symptom in this bug, let's use this bug for the Epiphany issue that was introduced a month after this bug was originally filed, since that's what the majority of the discussion above is about, and consider the original report a duplicate of bug #770112.