summaryrefslogtreecommitdiff
path: root/src/utilities
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2016-08-26 16:35:54 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2016-08-26 16:35:54 +0200
commit4b19e75939c5b7122d1429f6f258d4b83cd90dde (patch)
treec1af105b3b9f98326bb59a7c0a5f516f15b9f1f4 /src/utilities
parentd9c48b3d78430c190a8077f0ec1fb65de1fc8b09 (diff)
Imported Upstream version 0.6.9upstream/0.6.9
Diffstat (limited to 'src/utilities')
-rw-r--r--src/utilities/animatedValue.vala2
-rw-r--r--src/utilities/archiveReader.vala2
-rw-r--r--src/utilities/archiveWriter.vala2
-rw-r--r--src/utilities/bindingManager.vala39
-rw-r--r--src/utilities/color.vala2
-rw-r--r--src/utilities/config.vala2
-rw-r--r--src/utilities/focusGrabber.vala2
-rw-r--r--src/utilities/key.vala88
-rw-r--r--src/utilities/logger.vala2
-rw-r--r--src/utilities/paths.vala2
-rw-r--r--src/utilities/trigger.vala8
11 files changed, 105 insertions, 46 deletions
diff --git a/src/utilities/animatedValue.vala b/src/utilities/animatedValue.vala
index 79be155..5bb46f5 100644
--- a/src/utilities/animatedValue.vala
+++ b/src/utilities/animatedValue.vala
@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
-// Copyright (c) 2011-2015 by Simon Schneegans
+// Copyright (c) 2011-2016 by Simon Schneegans
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
diff --git a/src/utilities/archiveReader.vala b/src/utilities/archiveReader.vala
index 16e4541..14183ac 100644
--- a/src/utilities/archiveReader.vala
+++ b/src/utilities/archiveReader.vala
@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
-// Copyright (c) 2011-2015 by Simon Schneegans
+// Copyright (c) 2011-2016 by Simon Schneegans
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
diff --git a/src/utilities/archiveWriter.vala b/src/utilities/archiveWriter.vala
index 92bd31b..b74b5d0 100644
--- a/src/utilities/archiveWriter.vala
+++ b/src/utilities/archiveWriter.vala
@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
-// Copyright (c) 2011-2015 by Simon Schneegans
+// Copyright (c) 2011-2016 by Simon Schneegans
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
diff --git a/src/utilities/bindingManager.vala b/src/utilities/bindingManager.vala
index ac5a8fb..38ae1e0 100644
--- a/src/utilities/bindingManager.vala
+++ b/src/utilities/bindingManager.vala
@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
-// Copyright (c) 2011-2015 by Simon Schneegans
+// Copyright (c) 2011-2016 by Simon Schneegans
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -32,6 +32,12 @@ public class BindingManager : GLib.Object {
public signal void on_press(string id);
/////////////////////////////////////////////////////////////////////
+ /// Called when a previously pressed binding is released again.
+ /////////////////////////////////////////////////////////////////////
+
+ public signal void on_release(uint32 time_stamp);
+
+ /////////////////////////////////////////////////////////////////////
/// A list storing bindings, which are invoked even if Gnome-Pie
/// doesn't have the current focus
/////////////////////////////////////////////////////////////////////
@@ -303,6 +309,12 @@ public class BindingManager : GLib.Object {
mods = mods & ~ Gdk.ModifierType.SUPER_MASK;
}
+ mods &= ~(Gdk.ModifierType.BUTTON1_MASK
+ | Gdk.ModifierType.BUTTON2_MASK
+ | Gdk.ModifierType.BUTTON3_MASK
+ | Gdk.ModifierType.BUTTON4_MASK
+ | Gdk.ModifierType.BUTTON5_MASK);
+
return mods & ~lock_modifiers[7];
}
@@ -319,13 +331,16 @@ public class BindingManager : GLib.Object {
X.Event* xevent = (X.Event*) pointer;
#endif
- if(xevent->type == X.EventType.KeyPress) {
- foreach(var binding in bindings) {
- // remove NumLock, CapsLock and ScrollLock from key state
- var event_mods = prepare_modifiers((Gdk.ModifierType)xevent.xkey.state);
- var bound_mods = prepare_modifiers(binding.trigger.modifiers);
+ if (xevent->type == X.EventType.KeyRelease) {
+ on_release((uint32)xevent.xkey.time);
+ } else if (xevent->type == X.EventType.KeyPress) {
+ // remove NumLock, CapsLock and ScrollLock from key state
+ var event_mods = prepare_modifiers((Gdk.ModifierType)xevent.xkey.state);
+
+ foreach(var binding in bindings) {
+ var bound_mods = prepare_modifiers(binding.trigger.modifiers);
if(xevent->xkey.keycode == binding.trigger.key_code &&
event_mods == bound_mods) {
@@ -336,14 +351,14 @@ public class BindingManager : GLib.Object {
}
}
}
- }
- else if(xevent->type == X.EventType.ButtonPress) {
- foreach(var binding in bindings) {
+ } else if(xevent->type == X.EventType.ButtonRelease) {
+ on_release((uint32)xevent.xkey.time);
+ } 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);
- // remove NumLock, CapsLock and ScrollLock from key state
- var event_mods = prepare_modifiers((Gdk.ModifierType)xevent.xbutton.state);
+ foreach(var binding in bindings) {
var bound_mods = prepare_modifiers(binding.trigger.modifiers);
-
if(xevent->xbutton.button == binding.trigger.key_code &&
event_mods == bound_mods) {
diff --git a/src/utilities/color.vala b/src/utilities/color.vala
index a681e02..1e2baf3 100644
--- a/src/utilities/color.vala
+++ b/src/utilities/color.vala
@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
-// Copyright (c) 2011-2015 by Simon Schneegans
+// Copyright (c) 2011-2016 by Simon Schneegans
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
diff --git a/src/utilities/config.vala b/src/utilities/config.vala
index 74bbcbb..3fc8d3f 100644
--- a/src/utilities/config.vala
+++ b/src/utilities/config.vala
@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
-// Copyright (c) 2011-2015 by Simon Schneegans
+// Copyright (c) 2011-2016 by Simon Schneegans
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
diff --git a/src/utilities/focusGrabber.vala b/src/utilities/focusGrabber.vala
index baa5fed..4a3212f 100644
--- a/src/utilities/focusGrabber.vala
+++ b/src/utilities/focusGrabber.vala
@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
-// Copyright (c) 2011-2015 by Simon Schneegans
+// Copyright (c) 2011-2016 by Simon Schneegans
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
diff --git a/src/utilities/key.vala b/src/utilities/key.vala
index 486744d..432c40e 100644
--- a/src/utilities/key.vala
+++ b/src/utilities/key.vala
@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
-// Copyright (c) 2011-2015 by Simon Schneegans
+// Copyright (c) 2011-2016 by Simon Schneegans
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -30,10 +30,14 @@ public class Key : GLib.Object {
private static X.Display display;
- private static int shift_code;
- private static int ctrl_code;
- private static int alt_code;
- private static int super_code;
+ private static int shift_l_code;
+ private static int shift_r_code;
+ private static int ctrl_l_code;
+ private static int ctrl_r_code;
+ private static int alt_l_code;
+ private static int alt_r_code;
+ private static int super_l_code;
+ private static int super_r_code;
/////////////////////////////////////////////////////////////////////
/// A human readable form of the Key's accelerator.
@@ -96,10 +100,14 @@ public class Key : GLib.Object {
static construct {
display = new X.Display();
- shift_code = display.keysym_to_keycode(Gdk.keyval_from_name("Shift_L"));
- ctrl_code = display.keysym_to_keycode(Gdk.keyval_from_name("Control_L"));
- alt_code = display.keysym_to_keycode(Gdk.keyval_from_name("Alt_L"));
- super_code = display.keysym_to_keycode(Gdk.keyval_from_name("Super_L"));
+ shift_l_code = display.keysym_to_keycode(Gdk.keyval_from_name("Shift_L"));
+ shift_r_code = display.keysym_to_keycode(Gdk.keyval_from_name("Shift_R"));
+ ctrl_l_code = display.keysym_to_keycode(Gdk.keyval_from_name("Control_L"));
+ ctrl_r_code = display.keysym_to_keycode(Gdk.keyval_from_name("Control_R"));
+ alt_l_code = display.keysym_to_keycode(Gdk.keyval_from_name("Alt_L"));
+ alt_r_code = display.keysym_to_keycode(Gdk.keyval_from_name("Alt_R"));
+ super_l_code = display.keysym_to_keycode(Gdk.keyval_from_name("Super_L"));
+ super_r_code = display.keysym_to_keycode(Gdk.keyval_from_name("Super_R"));
}
/////////////////////////////////////////////////////////////////////
@@ -111,8 +119,8 @@ public class Key : GLib.Object {
Gdk.ModifierType current_modifiers = get_modifiers();
// release them and press the desired ones
- press_modifiers(current_modifiers, false);
- press_modifiers(this.modifiers, true);
+ release_modifiers(current_modifiers);
+ press_modifiers(this.modifiers);
// send events to X
display.flush();
@@ -122,8 +130,8 @@ public class Key : GLib.Object {
XTest.fake_key_event(display, this.key_code, false, 0);
// release the pressed modifiers and re-press the keys hold down by the user
- press_modifiers(this.modifiers, false);
- press_modifiers(current_modifiers, true);
+ release_modifiers(this.modifiers);
+ // press_modifiers(current_modifiers);
// send events to X
display.flush();
@@ -134,27 +142,57 @@ public class Key : GLib.Object {
/////////////////////////////////////////////////////////////////////
private Gdk.ModifierType get_modifiers() {
- Gdk.ModifierType modifiers;
- Gtk.get_current_event_state(out modifiers);
- return modifiers;
+ return (Gdk.ModifierType)Gdk.Keymap.get_default().get_modifier_state();
+ }
+
+ /////////////////////////////////////////////////////////////////////
+ /// Helper method which 'releases' the desired modifier keys.
+ /////////////////////////////////////////////////////////////////////
+
+ private void release_modifiers(Gdk.ModifierType modifiers) {
+ // since we do not know whether left or right version of each key
+ // is pressed, we release both...
+ if ((modifiers & Gdk.ModifierType.CONTROL_MASK) > 0) {
+ XTest.fake_key_event(display, ctrl_l_code, false, 0);
+ XTest.fake_key_event(display, ctrl_r_code, false, 0);
+ }
+
+ if ((modifiers & Gdk.ModifierType.SHIFT_MASK) > 0) {
+ XTest.fake_key_event(display, shift_l_code, false, 0);
+ XTest.fake_key_event(display, shift_r_code, false, 0);
+ }
+
+ if ((modifiers & Gdk.ModifierType.MOD1_MASK) > 0) {
+ XTest.fake_key_event(display, alt_l_code, false, 0);
+ XTest.fake_key_event(display, alt_r_code, false, 0);
+ }
+
+ if ((modifiers & Gdk.ModifierType.SUPER_MASK) > 0) {
+ XTest.fake_key_event(display, super_l_code, false, 0);
+ XTest.fake_key_event(display, super_r_code, false, 0);
+ }
}
/////////////////////////////////////////////////////////////////////
/// Helper method which 'presses' the desired modifier keys.
/////////////////////////////////////////////////////////////////////
- private void press_modifiers(Gdk.ModifierType modifiers, bool down) {
- if ((modifiers & Gdk.ModifierType.CONTROL_MASK) > 0)
- XTest.fake_key_event(display, ctrl_code, down, 0);
+ private void press_modifiers(Gdk.ModifierType modifiers) {
+ if ((modifiers & Gdk.ModifierType.CONTROL_MASK) > 0) {
+ XTest.fake_key_event(display, ctrl_l_code, true, 0);
+ }
- if ((modifiers & Gdk.ModifierType.SHIFT_MASK) > 0)
- XTest.fake_key_event(display, shift_code, down, 0);
+ if ((modifiers & Gdk.ModifierType.SHIFT_MASK) > 0) {
+ XTest.fake_key_event(display, shift_l_code, true, 0);
+ }
- if ((modifiers & Gdk.ModifierType.MOD1_MASK) > 0)
- XTest.fake_key_event(display, alt_code, down, 0);
+ if ((modifiers & Gdk.ModifierType.MOD1_MASK) > 0) {
+ XTest.fake_key_event(display, alt_l_code, true, 0);
+ }
- if ((modifiers & Gdk.ModifierType.SUPER_MASK) > 0)
- XTest.fake_key_event(display, super_code, down, 0);
+ if ((modifiers & Gdk.ModifierType.SUPER_MASK) > 0) {
+ XTest.fake_key_event(display, super_l_code, true, 0);
+ }
}
}
diff --git a/src/utilities/logger.vala b/src/utilities/logger.vala
index 7c66615..ecc551e 100644
--- a/src/utilities/logger.vala
+++ b/src/utilities/logger.vala
@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
-// Copyright (c) 2011-2015 by Simon Schneegans
+// Copyright (c) 2011-2016 by Simon Schneegans
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
diff --git a/src/utilities/paths.vala b/src/utilities/paths.vala
index 7bdd642..68c5384 100644
--- a/src/utilities/paths.vala
+++ b/src/utilities/paths.vala
@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
-// Copyright (c) 2011-2015 by Simon Schneegans
+// Copyright (c) 2011-2016 by Simon Schneegans
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
diff --git a/src/utilities/trigger.vala b/src/utilities/trigger.vala
index 5373b41..aeed3fb 100644
--- a/src/utilities/trigger.vala
+++ b/src/utilities/trigger.vala
@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
-// Copyright (c) 2011-2015 by Simon Schneegans
+// Copyright (c) 2011-2016 by Simon Schneegans
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -172,6 +172,8 @@ public class Trigger : GLib.Object {
int button = this.get_mouse_button(check_string);
if (button > 0) {
+ check_string = check_string.substring(0, check_string.index_of("button"));
+
this.with_mouse = true;
this.key_code = button;
this.key_sym = button;
@@ -179,6 +181,10 @@ public class Trigger : GLib.Object {
Gtk.accelerator_parse(check_string, null, out this._modifiers);
this.label = Gtk.accelerator_get_label(0, this.modifiers);
+ if (this.label != "") {
+ label += "+";
+ }
+
string button_text = _("Button %i").printf(this.key_code);
if (this.key_code == 1)