ALT Linux repositórios
Group :: Jogos/Enigmas
RPM: kiki
Main Changelog Spec Patches Sources Download Gear Bugs e FR Repocop
Patch: kiki-1.0.2-debian-sdl-set-video-mode.patch
Download
Download
- Allow the use of widescreen resolutions in fullscreen mode
- Remember window size when playing in windowed mode
Peter De Wachter (pdewacht@gmail.com)
placed in the public domain
Status: submitted upstream
--- a/kodilib/src/handler/KEventHandler.cpp
+++ b/kodilib/src/handler/KEventHandler.cpp
@@ -226,86 +226,55 @@
// --------------------------------------------------------------------------------------------------------
bool KEventHandler::setScreenSize ( int width, int height, bool fullscreen )
{
- int flags = SDL_OPENGL; // | SDL_ANYFORMAT;
- if (fullscreen)
- {
- flags |= SDL_FULLSCREEN;
- }
- else
- {
- flags |= SDL_RESIZABLE;
- }
-
- if (SDL_VideoModeOK (width, height, 32, flags) == 0) // video mode not ok
- {
- if (fullscreen)
- {
- switch (width)
- {
- case 1600:
- KConsole::printf ("couldn't set video mode %dx%d:\ntrying to fallback to 1280x1024 mode", width, height);
- return setScreenSize (1280, 1024, true);
- case 1280:
- KConsole::printf ("couldn't set video mode %dx%d:\ntrying to fallback to 1024x768 mode", width, height);
- return setScreenSize (1024, 768, true);
- case 1024:
- KConsole::printf ("couldn't set video mode %dx%d:\ntrying to fallback to 800x600 mode", width, height);
- return setScreenSize (800, 600, true);
- default:
- break;
- }
-
- // fallback to window mode
- KConsole::printf ("couldn't set video mode %dx%d (%s) test failed",
- width, height,
- fullscreen ? "fullscreen" : "window");
- KConsole::printf ("trying to fallback to window mode");
- return setScreenSize (width, height, false);
- }
- else
- {
- KConsole::printError( kStringPrintf("couldn't set video mode %dx%d (window test failed)", width, height));
- return false;
- }
- }
-
- if (SDL_SetVideoMode (width, height, 32, flags) == NULL) // paranoid
+ // For fullscreen mode the requested resolution is ignore, we'll pick what
+ // SDL thinks is best.
+
+ int baseFlags = SDL_OPENGL;
+
+ if (fullscreen)
{
- if (fullscreen)
+ int flags = baseFlags | SDL_FULLSCREEN;
+ KSize fallbackSize = getScreenSize();
+
+ SDL_Rect ** modes = SDL_ListModes (NULL, flags);
+
+ if (modes != 0 && modes != (SDL_Rect **)-1)
{
- switch (width)
- {
- case 1600:
- KConsole::printf ("couldn't init video mode %dx%d:\ntrying to fallback to 1280x1024 mode", width, height);
- return setScreenSize (1280, 1024, true);
- case 1280:
- KConsole::printf ("couldn't init video mode %dx%d:\ntrying to fallback to 1024x768 mode", width, height);
- return setScreenSize (1024, 768, true);
- case 1024:
- KConsole::printf ("couldn't init video mode %dx%d:\ntrying to fallback to 800x600 mode", width, height);
- return setScreenSize (800, 600, true);
- default:
- break;
- }
-
- // fallback to window mode
- KConsole::printf ("couldn't change video mode %dx%d (fullscreen setting failed)", width, height);
- KConsole::printf ("trying to fallback to window mode");
- return setScreenSize (width, height, false);
+ for (int i = 0; modes[i]; ++i)
+ {
+ if (SDL_SetVideoMode (modes[i]->w, modes[i]->h, 0, flags) != NULL)
+ {
+ // notify interested receivers that the resolution changed
+ notification_center.notifyReceiversType(KDL_NOTIFICATION_TYPE_VIDEO_MODE_CHANGED);
+ return true;
+ }
+
+ KConsole::printf ("couldn't change vidoe mode %dx%d (fullscreen):\n%s",
+ modes[i]->w, modes[i]->h, SDL_GetError());
+ }
}
else
{
- KConsole::printError(kStringPrintf("couldn't change video mode %dx%d (%s):\n%s\n",
- width, height,
- fullscreen ? "fullscreen" : "window", SDL_GetError()), true);
- return false;
+ KConsole::printf ("SDL didn't give us a list of video modes");
}
+
+ // fallback to window mode
+ KConsole::printf ("trying to fallback to window mode");
+ width = fallbackSize.w;
+ height = fallbackSize.h;
}
- // notify interested receivers that the resolution changed
- notification_center.notifyReceiversType(KDL_NOTIFICATION_TYPE_VIDEO_MODE_CHANGED);
+ int flags = baseFlags | SDL_RESIZABLE;
+ if (SDL_SetVideoMode (width, height, 0, flags) != NULL)
+ {
+ // notify interested receivers that the resolution changed
+ notification_center.notifyReceiversType(KDL_NOTIFICATION_TYPE_VIDEO_MODE_CHANGED);
+ return true;
+ }
- return true;
+ KConsole::printError(kStringPrintf("couldn't change video mode %dx%d (window):\n%s\n",
+ width, height, SDL_GetError()), true);
+ return false;
}
// --------------------------------------------------------------------------------------------------------
@@ -332,7 +301,7 @@
return;
}
// check if resolution is restricted
- if (modes != (SDL_Rect **)-1)
+ if (modes == (SDL_Rect **)-1)
{
// all resolutions available
width = 1024;
@@ -359,7 +328,7 @@
return;
}
// check if resolution is restricted
- if (modes != (SDL_Rect **)-1)
+ if (modes == (SDL_Rect **)-1)
{
// all resolutions available
width = 1024;
--- a/py/config.py
+++ b/py/config.py
@@ -46,11 +46,14 @@
Controller.setGamma(int(value))
elif option == "fullscreen":
fullscreen = self.getboolean(section, option)
- if fullscreen <> Controller.getFullscreen():
- screen_size = self.get (section, fullscreen and "fullscreen size" or "window size")
- screen_size = tuple (map (int, screen_size.split("x")))
- Controller.changeScreenSize (screen_size[0], screen_size[1], self.getboolean(section, option))
- self.set (section, "fullscreen size", "%dx%d" % Controller.getScreenSize())
+ if fullscreen:
+ # remember window size before switching to fullscreen
+ if not Controller.getFullscreen():
+ self.set (section, "window size", "%dx%d" % Controller.getScreenSize())
+ Controller.changeScreenSize (0, 0, true)
+ else:
+ window_size = map (int, self.get (section, "window size").split("x"))
+ Controller.changeScreenSize (window_size[0], window_size[1], false)
elif section == "keyboard":
player = Controller.getPlayer()
player.setKeyForAction (value, option.replace("_", " "))
@@ -70,6 +73,10 @@
def save (self):
"""save the configuration"""
+ # Save the window size. We need to do this here as the resize
+ # notifications don't get transfered to the Python code (AFAICS).
+ if not Controller.getFullscreen():
+ self.set ("display", "window size", "%dx%d" % Controller.getScreenSize())
try:
cfg_file = file (self.config_file_path, "w+")
self.write (cfg_file)