Merge lp:~unity-2d-team/unity-2d/refactor-screeninfo into lp:unity-2d

Proposed by Michał Sawicz
Status: Merged
Approved by: Albert Astals Cid
Approved revision: 896
Merged at revision: 900
Proposed branch: lp:~unity-2d-team/unity-2d/refactor-screeninfo
Merge into: lp:unity-2d
Diff against target: 1198 lines (+435/-185)
27 files modified
launcher/Launcher.qml (+2/-2)
launcher/app/launcher.cpp (+3/-2)
launcher/app/launcherview.cpp (+3/-0)
libunity-2d-private/Unity2d/GnomeBackground.qml (+2/-2)
libunity-2d-private/Unity2d/plugin.cpp (+4/-2)
libunity-2d-private/src/CMakeLists.txt (+1/-0)
libunity-2d-private/src/dashclient.cpp (+1/-1)
libunity-2d-private/src/desktopinfo.cpp (+7/-88)
libunity-2d-private/src/desktopinfo.h (+6/-30)
libunity-2d-private/src/screeninfo.cpp (+211/-0)
libunity-2d-private/src/screeninfo.h (+72/-0)
libunity-2d-private/src/unity2ddeclarativeview.cpp (+9/-0)
libunity-2d-private/src/unity2ddeclarativeview.h (+7/-0)
libunity-2d-private/src/unity2dpanel.cpp (+24/-4)
libunity-2d-private/src/unity2dpanel.h (+7/-1)
libunity-2d-private/src/workspacesinfo.cpp (+3/-3)
panel/app/panelmanager.cpp (+41/-6)
panel/app/panelmanager.h (+2/-1)
panel/applets/appname/windowhelper.cpp (+0/-1)
places/app/dashdeclarativeview.cpp (+5/-11)
places/app/dashdeclarativeview.h (+2/-1)
places/dash.qml (+1/-1)
spread/Workspace.qml (+2/-2)
spread/Workspaces.qml (+11/-11)
spread/app/spread.cpp (+0/-5)
spread/app/spreadview.cpp (+8/-10)
spread/app/spreadview.h (+1/-1)
To merge this branch: bzr merge lp:~unity-2d-team/unity-2d/refactor-screeninfo
Reviewer Review Type Date Requested Status
Gerry Boland (community) Approve
Christoph Trassl Pending
Albert Astals Cid Pending
Florian Boucault Pending
Review via email: mp+91471@code.launchpad.net

This proposal supersedes a proposal from 2012-01-31.

Description of the change

This, in itself, will not change anything in unity-2d, but will later allow for easier multi-monitor implementation.

To post a comment you must log in.
Revision history for this message
Albert Astals Cid (aacid) wrote : Posted in a previous version of this proposal

Just a comment (not sure it really has any influence here) but the QDesktopWidget calls that take a QWidget * are known not to work until the widget has been shown (which kind of makes sense) so it'd be good to have that in mind for this rework

Revision history for this message
Albert Astals Cid (aacid) wrote : Posted in a previous version of this proposal

I guess the use of wnck_screen_get_default is not correct and should be changed to
  WnckScreen* wnck_screen_get(int index);

review: Needs Fixing
Revision history for this message
Michał Sawicz (saviq) wrote : Posted in a previous version of this proposal

Revision 891 is finally ready for review.

Here lp:~saviq/+junk/shell-refactor-screeninfo is a version integrated into unity-2d-shell.

Revision history for this message
Albert Astals Cid (aacid) wrote : Posted in a previous version of this proposal

d->m_screenInfo needs to be deleted in Unity2dPanel::~Unity2dPanel (or give the ScreenInfo a parent when creating it)
m_screenInfo needs to be initialized to NULL in Unity2DDeclarativeView::Unity2DDeclarativeView
m_screenInfo needs to be delete in Unity2DDeclarativeView::~Unity2DDeclarativeView (or give the ScreenInfo a parent when creating it in the various children)

review: Needs Fixing
Revision history for this message
Albert Astals Cid (aacid) wrote : Posted in a previous version of this proposal

Seems
Q_ENUMS(WorkspacesOrientation)
Q_ENUMS(WorkspacesCorner)
are not used at all? I think they were "wrong" before already but since we're cleaning up, might make sense to kill them now too.

review: Needs Fixing
Revision history for this message
Albert Astals Cid (aacid) wrote : Posted in a previous version of this proposal

Besides those small minor things the change seems much welcome and a much cleaner separation between the desktop and a screen that will help fix other multimunitor problems.

Revision history for this message
Michał Sawicz (saviq) wrote : Posted in a previous version of this proposal

> d->m_screenInfo needs to be deleted in Unity2dPanel::~Unity2dPanel (or give
> the ScreenInfo a parent when creating it)
> m_screenInfo needs to be initialized to NULL in
> Unity2DDeclarativeView::Unity2DDeclarativeView
> m_screenInfo needs to be delete in
> Unity2DDeclarativeView::~Unity2DDeclarativeView (or give the ScreenInfo a
> parent when creating it in the various children)
Done.

> Seems
> Q_ENUMS(WorkspacesOrientation)
> Q_ENUMS(WorkspacesCorner)
> are not used at all? I think they were "wrong" before already but since we're
> cleaning up, might make sense to kill them now too.
Yup, got rid of that.

Resubmitted from ~unity-2d-team so that you guys can work off of that when I'm away. Cheers!

Revision history for this message
Gerry Boland (gerboland) wrote :

Compiler warning to fix:
https://pastebin.canonical.com/59516/

But good otherwise.

review: Needs Fixing
Revision history for this message
Albert Astals Cid (aacid) wrote :

Pushed a fix for this

Revision history for this message
Gerry Boland (gerboland) wrote :

Ok great, approving. Great work Michal (and Albert)!

review: Approve
Revision history for this message
Unity Merger (unity-merger) wrote :

Attempt to merge into lp:unity-2d failed due to conflicts:

text conflict in launcher/app/launcherview.cpp
text conflict in libunity-2d-private/src/unity2ddeclarativeview.cpp

896. By Albert Astals Cid

Merge

Revision history for this message
Christoph Trassl (chtrassl) wrote : Posted in a previous version of this proposal

I was late for the review, sorry.

Thanks for you all for your work, just compiled and tested lp:unity-2d rev902 - bug 880698 is fixed for me.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'launcher/Launcher.qml'
2--- launcher/Launcher.qml 2011-12-11 22:26:34 +0000
3+++ launcher/Launcher.qml 2012-02-07 10:49:23 +0000
4@@ -56,7 +56,7 @@
5 anchors.fill: parent
6 overlay_color: "black"
7 overlay_alpha: 0.66
8- visible: !screen.isCompositingManagerRunning
9+ visible: !desktop.isCompositingManagerRunning
10 }
11 }
12
13@@ -65,7 +65,7 @@
14 anchors.fill: parent
15 color: "black"
16 opacity: 0.66
17- visible: screen.isCompositingManagerRunning
18+ visible: desktop.isCompositingManagerRunning
19 }
20
21 Image {
22
23=== modified file 'launcher/app/launcher.cpp'
24--- launcher/app/launcher.cpp 2011-12-01 09:55:45 +0000
25+++ launcher/app/launcher.cpp 2012-02-07 10:49:23 +0000
26@@ -37,6 +37,7 @@
27 #include "unity2ddebug.h"
28 #include "unity2dpanel.h"
29 #include "gesturehandler.h"
30+#include "screeninfo.h"
31
32 // libc
33 #include <stdlib.h>
34@@ -82,8 +83,8 @@
35 with that prefix resolves properly. */
36 QDir::addSearchPath("artwork", unity2dDirectory() + "/launcher/artwork");
37
38- /* Panel containing the QML declarative view */
39- Unity2dPanel panel(true);
40+ /* Panel containing the QML declarative view, topleft screen */
41+ Unity2dPanel panel(true, -1, ScreenInfo::TopLeft);
42
43 panel.setEdge(Unity2dPanel::LeftEdge);
44 panel.setFixedWidth(LauncherClient::MaximumWidth);
45
46=== modified file 'launcher/app/launcherview.cpp'
47--- launcher/app/launcherview.cpp 2012-02-06 19:38:07 +0000
48+++ launcher/app/launcherview.cpp 2012-02-07 10:49:23 +0000
49@@ -24,6 +24,7 @@
50 #include <hotkey.h>
51 #include <hotkeymonitor.h>
52 #include <keymonitor.h>
53+#include <screeninfo.h>
54 #include <debug_p.h>
55
56 #include <QApplication>
57@@ -69,6 +70,8 @@
58 connect(&m_superKeyHoldTimer, SIGNAL(timeout()), SLOT(updateSuperKeyHoldState()));
59 connect(this, SIGNAL(superKeyTapped()), SLOT(toggleDash()));
60
61+ m_screenInfo = new ScreenInfo(ScreenInfo::TopLeft, this);
62+
63 connect(&launcher2dConfiguration(), SIGNAL(superKeyEnableChanged(bool)), SLOT(updateSuperKeyMonitoring()));
64 updateSuperKeyMonitoring();
65
66
67=== modified file 'libunity-2d-private/Unity2d/GnomeBackground.qml'
68--- libunity-2d-private/Unity2d/GnomeBackground.qml 2011-12-07 02:15:57 +0000
69+++ libunity-2d-private/Unity2d/GnomeBackground.qml 2012-02-07 10:49:23 +0000
70@@ -80,8 +80,8 @@
71 else
72 return filename
73 }
74- width: screen.geometry.width
75- height: screen.geometry.height
76+ width: declarativeView.screen.geometry.width
77+ height: declarativeView.screen.geometry.height
78
79 smooth: true
80
81
82=== modified file 'libunity-2d-private/Unity2d/plugin.cpp'
83--- libunity-2d-private/Unity2d/plugin.cpp 2012-01-24 16:46:52 +0000
84+++ libunity-2d-private/Unity2d/plugin.cpp 2012-02-07 10:49:23 +0000
85@@ -36,6 +36,7 @@
86 #include "windowinfo.h"
87 #include "windowslist.h"
88 #include "screeninfo.h"
89+#include "desktopinfo.h"
90 #include "plugin.h"
91 #include "cacheeffect.h"
92 #include "iconutilities.h"
93@@ -100,7 +101,8 @@
94
95 qmlRegisterType<WindowInfo>(uri, 0, 1, "WindowInfo");
96 qmlRegisterType<WindowsList>(uri, 0, 1, "WindowsList");
97- qmlRegisterType<ScreenInfo>(); // Register the type as non creatable
98+ qmlRegisterType<ScreenInfo>(uri, 0, 1, "ScreenInfo");
99+ qmlRegisterType<DesktopInfo>(); // Register the type as non creatable
100 qmlRegisterType<WorkspacesInfo>(); // Register the type as non creatable
101
102 qmlRegisterType<CacheEffect>(uri, 0, 1, "CacheEffect");
103@@ -173,7 +175,7 @@
104
105 /* ScreenInfo is exposed as a context property as it's a singleton and therefore
106 not creatable directly in QML */
107- engine->rootContext()->setContextProperty("screen", ScreenInfo::instance());
108+ engine->rootContext()->setContextProperty("desktop", DesktopInfo::instance());
109 engine->rootContext()->setContextProperty("iconUtilities", new IconUtilities(engine));
110
111 /* Expose QConf objects as a context property not to initialize it multiple times */
112
113=== modified file 'libunity-2d-private/src/CMakeLists.txt'
114--- libunity-2d-private/src/CMakeLists.txt 2012-01-24 11:50:38 +0000
115+++ libunity-2d-private/src/CMakeLists.txt 2012-02-07 10:49:23 +0000
116@@ -34,6 +34,7 @@
117 windowinfo.cpp
118 windowslist.cpp
119 screeninfo.cpp
120+ desktopinfo.cpp
121 cacheeffect.cpp
122 workspacesinfo.cpp
123 signalwaiter.cpp
124
125=== modified file 'libunity-2d-private/src/dashclient.cpp'
126--- libunity-2d-private/src/dashclient.cpp 2012-01-27 11:34:36 +0000
127+++ libunity-2d-private/src/dashclient.cpp 2012-02-07 10:49:23 +0000
128@@ -179,7 +179,7 @@
129 if (unity2dConfiguration().property("formFactor").toString() != "desktop") {
130 alwaysFullScreen = true;
131 } else {
132- QRect rect = QApplication::desktop()->screenGeometry();
133+ QRect rect = QApplication::desktop()->screenGeometry(QPoint());
134 QSize minSize = minimumSizeForDesktop();
135 alwaysFullScreen = rect.width() < minSize.width() && rect.height() < minSize.height();
136 }
137
138=== renamed file 'libunity-2d-private/src/screeninfo.cpp' => 'libunity-2d-private/src/desktopinfo.cpp'
139--- libunity-2d-private/src/screeninfo.cpp 2011-12-07 17:50:45 +0000
140+++ libunity-2d-private/src/desktopinfo.cpp 2012-02-07 10:49:23 +0000
141@@ -8,109 +8,28 @@
142
143 #include "config.h"
144 #include "launcherclient.h"
145-#include "screeninfo.h"
146+#include "desktopinfo.h"
147 #include "workspacesinfo.h"
148
149 #include <QX11Info>
150 #include <QApplication>
151 #include <QDesktopWidget>
152
153-ScreenInfo::ScreenInfo(QObject *parent) :
154- QObject(parent),
155- m_activeWindow(0)
156+DesktopInfo::DesktopInfo(QObject *parent) :
157+ QObject(parent)
158 {
159- WnckScreen *screen = wnck_screen_get_default();
160- g_signal_connect(G_OBJECT(screen), "active-window-changed",
161- G_CALLBACK(ScreenInfo::onActiveWindowChanged), NULL);
162-
163- updateActiveWindow(screen);
164-
165- connect(QApplication::desktop(), SIGNAL(resized(int)),
166- SLOT(updateGeometry(int)));
167- connect(QApplication::desktop(), SIGNAL(workAreaResized(int)),
168- SLOT(updateAvailableGeometry(int)));
169 }
170
171
172-ScreenInfo* ScreenInfo::instance()
173+DesktopInfo* DesktopInfo::instance()
174 {
175- static ScreenInfo* singleton = new ScreenInfo();
176+ static DesktopInfo* singleton = new DesktopInfo();
177 return singleton;
178 }
179
180-void ScreenInfo::onActiveWindowChanged(WnckScreen *screen,
181- WnckWindow *previously_active_window,
182- gpointer user_data)
183-{
184- Q_UNUSED(previously_active_window);
185- Q_UNUSED(user_data);
186-
187- ScreenInfo::instance()->updateActiveWindow(screen);
188-}
189-
190-void ScreenInfo::updateActiveWindow(WnckScreen *screen)
191-{
192- unsigned int activeWindow = 0;
193- WnckWindow *wnckActiveWindow = wnck_screen_get_active_window(screen);
194- if (wnckActiveWindow != NULL) {
195- activeWindow = wnck_window_get_xid(wnckActiveWindow);
196- }
197-
198- if (activeWindow != m_activeWindow) {
199- m_activeWindow = activeWindow;
200- Q_EMIT activeWindowChanged(m_activeWindow);
201- }
202-}
203-
204-QRect ScreenInfo::availableGeometry() const
205-{
206- int screen = QX11Info::appScreen();
207- return QApplication::desktop()->availableGeometry(screen);
208-}
209-
210-QRect ScreenInfo::panelsFreeGeometry() const
211-{
212- /* We cannot just return the system's availableGeometry(), because that
213- * doesn't consider the Launcher, if it's set to auto-hide. */
214- int screen = QX11Info::appScreen();
215- QRect screenRect = QApplication::desktop()->screenGeometry(screen);
216- QRect availableRect = QApplication::desktop()->availableGeometry(screen);
217-
218- QRect availableGeometry(
219- LauncherClient::MaximumWidth,
220- availableRect.top(),
221- screenRect.width() - LauncherClient::MaximumWidth,
222- availableRect.height()
223- );
224- if (QApplication::isRightToLeft()) {
225- availableGeometry.moveLeft(0);
226- }
227- return availableGeometry;
228-}
229-
230-QRect ScreenInfo::geometry() const
231-{
232- return QApplication::desktop()->screenGeometry(QX11Info::appScreen());
233-}
234-
235-void ScreenInfo::updateGeometry(int screen)
236-{
237- if (screen == QX11Info::appScreen()) {
238- Q_EMIT geometryChanged(geometry());
239- }
240-}
241-
242-void ScreenInfo::updateAvailableGeometry(int screen)
243-{
244- if (screen == QX11Info::appScreen()) {
245- Q_EMIT availableGeometryChanged(availableGeometry());
246- Q_EMIT panelsFreeGeometryChanged(panelsFreeGeometry());
247- }
248-}
249-
250-bool ScreenInfo::isCompositingManagerRunning() const
251+bool DesktopInfo::isCompositingManagerRunning() const
252 {
253 return QX11Info::isCompositingManagerRunning();
254 }
255
256-#include "screeninfo.moc"
257+#include "desktopinfo.moc"
258
259=== renamed file 'libunity-2d-private/src/screeninfo.h' => 'libunity-2d-private/src/desktopinfo.h'
260--- libunity-2d-private/src/screeninfo.h 2011-12-07 17:50:45 +0000
261+++ libunity-2d-private/src/desktopinfo.h 2012-02-07 10:49:23 +0000
262@@ -1,5 +1,5 @@
263-#ifndef SCREENINFO_H
264-#define SCREENINFO_H
265+#ifndef DESKTOPINFO_H
266+#define DESKTOPINFO_H
267
268 #include <QObject>
269 #include <QRect>
270@@ -10,54 +10,30 @@
271 typedef struct _WnckScreen WnckScreen;
272 typedef struct _WnckWindow WnckWindow;
273
274-class ScreenInfo : public QObject
275+class DesktopInfo : public QObject
276 {
277 Q_OBJECT
278
279- Q_ENUMS(WorkspacesOrientation)
280- Q_ENUMS(WorkspacesCorner)
281-
282 Q_PROPERTY(WorkspacesInfo *workspaces READ workspaces NOTIFY workspacesChanged)
283- Q_PROPERTY(unsigned int activeWindow READ activeWindow NOTIFY activeWindowChanged)
284- Q_PROPERTY(QRect geometry READ geometry NOTIFY geometryChanged)
285- Q_PROPERTY(QRect availableGeometry READ availableGeometry NOTIFY availableGeometryChanged)
286- Q_PROPERTY(QRect panelsFreeGeometry READ panelsFreeGeometry NOTIFY panelsFreeGeometryChanged)
287 Q_PROPERTY(bool isCompositingManagerRunning READ isCompositingManagerRunning
288 NOTIFY isCompositingManagerRunningChanged)
289
290 public:
291- static ScreenInfo* instance();
292+ static DesktopInfo* instance();
293
294 /* Getters */
295 WorkspacesInfo *workspaces() { return &m_workspacesInfo; }
296- unsigned int activeWindow() const { return m_activeWindow; }
297- QRect availableGeometry() const;
298- QRect panelsFreeGeometry() const;
299- QRect geometry() const;
300 bool isCompositingManagerRunning() const;
301
302 Q_SIGNALS:
303- void activeWindowChanged(unsigned int activeWindow);
304- void geometryChanged(QRect geometry);
305- void availableGeometryChanged(QRect availableGeometry);
306- void panelsFreeGeometryChanged(QRect panelsFreeGeometry);
307 void workspacesChanged(WorkspacesInfo *workspaces);
308 void isCompositingManagerRunningChanged(bool);
309
310 private:
311- explicit ScreenInfo(QObject *parent = 0);
312- void updateActiveWindow(WnckScreen *screen);
313-
314- static void onActiveWindowChanged(WnckScreen *screen,
315- WnckWindow *previously_active_window,
316- gpointer user_data);
317-private Q_SLOTS:
318- void updateGeometry(int screen);
319- void updateAvailableGeometry(int screen);
320+ explicit DesktopInfo(QObject *parent = 0);
321
322 private:
323 WorkspacesInfo m_workspacesInfo;
324- unsigned int m_activeWindow;
325 };
326
327-#endif // SCREENINFO_H
328+#endif // DESKTOPINFO_H
329
330=== added file 'libunity-2d-private/src/screeninfo.cpp'
331--- libunity-2d-private/src/screeninfo.cpp 1970-01-01 00:00:00 +0000
332+++ libunity-2d-private/src/screeninfo.cpp 2012-02-07 10:49:23 +0000
333@@ -0,0 +1,211 @@
334+#include "config.h"
335+#include "launcherclient.h"
336+#include "screeninfo.h"
337+
338+#include <QApplication>
339+#include <QDesktopWidget>
340+#include <QX11Info>
341+
342+ScreenInfo::ScreenInfo(QObject *parent) :
343+ QObject(parent),
344+ m_screen(QX11Info::appScreen()),
345+ m_widget(NULL),
346+ m_corner(InvalidCorner)
347+{
348+ connect(QApplication::desktop(), SIGNAL(resized(int)),
349+ SLOT(updateGeometry(int)));
350+ connect(QApplication::desktop(), SIGNAL(workAreaResized(int)),
351+ SLOT(updateAvailableGeometry(int)));
352+}
353+
354+ScreenInfo::ScreenInfo(int screen, QObject *parent) :
355+ QObject(parent),
356+ m_screen(screen),
357+ m_widget(NULL),
358+ m_corner(InvalidCorner)
359+{
360+ connect(QApplication::desktop(), SIGNAL(resized(int)),
361+ SLOT(updateGeometry(int)));
362+ connect(QApplication::desktop(), SIGNAL(workAreaResized(int)),
363+ SLOT(updateAvailableGeometry(int)));
364+}
365+
366+ScreenInfo::ScreenInfo(QWidget *widget, QObject *parent) :
367+ QObject(parent),
368+ m_screen(QApplication::desktop()->screenNumber(widget)),
369+ m_widget(widget),
370+ m_corner(InvalidCorner)
371+{
372+ m_widget->installEventFilter(this);
373+ connect(QApplication::desktop(), SIGNAL(resized(int)),
374+ SLOT(updateGeometry(int)));
375+ connect(QApplication::desktop(), SIGNAL(workAreaResized(int)),
376+ SLOT(updateAvailableGeometry(int)));
377+}
378+
379+ScreenInfo::ScreenInfo(Corner corner, QObject *parent) :
380+ QObject(parent),
381+ m_screen(cornerScreen(corner)),
382+ m_widget(NULL),
383+ m_corner(corner)
384+{
385+ connect(QApplication::desktop(), SIGNAL(resized(int)),
386+ SLOT(updateGeometry(int)));
387+ connect(QApplication::desktop(), SIGNAL(workAreaResized(int)),
388+ SLOT(updateAvailableGeometry(int)));
389+}
390+
391+ScreenInfo::~ScreenInfo()
392+{
393+ if (m_widget) {
394+ m_widget->removeEventFilter(this);
395+ }
396+}
397+
398+QRect ScreenInfo::availableGeometry() const
399+{
400+ return QApplication::desktop()->availableGeometry(m_screen);
401+}
402+
403+QRect ScreenInfo::panelsFreeGeometry() const
404+{
405+ /* We cannot just return the system's availableGeometry(), because that
406+ * doesn't consider the Launcher, if it's set to auto-hide. */
407+ QRect screenRect = QApplication::desktop()->screenGeometry(m_screen);
408+ QRect availableRect = QApplication::desktop()->availableGeometry(m_screen);
409+
410+ QRect availableGeometry(
411+ LauncherClient::MaximumWidth,
412+ availableRect.top(),
413+ screenRect.width() - LauncherClient::MaximumWidth,
414+ availableRect.height()
415+ );
416+ if (QApplication::isRightToLeft()) {
417+ availableGeometry.moveLeft(0);
418+ }
419+ return availableGeometry;
420+}
421+
422+QRect ScreenInfo::geometry() const
423+{
424+ return QApplication::desktop()->screenGeometry(m_screen);
425+}
426+
427+void ScreenInfo::updateGeometry(int screen)
428+{
429+ if (m_corner != InvalidCorner) {
430+ int screenCorner = cornerScreen(m_corner);
431+ if (m_screen != screenCorner) {
432+ setScreen(screenCorner);
433+ return;
434+ }
435+ }
436+ if (screen == m_screen) {
437+ Q_EMIT geometryChanged(geometry());
438+ }
439+}
440+
441+void ScreenInfo::updateAvailableGeometry(int screen)
442+{
443+ if (screen == m_screen) {
444+ Q_EMIT availableGeometryChanged(availableGeometry());
445+ Q_EMIT panelsFreeGeometryChanged(panelsFreeGeometry());
446+ }
447+}
448+
449+void ScreenInfo::updateScreen()
450+{
451+ int screen;
452+ if (m_corner != InvalidCorner) {
453+ screen = cornerScreen(m_corner);
454+ setScreen(screen);
455+ } else if (m_widget) {
456+ screen = QApplication::desktop()->screenNumber(m_widget);
457+ setScreen(screen);
458+ }
459+}
460+
461+int
462+ScreenInfo::cornerScreen(Corner corner)
463+{
464+ QDesktopWidget* desktop = QApplication::desktop();
465+ switch(corner) {
466+ case TopLeft:
467+ return desktop->screenNumber(QPoint());
468+ case TopRight:
469+ return desktop->screenNumber(QPoint(desktop->width(), 0));
470+ case BottomLeft:
471+ return desktop->screenNumber(QPoint(0, desktop->height()));
472+ case BottomRight:
473+ return desktop->screenNumber(QPoint(desktop->width(), desktop->height()));
474+ default:
475+ return desktop->screenNumber(QPoint());
476+ }
477+}
478+
479+bool
480+ScreenInfo::eventFilter(QObject *object, QEvent *event)
481+{
482+ Q_UNUSED(object);
483+
484+ if (event->type() == QEvent::Move || event->type() == QEvent::Show) {
485+ updateScreen();
486+ }
487+ return QObject::eventFilter(object, event);
488+}
489+
490+int
491+ScreenInfo::screen() const
492+{
493+ return m_screen;
494+}
495+
496+void
497+ScreenInfo::setScreen(int screen)
498+{
499+ if (m_screen != screen) {
500+ m_screen = screen;
501+ Q_EMIT screenChanged(m_screen);
502+ Q_EMIT geometryChanged(geometry());
503+ Q_EMIT availableGeometryChanged(availableGeometry());
504+ Q_EMIT panelsFreeGeometryChanged(panelsFreeGeometry());
505+ }
506+}
507+
508+QWidget*
509+ScreenInfo::widget() const
510+{
511+ return m_widget;
512+}
513+
514+void
515+ScreenInfo::setWidget(QWidget *widget)
516+{
517+ if (m_widget != widget) {
518+ m_widget->removeEventFilter(this);
519+ m_widget = widget;
520+ if (m_widget) {
521+ m_widget->installEventFilter(this);
522+ }
523+ Q_EMIT widgetChanged(m_widget);
524+ updateScreen();
525+ }
526+}
527+
528+ScreenInfo::Corner
529+ScreenInfo::corner() const
530+{
531+ return m_corner;
532+}
533+
534+void
535+ScreenInfo::setCorner(Corner corner)
536+{
537+ if (m_corner != corner) {
538+ m_corner = corner;
539+ Q_EMIT cornerChanged(corner);
540+ updateScreen();
541+ }
542+}
543+
544+#include "screeninfo.moc"
545
546=== added file 'libunity-2d-private/src/screeninfo.h'
547--- libunity-2d-private/src/screeninfo.h 1970-01-01 00:00:00 +0000
548+++ libunity-2d-private/src/screeninfo.h 2012-02-07 10:49:23 +0000
549@@ -0,0 +1,72 @@
550+#ifndef SCREENINFO_H
551+#define SCREENINFO_H
552+
553+#include <QObject>
554+#include <QRect>
555+
556+class QEvent;
557+class QWidget;
558+
559+class ScreenInfo : public QObject
560+{
561+ Q_OBJECT
562+
563+ Q_PROPERTY(QRect geometry READ geometry NOTIFY geometryChanged)
564+ Q_PROPERTY(QRect availableGeometry READ availableGeometry NOTIFY availableGeometryChanged)
565+ Q_PROPERTY(QRect panelsFreeGeometry READ panelsFreeGeometry NOTIFY panelsFreeGeometryChanged)
566+ Q_PROPERTY(int screen READ screen WRITE setScreen NOTIFY screenChanged)
567+ Q_PROPERTY(QWidget* widget READ widget WRITE setWidget NOTIFY widgetChanged)
568+ Q_PROPERTY(Corner corner READ corner WRITE setCorner NOTIFY cornerChanged)
569+
570+public:
571+ enum Corner {
572+ InvalidCorner,
573+ TopLeft,
574+ TopRight,
575+ BottomLeft,
576+ BottomRight
577+ };
578+
579+ /* Getters */
580+ explicit ScreenInfo(QObject *parent = 0);
581+ ScreenInfo(QWidget* widget, QObject *parent = 0);
582+ ScreenInfo(int screen, QObject *parent = 0);
583+ ScreenInfo(Corner corner, QObject *parent = 0);
584+ ~ScreenInfo();
585+ QRect availableGeometry() const;
586+ QRect panelsFreeGeometry() const;
587+ QRect geometry() const;
588+ int screen() const;
589+ QWidget* widget() const;
590+ Corner corner() const;
591+
592+ /* Setters */
593+ void setScreen(int screen);
594+ void setWidget(QWidget* widget);
595+ void setCorner(Corner corner);
596+
597+
598+protected:
599+ bool eventFilter(QObject *object, QEvent *event);
600+
601+Q_SIGNALS:
602+ void geometryChanged(QRect geometry);
603+ void availableGeometryChanged(QRect availableGeometry);
604+ void panelsFreeGeometryChanged(QRect panelsFreeGeometry);
605+ void screenChanged(int screen);
606+ void widgetChanged(QWidget* widget);
607+ void cornerChanged(Corner corner);
608+
609+private Q_SLOTS:
610+ void updateGeometry(int screen);
611+ void updateAvailableGeometry(int screen);
612+
613+private:
614+ void updateScreen();
615+ int cornerScreen(Corner corner);
616+ int m_screen;
617+ QWidget* m_widget;
618+ Corner m_corner;
619+};
620+
621+#endif // SCREENINFO_H
622
623=== modified file 'libunity-2d-private/src/unity2ddeclarativeview.cpp'
624--- libunity-2d-private/src/unity2ddeclarativeview.cpp 2012-02-06 19:38:07 +0000
625+++ libunity-2d-private/src/unity2ddeclarativeview.cpp 2012-02-07 10:49:23 +0000
626@@ -19,6 +19,8 @@
627 #include <debug_p.h>
628 #include <config.h>
629
630+#include "screeninfo.h"
631+
632 #include <QDebug>
633 #include <QGLWidget>
634 #include <QVariant>
635@@ -45,6 +47,7 @@
636
637 Unity2DDeclarativeView::Unity2DDeclarativeView(QWidget *parent) :
638 QDeclarativeView(parent),
639+ m_screenInfo(NULL),
640 m_useOpenGL(false),
641 m_transparentBackground(false),
642 m_last_focused_window(None)
643@@ -278,4 +281,10 @@
644 Q_EMIT activeWorkspaceChanged();
645 }
646
647+ScreenInfo*
648+Unity2DDeclarativeView::screen() const
649+{
650+ return m_screenInfo;
651+}
652+
653 #include <unity2ddeclarativeview.moc>
654
655=== modified file 'libunity-2d-private/src/unity2ddeclarativeview.h'
656--- libunity-2d-private/src/unity2ddeclarativeview.h 2012-02-03 20:59:54 +0000
657+++ libunity-2d-private/src/unity2ddeclarativeview.h 2012-02-07 10:49:23 +0000
658@@ -19,6 +19,8 @@
659
660 #include <QDeclarativeView>
661
662+class ScreenInfo;
663+
664 class Unity2DDeclarativeView : public QDeclarativeView
665 {
666 Q_OBJECT
667@@ -26,6 +28,7 @@
668 Q_PROPERTY(bool useOpenGL READ useOpenGL WRITE setUseOpenGL NOTIFY useOpenGLChanged)
669 Q_PROPERTY(bool transparentBackground READ transparentBackground WRITE setTransparentBackground NOTIFY transparentBackgroundChanged)
670 Q_PROPERTY(QPoint globalPosition READ globalPosition NOTIFY globalPositionChanged)
671+ Q_PROPERTY(ScreenInfo* screen READ screen NOTIFY screenChanged)
672 Q_PROPERTY(bool visible READ isVisible NOTIFY visibleChanged)
673
674 public:
675@@ -36,6 +39,7 @@
676 bool useOpenGL() const;
677 bool transparentBackground() const;
678 QPoint globalPosition() const;
679+ ScreenInfo* screen() const;
680
681 // setters
682 void setUseOpenGL(bool);
683@@ -45,6 +49,7 @@
684 void useOpenGLChanged(bool);
685 void transparentBackgroundChanged(bool);
686 void globalPositionChanged(QPoint);
687+ void screenChanged(ScreenInfo*);
688 void visibleChanged(bool);
689 void activeWorkspaceChanged();
690
691@@ -54,6 +59,8 @@
692 virtual void showEvent(QShowEvent *event);
693 virtual void hideEvent(QHideEvent* event);
694
695+ ScreenInfo* m_screenInfo;
696+
697 protected Q_SLOTS:
698 void forceActivateWindow();
699 void forceDeactivateWindow();
700
701=== modified file 'libunity-2d-private/src/unity2dpanel.cpp'
702--- libunity-2d-private/src/unity2dpanel.cpp 2011-11-05 21:14:08 +0000
703+++ libunity-2d-private/src/unity2dpanel.cpp 2012-02-07 10:49:23 +0000
704@@ -36,6 +36,9 @@
705 #include <X11/Xlib.h>
706 #include <X11/Xatom.h>
707
708+// unity-2d
709+#include "screeninfo.h"
710+
711 static const int SLIDE_DURATION = 125;
712
713 struct Unity2dPanelPrivate
714@@ -49,6 +52,7 @@
715 bool m_useStrut;
716 int m_delta;
717 bool m_manualSliding;
718+ ScreenInfo* m_screenInfo;
719
720 void setStrut(ulong* struts)
721 {
722@@ -96,9 +100,8 @@
723
724 void updateGeometry()
725 {
726- QDesktopWidget* desktop = QApplication::desktop();
727- const QRect screen = desktop->screenGeometry(q);
728- const QRect available = desktop->availableGeometry(q);
729+ const QRect screen = m_screenInfo->geometry();
730+ const QRect available = m_screenInfo->availableGeometry();
731
732 QRect rect;
733 switch (m_edge) {
734@@ -144,7 +147,7 @@
735 }
736 };
737
738-Unity2dPanel::Unity2dPanel(bool requiresTransparency, QWidget* parent)
739+Unity2dPanel::Unity2dPanel(bool requiresTransparency, int screen, ScreenInfo::Corner corner, QWidget* parent)
740 : QWidget(parent)
741 , d(new Unity2dPanelPrivate)
742 {
743@@ -157,6 +160,13 @@
744 d->m_layout = new QHBoxLayout(this);
745 d->m_layout->setMargin(0);
746 d->m_layout->setSpacing(0);
747+ if (corner != ScreenInfo::InvalidCorner) {
748+ d->m_screenInfo = new ScreenInfo(corner, this);
749+ } else if (screen >= 0) {
750+ d->m_screenInfo = new ScreenInfo(screen, this);
751+ } else {
752+ d->m_screenInfo = new ScreenInfo(this, this);
753+ }
754
755 d->m_slideInAnimation = new QPropertyAnimation(this);
756 d->m_slideInAnimation->setTargetObject(this);
757@@ -203,6 +213,16 @@
758 return d->m_edge;
759 }
760
761+void Unity2dPanel::setScreen(int screen)
762+{
763+ d->m_screenInfo->setScreen(screen);
764+}
765+
766+int Unity2dPanel::screen() const
767+{
768+ return d->m_screenInfo->screen();
769+}
770+
771 IndicatorsManager* Unity2dPanel::indicatorsManager() const
772 {
773 if (d->m_indicatorsManager == 0) {
774
775=== modified file 'libunity-2d-private/src/unity2dpanel.h'
776--- libunity-2d-private/src/unity2dpanel.h 2011-10-12 16:54:18 +0000
777+++ libunity-2d-private/src/unity2dpanel.h 2012-02-07 10:49:23 +0000
778@@ -29,6 +29,8 @@
779 #include <QWidget>
780 #include <QEvent>
781
782+#include "screeninfo.h"
783+
784 struct Unity2dPanelPrivate;
785 class Unity2dPanel : public QWidget
786 {
787@@ -54,12 +56,16 @@
788
789 static const QEvent::Type SHOW_FIRST_MENU_EVENT = QEvent::User;
790
791- Unity2dPanel(bool requiresTransparency = false, QWidget* parent = 0);
792+ Unity2dPanel(bool requiresTransparency = false, int screen = -1,
793+ ScreenInfo::Corner corner = ScreenInfo::InvalidCorner, QWidget* parent = 0);
794 ~Unity2dPanel();
795
796 void setEdge(Edge);
797 Edge edge() const;
798
799+ void setScreen(int);
800+ int screen() const;
801+
802 void addWidget(QWidget*);
803
804 void addSpacer();
805
806=== modified file 'libunity-2d-private/src/workspacesinfo.cpp'
807--- libunity-2d-private/src/workspacesinfo.cpp 2011-11-10 17:53:54 +0000
808+++ libunity-2d-private/src/workspacesinfo.cpp 2012-02-07 10:49:23 +0000
809@@ -1,5 +1,5 @@
810 #include "workspacesinfo.h"
811-#include "screeninfo.h"
812+#include "desktopinfo.h"
813 #include "signalwaiter.h"
814 #include <debug_p.h>
815
816@@ -74,9 +74,9 @@
817
818 if (notify->atom == _NET_DESKTOP_LAYOUT ||
819 notify->atom == _NET_NUMBER_OF_DESKTOPS) {
820- ScreenInfo::instance()->workspaces()->updateWorkspaceGeometry();
821+ DesktopInfo::instance()->workspaces()->updateWorkspaceGeometry();
822 } else if (notify->atom == _NET_CURRENT_DESKTOP) {
823- ScreenInfo::instance()->workspaces()->updateCurrentWorkspace();
824+ DesktopInfo::instance()->workspaces()->updateCurrentWorkspace();
825 }
826
827 return ret;
828
829=== modified file 'panel/app/panelmanager.cpp'
830--- panel/app/panelmanager.cpp 2012-01-26 11:16:03 +0000
831+++ panel/app/panelmanager.cpp 2012-02-07 10:49:23 +0000
832@@ -116,14 +116,31 @@
833 PanelManager::PanelManager(QObject* parent)
834 : QObject(parent)
835 {
836+ Unity2dPanel* panel;
837 QDesktopWidget* desktop = QApplication::desktop();
838+
839+ QPoint p;
840+ if (QApplication::isRightToLeft()) {
841+ p = QPoint(desktop->width() - 1, 0);
842+ }
843+ int leftmost = desktop->screenNumber(p);
844+
845+ panel = instantiatePanel(leftmost);
846+ m_panels.append(panel);
847+ panel->show();
848+ panel->move(desktop->screenGeometry(leftmost).topLeft());
849+
850 for(int i = 0; i < desktop->screenCount(); ++i) {
851- Unity2dPanel* panel = instantiatePanel(i);
852+ if (i == leftmost) {
853+ continue;
854+ }
855+ panel = instantiatePanel(i);
856 m_panels.append(panel);
857 panel->show();
858 panel->move(desktop->screenGeometry(i).topLeft());
859 }
860- connect(desktop, SIGNAL(screenCountChanged(int)), SLOT(onScreenCountChanged(int)));
861+ connect(desktop, SIGNAL(screenCountChanged(int)), SLOT(updateScreenLayout(int)));
862+ connect(desktop, SIGNAL(resized(int)), SLOT(onScreenResized(int)));
863
864 /* A F10 keypress opens the first menu of the visible application or of the first
865 indicator on the panel */
866@@ -138,7 +155,7 @@
867
868 Unity2dPanel* PanelManager::instantiatePanel(int screen)
869 {
870- Unity2dPanel* panel = new Unity2dPanel;
871+ Unity2dPanel* panel = new Unity2dPanel(false, screen);
872 panel->setAccessibleName("Top Panel");
873 panel->setEdge(Unity2dPanel::TopEdge);
874 panel->setFixedHeight(24);
875@@ -181,7 +198,25 @@
876 }
877
878 void
879-PanelManager::onScreenCountChanged(int newCount)
880+PanelManager::onScreenResized(int screen)
881+{
882+ QPoint p;
883+ QDesktopWidget* desktop = QApplication::desktop();
884+ if (QApplication::isRightToLeft()) {
885+ p = QPoint(desktop->width() - 1, 0);
886+ }
887+ int leftmost = desktop->screenNumber(p);
888+
889+ /* We only care about the leftmost screen being resized,
890+ because there is no screenLayoutChanged signal, we're
891+ abusing it here so that we update the panels */
892+ if (screen == leftmost) {
893+ updateScreenLayout(desktop->screenCount());
894+ }
895+}
896+
897+void
898+PanelManager::updateScreenLayout(int newCount)
899 {
900 if (newCount > 0) {
901 QDesktopWidget* desktop = QApplication::desktop();
902@@ -197,7 +232,7 @@
903 m_panels.append(panel);
904 }
905 panel->show();
906- panel->move(desktop->screenGeometry(leftmost).topLeft());
907+ panel->setScreen(leftmost);
908
909 /* Update the position of other existing panels, and instantiate new
910 panels as needed. */
911@@ -213,7 +248,7 @@
912 m_panels.append(panel);
913 }
914 panel->show();
915- panel->move(desktop->screenGeometry(screen).topLeft());
916+ panel->setScreen(screen);
917 ++i;
918 }
919 }
920
921=== modified file 'panel/app/panelmanager.h'
922--- panel/app/panelmanager.h 2012-01-26 11:16:03 +0000
923+++ panel/app/panelmanager.h 2012-02-07 10:49:23 +0000
924@@ -44,8 +44,9 @@
925 QStringList loadPanelConfiguration() const;
926
927 private Q_SLOTS:
928- void onScreenCountChanged(int newCount);
929+ void updateScreenLayout(int newCount);
930 void onAltF10Pressed();
931+ void onScreenResized(int screen);
932 };
933
934 #endif // PanelManager_H
935
936=== modified file 'panel/applets/appname/windowhelper.cpp'
937--- panel/applets/appname/windowhelper.cpp 2012-01-24 13:03:34 +0000
938+++ panel/applets/appname/windowhelper.cpp 2012-02-07 10:49:23 +0000
939@@ -29,7 +29,6 @@
940 #include <dashclient.h>
941 #include <debug_p.h>
942 #include <gconnector.h>
943-#include <screeninfo.h>
944
945 // Bamf
946 #include <bamf-matcher.h>
947
948=== modified file 'places/app/dashdeclarativeview.cpp'
949--- places/app/dashdeclarativeview.cpp 2012-02-01 14:47:57 +0000
950+++ places/app/dashdeclarativeview.cpp 2012-02-07 10:49:23 +0000
951@@ -23,7 +23,6 @@
952 #include <dashclient.h>
953
954 // Qt
955-#include <QDesktopWidget>
956 #include <QApplication>
957 #include <QBitmap>
958 #include <QCloseEvent>
959@@ -55,20 +54,15 @@
960 setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
961 setTransparentBackground(QX11Info::isCompositingManagerRunning());
962
963- QDesktopWidget* desktop = QApplication::desktop();
964- connect(desktop, SIGNAL(resized(int)), SIGNAL(screenGeometryChanged()));
965- connect(desktop, SIGNAL(workAreaResized(int)), SLOT(onWorkAreaResized(int)));
966+ m_screenInfo = new ScreenInfo(ScreenInfo::TopLeft, this);
967+ connect(m_screenInfo, SIGNAL(availableGeometryChanged(QRect)), SLOT(onWorkAreaResized()));
968
969 updateSize();
970 }
971
972 void
973-DashDeclarativeView::onWorkAreaResized(int screen)
974+DashDeclarativeView::onWorkAreaResized()
975 {
976- if (QApplication::desktop()->screenNumber(this) != screen) {
977- return;
978- }
979-
980 updateSize();
981 }
982
983@@ -85,7 +79,7 @@
984 void
985 DashDeclarativeView::fitToAvailableSpace()
986 {
987- QRect rect = ScreenInfo::instance()->panelsFreeGeometry();
988+ QRect rect = m_screenInfo->panelsFreeGeometry();
989 move(rect.topLeft());
990 setFixedSize(rect.size());
991 }
992@@ -93,7 +87,7 @@
993 void
994 DashDeclarativeView::resizeToDesktopModeSize()
995 {
996- QRect rect = ScreenInfo::instance()->panelsFreeGeometry();
997+ QRect rect = m_screenInfo->panelsFreeGeometry();
998 int screenRight = rect.right();
999
1000 rect.setWidth(qMin(DASH_DESKTOP_WIDTH, rect.width()));
1001
1002=== modified file 'places/app/dashdeclarativeview.h'
1003--- places/app/dashdeclarativeview.h 2012-01-24 12:35:44 +0000
1004+++ places/app/dashdeclarativeview.h 2012-02-07 10:49:23 +0000
1005@@ -21,6 +21,7 @@
1006 #include <unity2ddeclarativeview.h>
1007
1008 class LauncherClient;
1009+class ScreenInfo;
1010
1011 class DashDeclarativeView : public Unity2DDeclarativeView
1012 {
1013@@ -67,7 +68,7 @@
1014 virtual void showEvent(QShowEvent *event);
1015
1016 private Q_SLOTS:
1017- void onWorkAreaResized(int screen);
1018+ void onWorkAreaResized();
1019 void updateSize();
1020
1021 private:
1022
1023=== modified file 'places/dash.qml'
1024--- places/dash.qml 2012-01-30 14:08:55 +0000
1025+++ places/dash.qml 2012-02-07 10:49:23 +0000
1026@@ -206,7 +206,7 @@
1027 BorderImage {
1028 anchors.fill: parent
1029 visible: dashView.dashMode == DashDeclarativeView.DesktopMode
1030- source: screen.isCompositingManagerRunning ? "artwork/desktop_dash_background.sci" : "artwork/desktop_dash_background_no_transparency.sci"
1031+ source: desktop.isCompositingManagerRunning ? "artwork/desktop_dash_background.sci" : "artwork/desktop_dash_background_no_transparency.sci"
1032 mirror: isRightToLeft()
1033 }
1034 }
1035
1036=== modified file 'spread/Workspace.qml'
1037--- spread/Workspace.qml 2011-10-21 12:46:08 +0000
1038+++ spread/Workspace.qml 2012-02-07 10:49:23 +0000
1039@@ -54,8 +54,8 @@
1040
1041 clip: true
1042 cached: false
1043- offsetX: -screen.panelsFreeGeometry.x
1044- offsetY: -screen.panelsFreeGeometry.y
1045+ offsetX: -declarativeView.screen.panelsFreeGeometry.x
1046+ offsetY: -declarativeView.screen.panelsFreeGeometry.y
1047 }
1048
1049 Windows {
1050
1051=== modified file 'spread/Workspaces.qml'
1052--- spread/Workspaces.qml 2011-12-06 19:37:23 +0000
1053+++ spread/Workspaces.qml 2012-02-07 10:49:23 +0000
1054@@ -25,8 +25,8 @@
1055
1056 color: "black"
1057
1058- property int columns: screen.workspaces.columns
1059- property int rows: screen.workspaces.rows
1060+ property int columns: desktop.workspaces.columns
1061+ property int rows: desktop.workspaces.rows
1062
1063 property int margin: 35
1064 property int spacing: 4
1065@@ -57,7 +57,7 @@
1066
1067 /* Scale of a workspace when the user zooms on it (fills most of the switcher, leaving a margin to see
1068 the corners of the other workspaces below it) */
1069- property bool isDesktopHorizontal: screen.panelsFreeGeometry.width > screen.panelsFreeGeometry.height
1070+ property bool isDesktopHorizontal: declarativeView.screen.panelsFreeGeometry.width > declarativeView.screen.panelsFreeGeometry.height
1071 property real zoomedScale: (isDesktopHorizontal) ? ((width - 2*margin) / switcher.width) :
1072 ((height - 2*margin) / switcher.height)
1073
1074@@ -85,7 +85,7 @@
1075 width: cellWidth * columns
1076 height: cellHeight * rows
1077
1078- model: screen.workspaces.count
1079+ model: desktop.workspaces.count
1080 cellWidth: parent.cellWidth + spacing
1081 cellHeight: parent.cellHeight + spacing
1082 keyNavigationWraps: true
1083@@ -136,7 +136,7 @@
1084 }
1085 state: {
1086 if (initial) {
1087- if (screen.workspaces.current == workspaceNumber) {
1088+ if (desktop.workspaces.current == workspaceNumber) {
1089 return "screen"
1090 } else {
1091 return "unzoomed"
1092@@ -189,12 +189,12 @@
1093 /* Setup application pre-filtering and initially zoomed desktop, if any
1094 were specified as arguments */
1095 applicationFilter = applicationDesktopFile
1096- zoomedWorkspace = screen.workspaces.current
1097+ zoomedWorkspace = desktop.workspaces.current
1098 show()
1099 }
1100
1101 onShowAllWorkspaces: {
1102- if (screen.workspaces.count > 1) {
1103+ if (desktop.workspaces.count > 1) {
1104 applicationFilter = applicationDesktopFile
1105 zoomedWorkspace = -1
1106 show()
1107@@ -211,13 +211,13 @@
1108 function show() {
1109 /* Save the currently active window before showing and activating the switcher,
1110 so that we can use it to pre-select the active window on the workspace */
1111- lastActiveWindow = screen.activeWindow
1112+ lastActiveWindow = desktop.activeWindow
1113
1114 allWindows.load()
1115
1116 spreadView.show()
1117 spreadView.forceActivateWindow()
1118- workspaces.currentIndex = screen.workspaces.current
1119+ workspaces.currentIndex = desktop.workspaces.current
1120 /* This is necessary otherwise we don't get keypresses until the user does a
1121 mouse over on a window */
1122 workspaces.forceActiveFocus()
1123@@ -280,13 +280,13 @@
1124 }
1125
1126 function activateWindow(windowInfo) {
1127- screen.workspaces.changeCurrent(zoomedWorkspace)
1128+ desktop.workspaces.changeCurrent(zoomedWorkspace)
1129 windowInfo.activate()
1130 cancelAndExit()
1131 }
1132
1133 function activateWorkspace(workspaceNumber) {
1134- screen.workspaces.changeCurrent(workspaceNumber)
1135+ desktop.workspaces.changeCurrent(workspaceNumber)
1136 cancelAndExit()
1137 }
1138 }
1139
1140=== modified file 'spread/app/spread.cpp'
1141--- spread/app/spread.cpp 2011-11-11 15:52:49 +0000
1142+++ spread/app/spread.cpp 2012-02-07 10:49:23 +0000
1143@@ -66,10 +66,5 @@
1144 view.rootContext()->setContextProperty("spreadView", &view);
1145 view.setSource(QUrl("./Workspaces.qml"));
1146
1147- /* Always match the size of the desktop */
1148- int current_screen = QApplication::desktop()->screenNumber(&view);
1149- view.fitToAvailableSpace(current_screen);
1150- QObject::connect(QApplication::desktop(), SIGNAL(workAreaResized(int)), &view, SLOT(fitToAvailableSpace(int)));
1151-
1152 return application.exec();
1153 }
1154
1155=== modified file 'spread/app/spreadview.cpp'
1156--- spread/app/spreadview.cpp 2012-02-01 14:47:57 +0000
1157+++ spread/app/spreadview.cpp 2012-02-07 10:49:23 +0000
1158@@ -28,19 +28,17 @@
1159 SpreadView::SpreadView()
1160 : Unity2DDeclarativeView()
1161 {
1162+ m_screenInfo = new ScreenInfo(ScreenInfo::TopLeft, this);
1163+ connect(m_screenInfo, SIGNAL(availableGeometryChanged(QRect)), SLOT(fitToAvailableSpace()));
1164+
1165+ fitToAvailableSpace();
1166 }
1167
1168-void SpreadView::fitToAvailableSpace(int screen)
1169+void SpreadView::fitToAvailableSpace()
1170 {
1171- QDesktopWidget *desktop = QApplication::desktop();
1172- int current_screen = desktop->screenNumber(this);
1173-
1174- if(screen == current_screen)
1175- {
1176- QRect geometry = ScreenInfo::instance()->panelsFreeGeometry();
1177- setGeometry(geometry);
1178- setFixedSize(geometry.size());
1179- }
1180+ QRect geometry = m_screenInfo->panelsFreeGeometry();
1181+ setGeometry(geometry);
1182+ setFixedSize(geometry.size());
1183 }
1184
1185 /* To be able to call grabMouse() we need to be 100% sure that X11 did
1186
1187=== modified file 'spread/app/spreadview.h'
1188--- spread/app/spreadview.h 2012-02-01 14:47:57 +0000
1189+++ spread/app/spreadview.h 2012-02-07 10:49:23 +0000
1190@@ -34,7 +34,7 @@
1191
1192 public Q_SLOTS:
1193 /* FIXME: copied from places/app/dashdeclarativeview.h */
1194- void fitToAvailableSpace(int screen);
1195+ void fitToAvailableSpace();
1196
1197 protected:
1198 virtual void focusInEvent( QFocusEvent * event );

Subscribers

People subscribed via source and target branches