Browse Source

Platform: SDL disables power-saving when running. That's stupid, don't.

I'm getting kinda pissed at the strange defaults. Should I be using a
different toolkit altogether because SDL IS FOR GAMES ONLY? Given how
many bugreports and complaints there is about "Dosbox blocking
screensaver" I'm beginning to think it's SDL's fault, not mine.

Let the users control what they want, ffs, don't enable problematic
features like blocking powersave or disabling compositor by default.
Those should be a runtime option anyway, similarly to how video players
block powersaving only when *an actual video is playing*.
pull/603/head
Vladimír Vondruš 4 years ago
parent
commit
ed9f82fad0
  1. 4
      doc/changelog.dox
  2. 8
      src/Magnum/Platform/Sdl2Application.cpp
  3. 16
      src/Magnum/Platform/Sdl2Application.h

4
doc/changelog.dox

@ -505,6 +505,10 @@ See also:
@relativeref{Platform::Sdl2Application::KeyEvent::Key,Menu} for consistency
with @ref Platform::EmscriptenApplication and
@ref Platform::GlfwApplication (see [mosra/magnum#547](https://github.com/mosra/magnum/pull/547))
- @ref Platform::Sdl2Application now overrides SDL's default behavior that
prevents computer from entering a power-saving mode while the application
is running, as that's generally undesirable for regular GUI applications.
See @ref Platform-Sdl2Application-usage-power for more information.
@subsubsection changelog-latest-changes-scenegraph SceneGraph library

8
src/Magnum/Platform/Sdl2Application.cpp

@ -149,6 +149,14 @@ Sdl2Application::Sdl2Application(const Arguments& arguments, NoCreateT):
#ifdef SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR
SDL_SetHint(SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR, "0");
#endif
/* By default, SDL behaves like if it was playing a video or whatever,
preventing the computer from turning off the screen or going to sleep.
While it sorta makes sense for games, it's useless and annoying for
regular apps. Together with the compositor disabling those two are the
most stupid defaults. */
#ifdef SDL_HINT_VIDEO_ALLOW_SCREENSAVER
SDL_SetHint(SDL_HINT_VIDEO_ALLOW_SCREENSAVER, "1");
#endif
/* Available since 2.0.12, use EGL if desired */
#if defined(MAGNUM_TARGET_EGL) && defined(SDL_HINT_VIDEO_X11_FORCE_EGL)
SDL_SetHint(SDL_HINT_VIDEO_X11_FORCE_EGL, "1");

16
src/Magnum/Platform/Sdl2Application.h

@ -286,6 +286,19 @@ If no other application header is included, this class is also aliased to
@cpp Platform::Application @ce and the macro is aliased to @cpp MAGNUM_APPLICATION_MAIN() @ce
to simplify porting.
@subsection Platform-Sdl2Application-usage-power Power management
SDL by default prevents the computer from powering off the or screen going to
sleep. While possibly useful for game-like use cases, it's generally
undesirable for regular applications. @ref Sdl2Application turns this behavior
off. You can restore SDL's default behavior by disabling the
[corresponding SDL hint](https://wiki.libsdl.org/CategoryHints) through an
environment variable or through @cpp SDL_SetHint() @ce from your application.
@code{.sh}
SDL_VIDEO_ALLOW_SCREENSAVER=0 ./your-app
@endcode
@subsection Platform-Sdl2Application-usage-posix POSIX specifics
On POSIX systems, SDL by default intercepts the `SIGTERM` signal and generates
@ -314,7 +327,8 @@ for non-fullscreen apps (KWin, among others, is known to respect this setting).
When using SDL >= 2.0.8, @ref Sdl2Application turns this behavior off, keeping
the compositor running to avoid the flicker. You can turn this behavior back on
by enabling the [corresponding SDL hint](https://wiki.libsdl.org/CategoryHints)
through an environment variable:
through an environment variable or through @cpp SDL_SetHint() @ce from your
application.
@code{.sh}
SDL_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR=1 ./your-app

Loading…
Cancel
Save