Giter Club home page Giter Club logo

Comments (6)

Kontrabant avatar Kontrabant commented on September 13, 2024 1

You need to call SDL_GetWindowSurface() before calling SDL_UpdateWindowSurface(). If you check the return code in your example, it's actually failing and setting an error "Window surface is invalid, please call SDL_GetWindowSurface() to get a new surface".

from sdl.

ell1e avatar ell1e commented on September 13, 2024

I found yet another bug:

  1. With above example, let the mouse leave the window to the left. You'll see ouput similar to:

    Mouse at: 1, 37
    Mouse leaves window.
    

    This is toward the left side, as the x=1 clearly indicates, where you moved the mouse last. This makes sense.

  2. Wait a few seconds and keep the mouse away from the window at all cost.

  3. Now move the mouse around the window without touching it, and move the mouse back in from the right side. You'll see something like this output:

    Mouse enters window.
    Mouse at: 1, 37
    Mouse at: 199, 28
    Mouse at: 199, 29
    

The 1, 37 after the mouse was announced back inside the window by SDL2 is multiple seconds and hundreds pixels away outdated and really shouldn't be there.

from sdl.

ell1e avatar ell1e commented on September 13, 2024

I was going to test if with SDL_VIDEODRIVER=wayland I get more correct results, but #5596 then makes the window not show up with above minimal code example.

from sdl.

Kontrabant avatar Kontrabant commented on September 13, 2024

I'll have to check this on KDE a bit later, but it sounds like a window manager bug as it doesn't happen on GNOME. SDL just forwards events from the window manager. If it's getting weird coordinates at random times, it's because something is sending them.

I was going to test if with SDL_VIDEODRIVER=wayland I get more correct results, but #5596 then makes the window not show up with above minimal code example.

You need to present a frame for a Wayland window to become fully mapped. That's just how it works. Trying to hack around this with subsurfaces or some other solution just to show a blank window in the most trivial of cases would become very messy and have undesirable side effects, such as potentially interfering with direct scanout on some window managers.

You can just create a renderer, clear the screen, and present for the blank window to become visible.

from sdl.

ell1e avatar ell1e commented on September 13, 2024

Isn't there plenty of SDL code that uses SDL_UpdateWindowSurface instead of a renderer as the entire way of the application to work? It doesn't make sense to me that this approach would be broken. I would get it if neither SDL_RenderPresent nor SDL_UpdateWindowSurface was called, but one of the two surely should make the window visible. Otherwise, why does SDL_UpdateWindowSurface even still exist at this point?

from sdl.

ell1e avatar ell1e commented on September 13, 2024

Thanks so much! With your help I confirmed that this bug exists also with SDL_VIDEODRIVER=wayland, but only the 2nd part of it. The 1st part of having a bogus window enter to start with seems to be limited to X11. The 2nd part is also way harder to reproduce with wayland, I needed to try around 20 times until it happened, but then I managed multiple times. I can therefore only assume it's a race condition since it's so random.

from sdl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.