Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix touch dislocation #2893

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/platform/linux/kmsgrab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ namespace platf {
uint32_t offsets[4];
};

struct monitor_info_t {
int display_index;
unsigned int width;
unsigned int height;
};

using plane_res_t = util::safe_ptr<drmModePlaneRes, drmModeFreePlaneResources>;
using encoder_t = util::safe_ptr<drmModeEncoder, drmModeFreeEncoder>;
using res_t = util::safe_ptr<drmModeRes, drmModeFreeResources>;
Expand All @@ -115,6 +121,7 @@ namespace platf {

static int env_width;
static int env_height;
static std::vector<monitor_info_t> env_monitors;

std::string_view
plane_type(std::uint64_t val) {
Expand Down Expand Up @@ -701,8 +708,8 @@ namespace platf {
img_offset_x = crtc->x;
img_offset_y = crtc->y;

this->env_width = ::platf::kms::env_width;
this->env_height = ::platf::kms::env_height;
this->env_width = ::platf::kms::env_monitors[monitor].width;
this->env_height = ::platf::kms::env_monitors[monitor].height;
Comment on lines +711 to +712
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any risk with this breaking if we disconnect or add a monitor after sunshine was started? Can some id be used instead of index to improve safety?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functions that hanlle monitor change should take action to keep env_monitors updated, otherwise it might cause other issues.


auto monitor = pos->crtc_to_monitor.find(plane->crtc_id);
if (monitor != std::end(pos->crtc_to_monitor)) {
Expand Down Expand Up @@ -1712,6 +1719,10 @@ namespace platf {

kms::print(plane.get(), fb.get(), crtc.get());

kms::env_monitors.push_back(kms::monitor_info_t {
count,
crtc->width,
crtc->height });
display_names.emplace_back(std::to_string(count++));
}

Expand Down