Merge lp:~ricmm/unity-mir/api-screen-geometry into lp:unity-mir

Proposed by Ricardo Mendoza
Status: Rejected
Rejected by: Ricardo Mendoza
Proposed branch: lp:~ricmm/unity-mir/api-screen-geometry
Merge into: lp:unity-mir
Diff against target: 69 lines (+32/-0)
2 files modified
src/unity-mir/dbusscreen.cpp (+25/-0)
src/unity-mir/dbusscreen.h (+7/-0)
To merge this branch: bzr merge lp:~ricmm/unity-mir/api-screen-geometry
Reviewer Review Type Date Requested Status
Gerry Boland (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+187503@code.launchpad.net

Commit message

Add API to request screen geometry

To post a comment you must log in.
Revision history for this message
Gerry Boland (gerboland) wrote :

- Q_INVOKABLE Q_SCRIPTABLE bool setScreenPowerMode(const QString &mode);
+ Q_INVOKABLE Q_SCRIPTABLE bool setScreenPowerMode(const QString mode);
Please restore the reference

Would be cleaner to move the code shared between the width & height methods into a private method, and call that in each.

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
93. By Ricardo Mendoza

Abstract duplicate code to private method

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Gerry Boland (gerboland) wrote :

LGTM, top approve when Ricardo wants

review: Approve

Unmerged revisions

93. By Ricardo Mendoza

Abstract duplicate code to private method

92. By Ricardo Mendoza

Add API to request screen geometry

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/unity-mir/dbusscreen.cpp'
2--- src/unity-mir/dbusscreen.cpp 2013-09-25 09:30:08 +0000
3+++ src/unity-mir/dbusscreen.cpp 2013-09-25 13:19:52 +0000
4@@ -16,6 +16,7 @@
5
6 // mir
7 #include <mir/graphics/display.h>
8+#include <mir/graphics/display_buffer.h>
9 #include <mir/graphics/display_configuration.h>
10 #include <mir_toolkit/common.h>
11
12@@ -42,6 +43,30 @@
13 QDBusConnection::ExportScriptableInvokables );
14 }
15
16+mir::geometry::Size DBusScreen::getDisplaySize(void) const
17+{
18+ std::shared_ptr<mg::Display> display = m_serverConfig->the_display();
19+
20+ mir::geometry::Rectangles view_area;
21+ display->for_each_display_buffer([&view_area](mg::DisplayBuffer const& db)
22+ {
23+ view_area.add(db.view_area());
24+ });
25+ mir::geometry::Size const display_size{view_area.bounding_rectangle().size};
26+
27+ return display_size;
28+}
29+
30+int DBusScreen::getDisplayWidth(void)
31+{
32+ return getDisplaySize().width.as_uint32_t();
33+}
34+
35+int DBusScreen::getDisplayHeight(void)
36+{
37+ return getDisplaySize().height.as_uint32_t();
38+}
39+
40 bool DBusScreen::setScreenPowerMode(const QString &mode)
41 {
42 MirPowerMode newPowerMode;
43
44=== modified file 'src/unity-mir/dbusscreen.h'
45--- src/unity-mir/dbusscreen.h 2013-09-25 09:30:08 +0000
46+++ src/unity-mir/dbusscreen.h 2013-09-25 13:19:52 +0000
47@@ -17,6 +17,9 @@
48 #ifndef DBUSSCREEN_H
49 #define DBUSSCREEN_H
50
51+// mir
52+#include <mir/geometry/rectangles.h>
53+
54 // qt
55 #include <QObject>
56
57@@ -30,9 +33,13 @@
58 public:
59 explicit DBusScreen(ShellServerConfiguration *config, QObject *parent = 0);
60
61+ Q_INVOKABLE Q_SCRIPTABLE int getDisplayWidth(void);
62+ Q_INVOKABLE Q_SCRIPTABLE int getDisplayHeight(void);
63 Q_INVOKABLE Q_SCRIPTABLE bool setScreenPowerMode(const QString &mode);
64
65 private:
66+ mir::geometry::Size getDisplaySize(void) const;
67+
68 ShellServerConfiguration *m_serverConfig;
69 };
70

Subscribers

People subscribed via source and target branches