summaryrefslogtreecommitdiff
path: root/src/utilities
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2016-09-22 19:16:49 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2016-09-22 19:16:49 +0200
commitc59cef2ee7de5c2dc882c496deb569affb03bad8 (patch)
treedacf15d7bbedfe397a60387fde1dda3fbd68d92e /src/utilities
parent5e23ab97cea2ac130e20ac46911cab0d9356f33d (diff)
parent45a3d7f0e2783d9898f017772583d31c1c9e0f03 (diff)
Merge tag 'upstream/0.7.0'
Upstream version 0.7.0
Diffstat (limited to 'src/utilities')
-rw-r--r--src/utilities/bindingManager.vala79
1 files changed, 43 insertions, 36 deletions
diff --git a/src/utilities/bindingManager.vala b/src/utilities/bindingManager.vala
index 38ae1e0..a21c0a1 100644
--- a/src/utilities/bindingManager.vala
+++ b/src/utilities/bindingManager.vala
@@ -332,10 +332,7 @@ public class BindingManager : GLib.Object {
#endif
- if (xevent->type == X.EventType.KeyRelease) {
- on_release((uint32)xevent.xkey.time);
- } else if (xevent->type == X.EventType.KeyPress) {
-
+ if (xevent->type == X.EventType.KeyPress) {
// remove NumLock, CapsLock and ScrollLock from key state
var event_mods = prepare_modifiers((Gdk.ModifierType)xevent.xkey.state);
@@ -351,9 +348,7 @@ public class BindingManager : GLib.Object {
}
}
}
- } else if(xevent->type == X.EventType.ButtonRelease) {
- on_release((uint32)xevent.xkey.time);
- } else if(xevent->type == X.EventType.ButtonPress) {
+ } else if(xevent->type == X.EventType.ButtonPress) {
// remove NumLock, CapsLock and ScrollLock from key state
var event_mods = prepare_modifiers((Gdk.ModifierType)xevent.xbutton.state);
@@ -369,33 +364,61 @@ public class BindingManager : GLib.Object {
}
}
}
- }
- else if(xevent->type == X.EventType.ButtonRelease || xevent->type == X.EventType.KeyRelease) {
- this.activate_delayed(null, *xevent);
- }
+ }
+ else if(xevent->type == X.EventType.ButtonRelease || xevent->type == X.EventType.KeyRelease) {
+ on_release((uint32)xevent.xkey.time);
+ this.cancel_activate_delayed();
+ }
return Gdk.FilterReturn.CONTINUE;
}
/////////////////////////////////////////////////////////////////////
/// This method is always called when a trigger is activated which is
- /// delayed. Therefore on_press() is only emitted, when this method
- /// is not called again within 300 milliseconds. Else a fake event is
- /// sent in order to simulate the actual key which has been pressed.
+ /// delayed. Therefore on_press() is only emitted, when
+ /// cancel_activate_delayed is not called again 300 milliseconds.
+ /// Else a fake event is sent in order to simulate the actual key
+ /// which has been pressed.
/////////////////////////////////////////////////////////////////////
- private void activate_delayed(Keybinding? binding , X.Event event) {
- // increase event count, so any waiting event will realize that
- // something happened in the meantime
- var current_count = ++this.delayed_count;
+ private void activate_delayed(Keybinding binding, X.Event event) {
+
+ if (this.delayed_binding == null) {
+ // the current event count is captured in the lambda below. If
+ // cancel_activate_delayed is not called within 300 milliseconds,
+ // the binding can be activated
+ var current_count = this.delayed_count;
+
+ // if the trigger has been pressed, store it and wait for any interuption
+ // within the next 300 milliseconds
+ this.delayed_event = event;
+ this.delayed_binding = binding;
+
+ Timeout.add(300, () => {
+ // if nothing has been pressed in the meantime
+ if (current_count == this.delayed_count) {
+ this.delayed_binding = null;
+ this.delayed_event = null;
+ on_press(binding.id);
+ }
+ return false;
+ });
+ }
+ }
+
+ private void cancel_activate_delayed() {
+
+ if (this.delayed_event != null) {
+ // increase event count, so any waiting event will realize that
+ // something happened in the meantime
+ ++this.delayed_count;
- if (binding == null && this.delayed_event != null) {
// if the trigger is released and an event is currently waiting
// simulate that the trigger has been pressed without any inter-
// ference of Gnome-Pie
unowned X.Display display = Gdk.X11.get_default_xdisplay();
- // unbind the trigger, else we'll capture that event again ;)
+ // unbind the trigger, else we'll capture that event again ;-)
unbind(delayed_binding.id);
if (this.delayed_binding.trigger.with_mouse) {
@@ -420,22 +443,6 @@ public class BindingManager : GLib.Object {
this.delayed_binding = null;
this.delayed_event = null;
-
- } else if (binding != null) {
- // if the trigger has been pressed, store it and wait for any interuption
- // within the next 300 milliseconds
- this.delayed_event = event;
- this.delayed_binding = binding;
-
- Timeout.add(300, () => {
- // if nothing has been pressed in the meantime
- if (current_count == this.delayed_count) {
- this.delayed_binding = null;
- this.delayed_event = null;
- on_press(binding.id);
- }
- return false;
- });
}
}
}