Skip to content

Commit

Permalink
[remoting] Simplify DesktopResizerX11::CreateMode().
Browse files Browse the repository at this point in the history
The new mode ID is returned by the RANDR CreateMode() request, so
there is no need to refresh the resources and search for it.

Bug: 1326339
Change-Id: Ibb0bf991ccfa431c1ead900205d66529a7d08f61
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3839075
Auto-Submit: Lambros Lambrou <lambroslambrou@chromium.org>
Commit-Queue: Jamie Walch <jamiewalch@chromium.org>
Reviewed-by: Jamie Walch <jamiewalch@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1036826}
  • Loading branch information
Lambros Lambrou authored and Chromium LUCI CQ committed Aug 18, 2022
1 parent 96dec96 commit 4f7bea5
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions remoting/host/desktop_resizer_x11.cc
Original file line number Diff line number Diff line change
Expand Up @@ -336,20 +336,14 @@ x11::RandR::Mode DesktopResizerX11::CreateMode(x11::RandR::Output output,
mode.width = width;
mode.height = height;
mode.name_len = name.size();
randr_->CreateMode({root_, mode, name.c_str()});

if (!resources_.Refresh(randr_, root_))
return kInvalidMode;
x11::RandR::Mode mode_id = resources_.GetIdForMode(name);
if (mode_id == kInvalidMode) {
LOG(ERROR) << "No ID found for mode: " << name;
return kInvalidMode;
if (auto reply = randr_->CreateMode({root_, mode, name.c_str()}).Sync()) {
randr_->AddOutputMode({
output,
reply->mode,
});
return reply->mode;
}
randr_->AddOutputMode({
output,
mode_id,
});
return mode_id;
return kInvalidMode;
}

void DesktopResizerX11::DeleteMode(x11::RandR::Output output,
Expand Down

0 comments on commit 4f7bea5

Please sign in to comment.