pbxqdown / gnome-shell-extension-transparent-window

Gnome shell extension which changes the opacity of window through mouse operation.
47 stars 12 forks source link

The extension is incompatible with the current GNOME version 42.1 #17

Closed rogue-agent closed 2 years ago

rogue-agent commented 2 years ago

System information

You can obtain the GNOME version by:

  1. Open the Activities overview and start typing About.
  2. Click on About to open the panel. A window appears showing information about your system, including your distribution's name and the GNOME version.

Describe the problem

Downloaded from extensions page(latest) (latest) and manually installed

Source code / logs

`Error: No property margin on GtkBox

Stack trace:
  _init/Gtk.Widget.prototype._init@resource:///org/gnome/gjs/modules/core/overrides/Gtk.js:55:50
  _init@/home/wz/.local/share/gnome-shell/extensions/transparent-window@pbxqdown.github.com/prefs.js:62:26
  wrapper@resource:///org/gnome/gjs/modules/script/_legacy.js:83:27
  buildPrefsWidget@/home/wz/.local/share/gnome-shell/extensions/transparent-window@pbxqdown.github.com/prefs.js:98:16
  _init@resource:///org/gnome/Shell/Extensions/js/extensionPrefsDialog.js:32:44
  ExtensionPrefsDialog@resource:///org/gnome/Shell/Extensions/js/extensionPrefsDialog.js:10:4
  OpenExtensionPrefsAsync/<@resource:///org/gnome/Shell/Extensions/js/extensionsService.js:129:33
  asyncCallback@resource:///org/gnome/gjs/modules/core/overrides/Gio.js:115:22
  run@resource:///org/gnome/Shell/Extensions/js/dbusService.js:186:20
  main@resource:///org/gnome/Shell/Extensions/js/main.js:22:13
  run@resource:///org/gnome/gjs/modules/script/package.js:206:19
  start@resource:///org/gnome/gjs/modules/script/package.js:190:8
  @/usr/share/gnome-shell/org.gnome.Shell.Extensions:1:17
  `
pbxqdown commented 2 years ago

It seems that the issue is due to GTK4 deprecated margin property with margin-*(e.g. margin-top, margin-bottom) instead. Articles: https://docs.gtk.org/gtk4/migrating-3to4.html https://discourse.gnome.org/t/why-did-margin-property-disappeared-in-gtk4/5530 I don't have Gnome 42 environment, could you manually modify prefs.js containing margin keyword and and see whether it works? Thanks.

igolskyi commented 2 years ago

Thank you @pbxqdown for the suggestion, I changed "margin" to "margin-start" for example. But I got the following error:

TypeError: ModifierKeyLabel.set_line_wrap is not a function

Stack trace:
  _init@/home/igolskyi/.local/share/gnome-shell/extensions/transparent-window@pbxqdown.github.com/prefs.js:64:22
  wrapper@resource:///org/gnome/gjs/modules/script/_legacy.js:83:27
  buildPrefsWidget@/home/igolskyi/.local/share/gnome-shell/extensions/transparent-window@pbxqdown.github.com/prefs.js:98:16
  _init@resource:///org/gnome/Shell/Extensions/js/extensionPrefsDialog.js:32:44
  ExtensionPrefsDialog@resource:///org/gnome/Shell/Extensions/js/extensionPrefsDialog.js:10:4
  OpenExtensionPrefsAsync/<@resource:///org/gnome/Shell/Extensions/js/extensionsService.js:129:33
  asyncCallback@resource:///org/gnome/gjs/modules/core/overrides/Gio.js:115:22
  run@resource:///org/gnome/Shell/Extensions/js/dbusService.js:186:20
  main@resource:///org/gnome/Shell/Extensions/js/main.js:22:13
  run@resource:///org/gnome/gjs/modules/script/package.js:206:19
  start@resource:///org/gnome/gjs/modules/script/package.js:190:8
  @/usr/share/gnome-shell/org.gnome.Shell.Extensions:1:17

Unfortunately, it seems that this will also not be the last error.

P.S. Fantastic, now the extension is working even with this error. Thank you.

pbxqdown commented 2 years ago

Thanks @igolskyi for helping with this. It seems that gtk4 renames set_line_wrap with set_wrap, maybe you can try and see whether it fixes the issue? https://docs.gtk.org/gtk4/method.Label.set_wrap.html

