[gnome-shell] [dnd] Special-case St.Clickable
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] [dnd] Special-case St.Clickable
- Date: Mon, 29 Mar 2010 16:01:37 +0000 (UTC)
commit 04200a428141e5424e620ed8c598f390da2c39ea
Author: Florian Müllner <fmuellner src gnome org>
Date: Sat Mar 27 02:24:50 2010 +0100
[dnd] Special-case St.Clickable
Currently manual dnd mode is used with St.Clickable to avoid messing
up its internal state with a pointer grab. To avoid code duplication,
move this special handling into dnd.
https://bugzilla.gnome.org/show_bug.cgi?id=610385
js/ui/dnd.js | 23 ++++++++++++++++++++---
1 files changed, 20 insertions(+), 3 deletions(-)
---
diff --git a/js/ui/dnd.js b/js/ui/dnd.js
index 8bf28df..2132165 100644
--- a/js/ui/dnd.js
+++ b/js/ui/dnd.js
@@ -2,6 +2,7 @@
const Clutter = imports.gi.Clutter;
const Gtk = imports.gi.Gtk;
+const St = imports.gi.St;
const Lang = imports.lang;
const Signals = imports.signals;
const Tweener = imports.ui.tweener;
@@ -61,13 +62,20 @@ _Draggable.prototype = {
},
_onButtonPress : function (actor, event) {
- // FIXME: we should make sure it's button 1, but we can't currently
- // check that from JavaScript
+ if (event.get_button() != 1)
+ return false;
+
if (Tweener.getTweenCount(actor))
return false;
this._buttonDown = true;
- this._grabActor();
+ // special case St.Clickable: grabbing the pointer would mess up the
+ // internal state, so we start the drag manually on hover change
+ if (this.actor instanceof St.Clickable)
+ this.actor.connect('notify::hover',
+ Lang.bind(this, this._onClickableHoverChanged));
+ else
+ this._grabActor();
let [stageX, stageY] = event.get_coords();
this._dragStartX = stageX;
@@ -76,6 +84,15 @@ _Draggable.prototype = {
return false;
},
+ _onClickableHoverChanged: function(button) {
+ if (button.hover || !button.held)
+ return;
+
+ button.fake_release();
+ this.startDrag(this._dragStartX, this._dragStartY,
+ global.get_current_time());
+ },
+
_grabActor: function() {
Clutter.grab_pointer(this.actor);
this._onEventId = this.actor.connect('event',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]