Repository: qtile/qtile

Issue:
Regression when starting full screen steam games
f0a67e8bd4ebda97f310de6c235f1cbd72a0dc7d introduces a regression where, when I start a steam game on one monitor (e.g. dota) and then go click on the other monitor, the window disappears and there's not a way to get it back.

I assume the window goes "somewhere" (it is still using cpu and doing i/o, etc.), but we don't have a way to get windows *out* of IconicState as far as I can tell.

/cc @m-col 


Discussion:
A dota xprop:

```
_NET_WM_USER_TIME(CARDINAL) = 289778665
_NET_WM_ICON(CARDINAL) = 	Icon (48 x 48):
	                                                
	                                                
	                     ▒  ▒  ▒▒                   
	   ▒▒▓▓▓▓▓▒▒▒▓   ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒    
	  ▓▒▓▓▒▒▓▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒▓▓▓▓▓▓▓▓   
	  ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓  
	  ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓  
	  ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓  
	  ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓  
	  ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓  
	  ▓▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓  
	  ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓  
	  ▓▒▓▓▓▓▓▓  ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒  ▓▓▓▓▓▓▓▓▓▓▓  
	  ▓▓▓▓▓▓▓▓▒  ▒▓▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓    ▒▓▓▓▓▓▓▓▒▓▓  
	  ▓▒▓▓▓▓▓▓▓▒   ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒    ▓▓▓▓▓▓▓▒▓▓  
	  ▓▒▓▓▓▓▓▓▓▓░   ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓   ▓▓▓▓▓▓▓▒▓▓  
	  ▓▒▓▓▓▓▓▓▓▓▓     ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒▓▓▓▓▓▒▓▒▒▓  
	  ▓▒▓▓▓▓▓▓▓▓▓▓     ▒▓▓▓▓▓▓▓▓▓▓▓▓▒▓▓▓▓▓▓▓▓▓▓▒▓▓  
	  ▓▒▓▓▓▓▓▓▓▓▓▓▓      ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒▓▓▓▓▓▓▓▓▒  
	  ▓▓▓▓▓▓▓▓▓▓▓▓▓▓      ▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▓▓   
	  ▓▓▓▓▓▓▓▒▓▓▓▓▓▒▓       ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▓▓   
	  ▓▒▓▓▓▓▓▓▓▓▓▓▓▓▒▓       ▒▓▓▓▓▓▓▓▓▓▓▒▒▓▓▓▓▓▒▓   
	  ▓▓▓▓▒▒▓▓▒▓▓▒▓▓▓▓▓▒       ▓▓▓▓▓▓▓▓▒▓▓▒▓▓▒▓▒▓   
	  ▓▓▓▓▒▒▓▒▒▓▓▓▒▓▓▓▓▓        ▒▓▓▒▓▓▒▓▓▒▒▒▓▒▒▒▓▒  
	  ▓▓▒▓▒▒▒▓▓▒▓▒▓▓▓▓▓▓▓         ▓▓▓▒▒▓▒▓▒▓▓▒▒▒▓▒  
	  ▓▒▒▓▒▒▒▒▓▒▓▓▒▓▓▒▓▒▓▓         ▒▓▒▒▒▒▒▒▒▓▒▒▒▓   
	  ▒▓▒▒▒▒▒▒▒▒▒▒▒▓▒▒▒▒▒▓▓          ▓▓▒▒▓▒▒▒▒▒▒▓   
	  ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓         ░▓▓▒▒▒▒▒▒▒▒▓▓  
	  ▒▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓░        ▒▓▓▓▒▒▒▒▒▒▒▓  
	  ▒▒▒▒▒▒▒▒▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▓           ▓▓▓▒▒▒▒▒▓  
	   ▓▓▒▒▒▒▒▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▓            ▓▒▒▒▒▓▓  
	   ▓▓▒▒▒▒▓▓ ▒▓▒▒▒▒▒▒▒▒▒▒▒▒▓▓           ▓▒▒▒▒▒▓  
	   ▒▒▒▒▒▒▓▒  ▒▓▒▒▒▒▒▒▒▒▒▒▒▒▓▒          ▓▒▒▒▒▓▓  
	   ▒▒▒▒▒▒▓    ▒▓▒▒▒▒▒▒▒▒▒▒▒▒▓▒        ▒▒▒▒▒▒▒▓  
	   ▓▒▒▒▒▓▓     ▒▓▒▒▒▒▒▒▒▒▒▒▒▒▓▒       ▓▒▒▒▒▒▓▓  
	  ░▓▒▒▒▒▓▒      ░▓▒▒▒▒▒▒▒▒▒▒▒▒▓░      ▓▒▒▒▒▒▓▓  
	  ▒▒▒▒▒▒▒▓▓▒     ▓▓▒▒▒▒▒▒▒▒▒▒▒▒▓     ▒▒▒▒▒▒▒▒▓  
	  ▒▒▒▒▒▒▒▒▓▓▓ ▒▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓▓▒▒▒▓▒▒▒▒▒▒▒▓  
	  ▒▓▒▒▒▒▒▒▒▒▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓  
	  ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓  
	  ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓  
	  ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓  
	  ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓  
	  ▒▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓▒▒▓  
	   ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▓▓▒▒▒▓▓▓▓▓▓▒▒▓▓▓▓▓▓  
	     ▒ ░ ░         ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒▓▓▓▓▓▒  ▒   
	                    ▒▓▓▒▒▒▒  ▒▒                 
	                                                


_NET_WM_STATE(ATOM) = 
_NET_WM_DESKTOP(CARDINAL) = 6
WM_STATE(WM_STATE):
		window state: Normal
		icon window: 0x0
XdndAware(ATOM) = BITMAP
_NET_WM_NAME(UTF8_STRING) = "Dota 2"
WM_NAME(STRING) = "Dota 2"
WM_PROTOCOLS(ATOM): protocols  WM_DELETE_WINDOW, WM_TAKE_FOCUS
_NET_WM_BYPASS_COMPOSITOR(CARDINAL) = 1
_NET_WM_WINDOW_TYPE(ATOM) = _NET_WM_WINDOW_TYPE_NORMAL
_NET_WM_PID(CARDINAL) = 1329229
WM_LOCALE_NAME(STRING) = "en_US.UTF-8"
WM_CLASS(STRING) = "dota2", "dota2"
WM_HINTS(WM_HINTS):
		Client accepts input or input focus: True
		window id # of group leader: 0x15528cd
WM_NORMAL_HINTS(WM_SIZE_HINTS):
		user specified location: 0, 0
		program specified minimum size: 1920 by 1200
		program specified maximum size: 1920 by 1200
WM_CLIENT_MACHINE(STRING) = "cisco"
_MOTIF_WM_HINTS(_MOTIF_WM_HINTS) = 0x2, 0x0, 0x0, 0x0, 0x0
STEAM_GAME(CARDINAL) = 570
```
That's a feature (of steam), not a bug. Does it not remain in the TaskList widget or similar, where its normal state can be restored?

