1
0
Fork 0
Commit graph

306 commits

Author SHA1 Message Date
Patryk Obara
65b4e7c5d7 Remove HandleVideoResize call from SetWindowMode
This call was useful during development and testing with
output=opengl, but now it's no longer necessary.  This call causes
output=texture to go into initialization loop, which falls back to
surface, which we definitely do not want.
2020-04-14 06:28:08 +02:00
Patryk Obara
75e0a1af86 Add windowresolution options: 'resizable' and 'default'
'resizable' option turns on resizable window if all the prerequisites
are met (OpenGL and compatible shader). Right now only shader 'sharp' was
tested as compatible, but other built-in shaders might be whitelisted in
the future as well (e.g. 'advmame*' shaders seem like good candidates).

Using incompatible shader does not cause any particular problems for the
users, but it looks really ugly - shader implementations clearly were
implemented only for a fixed window size.

'default' option acts as 'resizable' on Linux and 'original' everywhere
else. It also gives as an option to tweak available windowresolution
settings without causing too much disruption to end users.
2020-04-14 06:28:08 +02:00
Patryk Obara
2ab250d1a1 Update minimum window size
It's necessary for usecase when game changes resolution while in game.
We don't want to resize the window in such case, just change minimum
size (SDL might decide to update the window size in the result, if new
resolution is higher than current window size).
2020-04-14 06:28:08 +02:00
Patryk Obara
7a98ff787f Update clip when window is being resized
This works very well when user is resizing the window and going
in/leaving fullscreen.  It does not affect usecase where window size is
being updated by the emulator (e.g. game changing resolution).
2020-04-14 06:28:08 +02:00
Patryk Obara
a5e8118afd Cleanup and initialize all fields in sdl.draw 2020-04-14 06:28:08 +02:00
Patryk Obara
5ee474fdb8 Restore redraw instead of reset during expose
This prevents perceived lag window is being dragged (at least on Linux).
2020-04-14 06:28:08 +02:00
Patryk Obara
edf8e7e850 Make window resizable with a minimum size 2020-04-14 06:28:08 +02:00
Patryk Obara
860003a89f Calculate clip stretching inside the window 2020-04-14 06:28:08 +02:00
Patryk Obara
5b5cbd7f4b Watch window resize events 2020-04-14 06:28:08 +02:00
Patryk Obara
fff4dcf8b3 Add want_resizable_window flag 2020-04-14 06:28:08 +02:00
Patryk Obara
ffb9fe14bb Add 'resizable' parameter to SetWindowMode 2020-04-14 06:28:08 +02:00
Patryk Obara
e4b19ccd37 Fix window size and position when leaving fullscreen
Overrides previous, Windows-only hack used for the same purpose.

After initial window position, OS or window manager will take care of
emplacing window - this change takes care only of situation, when there
is NO initial window position.

Additionally, avoid re-setting the window size on every SetSDLWindowMode
call. This prevents a number of issues with the window being set to
incorrect size while switching between fullscreen and window.

Overally this change takes care of number of small issues happening on
macOS, Windows (without need for an ifdef), and Linux with KDE and MATE.
Also makes the behaviour more consistent for Gnome when starting dosbox
via XWayland.
2020-04-10 09:57:29 +02:00
Patryk Obara
803d65dd23 Log SDL window events
SDL2 introduced a bunch of new events, that old SDL1.2 implementation
did not have. We probably should start using some of them…

It's also extremely helpful for comparing order/number of window events
arriving on different OSes and WMs.
2020-04-10 09:57:29 +02:00
Patryk Obara
86d6647b4e Improved windowresolution handling
Move the code to a separate function to make it easier to understand and
modify. Remove traces of windowresolution=X% support - this option
causes more harm than benefit.

