You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes, a windowresize event is immediately put out upon creation of a window that resizes it. I haven't been able to figure out the common denominator of when this happens and how to get the size it'll rescale to. I'm a maintainer of pygame-ce and this has been causing us headaches lately because when this does happen, it causes one of our tests to segfault or fail because at best, the surface we stored from the window is no longer the same size as the one that the user requested. At worst, it segfaults because the surface we stored is now garbage data.
Is there a reason for this that's already known and I missed something? Is there a reliable way to at least get the size that will be rescaled to so that we can notify our users that their screen is not the requested size?
C reproducer:
#include<stdio.h>#include"SDL2/SDL.h"intmain()
{
intw=1;
inth=100;
if (SDL_InitSubSystem(SDL_INIT_VIDEO))
{
printf("Failed to init video");
return1;
}
SDL_Window*win=SDL_CreateWindow("test window", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, w, h, 0);
if (win==NULL)
{
printf("win is NULL");
return-1;
}
SDL_Surface*surf=SDL_GetWindowSurface(win);
if (surf==NULL)
{
printf("surf is NULL");
return-1;
}
printf("surf->size == %d,%d\n", surf->w, surf->h);
SDL_Eventevent;
while (SDL_PollEvent(&event) >0)
{
if (event.type==SDL_WINDOWEVENT&&event.window.event==SDL_WINDOWEVENT_RESIZED)
{
printf("Resize event to (%d, %d)\n", event.window.data1, event.window.data2);
}
}
surf=SDL_GetWindowSurface(win);
if (surf==NULL)
{
printf("surf is NULL");
return-1;
}
printf("surf->size == %d,%d\n", surf->w, surf->h);
return0;
}
Output on Manjaro linux, X11, KDE Plasma 6.0.5, KWin WM:
It's always possible for the OS to ignore the size and position of your window. If you try to create a window smaller than the minimum size, like you do here, for example. On mobile devices, you don't have an option, the window is the size of the screen, whether you wanted it or not.
I know it's not ideal, but the real answer is that you should always be able to accommodate window resizing, even in test code.
Sometimes, a windowresize event is immediately put out upon creation of a window that resizes it. I haven't been able to figure out the common denominator of when this happens and how to get the size it'll rescale to. I'm a maintainer of pygame-ce and this has been causing us headaches lately because when this does happen, it causes one of our tests to segfault or fail because at best, the surface we stored from the window is no longer the same size as the one that the user requested. At worst, it segfaults because the surface we stored is now garbage data.
Is there a reason for this that's already known and I missed something? Is there a reliable way to at least get the size that will be rescaled to so that we can notify our users that their screen is not the requested size?
C reproducer:
Output on Manjaro linux, X11, KDE Plasma 6.0.5, KWin WM:
The text was updated successfully, but these errors were encountered: