Skip to contentSkip to conversation

sdl: Reverse support for video mode setting

PATCH RESEND Superseded Lei Li 2 participants 4 messages Sep 4, 2013 – Nov 6, 2013

lore
Share & tools
lore

Lei Li

author
#0 lore raw

PATCH RESEND 1/1 sdl: Reverse support for video mode setting

Currently, If the setting of video mode failed, qemu will exit. It should go back to the previous setting if the new screen resolution failed. This patch fixes LP#1216368, add support to revert to existing surface for the failure of video mode setting.

---
 ui/sdl.c |   23 +++++++++++++++++++----
 1 files changed, 19 insertions(+), 4 deletions(-)
ui/sdl.c +19 -4
index 39a42d6..9d8583c 100644
@@ -86,6 +86,7 @@ static void sdl_update(DisplayChangeListener *dcl,
 static void do_sdl_resize(int width, int height, int bpp)
 {
     int flags;
+    SDL_Surface *tmp_screen;
 
     //    printf("resizing to %d %d\n", w, h);
 
@@ -98,12 +99,26 @@ static void do_sdl_resize(int width, int height, int bpp)
     if (gui_noframe)
         flags |= SDL_NOFRAME;
 
-    real_screen = SDL_SetVideoMode(width, height, bpp, flags);
+    tmp_screen = SDL_SetVideoMode(width, height, bpp, flags);
     if (!real_screen) {
-	fprintf(stderr, "Could not open SDL display (%dx%dx%d): %s\n", width, 
-		height, bpp, SDL_GetError());
-        exit(1);
+        if (!tmp_screen) {
+            fprintf(stderr, "Could not open SDL display (%dx%dx%d): %s\n",
+                    width, height, bpp, SDL_GetError());
+            exit(1);
+        }
+    } else {
+        /*
+         * Revert to the previous video mode if the change of resizing or
+         * resolution failed.
+         */
+        if (!tmp_screen) {
+            fprintf(stderr, "Failed to set SDL display (%dx%dx%d): %s\n",
+                    width, height, bpp, SDL_GetError());
+            return;
+        }
     }
+
+    real_screen = tmp_screen;
 }
 
 static void sdl_switch(DisplayChangeListener *dcl,
Signature · 1 line
1.7.7.6
author
#1 lore raw

This patch has been confirmed by the reporter himself as link below,

https://bugs.launchpad.net/qemu/+bug/1216368

It has been on the mailing list for a while, could it be merged? PING...

Quoted 54 lines · Lei Li

Currently, If the setting of video mode failed, qemu will exit. It should go back to the previous setting if the new screen resolution failed. This patch fixes LP#1216368, add support to revert to existing surface for the failure of video mode setting.

---
  ui/sdl.c |   23 +++++++++++++++++++----
  1 files changed, 19 insertions(+), 4 deletions(-)
ui/sdl.c +19 -4
index 39a42d6..9d8583c 100644
@@ -86,6 +86,7 @@ static void sdl_update(DisplayChangeListener *dcl,
  static void do_sdl_resize(int width, int height, int bpp)
  {
      int flags;
+    SDL_Surface *tmp_screen;
 
      //    printf("resizing to %d %d\n", w, h);
 
@@ -98,12 +99,26 @@ static void do_sdl_resize(int width, int height, int bpp)
      if (gui_noframe)
          flags |= SDL_NOFRAME;
 
-    real_screen = SDL_SetVideoMode(width, height, bpp, flags);
+    tmp_screen = SDL_SetVideoMode(width, height, bpp, flags);
      if (!real_screen) {
-	fprintf(stderr, "Could not open SDL display (%dx%dx%d): %s\n", width,
-		height, bpp, SDL_GetError());
-        exit(1);
+        if (!tmp_screen) {
+            fprintf(stderr, "Could not open SDL display (%dx%dx%d): %s\n",
+                    width, height, bpp, SDL_GetError());
+            exit(1);
+        }
+    } else {
+        /*
+         * Revert to the previous video mode if the change of resizing or
+         * resolution failed.
+         */
+        if (!tmp_screen) {
+            fprintf(stderr, "Failed to set SDL display (%dx%dx%d): %s\n",
+                    width, height, bpp, SDL_GetError());
+            return;
+        }
      }
+
+    real_screen = tmp_screen;
  }
 
  static void sdl_switch(DisplayChangeListener *dcl,
Signature · 1 line
Lei
author
#2 lore raw

Ping^2

Quoted 69 lines · Lei Li

This patch has been confirmed by the reporter himself as link below,

https://bugs.launchpad.net/qemu/+bug/1216368

It has been on the mailing list for a while, could it be merged? PING...

Quoted 59 lines · Lei Li

Currently, If the setting of video mode failed, qemu will exit. It should go back to the previous setting if the new screen resolution failed. This patch fixes LP#1216368, add support to revert to existing surface for the failure of video mode setting.

---
  ui/sdl.c |   23 +++++++++++++++++++----
  1 files changed, 19 insertions(+), 4 deletions(-)
ui/sdl.c +10 -4
index 39a42d6..9d8583c 100644
@@ -86,6 +86,7 @@ static void sdl_update(DisplayChangeListener *dcl,
  static void do_sdl_resize(int width, int height, int bpp)
  {
      int flags;
+    SDL_Surface *tmp_screen;
 
      //    printf("resizing to %d %d\n", w, h);
 
@@ -98,12 +99,26 @@ static void do_sdl_resize(int width, int height, 
 int bpp)
      if (gui_noframe)
          flags |= SDL_NOFRAME;
 
-    real_screen = SDL_SetVideoMode(width, height, bpp, flags);
+    tmp_screen = SDL_SetVideoMode(width, height, bpp, flags);
      if (!real_screen) {
-    fprintf(stderr, "Could not open SDL display (%dx%dx%d): %s\n", 
 width,
-        height, bpp, SDL_GetError());
-        exit(1);
+        if (!tmp_screen) {
+            fprintf(stderr, "Could not open SDL display (%dx%dx%d): 
 %s\n",
+                    width, height, bpp, SDL_GetError());
+            exit(1);
+        }
+    } else {
+        /*
+         * Revert to the previous video mode if the change of 

resizing or

ui/sdl.c +4 -0
+         * resolution failed.
+         */
+        if (!tmp_screen) {
+            fprintf(stderr, "Failed to set SDL display (%dx%dx%d): 

%s\n",

ui/sdl.c +5 -0
+                    width, height, bpp, SDL_GetError());
+            return;
+        }
      }
+
+    real_screen = tmp_screen;
  }
 
  static void sdl_switch(DisplayChangeListener *dcl,
Signature · 1 line
Lei
Reviewed-by
#3 lore raw

Il 06/11/2013 14:31, Lei Li ha scritto:

Quoted 74 lines

Ping^2

Quoted 69 lines · Lei Li

This patch has been confirmed by the reporter himself as link below,

https://bugs.launchpad.net/qemu/+bug/1216368

It has been on the mailing list for a while, could it be merged? PING...

Quoted 59 lines · Lei Li

Currently, If the setting of video mode failed, qemu will exit. It should go back to the previous setting if the new screen resolution failed. This patch fixes LP#1216368, add support to revert to existing surface for the failure of video mode setting.

---
  ui/sdl.c |   23 +++++++++++++++++++----
  1 files changed, 19 insertions(+), 4 deletions(-)
ui/sdl.c +10 -4
index 39a42d6..9d8583c 100644
@@ -86,6 +86,7 @@ static void sdl_update(DisplayChangeListener *dcl,
  static void do_sdl_resize(int width, int height, int bpp)
  {
      int flags;
+    SDL_Surface *tmp_screen;
 
      //    printf("resizing to %d %d\n", w, h);
 
@@ -98,12 +99,26 @@ static void do_sdl_resize(int width, int height,
 int bpp)
      if (gui_noframe)
          flags |= SDL_NOFRAME;
 
-    real_screen = SDL_SetVideoMode(width, height, bpp, flags);
+    tmp_screen = SDL_SetVideoMode(width, height, bpp, flags);
      if (!real_screen) {
-    fprintf(stderr, "Could not open SDL display (%dx%dx%d): %s\n",
 width,
-        height, bpp, SDL_GetError());
-        exit(1);
+        if (!tmp_screen) {
+            fprintf(stderr, "Could not open SDL display (%dx%dx%d):
 %s\n",
+                    width, height, bpp, SDL_GetError());
+            exit(1);
+        }
+    } else {
+        /*
+         * Revert to the previous video mode if the change of

resizing or

ui/sdl.c +4 -0
+         * resolution failed.
+         */
+        if (!tmp_screen) {
+            fprintf(stderr, "Failed to set SDL display (%dx%dx%d):

%s\n",

ui/sdl.c +5 -0
+                    width, height, bpp, SDL_GetError());
+            return;
+        }
      }
+
+    real_screen = tmp_screen;
  }
 
  static void sdl_switch(DisplayChangeListener *dcl,