[gnome-games] runner: Don't pass event directly to key_press_event()
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] runner: Don't pass event directly to key_press_event()
- Date: Wed, 14 Aug 2019 19:51:24 +0000 (UTC)
commit bea89bd2c1f364579550780f529a8882f70aa977
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date: Thu Aug 15 00:00:25 2019 +0500
runner: Don't pass event directly to key_press_event()
Instead, pass keyval and modifier state.
plugins/nintendo-ds/src/nintendo-ds-runner.vala | 14 +++++---------
src/command/command-runner.vala | 2 +-
src/core/runner.vala | 2 +-
src/dummy/dummy-runner.vala | 2 +-
src/retro/retro-runner.vala | 2 +-
src/ui/display-box.vala | 4 +++-
src/ui/flash-box.vala | 14 ++++++++++++++
7 files changed, 26 insertions(+), 14 deletions(-)
---
diff --git a/plugins/nintendo-ds/src/nintendo-ds-runner.vala b/plugins/nintendo-ds/src/nintendo-ds-runner.vala
index 8311f4a2..88e61ada 100644
--- a/plugins/nintendo-ds/src/nintendo-ds-runner.vala
+++ b/plugins/nintendo-ds/src/nintendo-ds-runner.vala
@@ -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;
diff --git a/src/command/command-runner.vala b/src/command/command-runner.vala
index 725edfb3..f0f0ad16 100644
--- a/src/command/command-runner.vala
+++ b/src/command/command-runner.vala
@@ -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;
}
diff --git a/src/core/runner.vala b/src/core/runner.vala
index 34932a48..ce0eab23 100644
--- a/src/core/runner.vala
+++ b/src/core/runner.vala
@@ -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);
}
diff --git a/src/dummy/dummy-runner.vala b/src/dummy/dummy-runner.vala
index 31fcf721..6ae99161 100644
--- a/src/dummy/dummy-runner.vala
+++ b/src/dummy/dummy-runner.vala
@@ -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;
}
diff --git a/src/retro/retro-runner.vala b/src/retro/retro-runner.vala
index 8c997700..bedb2b7b 100644
--- a/src/retro/retro-runner.vala
+++ b/src/retro/retro-runner.vala
@@ -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;
}
diff --git a/src/ui/display-box.vala b/src/ui/display-box.vala
index 7451ad83..c2d786aa 100644
--- a/src/ui/display-box.vala
+++ b/src/ui/display-box.vala
@@ -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) {
diff --git a/src/ui/flash-box.vala b/src/ui/flash-box.vala
new file mode 100644
index 00000000..09f46409
--- /dev/null
+++ b/src/ui/flash-box.vala
@@ -0,0 +1,14 @@
+// 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);
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]