Commit 52a6b486 authored by Alexander Mikhaylenko's avatar Alexander Mikhaylenko

display-box: Don't pass event directly to on_key_press_event()

Instead, pass keyval and state.

Since DisplayView corrects keyval, this means that Nintendo DS shortcuts
are now layout-independent.

See a378f4b8
parent bea89bd2
Pipeline #104693 passed with stages
in 14 minutes and 15 seconds
...@@ -104,16 +104,14 @@ private class Games.DisplayBox : Gtk.Bin { ...@@ -104,16 +104,14 @@ private class Games.DisplayBox : Gtk.Bin {
display_bin.remove (child); display_bin.remove (child);
} }
public bool on_key_press_event (Gdk.EventKey event) { public bool on_key_press_event (uint keyval, uint status) {
if (!get_mapped ()) if (!get_mapped ())
return false; return false;
if (runner == null) if (runner == null)
return false; return false;
var default_modifiers = Gtk.accelerator_get_default_mod_mask (); return runner.key_press_event (keyval, status);
return runner.key_press_event (event.keyval, event.state & default_modifiers);
} }
public bool gamepad_button_press_event (Manette.Event event) { public bool gamepad_button_press_event (Manette.Event event) {
......
...@@ -94,15 +94,15 @@ private class Games.DisplayView : Object, UiView { ...@@ -94,15 +94,15 @@ private class Games.DisplayView : Object, UiView {
public bool on_key_pressed (Gdk.EventKey event) { public bool on_key_pressed (Gdk.EventKey event) {
var default_modifiers = Gtk.accelerator_get_default_mod_mask (); var default_modifiers = Gtk.accelerator_get_default_mod_mask ();
if (box.on_key_press_event (event))
return true;
uint keyval; uint keyval;
var keymap = Gdk.Keymap.get_for_display (window.get_display ()); var keymap = Gdk.Keymap.get_for_display (window.get_display ());
keymap.translate_keyboard_state (event.hardware_keycode, event.state, keymap.translate_keyboard_state (event.hardware_keycode, event.state,
event.group, out keyval, null, null, null); event.group, out keyval, null, null, null);
var ctrl_pressed = (event.state & default_modifiers) == Gdk.ModifierType.CONTROL_MASK; var ctrl_pressed = (event.state & default_modifiers) == Gdk.ModifierType.CONTROL_MASK;
if (box.on_key_press_event (keyval, event.state & default_modifiers))
return true;
if ((keyval == Gdk.Key.f || keyval == Gdk.Key.F) && ctrl_pressed && if ((keyval == Gdk.Key.f || keyval == Gdk.Key.F) && ctrl_pressed &&
header_bar.can_fullscreen && !savestates_list_state.is_revealed) { header_bar.can_fullscreen && !savestates_list_state.is_revealed) {
is_fullscreen = !is_fullscreen; is_fullscreen = !is_fullscreen;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment