[sushi/wip/cosimoc/no-clutter: 61/66] mainWindow: use event box to trap button presses



commit 769037d24b46c4cc6add222769fa7bb866aed9d7
Author: Cosimo Cecchi <cosimo endlessm com>
Date:   Fri Jun 7 22:18:37 2019 -0700

    mainWindow: use event box to trap button presses
    
    Instead of using an event handler on the window itself.
    This is necessary since the window also will catch events around
    the corners used for the resize cursors, which we don't want to
    trigger a window move.

 src/ui/mainWindow.js | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/src/ui/mainWindow.js b/src/ui/mainWindow.js
index 8a4ebbc..0a6997d 100644
--- a/src/ui/mainWindow.js
+++ b/src/ui/mainWindow.js
@@ -75,15 +75,18 @@ var MainWindow = GObject.registerClass(class MainWindow extends Gtk.Window {
                                              decoration_layout: "menu:close" });
         this.set_titlebar(this._titlebar);
 
-        this.connect('button-press-event', this._onButtonPressEvent.bind(this));
         this.connect('delete-event', this._onDeleteEvent.bind(this));
         this.connect('key-press-event', this._onKeyPressEvent.bind(this));
         this.connect('motion-notify-event', this._onMotionNotifyEvent.bind(this));
         this.connect('realize', this._onRealize.bind(this));
 
+        let eventBox = new Gtk.EventBox({ visible_window: false });
+        eventBox.connect('button-press-event', this._onButtonPressEvent.bind(this));
+        this.add(eventBox);
+
         this._embed = new Embed();
         this._embed.connect('size-request', this._onEmbedSizeRequest.bind(this));
-        this.add(this._embed);
+        eventBox.add(this._embed);
     }
 
     /**************************************************************************
@@ -115,7 +118,7 @@ var MainWindow = GObject.registerClass(class MainWindow extends Gtk.Window {
         return false;
     }
 
-    _onButtonPressEvent(window, event) {
+    _onButtonPressEvent(widget, event) {
         if (!this._renderer.moveOnClick)
             return false;
 


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