Add bound checks to prevent user from setting up window size bigger then
configured display allows.
2020-04-10 09:57:29 +02:00
Patryk Obara
d0bf1ee09b Allow selecting windowresolution only on start
Changing this option dynamically via "config" built-in never worked, it
was always broken.  Set it to change'able only on start, otherwise all
broken edge-cases would need to be fixed.
2020-04-10 09:57:29 +02:00
Patryk Obara
b1c69bebff Wrap description of sdl.mapperfile in .conf file 2020-04-10 09:57:29 +02:00
Patryk Obara
bf514eebfe Make HandleVideoResize a static function 2020-04-10 09:57:29 +02:00
Patryk Obara
f243f585ed Change Config::PrintConfig to use std::string 2020-04-04 04:20:28 +02:00
Patryk Obara
5a41709a47 Cleanup windows title 2020-04-04 04:20:28 +02:00
Patryk Obara
726f024546 Update --version information 2020-04-04 04:20:28 +02:00
Patryk Obara
6b24ff7dee Reformat OpenGL log line 2020-04-04 04:20:28 +02:00
Patryk Obara
e46604f4a2 Reformat texture_renderer log 2020-04-04 04:20:28 +02:00
Patryk Obara
a032e1acb0 Reformat pixel-perfect related logs
Now they are using the same format as other lines, making the output
more readable.
2020-04-04 04:20:28 +02:00
Patryk Obara
72d33df24b Remove SDL 1.2 SDL_DISABLE_LOCK_KEYS hack
Such environment variable is nowhere to be found in SDL2 source code.
2020-04-04 04:20:28 +02:00
Patryk Obara
3aadf84a00 Restore display setting property
This property can be used for selecting which display dosbox should
initially use. Number 0 can be either primary display or left-most
display, depending on OS and user settings.
2020-04-04 04:20:28 +02:00
Patryk Obara
6f76a1e38d Remove misleading comment 2020-04-04 04:20:28 +02:00
krcroft
a8a0e5fa91 Cleanup PVS warning about uninitialized members 2020-04-04 04:10:06 +02:00
krcroft
619742f70f Improve comment about EXPOSED event 2020-03-30 21:48:02 +02:00
krcroft
b4e6e40c95 Assess the mouse capture state when gaining window focus
This fixes mouse visibility issues on the Raspberry Pi,
which uses an older customized version of SDL2. SDL2 on
the Pi fires different windows events in a different
order, making dealing with states challenging.

To handle this generically, we additionally assess the
mouse capture state after the Window has gained focus.

We also add a "has_focus" state tracking boolean to the
SDL object, which protects against general SDL mouse
trigger events from changing the mouse state before the
Window has "risen" and delivered us an EXPOSED or FOCUS
event. In the prior code rapidly clicking the mouse while
DOSBox was starting could freeze the mouse cursor in
place on the Pi.

We still also assess the mouse state on EXPOSE events,
which is fired after full - windowed modes are toggled.
The EXPOSE even occurs reliably on OSX, X11, Wayland, and
Windows after the window has settled (but is never fired
on the Pi).
2020-03-30 21:48:02 +02:00
Patryk Obara
9d2b7ea578 Adjust help strings for sdl options 2020-03-27 00:54:11 +01:00
Patryk Obara
193f2ed564 Declare sdl.vsync as deprecated/disabled
vsync is an option introduced by SDL2 patch, but the testing indicates,
that it very rarely (if ever) works.  We still want to support it, but
this might require serious implementation effort, so for the time being
we're removing broken option to prevent confusing the users.
2020-03-27 00:54:11 +01:00
Patryk Obara
779131d396 Skip splash screen if resolution is not large enough
It's the easiest way to prevent problems when user wants to play the
game using fullscreen while explicitly setting tiny resolution
for a specific game (e.g. 320x200).
2020-03-27 00:54:11 +01:00
Patryk Obara
5ac2567adc Rename gimp_image to splash_image 2020-03-27 00:54:11 +01:00
Patryk Obara
6f238c0d1a Fix splash screen for surface output
All rendering backends except output=surface assume input buffer row
with the same length as output buffer row. Surface is "special" and in
fullscreen uses pitch equal to *screen* width instead. Padding the
output rows with black pixels is necessary for splash screen to show up
correctly.
2020-03-27 00:54:11 +01:00
Patryk Obara
00ffbd0977 Remove dead code remains of "lazy_fullscreen" feature 2020-03-27 00:54:11 +01:00
Patryk Obara
1f62338610 Fix indirect memory leak of icon surface 2020-03-27 00:54:11 +01:00
Patryk Obara
d34378b621 Define SDL rgb-masks for creating surfaces 2020-03-27 00:54:11 +01:00
Patryk Obara
a5b65b3c8e Initialize default window size before GUI_StartUp 2020-03-27 00:54:11 +01:00
Patryk Obara
acb020147d Move "extern C" to ppscale header 2020-03-27 00:54:11 +01:00
Patryk Obara
facabcee2a Handle surface as the last option during update
SCREEN_SURFACE is no longer the default option, and it's usable only for
debugging purposes. Move it to the last position in switches, to make
texture and opengl a little bit faster.
2020-03-27 00:54:11 +01:00
Patryk Obara
8d5bc9537a Prevent a crash in Windows AMD drivers
Usually, when window is being created without SDL_WINDOW_OPENGL flag,
SDL2 internally re-creates it to support OpenGL during
SDL_CreateRenderer if needed.

