[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:
akallabeth
2026-01-30 11:02:07 +01:00
committed by Armin Novak
parent efa15e1dc2
commit e2dd2eedab
2 changed files with 48 additions and 0 deletions

View File

@@ -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);