Skip to content
This repository has been archived by the owner on Nov 18, 2018. It is now read-only.

Commit

Permalink
Scale surface items by the buffer scale
Browse files Browse the repository at this point in the history
As reported here [1] with a compositor that properly
handles HiDPI, surface item size is not scaled at all
resulting in windows twice the size on Retina.

Issue: #190
Issue: #218

[1] = https://bugreports.qt.io/browse/QTBUG-55303
  • Loading branch information
plfiorini committed Aug 14, 2016
1 parent ee13b4a commit 3088e0a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/server/shell/clientwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -639,8 +639,9 @@ QPointF ClientWindow::randomPosition() const
Q_D(const ClientWindow);

// Surface size
const int w = d->surface->size().width();
const int h = d->surface->size().height();
const QSize surfaceSize = d->surface->size() / d->surface->bufferScale();
const int w = surfaceSize.width();
const int h = surfaceSize.height();

// Find the output where the pointer is located, defaults
// to the default output
Expand Down
2 changes: 1 addition & 1 deletion src/waylandcompositor/compositor_api/qwaylandquickitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,7 @@ void QWaylandQuickItem::updateSize()
{
Q_D(QWaylandQuickItem);
if (d->sizeFollowsSurface && surface()) {
setSize(surface()->size() * (d->scaleFactor() / surface()->bufferScale()));
setSize(surface()->size() / d->scaleFactor());
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/waylandcompositor/compositor_api/qwaylandquickitem_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class QWaylandQuickItemPrivate : public QQuickItemPrivate
}

bool shouldSendInputEvents() const { return view->surface() && inputEventsEnabled; }
int scaleFactor() const { return view->output() ? view->output()->scaleFactor() : 1; }
int scaleFactor() const { return view->surface() ? view->surface()->bufferScale() : 1; }

static QMutex *mutex;

Expand Down

0 comments on commit 3088e0a

Please sign in to comment.