Merge pull request #2284 from OTHGMars/SDLMonitor

Fills in monitor functions in PlatformWindowManagerSDL
This commit is contained in:
Areloch 2018-12-09 15:36:15 -06:00 committed by GitHub
commit 58cf310971
2 changed files with 34 additions and 26 deletions

View file

@ -61,8 +61,6 @@ PlatformWindowManagerSDL::PlatformWindowManagerSDL()
mOffscreenRender = false; mOffscreenRender = false;
mInputState = KeyboardInputState::NONE; mInputState = KeyboardInputState::NONE;
buildMonitorsList();
} }
PlatformWindowManagerSDL::~PlatformWindowManagerSDL() PlatformWindowManagerSDL::~PlatformWindowManagerSDL()
@ -75,9 +73,8 @@ PlatformWindowManagerSDL::~PlatformWindowManagerSDL()
RectI PlatformWindowManagerSDL::getPrimaryDesktopArea() RectI PlatformWindowManagerSDL::getPrimaryDesktopArea()
{ {
// TODO SDL // Primary is monitor 0
AssertFatal(0, ""); return getMonitorRect(0);
return RectI(0,0,0,0);
} }
Point2I PlatformWindowManagerSDL::getDesktopResolution() Point2I PlatformWindowManagerSDL::getDesktopResolution()
@ -100,46 +97,60 @@ S32 PlatformWindowManagerSDL::getDesktopBitDepth()
return bbp; return bbp;
} }
void PlatformWindowManagerSDL::buildMonitorsList()
{
// TODO SDL
}
S32 PlatformWindowManagerSDL::findFirstMatchingMonitor(const char* name) S32 PlatformWindowManagerSDL::findFirstMatchingMonitor(const char* name)
{ {
/// TODO SDL S32 count = SDL_GetNumVideoDisplays();
AssertFatal(0, ""); for (U32 index = 0; index < count; ++index)
{
if (dStrstr(name, SDL_GetDisplayName(index)) == name)
return index;
}
return 0; return 0;
} }
U32 PlatformWindowManagerSDL::getMonitorCount() U32 PlatformWindowManagerSDL::getMonitorCount()
{ {
// TODO SDL S32 monitorCount = SDL_GetNumVideoDisplays();
AssertFatal(0, ""); if (monitorCount < 0)
return 1; {
Con::errorf("SDL_GetNumVideoDisplays() failed: %s", SDL_GetError());
monitorCount = 0;
}
return (U32)monitorCount;
} }
const char* PlatformWindowManagerSDL::getMonitorName(U32 index) const char* PlatformWindowManagerSDL::getMonitorName(U32 index)
{ {
// TODO SDL const char* monitorName = SDL_GetDisplayName(index);
AssertFatal(0, ""); if (monitorName == NULL)
Con::errorf("SDL_GetDisplayName() failed: %s", SDL_GetError());
return "Monitor"; return monitorName;
} }
RectI PlatformWindowManagerSDL::getMonitorRect(U32 index) RectI PlatformWindowManagerSDL::getMonitorRect(U32 index)
{ {
// TODO SDL SDL_Rect sdlRect;
AssertFatal(0, ""); if (0 != SDL_GetDisplayBounds(index, &sdlRect))
{
Con::errorf("SDL_GetDisplayBounds() failed: %s", SDL_GetError());
return RectI(0, 0, 0, 0);
}
return RectI(0, 0, 0,0 ); return RectI(sdlRect.x, sdlRect.y, sdlRect.w, sdlRect.h);
} }
void PlatformWindowManagerSDL::getMonitorRegions(Vector<RectI> &regions) void PlatformWindowManagerSDL::getMonitorRegions(Vector<RectI> &regions)
{ {
// TODO SDL SDL_Rect sdlRect;
AssertFatal(0, ""); S32 monitorCount = SDL_GetNumVideoDisplays();
for (S32 index = 0; index < monitorCount; ++index)
{
if (0 == SDL_GetDisplayBounds(index, &sdlRect))
regions.push_back(RectI(sdlRect.x, sdlRect.y, sdlRect.w, sdlRect.h));
}
} }
void PlatformWindowManagerSDL::getWindows(VectorPtr<PlatformWindow*> &windows) void PlatformWindowManagerSDL::getWindows(VectorPtr<PlatformWindow*> &windows)

View file

@ -105,9 +105,6 @@ public:
virtual S32 getDesktopBitDepth(); virtual S32 getDesktopBitDepth();
virtual Point2I getDesktopResolution(); virtual Point2I getDesktopResolution();
/// Build out the monitors list.
virtual void buildMonitorsList();
virtual S32 findFirstMatchingMonitor(const char* name); virtual S32 findFirstMatchingMonitor(const char* name);
virtual U32 getMonitorCount(); virtual U32 getMonitorCount();
virtual const char* getMonitorName(U32 index); virtual const char* getMonitorName(U32 index);