Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

"SDL_CreateWindowFrom" in "display" module#2981

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
illume merged 1 commit intopygame:windowidfromRabbid76:Issue-1574-display-module
Feb 19, 2023
Merged

"SDL_CreateWindowFrom" in "display" module#2981

illume merged 1 commit intopygame:windowidfromRabbid76:Issue-1574-display-module
Feb 19, 2023

Conversation

@Rabbid76
Copy link
Contributor

the environment variable "SDL_WINDOWID" is set, use "SDL_CreateWindowFrom" to create the window in "display.set_mode"

Using 'SDL_WINDOWID' does not embed pygame display correctly into another application #1574

Salamek reacted with thumbs up emoji
if the environment variable "SDL_WINDOWID" is set, use "SDL_CreateWindowFrom" to create the window in "display.set_mode"
Copy link
Contributor

@ankith26ankith26 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Thanks for the PR! 🎉
I can't really provide an in-depth review because I'm not too experienced around display.c myself, but at a glance I noticed

  1. atoll can return 0 when no conversion happens. IG in that case,SDL_CreateWindow should be called
  2. SDL_CreateWindowFrom docs mention

In some cases (e.g. OpenGL) and on some platforms (e.g. Microsoft Windows) the hint SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT needs to be configured before using SDL_CreateWindowFrom().

So I wonder how we should be handling this

Copy link
Member

@illumeillume left a comment
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Thank you very much. This is an important backwards compatibility fix.

Ankith already mentioned that atol can return an error.

  1. Additionally, I wanted to ask about 32bit and 64bit windows... Is atol (long long?) the correct call to make on both 32/64 bit architectures?
  2. python3 setup.py format CI is failing because clang-format needs to be run on the C code.

@illumeillume added Compatability (Pygame 2)Something that works in Pygame 1 but is broken in Pygame 2 displaypygame.display labelsJan 16, 2022
@illume
Copy link
Member

I see there is test code here:#1574 (comment)
It would be good to confirm that the test code works on 32bit python and 64bit python.

Rabbid76 reacted with thumbs up emoji

@Rabbid76
Copy link
ContributorAuthor

The return type ofstd::atoll islong long. An alternative solution might bestd::stoll.

@ankith26
Copy link
Contributor

Revisiting this PR, I believeatol is the right function to use here. It returns along not along long, which should be the better datatype to use here IG. Because the size of a void pointer is not fixed at 8 bytes likelong long, instead it can vary by implementation. I believe the sizeoflong best matches the size of a void pointer on most platforms and configurations.

As mentioned above, likeatoll, this function can return0 on fail too. The error handling bit can look something like

if (!window_handle) {/* NULL window_handle can segfault when *window_handle executes */window_handle="";}longwindow_id=atol(window_handle);if (!window_id&&*window_handle!='0') {/* window_id is 0 when atol errors. It can also be 0 when the input was 0 */returnRAISE(pgExc_SDLError,"'SDL_WINDOWID' must be an integer");}

As illume pointed above, it would be good to test this change on 32 bit and 64 bit windows, bonus points if this can be put in a unit test ;)

@MyreMylar
Copy link
Contributor

@Rabbid76 are you still interested in finishing this off? It has been a while, so we could find someone else to take this over to get it into 2.1.3.

BondarenkoArtur and MrL314 reacted with thumbs up emoji

@illumeillume changed the base branch frommain towindowidFebruary 19, 2023 00:28
Copy link
Member

@illumeillume left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

👍 Thanks

@illumeillume merged commite52b0e8 intopygame:windowidFeb 19, 2023
illume added a commit that referenced this pull requestApr 30, 2023
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@illumeillumeillume approved these changes

+1 more reviewer

@ankith26ankith26ankith26 left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

Compatability (Pygame 2)Something that works in Pygame 1 but is broken in Pygame 2displaypygame.display

Projects

None yet

Milestone

2.2.0

Development

Successfully merging this pull request may close these issues.

Using 'SDL_WINDOWID' does not embed pygame display correctly into another application

4 participants

@Rabbid76@illume@ankith26@MyreMylar

[8]ページ先頭

©2009-2025 Movatter.jp