[gnome-shell/wip/pressure: 9/14] grabHelper: Add mechanism to ignore the next release event
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/pressure: 9/14] grabHelper: Add mechanism to ignore the next release event
- Date: Mon, 30 Jul 2012 23:49:41 +0000 (UTC)
commit acb165eb889345713ec756b6134c1c8b638d3a9f
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Wed Feb 29 19:09:31 2012 -0500
grabHelper: Add mechanism to ignore the next release event
Some child menus go away on a press, which means that we need to
eat the next release.
js/ui/grabHelper.js | 29 ++++++++++++++++++++++++++---
1 files changed, 26 insertions(+), 3 deletions(-)
---
diff --git a/js/ui/grabHelper.js b/js/ui/grabHelper.js
index 4f680ec..9c2f368 100644
--- a/js/ui/grabHelper.js
+++ b/js/ui/grabHelper.js
@@ -48,6 +48,7 @@ const GrabHelper = new Lang.Class({
this._eventId = 0;
this._keyFocusNotifyId = 0;
this._focusWindowChangedId = 0;
+ this._ignoreRelease = false;
},
// addActor:
@@ -147,6 +148,16 @@ const GrabHelper = new Lang.Class({
this.emit('grabbed');
},
+ // ignoreRelease:
+ //
+ // Make sure that the next button release event evaluated by the
+ // capture event handler returns false. This is designed for things
+ // like the ComboBoxMenu that go away on press, but need to eat
+ // the next release event.
+ ignoreRelease: function() {
+ this._ignoreRelease = true;
+ },
+
// ungrab:
// @newFocus: (allow-none): new focus container
// @userAction: Whether the ungrab was the cause of a user
@@ -221,8 +232,14 @@ const GrabHelper = new Lang.Class({
_onCapturedEvent: function(actor, event) {
let type = event.type();
- let button = (type == Clutter.EventType.BUTTON_PRESS ||
- type == Clutter.EventType.BUTTON_RELEASE);
+ let press = type == Clutter.EventType.BUTTON_PRESS;
+ let release = type == Clutter.EventType.BUTTON_RELEASE;
+ let button = press || release;
+
+ if (release && this._ignoreRelease) {
+ this._ignoreReleas = false;
+ return false;
+ }
if (!button && !this._modal)
return false;
@@ -230,8 +247,14 @@ const GrabHelper = new Lang.Class({
if (this._isWithinGrabbedActor(event.get_source()))
return false;
- if (button)
+ if (button) {
+ // If we have a press event, ignore the next event,
+ // which should be a release event.
+ if (press)
+ this._ignoreRelease = true;
this.ungrab(null, true);
+ }
+
return this._modal;
},
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]