src/video/SDL_video.c
changeset 5479 5c4635640bf9
parent 5478 6b65ff3cee62
child 5480 55a687c55676
equal deleted inserted replaced
5478:6b65ff3cee62 5479:5c4635640bf9
  1016     display = SDL_GetDisplayForWindow(window);
  1016     display = SDL_GetDisplayForWindow(window);
  1017     return display->current_mode.format;
  1017     return display->current_mode.format;
  1018 }
  1018 }
  1019 
  1019 
  1020 static void
  1020 static void
       
  1021 SDL_RestoreMousePosition(SDL_Window *window)
       
  1022 {
       
  1023     int x, y;
       
  1024 
       
  1025     if (window == SDL_GetMouseFocus()) {
       
  1026         SDL_GetMouseState(&x, &y);
       
  1027         SDL_WarpMouseInWindow(window, x, y);
       
  1028     }
       
  1029 }
       
  1030 
       
  1031 static void
  1021 SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool fullscreen)
  1032 SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool fullscreen)
  1022 {
  1033 {
  1023     SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
  1034     SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
  1024     SDL_Window *other;
  1035     SDL_Window *other;
  1025 
  1036 
  1068                     SDL_SendWindowEvent(other, SDL_WINDOWEVENT_RESIZED,
  1079                     SDL_SendWindowEvent(other, SDL_WINDOWEVENT_RESIZED,
  1069                                         fullscreen_mode.w, fullscreen_mode.h);
  1080                                         fullscreen_mode.w, fullscreen_mode.h);
  1070                 } else {
  1081                 } else {
  1071                     SDL_OnWindowResized(other);
  1082                     SDL_OnWindowResized(other);
  1072                 }
  1083                 }
       
  1084 
       
  1085                 SDL_RestoreMousePosition(other);
  1073                 return;
  1086                 return;
  1074             }
  1087             }
  1075         }
  1088         }
  1076     }
  1089     }
  1077 
  1090 
  1083     }
  1096     }
  1084     display->fullscreen_window = NULL;
  1097     display->fullscreen_window = NULL;
  1085 
  1098 
  1086     /* Generate a mode change event here */
  1099     /* Generate a mode change event here */
  1087     SDL_OnWindowResized(window);
  1100     SDL_OnWindowResized(window);
       
  1101 
       
  1102     /* Restore the cursor position */
       
  1103     SDL_RestoreMousePosition(window);
  1088 }
  1104 }
  1089 
  1105 
  1090 #define CREATE_FLAGS \
  1106 #define CREATE_FLAGS \
  1091     (SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS | SDL_WINDOW_RESIZABLE)
  1107     (SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS | SDL_WINDOW_RESIZABLE)
  1092 
  1108