Closed Bug 1269058 Opened 8 years ago Closed 8 years ago

GTK3 key bindings are ignored

Categories

(Core :: Widget: Gtk, defect)

46 Branch
Unspecified
Linux
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: vincent-moz, Unassigned)

References

Details

I have a ~/.config/gtk-3.0/gtk.css file (which is read, since when there is an error in it, it is signaled) with:

@binding-set text-entry
{
  bind "<Control>a"
  {
    "move-cursor" (paragraph-ends, -1, 0)
  };
  bind "<Control>e"
  {
    "move-cursor" (paragraph-ends, 1, 0)
  };
  bind "<Control>k"
  {
    "delete-from-cursor" (paragraph-ends, 1)
  };
  bind "<Control>u"
  {
    "move-cursor" (paragraph-ends, -1, 0)
    "delete-from-cursor" (paragraph-ends, 1)
  };
  bind "<Control>w"
  {
    "delete-from-cursor" (word-ends, -1)
  };
}

GtkEntry
{
    -gtk-key-bindings: text-entry;
}

However these key bindings are ignored: Ctrl-a selects everything and Ctrl-e has no effect. I had no such problem with Firefox before 46.
(firefox:22969): Gtk-WARNING **: Theme parsing error: gtk.css:32:21: '-gtk-key-bindings' is not a valid property name

I guess you mean gtk-key-bindings, which works for me.

You'll need to set this for GtkTextView also, if you want similar bindings for multiline inputs.

(In reply to Vincent Lefevre from comment #0)
> I had no such problem with Firefox before 46.

Do you mean that you had Firefox 45 compiled against GTK3 that respected these key bindings?

Or do you mean that Firefox 45 respected gtk2 key bindings?
(In reply to Karl Tomlinson (ni?:karlt) from comment #1)
> (firefox:22969): Gtk-WARNING **: Theme parsing error: gtk.css:32:21:
> '-gtk-key-bindings' is not a valid property name
> 
> I guess you mean gtk-key-bindings, which works for me.

No, the correct property name is -gtk-key-bindings. See the GTK3 documentation: https://developer.gnome.org/gtk3/stable/gtk3-Bindings.html

And if I change -gtk-key-bindings to gtk-key-bindings, I get a warning:

(firefox:27073): Gtk-WARNING **: Theme parsing error: gtk.css:41:20: The 'gtk-key-bindings' property has been renamed to '-gtk-key-bindings'

which makes clear that -gtk-key-bindings is the correct property name (and this doesn't work either).

> You'll need to set this for GtkTextView also, if you want similar bindings
> for multiline inputs.

This doesn't work either for GtkTextView in a multiline textarea.

> (In reply to Vincent Lefevre from comment #0)
> > I had no such problem with Firefox before 46.
> 
> Do you mean that you had Firefox 45 compiled against GTK3 that respected
> these key bindings?

No, I didn't try that.

> Or do you mean that Firefox 45 respected gtk2 key bindings?

Yes, I meant that my .gtkrc-2.0 settings (which I was using since 2004) were taken into account.
(In reply to Vincent Lefevre from comment #2)
> (In reply to Karl Tomlinson (ni?:karlt) from comment #1)
> > (firefox:22969): Gtk-WARNING **: Theme parsing error: gtk.css:32:21:
> > '-gtk-key-bindings' is not a valid property name
> > 
> > I guess you mean gtk-key-bindings, which works for me.
> 
> No, the correct property name is -gtk-key-bindings. See the GTK3
> documentation: https://developer.gnome.org/gtk3/stable/gtk3-Bindings.html

Ah, thanks.  Argh, yet another backward incompatible change.

https://developer.gnome.org/gtk3/3.18/gtk3-Bindings.html has
gtk-key-bindings

I guess you are reproducing with 3.20?
Which micro version?
3.16.7 was working for me.

Do you have other GTK3 apps with which to test the bindings?

Does gtk-key-theme-name=Emacs have an effect, on Firefox and/or other apps?
(In reply to Karl Tomlinson (ni?:karlt) from comment #3)
> Do you have other GTK3 apps with which to test the bindings?

gtk3-widget-factory is a good one.  Perhaps there is a gtk-3-examples package
to install that.
I have GTK 3.20.3. The config file is parsed by both gedit and gtk3-widget-factory, but neither take the bindings into account. So, it seems to be a GTK3 bug.
I've just reported a bug here: https://bugzilla.gnome.org/show_bug.cgi?id=766166
According to the reply to this upstream bug, the selectors have actually changed for Gtk+ 3.20, though https://developer.gnome.org/gtk3/3.20/gtk3-Bindings.html still gives the old, non-working selectors. After changing "GtkEntry" to "entry" and "GtkTextView" to "textview", the key bindings work as expected. So, this was a Gtk+ documentation bug, not related to Firefox.
Status: UNCONFIRMED → RESOLVED
Closed: 8 years ago
Resolution: --- → INVALID
I found that gtk.css bindings applied to entry/textview components still work in the URL bar and the search engine bar.
*but*, in nightly (FF 57) it does not apply anymore to HTML components like <input type="text/search/password"> neither it does for textareas:

# emacs still delete-prev-word rather than "close tab"
@binding-set text-entry { bind "<Control>w" { "delete-from-cursor" (word-ends, -1) }; }
entry    { -gtk-key-bindings: text-entry; }
textview { -gtk-key-bindings: text-entry; }
You need to log in before you can comment on or make changes to this bug.