summaryrefslogtreecommitdiff
path: root/src/utilities
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2017-07-25 06:51:21 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2017-07-25 06:51:21 +0200
commit3b49907c8b012b0a62d6e264f62bf03b13e68a51 (patch)
treee9acc532002ca7a52810325eee1f16d6d17f9d27 /src/utilities
parent394ad3b32f9f79775bcac4c6cc2a4dfa74586800 (diff)
parent334f925d5866faaf6ed36a4269d14bcc7aa86a76 (diff)
Merge branch 'feature/upstream' into develop
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.vala16
-rw-r--r--src/utilities/color.vala14
-rw-r--r--src/utilities/config.vala2
-rw-r--r--src/utilities/focusGrabber.vala85
-rw-r--r--src/utilities/key.vala2
-rw-r--r--src/utilities/logger.vala28
-rw-r--r--src/utilities/paths.vala6
-rw-r--r--src/utilities/trigger.vala2
11 files changed, 90 insertions, 71 deletions
diff --git a/src/utilities/animatedValue.vala b/src/utilities/animatedValue.vala
index 5bb46f5..3dc0685 100644
--- a/src/utilities/animatedValue.vala
+++ b/src/utilities/animatedValue.vala
@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
-// Copyright (c) 2011-2016 by Simon Schneegans
+// Copyright (c) 2011-2017 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 14183ac..df248cf 100644
--- a/src/utilities/archiveReader.vala
+++ b/src/utilities/archiveReader.vala
@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
-// Copyright (c) 2011-2016 by Simon Schneegans
+// Copyright (c) 2011-2017 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 b74b5d0..2a18154 100644
--- a/src/utilities/archiveWriter.vala
+++ b/src/utilities/archiveWriter.vala
@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
-// Copyright (c) 2011-2016 by Simon Schneegans
+// Copyright (c) 2011-2017 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 a21c0a1..82b6334 100644
--- a/src/utilities/bindingManager.vala
+++ b/src/utilities/bindingManager.vala
@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
-// Copyright (c) 2011-2016 by Simon Schneegans
+// Copyright (c) 2011-2017 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
@@ -73,6 +73,12 @@ public class BindingManager : GLib.Object {
private Keybinding? delayed_binding = null;
/////////////////////////////////////////////////////////////////////
+ /// Used to identify wayland sessions.
+ /////////////////////////////////////////////////////////////////////
+
+ private bool wayland = GLib.Environment.get_variable("XDG_SESSION_TYPE") == "wayland";
+
+ /////////////////////////////////////////////////////////////////////
/// Helper class to store keybinding
/////////////////////////////////////////////////////////////////////
@@ -104,7 +110,9 @@ public class BindingManager : GLib.Object {
/////////////////////////////////////////////////////////////////////
public void bind(Trigger trigger, string id) {
- if (trigger.key_code != 0) {
+
+ // global key grabbing is impossible on wayland
+ if (!wayland && trigger.key_code != 0) {
unowned X.Display display = Gdk.X11.get_default_xdisplay();
X.ID xid = Gdk.X11.get_default_root_xwindow();
@@ -143,8 +151,8 @@ public class BindingManager : GLib.Object {
public void unbind(string id) {
foreach (var binding in bindings) {
if (id == binding.id) {
- if (binding.trigger.key_code == 0) {
- //no key_code: just remove the bindind from the list
+ if (binding.trigger.key_code == 0 || wayland) {
+ //no key_code or wayland: just remove the bindind from the list
bindings.remove(binding);
return;
}
diff --git a/src/utilities/color.vala b/src/utilities/color.vala
index 1e2baf3..cc65434 100644
--- a/src/utilities/color.vala
+++ b/src/utilities/color.vala
@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
-// Copyright (c) 2011-2016 by Simon Schneegans
+// Copyright (c) 2011-2017 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
@@ -41,7 +41,7 @@ public class Color: GLib.Object {
/////////////////////////////////////////////////////////////////////
public Color() {
- Color.from_rgb(1.0f, 1.0f, 1.0f);
+ this.from_rgb(1.0f, 1.0f, 1.0f);
}
/////////////////////////////////////////////////////////////////////
@@ -49,7 +49,7 @@ public class Color: GLib.Object {
/////////////////////////////////////////////////////////////////////
public Color.from_rgb(float red, float green, float blue) {
- Color.from_rgba(red, green, blue, 1.0f);
+ this.from_rgba(red, green, blue, 1.0f);
}
/////////////////////////////////////////////////////////////////////
@@ -68,7 +68,7 @@ public class Color: GLib.Object {
/////////////////////////////////////////////////////////////////////
public Color.from_gdk(Gdk.RGBA color) {
- Color.from_rgba(
+ this.from_rgba(
(float)color.red,
(float)color.green,
(float)color.blue,
@@ -86,7 +86,7 @@ public class Color: GLib.Object {
if (!ctx.lookup_color(style_name, out color)) {
warning("Failed to get style color for widget style \"" + style_name + "\"!");
}
- Color.from_gdk(color);
+ this.from_gdk(color);
}
/////////////////////////////////////////////////////////////////////
@@ -96,7 +96,7 @@ public class Color: GLib.Object {
public Color.from_string(string hex_string) {
var color = Gdk.RGBA();
color.parse(hex_string);
- Color.from_gdk(color);
+ this.from_gdk(color);
}
/////////////////////////////////////////////////////////////////////
@@ -134,7 +134,7 @@ public class Color: GLib.Object {
}
}
- Color.from_rgb((float)(rtotal/total), (float)(gtotal/total), (float)(btotal/total));
+ this.from_rgb((float)(rtotal/total), (float)(gtotal/total), (float)(btotal/total));
if (s > 0.15f) s = 0.65f;
diff --git a/src/utilities/config.vala b/src/utilities/config.vala
index 3fc8d3f..1d3fde4 100644
--- a/src/utilities/config.vala
+++ b/src/utilities/config.vala
@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
-// Copyright (c) 2011-2016 by Simon Schneegans
+// Copyright (c) 2011-2017 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 4a3212f..8424f12 100644
--- a/src/utilities/focusGrabber.vala
+++ b/src/utilities/focusGrabber.vala
@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
-// Copyright (c) 2011-2016 by Simon Schneegans
+// Copyright (c) 2011-2017 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
@@ -28,18 +28,16 @@ public class FocusGrabber : GLib.Object {
/// Code roughly from Gnome-Do/Synapse.
/////////////////////////////////////////////////////////////////////
- public static void grab(Gdk.Window window, bool keyboard = true, bool pointer = true, bool owner_events = true) {
- if (keyboard || pointer) {
- window.raise();
- window.focus(Gdk.CURRENT_TIME);
-
- if (!try_grab_window(window, keyboard, pointer, owner_events)) {
- int i = 0;
- Timeout.add(100, () => {
- if (++i >= 100) return false;
- return !try_grab_window(window, keyboard, pointer, owner_events);
- });
- }
+ public static void grab(Gdk.Window window) {
+ window.raise();
+ window.focus(Gdk.CURRENT_TIME);
+
+ if (!try_grab_window(window)) {
+ int i = 0;
+ Timeout.add(100, () => {
+ if (++i >= 100) return false;
+ return !try_grab_window(window);
+ });
}
}
@@ -47,50 +45,65 @@ public class FocusGrabber : GLib.Object {
/// Code roughly from Gnome-Do/Synapse.
/////////////////////////////////////////////////////////////////////
- public static void ungrab(bool keyboard = true, bool pointer = true) {
- var display = Gdk.Display.get_default();
- var manager = display.get_device_manager();
-
- GLib.List<weak Gdk.Device?> list = manager.list_devices(Gdk.DeviceType.MASTER);
+ public static void ungrab() {
+ #if HAVE_GTK_3_20
+ var seat = Gdk.Display.get_default().get_default_seat();
+ seat.ungrab();
+ #else
+ var display = Gdk.Display.get_default();
+ var manager = display.get_device_manager();
- foreach(var device in list) {
- if ((device.input_source == Gdk.InputSource.KEYBOARD && keyboard)
- || (device.input_source != Gdk.InputSource.KEYBOARD && pointer))
+ GLib.List<weak Gdk.Device?> list = manager.list_devices(Gdk.DeviceType.MASTER);
+ foreach(var device in list) {
device.ungrab(Gdk.CURRENT_TIME);
- }
+ }
+ #endif
}
/////////////////////////////////////////////////////////////////////
/// Code roughly from Gnome-Do/Synapse.
/////////////////////////////////////////////////////////////////////
- private static bool try_grab_window(Gdk.Window window, bool keyboard, bool pointer, bool owner_events) {
- var display = Gdk.Display.get_default();
- var manager = display.get_device_manager();
+ private static bool try_grab_window(Gdk.Window window) {
+ #if HAVE_GTK_3_20
+ // try again if window is not yet viewable
+ if (!window.is_viewable()) return false;
- bool grabbed_all = true;
+ var seat = Gdk.Display.get_default().get_default_seat();
+ var caps = Gdk.SeatCapabilities.POINTER | Gdk.SeatCapabilities.KEYBOARD;
+ var result = seat.grab(window, caps, true, null, null, null);
- GLib.List<weak Gdk.Device?> list = manager.list_devices(Gdk.DeviceType.MASTER);
+ // for some reason GDK hides the window if the grab fails...
+ if (result != Gdk.GrabStatus.SUCCESS) {
+ window.show();
+ }
+
+ // continue trying to grab if it failed!
+ return result == Gdk.GrabStatus.SUCCESS;
+ #else
+ var display = Gdk.Display.get_default();
+ var manager = display.get_device_manager();
- foreach(var device in list) {
- if ((device.input_source == Gdk.InputSource.KEYBOARD && keyboard)
- || (device.input_source != Gdk.InputSource.KEYBOARD && pointer)) {
+ bool grabbed_all = true;
- var status = device.grab(window, Gdk.GrabOwnership.APPLICATION, owner_events,
+ GLib.List<weak Gdk.Device?> list = manager.list_devices(Gdk.DeviceType.MASTER);
+
+ foreach(var device in list) {
+ var status = device.grab(window, Gdk.GrabOwnership.APPLICATION, true,
Gdk.EventMask.ALL_EVENTS_MASK, null, Gdk.CURRENT_TIME);
if (status != Gdk.GrabStatus.SUCCESS)
grabbed_all = false;
}
- }
- if (grabbed_all)
- return true;
+ if (grabbed_all)
+ return true;
- ungrab(keyboard, pointer);
+ ungrab();
- return false;
+ return false;
+ #endif
}
}
diff --git a/src/utilities/key.vala b/src/utilities/key.vala
index 432c40e..93e18b5 100644
--- a/src/utilities/key.vala
+++ b/src/utilities/key.vala
@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
-// Copyright (c) 2011-2016 by Simon Schneegans
+// Copyright (c) 2011-2017 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/logger.vala b/src/utilities/logger.vala
index ecc551e..48f27c6 100644
--- a/src/utilities/logger.vala
+++ b/src/utilities/logger.vala
@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
-// Copyright (c) 2011-2016 by Simon Schneegans
+// Copyright (c) 2011-2017 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
@@ -29,33 +29,33 @@ public class Logger {
/// If these are set to false, the according messages are not shown
/////////////////////////////////////////////////////////////////////
- private static const bool display_debug = true;
- private static const bool display_warning = true;
- private static const bool display_error = true;
- private static const bool display_message = true;
+ private const bool display_debug = true;
+ private const bool display_warning = true;
+ private const bool display_error = true;
+ private const bool display_message = true;
/////////////////////////////////////////////////////////////////////
/// If these are set to false, the according messages are not logged
/////////////////////////////////////////////////////////////////////
- private static const bool log_debug = false;
- private static const bool log_warning = true;
- private static const bool log_error = true;
- private static const bool log_message = true;
+ private const bool log_debug = false;
+ private const bool log_warning = true;
+ private const bool log_error = true;
+ private const bool log_message = true;
/////////////////////////////////////////////////////////////////////
/// If true, a time stamp is shown in each message.
/////////////////////////////////////////////////////////////////////
- private static const bool display_time = false;
- private static const bool log_time = true;
+ private const bool display_time = false;
+ private const bool log_time = true;
/////////////////////////////////////////////////////////////////////
/// If true, the origin of the message is shown. In form file:line
/////////////////////////////////////////////////////////////////////
- private static const bool display_file = false;
- private static const bool log_file = false;
+ private const bool display_file = false;
+ private const bool log_file = false;
/////////////////////////////////////////////////////////////////////
/// A regex, used to format the standard message.
@@ -67,7 +67,7 @@ public class Logger {
/// Limit log and statistics size to roughly 1 MB.
/////////////////////////////////////////////////////////////////////
- private static const int max_log_length = 1000000;
+ private const int max_log_length = 1000000;
private static int log_length;
diff --git a/src/utilities/paths.vala b/src/utilities/paths.vala
index 68c5384..f076ddc 100644
--- a/src/utilities/paths.vala
+++ b/src/utilities/paths.vala
@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
-// Copyright (c) 2011-2016 by Simon Schneegans
+// Copyright (c) 2011-2017 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
@@ -150,9 +150,7 @@ public class Paths : GLib.Object {
Gtk.IconTheme.get_default().append_search_path(path);
}
- Gtk.IconTheme.get_default().append_search_path("/usr/share/pixmaps/");
- Gtk.IconTheme.get_default().append_search_path("/usr/share/icons/hicolor/scalable/apps");
- Gtk.IconTheme.get_default().append_search_path("/usr/local/share/icons/hicolor/scalable/apps");
+ Gtk.IconTheme.get_default().append_search_path(GLib.Environment.get_home_dir() + ".icons");
// get global paths
var default_dir = GLib.File.new_for_path("/usr/share/gnome-pie/");
diff --git a/src/utilities/trigger.vala b/src/utilities/trigger.vala
index aeed3fb..ac236cd 100644
--- a/src/utilities/trigger.vala
+++ b/src/utilities/trigger.vala
@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
-// Copyright (c) 2011-2016 by Simon Schneegans
+// Copyright (c) 2011-2017 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