ch11ng / exwm

Emacs X Window Manager
2.85k stars 134 forks source link

`M-w` bindig hijacked by some applications. #859

Open orencio opened 2 years ago

orencio commented 2 years ago

Some applications hijack M-w binding for some minor modes.

For example, flatpak Spotify application:

$ flatpak list | grep spotify
Spotify com.spotify.Client  1.1.68.632.g2b11de83    stable  system

$ ps aux | grep spotify
andy       60839  0.0  0.0   2464   108 ?        S    11:00   0:00 bwrap --args 38 spotify
andy       60844  1.3  2.8 2859348 230712 ?      Sl   11:00   0:09 /app/extra/share/spotify/spotify --force-device-scale-factor=1.0
andy       60849  0.0  0.9 389416 75884 ?        S    11:00   0:00 /app/extra/share/spotify/spotify --type=zygote --no-zygote-sandbox --no-sandbox --force-device-scale-factor=1.0 --log-file=/app/extra/share/spotify/debug.log --log-severity=disable --user-agent-product=Chrome/91.0.4472.164 Spotify/1.1.68.632 --lang=es
andy       60850  0.0  0.9 389416 76048 ?        S    11:00   0:00 /app/extra/share/spotify/spotify --type=zygote --no-sandbox --force-device-scale-factor=1.0 --log-file=/app/extra/share/spotify/debug.log --log-severity=disable --user-agent-product=Chrome/91.0.4472.164 Spotify/1.1.68.632 --lang=es
andy       60865  0.3  1.4 1192012 114564 ?      Sl   11:00   0:02 /app/extra/share/spotify/spotify --type=gpu-process --field-trial-handle=***--no-sandbox --log-file=/app/extra/share/spotify/debug.log --log-severity=disable --user-agent-product=Chrome/91.0.4472.164 Spotify/1.1.68.632 --lang=es --gpu-preferences=***= --log-file=/app/extra/share/spotify/debug.log --shared-files
andy       60874  0.0  0.3 691004 30960 ?        Sl   11:00   0:00 /app/extra/share/spotify/spotify --type=utility --utility-sub-type=storage.mojom.StorageService --field-trial-handle=***--lang=en-US --service-sandbox-type=utility --no-sandbox --log-file=/app/extra/share/spotify/debug.log --log-severity=disable --user-agent-product=Chrome/91.0.4472.164 Spotify/1.1.68.632 --lang=es --log-file=/app/extra/share/spotify/debug.log --shared-files=v8_context_snapshot_data:100
andy       60875  0.0  1.2 766484 96436 ?        Sl   11:00   0:00 /app/extra/share/spotify/spotify --type=utility --utility-sub-type=network.mojom.NetworkService --field-trial-handle=*** --lang=en-US --service-sandbox-type=none --no-sandbox --log-file=/app/extra/share/spotify/debug.log --log-severity=disable --user-agent-product=Chrome/91.0.4472.164 Spotify/1.1.68.632 --lang=es --log-file=/app/extra/share/spotify/debug.log --shared-files=v8_context_snapshot_data:100
andy       60918  2.0  2.4 43364868 194124 ?     Sl   11:00   0:14 /app/extra/share/spotify/spotify --type=renderer --no-sandbox --force-device-scale-factor=1.0 --log-file=/app/extra/share/spotify/debug.log --field-trial-handle=*** --lang=en-US --log-file=/app/extra/share/spotify/debug.log --log-severity=disable --user-agent-product=Chrome/91.0.4472.164 Spotify/1.1.68.632 --disable-spell-checking --num-raster-threads=2 --enable-main-frame-before-activation --renderer-client-id=5 --shared-files=v8_context_snapshot_data:100

Launching this application (and switching to other workspace) causes M-w not to be recognized by Scratch buffer, org-mode.

If I press C-h k and the press M-w emacs doesn't detect I've pressed M-w.

This is commented in:

Is there anyway to prevent M-w to be hijacked?

orencio commented 2 years ago

Curious fact is that if I split the Spotify workspace in two windows and in the other window I switch to scratch buffer, then all workspaces attend correctly to M-w binding. Although I unsplit the Spotify workspace to maintain Spotify window alone.

medranocalvo commented 2 years ago

That's weird.

Please, follow the steps in https://unix.stackexchange.com/questions/59141/find-x-org-pointer-grab-owner/62252#62252 or https://unix.stackexchange.com/questions/23164/manipulating-x-key-and-pointer-grabs-on-the-command-line/273198 to check who's grabbing the key.

orencio commented 2 years ago

Hello, I've migrated to emacs 28.1 (Arch Linux) and I get same issue.

I attach Xorg.0.log file with grab info.

At the moment of creating the log, the apps whose was hijacking M-w key was electron (Element and Mattermost), and Spotify:

...
[ 62709.618]   Printing all registered grabs of client pid 2358 /usr/lib/electron17/electron --type=gpu-process --enable-crashpad --enable-crash-reporter=b9edf277-5ae2-4dc8-9afb-98088e78b01d,no_channel --user-data-dir=/home/user/.config/Element --gpu-preferences=UAAAAAAAAAAgAAAIAAAAAAAAAAAAAAAAAABgAAAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAABgAAAAAAAAAGAAAAAAAAAAIAAAAAAAAAAgAAAAAAAAACAAAAAAAAAA= --shared-files --field-trial-handle=0,1684284544763430908,4260445013085214435,131072 --enable-features=WebRTCPipeWireCapturer --disable-features=HardwareMediaKeyHandling,MediaSessionService,PlzServiceWorker,SpareRendererForSitePerProcess 
[ 62709.621]   Printing all registered grabs of client pid 11875 /app/extra/share/spotify/spotify --type=gpu-process --field-trial-handle=5432864910630463721,5842399891995256266,131072 --no-sandbox --log-severity=disable --user-agent-product=Chrome/96.0.4664.93 Spotify/1.1.77.643 --lang=en --user-data-dir=/home/user/.var/app/com.spotify.Client/config/spotify/User Data --gpu-preferences=UAAAAAAAAAAgAAAIAAAAAAAAAAAAAAAAAABgAAAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAABgAAAAAAAAAGAAAAAAAAAAIAAAAAAAAAAgAAAAAAAAACAAAAAAAAAA= --log-file=/app/extra/share/spotify/debug.log --shared-files 
...

I've probed to specify this and M-w continues hijacked:

(setq exwm-input-prefix-keys
      '(?\C-x
        ?\C-u
        ?\C-h
        ?\M-x
        ?\M-w
        ...
        ))

Regards.