pbxqdown / gnome-shell-extension-transparent-window

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

Incompatible with gnome 40 (X11) #15

Closed salazarbarrera closed 1 year ago

salazarbarrera commented 3 years ago

System information

Describe the problem

Extension works fine, but modifier can't be edited via GUI, only by modifying an integer key "/org/gnome/shell/extensions/TransparentWindow/modifier-key" on an empty schema. This is particularly hard because the extension doesn't use standard key codes (e.g. the value 8 doesn't represent backspace, but the left Alt key when Num Lock is off). This seems to be the same problem as #13, but it happens in X11, not only on Wayland as before.

Source code / logs

When one goes to settings, one is greeted by this error:

TypeError: Gdk.Keymap is undefined

Stack trace:
  @/home/$USER/.local/share/gnome-shell/extensions/transparentwindows.mdirshad07/prefs.js:17:16
  _init@resource:///org/gnome/Shell/Extensions/js/extensionsService.js:206:33
  OpenExtensionPrefsAsync/<@resource:///org/gnome/Shell/Extensions/js/extensionsService.js:122:28
  asyncCallback@resource:///org/gnome/gjs/modules/core/overrides/Gio.js:115:22
  run@resource:///org/gnome/Shell/Extensions/js/dbusService.js:177:20
  main@resource:///org/gnome/Shell/Extensions/js/main.js:19: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 3 years ago

Thanks for reporting the issue! The way Gnome handles modifier key code is nasty.. IIRC it is always the power of 2(e.g. 8 16 32 etc). This page may contain more details: https://wiki.archlinux.org/title/xmodmap For the Error "Gdk.Keymap is undefined", can you please check what GDK/GTK version is if it is in X11?

salazarbarrera commented 3 years ago

I'm not sure if this is what you are asking me, but here is the information I could gather

$ xdpyinfo

name of display:    :0
version number:    11.0
vendor string:    The X.Org Foundation
vendor release number:    12011000
X.Org version: 1.20.11

That's the X.Org version. Since we are talking about Gnome 40.3, gnome-shell depends on gtk4 (current version: gtk4-1:4.2.1-2 ).

$ pacman -Qi gnome-shell|grep Depends

Depends On : accountsservice  gcr  gjs  gnome-bluetooth  upower  gnome-session  gtk4  gnome-settings-daemon  gnome-themes-extra  gsettings-desktop-schemas  libcanberra-pulse  libgdm  libsecret  mutter  nm-connection-editor  unzip  gstreamer  libibus  gnome-autoar  gnome-disk-utility  gst-plugin-pipewire  libmutter-8.so=0-64

But again, I'm not sure if that was what you were asking me.

pbxqdown commented 3 years ago

Thanks. It seems that it is the Gtk4 rather than X11 that caused the issue given the info. Gnome40 is the first version adapting gtk4: https://www.zdnet.com/article/gnome-drops-3-x-versioning-to-shift-to-gnome-40-for-next-release/ I'm using ubuntu and the community seems to keep using Gnome38 and gtk3 for potential issue of new gtk4:https://www.linuxuprising.com/2021/04/how-to-install-gnome-40-on-ubuntu-2104.html#:~:text=Ubuntu%2021.04%2C%20which%20was%20released,is%20neither%20official%20nor%20stable.

I don't have a gnome40 environment currently, but may get some gnome40 VM to debug later or wait until ubuntu community introduces new Gnome version.. But please let me know if you have further findings about equivalence of Gdk.Keymap in GTK4 or a proper way to detect modifier key event in GTK4.

salazarbarrera commented 3 years ago

I haven't developed for gnome, so I'm not familiar with doing stuff with keys beyond modifying the already existing ones. BUT, here are the old and the new documentations of gtk4 on keyboard handling, maybe it can help you. I'll try to read more about the topic in case I can help you.

Edit: Also, gdk3 documentation recommends replacing get_default() with get_for_display(), apparently (because get_default was marked as deprecated since 3.22).

pbxqdown commented 3 years ago

Thanks for the info! The get_for_display might be a quick fix. Please try it if you could. The shell extension code is located at ~/.local/share/gnome-shell/extensions/transparent-window@pbxqdown.github.com. Try modify it locally and reload extension.

Actually I did some exploration before on new GTK and found that they deprecated Keymap struct. The hard part is, i didn't find a suitable way to listen to modifer-press event and get key code, like Keymap struct did. For old GTK's Keymap struct, it can be connected with "state_changed" signal, and Keymap.get_modifier_state would get the key code. See: https://github.com/pbxqdown/gnome-shell-extension-transparent-window/blob/7ac02c501e1b82ba6a60d9f59477808976bf4c0c/extension.js#L155

darkcircle commented 1 year ago

so ... Is it fixed?

pbxqdown commented 1 year ago

so ... Is it fixed?

The extension's main functionality works with latest gnome. If you are not able to edit modifier key by pressing the key, try use following modifer key code list to calculate hotkey code(E.g. Ctrl+Alt is 4 + 8 = 12): Shift 1 AltGr 2 Control 4 Alt 8 ShiftL 16 ShiftR 32 CtrlL 64 CtrlR 128 CapsShift 256 https://man7.org/linux/man-pages/man5/keymaps.5.html

igolskyi commented 1 year ago

image It works with Gnome Shell v. 42.5

github-actions[bot] commented 1 year ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 1 year ago

This issue was closed because it has been inactive for 15 days since being marked as stale.