Skip to content
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

can't get Fullwindow onto secondary screen #17

Open
rofl0r opened this issue Feb 8, 2025 · 9 comments
Open

can't get Fullwindow onto secondary screen #17

rofl0r opened this issue Feb 8, 2025 · 9 comments
Assignees

Comments

@rofl0r
Copy link

rofl0r commented Feb 8, 2025

Describe the bug
amiberry starts up on the primary screen, which in my case is smaller and on the side. when i switch to windowed and pull the the window onto the secondary screen, then switch to fullwin again, the emulator display moves back to the small primary screen.
this is the first time i hit this behaviour with an app using SDL2, other SDL2 apps switch to fullscreen-desktop mode on the screen the window is currently on. it's as if there's some special code dealing with multiple screens in amiberry that somehow misbehaves.

This is on linux running X11. SDL2 is version SDL2-2.28.5.

@rofl0r
Copy link
Author

rofl0r commented Feb 8, 2025

hmm, one of the SDL2 apps this works as expected is AGS, but they use some special code to deal with this: https://github.com/adventuregamestudio/ags/blob/master/Engine/platform/base/sys_main.cpp#L74

@rofl0r
Copy link
Author

rofl0r commented Feb 8, 2025

in my own app sdlbook, it also works by default but i use the following code to toggle fullscreen_desktop using the existing window: https://github.com/rofl0r/SDLBook/blob/master/ezsdl.h#L401 (i got a newer version of that line locally that actually uses SDL_WINDOW_FULLSCREEN_DESKTOP)

@rofl0r
Copy link
Author

rofl0r commented Feb 8, 2025

tried using SDL_WINDOWPOS_UNDEFINED instead of SDL_WINDOWPOS_CENTERED but that doesn't make a difference. when switching to full-window, the screen the window is on goes black for half a second, as if trying to make the full-screen window there, then it moves over to the other screen again.

@midwan midwan self-assigned this Feb 8, 2025
@rofl0r
Copy link
Author

rofl0r commented Feb 11, 2025

ok the issue is that after the window is set fullscreen, it's getting destroyed again by

#0  check_prefs_changed_gfx ()
    at /home/rofl/tmp/amiberry-lite/src/osdep/amiberry_gfx.cpp:1613
#1  0x00000000004ad087 in vsync_handle_check ()
    at /home/rofl/tmp/amiberry-lite/src/drawing.cpp:4334
#2  0x000000000047899f in vsync_handler_pre ()
    at /home/rofl/tmp/amiberry-lite/src/custom.cpp:8378
#3  0x000000000047d811 in hsync_handler ()
    at /home/rofl/tmp/amiberry-lite/src/custom.cpp:9338
#4  0x00000000004b0258 in do_cycles_cpu_norm (cycles_to_add=896)
    at /home/rofl/tmp/amiberry-lite/src/events.cpp:320

at
close_windows (mon=mon@entry=0x4aa7720 )
2388 SDL_DestroyWindow(mon->amiga_window);

having single-stepped through all code after the initial resolution change, i must say this whole code is utterly complex and confusing. there's code all over the place checking whether the prefs changed and then tearing everything down that's been built up just before. like SDL textures, renderers, windows. if you wanna beat some sense into that code, you gotta rip out all code that tries to detect a configuration change, and only do the respective actions right after the emulation returns from the F12 window.

@rofl0r
Copy link
Author

rofl0r commented Feb 11, 2025

i managed to fix it by saving the current screen number before destroying the freshly full-screened window. this has been the most frustrating debugging session since i had to debug the 60 line macros of boehm gc 10 yeats ago.
https://0x0.st/8Z_p.patch

@midwan
Copy link
Contributor

midwan commented Feb 11, 2025

Welcome to a glimpse of the horrible mess that is UAE code... :)

@rofl0r
Copy link
Author

rofl0r commented Feb 11, 2025

ok, i guess to make something productive out of my patch without refactoring the whole mess, i'd suggest:

  1. removal of the code that uses SDL_SetWindowFullscreen - doing it is superfluous as the window gets destroyed and recreated anyway.
  2. make the gui variable i added external or add both variables to the monitor struct or to prefs struct, and use it in the same way i use the gfx variable here from the code that creates the gui window. it's very annoying when the window is on another screen whenever it's brought up and removed.
  3. on shutdown or manual config save, save the current screen numbers and/or positions for both windows automatically so they are on the right spot when starting the emulator again. having to pull around two windows on every start is annoying. use the saved values on startup, unless one of the display ids is > SDL_GetNumVideoDisplays()-1 which could happen when e.g. a laptop owner doesnt have external screen attached currently. in which case the display ids are reset to 0. otherwise the window could get created outside of the visible area of the desktop.
    imo config used for that shouldn't be amiga config, but global. like e.g. start values for rom directory etc.

@rofl0r
Copy link
Author

rofl0r commented Feb 11, 2025

having to pull around two windows on every start is annoying

actually, i think it would be nice if emulator window would always be created on the same screen as F12 gui window (unless the saved position indicates otherwise - someone might want to have the F12 window deliberately on a side screen). so on start, you pull the gui window to screen you want it, then hit start and emulator is on that same screen.

@midwan
Copy link
Contributor

midwan commented Feb 12, 2025

I'm working on rewriting some parts of the gfx code, so I'll look into it as part of that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants