Commit bea89bd2 authored by Alexander Mikhaylenko's avatar Alexander Mikhaylenko

runner: Don't pass event directly to key_press_event()

Instead, pass keyval and modifier state.
parent 3f64e8b6
......@@ -76,14 +76,10 @@ private class Games.NintendoDsRunner : RetroRunner {
return new NintendoDsLayoutSwitcher (this);
}
public override bool key_press_event (Gdk.EventKey event) {
// First check for Alt + 1|2|3|4
// These shortcuts change the screen layout
var default_modifiers = Gtk.accelerator_get_default_mod_mask ();
if ((event.state & default_modifiers) == Gdk.ModifierType.MOD1_MASK) {
// Alt key is pressed
var shortcut_layout = layouts[event.keyval];
public override bool key_press_event (uint keyval, uint state) {
if (state == Gdk.ModifierType.MOD1_MASK) {
// Alt + 1|2|3|4
var shortcut_layout = layouts[keyval];
if (shortcut_layout != null) {
screen_layout = shortcut_layout;
......@@ -95,7 +91,7 @@ private class Games.NintendoDsRunner : RetroRunner {
return false;
var switch_keyval = view_bottom_screen ? Gdk.Key.Page_Up : Gdk.Key.Page_Down;
if (event.keyval == switch_keyval)
if (keyval == switch_keyval)
return swap_screens ();
return false;
......
......@@ -110,7 +110,7 @@ public class Games.CommandRunner : Object, Runner {
return { };
}
public bool key_press_event (Gdk.EventKey event) {
public bool key_press_event (uint keyval, uint state) {
return false;
}
......
......@@ -27,6 +27,6 @@ public interface Games.Runner : Object {
public abstract Savestate[] get_savestates ();
public abstract InputMode[] get_available_input_modes ();
public abstract bool key_press_event (Gdk.EventKey event);
public abstract bool key_press_event (uint keyval, uint state);
public abstract bool gamepad_button_press_event (uint16 button);
}
......@@ -76,7 +76,7 @@ private class Games.DummyRunner : Object, Runner {
return { };
}
public bool key_press_event (Gdk.EventKey event) {
public bool key_press_event (uint keyval, uint state) {
return false;
}
......
......@@ -386,7 +386,7 @@ public class Games.RetroRunner : Object, Runner {
return { InputMode.GAMEPAD };
}
public virtual bool key_press_event (Gdk.EventKey event) {
public virtual bool key_press_event (uint keyval, uint state) {
return false;
}
......
......@@ -111,7 +111,9 @@ private class Games.DisplayBox : Gtk.Bin {
if (runner == null)
return false;
return runner.key_press_event (event);
var default_modifiers = Gtk.accelerator_get_default_mod_mask ();
return runner.key_press_event (event.keyval, event.state & default_modifiers);
}
public bool gamepad_button_press_event (Manette.Event event) {
......
// This file is part of GNOME Games. License: GPL-3.0+.
public class Games.FlashBox : Gtk.Widget {
static construct {
set_css_name ("gamesflashbox");
}
public override bool draw (Cairo.Context cr) {
var width = get_allocated_width ();
var height = get_allocated_height ();
context.style.render_background (cr, 0.0, 0.0, width, height);
}
}
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