Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Borderless Fullscreen Windows, sf::Style:None, and Linux Window Managers  (Read 4115 times)

0 Members and 1 Guest are viewing this topic.

Cheeseness

  • Newbie
  • *
  • Posts: 13
  • I write, make, draw, play, game & everything else
    • View Profile
    • Cheese Talks
Ahoy there!

I recently had to work around item 3 from this thread, where a borderless fullscreen window created via sf::Style::None would not be positioned over the top of launcher bars, status menus and desktop margins in Gnome, KDE, XFCE, and Cinnamon (and probably more). Attached are some screenshots demonstrating various behaviours in various WMs.

After diving down the rabbit hole a bit and doing a bunch of research, I was able to implement something that achieved what I was after without resorting to FSEM (Fullscreen Exclusive Mode), that I've been able to confirm as working with the previously mentioned WMs/DEs.

Best practices for most broadly compatible borderless fullscreen windows seem to include setting _NET_WM_STATE_FULLSCREEN (currently not done for sf::Style::None because sf::Style::None is used for more than just borderless fullscreen windows). In addition to this, the window needs hints saying that it's resizeable before _NET_WM_STATE_FULLSCREEN is set (and then changed to be non-resizeable after) thanks to the fussiness of some window managers. Without these states and hints set in the right order, the WM (Some WMs? Many WMs? All WMs? Who knows) is free to reposition and resize the window to fit the space available to non-fullscreen windows.

The attached patch changes the WindowImplX11::WindowImplX11(VideoMode mode, const String& title, unsigned long style, const ContextSettings& settings) function. It uses the existing sf::Style::Resize resize hints for sf::Style::None, calls switchToFullscreen() when sf::Style::None is used, and moves the "hack" to disable resizing to the end of the function so that it's after switchToFullscreen() calls.

Since the game I'm working on doesn't use sf::Style::None for anything but borderless fullscreen windows, that meets our needs. SFML provides sf::Style::None for other purposes, and so in its current form, I wasn't comfortable opening a pull request. It's also likely to conflict with the work in PR #1238, which appears to focus mostly on FSEM (though what I've learned while writing this patch may still be relevant there).

I am open to improving this patch to a point where it could be merged, but I feel like I won't have time for that in the near future. It's better to share than hoard though, so here it is ^_^
« Last Edit: September 07, 2018, 05:31:16 pm by Cheeseness »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Borderless Fullscreen Windows, sf::Style:None, and Linux Window Managers
« Reply #1 on: September 11, 2018, 03:24:55 pm »
I don't think this is the best solution. We should probably finally get behind adjusting stuff to use "states" and "decorations" or something and then maybe have a fullscreen borderless state, given that it seems to require special treatment in some situation.

Given that the Linux multi-monitor fix has been merged into master, could you give SFML master another try and see if it fixes your issue without your modifications?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Cheeseness

  • Newbie
  • *
  • Posts: 13
  • I write, make, draw, play, game & everything else
    • View Profile
    • Cheese Talks
Re: Borderless Fullscreen Windows, sf::Style:None, and Linux Window Managers
« Reply #2 on: September 11, 2018, 03:44:15 pm »
Yeah, a fullscreen borderless window state or automatic checking whether the requested window size matches the current screen mode were the kinds of things I had in mind when saying it needed improvement before it could be merged.

I won't have the downtime to do a test till after The Away Team ships, but looking at the diff for PR #1238, it does not address this issue, which requires the window to be resizeable and _NET_WM_STATE_FULLSCREEN to be set in order for fullscreen borderless windows to behave as I would expect.

At this time, _NET_WM_STATE_FULLSCREEN is only set for sf::Style::Fullscreen, and resizing is disabled before that.