Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deprecation warnings on 3.30 #97

Open
trustin opened this issue Sep 19, 2018 · 5 comments
Open

Fix deprecation warnings on 3.30 #97

trustin opened this issue Sep 19, 2018 · 5 comments

Comments

@trustin
Copy link

trustin commented Sep 19, 2018

It seems like the current behavior of UInt8Array.toString() has been deprecated. GNOME 3.30 keeps producing a warning message about this into syslog. The following patch fixed the problem for me, but I'm not an expert on GNOME extension programming, so I'd like to leave this to the author:

diff --git decoration.js decoration.js
index e78db85..8d7eeab 100644
--- decoration.js
+++ decoration.js
@@ -9,6 +9,8 @@ const Shell = imports.gi.Shell;
 const Config = imports.misc.config;
 const Util = imports.misc.util;
 
+const ByteArray = imports.byteArray;
+
 const Me = imports.misc.extensionUtils.getCurrentExtension();
 const Utils = Me.imports.utils;
 
@@ -185,7 +187,7 @@ var Decoration = new Lang.Class({
         if (xwindow) {
             let xwininfo = GLib.spawn_command_line_sync('xwininfo -children -id 0x%x'.format(xwindow));
             if (xwininfo[0]) {
-                let str = xwininfo[1].toString();
+                let str = ByteArray.toString(xwininfo[1]);
 
                 /**
                  * The X ID of the window is the one preceding the target window's title.
@@ -211,7 +213,7 @@ var Decoration = new Lang.Class({
         // is not available.
         let result = GLib.spawn_command_line_sync('xprop -root _NET_CLIENT_LIST');
         if (result[0]) {
-            let str = result[1].toString();
+            let str = ByteArray.toString(result[1]);
 
             // Get the list of window IDs.
             if (str.match(/0x[0-9a-f]+/g) == null)
@@ -224,7 +226,7 @@ var Decoration = new Lang.Class({
                 let result = GLib.spawn_command_line_sync(cmd);
 
                 if (result[0]) {
-                    let output = result[1].toString();
+                    let output = ByteArray.toString(result[1]);
                     let isManaged = output.indexOf("_NO_TITLE_BAR_ORIGINAL_STATE(CARDINAL)") > -1;
                     if (isManaged) {
                         continue;
@@ -267,7 +269,7 @@ var Decoration = new Lang.Class({
             return win._noTitleBarOriginalState = State.UNKNOWN;
         }
 
-        let str = xprops[1].toString();
+        let str = ByteArray.toString(xprops[1]);
         let m = str.match(/^_NO_TITLE_BAR_ORIGINAL_STATE\(CARDINAL\) = ([0-9]+)$/m);
         if (m) {
             let state = !!parseInt(m[1]);

Note: There was one more place that calls toString() but I wasn't sure if it is for an UInt8Array, so I left it as it is.

@storm119
Copy link

Seems this patch worked on my side too (Manjaro Gnome)...thank you!

@uniquePWD
Copy link
Contributor

These changes appear in #101

@franglais125
Copy link
Owner

Thanks a lot for looking into this, and for providing the solution! Do you know how far back this works? I just want to make sure we don't break the extension on old versions.

At the moment, we claim to support Gnome Shell 3.18 to 3.30.

@trustin
Copy link
Author

trustin commented Nov 5, 2018

I personally have no idea since I'm not an expert on GNOME's extension API. Perhaps we could check some version numbers and use the old APIs only for old versions? .. because otherwise my syslog would explode :-)

@andyholmes
Copy link

@franglais125

This is new as of GJS-1.54. A simple way to handle this in backwards-compatible fashion is like so:

if (possibleByteArray instanceof Uint8Array) {
    possibleByteArray = imports.byteArray.toString(possibleByteArray);
}

I'm pretty sure this how gnome-shell does it, too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants