Commit 2f73feab authored by Gabriel Ivascu's avatar Gabriel Ivascu Committed by Iulian Radu

Handle key pressed event in gnome-nibbles.vala

The reason I am moving this from nibbles-view.vala to gnome-nibbles.vala
is to avoid a weird behavior of having your first key press ignored
everytime by the start of a new level, thus making your worm
unresponsive to your command.

As unlikey as it may seem that there is any difference of behavior
by connecting to the signal in gnome-nibbles.vala rather than
nibbles-view.vala, this actually provides a fix for the bug that states
a worm is uncontrollable briefly after spawn.

https://bugzilla.gnome.org/show_bug.cgi?id=758467
parent 6f579d5b
......@@ -156,6 +156,7 @@ public class Nibbles : Gtk.Application
window = builder.get_object ("nibbles-window") as Gtk.ApplicationWindow;
window.size_allocate.connect (size_allocate_cb);
window.window_state_event.connect (window_state_event_cb);
window.key_press_event.connect (key_press_event_cb);
window.set_default_size (settings.get_int ("window-width"), settings.get_int ("window-height"));
if (settings.get_boolean ("window-is-maximized"))
window.maximize ();
......@@ -258,6 +259,16 @@ public class Nibbles : Gtk.Application
* * Window events
\*/
/* The reason this event handler is found here (and not in nibbles-view.vala
* which would be a more suitable place) is to avoid a weird behavior of having
* your first key press ignored everytime by the start of a new level, thus
* making your worm unresponsive to your command.
*/
private bool key_press_event_cb (Gtk.Widget widget, Gdk.EventKey event)
{
return game.handle_keypress (event.keyval);
}
private void size_allocate_cb (Gtk.Allocation allocation)
{
if (is_maximized || is_tiled)
......
......@@ -894,15 +894,6 @@ public class NibblesView : GtkClutter.Embed
}
}
/*\
* * Input handling
\*/
public override bool key_press_event (Gdk.EventKey event)
{
return game.handle_keypress (event.keyval);
}
/*\
* * Sound
\*/
......
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