2 * Copyright 2008 Aike J Sommer <dev@aikesommer.name>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2,
7 * or (at your option) any later version.
9 * This program 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
12 * GNU General Public License for more details
14 * You should have received a copy of the GNU Library General Public
15 * License along with this program; if not, write to the
16 * Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 #include "dbusapi_screens.h"
22 #include "kephal/screens.h"
23 #include "kephal/outputs.h"
24 #include "screensadaptor.h"
30 using namespace Kephal
;
32 DBusAPIScreens::DBusAPIScreens(QObject
* parent
)
35 new ScreensAdaptor(this);
36 QDBusConnection dbus
= QDBusConnection::sessionBus();
39 result
= dbus
.registerObject("/Screens", this);
40 qDebug() << "screens registered on the bus:" << result
;
42 connect(Screens::self(), SIGNAL(screenResized(Kephal::Screen
*, QSize
, QSize
)), this, SLOT(screenResized(Kephal::Screen
*, QSize
, QSize
)));
43 connect(Screens::self(), SIGNAL(screenMoved(Kephal::Screen
*, QPoint
, QPoint
)), this, SLOT(screenMoved(Kephal::Screen
*, QPoint
, QPoint
)));
44 connect(Screens::self(), SIGNAL(screenAdded(Kephal::Screen
*)), this, SLOT(screenAdded(Kephal::Screen
*)));
45 connect(Screens::self(), SIGNAL(screenRemoved(int)), this, SLOT(screenRemovedSlot(int)));
48 void DBusAPIScreens::screenResized(Kephal::Screen
* s
, QSize oldSize
, QSize newSize
) {
51 emit
screenResized(s
->id());
54 void DBusAPIScreens::screenMoved(Kephal::Screen
* s
, QPoint oldPosition
, QPoint newPosition
) {
57 emit
screenMoved(s
->id());
60 void DBusAPIScreens::screenAdded(Kephal::Screen
* s
) {
61 emit
screenAdded(s
->id());
64 void DBusAPIScreens::screenRemovedSlot(int id
) {
65 emit
screenRemoved(id
);
68 QSize
DBusAPIScreens::size(int id
)
70 Screen
* s
= Screens::self()->screen(id
);
71 return s
? s
->size() : QSize(0,0);
74 QPoint
DBusAPIScreens::position(int id
)
76 Screen
* s
= Screens::self()->screen(id
);
77 return s
? s
->position() : QPoint(0,0);
80 int DBusAPIScreens::numScreens()
82 QList
<Screen
*> screens
= Screens::self()->screens();
83 return screens
.size();
86 int DBusAPIScreens::id(int index
)
88 QList
<Screen
*> screens
= Screens::self()->screens();
89 if (index
< screens
.size()) {
90 return screens
[index
]->id();
95 int DBusAPIScreens::primaryScreen()
97 Screen
* s
= Screens::self()->primaryScreen();
98 return s
? s
->id() : 0;
101 QStringList
DBusAPIScreens::outputs(int id
) {
102 Screen
* s
= Screens::self()->screen(id
);
105 foreach (Output
* output
, s
->outputs()) {
106 result
<< output
->id();
113 #include "dbusapi_screens.moc"