fix: touch scaling bug and initialize display variables as 0 (#4758)
Co-authored-by: Chase Payne <27069224+nonary@users.noreply.github.com>
This commit is contained in:
@@ -485,10 +485,7 @@ namespace platf {
|
|||||||
*/
|
*/
|
||||||
using pull_free_image_cb_t = std::function<bool(std::shared_ptr<img_t> &img_out)>;
|
using pull_free_image_cb_t = std::function<bool(std::shared_ptr<img_t> &img_out)>;
|
||||||
|
|
||||||
display_t() noexcept:
|
display_t() noexcept = default;
|
||||||
offset_x {0},
|
|
||||||
offset_y {0} {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Capture a frame.
|
* @brief Capture a frame.
|
||||||
@@ -538,16 +535,16 @@ namespace platf {
|
|||||||
virtual ~display_t() = default;
|
virtual ~display_t() = default;
|
||||||
|
|
||||||
// Offsets for when streaming a specific monitor. By default, they are 0.
|
// Offsets for when streaming a specific monitor. By default, they are 0.
|
||||||
int offset_x;
|
int offset_x {0};
|
||||||
int offset_y;
|
int offset_y {0};
|
||||||
int env_width;
|
int env_width {0};
|
||||||
int env_height;
|
int env_height {0};
|
||||||
int env_logical_width;
|
int env_logical_width {0};
|
||||||
int env_logical_height;
|
int env_logical_height {0};
|
||||||
int width;
|
int width {0};
|
||||||
int height;
|
int height {0};
|
||||||
int logical_width;
|
int logical_width {0};
|
||||||
int logical_height;
|
int logical_height {0};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// collect capture timing data (at loglevel debug)
|
// collect capture timing data (at loglevel debug)
|
||||||
|
|||||||
@@ -513,8 +513,10 @@ namespace platf {
|
|||||||
// MOUSEEVENTF_VIRTUALDESK maps to the entirety of the desktop rather than the primary desktop
|
// MOUSEEVENTF_VIRTUALDESK maps to the entirety of the desktop rather than the primary desktop
|
||||||
MOUSEEVENTF_VIRTUALDESK;
|
MOUSEEVENTF_VIRTUALDESK;
|
||||||
|
|
||||||
auto scaled_x = std::lround((x + touch_port.offset_x) * ((float) target_touch_port.width / (float) touch_port.width));
|
// Note: x and y already include the display offset (offset_x/offset_y) from client_to_touchport(),
|
||||||
auto scaled_y = std::lround((y + touch_port.offset_y) * ((float) target_touch_port.height / (float) touch_port.height));
|
// so we must not add offset_x/offset_y again here to avoid double-offsetting on multi-monitor setups.
|
||||||
|
auto scaled_x = std::lround(x * ((float) target_touch_port.width / (float) touch_port.width));
|
||||||
|
auto scaled_y = std::lround(y * ((float) target_touch_port.height / (float) touch_port.height));
|
||||||
|
|
||||||
mi.dx = scaled_x;
|
mi.dx = scaled_x;
|
||||||
mi.dy = scaled_y;
|
mi.dy = scaled_y;
|
||||||
|
|||||||
@@ -2139,7 +2139,7 @@ namespace video {
|
|||||||
float scalar_tpcoords = 1.0f;
|
float scalar_tpcoords = 1.0f;
|
||||||
int display_env_logical_width = 0;
|
int display_env_logical_width = 0;
|
||||||
int display_env_logical_height = 0;
|
int display_env_logical_height = 0;
|
||||||
if (display->logical_width && display->logical_height && display->env_logical_width && display->env_logical_height) {
|
if (display->logical_width > 0 && display->logical_height > 0 && display->env_logical_width > 0 && display->env_logical_height > 0) {
|
||||||
float lwd = display->logical_width;
|
float lwd = display->logical_width;
|
||||||
float lhd = display->logical_height;
|
float lhd = display->logical_height;
|
||||||
scalar_tpcoords = std::fminf(wd / lwd, hd / lhd);
|
scalar_tpcoords = std::fminf(wd / lwd, hd / lhd);
|
||||||
|
|||||||
Reference in New Issue
Block a user