diff --git a/backends/kwayland/waylandscreen.cpp b/backends/kwayland/waylandscreen.cpp index 9e64bee..c8f2ac4 100644 --- a/backends/kwayland/waylandscreen.cpp +++ b/backends/kwayland/waylandscreen.cpp @@ -1,65 +1,66 @@ /************************************************************************************* * Copyright 2014-2015 Sebastian Kügler * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * * License as published by the Free Software Foundation; either * * version 2.1 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *************************************************************************************/ +#include "waylandscreen.h" #include "waylandconfig.h" -#include "waylandscreen.h" #include "waylandoutput.h" #include - using namespace KScreen; WaylandScreen::WaylandScreen(WaylandConfig *config) : QObject(config) , m_outputCount(0) { } -WaylandScreen::~WaylandScreen() -{ -} - ScreenPtr WaylandScreen::toKScreenScreen(KScreen::ConfigPtr &parent) const { Q_UNUSED(parent); + KScreen::ScreenPtr kscreenScreen(new KScreen::Screen); updateKScreenScreen(kscreenScreen); return kscreenScreen; } void WaylandScreen::setOutputs(const QList &outputs) { m_outputCount = outputs.count(); + QRect r; - Q_FOREACH (auto o, outputs) { - if (o->enabled()) { - r |= QRect(o->outputDevice()->globalPosition(), o->outputDevice()->pixelSize() / o->outputDevice()->scale()); + for (const auto *out : outputs) { + if (out->enabled()) { + const auto *dev = out->outputDevice(); + r |= QRect(dev->globalPosition(), dev->pixelSize() / dev->scale()); } } m_size = r.size(); } void WaylandScreen::updateKScreenScreen(KScreen::ScreenPtr &screen) const { screen->setMinSize(QSize(0, 0)); - screen->setMaxSize(QSize(64000, 64000)); // 64000^2 should be enough for everyone. + + // 64000^2 should be enough for everyone. + screen->setMaxSize(QSize(64000, 64000)); + screen->setCurrentSize(m_size); screen->setMaxActiveOutputsCount(m_outputCount); } diff --git a/backends/kwayland/waylandscreen.h b/backends/kwayland/waylandscreen.h index 33ce925..a841f7e 100644 --- a/backends/kwayland/waylandscreen.h +++ b/backends/kwayland/waylandscreen.h @@ -1,56 +1,52 @@ /************************************************************************************* * Copyright 2014-2015 Sebastian Kügler * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * * License as published by the Free Software Foundation; either * * version 2.1 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *************************************************************************************/ - -#ifndef KSCREEN_WAYLAND_SCREEN_H -#define KSCREEN_WAYLAND_SCREEN_H +#pragma once #include "abstractbackend.h" #include "config.h" #include "screen.h" #include #include namespace KScreen { class WaylandConfig; class WaylandOutput; class WaylandScreen : public QObject { Q_OBJECT public: explicit WaylandScreen(WaylandConfig *config); - ~WaylandScreen() override; + ~WaylandScreen() override = default; KScreen::ScreenPtr toKScreenScreen(KScreen::ConfigPtr &parent) const; void updateKScreenScreen(KScreen::ScreenPtr &screen) const; void setOutputs(const QList &outputs); void setSize(const QSize &size); void setOutputCount(int count); private: QSize m_size; int m_outputCount; }; -} // namespace - -#endif // KSCREEN_WAYLAND_SCREEN_H +}