amarullz / windowgestures

GNOME Extension to Manage window with touchpad gestures
https://amarullz.com/
GNU General Public License v2.0
63 stars 10 forks source link

Show desktop action sends a key to the desktop window and does not show the desktop. #18

Open smedir opened 1 year ago

smedir commented 1 year ago

https://github.com/amarullz/windowgestures/blob/2473192d5791fabc5a3a6c7e4ec83a7c93f61bb8/src/extension.js#L1872

So when the action is completed, it sends a 'd' key to the desktop window, which actually starts a search and shows a box for all files on the desktop that have 'd' in them.., and does not actually show the desktop...

I don't think the shortcut is activated on most distributions, and the gnome settings allow you to bind that shortcut actually to any combination.

There should be a way to make this call directly...

amarullz commented 1 year ago

New method for show-desktop (+hide non-active windows) still on development. It will not use shortcut.

smedir commented 1 year ago

New method for show-desktop (+hide non-active windows) still on development. It will not use shortcut.

So I was thinking about this...

There is no way to make this call directly in gnome wm that I know off. Yes, you can write the function to do it, and it is not too hard. But you have to keep track of all the windows minimized etc, it is a little bit of a pain and duplication of effort as the Meta.wm does this in C code very efficiently, keeps track of the windows and shows them back when the shortcut is activated again.

I actually like the idea of the virtual key press to leverage and make the window manager do what we want, while keeping our code short and simple.

The issue here is that different distributions have different shortcuts for the 'show-desktop'. A user can also override the default. If you send the correct combination, it is always intercepted first by the wm and shell and never sent to any application window. If you send the incorrect combination, well, it will be sent to the active window.

So the best strategy is to load org.gnome.desktop.wm.keybindings with Gio.Settings, read the string array for 'show-desktop' key and keep that updated in memory. Then send that string through virtual key press.

This way, even if a user changes the shortcut, you are always sending the correct shortcut. Some distributions have it set to an empty array, in which case you can add a random shortcut key combination. The problem here is that it may be used elsewhere for another action.... Maybe look into sending a weird keycode for something that cannot be on the keyboard- although I am not sure you can send random keycodes....

What do you think?

smedir commented 1 year ago

Ah, there is a easy way around the last problem as well.... check if the keybinding is set for another action and if it is just use a different one. Do you want an MR?

amarullz commented 1 year ago

I need to implement own show desktop (and minimize non-active window), because system implementation will not work smoothly with animation (specially when reshow window), I have some method to implement it without tracking all windows, I can just add flags to minimized window by show desktop. I know it's not the best method except if I can access system show desktop function & modify how it works.

amarullz commented 1 year ago

Ah, there is a easy way around the last problem as well.... check if the keybinding is set for another action and if it is just use a different one. Do you want an MR?

Many distro don't bind any key, so if it not set the show desktop cannot executed.

smedir commented 1 year ago

It is better to call the method directly in the window manager if you can- I don't remember if you can do this in the Shell or in Meta, and if that method/call is exported, but with that method you can hide the windows (without hiding the desktop window of DING), and calling it again puts all the windows back in the correct place. See what super + D is triggering and trigger the same method if you can instead of writing a brand new method.

Thanks for looking into this.

On Mon, Nov 13 2023 at 10:03:38 AM -08:00:00, Ahmad Amarullah @.***> wrote:

New method for show-desktop (+hide non-active windows) still on development. It will not use shortcut.

— Reply to this email directly, view it on GitHub https://github.com/amarullz/windowgestures/issues/18#issuecomment-1808722484, or unsubscribe https://github.com/notifications/unsubscribe-auth/AWEICQGWLSOLXI56PRDXJY3YEJOHVAVCNFSM6AAAAAA7JGTUEGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMBYG4ZDENBYGQ. You are receiving this because you authored the thread.Message ID: @.***>