This leads to crash in AMD OpenGL drivers (Windows only), which happens
for drivers: "opengl", "opengles", "opengles2".

When the window is created with correct flag from the get-go, the crash
does not happen.

On Linux, the code does not crash either way (at least not when using
Mesa and AMDGPU open source driver), so there's no point in propagating
the hack.

Also, remove a comment that is no longer relevant to the code below.
2020-03-27 00:54:11 +01:00
Patryk Obara
bb43294f68 Store SDL texture render driver as std::string 2020-03-27 00:54:11 +01:00
Patryk Obara
54a50d4231 Replace Lock/UnlockTexture with UpdateTexture
Lock/UnlockTexture is stable and works very well on Linux and with
OpenGL texture driver and on Linux and Windows, but it's usage caused
problems with content of updated texture when used with drivers:
'direct3d11' on Windows and 'metal' on macOS.

Also, Lock/Unlock turned out to be the root cause of deadlocks for
'opengl' driver on AmigaOS.

According to SDL2 documentation, using Lock/UnlockTexture is supposed to
be faster, but in DOSBox usecase we couldn't confirm significant
performance change - there are some community reports indicating, that
UpdateTexture might be actually faster (but we couldn't confirm it
either).

Discussion on this topic can be found on SDL forum:
https://forums.libsdl.org/viewtopic.php?t=9728

In our case, switch to UpdateTexture has no serious negative impact, but
makes the behaviour more robust across the board.
2020-03-27 00:54:11 +01:00
Patryk Obara
fa4e8c28de Update description of sdl.windowresolution 2020-03-27 00:54:11 +01:00
Patryk Obara
aed68e9e6e Destroy SDL resources in the proper order
Prevent internal SDL2 asserts on Windows 10 when using output=texture,
also improves stability on AmigaOS and Linux using Wayland.
2020-03-27 00:54:11 +01:00
Patryk Obara
d3f3833f2c Set icon after sdl.window is created
Otherwise internal SDL2 asserts are triggered in Windows debug builds.
2020-03-27 00:54:11 +01:00
Patryk Obara
919099c757 Start with the correct full/window resolution
Make the user settings affect splash screen as well as emulator; this
way, when user wants to start in fullscreen, the splash screen will be
displayed in fullscreen - making the startup process more streamlined.

This fixes long-standing problem on SteamOS (or Steam in Big Picture
mode), when starting dosbox moves the user out of fullscreen to window
(to show tiny splash screen), and then back to fullscreen.
2020-03-27 00:54:11 +01:00
Patryk Obara
600ccccd37 Display splash screen using GFX API
Simplify the code displaying the splash screen and extract it to a new
function. Using GFX_* functions avoids the problem of re-creating
the window from scratch after splash is shown, which solves a lot of
problems:

- application window is always visible on screen, it does not disappear
  for a moment between closing splash and starting emulator.
- seriously reduces resolution trashing on start
- user will not experience loss of window focus due to splash screen
  disappearing (this was happening e.g. on AmigaOS)
2020-03-27 00:54:11 +01:00
Patryk Obara
0b173eec08 Cleanup and document GFX_StartUpdate function
Usage of this function depends on the state of global sdl struct; and
it's very easy to make a mistake - documentation should lower this risk.

Change the type of output parameter 'pitch' and assure type safety with
internal SDL types via static asserts.
2020-03-27 00:54:11 +01:00
Patryk Obara
08934b2972 Remove dead code remains of WinDIB usage
This used to have meaning for Windows 9x support via SDL 1.2; the issue
described in README was never mentioned in the context of SDL2.

Add missing include to video header while we're at it.
2020-03-27 00:54:11 +01:00