Merge lp:~unity-team/qtmir/dpr into lp:qtmir

Proposed by Gerry Boland
Status: Work in progress
Proposed branch: lp:~unity-team/qtmir/dpr
Merge into: lp:qtmir
Diff against target: 722 lines (+187/-116) (has conflicts)
14 files modified
debian/changelog (+9/-0)
src/modules/Unity/Application/mirsurface.cpp (+63/-61)
src/modules/Unity/Application/mirsurface.h (+8/-8)
src/modules/Unity/Application/mirsurfaceinterface.h (+8/-8)
src/modules/Unity/Application/mirsurfaceitem.cpp (+36/-16)
src/modules/Unity/Application/mirsurfaceitem.h (+1/-0)
src/platforms/mirserver/qteventfeeder.cpp (+13/-6)
src/platforms/mirserver/qteventfeeder.h (+1/-0)
src/platforms/mirserver/screen.cpp (+26/-5)
src/platforms/mirserver/screen.h (+5/-2)
src/platforms/mirserver/screencontroller.cpp (+2/-2)
src/platforms/mirserver/screenwindow.cpp (+5/-0)
src/platforms/mirserver/screenwindow.h (+2/-0)
tests/modules/common/fake_mirsurface.h (+8/-8)
Text conflict in debian/changelog
To merge this branch: bzr merge lp:~unity-team/qtmir/dpr
Reviewer Review Type Date Requested Status
Unity8 CI Bot (community) continuous-integration Needs Fixing
Daniel d'Andrada (community) Approve
PS Jenkins bot (community) continuous-integration Needs Fixing
Review via email: mp+257514@code.launchpad.net

Commit message

Add device pixel ratio support

Description of the change

* Are there any related MPs required for this MP to build/function as expected? Please list.
Nothing depends on this directly, but to do a full test, you'll need:
https://code.launchpad.net/~unity-team/qtubuntu/DPR2/+merge/281664

* Did you perform an exploratory manual test run of your code change and any related functionality?
Y

* If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
N/A

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Gerry Boland (gerboland) wrote :

 * Are there any related MPs required for this MP to build/function as expected? Please list.
Nothing depends on this directly, but to do a full test, you'll need:
https://code.launchpad.net/~unity-team/qtubuntu/DPR/+merge/257515
https://code.launchpad.net/~ubuntu-sdk-team/ubuntu-ui-toolkit/dpr/+merge/256470
https://code.launchpad.net/~mzanetti/ubuntu-settings-components/dpr/+merge/253944

 * Did you perform an exploratory manual test run of your code change and any related functionality?
Y
 * If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
N/A

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

In src/modules/Unity/Application/mirsurfaceitem.cpp:

"""
- int qmlWidth = (int)width();
- int qmlHeight = (int)height();
+ const qreal dpr = devicePixelRatio();
+ int qmlWidth = (int)width() * dpr;
+ int qmlHeight = (int)height() * dpr;
"""

Now they're no longer representing the qml width and height, thus the naming is misleading.
Better calling them something like newMirWidth and newMirHeight.

Also it would be more correct to cast to int *after* the dpr multiplication: (int)(width() * dpr)

review: Needs Fixing
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

In src/modules/Unity/Application/mirsurfaceitem.cpp:

"""
         qCDebug(QTMIR_SURFACES) << "MirSurfaceItem::syncSurfaceSizeWithItemSize()";
- mir::geometry::Size newMirSize((int)width(), (int)height());
+ mir::geometry::Size newMirSize(scaledWidth, scaledHeight);
         m_surface->resize(newMirSize);
- setImplicitSize(width(), height());
+ setImplicitSize(scaledWidth, scaledHeight);
     }
 }
"""

The implicit size should not be scaled.

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

The debian/changelog entry is misplaced. Likely the result of a bad merge with trunk.

Revision history for this message
Daniel d'Andrada (dandrader) wrote :

The only way I see of saving MirSurface from knowing about DPR is passing it the event data directly as parameters instead of giving it the whole QEvent.

Eg:

MirSurface::mouseMoveEvent(QMouseEvent *event, qreal dpr)

Would be:

MirSurface::mouseMoveEvent(Qt::MouseButtons buttons, ulong timestamp, Qt::KeyboardModifiers modifiers, int x, int y)

Which is actually not a bad thing.

Revision history for this message
Gerry Boland (gerboland) wrote :

> The only way I see of saving MirSurface from knowing about DPR is passing it
> the event data directly as parameters instead of giving it the whole QEvent.
>
> Eg:
>
> MirSurface::mouseMoveEvent(QMouseEvent *event, qreal dpr)
>
> Would be:
>
> MirSurface::mouseMoveEvent(Qt::MouseButtons buttons, ulong timestamp,
> Qt::KeyboardModifiers modifiers, int x, int y)
>
> Which is actually not a bad thing.

For touch events too?

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

On 18/09/15 08:44, Gerry Boland wrote:
>> The only way I see of saving MirSurface from knowing about DPR is passing it
>> the event data directly as parameters instead of giving it the whole QEvent.
>>
>> Eg:
>>
>> MirSurface::mouseMoveEvent(QMouseEvent *event, qreal dpr)
>>
>> Would be:
>>
>> MirSurface::mouseMoveEvent(Qt::MouseButtons buttons, ulong timestamp,
>> Qt::KeyboardModifiers modifiers, int x, int y)
>>
>> Which is actually not a bad thing.
> For touch events too?

You'll have to to copy the QList<QTouchEvent::TouchPoint> parameter so
you can transform the points. Is that what you're afraid of (performance
hit)?

Revision history for this message
Gerry Boland (gerboland) wrote :

> On 18/09/15 08:44, Gerry Boland wrote:
> >> The only way I see of saving MirSurface from knowing about DPR is passing
> it
> >> the event data directly as parameters instead of giving it the whole
> QEvent.
> >>
> >> Eg:
> >>
> >> MirSurface::mouseMoveEvent(QMouseEvent *event, qreal dpr)
> >>
> >> Would be:
> >>
> >> MirSurface::mouseMoveEvent(Qt::MouseButtons buttons, ulong timestamp,
> >> Qt::KeyboardModifiers modifiers, int x, int y)
> >>
> >> Which is actually not a bad thing.
> > For touch events too?
>
> You'll have to to copy the QList<QTouchEvent::TouchPoint> parameter so
> you can transform the points. Is that what you're afraid of (performance
> hit)?

Well more generally, it seems to be so much work just for a multiplication. Is why I'm hesitating.

Revision history for this message
Daniel d'Andrada (dandrader) wrote :

In mirsurfaceitem.cpp:

"""
m_lastTouchEvent->touchPoints = touchPoints; ////????
"""

????

Revision history for this message
Daniel d'Andrada (dandrader) wrote :

In mirsurfceitem.cpp:

"""
Note: all geometry is in device-pixels, except that contained in variables with the
"""

s/device-pixels/device-independent pixels

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

"""
const float kP = mir_touch_event_axis_value(tev, i, mir_touch_axis_pressure) / dpr;
"""

Not sure if the pressure axis has any relationship with x & y dimensions to deserve the dpr conversion.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Daniel d'Andrada (dandrader) wrote :
review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

In MirSurfaceItem::updatePaintNode, I would move the "const qreal dpr" declaration next to the single place where it's used.

Revision history for this message
Daniel d'Andrada (dandrader) wrote :

Still in MirSurfaceItem::updatePaintNode:

"""
qreal u = targetRect.width() / textureSize.width() * dpr;
"""

Would be better expressed as:

"""
qreal u = (targetRect.width() * dpr) / textureSize.width();
"""

To make it obvious that your're converting targetRect.width() from DIP (or layout pixels) to actual/physical pixels, which is the unit of textureSize.width().

Likewise for the v coordinate.

Revision history for this message
Daniel d'Andrada (dandrader) wrote :

In src/platforms/mirserver/qteventfeeder.cpp:

"""
    qreal getDevicePixelRatio() override
    {
        return qGuiApp->devicePixelRatio(); // FIXME: make per-screen.
    }
"""

Qt coding style doesn't use the "get" prefix for getters. I think we should stick to it unless there's a good reason to deviate.

Revision history for this message
Daniel d'Andrada (dandrader) wrote :

In QtEventFeeder::dispatchPointer:

"""
    auto movement = QPointF(mir_pointer_event_axis_value(pev, mir_pointer_axis_relative_x) / dpr,
                            mir_pointer_event_axis_value(pev, mir_pointer_axis_relative_y)) / dpr;
"""

I think you meant:

"""
    auto movement = QPointF(mir_pointer_event_axis_value(pev, mir_pointer_axis_relative_x) / dpr,
                            mir_pointer_event_axis_value(pev, mir_pointer_axis_relative_y) / dpr);
"""

review: Needs Fixing
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

Nitpick in Screen::Screen

"""
    bool ok;
    const int dpr = qGetEnvIntValue("QT_DEVICE_PIXEL_RATIO", &ok);
    m_devicePixelRatio = (ok && dpr > 0) ? dpr : 1.0;
"""

You would be better off moving this whole snippet into a separate function instead of just the qGetEnvIntValue part (as it's used only once anyway). That would spare the constructor namespace from getting polluted with those helper variables ok and dpr.

PS: That's what happens when you re-review something. You start to nitpick :)

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Gerry Boland (gerboland) wrote :

I can merge this into trunk just fine. LP confused?

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

Code looks fine. Didn't test yet.

review: Approve (code)
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

And works fine as well.

review: Approve
Revision history for this message
Michał Sawicz (saviq) wrote :

Text conflict in debian/changelog

Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote :

Text conflict in src/modules/Unity/Application/mirsurface.cpp
Text conflict in src/platforms/mirserver/screen.h
Text conflict in tests/framework/fake_mirsurface.h
3 conflicts encountered.

Revision history for this message
Gerry Boland (gerboland) wrote :

Marking WIP, needs rebasing on top of DGU work

Unmerged revisions

360. By Gerry Boland

Move DPR env var reading into dedicated function

359. By Gerry Boland

Typo in DPR calculation

358. By Gerry Boland

getDevicePixelRatio -> devicePixelRatio

357. By Gerry Boland

MirSurfaceItem::updatePaintNode - move calculation around to clarify intention

356. By Gerry Boland

MirSurfaceItem::updatePaintNode Move dpr inside block where it is used

355. By Gerry Boland

Merge trunk

354. By Gerry Boland

Fix scaling to render app surface correctly

353. By Gerry Boland

Add units to debug message

352. By Gerry Boland

Merge trunk

351. By Gerry Boland

Merge trunk

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2016-01-04 09:38:12 +0000
+++ debian/changelog 2016-01-07 17:03:26 +0000
@@ -1,3 +1,4 @@
1<<<<<<< TREE
1qtmir (0.4.7+16.04.20160104-0ubuntu1) xenial; urgency=medium2qtmir (0.4.7+16.04.20160104-0ubuntu1) xenial; urgency=medium
23
3 [ Daniel d'Andrada ]4 [ Daniel d'Andrada ]
@@ -6,6 +7,14 @@
67
7 -- Michał Sawicz <michal.sawicz@canonical.com> Mon, 04 Jan 2016 09:38:12 +00008 -- Michał Sawicz <michal.sawicz@canonical.com> Mon, 04 Jan 2016 09:38:12 +0000
89
10=======
11qtmir (0.4.8) UNRELEASED; urgency=medium
12
13 * Add support for devicePixelRatio, the Qt5.4 UI scaling system
14
15 -- Gerry Boland <gerry.boland@canonical.com> Mon, 04 Jan 2016 12:30:00 +0100
16
17>>>>>>> MERGE-SOURCE
9qtmir (0.4.7+16.04.20151222-0ubuntu1) xenial; urgency=medium18qtmir (0.4.7+16.04.20151222-0ubuntu1) xenial; urgency=medium
1019
11 * No-change rebuild to get -gles in sync20 * No-change rebuild to get -gles in sync
1221
=== modified file 'src/modules/Unity/Application/mirsurface.cpp'
--- src/modules/Unity/Application/mirsurface.cpp 2015-12-10 13:08:43 +0000
+++ src/modules/Unity/Application/mirsurface.cpp 2016-01-07 17:03:26 +0000
@@ -73,34 +73,34 @@
73 return result;73 return result;
74}74}
7575
76mir::EventUPtr makeMirEvent(QMouseEvent *qtEvent, MirPointerAction action)76mir::EventUPtr makeMirEvent(QMouseEvent *qtEvent, MirPointerAction action, qreal dpr)
77{77{
78 auto timestamp = uncompressTimestamp<qtmir::Timestamp>(qtmir::Timestamp(qtEvent->timestamp()));78 auto timestamp = uncompressTimestamp<qtmir::Timestamp>(qtmir::Timestamp(qtEvent->timestamp()));
79 auto modifiers = getMirModifiersFromQt(qtEvent->modifiers());79 auto modifiers = getMirModifiersFromQt(qtEvent->modifiers());
80 auto buttons = getMirButtonsFromQt(qtEvent->buttons());80 auto buttons = getMirButtonsFromQt(qtEvent->buttons());
8181
82 return mir::events::make_event(0 /*DeviceID */, timestamp, 0 /* mac */, modifiers, action,82 return mir::events::make_event(0 /*DeviceID */, timestamp, 0 /* mac */, modifiers, action,
83 buttons, qtEvent->x(), qtEvent->y(), 0, 0, 0, 0);83 buttons, qtEvent->x() * dpr, qtEvent->y() * dpr, 0, 0, 0, 0);
84}84}
8585
86mir::EventUPtr makeMirEvent(QHoverEvent *qtEvent, MirPointerAction action)86mir::EventUPtr makeMirEvent(QHoverEvent *qtEvent, MirPointerAction action, qreal dpr)
87{87{
88 auto timestamp = uncompressTimestamp<qtmir::Timestamp>(qtmir::Timestamp(qtEvent->timestamp()));88 auto timestamp = uncompressTimestamp<qtmir::Timestamp>(qtmir::Timestamp(qtEvent->timestamp()));
8989
90 MirPointerButtons buttons = 0;90 MirPointerButtons buttons = 0;
9191
92 return mir::events::make_event(0 /*DeviceID */, timestamp, 0 /* mac */, mir_input_event_modifier_none, action,92 return mir::events::make_event(0 /*DeviceID */, timestamp, 0 /* mac */, mir_input_event_modifier_none, action,
93 buttons, qtEvent->posF().x(), qtEvent->posF().y(), 0, 0, 0, 0);93 buttons, qtEvent->posF().x() * dpr, qtEvent->posF().y() * dpr, 0, 0, 0, 0);
94}94}
9595
96mir::EventUPtr makeMirEvent(QWheelEvent *qtEvent)96mir::EventUPtr makeMirEvent(QWheelEvent *qtEvent, qreal dpr)
97{97{
98 auto timestamp = std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::milliseconds(qtEvent->timestamp()));98 auto timestamp = std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::milliseconds(qtEvent->timestamp()));
99 auto modifiers = getMirModifiersFromQt(qtEvent->modifiers());99 auto modifiers = getMirModifiersFromQt(qtEvent->modifiers());
100 auto buttons = getMirButtonsFromQt(qtEvent->buttons());100 auto buttons = getMirButtonsFromQt(qtEvent->buttons());
101101
102 return mir::events::make_event(0 /*DeviceID */, timestamp, 0 /* mac */, modifiers, mir_pointer_action_motion,102 return mir::events::make_event(0 /*DeviceID */, timestamp, 0 /* mac */, modifiers, mir_pointer_action_motion,
103 buttons, qtEvent->x(), qtEvent->y(),103 buttons, qtEvent->x() * dpr, qtEvent->y() * dpr,
104 qtEvent->angleDelta().x(), qtEvent->angleDelta().y(),104 qtEvent->angleDelta().x(), qtEvent->angleDelta().y(),
105 0, 0);105 0, 0);
106}106}
@@ -131,7 +131,8 @@
131mir::EventUPtr makeMirEvent(Qt::KeyboardModifiers qmods,131mir::EventUPtr makeMirEvent(Qt::KeyboardModifiers qmods,
132 const QList<QTouchEvent::TouchPoint> &qtTouchPoints,132 const QList<QTouchEvent::TouchPoint> &qtTouchPoints,
133 Qt::TouchPointStates /* qtTouchPointStates */,133 Qt::TouchPointStates /* qtTouchPointStates */,
134 ulong qtTimestamp)134 ulong qtTimestamp,
135 qreal dpr)
135{136{
136 auto modifiers = getMirModifiersFromQt(qmods);137 auto modifiers = getMirModifiersFromQt(qmods);
137 auto ev = mir::events::make_event(0, uncompressTimestamp<qtmir::Timestamp>(qtmir::Timestamp(qtTimestamp)),138 auto ev = mir::events::make_event(0, uncompressTimestamp<qtmir::Timestamp>(qtmir::Timestamp(qtTimestamp)),
@@ -156,10 +157,10 @@
156 tooltype = mir_touch_tooltype_stylus;157 tooltype = mir_touch_tooltype_stylus;
157158
158 mir::events::add_touch(*ev, id, action, tooltype,159 mir::events::add_touch(*ev, id, action, tooltype,
159 touchPoint.pos().x(), touchPoint.pos().y(),160 touchPoint.pos().x() * dpr, touchPoint.pos().y() * dpr,
160 touchPoint.pressure(),161 touchPoint.pressure(),
161 touchPoint.rect().width(),162 touchPoint.rect().width() * dpr,
162 touchPoint.rect().height(),163 touchPoint.rect().height() * dpr,
163 0 /* size */);164 0 /* size */);
164 }165 }
165166
@@ -429,16 +430,16 @@
429430
430void MirSurface::resize(int width, int height)431void MirSurface::resize(int width, int height)
431{432{
432 int mirWidth = m_surface->size().width.as_int();433 const int mirWidth = m_surface->size().width.as_int();
433 int mirHeight = m_surface->size().height.as_int();434 const int mirHeight = m_surface->size().height.as_int();
434435
435 bool mirSizeIsDifferent = width != mirWidth || height != mirHeight;436 bool mirSizeIsDifferent = width != mirWidth || height != mirHeight;
436437
437 if (clientIsRunning() && mirSizeIsDifferent) {438 if (clientIsRunning() && mirSizeIsDifferent) {
438 mir::geometry::Size newMirSize(width, height);439 mir::geometry::Size newMirSize(width, height);
439 m_surface->resize(newMirSize);440 m_surface->resize(newMirSize);
440 DEBUG_MSG << " old (" << mirWidth << "," << mirHeight << ")"441 DEBUG_MSG << " old (" << mirWidth << "," << mirHeight << ")px"
441 << ", new (" << width << "," << height << ")";442 << ", new (" << width << "," << height << ")px";
442 }443 }
443}444}
444445
@@ -576,51 +577,51 @@
576 return m_surface->query(mir_surface_attrib_visibility) == mir_surface_visibility_exposed;577 return m_surface->query(mir_surface_attrib_visibility) == mir_surface_visibility_exposed;
577}578}
578579
579void MirSurface::mousePressEvent(QMouseEvent *event)580void MirSurface::mousePressEvent(QMouseEvent *event, qreal dpr)
580{581{
581 auto ev = makeMirEvent(event, mir_pointer_action_button_down);582 auto ev = makeMirEvent(event, mir_pointer_action_button_down, dpr);
582 m_surface->consume(*ev);583 m_surface->consume(*ev);
583 event->accept();584 event->accept();
584}585}
585586
586void MirSurface::mouseMoveEvent(QMouseEvent *event)587void MirSurface::mouseMoveEvent(QMouseEvent *event, qreal dpr)
587{588{
588 auto ev = makeMirEvent(event, mir_pointer_action_motion);589 auto ev = makeMirEvent(event, mir_pointer_action_motion, dpr);
589 m_surface->consume(*ev);590 m_surface->consume(*ev);
590 event->accept();591 event->accept();
591}592}
592593
593void MirSurface::mouseReleaseEvent(QMouseEvent *event)594void MirSurface::mouseReleaseEvent(QMouseEvent *event, qreal dpr)
594{595{
595 auto ev = makeMirEvent(event, mir_pointer_action_button_up);596 auto ev = makeMirEvent(event, mir_pointer_action_button_up, dpr);
596 m_surface->consume(*ev);597 m_surface->consume(*ev);
597 event->accept();598 event->accept();
598}599}
599600
600void MirSurface::hoverEnterEvent(QHoverEvent *event)601void MirSurface::hoverEnterEvent(QHoverEvent *event, qreal dpr)
601{602{
602 auto ev = makeMirEvent(event, mir_pointer_action_enter);603 auto ev = makeMirEvent(event, mir_pointer_action_enter, dpr);
603 m_surface->consume(*ev);604 m_surface->consume(*ev);
604 event->accept();605 event->accept();
605}606}
606607
607void MirSurface::hoverLeaveEvent(QHoverEvent *event)608void MirSurface::hoverLeaveEvent(QHoverEvent *event, qreal dpr)
608{609{
609 auto ev = makeMirEvent(event, mir_pointer_action_leave);610 auto ev = makeMirEvent(event, mir_pointer_action_leave, dpr);
610 m_surface->consume(*ev);611 m_surface->consume(*ev);
611 event->accept();612 event->accept();
612}613}
613614
614void MirSurface::hoverMoveEvent(QHoverEvent *event)615void MirSurface::hoverMoveEvent(QHoverEvent *event, qreal dpr)
615{616{
616 auto ev = makeMirEvent(event, mir_pointer_action_motion);617 auto ev = makeMirEvent(event, mir_pointer_action_motion, dpr);
617 m_surface->consume(*ev);618 m_surface->consume(*ev);
618 event->accept();619 event->accept();
619}620}
620621
621void MirSurface::wheelEvent(QWheelEvent *event)622void MirSurface::wheelEvent(QWheelEvent *event, qreal dpr)
622{623{
623 auto ev = makeMirEvent(event);624 auto ev = makeMirEvent(event, dpr);
624 m_surface->consume(*ev);625 m_surface->consume(*ev);
625 event->accept();626 event->accept();
626}627}
@@ -642,9 +643,10 @@
642void MirSurface::touchEvent(Qt::KeyboardModifiers mods,643void MirSurface::touchEvent(Qt::KeyboardModifiers mods,
643 const QList<QTouchEvent::TouchPoint> &touchPoints,644 const QList<QTouchEvent::TouchPoint> &touchPoints,
644 Qt::TouchPointStates touchPointStates,645 Qt::TouchPointStates touchPointStates,
645 ulong timestamp)646 ulong timestamp,
647 qreal dpr)
646{648{
647 auto ev = makeMirEvent(mods, touchPoints, touchPointStates, timestamp);649 auto ev = makeMirEvent(mods, touchPoints, touchPointStates, timestamp, dpr);
648 m_surface->consume(*ev);650 m_surface->consume(*ev);
649}651}
650652
651653
=== modified file 'src/modules/Unity/Application/mirsurface.h'
--- src/modules/Unity/Application/mirsurface.h 2015-12-10 13:08:43 +0000
+++ src/modules/Unity/Application/mirsurface.h 2016-01-07 17:03:26 +0000
@@ -101,13 +101,13 @@
101101
102 void close() override;102 void close() override;
103103
104 void mousePressEvent(QMouseEvent *event) override;104 void mousePressEvent(QMouseEvent *event, qreal dpr) override;
105 void mouseMoveEvent(QMouseEvent *event) override;105 void mouseMoveEvent(QMouseEvent *event, qreal dpr) override;
106 void mouseReleaseEvent(QMouseEvent *event) override;106 void mouseReleaseEvent(QMouseEvent *event, qreal dpr) override;
107 void hoverEnterEvent(QHoverEvent *event) override;107 void hoverEnterEvent(QHoverEvent *event, qreal dpr) override;
108 void hoverLeaveEvent(QHoverEvent *event) override;108 void hoverLeaveEvent(QHoverEvent *event, qreal dpr) override;
109 void hoverMoveEvent(QHoverEvent *event) override;109 void hoverMoveEvent(QHoverEvent *event, qreal dpr) override;
110 void wheelEvent(QWheelEvent *event) override;110 void wheelEvent(QWheelEvent *event, qreal dpr) override;
111111
112 void keyPressEvent(QKeyEvent *event) override;112 void keyPressEvent(QKeyEvent *event) override;
113 void keyReleaseEvent(QKeyEvent *event) override;113 void keyReleaseEvent(QKeyEvent *event) override;
@@ -115,7 +115,7 @@
115 void touchEvent(Qt::KeyboardModifiers qmods,115 void touchEvent(Qt::KeyboardModifiers qmods,
116 const QList<QTouchEvent::TouchPoint> &qtTouchPoints,116 const QList<QTouchEvent::TouchPoint> &qtTouchPoints,
117 Qt::TouchPointStates qtTouchPointStates,117 Qt::TouchPointStates qtTouchPointStates,
118 ulong qtTimestamp) override;118 ulong qtTimestamp, qreal dpr) override;
119119
120 QString appId() const override;120 QString appId() const override;
121121
122122
=== modified file 'src/modules/Unity/Application/mirsurfaceinterface.h'
--- src/modules/Unity/Application/mirsurfaceinterface.h 2015-12-10 13:08:43 +0000
+++ src/modules/Unity/Application/mirsurfaceinterface.h 2016-01-07 17:03:26 +0000
@@ -66,13 +66,13 @@
6666
67 virtual void close() = 0;67 virtual void close() = 0;
6868
69 virtual void mousePressEvent(QMouseEvent *event) = 0;69 virtual void mousePressEvent(QMouseEvent *event, qreal dpr = 1.0) = 0;
70 virtual void mouseMoveEvent(QMouseEvent *event) = 0;70 virtual void mouseMoveEvent(QMouseEvent *event, qreal dpr = 1.0) = 0;
71 virtual void mouseReleaseEvent(QMouseEvent *event) = 0;71 virtual void mouseReleaseEvent(QMouseEvent *event, qreal dpr = 1.0) = 0;
72 virtual void hoverEnterEvent(QHoverEvent *event) = 0;72 virtual void hoverEnterEvent(QHoverEvent *event, qreal dpr = 1.0) = 0;
73 virtual void hoverLeaveEvent(QHoverEvent *event) = 0;73 virtual void hoverLeaveEvent(QHoverEvent *event, qreal dpr = 1.0) = 0;
74 virtual void hoverMoveEvent(QHoverEvent *event) = 0;74 virtual void hoverMoveEvent(QHoverEvent *event, qreal dpr = 1.0) = 0;
75 virtual void wheelEvent(QWheelEvent *event) = 0;75 virtual void wheelEvent(QWheelEvent *event, qreal dpr = 1.0) = 0;
7676
77 virtual void keyPressEvent(QKeyEvent *event) = 0;77 virtual void keyPressEvent(QKeyEvent *event) = 0;
78 virtual void keyReleaseEvent(QKeyEvent *event) = 0;78 virtual void keyReleaseEvent(QKeyEvent *event) = 0;
@@ -80,7 +80,7 @@
80 virtual void touchEvent(Qt::KeyboardModifiers qmods,80 virtual void touchEvent(Qt::KeyboardModifiers qmods,
81 const QList<QTouchEvent::TouchPoint> &qtTouchPoints,81 const QList<QTouchEvent::TouchPoint> &qtTouchPoints,
82 Qt::TouchPointStates qtTouchPointStates,82 Qt::TouchPointStates qtTouchPointStates,
83 ulong qtTimestamp) = 0;83 ulong qtTimestamp, qreal dpr = 1.0) = 0;
8484
85 virtual QString appId() const = 0;85 virtual QString appId() const = 0;
8686
8787
=== modified file 'src/modules/Unity/Application/mirsurfaceitem.cpp'
--- src/modules/Unity/Application/mirsurfaceitem.cpp 2015-12-10 13:08:43 +0000
+++ src/modules/Unity/Application/mirsurfaceitem.cpp 2016-01-07 17:03:26 +0000
@@ -54,6 +54,11 @@
54 QObject *textureProvider;54 QObject *textureProvider;
55};55};
5656
57inline int divideAndRoundUp(int numerator, qreal denominator)
58{
59 return ceil((qreal)numerator / denominator);
60}
61
57} // namespace {62} // namespace {
5863
59class MirTextureProvider : public QSGTextureProvider64class MirTextureProvider : public QSGTextureProvider
@@ -81,6 +86,11 @@
81 QSharedPointer<QSGTexture> t;86 QSharedPointer<QSGTexture> t;
82};87};
8388
89/*
90 * Note: all geometry is in device-independent pixels, except that contained in variables with the
91 * suffix "Px" - whose units are physical pixels
92 */
93
84MirSurfaceItem::MirSurfaceItem(QQuickItem *parent)94MirSurfaceItem::MirSurfaceItem(QQuickItem *parent)
85 : MirSurfaceItemInterface(parent)95 : MirSurfaceItemInterface(parent)
86 , m_surface(nullptr)96 , m_surface(nullptr)
@@ -248,13 +258,14 @@
248258
249 if (m_fillMode == PadOrCrop) {259 if (m_fillMode == PadOrCrop) {
250 const QSize &textureSize = m_textureProvider->texture()->textureSize();260 const QSize &textureSize = m_textureProvider->texture()->textureSize();
261 const qreal dpr = devicePixelRatio();
251262
252 QRectF targetRect;263 QRectF targetRect;
253 targetRect.setWidth(qMin(width(), static_cast<qreal>(textureSize.width())));264 targetRect.setWidth(qMin(width(), static_cast<qreal>(textureSize.width())));
254 targetRect.setHeight(qMin(height(), static_cast<qreal>(textureSize.height())));265 targetRect.setHeight(qMin(height(), static_cast<qreal>(textureSize.height())));
255266
256 qreal u = targetRect.width() / textureSize.width();267 qreal u = (targetRect.width() * dpr) / textureSize.width();
257 qreal v = targetRect.height() / textureSize.height();268 qreal v = (targetRect.height() * dpr) / textureSize.height();
258 node->setSubSourceRect(QRectF(0, 0, u, v));269 node->setSubSourceRect(QRectF(0, 0, u, v));
259270
260 node->setTargetRect(targetRect);271 node->setTargetRect(targetRect);
@@ -285,12 +296,12 @@
285 if (type() == Mir::InputMethodType) {296 if (type() == Mir::InputMethodType) {
286 // FIXME: Hack to get the VKB use case working while we don't have the proper solution in place.297 // FIXME: Hack to get the VKB use case working while we don't have the proper solution in place.
287 if (isMouseInsideUbuntuKeyboard(event)) {298 if (isMouseInsideUbuntuKeyboard(event)) {
288 m_surface->mousePressEvent(event);299 m_surface->mousePressEvent(event, devicePixelRatio());
289 } else {300 } else {
290 event->ignore();301 event->ignore();
291 }302 }
292 } else {303 } else {
293 m_surface->mousePressEvent(event);304 m_surface->mousePressEvent(event, devicePixelRatio());
294 }305 }
295 } else {306 } else {
296 event->ignore();307 event->ignore();
@@ -300,7 +311,7 @@
300void MirSurfaceItem::mouseMoveEvent(QMouseEvent *event)311void MirSurfaceItem::mouseMoveEvent(QMouseEvent *event)
301{312{
302 if (m_consumesInput && m_surface && m_surface->live()) {313 if (m_consumesInput && m_surface && m_surface->live()) {
303 m_surface->mouseMoveEvent(event);314 m_surface->mouseMoveEvent(event, devicePixelRatio());
304 } else {315 } else {
305 event->ignore();316 event->ignore();
306 }317 }
@@ -309,7 +320,7 @@
309void MirSurfaceItem::mouseReleaseEvent(QMouseEvent *event)320void MirSurfaceItem::mouseReleaseEvent(QMouseEvent *event)
310{321{
311 if (m_consumesInput && m_surface && m_surface->live()) {322 if (m_consumesInput && m_surface && m_surface->live()) {
312 m_surface->mouseReleaseEvent(event);323 m_surface->mouseReleaseEvent(event, devicePixelRatio());
313 } else {324 } else {
314 event->ignore();325 event->ignore();
315 }326 }
@@ -327,7 +338,7 @@
327void MirSurfaceItem::hoverEnterEvent(QHoverEvent *event)338void MirSurfaceItem::hoverEnterEvent(QHoverEvent *event)
328{339{
329 if (m_consumesInput && m_surface && m_surface->live()) {340 if (m_consumesInput && m_surface && m_surface->live()) {
330 m_surface->hoverEnterEvent(event);341 m_surface->hoverEnterEvent(event, devicePixelRatio());
331 } else {342 } else {
332 event->ignore();343 event->ignore();
333 }344 }
@@ -336,7 +347,7 @@
336void MirSurfaceItem::hoverLeaveEvent(QHoverEvent *event)347void MirSurfaceItem::hoverLeaveEvent(QHoverEvent *event)
337{348{
338 if (m_consumesInput && m_surface && m_surface->live()) {349 if (m_consumesInput && m_surface && m_surface->live()) {
339 m_surface->hoverLeaveEvent(event);350 m_surface->hoverLeaveEvent(event, devicePixelRatio());
340 } else {351 } else {
341 event->ignore();352 event->ignore();
342 }353 }
@@ -345,7 +356,7 @@
345void MirSurfaceItem::hoverMoveEvent(QHoverEvent *event)356void MirSurfaceItem::hoverMoveEvent(QHoverEvent *event)
346{357{
347 if (m_consumesInput && m_surface && m_surface->live()) {358 if (m_consumesInput && m_surface && m_surface->live()) {
348 m_surface->hoverMoveEvent(event);359 m_surface->hoverMoveEvent(event, devicePixelRatio());
349 } else {360 } else {
350 event->ignore();361 event->ignore();
351 }362 }
@@ -404,7 +415,7 @@
404 touchEvent.updateTouchPointStatesAndType();415 touchEvent.updateTouchPointStatesAndType();
405416
406 m_surface->touchEvent(touchEvent.modifiers, touchEvent.touchPoints,417 m_surface->touchEvent(touchEvent.modifiers, touchEvent.touchPoints,
407 touchEvent.touchPointStates, touchEvent.timestamp);418 touchEvent.touchPointStates, touchEvent.timestamp, devicePixelRatio());
408419
409 *m_lastTouchEvent = touchEvent;420 *m_lastTouchEvent = touchEvent;
410421
@@ -425,7 +436,7 @@
425 endCurrentTouchSequence(timestamp);436 endCurrentTouchSequence(timestamp);
426 }437 }
427438
428 m_surface->touchEvent(mods, touchPoints, touchPointStates, timestamp);439 m_surface->touchEvent(mods, touchPoints, touchPointStates, timestamp, devicePixelRatio());
429440
430 if (!m_lastTouchEvent) {441 if (!m_lastTouchEvent) {
431 m_lastTouchEvent = new TouchEvent;442 m_lastTouchEvent = new TouchEvent;
@@ -537,10 +548,12 @@
537 }548 }
538549
539 // If one dimension is not set, fallback to the current value550 // If one dimension is not set, fallback to the current value
540 int width = m_surfaceWidth > 0 ? m_surfaceWidth : m_surface->size().width();551 const int width = m_surfaceWidth > 0 ? m_surfaceWidth : m_surface->size().width();
541 int height = m_surfaceHeight > 0 ? m_surfaceHeight : m_surface->size().height();552 const int height = m_surfaceHeight > 0 ? m_surfaceHeight : m_surface->size().height();
553 const int widthPx = width * devicePixelRatio();
554 const int heightPx = height * devicePixelRatio();
542555
543 m_surface->resize(width, height);556 m_surface->resize(widthPx, heightPx);
544}557}
545558
546void MirSurfaceItem::updateMirSurfaceVisibility()559void MirSurfaceItem::updateMirSurfaceVisibility()
@@ -565,6 +578,11 @@
565 m_textureProvider = nullptr;578 m_textureProvider = nullptr;
566}579}
567580
581qreal MirSurfaceItem::devicePixelRatio() const
582{
583 return window() ? window()->devicePixelRatio() : 1.0;
584}
585
568void MirSurfaceItem::TouchEvent::updateTouchPointStatesAndType()586void MirSurfaceItem::TouchEvent::updateTouchPointStatesAndType()
569{587{
570 touchPointStates = 0;588 touchPointStates = 0;
@@ -654,7 +672,8 @@
654 Q_EMIT surfaceStateChanged(m_surface->state());672 Q_EMIT surfaceStateChanged(m_surface->state());
655673
656 updateMirSurfaceSize();674 updateMirSurfaceSize();
657 setImplicitSize(m_surface->size().width(), m_surface->size().height());675 setImplicitSize(divideAndRoundUp(m_surface->size().width(), devicePixelRatio()),
676 divideAndRoundUp(m_surface->size().height(), devicePixelRatio()));
658 updateMirSurfaceVisibility();677 updateMirSurfaceVisibility();
659678
660 // Qt::ArrowCursor is the default when no cursor has been explicitly set, so no point forwarding it.679 // Qt::ArrowCursor is the default when no cursor has been explicitly set, so no point forwarding it.
@@ -729,7 +748,8 @@
729748
730void MirSurfaceItem::onActualSurfaceSizeChanged(const QSize &size)749void MirSurfaceItem::onActualSurfaceSizeChanged(const QSize &size)
731{750{
732 setImplicitSize(size.width(), size.height());751 setImplicitSize(divideAndRoundUp(size.width(), devicePixelRatio()),
752 divideAndRoundUp(size.height(), devicePixelRatio()));
733}753}
734754
735int MirSurfaceItem::surfaceHeight() const755int MirSurfaceItem::surfaceHeight() const
736756
=== modified file 'src/modules/Unity/Application/mirsurfaceitem.h'
--- src/modules/Unity/Application/mirsurfaceitem.h 2015-12-10 13:08:43 +0000
+++ src/modules/Unity/Application/mirsurfaceitem.h 2016-01-07 17:03:26 +0000
@@ -123,6 +123,7 @@
123 void onWindowChanged(QQuickWindow *window);123 void onWindowChanged(QQuickWindow *window);
124124
125private:125private:
126 qreal devicePixelRatio() const;
126 void ensureTextureProvider();127 void ensureTextureProvider();
127128
128 bool hasTouchInsideUbuntuKeyboard(const QList<QTouchEvent::TouchPoint> &touchPoints);129 bool hasTouchInsideUbuntuKeyboard(const QList<QTouchEvent::TouchPoint> &touchPoints);
129130
=== modified file 'src/platforms/mirserver/qteventfeeder.cpp'
--- src/platforms/mirserver/qteventfeeder.cpp 2015-12-07 08:06:16 +0000
+++ src/platforms/mirserver/qteventfeeder.cpp 2016-01-07 17:03:26 +0000
@@ -395,6 +395,11 @@
395 return m_screenController->getWindowForPoint(point);395 return m_screenController->getWindowForPoint(point);
396 }396 }
397397
398 qreal devicePixelRatio() override
399 {
400 return qGuiApp->devicePixelRatio(); // FIXME: make per-screen.
401 }
402
398 void registerTouchDevice(QTouchDevice *device) override403 void registerTouchDevice(QTouchDevice *device) override
399 {404 {
400 QWindowSystemInterface::registerTouchDevice(device);405 QWindowSystemInterface::registerTouchDevice(device);
@@ -558,8 +563,9 @@
558563
559 auto modifiers = getQtModifiersFromMir(mir_pointer_event_modifiers(pev));564 auto modifiers = getQtModifiersFromMir(mir_pointer_event_modifiers(pev));
560565
561 auto movement = QPointF(mir_pointer_event_axis_value(pev, mir_pointer_axis_relative_x),566 const qreal dpr = mQtWindowSystem->devicePixelRatio();
562 mir_pointer_event_axis_value(pev, mir_pointer_axis_relative_y));567 auto movement = QPointF(mir_pointer_event_axis_value(pev, mir_pointer_axis_relative_x) / dpr,
568 mir_pointer_event_axis_value(pev, mir_pointer_axis_relative_y) / dpr);
563569
564 switch (action) {570 switch (action) {
565 case mir_pointer_action_button_up:571 case mir_pointer_action_button_up:
@@ -653,6 +659,7 @@
653 // FIXME(loicm) Max pressure is device specific. That one is for the Samsung Galaxy Nexus. That659 // FIXME(loicm) Max pressure is device specific. That one is for the Samsung Galaxy Nexus. That
654 // needs to be fixed as soon as the compat input lib adds query support.660 // needs to be fixed as soon as the compat input lib adds query support.
655 const float kMaxPressure = 1.28;661 const float kMaxPressure = 1.28;
662 const qreal dpr = mQtWindowSystem->devicePixelRatio();
656 const int kPointerCount = mir_touch_event_point_count(tev);663 const int kPointerCount = mir_touch_event_point_count(tev);
657 QList<QWindowSystemInterface::TouchPoint> touchPoints;664 QList<QWindowSystemInterface::TouchPoint> touchPoints;
658 QWindow *window = nullptr;665 QWindow *window = nullptr;
@@ -674,10 +681,10 @@
674 for (int i = 0; i < kPointerCount; ++i) {681 for (int i = 0; i < kPointerCount; ++i) {
675 QWindowSystemInterface::TouchPoint touchPoint;682 QWindowSystemInterface::TouchPoint touchPoint;
676683
677 const float kX = mir_touch_event_axis_value(tev, i, mir_touch_axis_x);684 const float kX = mir_touch_event_axis_value(tev, i, mir_touch_axis_x) / dpr;
678 const float kY = mir_touch_event_axis_value(tev, i, mir_touch_axis_y);685 const float kY = mir_touch_event_axis_value(tev, i, mir_touch_axis_y) / dpr;
679 const float kW = mir_touch_event_axis_value(tev, i, mir_touch_axis_touch_major);686 const float kW = mir_touch_event_axis_value(tev, i, mir_touch_axis_touch_major) / dpr;
680 const float kH = mir_touch_event_axis_value(tev, i, mir_touch_axis_touch_minor);687 const float kH = mir_touch_event_axis_value(tev, i, mir_touch_axis_touch_minor) / dpr;
681 const float kP = mir_touch_event_axis_value(tev, i, mir_touch_axis_pressure);688 const float kP = mir_touch_event_axis_value(tev, i, mir_touch_axis_pressure);
682 touchPoint.id = mir_touch_event_id(tev, i);689 touchPoint.id = mir_touch_event_id(tev, i);
683690
684691
=== modified file 'src/platforms/mirserver/qteventfeeder.h'
--- src/platforms/mirserver/qteventfeeder.h 2015-11-19 14:17:54 +0000
+++ src/platforms/mirserver/qteventfeeder.h 2016-01-07 17:03:26 +0000
@@ -39,6 +39,7 @@
39 virtual ~QtWindowSystemInterface() {}39 virtual ~QtWindowSystemInterface() {}
40 virtual void setScreenController(const QSharedPointer<ScreenController> &sc) = 0;40 virtual void setScreenController(const QSharedPointer<ScreenController> &sc) = 0;
41 virtual QWindow* getWindowForTouchPoint(const QPoint &point) = 0;41 virtual QWindow* getWindowForTouchPoint(const QPoint &point) = 0;
42 virtual qreal devicePixelRatio() { return 1.0; }
42 virtual QWindow* focusedWindow() = 0;43 virtual QWindow* focusedWindow() = 0;
43 virtual void registerTouchDevice(QTouchDevice *device) = 0;44 virtual void registerTouchDevice(QTouchDevice *device) = 0;
44 virtual void handleExtendedKeyEvent(QWindow *window, ulong timestamp, QEvent::Type type, int key,45 virtual void handleExtendedKeyEvent(QWindow *window, ulong timestamp, QEvent::Type type, int key,
4546
=== modified file 'src/platforms/mirserver/screen.cpp'
--- src/platforms/mirserver/screen.cpp 2015-10-14 22:59:04 +0000
+++ src/platforms/mirserver/screen.cpp 2016-01-07 17:03:26 +0000
@@ -44,6 +44,7 @@
44 char *c = (char*)&i;44 char *c = (char*)&i;
45 return *c == 1;45 return *c == 1;
46}46}
47
47static mir::renderer::gl::RenderTarget *as_render_target(48static mir::renderer::gl::RenderTarget *as_render_target(
48 mir::graphics::DisplayBuffer *displayBuffer)49 mir::graphics::DisplayBuffer *displayBuffer)
49{50{
@@ -56,6 +57,17 @@
56 return render_target;57 return render_target;
57}58}
5859
60qreal readDevicePixelRatioEnvVar()
61{
62 bool ok;
63 const int dpr = qgetenv("QT_DEVICE_PIXEL_RATIO").toInt(&ok);
64 if (ok && dpr > 0) {
65 return (qreal) dpr;
66 } else {
67 return 1.0; // fallback value
68 }
69}
70
59enum QImage::Format qImageFormatFromMirPixelFormat(MirPixelFormat mirPixelFormat) {71enum QImage::Format qImageFormatFromMirPixelFormat(MirPixelFormat mirPixelFormat) {
60 switch (mirPixelFormat) {72 switch (mirPixelFormat) {
61 case mir_pixel_format_abgr_8888:73 case mir_pixel_format_abgr_8888:
@@ -123,6 +135,9 @@
123 , m_screenWindow(nullptr)135 , m_screenWindow(nullptr)
124 , m_unityScreen(nullptr)136 , m_unityScreen(nullptr)
125{137{
138 // Get screen resolution and properties.
139 m_devicePixelRatio = readDevicePixelRatioEnvVar();
140
126 setMirDisplayConfiguration(screen);141 setMirDisplayConfiguration(screen);
127142
128 // Set the default orientation based on the initial screen dimmensions.143 // Set the default orientation based on the initial screen dimmensions.
@@ -197,14 +212,20 @@
197 m_powerMode = screen.power_mode;212 m_powerMode = screen.power_mode;
198213
199 QRect oldGeometry = m_geometry;214 QRect oldGeometry = m_geometry;
200 // Position of screen in virtual desktop coordinate space215 // Position of screen in virtual desktop coordinate space (physical pixels)
201 m_geometry.setTop(screen.top_left.y.as_int());216 m_nativeGeometry.setTop(screen.top_left.y.as_int());
202 m_geometry.setLeft(screen.top_left.x.as_int());217 m_nativeGeometry.setLeft(screen.top_left.x.as_int());
203218
204 // Mode = current resolution & refresh rate219 // Mode = current resolution & refresh rate
205 mir::graphics::DisplayConfigurationMode mode = screen.modes.at(screen.current_mode_index);220 mir::graphics::DisplayConfigurationMode mode = screen.modes.at(screen.current_mode_index);
206 m_geometry.setWidth(mode.size.width.as_int());221 m_nativeGeometry.setWidth(mode.size.width.as_int());
207 m_geometry.setHeight(mode.size.height.as_int());222 m_nativeGeometry.setHeight(mode.size.height.as_int());
223
224 // Geometry is in terms of device-independent pixels
225 m_geometry.setTop(m_nativeGeometry.top() / m_devicePixelRatio);
226 m_geometry.setLeft(m_nativeGeometry.left() / m_devicePixelRatio);
227 m_geometry.setWidth(m_nativeGeometry.width() / m_devicePixelRatio);
228 m_geometry.setHeight(m_nativeGeometry.height() / m_devicePixelRatio);
208229
209 // DPI - unnecessary to calculate, default implementation in QPlatformScreen is sufficient230 // DPI - unnecessary to calculate, default implementation in QPlatformScreen is sufficient
210231
211232
=== modified file 'src/platforms/mirserver/screen.h'
--- src/platforms/mirserver/screen.h 2015-10-14 22:59:04 +0000
+++ src/platforms/mirserver/screen.h 2016-01-07 17:03:26 +0000
@@ -44,13 +44,15 @@
44 ~Screen();44 ~Screen();
4545
46 // QPlatformScreen methods.46 // QPlatformScreen methods.
47 QRect geometry() const override { return m_geometry; }47 QRect geometry() const override { return m_geometry; } // in device-independent pixels
48 QRect nativeGeometry() const { return m_nativeGeometry; } // in physical pixels
48 int depth() const override { return m_depth; }49 int depth() const override { return m_depth; }
49 QImage::Format format() const override { return m_format; }50 QImage::Format format() const override { return m_format; }
50 QSizeF physicalSize() const override { return m_physicalSize; }51 QSizeF physicalSize() const override { return m_physicalSize; }
51 qreal refreshRate() const override { return m_refreshRate; }52 qreal refreshRate() const override { return m_refreshRate; }
52 Qt::ScreenOrientation nativeOrientation() const override { return m_nativeOrientation; }53 Qt::ScreenOrientation nativeOrientation() const override { return m_nativeOrientation; }
53 Qt::ScreenOrientation orientation() const override { return m_currentOrientation; }54 Qt::ScreenOrientation orientation() const override { return m_currentOrientation; }
55 qreal devicePixelRatio() const override { return m_devicePixelRatio; }
54 QPlatformCursor *cursor() const override;56 QPlatformCursor *cursor() const override;
5557
56 void toggleSensors(const bool enable) const;58 void toggleSensors(const bool enable) const;
@@ -79,11 +81,12 @@
79 void doneCurrent();81 void doneCurrent();
8082
81private:83private:
82 QRect m_geometry;84 QRect m_geometry, m_nativeGeometry;
83 int m_depth;85 int m_depth;
84 QImage::Format m_format;86 QImage::Format m_format;
85 QSizeF m_physicalSize;87 QSizeF m_physicalSize;
86 qreal m_refreshRate;88 qreal m_refreshRate;
89 qreal m_devicePixelRatio;
8790
88 mir::renderer::gl::RenderTarget *m_renderTarget;91 mir::renderer::gl::RenderTarget *m_renderTarget;
89 mir::graphics::DisplaySyncGroup *m_displayGroup;92 mir::graphics::DisplaySyncGroup *m_displayGroup;
9093
=== modified file 'src/platforms/mirserver/screencontroller.cpp'
--- src/platforms/mirserver/screencontroller.cpp 2015-10-21 11:34:56 +0000
+++ src/platforms/mirserver/screencontroller.cpp 2016-01-07 17:03:26 +0000
@@ -163,7 +163,7 @@
163 buffer.view_area().size.height.as_int());163 buffer.view_area().size.height.as_int());
164164
165 for (auto screen : m_screenList) {165 for (auto screen : m_screenList) {
166 if (dbGeom == screen->geometry()) {166 if (dbGeom == screen->nativeGeometry()) {
167 screen->setMirDisplayBuffer(&buffer, &group);167 screen->setMirDisplayBuffer(&buffer, &group);
168 break;168 break;
169 }169 }
@@ -174,7 +174,7 @@
174 qCDebug(QTMIR_SCREENS) << "=======================================";174 qCDebug(QTMIR_SCREENS) << "=======================================";
175 for (auto screen: m_screenList) {175 for (auto screen: m_screenList) {
176 qCDebug(QTMIR_SCREENS) << screen << "- id:" << screen->m_outputId.as_value()176 qCDebug(QTMIR_SCREENS) << screen << "- id:" << screen->m_outputId.as_value()
177 << "geometry:" << screen->geometry()177 << "geometry (px):" << screen->nativeGeometry()
178 << "window:" << screen->window()178 << "window:" << screen->window()
179 << "type" << static_cast<int>(screen->outputType());179 << "type" << static_cast<int>(screen->outputType());
180 }180 }
181181
=== modified file 'src/platforms/mirserver/screenwindow.cpp'
--- src/platforms/mirserver/screenwindow.cpp 2015-10-15 07:05:16 +0000
+++ src/platforms/mirserver/screenwindow.cpp 2016-01-07 17:03:26 +0000
@@ -60,6 +60,11 @@
60 window->setSurfaceType(QSurface::OpenGLSurface);60 window->setSurfaceType(QSurface::OpenGLSurface);
61}61}
6262
63qreal ScreenWindow::devicePixelRatio() const
64{
65 return screen()->devicePixelRatio();
66}
67
63ScreenWindow::~ScreenWindow()68ScreenWindow::~ScreenWindow()
64{69{
65 qCDebug(QTMIR_SCREENS) << "Destroying ScreenWindow" << this;70 qCDebug(QTMIR_SCREENS) << "Destroying ScreenWindow" << this;
6671
=== modified file 'src/platforms/mirserver/screenwindow.h'
--- src/platforms/mirserver/screenwindow.h 2015-10-14 22:59:04 +0000
+++ src/platforms/mirserver/screenwindow.h 2016-01-07 17:03:26 +0000
@@ -29,6 +29,8 @@
29 explicit ScreenWindow(QWindow *window);29 explicit ScreenWindow(QWindow *window);
30 virtual ~ScreenWindow();30 virtual ~ScreenWindow();
3131
32 qreal devicePixelRatio() const override;
33
32 bool isExposed() const override;34 bool isExposed() const override;
33 void setExposed(const bool exposed);35 void setExposed(const bool exposed);
3436
3537
=== modified file 'tests/modules/common/fake_mirsurface.h'
--- tests/modules/common/fake_mirsurface.h 2015-12-10 13:08:43 +0000
+++ tests/modules/common/fake_mirsurface.h 2016-01-07 17:03:26 +0000
@@ -152,13 +152,13 @@
152152
153 void setFocus(bool focus) override { m_focused = focus; }153 void setFocus(bool focus) override { m_focused = focus; }
154154
155 void mousePressEvent(QMouseEvent *) override {}155 void mousePressEvent(QMouseEvent *, qreal) override {}
156 void mouseMoveEvent(QMouseEvent *) override {}156 void mouseMoveEvent(QMouseEvent *, qreal) override {}
157 void mouseReleaseEvent(QMouseEvent *) override {}157 void mouseReleaseEvent(QMouseEvent *, qreal) override {}
158 void hoverEnterEvent(QHoverEvent *) override {}158 void hoverEnterEvent(QHoverEvent *, qreal) override {}
159 void hoverLeaveEvent(QHoverEvent *) override {}159 void hoverLeaveEvent(QHoverEvent *, qreal) override {}
160 void hoverMoveEvent(QHoverEvent *) override {}160 void hoverMoveEvent(QHoverEvent *, qreal) override {}
161 void wheelEvent(QWheelEvent *) override {}161 void wheelEvent(QWheelEvent *, qreal) override {}
162162
163 void keyPressEvent(QKeyEvent *) override {}163 void keyPressEvent(QKeyEvent *) override {}
164 void keyReleaseEvent(QKeyEvent *) override {}164 void keyReleaseEvent(QKeyEvent *) override {}
@@ -166,7 +166,7 @@
166 void touchEvent(Qt::KeyboardModifiers mods,166 void touchEvent(Qt::KeyboardModifiers mods,
167 const QList<QTouchEvent::TouchPoint> &points,167 const QList<QTouchEvent::TouchPoint> &points,
168 Qt::TouchPointStates states,168 Qt::TouchPointStates states,
169 ulong timestamp) override {169 ulong timestamp, qreal) override {
170 m_touchesReceived.append(TouchEvent(mods, points, states, timestamp));170 m_touchesReceived.append(TouchEvent(mods, points, states, timestamp));
171 }171 }
172172

Subscribers

People subscribed via source and target branches