Commit 6bfa931f authored by Roman Gilg's avatar Roman Gilg
Browse files

Associate output transforms and orientations

Summary:
We use internally Qt:ScreenOrientation for representing output transforms.

This is not ideal since the values do not map directly to Wayland transform
values, but we can make it work by using OR combinations of
Qt:ScreenOrientations.

Do this for now and see if we should not better introduce an internal enum
mapped directly.

Additionally the OR combinations need to be handled in the drm backend at
various places accordingly as well (see TODOs).

Test Plan: Compiles

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Maniphest Tasks: T11670

Differential Revision: https://phabricator.kde.org/D25505
parent 523967b3
......@@ -103,11 +103,6 @@ QSize AbstractOutput::physicalSize() const
return QSize();
}
Qt::ScreenOrientation AbstractOutput::orientation() const
{
return Qt::PrimaryOrientation;
}
int AbstractOutput::gammaRampSize() const
{
return 0;
......
......@@ -161,13 +161,6 @@ public:
*/
virtual QSize physicalSize() const;
/**
* Returns the orientation of this output.
*
* Default implementation returns Qt::PrimaryOrientation.
*/
virtual Qt::ScreenOrientation orientation() const;
/**
* Returns the size of the gamma lookup table.
*
......
......@@ -308,4 +308,29 @@ QSize AbstractWaylandOutput::orientateSize(const QSize &size) const
return size;
}
Qt::ScreenOrientations AbstractWaylandOutput::orientation() const
{
const DeviceInterface::Transform transform = m_waylandOutputDevice->transform();
switch (transform) {
case DeviceInterface::Transform::Rotated90:
return Qt::PortraitOrientation;
case DeviceInterface::Transform::Rotated180:
return Qt::InvertedLandscapeOrientation;
case DeviceInterface::Transform::Rotated270:
return Qt::InvertedPortraitOrientation;
case DeviceInterface::Transform::Flipped:
return Qt::LandscapeOrientation | Qt::InvertedPortraitOrientation;
case DeviceInterface::Transform::Flipped90:
return Qt::PortraitOrientation | Qt::InvertedLandscapeOrientation;
case DeviceInterface::Transform::Flipped180:
return Qt::InvertedLandscapeOrientation | Qt::InvertedPortraitOrientation;
case DeviceInterface::Transform::Flipped270:
return Qt::PortraitOrientation | Qt::InvertedLandscapeOrientation |
Qt::InvertedPortraitOrientation;
default:
return Qt::LandscapeOrientation;
}
}
}
......@@ -144,6 +144,17 @@ protected:
void setTransform(KWayland::Server::OutputDeviceInterface::Transform transform);
QSize orientateSize(const QSize &size) const;
/**
* Returns the orientation of this output.
*
* - Flipped along the vertical axis is landscape + inv. portrait.
* - Rotated 90° and flipped along the horizontal axis is portrait + inv. landscape
* - Rotated 180° and flipped along the vertical axis is inv. landscape + inv. portrait
* - Rotated 270° and flipped along the horizontal axis is inv. portrait + inv. landscape +
* portrait
*/
Qt::ScreenOrientations orientation() const;
private:
void createWaylandOutput();
void createXdgOutput();
......
......@@ -95,14 +95,6 @@ float OutputScreens::refreshRate(int screen) const
return 60.0;
}
Qt::ScreenOrientation OutputScreens::orientation(int screen) const
{
if (AbstractOutput *output = findOutput(screen)) {
return output->orientation();
}
return Qt::PrimaryOrientation;
}
void OutputScreens::updateCount()
{
setCount(m_platform->enabledOutputs().size());
......
......@@ -45,7 +45,6 @@ public:
QSize size(int screen) const override;
qreal scale(int screen) const override;
float refreshRate(int screen) const override;
Qt::ScreenOrientation orientation(int screen) const override;
void updateCount() override;
int number(const QPoint &pos) const override;
......
......@@ -128,7 +128,8 @@ bool DrmOutput::showCursor()
return ret;
}
int orientationToRotation(Qt::ScreenOrientation orientation)
// TODO: Respect OR combinations of values
int orientationToRotation(Qt::ScreenOrientations orientation)
{
switch (orientation) {
case Qt::PrimaryOrientation:
......@@ -182,6 +183,8 @@ void DrmOutput::moveCursor(const QPoint &globalPos)
const QMatrix4x4 hotspotMatrix = matrixDisplay(m_backend->softwareCursor().size());
QPoint p = globalPos - AbstractWaylandOutput::globalPos();
// TODO: Respect OR combinations of values
switch (orientation()) {
case Qt::PrimaryOrientation:
case Qt::LandscapeOrientation:
......
......@@ -150,7 +150,7 @@ private:
bool m_modesetRequested = true;
struct {
Qt::ScreenOrientation orientation;
Qt::ScreenOrientations orientation;
drmModeModeInfo mode;
DrmPlane::Transformations planeTransformations;
QPoint globalPos;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment