-
-
Notifications
You must be signed in to change notification settings - Fork 185
Remove warning with zero size & RESIZABLE in display.set_mode #3386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove warning with zero size & RESIZABLE in display.set_mode #3386
Conversation
I'd love too, but I'm not tech savvy when it comes to using pygame-ce directly from the repo (I usually only install it directly from pip). Is there any compilation steps required? Whichever the case, if there's any sort of guide I can follow available, I'd love to follow it and report my results. |
You just need to install the correct wheel from the CI. Since you're on linux and python 3.10, I'll grab the appropriate wheel for you and post that here for you in a sec. Then you can just pip install it |
Unzip this and then pip install it (I'm assuming you're on x86_64 lol) |
Sorry for the wait, I had to test under different circumstances to check a few assumptions. It didn't solve the problem (at least in my system). However, I noticed that the warning appears when I set the flag to RESIZABLE. If I don't set a flag, the warning doesn't appear, even though I set the size to I tested the wheel both with Nodezator and with this small fixture I put together: from random import randint
import pygame as pg
pg.init()
sc = pg.display.set_mode((0, 0), pg.RESIZABLE)
scr = sc.get_rect()
bg = pg.Surface(sc.get_size()).convert()
bg.fill('white')
circle = pg.font.Font(None, 200).render('\N{bullet}', True, 'black').convert_alpha()
circle_rect = circle.get_rect()
circle_rect.center = scr.center
running = True
maintain_fps = pg.time.Clock().tick
while True:
maintain_fps(30)
###
for event in pg.event.get():
if event.type == pg.QUIT:
pg.quit()
quit()
elif event.type == pg.KEYDOWN:
if event.key == pg.K_ESCAPE:
pg.quit()
quit()
###
sc.blit(bg, (0, 0))
circle_rect.move_ip(randint(0, 20), randint(0, 20))
if not scr.colliderect(circle_rect):
circle_rect.center = scr.center
sc.blit(circle, circle_rect)
###
pg.display.update() |
Here where I live it is starting to get late, so I have to retire for the night. I also have a commitment for the entire morning, so if you still require my assistance I'll be glad to help when I get back to my pc tomorrow after lunch. |
Unfortunately, I can't currently reproduce this on my end either. My current linux install is being too nice, so you might be the only one currently available to test this... |
So RESIZABLE windows are actually still subject to being force resized by the OS, and my warning is properly working. We're properly scaling it to the monitor's size, but then the OS is slighly scaling it down (probably to account for things like the task bar). We can probably add in an exception to just suppress the warning in this very specific case where we scale up a (0, 0) window with the RESIZABLE flag and the OS resizes it back down |
Alright @oddbookworm I'll do that. It makes sense, because we were already deciding the size of the window ourselves, so it doesn't make sense to warn if the size we chose wasn't liked by the OS. The size was going to be different from (0,0) anyways |
Don't worry, the RESIZABLE flag was also causing the problem. It just happens that when I posted the issue I hadn't realized this yet, but as I said after, the RESIZABLE flag was indeed part of the problem:
Since your new solution takes this into account I believe it should work now for everyone. Even so, I'll test it again here in my system, I think I figured out where to grab a wheel (on the Actions tab of the repo, from the item that has the same name as this PR). |
Okay, confirmed: the new changes solve the issue here on my end as well. Thank you all again for the awesome work. 👍 |
Just one more question, if I may: would it be safe to assume these changes will make into 2.5.4? Just wanted to know because I put an if-else clause in Nodezator that will suppress the warning in case the size is |
@KennedyRichard yes, this bugfix will be released with version 2.5.4 since the previous ones are already released. You may suppress this warning for 2.5.2 and 2.5.3. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks! ⭐
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks
Probably fixes #3385 .
NEW approach: don't warn if (0, 0) size is used with
pygame.RESIZABLE
. Explanation belowI humbly ask @oddbookworm (original implementation) and Kennedy Richard (issue opener) to test this PR if they can to see if it is fixed.