igolskyi commented 2 years ago

Yes, I renamed set_line_wrap with set_wrap.

Next error:

TypeError: ModifierKeyBox.pack_start is not a function

Stack trace:
  _init@/home/igolskyi/.local/share/gnome-shell/extensions/transparent-window@pbxqdown.github.com/prefs.js:74:20
  wrapper@resource:///org/gnome/gjs/modules/script/_legacy.js:83:27
  buildPrefsWidget@/home/igolskyi/.local/share/gnome-shell/extensions/transparent-window@pbxqdown.github.com/prefs.js:98:16
  _init@resource:///org/gnome/Shell/Extensions/js/extensionPrefsDialog.js:32:44
  ExtensionPrefsDialog@resource:///org/gnome/Shell/Extensions/js/extensionPrefsDialog.js:10:4
  OpenExtensionPrefsAsync/<@resource:///org/gnome/Shell/Extensions/js/extensionsService.js:129:33
  asyncCallback@resource:///org/gnome/gjs/modules/core/overrides/Gio.js:115:22
  run@resource:///org/gnome/Shell/Extensions/js/dbusService.js:186:20
  main@resource:///org/gnome/Shell/Extensions/js/main.js:22:13
  run@resource:///org/gnome/gjs/modules/script/package.js:206:19
  start@resource:///org/gnome/gjs/modules/script/package.js:190:8
  @/usr/share/gnome-shell/org.gnome.Shell.Extensions:1:17

Probably I'm trying to rename to gtk_box_prepend() as described here: https://docs.gtk.org/gtk4/migrating-3to4.html#adapt-to-gtkbox-api-changes

No, it's not helped

TypeError: ModifierKeyBox.gtk_box_prepend is not a function
pbxqdown commented 2 years ago

maybe try ModifierKeyBox.box_prepend, or ModifierKeyBox.prepend?

igolskyi commented 2 years ago

So prepend worked. Next error: TypeError: ModifierKeyBox.add is not a function

pbxqdown commented 2 years ago

gosh gtk4 changes everything😂 maybe try ModifierKeyBox.append? the definition is in: https://docs.gtk.org/gtk4/class.Box.html

igolskyi commented 2 years ago

So I replaced .add() with .append()

Next, I commented this line:

// widget.show_all();

Because: The function gtk_widget_show_all(), the GtkWidget:no-show-all property, and its getter and setter have been removed in GTK 4, so you should stop using them.

And finally no more errors :)

image

igolskyi commented 2 years ago

All changes I've tested for GNOME Shell 42.0:

margin --> "margin-start"
set_line_wrap() --> set_wrap()
pack_start() --> prepend()
add() --> append()

// widget.show_all();
pbxqdown commented 2 years ago

Thanks @igolskyi This is awesome! I saw that GTK4 is included since Gnome40: https://help.gnome.org/misc/release-notes/40.0/developers.html.en so maybe this will fix all Gnome40 upwards version?

igolskyi commented 2 years ago

Most likely yes, but we need more feedback on other versions of Gnome40.

I also think that it will not be worse if you update the extension and more people can test it :)

pbxqdown commented 2 years ago

Since I haven't upgraded since gnome 3.36 yet, i'm not able to verify.. Please let me know if the extension works on Gnome40 if you have used it. There is a version control feature of the extension: https://github.com/pbxqdown/gnome-shell-extension-transparent-window/blob/239529a38dc6aeb5c645c0692b9cf1e52b7c0a4e/extension.js#L112 Maybe we can define a gnome_at_least_40_1 variable to make it compatible with both GNOME3X and Gnome 4X. Version schema of Gnome 40:https://www.zdnet.com/article/gnome-drops-3-x-versioning-to-shift-to-gnome-40-for-next-release/

igolskyi commented 2 years ago

All the changes I've checked for GNOME Shell 42.0:

