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;
|
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
|
const SdlWindow* SdlContext::getWindowForId(SDL_WindowID id) const
|
||||||
{
|
{
|
||||||
auto it = _windows.find(id);
|
auto it = _windows.find(id);
|
||||||
@@ -1091,6 +1122,16 @@ bool SdlContext::handleEvent(const SDL_TouchFingerEvent& ev)
|
|||||||
return SdlTouch::handleEvent(this, copy.tfinger);
|
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)
|
bool SdlContext::eventToPixelCoordinates(SDL_WindowID id, SDL_Event& ev)
|
||||||
{
|
{
|
||||||
auto w = getWindowForId(id);
|
auto w = getWindowForId(id);
|
||||||
|
|||||||
@@ -121,6 +121,9 @@ class SdlContext
|
|||||||
|
|
||||||
[[nodiscard]] bool addDisplayWindow(SDL_DisplayID id);
|
[[nodiscard]] bool addDisplayWindow(SDL_DisplayID id);
|
||||||
[[nodiscard]] bool removeDisplayWindow(SDL_DisplayID id);
|
[[nodiscard]] bool removeDisplayWindow(SDL_DisplayID id);
|
||||||
|
[[nodiscard]] bool detectDisplays();
|
||||||
|
[[nodiscard]] rdpMonitor getDisplay(SDL_DisplayID id) const;
|
||||||
|
[[nodiscard]] std::vector<SDL_DisplayID> getDisplayIds() const;
|
||||||
|
|
||||||
[[nodiscard]] sdlDispContext& getDisplayChannelContext();
|
[[nodiscard]] sdlDispContext& getDisplayChannelContext();
|
||||||
[[nodiscard]] sdlInput& getInputChannelContext();
|
[[nodiscard]] sdlInput& getInputChannelContext();
|
||||||
@@ -162,6 +165,9 @@ class SdlContext
|
|||||||
[[nodiscard]] bool handleEvent(const SDL_MouseWheelEvent& ev);
|
[[nodiscard]] bool handleEvent(const SDL_MouseWheelEvent& ev);
|
||||||
[[nodiscard]] bool handleEvent(const SDL_TouchFingerEvent& ev);
|
[[nodiscard]] bool handleEvent(const SDL_TouchFingerEvent& ev);
|
||||||
|
|
||||||
|
void addOrUpdateDisplay(SDL_DisplayID id, const rdpMonitor& monitor);
|
||||||
|
void deleteDisplay(SDL_DisplayID id);
|
||||||
|
|
||||||
[[nodiscard]] bool createPrimary();
|
[[nodiscard]] bool createPrimary();
|
||||||
[[nodiscard]] std::string windowTitle() const;
|
[[nodiscard]] std::string windowTitle() const;
|
||||||
[[nodiscard]] bool waitForWindowsCreated();
|
[[nodiscard]] bool waitForWindowsCreated();
|
||||||
@@ -206,6 +212,7 @@ class SdlContext
|
|||||||
|
|
||||||
SdlConnectionDialogWrapper _dialog;
|
SdlConnectionDialogWrapper _dialog;
|
||||||
|
|
||||||
|
std::map<SDL_DisplayID, rdpMonitor> _displays;
|
||||||
std::map<SDL_WindowID, SdlWindow> _windows;
|
std::map<SDL_WindowID, SdlWindow> _windows;
|
||||||
|
|
||||||
uint32_t _windowWidth = 0;
|
uint32_t _windowWidth = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user