Skip to content

Fix bug on x11 where window close events were not propagated with certain window styles#2947

Closed
danieljpetersen wants to merge 1 commit into
SFML:masterfrom
danieljpetersen:x11-fix-window-close-event
Closed

Fix bug on x11 where window close events were not propagated with certain window styles#2947
danieljpetersen wants to merge 1 commit into
SFML:masterfrom
danieljpetersen:x11-fix-window-close-event

Conversation

@danieljpetersen

Copy link
Copy Markdown
Contributor

Description

This is intended to fix #2943.

It's a single line change which adds a flag for x11 telling it to propagate close events for styles None, Resize, Titlebar.

In truth I do not understand x11 very well, but the behavior / fix seems to make sense to me at least. It fixes the bug on my machine, and doesn't visually impact the window decorations.

I've only confirmed the initial bug on Cinnamon. Flareon from the Discord confirmed it was present on KDE.

I've only tested this PR Cinnamon.

How to test this PR?

Make sure hotkey is bound which closes in-focus window, compile / run this code, press hotkey
A) without this PR, the window will not get sf::Event::Close, the window will never close.
B) with this PR, the window will get sf::Event::Close, the window will successfully close.

#include <SFML/Window.hpp>
 
int main()
{
    sf::Window window; // also happens with RenderWindow
 
    // The following are all not working: Titlebar, Resize, None
    window.create(sf::VideoMode({800, 600}), "My window", sf::Style::None);
 
    while (window.isOpen()) {
        sf::Event event{};
        while (window.pollEvent(event)) {
            // sf::Event::Closed is never given to us from window.pollEvent(event)
            if (event.type == sf::Event::Closed)
                window.close();
        }
 
        window.display();
    }
 
    return 0;
}

@danieljpetersen

Copy link
Copy Markdown
Contributor Author

Ah, hmm, this actually alters the the decorations for resize and titlebar. I only tested against none before submitting the PR, should have tested all three cases.

With that in mind then, I could alter the PR so the bug is at least fixed for style::None, but I'm not sure how you'd fix it for the other two.

@coveralls

Copy link
Copy Markdown
Collaborator

Pull Request Test Coverage Report for Build 8681308266

Details

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 52.978%

Totals Coverage Status
Change from base Build 8675259711: 0.0%
Covered Lines: 10331
Relevant Lines: 18496

💛 - Coveralls

@eXpl0it3r

Copy link
Copy Markdown
Member

Ah, hmm, this actually alters the the decorations for resize and titlebar. I only tested against none before submitting the PR, should have tested all three cases.

How is it changed?

@danieljpetersen

Copy link
Copy Markdown
Contributor Author

Ah, hmm, this actually alters the the decorations for resize and titlebar. I only tested against none before submitting the PR, should have tested all three cases.

How is it changed?

It adds the close button to the window decorations for resize and titlebar. sf::Style::None however remains without decorations.

So the PR as it currently stands has regressions for resize and titlebar. We could modify the PR to just target sf::Style::None. This would effectively fix the bug for the sf::Style::None window state with no regressions. sf::Style::Resize and sf::Style::Titlebar would obviously remain broken if we did this (unable to close via hotkey). I do not know if there is a way to actually fix the bug for these two states.

To be as clear as possible,

  • sf::Style::None
    • Without current PR:
      • No window decorations
      • does not close via quit hotkey
    • With current PR:
      • No window decorations
      • Closes via window hotkey
  • sf::Style::Resize
    • Without current PR:
      • Has window decorations with minimize, maximize
      • Does not close via quit hotkey
    • With current PR:
      • Has window decorations with minimize, maximize, close
      • Closes via quit hotkey
  • sf::Style::Titlebar
    • Without current PR:
      • Has window decorations with minimize
      • Does not close via quit hotkey
    • With current PR:
      • Has window decorations with minimize, close
      • Closes via quit hotkey

I'm sure this is unnecessary, but to be abundantly clear here are some images

None with PR as it currently stands:
none_with_fix

None without PR as it currently stands:
none_without_fix

Resize with PR as it currently stands (regression, erroneously adds close):
resize_with_fix

None without PR as it currently stands:
resize_without_fix

Titlebar with PR as it currently stands (regression, erroneously adds close):
titlebar_with_fix

Titlebar without PR as it currently stands:
titlebar_without_fix

@eXpl0it3r eXpl0it3r removed this from the 3.0 milestone Dec 14, 2024
@eXpl0it3r eXpl0it3r added this to the 3.2 milestone Aug 28, 2025
@github-project-automation github-project-automation Bot moved this to Planned in SFML 3.2.0 Aug 28, 2025
@eXpl0it3r eXpl0it3r removed this from SFML 3.2.0 Mar 28, 2026
@github-project-automation github-project-automation Bot moved this to Planned in SFML 3.1.0 Mar 28, 2026
@eXpl0it3r eXpl0it3r modified the milestones: 3.2, 3.1 Mar 28, 2026
@eXpl0it3r eXpl0it3r moved this from Planned to Done in SFML 3.1.0 Mar 28, 2026
@eXpl0it3r

Copy link
Copy Markdown
Member

Superseded by #3684

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

(Linux) Window Close Event not triggered with sf::Style None, Titlebar, Resize

3 participants