Skip to content

Commit

Permalink
xxx: comment ifdefs back out, swap pos display, copy topleft
Browse files Browse the repository at this point in the history
Windows is being so inconsistent...
  • Loading branch information
toofar committed Dec 28, 2023
1 parent de7aa93 commit f8fbcb4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions src/tools/pin/pinwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,20 @@ 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);
debugText << QStringLiteral("orig geom: %1x%2+%3+%4")
.arg(geometry.x())
.arg(geometry.y())
.arg(geometry.width())
.arg(geometry.height())
.arg(geometry.x())
.arg(geometry.y())
;
debugText << QStringLiteral("pixel ratio: %1").arg(devicePixelRatio);
debugText << QStringLiteral("margin: %1")
Expand All @@ -83,7 +83,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 @@ -96,13 +96,13 @@ PinWidget::PinWidget(const QPixmap& pixmap,
resize(0, 0);
move(adjusted_pos.x(), adjusted_pos.y());
debugText << QStringLiteral("adjusted geom: %1x%2+%3+%4")
.arg(adjusted_pos.x())
.arg(adjusted_pos.y())
.arg(adjusted_pos.width())
.arg(adjusted_pos.height())
.arg(adjusted_pos.x())
.arg(adjusted_pos.y())
;
}
//#endif
#endif
grabGesture(Qt::PinchGesture);

this->setContextMenuPolicy(Qt::CustomContextMenu);
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/capture/capturewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ void CaptureWidget::initHelpMessage()
auto topLeft = req.initialCaptureScreen()->geometry().topLeft();
keyMap << QPair("Selected Screen Top Left", QStringLiteral("%1x%2").arg(topLeft.x()).arg(topLeft.y()));
for (QScreen* const screen : QGuiApplication::screens()) {
QPoint topLeftScreen = screen->geometry().topLeft();
QPoint topLeftScreen(screen->geometry().topLeft(), screen->geometry().size());
keyMap << QPair("Some Screen Top Left", QStringLiteral("%1x%2").arg(topLeftScreen.x()).arg(topLeftScreen.y()));

if (topLeftScreen.x() < topLeft.x()) {
Expand Down

0 comments on commit f8fbcb4

Please sign in to comment.