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

SDL: Allow toggling fullscreen/windowed mode #31

Merged
merged 21 commits into from
Apr 25, 2013

Conversation

vasi
Copy link
Contributor

@vasi vasi commented Apr 24, 2013

Currently if you launch SheepShaver or BasiliskII in fullscreen mode or windowed mode, you stay in that mode until you quit the emulator. On OS X this is especially bad: since fullscreen SDL gives no way to access the host OS, you're stuck in SS/B2. This patch allows you to use Ctrl-Return to toggle between fullscreen or windowed mode.

Sorry if it's a bit of a monster patch, here's a breakdown:

  • The first 3 commits fix a few bugs that were getting in my way:
  • The next 3 commits remove some obsolete code
  • The next 11 commits merge driver_window and driver_fullscreen into one. This lets us switch modes, without destroying the framebuffer that the emulated OS is using. It also cleans up a lot of duplicated code.
  • The last 4 commits actually enable fullscreen/windowed toggling.

I managed to rebase so it's pretty clean, I think each commit clearly makes sense in sequence. Thanks for taking a look!

vasi added 21 commits April 20, 2013 19:01
Prevent intermittent crashing when prefs contains empty lines or lines with
no spaces.
If mouse is grabbed on OS X, every time the mouse cursor icon changes the
cursor is recentered. Workaround similar to Windows in video_set_cursor().
Issue: cebix#26

On non-Mac platforms, driver_fullscreen constructor sets up software cursor,
but switch_to_current_mode() ask for a hardware cursor, possibly due to a typo.
Neither one ends up being drawn, so the cursor goes invisible.

This change makes them agree to use a software cursor. We should eventually
move to just one place deciding which cursor to use, so they don't have to be
kept in sync.
The old SDL_QuitSubsystem workaround is probably obsolete, and causes
flicker on resolution changes.
It always points to a member of an SDL_Surface, which is freed by SDL.
mouse_last_x, mouse_last_y and driver_window::mouse_moved() look like remnants
of X11 video, they're never really used.
We want to have just one base driver that can handle both fullscreen and
windowed mode, so that we can easily switch between modes.

Create a virtual init() method to do construction, so we can move common code
from the derived classes into the base init().
Including blitter, gray ramp, frame buffer initialization.
Also decide in just one place whether to use hardware or software cursor.
They don't use anything special from fullscreen/windowed derived classes.
Also, get rid of unneeded friend declarations.
Split init() into one-time initialization, and adaptation to a new video mode.
@vasi
Copy link
Contributor Author

vasi commented Apr 24, 2013

Oh, I forgot to mention testing! I tested on both 32-bit and 64-bit Intel Mac and Linux. Previous versions of this patchset were tested on Windows and PPC Mac. I also tried to test on PPC Linux, but that build seems altogether broken due to sheepthreads stuff. I have no idea if the really weird builds like Amiga and NetBSD/68k are still working, but I tried to not do anything that would break them.

There are still things that don't work perfectly with this patch, but as far as I can they're all things that also worked badly before, eg: VOSF or B2 banks with certain bit depths still look weird, and mouse-grabbing and resolution switching don't work well together.

@RonaldPR
Copy link


Op 24 april 2013, om 10:59, schreef Dave Vasilevsky notifications@github.com:

Mouse-grabbing (Ctrl-F5) was unusable on OS X

Maybe a stupid question, but what is this about? What is "mouse-grabbing" in this context? As far as I know there never was a Ctrl-F5 key-combo in MacOS and, according to Apple documentation, in OSX Ctrl-F5 will move the focus to the toolbar in some applications.

Ronald.

@vasi
Copy link
Contributor Author

vasi commented Apr 24, 2013

It's not a Mac feature, it's a macemu feature that's been around for awhile, apparently. If you're using SDL video in windowed mode, Ctrl-F5 should cause the mouse to be "grabbed" by SS/B2, so that the cursor can't leave the window. This is useful for games I guess?

Anyhow I just wanted to make sure my patch didn't break it, and it's hard to do that if it's not even working right in the first place, at least on OS X which is my main development platform. So I had to fix it.

asvitkine added a commit that referenced this pull request Apr 25, 2013
SDL: Allow toggling fullscreen/windowed mode
@asvitkine asvitkine merged commit 0231906 into cebix:master Apr 25, 2013
@asvitkine
Copy link
Collaborator

Awesome, thanks!

JustinCB pushed a commit to JustinCB/macemu that referenced this pull request Apr 22, 2018
rakslice referenced this pull request in rakslice/macemu Feb 10, 2020
ADB mouse event buffering proposed by OulanB
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

Successfully merging this pull request may close these issues.

None yet

3 participants