Revert "Add devicePixelRatio support to the Windows QPA plugin."
This change reverts c47b04696a .
Task-number: QTBUG-38993
Task-number: QTBUG-46615
Change-Id: I180dcac3a65a33498b90a71bbcad5e45a12af77c
Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
bb10
parent
318f62748b
commit
71545f8df8
|
|
@ -35,7 +35,6 @@
|
|||
#include "qwindowswindow.h"
|
||||
#include "qwindowsnativeimage.h"
|
||||
#include "qwindowscontext.h"
|
||||
#include "qwindowsscaling.h"
|
||||
|
||||
#include <QtGui/QWindow>
|
||||
#include <QtGui/QPainter>
|
||||
|
|
@ -68,10 +67,12 @@ QPaintDevice *QWindowsBackingStore::paintDevice()
|
|||
return &m_image->image();
|
||||
}
|
||||
|
||||
void QWindowsBackingStore::flushDp(QWindow *window, const QRect &br, const QPoint &offset)
|
||||
void QWindowsBackingStore::flush(QWindow *window, const QRegion ®ion,
|
||||
const QPoint &offset)
|
||||
{
|
||||
Q_ASSERT(window);
|
||||
|
||||
const QRect br = region.boundingRect();
|
||||
if (QWindowsContext::verbose > 1)
|
||||
qCDebug(lcQpaBackingStore) << __FUNCTION__ << this << window << offset << br;
|
||||
QWindowsWindow *rw = QWindowsWindow::baseWindowOf(window);
|
||||
|
|
@ -81,9 +82,8 @@ void QWindowsBackingStore::flushDp(QWindow *window, const QRect &br, const QPoin
|
|||
const Qt::WindowFlags flags = window->flags();
|
||||
if ((flags & Qt::FramelessWindowHint) && QWindowsWindow::setWindowLayered(rw->handle(), flags, hasAlpha, rw->opacity()) && hasAlpha) {
|
||||
// Windows with alpha: Use blend function to update.
|
||||
const QMargins marginsDP = rw->frameMarginsDp();
|
||||
const QRect r = rw->geometryDp() + marginsDP;
|
||||
const QPoint frameOffset(marginsDP.left(), marginsDP.top());
|
||||
QRect r = window->frameGeometry();
|
||||
QPoint frameOffset(window->frameMargins().left(), window->frameMargins().top());
|
||||
QRect dirtyRect = br.translated(offset + frameOffset);
|
||||
|
||||
SIZE size = {r.width(), r.height()};
|
||||
|
|
@ -127,15 +127,14 @@ void QWindowsBackingStore::flushDp(QWindow *window, const QRect &br, const QPoin
|
|||
}
|
||||
}
|
||||
|
||||
void QWindowsBackingStore::resize(const QSize &sizeDip, const QRegion ®ionDip)
|
||||
void QWindowsBackingStore::resize(const QSize &size, const QRegion ®ion)
|
||||
{
|
||||
const QSize size = sizeDip * QWindowsScaling::factor();
|
||||
if (m_image.isNull() || m_image->image().size() != size) {
|
||||
#ifndef QT_NO_DEBUG_OUTPUT
|
||||
if (QWindowsContext::verbose && lcQpaBackingStore().isDebugEnabled()) {
|
||||
qCDebug(lcQpaBackingStore)
|
||||
<< __FUNCTION__ << ' ' << window() << ' ' << size << ' ' << sizeDip << ' '
|
||||
<< regionDip << " from: " << (m_image.isNull() ? QSize() : m_image->image().size());
|
||||
<< __FUNCTION__ << ' ' << window() << ' ' << size << ' ' << region
|
||||
<< " from: " << (m_image.isNull() ? QSize() : m_image->image().size());
|
||||
}
|
||||
#endif
|
||||
const QImage::Format format = window()->format().hasAlpha() ?
|
||||
|
|
@ -144,10 +143,10 @@ void QWindowsBackingStore::resize(const QSize &sizeDip, const QRegion ®ionDip
|
|||
QWindowsNativeImage *oldwni = m_image.data();
|
||||
QWindowsNativeImage *newwni = new QWindowsNativeImage(size.width(), size.height(), format);
|
||||
|
||||
if (oldwni && !regionDip.isEmpty()) {
|
||||
if (oldwni && !region.isEmpty()) {
|
||||
const QImage &oldimg(oldwni->image());
|
||||
QImage &newimg(newwni->image());
|
||||
QRegion staticRegion = QWindowsScaling::mapToNative(regionDip);
|
||||
QRegion staticRegion(region);
|
||||
staticRegion &= QRect(0, 0, oldimg.width(), oldimg.height());
|
||||
staticRegion &= QRect(0, 0, newimg.width(), newimg.height());
|
||||
QPainter painter(&newimg);
|
||||
|
|
@ -156,38 +155,36 @@ void QWindowsBackingStore::resize(const QSize &sizeDip, const QRegion ®ionDip
|
|||
painter.drawImage(rect, oldimg, rect);
|
||||
}
|
||||
|
||||
if (QWindowsScaling::isActive())
|
||||
newwni->setDevicePixelRatio(QWindowsScaling::factor());
|
||||
m_image.reset(newwni);
|
||||
}
|
||||
}
|
||||
|
||||
Q_GUI_EXPORT void qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset);
|
||||
|
||||
bool QWindowsBackingStore::scroll(const QRegion &areaDip, int dxDip, int dyDip)
|
||||
bool QWindowsBackingStore::scroll(const QRegion &area, int dx, int dy)
|
||||
{
|
||||
if (m_image.isNull() || m_image->image().isNull())
|
||||
return false;
|
||||
|
||||
const QPoint dp = QPoint(dxDip, dyDip) * QWindowsScaling::factor();
|
||||
const QVector<QRect> rects = areaDip.rects();
|
||||
const QVector<QRect> rects = area.rects();
|
||||
const QPoint offset(dx, dy);
|
||||
for (int i = 0; i < rects.size(); ++i)
|
||||
qt_scrollRectInImage(m_image->image(), QWindowsScaling::mapToNative(rects.at(i)), dp);
|
||||
qt_scrollRectInImage(m_image->image(), rects.at(i), offset);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void QWindowsBackingStore::beginPaint(const QRegion ®ionDip)
|
||||
void QWindowsBackingStore::beginPaint(const QRegion ®ion)
|
||||
{
|
||||
if (QWindowsContext::verbose > 1)
|
||||
qCDebug(lcQpaBackingStore) <<__FUNCTION__ << regionDip;
|
||||
qCDebug(lcQpaBackingStore) <<__FUNCTION__ << region;
|
||||
|
||||
if (m_image->image().hasAlphaChannel()) {
|
||||
QPainter p(&m_image->image());
|
||||
p.setCompositionMode(QPainter::CompositionMode_Source);
|
||||
const QColor blank = Qt::transparent;
|
||||
foreach (const QRect &r, regionDip.rects())
|
||||
p.fillRect(QWindowsScaling::mapToNative(r), blank);
|
||||
foreach (const QRect &r, region.rects())
|
||||
p.fillRect(r, blank);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@
|
|||
#define QWINDOWSBACKINGSTORE_H
|
||||
|
||||
#include "qtwindows_additional.h"
|
||||
#include "qwindowsscaling.h"
|
||||
|
||||
#include <qpa/qplatformbackingstore.h>
|
||||
#include <QtCore/QScopedPointer>
|
||||
|
|
@ -53,12 +52,7 @@ public:
|
|||
~QWindowsBackingStore();
|
||||
|
||||
QPaintDevice *paintDevice() Q_DECL_OVERRIDE;
|
||||
void flush(QWindow *window, const QRegion ®ion, const QPoint &offset) Q_DECL_OVERRIDE
|
||||
{
|
||||
flushDp(window, QWindowsScaling::mapToNative(region.boundingRect()),
|
||||
offset * QWindowsScaling::factor());
|
||||
}
|
||||
void flushDp(QWindow *window, const QRect &boundingRect, const QPoint &offset);
|
||||
void flush(QWindow *window, const QRegion ®ion, const QPoint &offset) Q_DECL_OVERRIDE;
|
||||
void resize(const QSize &size, const QRegion &r) Q_DECL_OVERRIDE;
|
||||
bool scroll(const QRegion &area, int dx, int dy) Q_DECL_OVERRIDE;
|
||||
void beginPaint(const QRegion &) Q_DECL_OVERRIDE;
|
||||
|
|
|
|||
|
|
@ -51,7 +51,6 @@
|
|||
#endif
|
||||
#include "qwindowsscreen.h"
|
||||
#include "qwindowstheme.h"
|
||||
#include "qwindowsscaling.h"
|
||||
|
||||
#include <QtGui/QWindow>
|
||||
#include <qpa/qwindowsysteminterface.h>
|
||||
|
|
@ -1228,9 +1227,7 @@ bool QWindowsContext::handleContextMenuEvent(QWindow *window, const MSG &msg)
|
|||
}
|
||||
}
|
||||
|
||||
QWindowSystemInterface::handleContextMenuEvent(window, mouseTriggered,
|
||||
pos / QWindowsScaling::factor(),
|
||||
globalPos / QWindowsScaling::factor(),
|
||||
QWindowSystemInterface::handleContextMenuEvent(window, mouseTriggered, pos, globalPos,
|
||||
QWindowsKeyMapper::queryKeyboardModifiers());
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@
|
|||
#include "qwindowscontext.h"
|
||||
#include "qwindowswindow.h"
|
||||
#include "qwindowsscreen.h"
|
||||
#include "qwindowsscaling.h"
|
||||
|
||||
#include <QtGui/QBitmap>
|
||||
#include <QtGui/QImage>
|
||||
|
|
@ -646,13 +645,12 @@ QWindowsCursor::CursorState QWindowsCursor::cursorState()
|
|||
|
||||
QPoint QWindowsCursor::pos() const
|
||||
{
|
||||
return mousePosition() / QWindowsScaling::factor();
|
||||
return mousePosition();
|
||||
}
|
||||
|
||||
void QWindowsCursor::setPos(const QPoint &pos)
|
||||
{
|
||||
const QPoint posDp = pos * QWindowsScaling::factor();
|
||||
SetCursorPos(posDp.x() , posDp.y());
|
||||
SetCursorPos(pos.x() , pos.y());
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@
|
|||
|
||||
#include "qwindowsdrag.h"
|
||||
#include "qwindowscontext.h"
|
||||
#include "qwindowsscaling.h"
|
||||
#ifndef QT_NO_CLIPBOARD
|
||||
# include "qwindowsclipboard.h"
|
||||
#endif
|
||||
|
|
@ -43,7 +42,6 @@
|
|||
#include "qwindowswindow.h"
|
||||
#include "qwindowsmousehandler.h"
|
||||
#include "qwindowscursor.h"
|
||||
#include "qwindowsscaling.h"
|
||||
|
||||
#include <QtGui/QMouseEvent>
|
||||
#include <QtGui/QPixmap>
|
||||
|
|
@ -289,19 +287,12 @@ void QWindowsOleDropSource::createCursors()
|
|||
const QDrag *drag = m_drag->currentDrag();
|
||||
const QPixmap pixmap = drag->pixmap();
|
||||
const bool hasPixmap = !pixmap.isNull();
|
||||
const int scaleFactor = QWindowsScaling::factor();
|
||||
const QSize pixmapSizeDp = pixmap.size() * scaleFactor;
|
||||
const bool scalePixmap = hasPixmap
|
||||
&& m_mode != TouchDrag // Touch drag: pixmap is shown in a separate QWindow, which will be scaled.
|
||||
&& (scaleFactor != 1 && scaleFactor != qRound(pixmap.devicePixelRatio()));
|
||||
const QPixmap drawPixmap = scalePixmap
|
||||
? pixmap.scaled(pixmapSizeDp, Qt::KeepAspectRatio, Qt::SmoothTransformation) : pixmap;
|
||||
|
||||
Qt::DropAction actions[] = { Qt::MoveAction, Qt::CopyAction, Qt::LinkAction, Qt::IgnoreAction };
|
||||
int actionCount = int(sizeof(actions) / sizeof(actions[0]));
|
||||
if (!hasPixmap)
|
||||
--actionCount; // No Qt::IgnoreAction unless pixmap
|
||||
const QPoint hotSpot = drag->hotSpot() * scaleFactor;
|
||||
const QPoint hotSpot = drag->hotSpot();
|
||||
for (int cnum = 0; cnum < actionCount; ++cnum) {
|
||||
const Qt::DropAction action = actions[cnum];
|
||||
QPixmap cursorPixmap = drag->dragCursor(action);
|
||||
|
|
@ -321,14 +312,15 @@ void QWindowsOleDropSource::createCursors()
|
|||
|
||||
if (hasPixmap) {
|
||||
const int x1 = qMin(-hotSpot.x(), 0);
|
||||
const int x2 = qMax(pixmapSizeDp.width() - hotSpot.x(), cursorPixmap.width());
|
||||
const int x2 = qMax(pixmap.width() - hotSpot.x(), cursorPixmap.width());
|
||||
const int y1 = qMin(-hotSpot.y(), 0);
|
||||
const int y2 = qMax(pixmapSizeDp.height() - hotSpot.y(), cursorPixmap.height());
|
||||
const int y2 = qMax(pixmap.height() - hotSpot.y(), cursorPixmap.height());
|
||||
QPixmap newCursor(x2 - x1 + 1, y2 - y1 + 1);
|
||||
newCursor.fill(Qt::transparent);
|
||||
QPainter p(&newCursor);
|
||||
const QRect srcRect = pixmap.rect();
|
||||
const QPoint pmDest = QPoint(qMax(0, -hotSpot.x()), qMax(0, -hotSpot.y()));
|
||||
p.drawPixmap(pmDest, drawPixmap);
|
||||
p.drawPixmap(pmDest, pixmap, srcRect);
|
||||
p.drawPixmap(qMax(0, hotSpot.x()),qMax(0, hotSpot.y()), cursorPixmap);
|
||||
newPixmap = newCursor;
|
||||
newHotSpot = QPoint(qMax(0, hotSpot.x()), qMax(0, hotSpot.y()));
|
||||
|
|
@ -454,7 +446,7 @@ QWindowsOleDropSource::GiveFeedback(DWORD dwEffect)
|
|||
if (!m_touchDragWindow)
|
||||
m_touchDragWindow = new QWindowsDragCursorWindow;
|
||||
m_touchDragWindow->setPixmap(e.pixmap);
|
||||
m_touchDragWindow->setFramePosition((QWindowsCursor::mousePosition() - e.hotSpot) / QWindowsScaling::factor());
|
||||
m_touchDragWindow->setFramePosition(QWindowsCursor::mousePosition() - e.hotSpot);
|
||||
if (!m_touchDragWindow->isVisible())
|
||||
m_touchDragWindow->show();
|
||||
break;
|
||||
|
|
@ -530,9 +522,7 @@ void QWindowsOleDropTarget::handleDrag(QWindow *window, DWORD grfKeyState,
|
|||
QGuiApplicationPrivate::mouse_buttons = QWindowsMouseHandler::keyStateToMouseButtons(grfKeyState);
|
||||
|
||||
const QPlatformDragQtResponse response =
|
||||
QWindowSystemInterface::handleDrag(window, windowsDrag->dropData(),
|
||||
m_lastPoint / QWindowsScaling::factor(),
|
||||
actions);
|
||||
QWindowSystemInterface::handleDrag(window, windowsDrag->dropData(), m_lastPoint, actions);
|
||||
|
||||
m_answerRect = response.answerRect();
|
||||
const Qt::DropAction action = response.acceptedAction();
|
||||
|
|
@ -625,9 +615,8 @@ QWindowsOleDropTarget::Drop(LPDATAOBJECT pDataObj, DWORD grfKeyState,
|
|||
|
||||
const QPlatformDropQtResponse response =
|
||||
QWindowSystemInterface::handleDrop(m_window, windowsDrag->dropData(),
|
||||
m_lastPoint / QWindowsScaling::factor(),
|
||||
m_lastPoint,
|
||||
translateToQDragDropActions(*pdwEffect));
|
||||
|
||||
if (response.isAccepted()) {
|
||||
const Qt::DropAction action = response.acceptedAction();
|
||||
if (action == Qt::MoveAction || action == Qt::TargetMoveAction) {
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@
|
|||
#include "qwindowswindow.h"
|
||||
#include "qwindowsintegration.h"
|
||||
#include "qwindowsmousehandler.h"
|
||||
#include "qwindowsscaling.h"
|
||||
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtCore/QObject>
|
||||
|
|
@ -243,10 +242,9 @@ void QWindowsInputContext::cursorRectChanged()
|
|||
if (!m_compositionContext.hwnd)
|
||||
return;
|
||||
const QInputMethod *inputMethod = QGuiApplication::inputMethod();
|
||||
const QRect cursorRectangleDip = inputMethod->cursorRectangle().toRect();
|
||||
if (!cursorRectangleDip.isValid())
|
||||
const QRect cursorRectangle = inputMethod->cursorRectangle().toRect();
|
||||
if (!cursorRectangle.isValid())
|
||||
return;
|
||||
const QRect cursorRectangle = QWindowsScaling::mapToNative(cursorRectangleDip);
|
||||
|
||||
qCDebug(lcQpaInputMethods) << __FUNCTION__<< cursorRectangle;
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include "qwindowsintegration.h"
|
||||
#include "qwindowsscaling.h"
|
||||
#include "qwindowswindow.h"
|
||||
#include "qwindowscontext.h"
|
||||
#include "qwindowsopenglcontext.h"
|
||||
|
|
@ -223,12 +222,8 @@ QWindowsIntegrationPrivate::QWindowsIntegrationPrivate(const QStringList ¶mL
|
|||
m_context.setProcessDpiAwareness(dpiAwareness);
|
||||
dpiAwarenessSet = true;
|
||||
}
|
||||
// Determine suitable scale factor, don't mix Windows and Qt scaling
|
||||
if (dpiAwareness != QtWindows::ProcessDpiUnaware)
|
||||
QWindowsScaling::setFactor(QWindowsScaling::determineUiScaleFactor());
|
||||
qCDebug(lcQpaWindows)
|
||||
<< __FUNCTION__ << "DpiAwareness=" << dpiAwareness <<",Scaling="
|
||||
<< QWindowsScaling::factor();
|
||||
<< __FUNCTION__ << "DpiAwareness=" << dpiAwareness;
|
||||
|
||||
QTouchDevice *touchDevice = m_context.touchDevice();
|
||||
if (touchDevice) {
|
||||
|
|
@ -307,7 +302,7 @@ QWindowsWindowData QWindowsIntegration::createWindowData(QWindow *window) const
|
|||
{
|
||||
QWindowsWindowData requested;
|
||||
requested.flags = window->flags();
|
||||
requested.geometry = QWindowsScaling::mapToNative(window->geometry());
|
||||
requested.geometry = window->geometry();
|
||||
// Apply custom margins (see QWindowsWindow::setCustomMargins())).
|
||||
const QVariant customMarginsV = window->property("_q_windowsCustomMargins");
|
||||
if (customMarginsV.isValid())
|
||||
|
|
@ -327,7 +322,7 @@ QWindowsWindowData QWindowsIntegration::createWindowData(QWindow *window) const
|
|||
window->setFlags(obtained.flags);
|
||||
// Trigger geometry change signals of QWindow.
|
||||
if ((obtained.flags & Qt::Desktop) != Qt::Desktop && requested.geometry != obtained.geometry)
|
||||
QWindowSystemInterface::handleGeometryChange(window, QWindowsScaling::mapFromNative(obtained.geometry));
|
||||
QWindowSystemInterface::handleGeometryChange(window, obtained.geometry);
|
||||
}
|
||||
|
||||
return obtained;
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@
|
|||
#include "qwindowscontext.h"
|
||||
#include "qwindowswindow.h"
|
||||
#include "qwindowsguieventdispatcher.h"
|
||||
#include "qwindowsscaling.h"
|
||||
#include "qwindowsinputcontext.h"
|
||||
|
||||
#include <QtGui/QWindow>
|
||||
|
|
@ -792,10 +791,11 @@ static void showSystemMenu(QWindow* w)
|
|||
#undef enabled
|
||||
#undef disabled
|
||||
#endif // !Q_OS_WINCE
|
||||
const QPoint topLeft = topLevel->geometry().topLeft() * QWindowsScaling::factor();
|
||||
const int ret = TrackPopupMenuEx(menu,
|
||||
TPM_LEFTALIGN | TPM_TOPALIGN | TPM_NONOTIFY | TPM_RETURNCMD,
|
||||
topLeft.x(), topLeft.y(), topLevelHwnd, 0);
|
||||
topLevel->geometry().x(), topLevel->geometry().y(),
|
||||
topLevelHwnd,
|
||||
0);
|
||||
if (ret)
|
||||
qWindowsWndProc(topLevelHwnd, WM_SYSCOMMAND, ret, 0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -211,10 +211,8 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd,
|
|||
const QPoint globalPosition = winEventPosition;
|
||||
const QPoint clientPosition = QWindowsGeometryHint::mapFromGlobal(hwnd, globalPosition);
|
||||
const Qt::MouseButtons buttons = QWindowsMouseHandler::queryMouseButtons();
|
||||
QWindowSystemInterface::handleFrameStrutMouseEvent(window,
|
||||
clientPosition / QWindowsScaling::factor(),
|
||||
globalPosition / QWindowsScaling::factor(),
|
||||
buttons,
|
||||
QWindowSystemInterface::handleFrameStrutMouseEvent(window, clientPosition,
|
||||
globalPosition, buttons,
|
||||
QWindowsKeyMapper::queryKeyboardModifiers(),
|
||||
source);
|
||||
return false; // Allow further event processing (dragging of windows).
|
||||
|
|
@ -279,7 +277,7 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd,
|
|||
// ChildWindowFromPointEx() may not find the Qt window (failing with ERROR_ACCESS_DENIED)
|
||||
if (!currentWindowUnderMouse) {
|
||||
const QRect clientRect(QPoint(0, 0), window->size());
|
||||
if (clientRect.contains(winEventPosition / QWindowsScaling::factor()))
|
||||
if (clientRect.contains(winEventPosition))
|
||||
currentWindowUnderMouse = window;
|
||||
}
|
||||
|
||||
|
|
@ -366,10 +364,7 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd,
|
|||
m_windowUnderMouse = currentWindowUnderMouse;
|
||||
}
|
||||
|
||||
QWindowSystemInterface::handleMouseEvent(window,
|
||||
winEventPosition / QWindowsScaling::factor(),
|
||||
globalPosition / QWindowsScaling::factor(),
|
||||
buttons,
|
||||
QWindowSystemInterface::handleMouseEvent(window, winEventPosition, globalPosition, buttons,
|
||||
QWindowsKeyMapper::queryKeyboardModifiers(),
|
||||
source);
|
||||
m_previousCaptureWindow = hasCapture ? window : 0;
|
||||
|
|
@ -404,11 +399,9 @@ static void redirectWheelEvent(QWindow *window, const QPoint &globalPos, int del
|
|||
}
|
||||
|
||||
if (handleEvent) {
|
||||
const QPoint posDip = QWindowsGeometryHint::mapFromGlobal(receiver, globalPos) / QWindowsScaling::factor();
|
||||
QWindowSystemInterface::handleWheelEvent(receiver,
|
||||
posDip, globalPos / QWindowsScaling::factor(),
|
||||
delta / QWindowsScaling::factor(),
|
||||
orientation, mods);
|
||||
QWindowsGeometryHint::mapFromGlobal(receiver, globalPos),
|
||||
globalPos, delta, orientation, mods);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -495,7 +488,6 @@ bool QWindowsMouseHandler::translateTouchEvent(QWindow *window, HWND hwnd,
|
|||
Q_ASSERT(QWindowsContext::user32dll.getTouchInputInfo);
|
||||
|
||||
QWindowsContext::user32dll.getTouchInputInfo((HANDLE) msg.lParam, msg.wParam, winTouchInputs.data(), sizeof(TOUCHINPUT));
|
||||
const qreal screenPosFactor = 0.01 / qreal(QWindowsScaling::factor());
|
||||
for (int i = 0; i < winTouchPointCount; ++i) {
|
||||
const TOUCHINPUT &winTouchInput = winTouchInputs[i];
|
||||
int id = m_touchInputIDToTouchPointID.value(winTouchInput.dwID, -1);
|
||||
|
|
@ -509,9 +501,9 @@ bool QWindowsMouseHandler::translateTouchEvent(QWindow *window, HWND hwnd,
|
|||
if (m_lastTouchPositions.contains(id))
|
||||
touchPoint.normalPosition = m_lastTouchPositions.value(id);
|
||||
|
||||
const QPointF screenPos = QPointF(winTouchInput.x, winTouchInput.y) * screenPosFactor;
|
||||
const QPointF screenPos = QPointF(winTouchInput.x, winTouchInput.y) / qreal(100.);
|
||||
if (winTouchInput.dwMask & TOUCHINPUTMASKF_CONTACTAREA)
|
||||
touchPoint.area.setSize(QSizeF(winTouchInput.cxContact, winTouchInput.cyContact) * screenPosFactor);
|
||||
touchPoint.area.setSize(QSizeF(winTouchInput.cxContact, winTouchInput.cyContact) / qreal(100.));
|
||||
touchPoint.area.moveCenter(screenPos);
|
||||
QPointF normalPosition = QPointF(screenPos.x() / screenGeometry.width(),
|
||||
screenPos.y() / screenGeometry.height());
|
||||
|
|
|
|||
|
|
@ -57,8 +57,6 @@ public:
|
|||
|
||||
HDC hdc() const { return m_hdc; }
|
||||
|
||||
void setDevicePixelRatio(qreal scaleFactor) { m_image.setDevicePixelRatio(scaleFactor); }
|
||||
|
||||
static QImage::Format systemFormat();
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -1,71 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the plugins of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL21$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** As a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qwindowsscaling.h"
|
||||
#include "qwindowsscreen.h"
|
||||
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtCore/QCoreApplication>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class QWindowsScaling
|
||||
\brief Windows scaling utilities
|
||||
|
||||
\internal
|
||||
\ingroup qt-lighthouse-win
|
||||
*/
|
||||
|
||||
int QWindowsScaling::m_factor = 1;
|
||||
|
||||
static const char devicePixelRatioEnvVar[] = "QT_DEVICE_PIXEL_RATIO";
|
||||
|
||||
// Suggest a scale factor by checking monitor sizes.
|
||||
int QWindowsScaling::determineUiScaleFactor()
|
||||
{
|
||||
if (!qEnvironmentVariableIsSet(devicePixelRatioEnvVar))
|
||||
return 1;
|
||||
const QByteArray envDevicePixelRatioEnv = qgetenv(devicePixelRatioEnvVar);
|
||||
// Auto: Suggest a scale factor by checking monitor resolution.
|
||||
if (envDevicePixelRatioEnv == "auto") {
|
||||
const int maxResolution = QWindowsScreen::maxMonitorHorizResolution();
|
||||
return maxResolution > 180 ? maxResolution / 96 : 1;
|
||||
}
|
||||
// Get factor from environment
|
||||
bool ok = false;
|
||||
const int envFactor = envDevicePixelRatioEnv.toInt(&ok);
|
||||
return ok && envFactor > 0 ? envFactor : 1;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
@ -1,106 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the plugins of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL21$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** As a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QWINDOWSSCALING_H
|
||||
#define QWINDOWSSCALING_H
|
||||
|
||||
#include <QtGui/QRegion>
|
||||
#include <QtCore/QVector>
|
||||
#include <QtCore/QRect>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
enum
|
||||
#if defined(Q_COMPILER_CLASS_ENUM) || defined(Q_CC_MSVC)
|
||||
: int
|
||||
#endif
|
||||
{ QWINDOWSIZE_MAX = 16777215 };
|
||||
|
||||
class QWindowsScaling {
|
||||
public:
|
||||
static bool isActive() { return m_factor > 1; }
|
||||
static int factor() { return m_factor; }
|
||||
static void setFactor(int factor) { m_factor = factor; }
|
||||
static int determineUiScaleFactor();
|
||||
|
||||
// Scaling helpers for size constraints.
|
||||
static int mapToNativeConstrained(int qt)
|
||||
{ return m_factor != 1 && qt > 0 && qt < QWINDOWSIZE_MAX ? qt * m_factor : qt; }
|
||||
|
||||
static int mapFromNativeConstrained(int dp)
|
||||
{ return m_factor != 1 && dp > 0 && dp < QWINDOWSIZE_MAX ? dp / m_factor : dp; }
|
||||
|
||||
static QSize mapToNativeConstrained(const QSize &qt)
|
||||
{ return QSize(mapToNativeConstrained(qt.width()), mapToNativeConstrained(qt.height())); }
|
||||
|
||||
static QRect mapToNative(const QRect &qRect)
|
||||
{
|
||||
return QRect(qRect.x() * m_factor, qRect.y() * m_factor, qRect.width() * m_factor, qRect.height() * m_factor);
|
||||
}
|
||||
|
||||
static QRect mapFromNative(const QRect &dp)
|
||||
{
|
||||
return isActive() ?
|
||||
QRect(dp.x() / m_factor, dp.y() / m_factor, (dp.width() + 1) / m_factor, (dp.height() + 1) / m_factor) :
|
||||
dp;
|
||||
}
|
||||
|
||||
static QRegion mapToNative(const QRegion ®ionQt)
|
||||
{
|
||||
if (!QWindowsScaling::isActive() || regionQt.isEmpty())
|
||||
return regionQt;
|
||||
|
||||
QRegion result;
|
||||
foreach (const QRect &rectQt, regionQt.rects())
|
||||
result += QWindowsScaling::mapToNative(rectQt);
|
||||
return result;
|
||||
}
|
||||
|
||||
static QRegion mapFromNative(const QRegion ®ionDp)
|
||||
{
|
||||
if (!QWindowsScaling::isActive() || regionDp.isEmpty())
|
||||
return regionDp;
|
||||
|
||||
QRegion result;
|
||||
foreach (const QRect &rectDp, regionDp.rects())
|
||||
result += QWindowsScaling::mapFromNative(rectDp);
|
||||
return result;
|
||||
}
|
||||
|
||||
private:
|
||||
static int m_factor;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QWINDOWSSCALING_H
|
||||
|
|
@ -218,36 +218,14 @@ QWindowsScreen::QWindowsScreen(const QWindowsScreenData &data) :
|
|||
{
|
||||
}
|
||||
|
||||
BOOL QT_WIN_CALLBACK monitorResolutionEnumCallback(HMONITOR hMonitor, HDC, LPRECT, LPARAM p)
|
||||
{
|
||||
QWindowsScreenData data;
|
||||
if (monitorData(hMonitor, &data)) {
|
||||
int *maxHorizResolution = reinterpret_cast<int *>(p);
|
||||
const int horizResolution = qRound(data.dpi.first);
|
||||
if (horizResolution > *maxHorizResolution)
|
||||
*maxHorizResolution = horizResolution;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int QWindowsScreen::maxMonitorHorizResolution()
|
||||
{
|
||||
int result = 0;
|
||||
EnumDisplayMonitors(0, 0, monitorResolutionEnumCallback, (LPARAM)&result);
|
||||
return result;
|
||||
}
|
||||
|
||||
Q_GUI_EXPORT QPixmap qt_pixmapFromWinHBITMAP(HBITMAP bitmap, int hbitmapFormat = 0);
|
||||
|
||||
QPixmap QWindowsScreen::grabWindow(WId window, int qX, int qY, int qWidth, int qHeight) const
|
||||
QPixmap QWindowsScreen::grabWindow(WId window, int x, int y, int width, int height) const
|
||||
{
|
||||
RECT r;
|
||||
HWND hwnd = window ? (HWND)window : GetDesktopWindow();
|
||||
GetClientRect(hwnd, &r);
|
||||
const int x = qX * QWindowsScaling::factor();
|
||||
const int y = qY * QWindowsScaling::factor();
|
||||
int width = qWidth * QWindowsScaling::factor();
|
||||
int height = qHeight * QWindowsScaling::factor();
|
||||
|
||||
if (width < 0) width = r.right - r.left;
|
||||
if (height < 0) height = r.bottom - r.top;
|
||||
|
||||
|
|
@ -271,10 +249,6 @@ QPixmap QWindowsScreen::grabWindow(WId window, int qX, int qY, int qWidth, int q
|
|||
DeleteObject(bitmap);
|
||||
ReleaseDC(0, display_dc);
|
||||
|
||||
if (QWindowsScaling::isActive()) {
|
||||
const qreal factor = 1.0 / qreal(QWindowsScaling::factor());
|
||||
return pixmap.transformed(QTransform::fromScale(factor, factor));
|
||||
}
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
|
|
@ -285,7 +259,7 @@ QPixmap QWindowsScreen::grabWindow(WId window, int qX, int qY, int qWidth, int q
|
|||
QWindow *QWindowsScreen::topLevelAt(const QPoint &point) const
|
||||
{
|
||||
QWindow *result = 0;
|
||||
if (QWindow *child = QWindowsScreen::windowAt(point * QWindowsScaling::factor(), CWP_SKIPINVISIBLE))
|
||||
if (QWindow *child = QWindowsScreen::windowAt(point, CWP_SKIPINVISIBLE))
|
||||
result = QWindowsWindow::topLevelOf(child);
|
||||
qCDebug(lcQpaWindows) <<__FUNCTION__ << point << result;
|
||||
return result;
|
||||
|
|
@ -542,7 +516,7 @@ void QWindowsScreenManager::clearScreens()
|
|||
const QWindowsScreen *QWindowsScreenManager::screenAtDp(const QPoint &p) const
|
||||
{
|
||||
foreach (QWindowsScreen *scr, m_screens) {
|
||||
if (scr->geometryDp().contains(p))
|
||||
if (scr->geometry().contains(p))
|
||||
return scr;
|
||||
}
|
||||
return Q_NULLPTR;
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@
|
|||
#ifndef QWINDOWSSCREEN_H
|
||||
#define QWINDOWSSCREEN_H
|
||||
|
||||
#include "qwindowsscaling.h"
|
||||
#include "qtwindowsglobal.h"
|
||||
#ifdef Q_OS_WINCE
|
||||
# include "qplatformfunctions_wince.h"
|
||||
|
|
@ -82,16 +81,13 @@ public:
|
|||
|
||||
static QWindowsScreen *screenOf(const QWindow *w = 0);
|
||||
|
||||
QRect geometryDp() const { return m_data.geometry; }
|
||||
QRect geometry() const Q_DECL_OVERRIDE { return QWindowsScaling::mapFromNative(geometryDp()); }
|
||||
QRect availableGeometryDp() const { return m_data.availableGeometry; }
|
||||
QRect availableGeometry() const Q_DECL_OVERRIDE { return QWindowsScaling::mapFromNative(availableGeometryDp()); }
|
||||
QRect geometry() const Q_DECL_OVERRIDE { return m_data.geometry; }
|
||||
QRect availableGeometry() const Q_DECL_OVERRIDE { return m_data.availableGeometry; }
|
||||
int depth() const Q_DECL_OVERRIDE { return m_data.depth; }
|
||||
QImage::Format format() const Q_DECL_OVERRIDE { return m_data.format; }
|
||||
QSizeF physicalSize() const Q_DECL_OVERRIDE { return m_data.physicalSizeMM; }
|
||||
QDpi logicalDpi() const Q_DECL_OVERRIDE
|
||||
{ return QDpi(m_data.dpi.first / QWindowsScaling::factor(), m_data.dpi.second / QWindowsScaling::factor()); }
|
||||
qreal devicePixelRatio() const Q_DECL_OVERRIDE { return QWindowsScaling::factor(); }
|
||||
QDpi logicalDpi() const Q_DECL_OVERRIDE { return m_data.dpi; }
|
||||
qreal devicePixelRatio() const Q_DECL_OVERRIDE { return 1.0; }
|
||||
qreal refreshRate() const Q_DECL_OVERRIDE { return m_data.refreshRateHz; }
|
||||
QString name() const Q_DECL_OVERRIDE { return m_data.name; }
|
||||
Qt::ScreenOrientation orientation() const Q_DECL_OVERRIDE { return m_data.orientation; }
|
||||
|
|
@ -112,7 +108,6 @@ public:
|
|||
#endif // !QT_NO_CURSOR
|
||||
|
||||
const QWindowsScreenData &data() const { return m_data; }
|
||||
static int maxMonitorHorizResolution();
|
||||
|
||||
private:
|
||||
QWindowsScreenData m_data;
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include "qwindowstabletsupport.h"
|
||||
#include "qwindowsscaling.h"
|
||||
|
||||
#ifndef QT_NO_TABLETEVENT
|
||||
|
||||
|
|
@ -399,8 +398,7 @@ bool QWindowsTabletSupport::translateTabletPacketEvent()
|
|||
// in which case we snap the position to the mouse position.
|
||||
// It seems there is no way to find out the mode programmatically, the LOGCONTEXT orgX/Y/Ext
|
||||
// area is always the virtual desktop.
|
||||
const QRect virtualDesktopArea
|
||||
= QWindowsScaling::mapToNative(QGuiApplication::primaryScreen()->virtualGeometry());
|
||||
const QRect virtualDesktopArea = QGuiApplication::primaryScreen()->virtualGeometry();
|
||||
|
||||
qCDebug(lcQpaTablet) << __FUNCTION__ << "processing " << packetCount
|
||||
<< "target:" << QGuiApplicationPrivate::tabletPressTarget;
|
||||
|
|
@ -420,7 +418,7 @@ bool QWindowsTabletSupport::translateTabletPacketEvent()
|
|||
QPoint globalPos = globalPosF.toPoint();
|
||||
|
||||
// Get Mouse Position and compare to tablet info
|
||||
QPoint mouseLocation = QWindowsCursor::mousePosition();
|
||||
const QPoint mouseLocation = QWindowsCursor::mousePosition();
|
||||
|
||||
// Positions should be almost the same if we are in absolute
|
||||
// mode. If they are not, use the mouse location.
|
||||
|
|
@ -475,9 +473,7 @@ bool QWindowsTabletSupport::translateTabletPacketEvent()
|
|||
<< tiltY << "tanP:" << tangentialPressure << "rotation:" << rotation;
|
||||
}
|
||||
|
||||
const QPointF localPosDip = QPointF(localPos / QWindowsScaling::factor());
|
||||
const QPointF globalPosDip = globalPosF / qreal(QWindowsScaling::factor());
|
||||
QWindowSystemInterface::handleTabletEvent(target, localPosDip, globalPosDip,
|
||||
QWindowSystemInterface::handleTabletEvent(target, QPointF(localPos), globalPosF,
|
||||
currentDevice, currentPointer,
|
||||
static_cast<Qt::MouseButtons>(packet.pkButtons),
|
||||
pressureNew, tiltX, tiltY,
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@
|
|||
#include "qwindowsintegration.h"
|
||||
#include "qt_windows.h"
|
||||
#include "qwindowsfontdatabase.h"
|
||||
#include "qwindowsscaling.h"
|
||||
#ifdef Q_OS_WINCE
|
||||
# include "qplatformfunctions_wince.h"
|
||||
# include "winuser.h"
|
||||
|
|
@ -495,7 +494,7 @@ static QPixmap loadIconFromShell32(int resourceId, QSizeF size)
|
|||
|
||||
QPixmap QWindowsTheme::standardPixmap(StandardPixmap sp, const QSizeF &size) const
|
||||
{
|
||||
const int scaleFactor = QWindowsScaling::factor();
|
||||
const int scaleFactor = 1; // HIGDPI Fixme: ?
|
||||
const QSizeF pixmapSize = size * scaleFactor;
|
||||
int resourceId = -1;
|
||||
LPCTSTR iconName = 0;
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@
|
|||
#include "qwindowscontext.h"
|
||||
#include "qwindowsdrag.h"
|
||||
#include "qwindowsscreen.h"
|
||||
#include "qwindowsscaling.h"
|
||||
#include "qwindowsintegration.h"
|
||||
#include "qwindowsopenglcontext.h"
|
||||
#ifdef QT_NO_CURSOR
|
||||
|
|
@ -49,7 +48,7 @@
|
|||
#include <QtGui/QRegion>
|
||||
#include <QtGui/QOpenGLContext>
|
||||
#include <private/qsystemlibrary_p.h>
|
||||
#include <private/qwindow_p.h>
|
||||
#include <private/qwindow_p.h> // QWINDOWSIZE_MAX
|
||||
#include <private/qguiapplication_p.h>
|
||||
#include <qpa/qwindowsysteminterface.h>
|
||||
|
||||
|
|
@ -169,7 +168,7 @@ static QPoint windowPlacementOffset(HWND hwnd, const QPoint &point)
|
|||
const QWindowsScreen *screen = screenManager.screens().size() == 1
|
||||
? screenManager.screens().first() : screenManager.screenAtDp(point);
|
||||
if (screen)
|
||||
return screen->availableGeometryDp().topLeft() - screen->geometryDp().topLeft();
|
||||
return screen->availableGeometry().topLeft() - screen->geometry().topLeft();
|
||||
#else
|
||||
Q_UNUSED(hwnd)
|
||||
Q_UNUSED(point)
|
||||
|
|
@ -608,9 +607,7 @@ QWindowsWindowData
|
|||
|
||||
const QString windowClassName = QWindowsContext::instance()->registerWindowClass(w);
|
||||
|
||||
const QRect geometryDip = QWindowsScaling::mapFromNative(data.geometry);
|
||||
QRect fixedGeometryDip = QPlatformWindow::initialGeometry(w, geometryDip, defaultWindowWidth, defaultWindowHeight);
|
||||
const QRect rect = fixedGeometryDip != geometryDip ? QWindowsScaling::mapToNative(fixedGeometryDip) : data.geometry;
|
||||
const QRect rect = QPlatformWindow::initialGeometry(w, data.geometry, defaultWindowWidth, defaultWindowHeight);
|
||||
|
||||
if (title.isEmpty() && (result.flags & Qt::WindowTitleHint))
|
||||
title = topLevel ? qAppName() : w->objectName();
|
||||
|
|
@ -718,8 +715,8 @@ void WindowCreationData::initialize(const QWindow *w, HWND hwnd, bool frameChang
|
|||
*/
|
||||
|
||||
QWindowsGeometryHint::QWindowsGeometryHint(const QWindow *w, const QMargins &cm) :
|
||||
minimumSize(QWindowsScaling::mapToNativeConstrained(w->minimumSize())),
|
||||
maximumSize(QWindowsScaling::mapToNativeConstrained(w->maximumSize())),
|
||||
minimumSize(w->minimumSize()),
|
||||
maximumSize(w->maximumSize()),
|
||||
customMargins(cm)
|
||||
{
|
||||
}
|
||||
|
|
@ -953,8 +950,7 @@ void QWindowsWindow::fireExpose(const QRegion ®ion, bool force)
|
|||
clearFlag(Exposed);
|
||||
else
|
||||
setFlag(Exposed);
|
||||
QWindowSystemInterface::handleExposeEvent(window(),
|
||||
QWindowsScaling::mapFromNative(region));
|
||||
QWindowSystemInterface::handleExposeEvent(window(), region);
|
||||
}
|
||||
|
||||
static inline QWindow *findTransientChild(const QWindow *parent)
|
||||
|
|
@ -1134,7 +1130,7 @@ bool QWindowsWindow::isEmbedded(const QPlatformWindow *parentWindow) const
|
|||
return m_data.embedded;
|
||||
}
|
||||
|
||||
QPoint QWindowsWindow::mapToGlobalDp(const QPoint &pos) const
|
||||
QPoint QWindowsWindow::mapToGlobal(const QPoint &pos) const
|
||||
{
|
||||
if (m_data.hwnd)
|
||||
return QWindowsGeometryHint::mapToGlobal(m_data.hwnd, pos);
|
||||
|
|
@ -1142,7 +1138,7 @@ QPoint QWindowsWindow::mapToGlobalDp(const QPoint &pos) const
|
|||
return pos;
|
||||
}
|
||||
|
||||
QPoint QWindowsWindow::mapFromGlobalDp(const QPoint &pos) const
|
||||
QPoint QWindowsWindow::mapFromGlobal(const QPoint &pos) const
|
||||
{
|
||||
if (m_data.hwnd)
|
||||
return QWindowsGeometryHint::mapFromGlobal(m_data.hwnd, pos);
|
||||
|
|
@ -1323,22 +1319,22 @@ static QRect normalFrameGeometry(HWND hwnd)
|
|||
return QRect();
|
||||
}
|
||||
|
||||
QRect QWindowsWindow::normalGeometryDp() const
|
||||
QRect QWindowsWindow::normalGeometry() const
|
||||
{
|
||||
// Check for fake 'fullscreen' mode.
|
||||
const bool fakeFullScreen = m_savedFrameGeometry.isValid() && window()->windowState() == Qt::WindowFullScreen;
|
||||
const QRect frame = fakeFullScreen ? m_savedFrameGeometry : normalFrameGeometry(m_data.hwnd);
|
||||
const QMargins margins = fakeFullScreen ? QWindowsGeometryHint::frame(m_savedStyle, 0) : frameMarginsDp();
|
||||
const QMargins margins = fakeFullScreen ? QWindowsGeometryHint::frame(m_savedStyle, 0) : frameMargins();
|
||||
return frame.isValid() ? frame.marginsRemoved(margins) : frame;
|
||||
}
|
||||
|
||||
void QWindowsWindow::setGeometryDp(const QRect &rectIn)
|
||||
void QWindowsWindow::setGeometry(const QRect &rectIn)
|
||||
{
|
||||
QRect rect = rectIn;
|
||||
// This means it is a call from QWindow::setFramePosition() and
|
||||
// the coordinates include the frame (size is still the contents rectangle).
|
||||
if (QWindowsGeometryHint::positionIncludesFrame(window())) {
|
||||
const QMargins margins = frameMarginsDp();
|
||||
const QMargins margins = frameMargins();
|
||||
rect.moveTopLeft(rect.topLeft() + QPoint(margins.left(), margins.top()));
|
||||
}
|
||||
if (m_windowState == Qt::WindowMinimized)
|
||||
|
|
@ -1407,9 +1403,8 @@ void QWindowsWindow::handleGeometryChange()
|
|||
return;
|
||||
const QRect previousGeometry = m_data.geometry;
|
||||
m_data.geometry = geometry_sys();
|
||||
const QRect geometryDip = QWindowsScaling::mapFromNative(m_data.geometry);
|
||||
QPlatformWindow::setGeometry(geometryDip);
|
||||
QWindowSystemInterface::handleGeometryChange(window(), geometryDip);
|
||||
QPlatformWindow::setGeometry(m_data.geometry);
|
||||
QWindowSystemInterface::handleGeometryChange(window(), m_data.geometry);
|
||||
// QTBUG-32121: OpenGL/normal windows (with exception of ANGLE) do not receive
|
||||
// expose events when shrinking, synthesize.
|
||||
if (!testFlag(OpenGL_ES2) && isExposed()
|
||||
|
|
@ -1417,7 +1412,7 @@ void QWindowsWindow::handleGeometryChange()
|
|||
fireExpose(QRect(QPoint(0, 0), m_data.geometry.size()), true);
|
||||
}
|
||||
if (previousGeometry.topLeft() != m_data.geometry.topLeft()) {
|
||||
QPlatformScreen *newScreen = screenForGeometry(geometryDip);
|
||||
QPlatformScreen *newScreen = screenForGeometry(m_data.geometry);
|
||||
if (newScreen != screen())
|
||||
QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->screen());
|
||||
}
|
||||
|
|
@ -1429,7 +1424,7 @@ void QWindowsWindow::handleGeometryChange()
|
|||
|
||||
void QWindowsWindow::setGeometry_sys(const QRect &rect) const
|
||||
{
|
||||
const QMargins margins = frameMarginsDp();
|
||||
const QMargins margins = frameMargins();
|
||||
const QRect frameGeometry = rect + margins;
|
||||
|
||||
qCDebug(lcQpaWindows) << '>' << __FUNCTION__ << window()
|
||||
|
|
@ -1468,7 +1463,7 @@ QRect QWindowsWindow::frameGeometry_sys() const
|
|||
|
||||
QRect QWindowsWindow::geometry_sys() const
|
||||
{
|
||||
return frameGeometry_sys().marginsRemoved(frameMarginsDp());
|
||||
return frameGeometry_sys().marginsRemoved(frameMargins());
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
@ -1540,7 +1535,7 @@ void QWindowsWindow::setWindowFlags(Qt::WindowFlags flags)
|
|||
{
|
||||
qCDebug(lcQpaWindows) << '>' << __FUNCTION__ << this << window() << "\n from: "
|
||||
<< m_data.flags << "\n to: " << flags;
|
||||
const QRect oldGeometry = geometryDp();
|
||||
const QRect oldGeometry = geometry();
|
||||
if (m_data.flags != flags) {
|
||||
m_data.flags = flags;
|
||||
if (m_data.hwnd) {
|
||||
|
|
@ -1626,8 +1621,7 @@ void QWindowsWindow::setWindowState(Qt::WindowState state)
|
|||
|
||||
bool QWindowsWindow::isFullScreen_sys() const
|
||||
{
|
||||
return window()->isTopLevel()
|
||||
&& geometry_sys() == QWindowsScaling::mapToNative(window()->screen()->geometry());
|
||||
return window()->isTopLevel() && geometry_sys() == window()->screen()->geometry();
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
@ -1697,15 +1691,14 @@ void QWindowsWindow::setWindowState_sys(Qt::WindowState newState)
|
|||
// Use geometry of QWindow::screen() within creation or the virtual screen the
|
||||
// window is in (QTBUG-31166, QTBUG-30724).
|
||||
const QScreen *screen = window()->screen();
|
||||
const QRect rDip = screen->geometry();
|
||||
const QRect r = QWindowsScaling::mapToNative(rDip);
|
||||
const QRect r = screen->geometry();
|
||||
const UINT swpf = SWP_FRAMECHANGED | SWP_NOACTIVATE;
|
||||
const bool wasSync = testFlag(SynchronousGeometryChangeEvent);
|
||||
setFlag(SynchronousGeometryChangeEvent);
|
||||
SetWindowPos(m_data.hwnd, HWND_TOP, r.left(), r.top(), r.width(), r.height(), swpf);
|
||||
if (!wasSync)
|
||||
clearFlag(SynchronousGeometryChangeEvent);
|
||||
QWindowSystemInterface::handleGeometryChange(window(), rDip);
|
||||
QWindowSystemInterface::handleGeometryChange(window(), r);
|
||||
QWindowSystemInterface::flushWindowSystemEvents();
|
||||
} else if (newState != Qt::WindowMinimized) {
|
||||
// Restore saved state.
|
||||
|
|
@ -1804,7 +1797,7 @@ void QWindowsWindow::propagateSizeHints()
|
|||
qCDebug(lcQpaWindows) << __FUNCTION__ << this << window();
|
||||
}
|
||||
|
||||
bool QWindowsWindow::handleGeometryChangingMessage(MSG *message, const QWindow *qWindow, const QMargins &marginsDp)
|
||||
bool QWindowsWindow::handleGeometryChangingMessage(MSG *message, const QWindow *qWindow, const QMargins &margins)
|
||||
{
|
||||
#ifndef Q_OS_WINCE
|
||||
if (!qWindow->isTopLevel()) // Implement hasHeightForWidth().
|
||||
|
|
@ -1812,26 +1805,20 @@ bool QWindowsWindow::handleGeometryChangingMessage(MSG *message, const QWindow *
|
|||
WINDOWPOS *windowPos = reinterpret_cast<WINDOWPOS *>(message->lParam);
|
||||
if ((windowPos->flags & (SWP_NOCOPYBITS | SWP_NOSIZE)))
|
||||
return false;
|
||||
const QRect suggestedFrameGeometryDp(windowPos->x, windowPos->y,
|
||||
windowPos->cx, windowPos->cy);
|
||||
const qreal factor = QWindowsScaling::factor();
|
||||
const QRect suggestedGeometryDp = suggestedFrameGeometryDp - marginsDp;
|
||||
const QRectF suggestedGeometry = QRectF(QPointF(suggestedGeometryDp.topLeft()) / factor,
|
||||
QSizeF(suggestedGeometryDp.size()) / factor);
|
||||
const QRect suggestedFrameGeometry(windowPos->x, windowPos->y,
|
||||
windowPos->cx, windowPos->cy);
|
||||
const QRect suggestedGeometry = suggestedFrameGeometry - margins;
|
||||
const QRectF correctedGeometryF =
|
||||
qt_window_private(const_cast<QWindow *>(qWindow))->closestAcceptableGeometry(suggestedGeometry);
|
||||
if (!correctedGeometryF.isValid())
|
||||
return false;
|
||||
const QRect correctedFrameGeometryDp
|
||||
= QRectF(correctedGeometryF.topLeft() * factor,
|
||||
correctedGeometryF.size() * factor).toRect()
|
||||
+ marginsDp;
|
||||
if (correctedFrameGeometryDp == suggestedFrameGeometryDp)
|
||||
const QRect correctedFrameGeometry = correctedGeometryF.toRect() + margins;
|
||||
if (correctedFrameGeometry == suggestedFrameGeometry)
|
||||
return false;
|
||||
windowPos->x = correctedFrameGeometryDp.left();
|
||||
windowPos->y = correctedFrameGeometryDp.top();
|
||||
windowPos->cx = correctedFrameGeometryDp.width();
|
||||
windowPos->cy = correctedFrameGeometryDp.height();
|
||||
windowPos->x = correctedFrameGeometry.left();
|
||||
windowPos->y = correctedFrameGeometry.top();
|
||||
windowPos->cx = correctedFrameGeometry.width();
|
||||
windowPos->cy = correctedFrameGeometry.height();
|
||||
return true;
|
||||
#else // !Q_OS_WINCE
|
||||
Q_UNUSED(message)
|
||||
|
|
@ -1841,11 +1828,11 @@ bool QWindowsWindow::handleGeometryChangingMessage(MSG *message, const QWindow *
|
|||
|
||||
bool QWindowsWindow::handleGeometryChanging(MSG *message) const
|
||||
{
|
||||
const QMargins marginsDp = window()->isTopLevel() ? frameMarginsDp() : QMargins();
|
||||
return QWindowsWindow::handleGeometryChangingMessage(message, window(), marginsDp);
|
||||
const QMargins margins = window()->isTopLevel() ? frameMargins() : QMargins();
|
||||
return QWindowsWindow::handleGeometryChangingMessage(message, window(), margins);
|
||||
}
|
||||
|
||||
QMargins QWindowsWindow::frameMarginsDp() const
|
||||
QMargins QWindowsWindow::frameMargins() const
|
||||
{
|
||||
// Frames are invalidated by style changes (window state, flags).
|
||||
// As they are also required for geometry calculations in resize
|
||||
|
|
@ -1892,17 +1879,17 @@ static inline void addRectToWinRegion(const QRect &rect, HRGN *winRegion)
|
|||
}
|
||||
}
|
||||
|
||||
static HRGN qRegionToWinRegion(const QRegion ®ionDip)
|
||||
static HRGN qRegionToWinRegion(const QRegion ®ion)
|
||||
{
|
||||
const QVector<QRect> rects = regionDip.rects();
|
||||
const QVector<QRect> rects = region.rects();
|
||||
if (rects.isEmpty())
|
||||
return NULL;
|
||||
const int rectCount = rects.size();
|
||||
if (rectCount == 1)
|
||||
return createRectRegion(QWindowsScaling::mapToNative(regionDip.boundingRect()));
|
||||
HRGN hRegion = createRectRegion(QWindowsScaling::mapToNative(rects.front()));
|
||||
return createRectRegion(region.boundingRect());
|
||||
HRGN hRegion = createRectRegion(rects.front());
|
||||
for (int i = 1; i < rectCount; ++i)
|
||||
addRectToWinRegion(QWindowsScaling::mapToNative(rects.at(i)), &hRegion);
|
||||
addRectToWinRegion(rects.at(i), &hRegion);
|
||||
return hRegion;
|
||||
}
|
||||
|
||||
|
|
@ -1916,7 +1903,7 @@ void QWindowsWindow::setMask(const QRegion ®ion)
|
|||
|
||||
// Mask is in client area coordinates, so offset it in case we have a frame
|
||||
if (window()->isTopLevel()) {
|
||||
const QMargins margins = frameMarginsDp();
|
||||
const QMargins margins = frameMargins();
|
||||
OffsetRgn(winRegion, margins.left(), margins.top());
|
||||
}
|
||||
|
||||
|
|
@ -2053,23 +2040,23 @@ bool QWindowsWindow::handleNonClientHitTest(const QPoint &globalPos, LRESULT *re
|
|||
|| (m_data.flags & Qt::FramelessWindowHint)) {
|
||||
return false;
|
||||
}
|
||||
const QSize minimumSize = QWindowsScaling::mapToNativeConstrained(w->minimumSize());
|
||||
const QSize minimumSize = w->minimumSize();
|
||||
if (minimumSize.isEmpty())
|
||||
return false;
|
||||
const QSize maximumSize = QWindowsScaling::mapToNativeConstrained(w->maximumSize());
|
||||
const QSize maximumSize = w->maximumSize();
|
||||
const bool fixedWidth = minimumSize.width() == maximumSize.width();
|
||||
const bool fixedHeight = minimumSize.height() == maximumSize.height();
|
||||
if (!fixedWidth && !fixedHeight)
|
||||
return false;
|
||||
const QPoint localPos = mapFromGlobalDp(globalPos);
|
||||
const QSize size = w->size() * QWindowsScaling::factor();
|
||||
const QPoint localPos = w->mapFromGlobal(globalPos);
|
||||
const QSize size = w->size();
|
||||
if (fixedHeight) {
|
||||
if (localPos.y() >= size.height()) {
|
||||
*result = HTBORDER; // Unspecified border, no resize cursor.
|
||||
return true;
|
||||
}
|
||||
if (localPos.y() < 0) {
|
||||
const QMargins margins = frameMarginsDp();
|
||||
const QMargins margins = frameMargins();
|
||||
const int topResizeBarPos = margins.left() - margins.top();
|
||||
if (localPos.y() < topResizeBarPos) {
|
||||
*result = HTCAPTION; // Extend caption over top resize bar, let's user move the window.
|
||||
|
|
@ -2245,10 +2232,6 @@ void QWindowsWindow::setWindowIcon(const QIcon &icon)
|
|||
The property can be set using QPlatformNativeInterface::setWindowProperty() or,
|
||||
before platform window creation, by setting a dynamic property
|
||||
on the QWindow (see QWindowsIntegration::createPlatformWindow()).
|
||||
|
||||
Note: The function uses (unscaled) device pixels since the QWizard also
|
||||
uses AdjustWindowRect() and using device independent pixels would introduce
|
||||
rounding errors.
|
||||
*/
|
||||
|
||||
void QWindowsWindow::setCustomMargins(const QMargins &newCustomMargins)
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@
|
|||
#ifdef Q_OS_WINCE
|
||||
# include "qplatformfunctions_wince.h"
|
||||
#endif
|
||||
#include "qwindowsscaling.h"
|
||||
#include "qwindowscursor.h"
|
||||
|
||||
#include <qpa/qplatformwindow.h>
|
||||
|
|
@ -145,28 +144,18 @@ public:
|
|||
~QWindowsWindow();
|
||||
|
||||
QSurfaceFormat format() const Q_DECL_OVERRIDE { return m_format; }
|
||||
void setGeometryDp(const QRect &rectIn);
|
||||
void setGeometry(const QRect &rect) Q_DECL_OVERRIDE
|
||||
{ setGeometryDp(QWindowsScaling::mapToNative(rect)); }
|
||||
QRect geometryDp() const { return m_data.geometry; }
|
||||
QRect geometry() const Q_DECL_OVERRIDE
|
||||
{ return QWindowsScaling::mapFromNative(geometryDp()); }
|
||||
QRect normalGeometryDp() const;
|
||||
QRect normalGeometry() const Q_DECL_OVERRIDE
|
||||
{ return QWindowsScaling::mapFromNative(normalGeometryDp()); }
|
||||
qreal devicePixelRatio() const Q_DECL_OVERRIDE
|
||||
{ return qreal(QWindowsScaling::factor()); }
|
||||
void setGeometry(const QRect &rect) Q_DECL_OVERRIDE;
|
||||
QRect geometry() const Q_DECL_OVERRIDE { return m_data.geometry; }
|
||||
QRect normalGeometry() const Q_DECL_OVERRIDE;
|
||||
|
||||
void setVisible(bool visible) Q_DECL_OVERRIDE;
|
||||
bool isVisible() const;
|
||||
bool isExposed() const Q_DECL_OVERRIDE { return testFlag(Exposed); }
|
||||
bool isActive() const Q_DECL_OVERRIDE;
|
||||
bool isEmbedded(const QPlatformWindow *parentWindow) const Q_DECL_OVERRIDE;
|
||||
QPoint mapToGlobalDp(const QPoint &pos) const;
|
||||
QPoint mapToGlobal(const QPoint &pos) const Q_DECL_OVERRIDE
|
||||
{ return mapToGlobalDp(pos * QWindowsScaling::factor()) / QWindowsScaling::factor(); }
|
||||
QPoint mapFromGlobalDp(const QPoint &pos) const;
|
||||
QPoint mapFromGlobal(const QPoint &pos) const Q_DECL_OVERRIDE
|
||||
{ return mapFromGlobalDp(pos * QWindowsScaling::factor()) / QWindowsScaling::factor(); }
|
||||
QPoint mapToGlobal(const QPoint &pos) const Q_DECL_OVERRIDE;
|
||||
QPoint mapFromGlobal(const QPoint &pos) const Q_DECL_OVERRIDE;
|
||||
|
||||
void setWindowFlags(Qt::WindowFlags flags) Q_DECL_OVERRIDE;
|
||||
void setWindowState(Qt::WindowState state) Q_DECL_OVERRIDE;
|
||||
|
||||
|
|
@ -184,8 +173,7 @@ public:
|
|||
void propagateSizeHints() Q_DECL_OVERRIDE;
|
||||
static bool handleGeometryChangingMessage(MSG *message, const QWindow *qWindow, const QMargins &marginsDp);
|
||||
bool handleGeometryChanging(MSG *message) const;
|
||||
QMargins frameMarginsDp() const;
|
||||
QMargins frameMargins() const Q_DECL_OVERRIDE { return frameMarginsDp() / QWindowsScaling::factor(); }
|
||||
QMargins frameMargins() const Q_DECL_OVERRIDE;
|
||||
|
||||
void setOpacity(qreal level) Q_DECL_OVERRIDE;
|
||||
void setMask(const QRegion ®ion) Q_DECL_OVERRIDE;
|
||||
|
|
@ -196,7 +184,7 @@ public:
|
|||
bool setMouseGrabEnabled(bool grab) Q_DECL_OVERRIDE;
|
||||
inline bool hasMouseCapture() const { return GetCapture() == m_data.hwnd; }
|
||||
|
||||
bool startSystemResize(const QPoint &, Qt::Corner corner) Q_DECL_OVERRIDE;
|
||||
bool startSystemResize(const QPoint &pos, Qt::Corner corner) Q_DECL_OVERRIDE;
|
||||
|
||||
void setFrameStrutEventsEnabled(bool enabled);
|
||||
bool frameStrutEventsEnabled() const { return testFlag(FrameStrutEventsEnabled); }
|
||||
|
|
|
|||
|
|
@ -40,7 +40,6 @@ SOURCES += \
|
|||
$$PWD/qwindowsservices.cpp \
|
||||
$$PWD/qwindowsnativeimage.cpp \
|
||||
$$PWD/qwindowsnativeinterface.cpp \
|
||||
$$PWD/qwindowsscaling.cpp \
|
||||
$$PWD/qwindowsopengltester.cpp
|
||||
|
||||
HEADERS += \
|
||||
|
|
@ -67,7 +66,6 @@ HEADERS += \
|
|||
$$PWD/qplatformfunctions_wince.h \
|
||||
$$PWD/qwindowsnativeimage.h \
|
||||
$$PWD/qwindowsnativeinterface.h \
|
||||
$$PWD/qwindowsscaling.h \
|
||||
$$PWD/qwindowsopengltester.h
|
||||
|
||||
INCLUDEPATH += $$PWD
|
||||
|
|
|
|||
Loading…
Reference in New Issue