Fix incorrect abs mouse coordinates on Linux when scaling to different aspect ratio
This commit is contained in:
@@ -147,7 +147,7 @@ struct x11_attr_t : public display_t {
|
||||
* Last X (NOT the streamed monitor!) size.
|
||||
* This way we can trigger reinitialization if the dimensions changed while streaming
|
||||
*/
|
||||
int lastWidth, lastHeight;
|
||||
// int env_width, env_height;
|
||||
|
||||
x11_attr_t(mem_type_e mem_type) : xdisplay { XOpenDisplay(nullptr) }, xwindow {}, xattr {}, mem_type { mem_type } {
|
||||
XInitThreads();
|
||||
@@ -204,8 +204,8 @@ struct x11_attr_t : public display_t {
|
||||
height = xattr.height;
|
||||
}
|
||||
|
||||
lastWidth = xattr.width;
|
||||
lastHeight = xattr.height;
|
||||
env_width = xattr.width;
|
||||
env_height = xattr.height;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -221,7 +221,7 @@ struct x11_attr_t : public display_t {
|
||||
refresh();
|
||||
|
||||
//The whole X server changed, so we gotta reinit everything
|
||||
if(xattr.width != lastWidth || xattr.height != lastHeight) {
|
||||
if(xattr.width != env_width || xattr.height != env_height) {
|
||||
BOOST_LOG(warning) << "X dimensions changed in non-SHM mode, request reinit"sv;
|
||||
return capture_e::reinit;
|
||||
}
|
||||
@@ -289,7 +289,7 @@ struct shm_attr_t : public x11_attr_t {
|
||||
|
||||
capture_e snapshot(img_t *img, std::chrono::milliseconds timeout, bool cursor) override {
|
||||
//The whole X server changed, so we gotta reinit everything
|
||||
if(xattr.width != lastWidth || xattr.height != lastHeight) {
|
||||
if(xattr.width != env_width || xattr.height != env_height) {
|
||||
BOOST_LOG(warning) << "X dimensions changed in SHM mode, request reinit"sv;
|
||||
return capture_e::reinit;
|
||||
}
|
||||
|
||||
@@ -145,8 +145,8 @@ public:
|
||||
void abs_mouse(input_t &input, const touch_port_t &touch_port, float x, float y) {
|
||||
auto touchscreen = ((input_raw_t *)input.get())->touch_input.get();
|
||||
|
||||
auto scaled_x = (int)std::lround((x + touch_port.offset_x) * ((float)target_touch_port.width / (float)touch_port.width));
|
||||
auto scaled_y = (int)std::lround((y + touch_port.offset_y) * ((float)target_touch_port.height / (float)touch_port.height));
|
||||
auto scaled_x = (int)std::lround((x + touch_port.offset_x) * ((float)target_touch_port.env_width / (float)touch_port.env_width));
|
||||
auto scaled_y = (int)std::lround((y + touch_port.offset_y) * ((float)target_touch_port.env_height / (float)touch_port.env_height));
|
||||
|
||||
libevdev_uinput_write_event(touchscreen, EV_ABS, ABS_X, scaled_x);
|
||||
libevdev_uinput_write_event(touchscreen, EV_ABS, ABS_Y, scaled_y);
|
||||
@@ -470,7 +470,7 @@ evdev_t touchscreen() {
|
||||
input_absinfo absx {
|
||||
0,
|
||||
0,
|
||||
target_touch_port.width,
|
||||
target_touch_port.env_width,
|
||||
1,
|
||||
0,
|
||||
28
|
||||
@@ -479,7 +479,7 @@ evdev_t touchscreen() {
|
||||
input_absinfo absy {
|
||||
0,
|
||||
0,
|
||||
target_touch_port.height,
|
||||
target_touch_port.env_height,
|
||||
1,
|
||||
0,
|
||||
28
|
||||
|
||||
Reference in New Issue
Block a user