[swell-foop/arnaudb/event-controller-motion: 4/4] Use EventControllerMotion.



commit f6220c78625d394fc3710e17f9e7c2c3ab71056d
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Mon May 4 20:41:07 2020 +0200

    Use EventControllerMotion.

 src/game-view.vala |  4 +---
 src/window.vala    | 15 ++++++++++++++-
 2 files changed, 15 insertions(+), 4 deletions(-)
---
diff --git a/src/game-view.vala b/src/game-view.vala
index decabbd..f9aeeee 100644
--- a/src/game-view.vala
+++ b/src/game-view.vala
@@ -252,14 +252,12 @@ private class GameView : Clutter.Group
     }
 
     /* When the mouse leaves the application window, reset all tiles to the default brightness */
-    internal bool board_left_cb ()
+    internal void board_left_cb ()
     {
         game.reset_visit ();
 
         foreach (var tile in tiles)
             tile.opacity = 180;
-
-        return false;
     }
 
     private TileActor? find_tile_at_position (int position_x, int position_y)
diff --git a/src/window.vala b/src/window.vala
index 9a5c8e8..aabb6cf 100644
--- a/src/window.vala
+++ b/src/window.vala
@@ -102,7 +102,7 @@ private class SwellFoopWindow : ApplicationWindow
         clutter_embed.set_size_request ((int) stage.width, (int) stage.height);
 
         /* When the mouse leaves the window we need to update the view */
-        clutter_embed.leave_notify_event.connect (view.board_left_cb);
+        init_motion ();
     }
 
     private inline Stack build_first_run_stack ()
@@ -430,4 +430,17 @@ private class SwellFoopWindow : ApplicationWindow
                     scores_context.run_dialog ();
             });
     }
+
+    /*\
+    * * motion control
+    \*/
+
+    private EventControllerMotion motion_controller;    // for keeping in memory
+
+    private inline void init_motion ()
+    {
+        motion_controller = new EventControllerMotion (clutter_embed);
+        motion_controller.set_propagation_phase (PropagationPhase.CAPTURE);
+        motion_controller.leave.connect (view.board_left_cb);
+    }
 }


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