aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Hua <william.hua@canonical.com>2014-01-30 18:15:07 +0000
committerTarmac <Unknown>2014-01-30 18:15:07 +0000
commit30cc82bcb9a9cff416ae0eadf46024c84d450659 (patch)
treeb503d2b8cda02665b3e4fdcdfa4f6cd760996dd5
parent51e6bbedaf84074e96d9fb355edeb172212526cb (diff)
parent36b1e9f99cd85792a36b20047db2e1d09e0d53c4 (diff)
downloadayatana-indicator-keyboard-30cc82bcb9a9cff416ae0eadf46024c84d450659.tar.gz
ayatana-indicator-keyboard-30cc82bcb9a9cff416ae0eadf46024c84d450659.tar.bz2
ayatana-indicator-keyboard-30cc82bcb9a9cff416ae0eadf46024c84d450659.zip
Replace BAMF with Unity window stack API calls.
Approved by PS Jenkins bot, Charles Kerr.
-rw-r--r--configure.ac4
-rw-r--r--data/Makefile.am6
-rw-r--r--debian/control1
-rw-r--r--lib/Makefile.am14
-rw-r--r--lib/main.vala96
-rw-r--r--lib/unity-greeter.vala (renamed from lib/greeter.vala)2
-rw-r--r--lib/window-stack.vala37
7 files changed, 111 insertions, 49 deletions
diff --git a/configure.ac b/configure.ac
index 5a333009..dc2f0bae 100644
--- a/configure.ac
+++ b/configure.ac
@@ -78,10 +78,6 @@ PKG_CHECK_MODULES([LIGHTDM], [liblightdm-gobject-1])
AC_SUBST([LIGHTDM_CFLAGS])
AC_SUBST([LIGHTDM_LIBS])
-PKG_CHECK_MODULES([BAMF], [libbamf3])
-AC_SUBST([BAMF_CFLAGS])
-AC_SUBST([BAMF_LIBS])
-
m4_include([m4/gcov.m4])
AC_TDD_GCOV
AM_CONDITIONAL([HAVE_GCOV], [test "x$ac_cv_check_gcov" = xyes])
diff --git a/data/Makefile.am b/data/Makefile.am
index 29ad3e7a..4f0b7175 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -36,9 +36,9 @@ dist_service_DATA = indicator-keyboard.service
servicedir = $(DBUS_SERVICE_DIR)
indicator-keyboard.service:
- $(AM_V_GEN) (echo '[D-BUS Service]'; \
- echo 'Name=com.canonical.indicator.keyboard'; \
- echo 'Exec=${libexecdir}/indicator-keyboard-service --use-gtk --use-bamf') > $@.tmp && \
+ $(AM_V_GEN) (echo '[D-BUS Service]'; \
+ echo 'Name=com.canonical.indicator.keyboard'; \
+ echo 'Exec=${libexecdir}/indicator-keyboard-service --use-gtk') > $@.tmp && \
mv $@.tmp $@
dist_indicator_DATA = com.canonical.indicator.keyboard
diff --git a/debian/control b/debian/control
index 63e20ab6..4148227e 100644
--- a/debian/control
+++ b/debian/control
@@ -8,7 +8,6 @@ Build-Depends: debhelper (>= 9.0.0),
dh-translations,
dbus,
libaccountsservice-dev,
- libbamf3-dev,
libgee-dev,
libgirepository1.0-dev,
libgnome-desktop-3-dev,
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 72f5f949..0e7cd266 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -5,10 +5,11 @@ AM_LDFLAGS = -lm
AM_VALAFLAGS = --metadatadir $(top_srcdir)/deps \
--vapidir $(top_srcdir)/deps
-indicator_keyboard_service_SOURCES = main.vala \
- source.vala \
- common.vala \
- greeter.vala
+indicator_keyboard_service_SOURCES = main.vala \
+ source.vala \
+ common.vala \
+ window-stack.vala \
+ unity-greeter.vala
indicator_keyboard_service_VALAFLAGS = $(AM_VALAFLAGS) \
--pkg gee-1.0 \
--pkg posix \
@@ -20,8 +21,7 @@ indicator_keyboard_service_VALAFLAGS = $(AM_VALAFLAGS) \
--pkg Gkbd-3.0 \
--pkg ibus-1.0 \
--pkg accountsservice \
- --pkg liblightdm-gobject-1 \
- --pkg libbamf3
+ --pkg liblightdm-gobject-1
indicator_keyboard_service_CFLAGS = $(AM_CFLAGS) \
$(GEE_CFLAGS) \
$(PANGOCAIRO_CFLAGS) \
@@ -32,7 +32,6 @@ indicator_keyboard_service_CFLAGS = $(AM_CFLAGS) \
$(IBUS_CFLAGS) \
$(ACCOUNTSSERVICE_CFLAGS) \
$(LIGHTDM_CFLAGS) \
- $(BAMF_CFLAGS) \
$(COVERAGE_CFLAGS)
indicator_keyboard_service_LDFLAGS = $(AM_LDFLAGS) \
$(GEE_LIBS) \
@@ -44,5 +43,4 @@ indicator_keyboard_service_LDFLAGS = $(AM_LDFLAGS) \
$(IBUS_LIBS) \
$(ACCOUNTSSERVICE_LIBS) \
$(LIGHTDM_LIBS) \
- $(BAMF_LIBS) \
$(COVERAGE_LDFLAGS)
diff --git a/lib/main.vala b/lib/main.vala
index 66147b18..ffc558ba 100644
--- a/lib/main.vala
+++ b/lib/main.vala
@@ -24,15 +24,16 @@ public class Indicator.Keyboard.Service : Object {
private bool force;
private bool use_gtk;
- private bool use_bamf;
private MainLoop? loop;
private Settings indicator_settings;
private Settings source_settings;
private Settings per_window_settings;
private SList<Act.User> users;
- private Bamf.Matcher? matcher;
- private Gee.HashMap<string, uint>? window_sources;
+
+ private WindowStack? window_stack;
+ private Gee.HashMap<uint, uint>? window_sources;
+ private uint focused_window_id;
private Source[]? sources;
@@ -41,7 +42,7 @@ public class Indicator.Keyboard.Service : Object {
private MenuModel? menu_model;
private Menu? sources_menu;
- private Greeter? greeter;
+ private UnityGreeter? unity_greeter;
private string? greeter_user;
private uint lightdm_current;
@@ -49,7 +50,6 @@ public class Indicator.Keyboard.Service : Object {
public Service (ref unowned string[] args) {
force = "--force" in args;
use_gtk = "--use-gtk" in args;
- use_bamf = "--use-bamf" in args;
if (use_gtk) {
use_gtk = Gtk.init_check (ref args);
@@ -64,9 +64,15 @@ public class Indicator.Keyboard.Service : Object {
Bus.watch_name (BusType.SESSION,
(!) name,
BusNameWatcherFlags.NONE,
- handle_name_appeared,
- handle_name_vanished);
+ handle_unity_greeter_name_appeared,
+ handle_unity_greeter_name_vanished);
}
+ } else {
+ Bus.watch_name (BusType.SESSION,
+ "com.canonical.Unity.WindowStack",
+ BusNameWatcherFlags.NONE,
+ handle_window_stack_name_appeared,
+ handle_window_stack_name_vanished);
}
indicator_settings = new Settings ("com.canonical.indicator.keyboard");
@@ -127,9 +133,9 @@ public class Indicator.Keyboard.Service : Object {
[DBus (visible = false)]
private void update_greeter_user () {
- if (greeter_user == null && greeter != null) {
+ if (greeter_user == null && unity_greeter != null) {
try {
- greeter_user = ((!) greeter).get_active_entry ();
+ greeter_user = ((!) unity_greeter).get_active_entry ();
} catch (IOError error) {
warning ("error: %s", error.message);
}
@@ -464,17 +470,30 @@ public class Indicator.Keyboard.Service : Object {
[DBus (visible = false)]
private void update_window_sources () {
- if (use_bamf && !is_login_user ()) {
+ if (window_stack != null) {
var group_per_window = per_window_settings.get_boolean ("group-per-window");
if (group_per_window != (window_sources != null)) {
if (group_per_window) {
- window_sources = new Gee.HashMap<string, uint> ();
- matcher = Bamf.Matcher.get_default ();
- ((!) matcher).active_window_changed.connect (handle_active_window_changed);
+ focused_window_id = 0;
+
+ try {
+ var windows = ((!) window_stack).get_window_stack ();
+
+ foreach (var window in windows) {
+ if (window.focused) {
+ focused_window_id = window.window_id;
+ break;
+ }
+ }
+ } catch (IOError error) {
+ warning ("error: %s", error.message);
+ }
+
+ window_sources = new Gee.HashMap<uint, uint> ();
+ ((!) window_stack).focused_window_changed.connect (handle_focused_window_changed);
} else {
- ((!) matcher).active_window_changed.disconnect (handle_active_window_changed);
- matcher = null;
+ ((!) window_stack).focused_window_changed.disconnect (handle_focused_window_changed);
window_sources = null;
}
}
@@ -487,22 +506,20 @@ public class Indicator.Keyboard.Service : Object {
}
[DBus (visible = false)]
- private void handle_active_window_changed (Bamf.View? old_view, Bamf.View? new_view) {
- if (old_view != null) {
- ((!) window_sources)[((!) old_view).path] = source_settings.get_uint ("current");
- }
+ private void handle_focused_window_changed (uint window_id, string app_id, uint stage) {
+ ((!) window_sources)[focused_window_id] = source_settings.get_uint ("current");
- if (new_view != null) {
- if (!((!) window_sources).has_key (((!) new_view).path)) {
- var default_group = per_window_settings.get_int ("default-group");
+ if (!(((!) window_sources).has_key (window_id))) {
+ var default_group = per_window_settings.get_int ("default-group");
- if (default_group >= 0) {
- source_settings.set_uint ("current", (uint) default_group);
- }
- } else {
- source_settings.set_uint ("current", ((!) window_sources)[((!) new_view).path]);
+ if (default_group >= 0) {
+ source_settings.set_uint ("current", (uint) default_group);
}
+ } else {
+ source_settings.set_uint ("current", ((!) window_sources)[window_id]);
}
+
+ focused_window_id = window_id;
}
[DBus (visible = false)]
@@ -771,18 +788,33 @@ public class Indicator.Keyboard.Service : Object {
}
[DBus (visible = false)]
- private void handle_name_appeared (DBusConnection connection, string name, string name_owner) {
+ private void handle_unity_greeter_name_appeared (DBusConnection connection, string name, string name_owner) {
+ try {
+ unity_greeter = Bus.get_proxy_sync (BusType.SESSION, name, "/list");
+ ((!) unity_greeter).entry_selected.connect (handle_entry_selected);
+ } catch (IOError error) {
+ warning ("error: %s", error.message);
+ }
+ }
+
+ [DBus (visible = false)]
+ private void handle_unity_greeter_name_vanished (DBusConnection connection, string name) {
+ unity_greeter = null;
+ }
+
+ [DBus (visible = false)]
+ private void handle_window_stack_name_appeared (DBusConnection connection, string name, string name_owner) {
try {
- greeter = Bus.get_proxy_sync (BusType.SESSION, name, "/list");
- ((!) greeter).entry_selected.connect (handle_entry_selected);
+ window_stack = Bus.get_proxy_sync (BusType.SESSION, name, "/com/canonical/Unity/WindowStack");
+ update_window_sources ();
} catch (IOError error) {
warning ("error: %s", error.message);
}
}
[DBus (visible = false)]
- private void handle_name_vanished (DBusConnection connection, string name) {
- greeter = null;
+ private void handle_window_stack_name_vanished (DBusConnection connection, string name) {
+ window_stack = null;
}
[DBus (visible = false)]
diff --git a/lib/greeter.vala b/lib/unity-greeter.vala
index c378bbd5..2cdfe05c 100644
--- a/lib/greeter.vala
+++ b/lib/unity-greeter.vala
@@ -17,7 +17,7 @@
*/
[DBus (name="com.canonical.UnityGreeter.List")]
-public interface Greeter : Object {
+public interface UnityGreeter : Object {
public abstract string get_active_entry () throws IOError;
public abstract void set_active_entry (string entry_name) throws IOError;
diff --git a/lib/window-stack.vala b/lib/window-stack.vala
new file mode 100644
index 00000000..980eba4f
--- /dev/null
+++ b/lib/window-stack.vala
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2013 Canonical Ltd.
+ *
+ * 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
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors: William Hua <william.hua@canonical.com>
+ */
+
+public struct WindowInfo {
+
+ public uint window_id;
+ public string app_id;
+ public bool focused;
+ public uint stage;
+}
+
+[DBus (name="com.canonical.Unity.WindowStack")]
+public interface WindowStack : Object {
+
+ public abstract string get_app_id_from_pid (uint pid) throws IOError;
+ public abstract string[] get_window_properties (uint window_id, string app_id, string[] property_names) throws IOError;
+ public abstract WindowInfo[] get_window_stack () throws IOError;
+
+ public signal void focused_window_changed (uint window_id, string app_id, uint stage);
+ public signal void window_created (uint window_id, string app_id);
+ public signal void window_destroyed (uint window_id, string app_id);
+}