franglais125 / no-title-bar

Integrates maximized windows with the top panel
https://extensions.gnome.org/extension/1267/no-title-bar/
GNU General Public License v2.0
278 stars 40 forks source link

Fix deprecation warnings on 3.30 #97

Open trustin opened 5 years ago

trustin commented 5 years ago

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 commented 5 years ago

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

uniquePWD commented 5 years ago

These changes appear in #101

franglais125 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

@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.