Alternatively, it can be disabled altogether: https://superuser.com/questions/1144959/how-do-i-stop-fullscreen-games-from-minimizing-when-i-click-on-another-window-on
I don't use the task list :-). What functions would I call to restore it's normal state? 

On Sat, Jan 23, 2021, at 1:27 PM, m-col wrote:
> 

> That's a feature (of steam), not a bug. Does it not remain in the TaskList widget or similar, where its normal state can be restored?

> Alternatively, it can be disabled altogether: https://superuser.com/questions/1144959/how-do-i-stop-fullscreen-games-from-minimizing-when-i-click-on-another-window-on


> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub <https://github.com/qtile/qtile/issues/2149#issuecomment-766174297>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAF7VV67BQSCSG5J6KR2PU3S3MWM3ANCNFSM4WP5U55A>.

I think setting `window.minimized = False` should do it
Indeed, that works just fine. Is there a recommended hotkey setup for maximizing these windows?
I guess you could use cmd_toggle_minimize, if it counts as the current window
when there are no other windows in the group. Though if that is the case then
you ma as well just disable the minimising altogether.

On 210123 01:57, Tycho Andersen wrote:
>Indeed, that works just fine. Is there a recommended hotkey setup for maximizing these windows?
>
>-- 
>You are receiving this because you were mentioned.
>Reply to this email directly or view it on GitHub:
>https://github.com/qtile/qtile/issues/2149#issuecomment-766185859

Unfortunately it doesn't count as the current window in the group, since the steam library is also in the group.

I could change the SDL setting, but that will only work for windows that use SDL. Dota has such a setting as well which works fine, but I wonder if this behavior shouldn't be configurable.

Resolving patch:
diff --git a/libqtile/confreader.py b/libqtile/confreader.py
--- a/libqtile/confreader.py
+++ b/libqtile/confreader.py
@@ -59,6 +59,7 @@ class Config:
         ("bring_front_click", "bool"),
         ("reconfigure_screens", "bool"),
         ("wmname", "str"),
+        ("respect_minimize_requests", "bool"),
     ]
 
     def __init__(self, file_path=None, **settings):
diff --git a/libqtile/resources/default_config.py b/libqtile/resources/default_config.py
--- a/libqtile/resources/default_config.py
+++ b/libqtile/resources/default_config.py
@@ -175,6 +175,10 @@
 focus_on_window_activation = "smart"
 reconfigure_screens = True
 
+# If things like steam games want to auto-minimize themselves when losing
+# focus, should we respect this or not?
+respect_minimize_requests = True
+
 # XXX: Gasp! We're lying here. In fact, nobody really uses or cares about this
 # string besides java UI toolkits; you can see several discussions on the
 # mailing lists, GitHub issues, and other WM documentation that suggest setting
diff --git a/libqtile/window.py b/libqtile/window.py
--- a/libqtile/window.py
+++ b/libqtile/window.py
@@ -1212,7 +1212,7 @@ def handle_ClientMessage(self, event):  # noqa: N802
                     logger.warning("Invalid value for focus_on_window_activation: {}".format(focus_behavior))
         elif atoms["_NET_CLOSE_WINDOW"] == opcode:
             self.kill()
-        elif atoms["WM_CHANGE_STATE"] == opcode:
+        elif atoms["WM_CHANGE_STATE"] == opcode and self.qtile.config.respect_minimize_requests:
             state = data.data32[0]
             if state == NormalState:
                 self.minimized = False


Test patch: