mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-14 08:24:16 +09:00
Merge pull request #11487 from akallabeth/sdl-fixes
[client,sdl] fix orientation update
This commit is contained in:
@@ -665,15 +665,10 @@ static BOOL sdl_create_windows(SdlContext* sdl)
|
||||
h = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight);
|
||||
}
|
||||
|
||||
Uint32 flags = 0;
|
||||
Uint32 flags = SDL_WINDOW_HIGH_PIXEL_DENSITY;
|
||||
auto startupX = SDL_WINDOWPOS_CENTERED_DISPLAY(id);
|
||||
auto startupY = SDL_WINDOWPOS_CENTERED_DISPLAY(id);
|
||||
|
||||
if (monitor->attributes.desktopScaleFactor > 100)
|
||||
{
|
||||
flags |= SDL_WINDOW_HIGH_PIXEL_DENSITY;
|
||||
}
|
||||
|
||||
if (freerdp_settings_get_bool(settings, FreeRDP_Fullscreen) &&
|
||||
!freerdp_settings_get_bool(settings, FreeRDP_UseMultimon))
|
||||
{
|
||||
|
||||
@@ -138,22 +138,6 @@ static BOOL sdl_apply_max_size(SdlContext* sdl, UINT32* pMaxWidth, UINT32* pMaxH
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static UINT32 sdl_orientaion_to_rdp(SDL_DisplayOrientation orientation)
|
||||
{
|
||||
switch (orientation)
|
||||
{
|
||||
case SDL_ORIENTATION_LANDSCAPE:
|
||||
return ORIENTATION_LANDSCAPE;
|
||||
case SDL_ORIENTATION_LANDSCAPE_FLIPPED:
|
||||
return ORIENTATION_LANDSCAPE_FLIPPED;
|
||||
case SDL_ORIENTATION_PORTRAIT_FLIPPED:
|
||||
return ORIENTATION_PORTRAIT_FLIPPED;
|
||||
case SDL_ORIENTATION_PORTRAIT:
|
||||
default:
|
||||
return ORIENTATION_PORTRAIT;
|
||||
}
|
||||
}
|
||||
|
||||
static Uint32 scale(Uint32 val, float scale)
|
||||
{
|
||||
const auto dval = static_cast<float>(val);
|
||||
@@ -228,7 +212,7 @@ static BOOL sdl_apply_display_properties(SdlContext* sdl)
|
||||
}
|
||||
|
||||
const SDL_DisplayOrientation orientation = SDL_GetCurrentDisplayOrientation(id);
|
||||
const UINT32 rdp_orientation = sdl_orientaion_to_rdp(orientation);
|
||||
const UINT32 rdp_orientation = sdl::utils::orientaion_to_rdp(orientation);
|
||||
|
||||
rdpMonitor monitor = {};
|
||||
|
||||
|
||||
@@ -18,6 +18,9 @@
|
||||
*/
|
||||
|
||||
#include <cassert>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
#include "sdl_utils.hpp"
|
||||
|
||||
#include "sdl_freerdp.hpp"
|
||||
@@ -295,3 +298,58 @@ std::string sdl_window_event_str(Uint32 ev)
|
||||
|
||||
return "SDL_EVENT_WINDOW_UNKNOWN";
|
||||
}
|
||||
|
||||
UINT32 sdl::utils::orientaion_to_rdp(SDL_DisplayOrientation orientation)
|
||||
{
|
||||
switch (orientation)
|
||||
{
|
||||
case SDL_ORIENTATION_LANDSCAPE:
|
||||
return ORIENTATION_LANDSCAPE;
|
||||
case SDL_ORIENTATION_LANDSCAPE_FLIPPED:
|
||||
return ORIENTATION_LANDSCAPE_FLIPPED;
|
||||
case SDL_ORIENTATION_PORTRAIT_FLIPPED:
|
||||
return ORIENTATION_PORTRAIT_FLIPPED;
|
||||
case SDL_ORIENTATION_PORTRAIT:
|
||||
default:
|
||||
return ORIENTATION_PORTRAIT;
|
||||
}
|
||||
}
|
||||
|
||||
std::string sdl::utils::sdl_orientation_to_str(SDL_DisplayOrientation orientation)
|
||||
{
|
||||
switch (orientation)
|
||||
{
|
||||
case SDL_ORIENTATION_LANDSCAPE:
|
||||
return "SDL_ORIENTATION_LANDSCAPE";
|
||||
case SDL_ORIENTATION_LANDSCAPE_FLIPPED:
|
||||
return "SDL_ORIENTATION_LANDSCAPE_FLIPPED";
|
||||
case SDL_ORIENTATION_PORTRAIT_FLIPPED:
|
||||
return "SDL_ORIENTATION_PORTRAIT_FLIPPED";
|
||||
case SDL_ORIENTATION_PORTRAIT:
|
||||
return "SDL_ORIENTATION_PORTRAIT";
|
||||
default:
|
||||
return "SDL_ORIENTATION_UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
||||
std::string sdl::utils::rdp_orientation_to_str(uint32_t orientation)
|
||||
{
|
||||
switch (orientation)
|
||||
{
|
||||
case ORIENTATION_LANDSCAPE:
|
||||
return "ORIENTATION_LANDSCAPE";
|
||||
case ORIENTATION_LANDSCAPE_FLIPPED:
|
||||
return "ORIENTATION_LANDSCAPE_FLIPPED";
|
||||
case ORIENTATION_PORTRAIT_FLIPPED:
|
||||
return "ORIENTATION_PORTRAIT_FLIPPED";
|
||||
case ORIENTATION_PORTRAIT:
|
||||
return "ORIENTATION_PORTRAIT";
|
||||
default:
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "ORIENTATION_UNKNOWN_" << std::hex << std::setfill('0') << std::setw(8)
|
||||
<< orientation;
|
||||
return ss.str();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,3 +80,10 @@ const char* sdl_error_string(Sint32 res);
|
||||
#define sdl_log_error(res, log, what) sdl_log_error_ex(res, log, what, __FILE__, __LINE__, __func__)
|
||||
BOOL sdl_log_error_ex(Sint32 res, wLog* log, const char* what, const char* file, size_t line,
|
||||
const char* fkt);
|
||||
|
||||
namespace sdl::utils
|
||||
{
|
||||
std::string rdp_orientation_to_str(uint32_t orientation);
|
||||
std::string sdl_orientation_to_str(SDL_DisplayOrientation orientation);
|
||||
UINT32 orientaion_to_rdp(SDL_DisplayOrientation orientation);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ SdlWindow::SdlWindow(const std::string& title, Sint32 startupX, Sint32 startupY,
|
||||
SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_Y_NUMBER, startupY);
|
||||
SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_WIDTH_NUMBER, width);
|
||||
SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_HEIGHT_NUMBER, height);
|
||||
SDL_SetBooleanProperty(props, SDL_PROP_WINDOW_CREATE_HIGH_PIXEL_DENSITY_BOOLEAN, true);
|
||||
|
||||
if (flags & SDL_WINDOW_HIGH_PIXEL_DENSITY)
|
||||
SDL_SetBooleanProperty(props, SDL_PROP_WINDOW_CREATE_HIGH_PIXEL_DENSITY_BOOLEAN, true);
|
||||
@@ -47,7 +46,7 @@ SdlWindow::SdlWindow(const std::string& title, Sint32 startupX, Sint32 startupY,
|
||||
const int iscale = static_cast<int>(scale * 100.0f);
|
||||
auto w = 100 * width / iscale;
|
||||
auto h = 100 * height / iscale;
|
||||
SDL_SetWindowSize(_window, w, h);
|
||||
(void)SDL_SetWindowSize(_window, w, h);
|
||||
(void)SDL_SyncWindow(_window);
|
||||
}
|
||||
|
||||
@@ -144,10 +143,11 @@ rdpMonitor SdlWindow::monitor() const
|
||||
mon.y = rect.y;
|
||||
}
|
||||
|
||||
auto orientation = SDL_DisplayOrientation(did);
|
||||
mon.attributes.orientation = orientaion_to_rdp(orientation);
|
||||
auto orientation = SDL_GetCurrentDisplayOrientation(did);
|
||||
mon.attributes.orientation = sdl::utils::orientaion_to_rdp(orientation);
|
||||
|
||||
mon.is_primary = true;
|
||||
auto primary = SDL_GetPrimaryDisplay();
|
||||
mon.is_primary = SDL_GetWindowID(_window) == primary;
|
||||
mon.orig_screen = did;
|
||||
return mon;
|
||||
}
|
||||
@@ -232,19 +232,3 @@ void SdlWindow::updateSurface()
|
||||
{
|
||||
SDL_UpdateWindowSurface(_window);
|
||||
}
|
||||
|
||||
UINT32 SdlWindow::orientaion_to_rdp(SDL_DisplayOrientation orientation)
|
||||
{
|
||||
switch (orientation)
|
||||
{
|
||||
case SDL_ORIENTATION_LANDSCAPE:
|
||||
return ORIENTATION_LANDSCAPE;
|
||||
case SDL_ORIENTATION_LANDSCAPE_FLIPPED:
|
||||
return ORIENTATION_LANDSCAPE_FLIPPED;
|
||||
case SDL_ORIENTATION_PORTRAIT_FLIPPED:
|
||||
return ORIENTATION_PORTRAIT_FLIPPED;
|
||||
case SDL_ORIENTATION_PORTRAIT:
|
||||
default:
|
||||
return ORIENTATION_PORTRAIT;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user