Skip to content

Commit

Permalink
Fix help overlay positioning when drawing over a single screen
Browse files Browse the repository at this point in the history
The overlay positions itself at the center of the passed area relative to the
parent widget. "Current Screen" here is the screen the cursor is under at the
time the screenshot flow starts.

So that works fine when the window is covering the whole desktop because the
absolute screen offset matches the offset relative to the parent. But when the
GUI window is covering just one screen we don't want to pass it the absolute
position of the screen otherwise if the screen is anywhere but at the top
left that absolute offset will be applied relative to the parent widget and
the overlay will be way off the screen.
  • Loading branch information
toofar committed Dec 28, 2023
1 parent e7cfb97 commit 5756008
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/widgets/capture/capturewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,14 @@ CaptureWidget::CaptureWidget(const CaptureRequest& req,
OverlayMessage::instance()->update();
});

OverlayMessage::init(this,
QGuiAppCurrentScreen().currentScreen()->geometry());
if (req.initialCaptureScreen() != nullptr) {
// Child widget sizing is relative to the parent, so we just need to
// pass it our size with no offset.
OverlayMessage::init(this, QRect(QPoint(), size()));
} else {
OverlayMessage::init(this,
QGuiAppCurrentScreen().currentScreen()->geometry());
}

if (m_config.showHelp()) {
initHelpMessage();
Expand Down

0 comments on commit 5756008

Please sign in to comment.