summaryrefslogtreecommitdiff
path: root/src/utilities
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2015-05-03 07:25:38 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2015-05-03 07:25:38 +0200
commitdaab38595df60c0ef3e142c195382cb35d448203 (patch)
tree4186938621912272570b4187a4d8ef8e3ca87b47 /src/utilities
parentfbd5a9eb0d29bdfd9f5f0892190452e17871afd9 (diff)
parenta1c05d93bbb3c1bdb0c0fed9d7110804037cfd55 (diff)
Merge tag 'upstream/0.6.2'
Upstream version 0.6.2
Diffstat (limited to 'src/utilities')
-rw-r--r--src/utilities/bindingManager.vala84
-rw-r--r--src/utilities/color.vala21
-rw-r--r--src/utilities/config.vala2
-rw-r--r--src/utilities/key.vala12
-rw-r--r--src/utilities/trigger.vala2
5 files changed, 88 insertions, 33 deletions
diff --git a/src/utilities/bindingManager.vala b/src/utilities/bindingManager.vala
index e90fa74..6ca73cf 100644
--- a/src/utilities/bindingManager.vala
+++ b/src/utilities/bindingManager.vala
@@ -99,18 +99,22 @@ public class BindingManager : GLib.Object {
public void bind(Trigger trigger, string id) {
if (trigger.key_code != 0) {
- X.Display display = Gdk.X11.get_default_xdisplay();
+ unowned X.Display display = Gdk.X11.get_default_xdisplay();
X.ID xid = Gdk.X11.get_default_root_xwindow();
Gdk.error_trap_push();
+ // if bound to super key we need to grab MOD4 instead
+ // (for whatever reason...)
+ var modifiers = prepare_modifiers(trigger.modifiers);
+
foreach(uint lock_modifier in lock_modifiers) {
if (trigger.with_mouse) {
- display.grab_button(trigger.key_code, trigger.modifiers|lock_modifier, xid, false,
+ display.grab_button(trigger.key_code, modifiers|lock_modifier, xid, false,
X.EventMask.ButtonPressMask | X.EventMask.ButtonReleaseMask,
X.GrabMode.Async, X.GrabMode.Async, xid, 0);
} else {
- display.grab_key(trigger.key_code, trigger.modifiers|lock_modifier,
+ display.grab_key(trigger.key_code, modifiers|lock_modifier,
xid, false, X.GrabMode.Async, X.GrabMode.Async);
}
}
@@ -142,17 +146,22 @@ public class BindingManager : GLib.Object {
}
}
- X.Display display = Gdk.X11.get_default_xdisplay();
+ unowned X.Display display = Gdk.X11.get_default_xdisplay();
X.ID xid = Gdk.X11.get_default_root_xwindow();
Gee.List<Keybinding> remove_bindings = new Gee.ArrayList<Keybinding>();
foreach(var binding in bindings) {
if(id == binding.id) {
+
+ // if bound to super key we need to ungrab MOD4 instead
+ // (for whatever reason...)
+ var modifiers = prepare_modifiers(binding.trigger.modifiers);
+
foreach(uint lock_modifier in lock_modifiers) {
if (binding.trigger.with_mouse) {
- display.ungrab_button(binding.trigger.key_code, binding.trigger.modifiers|lock_modifier, xid);
+ display.ungrab_button(binding.trigger.key_code, modifiers|lock_modifier, xid);
} else {
- display.ungrab_key(binding.trigger.key_code, binding.trigger.modifiers|lock_modifier, xid);
+ display.ungrab_key(binding.trigger.key_code, modifiers|lock_modifier, xid);
}
}
remove_bindings.add(binding);
@@ -282,6 +291,21 @@ public class BindingManager : GLib.Object {
}
/////////////////////////////////////////////////////////////////////
+ /// If SUPER_MASK is set in the input, it will be replaced with
+ /// MOD4_MASK. For some reason this is required to listen for key
+ /// presses of the super button....
+ /////////////////////////////////////////////////////////////////////
+
+ private Gdk.ModifierType prepare_modifiers(Gdk.ModifierType mods) {
+ if ((mods & Gdk.ModifierType.SUPER_MASK) > 0) {
+ mods |= Gdk.ModifierType.MOD4_MASK;
+ mods = mods & ~ Gdk.ModifierType.SUPER_MASK;
+ }
+
+ return mods & ~lock_modifiers[7];
+ }
+
+ /////////////////////////////////////////////////////////////////////
/// Event filter method needed to fetch X.Events.
/////////////////////////////////////////////////////////////////////
@@ -296,9 +320,14 @@ public class BindingManager : GLib.Object {
if(xevent->type == X.EventType.KeyPress) {
foreach(var binding in bindings) {
+
// remove NumLock, CapsLock and ScrollLock from key state
- uint event_mods = xevent.xkey.state & ~ (lock_modifiers[7]);
- if(xevent->xkey.keycode == binding.trigger.key_code && event_mods == binding.trigger.modifiers) {
+ var event_mods = prepare_modifiers((Gdk.ModifierType)xevent.xkey.state);
+ var bound_mods = prepare_modifiers(binding.trigger.modifiers);
+
+ if(xevent->xkey.keycode == binding.trigger.key_code &&
+ event_mods == bound_mods) {
+
if (binding.trigger.delayed) {
this.activate_delayed(binding, *xevent);
} else {
@@ -309,9 +338,14 @@ public class BindingManager : GLib.Object {
}
else if(xevent->type == X.EventType.ButtonPress) {
foreach(var binding in bindings) {
+
// remove NumLock, CapsLock and ScrollLock from key state
- uint event_mods = xevent.xbutton.state & ~ (lock_modifiers[7]);
- if(xevent->xbutton.button == binding.trigger.key_code && event_mods == binding.trigger.modifiers) {
+ var event_mods = prepare_modifiers((Gdk.ModifierType)xevent.xbutton.state);
+ var bound_mods = prepare_modifiers(binding.trigger.modifiers);
+
+ if(xevent->xbutton.button == binding.trigger.key_code &&
+ event_mods == bound_mods) {
+
if (binding.trigger.delayed) {
this.activate_delayed(binding, *xevent);
} else {
@@ -343,27 +377,27 @@ public class BindingManager : GLib.Object {
// 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
- X.Display display = Gdk.X11.get_default_xdisplay();
+ unowned X.Display display = Gdk.X11.get_default_xdisplay();
- // unbind the trigger, else we'll capture that event again ;)
- unbind(delayed_binding.id);
+ // unbind the trigger, else we'll capture that event again ;)
+ unbind(delayed_binding.id);
- if (this.delayed_binding.trigger.with_mouse) {
- // simulate mouse click
- X.Test.fake_button_event(display, this.delayed_event.xbutton.button, true, 0);
- display.flush();
+ if (this.delayed_binding.trigger.with_mouse) {
+ // simulate mouse click
+ XTest.fake_button_event(display, this.delayed_event.xbutton.button, true, 0);
+ display.flush();
- X.Test.fake_button_event(display, this.delayed_event.xbutton.button, false, 0);
+ XTest.fake_button_event(display, this.delayed_event.xbutton.button, false, 0);
display.flush();
- } else {
- // simulate key press
- X.Test.fake_key_event(display, this.delayed_event.xkey.keycode, true, 0);
- display.flush();
+ } else {
+ // simulate key press
+ XTest.fake_key_event(display, this.delayed_event.xkey.keycode, true, 0);
+ display.flush();
- X.Test.fake_key_event(display, this.delayed_event.xkey.keycode, false, 0);
- display.flush();
- }
+ XTest.fake_key_event(display, this.delayed_event.xkey.keycode, false, 0);
+ display.flush();
+ }
// bind it again
bind(delayed_binding.trigger, delayed_binding.id);
diff --git a/src/utilities/color.vala b/src/utilities/color.vala
index 6bb9d06..a681e02 100644
--- a/src/utilities/color.vala
+++ b/src/utilities/color.vala
@@ -77,6 +77,19 @@ public class Color: GLib.Object {
}
/////////////////////////////////////////////////////////////////////
+ /// Creates a color from a given widget style
+ /////////////////////////////////////////////////////////////////////
+
+ public Color.from_widget_style(Gtk.Widget widget, string style_name) {
+ var ctx = widget.get_style_context();
+ Gdk.RGBA color;
+ if (!ctx.lookup_color(style_name, out color)) {
+ warning("Failed to get style color for widget style \"" + style_name + "\"!");
+ }
+ Color.from_gdk(color);
+ }
+
+ /////////////////////////////////////////////////////////////////////
/// Creates a color, parsed from a string, such as #22EE33
/////////////////////////////////////////////////////////////////////
@@ -129,6 +142,14 @@ public class Color: GLib.Object {
}
/////////////////////////////////////////////////////////////////////
+ /// Returns this color as its hex representation.
+ /////////////////////////////////////////////////////////////////////
+
+ public string to_hex_string() {
+ return "#%02X%02X%02X".printf((int)(_r*255), (int)(_g*255), (int)(_b*255));
+ }
+
+ /////////////////////////////////////////////////////////////////////
/// The reddish part of the color.
/////////////////////////////////////////////////////////////////////
diff --git a/src/utilities/config.vala b/src/utilities/config.vala
index abb8b23..dd31885 100644
--- a/src/utilities/config.vala
+++ b/src/utilities/config.vala
@@ -192,7 +192,7 @@ public class Config : GLib.Object {
if (themes.size > 0) {
if (current == "") {
- current = "Unity";
+ current = "Adwaita";
warning("No theme specified! Using default...");
}
foreach (var t in themes) {
diff --git a/src/utilities/key.vala b/src/utilities/key.vala
index 7cf425f..486744d 100644
--- a/src/utilities/key.vala
+++ b/src/utilities/key.vala
@@ -118,8 +118,8 @@ public class Key : GLib.Object {
display.flush();
// press and release the actual key
- X.Test.fake_key_event(display, this.key_code, true, 0);
- X.Test.fake_key_event(display, this.key_code, false, 0);
+ XTest.fake_key_event(display, this.key_code, true, 0);
+ 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);
@@ -145,16 +145,16 @@ public class Key : GLib.Object {
private void press_modifiers(Gdk.ModifierType modifiers, bool down) {
if ((modifiers & Gdk.ModifierType.CONTROL_MASK) > 0)
- X.Test.fake_key_event(display, ctrl_code, down, 0);
+ XTest.fake_key_event(display, ctrl_code, down, 0);
if ((modifiers & Gdk.ModifierType.SHIFT_MASK) > 0)
- X.Test.fake_key_event(display, shift_code, down, 0);
+ XTest.fake_key_event(display, shift_code, down, 0);
if ((modifiers & Gdk.ModifierType.MOD1_MASK) > 0)
- X.Test.fake_key_event(display, alt_code, down, 0);
+ XTest.fake_key_event(display, alt_code, down, 0);
if ((modifiers & Gdk.ModifierType.SUPER_MASK) > 0)
- X.Test.fake_key_event(display, super_code, down, 0);
+ XTest.fake_key_event(display, super_code, down, 0);
}
}
diff --git a/src/utilities/trigger.vala b/src/utilities/trigger.vala
index fbd74f8..5373b41 100644
--- a/src/utilities/trigger.vala
+++ b/src/utilities/trigger.vala
@@ -251,7 +251,7 @@ public class Trigger : GLib.Object {
msg += " | " + _("Half pie");
}
if (msg != "")
- this.label_with_specials += (" <small><span weight='light'>[ " + msg + " ]</span></small>");
+ this.label_with_specials += (" [ " + msg + " ]");
} else {
this.set_unbound();