Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some fullscreen applications iconify when switching workspaces #584

Open
7xnl opened this issue Sep 7, 2024 · 3 comments
Open

Some fullscreen applications iconify when switching workspaces #584

7xnl opened this issue Sep 7, 2024 · 3 comments

Comments

@7xnl
Copy link

7xnl commented Sep 7, 2024

While in a fullscreen application, like a game, switching to a different workspace will cause the application window to be iconified. It doesn't happen for every game - every Steam game I tried doesn't get iconified, but most non-Steam games I have like Minecraft, Vintage Story and The Witness do.
Neither fullscreen_unfocus nor any quirks have any effect.

@vqns
Copy link
Contributor

vqns commented Sep 9, 2024

This is because these games iconify themselves when losing focus if the window was fullscreen ('exclusive fullscreen' or some variation). There is no general workaround, but 'borderless fullscreen window' may prevent that, or turning off fullscreen in the game settings and then manually toggling fullscreen (e.g M-S-e with the default bindings). If you know a specific game uses SDL, then SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS=0 might work too.

@7xnl
Copy link
Author

7xnl commented Sep 9, 2024

In that case, I think spectrwm would benefit from either making iconification optional - on xmonad, you have to import the Layout.Minimize module, for example - or add the ability to focus on iconified windows via the regular M-j/k bindings.

@7xnl
Copy link
Author

7xnl commented Sep 10, 2024

For the time being I'm using this patch I wrote:

diff --git a/spectrwm.c b/spectrwm.c
index 0737202..e0f6858 100644
--- a/spectrwm.c
+++ b/spectrwm.c
@@ -518,6 +518,7 @@ int		 maximized_unfocus = SWM_UNFOCUS_RESTORE;
 bool		 maximize_hide_bar = false;
 bool		 maximize_hide_other = false;
 bool		 max_layout_maximize = true;
+bool		 minimize_windows = true;
 bool		 urgent_enabled = false;
 bool		 urgent_collapse = false;
 char		*clock_format = NULL;
@@ -2673,7 +2674,9 @@ ewmh_apply_flags(struct ws_win *win, uint32_t pending)
 	win->ewmh_flags = pending;
 
 	if (changed & EWMH_F_HIDDEN) {
-		if (HIDDEN(win)) {
+		if (!minimize_windows)
+			return (changed);
+		else if (HIDDEN(win)) {
 			unmap_window(win);
 		} else {
 			/* Reload floating geometry in case region changed. */
@@ -8924,6 +8927,9 @@ raise_toggle(struct swm_screen *s, struct binding *bp, union arg *args)
 static void
 iconify(struct swm_screen *s, struct binding *bp, union arg *args)
 {
+	if (!minimize_windows)
+		return;
+
 	struct swm_region	*r;
 	struct ws_win		*win, *nfw;
 	bool			follow;
@@ -9000,6 +9006,9 @@ get_win_name(xcb_window_t win)
 static void
 uniconify(struct swm_screen *s, struct binding *bp, union arg *args)
 {
+	if (!minimize_windows)
+		return;
+
 	struct swm_region	*r;
 	struct ws_win		*win;
 	FILE			*lfile;
@@ -13304,6 +13313,7 @@ enum {
 	SWM_S_MAXIMIZE_HIDE_BAR,
 	SWM_S_MAXIMIZE_HIDE_OTHER,
 	SWM_S_MAXIMIZED_UNFOCUS,
+	SWM_S_MINIMIZE_WINDOWS,
 	SWM_S_REGION_PADDING,
 	SWM_S_SNAP_RANGE,
 	SWM_S_SPAWN_ORDER,
@@ -13548,6 +13558,9 @@ setconfvalue(uint8_t asop, const char *selector, const char *value, int flags,
 			return (1);
 		}
 		break;
+	case SWM_S_MINIMIZE_WINDOWS:
+		minimize_windows = (atoi(value) != 0);
+		break;
 	case SWM_S_REGION_PADDING:
 		region_padding = atoi(value);
 		if (region_padding < 0)
@@ -14215,6 +14228,7 @@ struct config_option configopt[] = {
 	{ "maximize_hide_bar",		setconfvalue,	SWM_S_MAXIMIZE_HIDE_BAR },
 	{ "maximize_hide_other",	setconfvalue,	SWM_S_MAXIMIZE_HIDE_OTHER },
 	{ "maximized_unfocus",		setconfvalue,	SWM_S_MAXIMIZED_UNFOCUS },
+	{ "minimize_windows",		setconfvalue,	SWM_S_MINIMIZE_WINDOWS },
 	{ "modkey",			setconfmodkey,	0 },
 	{ "program",			setconfspawn,	0 },
 	{ "quirk",			setconfquirk,	0 },
@@ -16637,7 +16651,7 @@ clientmessage(xcb_client_message_event_t *e)
 	} else if (e->type == a_change_state) {
 		DNPRINTF(SWM_D_EVENT, "WM_CHANGE_STATE state: %s\n",
 		    get_wm_state_label(e->data.data32[0]));
-		if (e->data.data32[0] != XCB_ICCCM_WM_STATE_ICONIC)
+		if (!minimize_windows || e->data.data32[0] != XCB_ICCCM_WM_STATE_ICONIC)
 			return;
 		/* Iconify. */
 		follow = follow_mode(SWM_FOCUS_TYPE_ICONIFY);

I'm not opening a pull request for this because I realize this is a niche issue, but it would be nice to have a workaround like this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants