Skip to content

Commit

Permalink
wip: maybe fix windows initial wrong pin offset
Browse files Browse the repository at this point in the history
On windows when you have two monitors and they aren't lined up at the
top perfectly, then when you pin a selection the pin window ends up
jumping a little bit. Specifically it seems to be half of the screen's
y-offset from the global 0?

Will this fix it? Not sure.

It seems some global measurement needs to be mapped to local? Maybe?
  • Loading branch information
toofar committed Dec 28, 2023
1 parent fdfad50 commit 5b1b0d9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/tools/pin/pinwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ PinWidget::PinWidget(const QPixmap& pixmap,
new QShortcut(Qt::Key_Escape, this, SLOT(close()));

qreal devicePixelRatio = 1;
#if defined(Q_OS_MACOS) || defined(Q_OS_LINUX)
//#if defined(Q_OS_MACOS) || defined(Q_OS_LINUX)
QScreen* currentScreen = QGuiAppCurrentScreen().currentScreen();
if (currentScreen != nullptr) {
devicePixelRatio = currentScreen->devicePixelRatio();
}
#endif
//#endif
const int margin =
static_cast<int>(static_cast<double>(MARGIN) * devicePixelRatio);
QRect adjusted_pos = geometry + QMargins(margin, margin, margin, margin);
Expand All @@ -73,7 +73,7 @@ PinWidget::PinWidget(const QPixmap& pixmap,
setWindowFlags(Qt::X11BypassWindowManagerHint);
#endif

#if defined(Q_OS_MACOS) || defined(Q_OS_LINUX)
//#if defined(Q_OS_MACOS) || defined(Q_OS_LINUX)
if (currentScreen != nullptr) {
QPoint topLeft = currentScreen->geometry().topLeft();
adjusted_pos.setX((adjusted_pos.x() - topLeft.x()) / devicePixelRatio +
Expand All @@ -86,7 +86,7 @@ PinWidget::PinWidget(const QPixmap& pixmap,
resize(0, 0);
move(adjusted_pos.x(), adjusted_pos.y());
}
#endif
//#endif
grabGesture(Qt::PinchGesture);

this->setContextMenuPolicy(Qt::CustomContextMenu);
Expand Down

0 comments on commit 5b1b0d9

Please sign in to comment.