let gnome_at_least_40_1;
...
...
function init() {
  ...
  ...
  gnome_at_least_3_38 = isVersionGreaterOrEqual(3, 38);
  gnome_at_least_40_1 = isVersionGreaterOrEqual(40, 1);
}
...
...
if (gnome_at_least_40_1) {

After restart's Alt+F2 r extension still works.

pbxqdown commented 2 years ago

Nice! Could you submit a MR for this? It seems that there is no version check for prefs.js yet

igolskyi commented 2 years ago

Good idea. Could you please review for https://github.com/pbxqdown/gnome-shell-extension-transparent-window/pull/18

P.S. //TODO:support multi-monitor https://github.com/pbxqdown/gnome-shell-extension-transparent-window/blob/master/extension.js#L117 would be amazing ;)

pbxqdown commented 2 years ago

Good idea. Could you please review for #18

P.S. //TODO:support multi-monitor https://github.com/pbxqdown/gnome-shell-extension-transparent-window/blob/master/extension.js#L117 would be amazing ;)

Yep, i think it is doable, but the GTK API is ever-changing and hard to find reference😂

igolskyi commented 2 years ago

@pbxqdown I deleted this extension with our local changes. And installed the new version. All works on Gnome 42 image image

igolskyi commented 2 years ago

@rogue-agent could you please check if the new version works?

rogue-agent commented 2 years ago

image image

rogue-agent commented 2 years ago

Disabled all other window decorations, extensions and themes.

pbxqdown commented 2 years ago

@rogue-agent try change log verbose level to "Debug" and sudo journalctl -f /usr/bin/gnome-shell may print more debug details

rogue-agent commented 2 years ago

image It recognizes me pressing Ctrl + V and other button combinations.

pbxqdown commented 2 years ago

Yes so the hotkey detection works. I saw your hotkey code is set to 14. I think you are not pressing the correct hotkey?

rogue-agent commented 2 years ago

Is this hotkey activated? I thought this was basic transparency like in Windows. What hotkey combination?

pbxqdown commented 2 years ago

The default modifier key is Alt which has modifier key 8. You can press combination of key on preference window and it will change accordingly. Following are list of modifier key code(https://man7.org/linux/man-pages/man5/keymaps.5.html): Shift 1 AltGr 2 Control 4 Alt 8 ShiftL 16 ShiftR 32 CtrlL 64 CtrlR 128 CapsShift 256

rogue-agent commented 2 years ago

I pressed them in order you wrote. I don't know what there is control and shift if there is Control and Shift for left and right in the end. image

pbxqdown commented 2 years ago

if you want ctrl+shift, the modifier key would be 1+4 which is 5. You can then set 5 as the keycode and hover on a window, press ctrl+shift and scroll the mouse wheel

rogue-agent commented 2 years ago

I don't know. I set it to 18 for AltGr+ShiftL, I'm on a laptop so I used two finger scroll. Nothing happened

pbxqdown commented 2 years ago

maybe try default setting with Alt key(code is 8)? Under normal condition there would be logs of: [DEBUG][TransparentWindow] Modifier key pressed, listening to scroll

rogue-agent commented 2 years ago

It worked. I was able to scroll with the touchpad and the window changed opacity. Extensions window, Lutris, Filezilla, Geary, Calendar, Junction, Fragments, Banking, NewsFlash, EasySSH and Authenticator didn't work. I haven't tested others.

igolskyi commented 2 years ago

Hm... In my case https://github.com/pbxqdown/gnome-shell-extension-transparent-window/issues/17#issuecomment-1140498627 the key code of left Alt is 24 (Ubuntu 22.04, Gnome-Shell 42)

pbxqdown commented 2 years ago

@igolskyi Yep guess different regions have different keyboard layout/code. @rogue-agent Awesome so we can verify the extension work on Gnome42.

igolskyi commented 2 years ago

@pbxqdown also, check if nothing is broken on older versions.

pbxqdown commented 2 years ago

Yes, the extension works on my GNOME 3.36. And older version's code keeps untouched.

igolskyi commented 2 years ago

@pbxqdown probably, you can close this issue :)

pbxqdown commented 2 years ago

@igolskyi I suddenly have an idea why your Alt key code is 24. Do you have a keyboard with numlock? Since numlock's keycode is 16, 16(NUMSlock)+8(ALT) would get 24. This PR may mask off numlock key: https://github.com/pbxqdown/gnome-shell-extension-transparent-window/pull/19

igolskyi commented 2 years ago

@pbxqdown Yes, my laptop with numlock :)