Fullscreen mouse.
authorTimo Korvola <tkorvola@iki.fi>
Mon, 26 Mar 2018 17:13:42 +0000 (20:13 +0300)
committerTimo Korvola <tkorvola@iki.fi>
Wed, 28 Mar 2018 16:40:31 +0000 (19:40 +0300)
Apparently there is almost nothing to do here: just make sure to set
the logical size whenever in fullscreen, and SDL maps mouse events
to logical coordinates.

src/sdl/sf_video.c

index 15d4952690b072552a0e09479a621b04e1280398..35ec8191d91ca4fa7224c85226add36327e203df 100644 (file)
@@ -400,12 +400,6 @@ static void cleanvideo()
 #define GM 0x00ff00
 #define BM 0xff0000
 
-static int check( int R, int G, int B){
-  if (R==RM && G==GM && B==BM) return 0;
-  if (R==BM && G==GM && B==RM) return -1;
-  return 1;
-  }
-
 extern char stripped_story_name[];
 
 void sf_initvideo( int W, int H, int full)
@@ -448,13 +442,13 @@ void sf_initvideo( int W, int H, int full)
         os_fatal("Couldn't create %dx%d window: %s",
                  reqW, reqH, SDL_GetError());
     }
-    if (reqW != W || reqH != H) {
+    if (full) {
         SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear");
         if (SDL_RenderSetLogicalSize(renderer, W, H))
             os_fatal("Failed to set logical rendering size to %dx%d: %s",
                      W, H, SDL_GetError());
     }
-    pixfmt = SDL_MasksToPixelFormatEnum(32, 0xff, 0xff00, 0xff0000, 0);
+    pixfmt = SDL_MasksToPixelFormatEnum(32, RM, GM, BM, 0);
     if (!(texture = SDL_CreateTexture(renderer, pixfmt,
                                       SDL_TEXTUREACCESS_STREAMING, W, H)))
         os_fatal("Failed to create texture: %s", SDL_GetError());
@@ -554,7 +548,8 @@ static int numAltQ = 0;
 
 static void set_mouse_xy(int x, int y)
 {
-    //TODO Scale to logical coordinates.
+    /* This is enough even in fullscreen:
+       SDL maps mouse events to logical coordinates. */
     mouse_x = x + 1;
     mouse_y = y + 1;
 }