mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-15 00:44:19 +09:00
[client,sdl] implement display detection handling
* SdlContext::detectDisplays to create a initial list of displays and their rdpMonitor configuration * SdlContext::getDisplays to query a SDL_DisplayID at runtime * SdlContext::getDisplayIds to query available SDL_DisplayID at runtime
This commit is contained in:
@@ -888,6 +888,37 @@ bool SdlContext::removeDisplayWindow(SDL_DisplayID id)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SdlContext::detectDisplays()
|
||||
{
|
||||
int count = 0;
|
||||
auto display = SDL_GetDisplays(&count);
|
||||
if (!display)
|
||||
return false;
|
||||
for (int x = 0; x < count; x++)
|
||||
{
|
||||
const auto id = display[x];
|
||||
auto monitor = SdlWindow::query(id, false);
|
||||
addOrUpdateDisplay(id, monitor);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
rdpMonitor SdlContext::getDisplay(SDL_DisplayID id) const
|
||||
{
|
||||
return _displays.at(id);
|
||||
}
|
||||
|
||||
std::vector<SDL_DisplayID> SdlContext::getDisplayIds() const
|
||||
{
|
||||
std::vector<SDL_DisplayID> keys;
|
||||
for (const auto& entry : _displays)
|
||||
{
|
||||
keys.push_back(entry.first);
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
|
||||
const SdlWindow* SdlContext::getWindowForId(SDL_WindowID id) const
|
||||
{
|
||||
auto it = _windows.find(id);
|
||||
@@ -1091,6 +1122,16 @@ bool SdlContext::handleEvent(const SDL_TouchFingerEvent& ev)
|
||||
return SdlTouch::handleEvent(this, copy.tfinger);
|
||||
}
|
||||
|
||||
void SdlContext::addOrUpdateDisplay(SDL_DisplayID id, const rdpMonitor& monitor)
|
||||
{
|
||||
_displays.emplace(id, monitor);
|
||||
}
|
||||
|
||||
void SdlContext::deleteDisplay(SDL_DisplayID id)
|
||||
{
|
||||
_displays.erase(id);
|
||||
}
|
||||
|
||||
bool SdlContext::eventToPixelCoordinates(SDL_WindowID id, SDL_Event& ev)
|
||||
{
|
||||
auto w = getWindowForId(id);
|
||||
|
||||
Reference in New Issue
Block a user