alessivs / supermemo-wine

Project to make SuperMemo for Windows editions runnable with Wine
63 stars 5 forks source link

Make it possible to minimize floating SuperMemo windows (EWMH) #16

Open Golddouble opened 4 years ago

Golddouble commented 4 years ago

Normally I can press CTRL+ALT+D to minimize all open programs, so that the desktop appears. This does not work when SM from Lutris-Wine is open. I also can not minimize SM itself. Can you reproduce this?

alessivs commented 4 years ago

Yep. This is a lack of support for the minimize operation in the window manager + Wine interaction.

The Wine windows lack the _NET_WM_ACTION_MINIMIZE operation in the _NET_WM_ALLOWED_ACTIONS property. The following is the relevant output from xprop, formatted for readability:

_NET_WM_ALLOWED_ACTIONS(ATOM) = 
  _NET_WM_ACTION_CLOSE, 
  _NET_WM_ACTION_ABOVE,
  _NET_WM_ACTION_BELOW, 
  _NET_WM_ACTION_FULLSCREEN, 
  _NET_WM_ACTION_MOVE,
  _NET_WM_ACTION_RESIZE, 
  _NET_WM_ACTION_MAXIMIZE_HORZ,
  _NET_WM_ACTION_MAXIMIZE_VERT, 
  _NET_WM_ACTION_SHADE,
  _NET_WM_ACTION_CHANGE_DESKTOP, 
  _NET_WM_ACTION_STICK

While it is possible to add the _NET_WM_ACTION_MINIMIZE action (possibly, with wmctrl or other utilities), you would have to do it to every mapped window (Contents, Browser, Dock, Status bar, Element), and minimizing one window would not minimize the rest.

For a proof of this limitation, force-minimize one of the SuperMemo windows with:

xdotool selectwindow windowminimize

and click on a SuperMemo window. You will notice that only that window will be minimized. EDIT: actually, if you have enabled and minimized the Dock window that way, all other windows will be minimized on xfwm, the XFCE window manager.

I seem to remember that kwm (the window manager from KDE Plasma) does minimize all windows, but it is implementation specific. To my knowledge, it has a lot of heuristics that try to do the right thing, at the expense of more complexity.

In order not to have to detect and forcefully minimize the dock window to achieve the purpose every time, here are two suggestions:

  1. Use the Shift+Ctrl+G shortcut to send SuperMemo windows to the system tray.
  2. Use a Wine virtual desktop window. Example:
Lutris
  SuperMemo 17
    Configure
      Runner options
        [X] Windowed (virtual desktop)
        Virtual desktop resolution: (choose desired resolution)
alessivs commented 4 years ago

Additional suggestion: define a keyboard shortcut at the window manager level; say, with xfce4-keyboard-settings, that would minimize the dock window upon click:

image

A refinement would be to detect the dock window instead of clicking on it , but it isn't simple.

alessivs commented 4 years ago

The logical solution to minimize the dock window would be something like:

xdotool search --name " \(SuperMemo [0-9]+:" windowminimize

but it doesn't have a good hiding behavior on my system (freezes)

alessivs commented 4 years ago

I'll research into existing tools and/or Xlib to add minimize capability through _NET_WM_ACTION_MINIMIZE after a Wine SuperMemo window has been created.

Golddouble commented 4 years ago

Thank you again. :-)

Here is a feedback:

Use the Shift+Ctrl+G shortcut to send SuperMemo windows to the system tray.

Minimize SM this way works great, but there is no change to maximize it after. The only way to get the window back, is to close SM and open it again, to have it maximized again.

Use a Wine virtual desktop window. Example

This works great. But I don't like the title bar of "wine desktop" on the top. Is there a way to hide it?

xdotool search --name " (SuperMemo [0-9]+:" windowminimize

I have added this command entry in this App (Xfce settings): SM minimieren

Result: Works not better than CTRL+ALT+D (same behaviour)

So my favourite until now is "Use a Wine virtual desktop window".

alessivs commented 4 years ago

Use the Shift+Ctrl+G shortcut to send SuperMemo windows to the system tray.

Minimize SM this way works great, but there is no change to maximize it after. The only way to get the window back, is to close SM and open it again, to have it maximized again.

All I have to do is click on the tray icon to have the floating (not Wine virtual desktop) SuperMemo windows back (as in "restore windows"), but yes, this doesn't come automatically with Ctrl+Alt+D; it is an additional operation.

Use a Wine virtual desktop window. Example

This works great. But I don't like the title bar of "wine desktop" on the top. Is there a way to hide it?

The "wine desktop window" is how I deal with the multiple floating SuperMemo windows on incompatible window managers as well as tiling window managers. And yes to your question; you want to undecorate the window. XFCE doesn't have such option built-in, but you can do it with a third-party app.

Install devilspie using your package manager, then create the following file:

~/.devilspie/supermemo-wine-desktop.ds:

;; -*- scheme -*-
(if (and (contains (application_name) " - Wine desktop")
         ;; Unfortunately, when running a Wine virtual desktop, the SuperMemo
         ;; window class changes from "sm17.exe" (easier to identify) to
         ;; "explorer.exe"
         (is (window_class) "explorer.exe"))
    (undecorate))                       ;remove title bar

Run the following command in a terminal to test: devilspie -a. The SuperMemo Wine desktop window should be undecorated. You can Ctrl+C to stop the test.

To persist this configuration, add the devilspie command to your desktop environment's startup. (Here, xfce4-session-settings)

image

xdotool search --name " (SuperMemo [0-9]+:" windowminimize

I have added this command entry in this App (Xfce settings)... Works not better than CTRL+ALT+D (same behaviour)

I was also far from happy with the window freezing!

Conclusion

Use either:

  1. A Wine desktop window. You can undecorate it automatically with Devilspie. A "desktop window" avoids bugs from interacting with not-so-collaborating window managers.
  2. Regular floating SuperMemo windows. The experience isn't the best, which is why I will come up with an alternative to enable minimization for floating windows (likely a script running in the background, analog to devilspie).
Golddouble commented 4 years ago

Here is another solution: Right click onto the title bar and change Lutris window into full-screen mode: Lutis Vollbild

What's the hook? When I start SM again, Lutris window is again not in Full-screen mode.

alessivs commented 4 years ago

   1. The Window manager always has the final say on how to display a window.

   2. There is a Window state named _NET_WM_STATE_FULLSCREEN, that the window       manager can choose to implement.

     2a. Apparently, Lutris is concerned with configuring Wine apps to use          exclusive full screen not through this window state, but through OpenGL          and other methods more commonly used in games.

   3. To set this full screen state on the Wine desktop window upon starting,       you can use a devilspie script (see above instructions).

;; -*- scheme -*-
(if (and (contains (application_name) " - Wine desktop")
         (is (window_class) "explorer.exe"))
    (fullscreen))
Golddouble commented 4 years ago

Thank you. My "Lutris window full-screen method" is not a good idea. When full screen is active, I can't click on any icons in the taskbar. I can see them, but when I click on them, they don't react.

So I tried now the devilspie method. With ~/.devilspie/supermemo-wine-desktop.ds and devilspie -a

devispie

But the test was not working:

Golddouble@mx:~
$devilspie -a
^C
Golddouble@mx:~
$

No effect.

My expectation was, that now the title bar wine Lutris goes away. But as you can see it remains. Or do I miss anything?

alessivs commented 4 years ago

The window properties may differ. Please change:

(is (window_class) "explorer.exe")

To:

(is (window_class) "Wine")
Golddouble commented 4 years ago

Thank you. This works great. :+1: