| Summary: | [KMSDRM] Avoid new windows to be created | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Manuel Alfayate Corchete <redwindwanderer> |
| Component: | video | Assignee: | Manuel Alfayate Corchete <redwindwanderer> |
| Status: | ASSIGNED --- | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | ||
| Version: | 2.0.15 | ||
| Hardware: | x86_64 | ||
| OS: | Linux | ||
| Attachments: |
Patch to prevent programs from creating more than 1 window on KMSDRM
V2 of the patch. Cursor code changes moved to a different issue. |
||
|
Description
Manuel Alfayate Corchete
2021-01-15 10:55:58 UTC
Yes, that's fine, please attach a patch for review. In general, feel free to attach patches when you open issues on Bugzilla so they can be reviewed and approved in one step. Created attachment 4667 [details]
Patch to prevent programs from creating more than 1 window on KMSDRM
Here's a patch.
It also makes a minor adjustment at the end of KMSDRM_DestroyWindow() and a small refactor on the cursor buffer creation.
Created attachment 4670 [details]
V2 of the patch. Cursor code changes moved to a different issue.
I have done a second version of the patch because some more changes have been made to the cursor code, to fix another different issue, so changes related to that fix are in that bug report.
Looks good, go ahead and commit. @Sam Before commiting, I would like to ask you a question. I am thinking about adding support for multiple displays (I could create a different SDL_Display for each video file descriptor: In Rpi4, which has two HDMI outputs, there's /dev/dri/card0 and /dev/dri/card1, so for each file descriptor I can create a different GBM DEV, and I can flip them independently too). Thing is, what's the relationship between SDL_Displays and SDL_Windows? I mean: I know each SDL_Window has an SDL_Display member (ie, it's displayed on a display), but does SDL2 expect multiple windows on the same display, for example? If that's the case, I may still be limiting the window number to 1, but I can add multiple displays anyway so a single window could occupy 2 displays, for example. I believe SDL2 expects to be able to do that: create a window that's part in a display and part in another. Yes, SDL expects to be able to create windows on any display and potentially span displays. @Sam Ok, as things work on non-atomic KMSDRM, I can have as many windows as displays, and as many displays as video card FDs on the machine. So, for example, on a Pi4 I can have two FDs, hence two displays, hence two windows. I am currently initializing the SDL_displays in SDL_VideoInit(). Let's say I have two of them. Does SDL assign each window to a display internally if I don't do it in KMSDRM_CreateWindow? In other words, in KMSDRM_CreateWindow(), I get the window display here: https://hg.libsdl.org/SDL/file/d4c15ecfcf62/src/video/kmsdrm/SDL_kmsdrmvideo.c#l1074 ...But I have never assigned that. How does SDL manage the SDL_window->SDL_display relationhip internally? First window->first display? Then second window -> first display too? Reading the first answer here: https://stackoverflow.com/questions/41745492/sdl2-how-to-position-a-window-on-a-second-monitor ...I understand that SDL2 uses a global coord system, so it assigns window->display internally depending on the window position on that coord system. Is that right? If that's the case, that doesn't look like it will work with my current trick of programming a different video mode for smaller-than-native window sizes... Yes, that's correct. The coordinate space is the display's normal resolution, and it's expected that the monitor will change resolution to match fullscreen windows, so I think you're okay there. (In reply to Sam Lantinga from comment #8) > Yes, that's correct. The coordinate space is the display's normal > resolution, and it's expected that the monitor will change resolution to > match fullscreen windows, so I think you're okay there. But I am also changing resolution to display NON-FULLSCREEN windows (because having the image on a tiny area only looks ugly without a windowing system: it's mostly a cosmetic hack, so to say). Maybe I should NOT change resolution for NON-FULLSCREEN windows so I don't "break the API"? Yes, non-fullscreen windows should be just that - non-fullscreen. :) @Sam For the non-fullscreen windows being non-fullscreen, I have opened a new issue with a patch that does precissely that: https://bugzilla.libsdl.org/show_bug.cgi?id=5489 |