1 /*************************************************************************************
2  *  Copyright 2014 Sebastian Kügler <sebas@kde.org>                                  *
3  *                                                                                   *
4  *  This library is free software; you can redistribute it and/or                    *
5  *  modify it under the terms of the GNU Lesser General Public                       *
6  *  License as published by the Free Software Foundation; either                     *
7  *  version 2.1 of the License, or (at your option) any later version.               *
8  *                                                                                   *
9  *  This library is distributed in the hope that it will be useful,                  *
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of                   *
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                *
12  *  Lesser General Public License for more details.                                  *
13  *                                                                                   *
14  *  You should have received a copy of the GNU Lesser General Public                 *
15  *  License along with this library; if not, write to the Free Software              *
16  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA       *
17  *************************************************************************************/
18 #include "qscreenscreen.h"
19 
20 #include "qscreenbackend.h"
21 #include "qscreenoutput.h"
22 
23 #include <configmonitor.h>
24 #include <mode.h>
25 
26 #include <QGuiApplication>
27 #include <QScreen>
28 
29 using namespace Disman;
30 
QScreenScreen(QScreenConfig * config)31 QScreenScreen::QScreenScreen(QScreenConfig* config)
32     : QObject(config)
33 {
34 }
35 
~QScreenScreen()36 QScreenScreen::~QScreenScreen()
37 {
38 }
39 
toDismanScreen() const40 ScreenPtr QScreenScreen::toDismanScreen() const
41 {
42     Disman::ScreenPtr dismanScreen(new Disman::Screen);
43     updateDismanScreen(dismanScreen);
44     return dismanScreen;
45 }
46 
updateDismanScreen(ScreenPtr & screen) const47 void QScreenScreen::updateDismanScreen(ScreenPtr& screen) const
48 {
49     if (!screen) {
50         return;
51     }
52 
53     auto primary = QGuiApplication::primaryScreen();
54 
55     if (primary) {
56         QSize _s = primary->availableVirtualGeometry().size();
57 
58         screen->set_current_size(_s);
59         screen->set_id(1);
60         screen->set_max_size(_s);
61         screen->set_min_size(_s);
62         screen->set_current_size(_s);
63         screen->set_max_outputs_count(QGuiApplication::screens().count());
64     }
65 }
66