Skip to content

Commit

Permalink
Allow SDL2 2.0.2 (travis version)
Browse files Browse the repository at this point in the history
  • Loading branch information
Flamefire committed Aug 9, 2019
1 parent cd538cd commit 469c0b0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion extras/videoDrivers/SDL2/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
set(SDL2_BUILDING_LIBRARY ON)
find_package(SDL2 2.0.4)
find_package(SDL2 2.0.2)

if(SDL2_FOUND)
add_library(videoSDL2 SHARED ${RTTR_DRIVER_INTERFACE} VideoSDL2.cpp VideoSDL2.h icon.h icon.cpp)
Expand Down
15 changes: 12 additions & 3 deletions extras/videoDrivers/SDL2/VideoSDL2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,9 @@ bool VideoSDL2::ResizeScreen(const VideoMode& newSize, bool fullscreen)
isFullscreen_ = (SDL_GetWindowFlags(window) & SDL_WINDOW_FULLSCREEN) != 0;
if(!isFullscreen_)
{
#if SDL_VERSION_ATLEAST(2, 0, 5)
SDL_SetWindowResizable(window, SDL_TRUE);
#endif
MoveWindowToCenter();
}
}
Expand Down Expand Up @@ -386,11 +388,11 @@ bool VideoSDL2::MessageLoop()
CallBack->Msg_RightUp(mouse_xy);
}
break;
case SDL_MOUSEWHEEL:
{
int y = ev.wheel.y;
case SDL_MOUSEWHEEL: { int y = ev.wheel.y;
#if SDL_VERSION_ATLEAST(2, 0, 4)
if(ev.wheel.direction == SDL_MOUSEWHEEL_FLIPPED)
y = -y;
#endif
if(y > 0)
CallBack->Msg_WheelUp(mouse_xy);
else if(y < 0)
Expand Down Expand Up @@ -472,11 +474,18 @@ void* VideoSDL2::GetMapPointer() const
void VideoSDL2::MoveWindowToCenter()
{
SDL_Rect usableBounds;
#if SDL_VERSION_ATLEAST(2, 0, 5)
CHECK_SDL(SDL_GetDisplayUsableBounds(SDL_GetWindowDisplayIndex(window), &usableBounds));
int top, left, bottom, right;
CHECK_SDL(SDL_GetWindowBordersSize(window, &top, &left, &bottom, &right));
usableBounds.w -= left + right;
usableBounds.h -= top + bottom;
#else
CHECK_SDL(SDL_GetDisplayBounds(SDL_GetWindowDisplayIndex(window), &usableBounds));
// rough estimates
usableBounds.w -= 10;
usableBounds.h -= 30;
#endif
if(usableBounds.w < GetWindowSize().width || usableBounds.h < GetWindowSize().height)
{
SDL_SetWindowSize(window, usableBounds.w, usableBounds.h);
Expand Down

0 comments on commit 469c0b0

Please sign in to comment.