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 a84f90e
Show file tree
Hide file tree
Showing 2 changed files with 12 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
5 changes: 4 additions & 1 deletion src/widgets/capture/capturewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,10 @@ void CaptureWidget::initHelpMessage()
QList<QPair<QString, QString>> keyMap;
auto req = m_context.request;
if (req.initialCaptureScreen() != nullptr) {
auto topLeft = req.initialCaptureScreen()->geometry().topLeft();
QPoint topLeft(
req.initialCaptureScreen()->geometry().topLeft().x(),
req.initialCaptureScreen()->geometry().topLeft().y()
);
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();
Expand Down

0 comments on commit a84f90e

Please sign in to comment.