Skip to content

Instantly share code, notes, and snippets.

@Cheeseness
Last active May 3, 2019 16:33
Show Gist options
  • Select an option

  • Save Cheeseness/5d308780bbd322f0ff1abe99ce8b2830 to your computer and use it in GitHub Desktop.

Select an option

Save Cheeseness/5d308780bbd322f0ff1abe99ce8b2830 to your computer and use it in GitHub Desktop.
SFML 2.5.0 patch against https://github.com/SFML/SFML/blob/2.5.0/src/SFML/Window/Unix/WindowImplX11.cpp for nicer borderless fullscreen windows
diff --git a/SFML-2.5.0/src/SFML/Window/Unix/WindowImplX11.cpp b/SFML-2.5.0/src/SFML/Window/Unix/WindowImplX11.cpp
index e2c8d29..a4dcd8e 100644
--- a/SFML-2.5.0/src/SFML/Window/Unix/WindowImplX11.cpp
+++ b/SFML-2.5.0/src/SFML/Window/Unix/WindowImplX11.cpp
@@ -641,7 +641,10 @@ m_lastInputTime (0)
hints.decorations |= MWM_DECOR_BORDER | MWM_DECOR_TITLE | MWM_DECOR_MINIMIZE | MWM_DECOR_MENU;
hints.functions |= MWM_FUNC_MOVE | MWM_FUNC_MINIMIZE;
}
- if (style & Style::Resize)
+
+ //We want to enable resizing before going into fullscreen mode
+ //otherwise some WMs won't resize the window to fill the screen.
+ if (style & Style::Resize || style == 0) //For some reason, the sf::Style::None enum isn't behaving here.
{
hints.decorations |= MWM_DECOR_MAXIMIZE | MWM_DECOR_RESIZEH;
hints.functions |= MWM_FUNC_MAXIMIZE | MWM_FUNC_RESIZE;
@@ -662,19 +665,6 @@ m_lastInputTime (0)
5);
}
}
-
- // This is a hack to force some windows managers to disable resizing
- if (!(style & Style::Resize))
- {
- m_useSizeHints = true;
- XSizeHints* sizeHints = XAllocSizeHints();
- sizeHints->flags = PMinSize | PMaxSize;
- sizeHints->min_width = sizeHints->max_width = width;
- sizeHints->min_height = sizeHints->max_height = height;
- XSetWMNormalHints(m_display, m_window, sizeHints);
- XFree(sizeHints);
- }
-
// Set the window's WM class (this can be used by window managers)
XClassHint* hint = XAllocClassHint();
@@ -711,6 +701,26 @@ m_lastInputTime (0)
setVideoMode(mode);
switchToFullscreen();
}
+
+ //Since we're only using sf::Style::None forborderless fullscreen in The
+ //Away Team, we want to make sure _NET_WM_STATE_FULLSCREEN, etc is set.
+ if ((style == 0)) //For some reason, the sf::Style::None enum isn't behaving here.
+ {
+ switchToFullscreen();
+ }
+ //This is a hack to force some windows managers to disable resizing
+ //and it needs to be done after switching to fullscreen in order for some
+ //WMs to resize the window to cover the entire screen.
+ else if (!(style & Style::Resize))
+ {
+ m_useSizeHints = true;
+ XSizeHints* sizeHints = XAllocSizeHints();
+ sizeHints->flags = PMinSize | PMaxSize;
+ sizeHints->min_width = sizeHints->max_width = width;
+ sizeHints->min_height = sizeHints->max_height = height;
+ XSetWMNormalHints(m_display, m_window, sizeHints);
+ XFree(sizeHints);
+ }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment