[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kwin/scaling_merged] /: Set wayland output scale
From:       David Edmundson <kde () davidedmundson ! co ! uk>
Date:       2016-11-24 20:48:39
Message-ID: E1cA0wh-0000TY-JP () code ! kde ! org
[Download RAW message or body]

Git commit 8ed486718633fa03f8eaeb83709ece6118709278 by David Edmundson.
Committed on 23/11/2016 at 16:58.
Pushed by davidedmundson into branch 'scaling_merged'.

Set wayland output scale

Summary:
Provides a virtual method in Screens where backends can supply the scale
of each screen, this is then set on each output.

For the X windowed backend this value is taken from a command line
parameter.

Test Plan:
Ran windowed mode with --scale 1 and 2
then kate --platform=wayland from another screen.
On the latter case UI elements were scaled up correctly

Reviewers: #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D3159

M  +16   -0    main_wayland.cpp
M  +5    -0    platform.cpp
M  +15   -0    platform.h
M  +7    -0    plugins/platforms/x11/windowed/x11windowed_backend.cpp
M  +1    -0    plugins/platforms/x11/windowed/x11windowed_backend.h
M  +16   -0    screens.cpp
M  +7    -0    screens.h
M  +1    -0    wayland_server.cpp

https://commits.kde.org/kwin/8ed486718633fa03f8eaeb83709ece6118709278

diff --git a/main_wayland.cpp b/main_wayland.cpp
index 364f4ca..9534c03 100644
--- a/main_wayland.cpp
+++ b/main_wayland.cpp
@@ -526,6 +526,12 @@ int main(int argc, char * argv[])
                                     i18n("The height for windowed mode. Default \
height is 768."),  QStringLiteral("height"));
     heightOption.setDefaultValue(QString::number(768));
+
+    QCommandLineOption scaleOption(QStringLiteral("scale"),
+                                    i18n("The scale for windowed mode. Default value \
is 1."), +                                    QStringLiteral("scale"));
+    scaleOption.setDefaultValue(QString::number(1));
+
     QCommandLineOption outputCountOption(QStringLiteral("output-count"),
                                     i18n("The number of windows to open as outputs \
in windowed mode. Default value is 1"),  QStringLiteral("height"));
@@ -554,6 +560,7 @@ int main(int argc, char * argv[])
     if (hasSizeOption) {
         parser.addOption(widthOption);
         parser.addOption(heightOption);
+        parser.addOption(scaleOption);
     }
     if (hasOutputCountOption) {
         parser.addOption(outputCountOption);
@@ -632,6 +639,7 @@ int main(int argc, char * argv[])
     QSize initialWindowSize;
     QByteArray deviceIdentifier;
     int outputCount = 1;
+    qreal outputScale = 1;
 
 #if HAVE_DRM
     if (hasDrmOption && parser.isSet(drmOption)) {
@@ -651,6 +659,13 @@ int main(int argc, char * argv[])
             std::cerr << "FATAL ERROR incorrect value for height" << std::endl;
             return 1;
         }
+        const qreal scale = parser.value(scaleOption).toDouble(&ok);
+        if (!ok || scale < 1) {
+            std::cerr << "FATAL ERROR incorrect value for scale" << std::endl;
+            return 1;
+        }
+
+        outputScale = scale;
         initialWindowSize = QSize(width, height);
     }
 
@@ -732,6 +747,7 @@ int main(int argc, char * argv[])
     if (initialWindowSize.isValid()) {
         a.platform()->setInitialWindowSize(initialWindowSize);
     }
+    a.platform()->setInitialOutputScale(outputScale);
     a.platform()->setInitialOutputCount(outputCount);
 
     QObject::connect(&a, &KWin::Application::workspaceCreated, server, \
                &KWin::WaylandServer::initWorkspace);
diff --git a/platform.cpp b/platform.cpp
index 1012440..ae60194 100644
--- a/platform.cpp
+++ b/platform.cpp
@@ -338,6 +338,11 @@ QVector<QRect> Platform::screenGeometries() const
     return QVector<QRect>({QRect(QPoint(0, 0), screenSize())});
 }
 
+QVector<qreal> Platform::screenScales() const
+{
+    return QVector<qreal>({1});
+}
+
 bool Platform::requiresCompositing() const
 {
     return true;
diff --git a/platform.h b/platform.h
index 7badf83..5e52849 100644
--- a/platform.h
+++ b/platform.h
@@ -101,6 +101,14 @@ public:
      * Base implementation returns one QRect positioned at 0/0 with screenSize() as \
                size.
      **/
     virtual QVector<QRect> screenGeometries() const;
+
+    /**
+     * Implementing subclasses should provide all geometries in case the backend \
represents +     * a basic screen and uses the BasicScreens.
+     *
+     * Base implementation returns a screen with a scale of 1.
+     **/
+    virtual QVector<qreal> screenScales() const;
     /**
      * Implement this method to receive configuration change requests through \
                KWayland's
      * OutputManagement interface.
@@ -231,6 +239,12 @@ public:
     void setInitialOutputCount(int count) {
         m_initialOutputCount = count;
     }
+    qreal initialOutputScale() const {
+        return m_initialOutputScale;
+    }
+    void setInitialOutputScale(qreal scale) {
+        m_initialOutputScale = scale;
+    }
 
 public Q_SLOTS:
     void pointerMotion(const QPointF &position, quint32 time);
@@ -313,6 +327,7 @@ private:
     bool m_pointerWarping = false;
     bool m_outputsEnabled = true;
     int m_initialOutputCount = 1;
+    qreal m_initialOutputScale = 1;
     EGLDisplay m_eglDisplay;
     int m_hideCursorCounter = 0;
 };
diff --git a/plugins/platforms/x11/windowed/x11windowed_backend.cpp \
b/plugins/platforms/x11/windowed/x11windowed_backend.cpp index 3250c44..75f2d1c \
                100644
--- a/plugins/platforms/x11/windowed/x11windowed_backend.cpp
+++ b/plugins/platforms/x11/windowed/x11windowed_backend.cpp
@@ -472,4 +472,11 @@ QVector<QRect> X11WindowedBackend::screenGeometries() const
     return ret;
 }
 
+QVector<qreal> X11WindowedBackend::screenScales() const
+{
+    QVector<qreal> ret;
+    ret.fill(initialOutputScale(), m_windows.count());
+    return ret;
+}
+
 }
diff --git a/plugins/platforms/x11/windowed/x11windowed_backend.h \
b/plugins/platforms/x11/windowed/x11windowed_backend.h index 25121f9..17ada57 100644
--- a/plugins/platforms/x11/windowed/x11windowed_backend.h
+++ b/plugins/platforms/x11/windowed/x11windowed_backend.h
@@ -47,6 +47,7 @@ public:
     virtual ~X11WindowedBackend();
     void init() override;
     QVector<QRect> screenGeometries() const override;
+    QVector<qreal> screenScales() const override;
 
     xcb_connection_t *connection() const {
         return m_connection;
diff --git a/screens.cpp b/screens.cpp
index a08245e..8f5b478 100644
--- a/screens.cpp
+++ b/screens.cpp
@@ -91,6 +91,13 @@ float Screens::refreshRate(int screen) const
     return 60.0f;
 }
 
+qreal Screens::scale(int screen) const
+{
+    Q_UNUSED(screen)
+    qCWarning(KWIN_CORE, "%s::scale(qreal screen) is a stub, please reimplement \
it!", metaObject()->className()); +    return 1;
+}
+
 void Screens::reconfigure()
 {
     if (!m_config) {
@@ -213,9 +220,18 @@ QSize BasicScreens::size(int screen) const
     return QSize();
 }
 
+qreal BasicScreens::scale(int screen) const
+{
+    if (screen < m_scales.count()) {
+        return m_scales.at(screen);
+    }
+    return 1;
+}
+
 void BasicScreens::updateCount()
 {
     m_geometries = m_backend->screenGeometries();
+    m_scales = m_backend->screenScales();
     setCount(m_geometries.count());
 }
 
diff --git a/screens.h b/screens.h
index 1fb983d..1e4b798 100644
--- a/screens.h
+++ b/screens.h
@@ -86,6 +86,11 @@ public:
      * @see size()
      **/
     virtual QSize size(int screen) const = 0;
+
+    /*
+     * The output scale for this display, for use by high DPI displays
+     */
+    virtual qreal scale(int screen) const;
     /**
      * The bounding size of all screens combined. Overlapping areas
      * are not counted multiple times.
@@ -164,11 +169,13 @@ public:
     QRect geometry(int screen) const override;
     int number(const QPoint &pos) const override;
     QSize size(int screen) const override;
+    qreal scale(int screen) const override;
     void updateCount() override;
 
 private:
     Platform *m_backend;
     QVector<QRect> m_geometries;
+    QVector<qreal> m_scales;
 };
 
 inline
diff --git a/wayland_server.cpp b/wayland_server.cpp
index 53771ee..3743fe0 100644
--- a/wayland_server.cpp
+++ b/wayland_server.cpp
@@ -352,6 +352,7 @@ void WaylandServer::syncOutputsToWayland()
     Q_ASSERT(s);
     for (int i = 0; i < s->count(); ++i) {
         OutputInterface *output = m_display->createOutput(m_display);
+        output->setScale(s->scale(i));
         const QRect &geo = s->geometry(i);
         output->setGlobalPosition(geo.topLeft());
         output->setPhysicalSize(geo.size() / 3.8);


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic