[gnome-mines] Change tile click behaviour to reveal square on click release.



commit 39fba63e8c42c4663f61da52c8e0a1338904f3db
Author: Isaac Lenton <isaac isuniversal com>
Date:   Sat Oct 31 16:51:42 2015 +1000

    Change tile click behaviour to reveal square on click release.
    
        Changes behaviour of button-release event to only reveal tile
        that was originaly clicked or cancel the operation.
    
        https://bugzilla.gnome.org/show_bug.cgi?id=741718

 src/minefield-view.vala |   18 ++++--------------
 src/tile.vala           |    9 ++++-----
 2 files changed, 8 insertions(+), 19 deletions(-)
---
diff --git a/src/minefield-view.vala b/src/minefield-view.vala
index 91c627e..ee9a123 100644
--- a/src/minefield-view.vala
+++ b/src/minefield-view.vala
@@ -194,7 +194,6 @@ public class MinefieldView : Gtk.Grid
                 {
                     mines[i,j] = new Tile (i, j);
                     mines[i,j].show ();
-                    mines[i,j].tile_mouse_over.connect ((x, y) => { tile_mouse_over_cb (x, y); });
                     mines[i,j].tile_pressed.connect ((x, y, event) => { tile_pressed_cb (x, y, event); });
                     mines[i,j].tile_released.connect ((x, y, event) => { tile_released_cb (x, y, event); });
                     add (mines[i,j], i, j);
@@ -218,19 +217,6 @@ public class MinefieldView : Gtk.Grid
         }
     }
 
-    public void tile_mouse_over_cb (int x, int y)
-    {
-        /* Check for end cases and paused game */
-        if (minefield.exploded || minefield.is_complete || minefield.paused)
-            return;
-
-        /* Check that the user isn't currently navigating with keyboard */
-        if (!selected.is_set || keyboard_cursor.is_set)
-            return;
-
-        selected.position = {x, y};
-    }
-
     public void tile_pressed_cb (int x, int y, Gdk.EventButton event)
     {
         /* Ignore double click events */
@@ -284,6 +270,10 @@ public class MinefieldView : Gtk.Grid
         if (!selected.is_set || keyboard_cursor.is_set)
             return;
 
+        /* Check if the square released is the sames as the square pressed. */
+        if (selected.x != x || selected.y != y)
+            return;
+
         /* Check if the user released button outside the minefield */
         if (!minefield.is_location (selected.x, selected.y))
             return;
diff --git a/src/tile.vala b/src/tile.vala
index 30391e8..34260ea 100644
--- a/src/tile.vala
+++ b/src/tile.vala
@@ -39,17 +39,16 @@ public class Tile : Gtk.Button
         can_focus = false;
         add_class ("tile");
         set_image (scaling_image);
-        enter_notify_event.connect ((event) =>
-        {
-            tile_mouse_over (prow, pcol);
-            return false;
-        });
         size_allocate.connect ((allocation) =>
         {
             scaling_image.set_pixel_size (allocation.height/3*2);
         });
         button_press_event.connect ((event) =>
         {
+            /* By default windows with both button press and button release
+             * grab Gdk events, ungrab events here for other tiles. */
+            event.device.ungrab (event.time);
+
             tile_pressed (prow, pcol, event);
             return false;
         });


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]