Changeset View
Changeset View
Standalone View
Standalone View
shell/othershellhelper.cpp
- This file was added.
1 | #include "othershellhelper.h" | ||||
---|---|---|---|---|---|
2 | #include "shellcorona.h" | ||||
3 | | ||||
4 | #include <QDBusConnection> | ||||
5 | #include <QDebug> | ||||
6 | | ||||
7 | OtherShellHelper::OtherShellHelper(ShellCorona *plasmashellCorona) : QObject(qobject_cast<QObject *>(plasmashellCorona)), | ||||
8 | m_plasmashellCorona(plasmashellCorona) | ||||
davidedmundson: Ideally we want the ClassName to focus on what something does, rather than what the usage… | |||||
9 | { | ||||
10 | QDBusConnection dbus = QDBusConnection::sessionBus(); | ||||
11 | dbus.registerObject("/otherShellHelper", this, QDBusConnection::ExportAllSlots|QDBusConnection::ExportScriptableSignals); | ||||
12 | | ||||
13 | connect(m_plasmashellCorona, &ShellCorona::availableScreenRectChanged, this, &OtherShellHelper::plasmashellViewsChanged); | ||||
14 | connect(m_plasmashellCorona, &ShellCorona::availableScreenRegionChanged, this, &OtherShellHelper::plasmashellViewsChanged); | ||||
15 | | ||||
16 | connect(this, &OtherShellHelper::availableScreenRectChanged, m_plasmashellCorona, &ShellCorona::availableScreenRectChanged); | ||||
17 | connect(this, &OtherShellHelper::availableScreenRegionChanged, m_plasmashellCorona, &ShellCorona::availableScreenRegionChanged); | ||||
18 | } | ||||
19 | | ||||
20 | QRect OtherShellHelper::availableScreenRect(int id, bool plasmashell) const | ||||
21 | { | ||||
A QRegion is a list of QRects. You should be able to do QList<QRect> It might work out the box, it might need: https://techbase.kde.org/Development/Tutorials/D-Bus/CustomTypes Using a QByteArray is a bit meh. davidedmundson: A QRegion is a list of QRects.
You should be able to do
QList<QRect>
It might work out the… | |||||
22 | return plasmashell? m_plasmashellCorona->availableScreenRect(static_cast<quint32>(id)) : m_availableScreenRects[id]; | ||||
23 | } | ||||
24 | | ||||
25 | QByteArray OtherShellHelper::availableScreenRegion(int id, bool plasmashell) const | ||||
26 | { | ||||
27 | QByteArray ba; | ||||
28 | QDataStream d(&ba, QIODevice::WriteOnly); | ||||
29 | d << (plasmashell? m_plasmashellCorona->availableScreenRegion(static_cast<quint32>(id)) : m_availableScreenRegions[id]); | ||||
30 | | ||||
31 | return ba; | ||||
32 | } | ||||
33 | | ||||
34 | QRegion OtherShellHelper::availableScreenRegion(quint32 id) const { | ||||
35 | return m_availableScreenRegions[id]; | ||||
36 | } | ||||
37 | | ||||
38 | void OtherShellHelper::setAvailableScreenRect(int screenId, QRect rect) { | ||||
39 | if (m_availableScreenRects[screenId] == rect) { | ||||
40 | return; | ||||
41 | } | ||||
42 | m_availableScreenRects[screenId] = rect; | ||||
43 | emit availableScreenRectChanged(); | ||||
davidedmundson: int's for screens is not wayland safe.
string would be better | |||||
44 | } | ||||
45 | | ||||
46 | void OtherShellHelper::setAvailableScreenRegion(int screenId, QByteArray region) { | ||||
47 | QRegion r; | ||||
48 | QDataStream d(®ion, QIODevice::ReadOnly); | ||||
49 | d >> r; | ||||
50 | | ||||
51 | if (m_availableScreenRegions[screenId] != r) { | ||||
52 | m_availableScreenRegions[screenId] = r; | ||||
53 | emit availableScreenRegionChanged(); | ||||
54 | } | ||||
55 | return; | ||||
56 | } | ||||
57 | | ||||
58 | void OtherShellHelper::test(int screenId, int x, int y, int width, int height) { | ||||
59 | setAvailableScreenRect(screenId, QRect(x, y, width, height)); | ||||
60 | } | ||||
What if 2 clients connect? Also, please think about handling the connecting client crashing. davidedmundson: What if 2 clients connect?
Also, please think about handling the connecting client crashing. |
Ideally we want the ClassName to focus on what something does, rather than what the usage happens to be.
i.e
StrutManager or some such