[gnome-shell] windowManager: Use g-s-d wacom dbus helpers to update pad leds/oleds



commit 0008ef70e10ce29ab9236b94e7d6bba9f7b484fb
Author: Carlos Garnacho <carlosg gnome org>
Date:   Wed Dec 28 13:03:53 2016 +0100

    windowManager: Use g-s-d wacom dbus helpers to update pad leds/oleds
    
    This keeps feedback on the device itself in sync with the overall pad
    state, a feature we had previously through g-s-d.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=776543

 js/ui/windowManager.js |   43 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 43 insertions(+), 0 deletions(-)
---
diff --git a/js/ui/windowManager.js b/js/ui/windowManager.js
index 624eb73..324927f 100644
--- a/js/ui/windowManager.js
+++ b/js/ui/windowManager.js
@@ -33,6 +33,25 @@ const UNDIM_TIME = 0.250;
 const DISPLAY_REVERT_TIMEOUT = 20; // in seconds - keep in sync with mutter
 const ONE_SECOND = 1000; // in ms
 
+const GSD_WACOM_BUS_NAME = 'org.gnome.SettingsDaemon.Wacom';
+const GSD_WACOM_OBJECT_PATH = '/org/gnome/SettingsDaemon/Wacom';
+
+const GsdWacomIface = '<node name="/org/gnome/SettingsDaemon/Wacom"> \
+<interface name="org.gnome.SettingsDaemon.Wacom"> \
+  <method name="SetGroupModeLED"> \
+    <arg name="device_path" direction="in" type="s"/> \
+    <arg name="group" direction="in" type="u"/> \
+    <arg name="mode" direction="in" type="u"/> \
+  </method> \
+  <method name="SetOLEDLabels"> \
+    <arg name="device_path" direction="in" type="s"/> \
+    <arg name="labels" direction="in" type="as"/> \
+  </method> \
+  </interface> \
+</node>';
+
+const GsdWacomProxy = Gio.DBusProxy.makeProxyWrapper(GsdWacomIface);
+
 const DisplayChangeDialog = new Lang.Class({
     Name: 'DisplayChangeDialog',
     Extends: ModalDialog.ModalDialog,
@@ -925,6 +944,30 @@ const WindowManager = new Lang.Class({
             Main.osdWindowManager.show(monitorIndex, icon, label, null);
         }));
 
+        this._gsdWacomProxy = new GsdWacomProxy(Gio.DBus.session, GSD_WACOM_BUS_NAME,
+                                                GSD_WACOM_OBJECT_PATH,
+                                                Lang.bind(this, function(proxy, error) {
+                                                    if (error) {
+                                                        log(error.message);
+                                                        return;
+                                                    }
+                                                }));
+
+        global.display.connect('pad-mode-switch', Lang.bind(this, function (display, pad, group, mode) {
+            let labels = [];
+
+            //FIXME: Fix num buttons
+            for (let i = 0; i < 50; i++) {
+                let str = display.get_pad_action_label(pad, Meta.PadActionType.BUTTON, i);
+                labels.push(str ? str: '');
+            }
+
+            if (this._gsdWacomProxy) {
+                this._gsdWacomProxy.SetOLEDLabelsRemote(pad.get_device_node(), labels);
+                this._gsdWacomProxy.SetGroupModeLEDRemote(pad.get_device_node(), group, mode);
+            }
+        }));
+
         Main.overview.connect('showing', Lang.bind(this, function() {
             for (let i = 0; i < this._dimmedWindows.length; i++)
                 this._undimWindow(this._dimmedWindows[i]);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]