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

Use keycode for keybindings #1953

Merged
merged 3 commits into from
Oct 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 4 additions & 17 deletions guake/keybindings.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@
import gi

gi.require_version("Gtk", "3.0")
gi.require_version("Gdk", "3.0")
from gi.repository import Gtk
from gi.repository import Gdk

from guake import notifier
from guake.common import pixmapfile
Expand Down Expand Up @@ -230,18 +228,8 @@ def reload_global(self, settings, key, user_data):
def activate(self, window, event):
"""If keystroke matches a key binding, activate keybinding. Otherwise, allow
keystroke to pass through."""
key = event.keyval
key = event.hardware_keycode
mod = event.state
if mod & Gdk.ModifierType.SHIFT_MASK:
if key == Gdk.KEY_ISO_Left_Tab:
key = Gdk.KEY_Tab
else:
key = Gdk.keyval_to_lower(key)
else:
keys = Gdk.keyval_convert_case(key)
if key != keys[1]:
key = keys[0]
mod &= ~Gdk.ModifierType.SHIFT_MASK

mask = mod & self._masks

Expand All @@ -266,11 +254,10 @@ def load_accelerators(self):
"""Reads all gconf paths under /apps/guake/keybindings/local
and adds to the _lookup.
"""

for binding, action in self.keys:
key, mask = Gtk.accelerator_parse(
key, keycodes, mask = Gtk.accelerator_parse_with_keycode(
self.guake.settings.keybindingsLocal.get_string(binding)
)
if key > 0:
self._lookup[mask][key] = action
if keycodes and keycodes[0]:
self._lookup[mask][keycodes[0]] = action
self._masks |= mask
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
release_summary: >
Use keycodes instead of keyvals for keybindings. This allow to use keybindings with different keyboard layouts.

known_issues:
- keybindings does not work with not English layout. #1946