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

Proposed by Michał Sawicz on 2012-01-31
Status: Superseded
Proposed branch: lp:~saviq/unity-2d/screeninfo-refactor
Merge into: lp:unity-2d
Diff against target: 1186 lines (+433/-182)
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/-27)
libunity-2d-private/src/screeninfo.cpp (+211/-0)
libunity-2d-private/src/screeninfo.h (+72/-0)
libunity-2d-private/src/unity2ddeclarativeview.cpp (+8/-0)
libunity-2d-private/src/unity2ddeclarativeview.h (+6/-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:~saviq/unity-2d/screeninfo-refactor
Reviewer Review Type Date Requested Status
Christoph Trassl (community) 2012-02-01 Approve on 2012-02-07
Albert Astals Cid (community) Needs Fixing on 2012-02-03
Florian Boucault 2012-01-31 Pending
Review via email: mp+90882@code.launchpad.net

This proposal has been superseded by a proposal from 2012-02-03.

Commit message

[all] refactor ScreenInfo into DesktopInfo

* rename ScreenInfo to DesktopInfo
* remove screen-specific functionality from DesktopInfo as there might be more than one screen handled
* make Unity2DDeclarativeView screen-aware
* update all references to match the new approach
* get rid of calls to unsafe QX11Info::appScreen()

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.
Albert Astals Cid (aacid) wrote :

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

Albert Astals Cid (aacid) wrote :

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
883. By Michał Sawicz on 2012-02-01

[lib] extend ScreenInfo to allow binding to a screen as well as usage from QML

884. By Michał Sawicz on 2012-02-01

[launcher] make sure launcher is always shown on leftmost / topmost screen

885. By Michał Sawicz on 2012-02-01

[panel] use ScreenInfo to move panels around

886. By Michał Sawicz on 2012-02-01

[lib] require classes inheriting from Unity2DDeclarativeView to instantiate their own ScreenInfo

887. By Michał Sawicz on 2012-02-01

[lib] remove dead code from DesktopInfo

888. By Michał Sawicz on 2012-02-01

[lib] make sure ScreenInfo will also update when the widget is shown

889. By Michał Sawicz on 2012-02-02

[lib] fix getter in Unity2dPanel

890. By Michał Sawicz on 2012-02-02

[panel] make the panels update properly when screen layout changes

891. By Michał Sawicz on 2012-02-02

[launcher] instantiate a ScreenInfo for LauncherView

Michał Sawicz (saviq) wrote :

Revision 891 is finally ready for review.

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

Albert Astals Cid (aacid) wrote :

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
Albert Astals Cid (aacid) wrote :

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
Albert Astals Cid (aacid) wrote :

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.

Michał Sawicz (saviq) wrote :

> 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!

892. By Michał Sawicz on 2012-02-03

[lib] clean up unused ENUMS in DesktopInfo

893. By Michał Sawicz on 2012-02-03

[all] make sure ScreenInfo has a parent so that it gets deleted along with it

Christoph Trassl (chtrassl) wrote :

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

Unmerged revisions

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-02 10:59:19 +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-02 10:59:19 +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 2011-11-25 11:13:44 +0000
48+++ launcher/app/launcherview.cpp 2012-02-02 10:59:19 +0000
49@@ -41,6 +41,7 @@
50 #include <hotkey.h>
51 #include <hotkeymonitor.h>
52 #include <keymonitor.h>
53+#include <screeninfo.h>
54 #include <debug_p.h>
55 #include <config.h>
56
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);
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-02 10:59:19 +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-02 10:59:19 +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-02 10:59:19 +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-02 10:59:19 +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-02 10:59:19 +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-02 10:59:19 +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,7 +10,7 @@
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@@ -18,46 +18,25 @@
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-02 10:59:19 +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-02 10:59:19 +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 2011-12-08 19:41:38 +0000
625+++ libunity-2d-private/src/unity2ddeclarativeview.cpp 2012-02-02 10:59:19 +0000
626@@ -28,6 +28,8 @@
627 #include <debug_p.h>
628 #include <config.h>
629
630+#include "screeninfo.h"
631+
632 // libwnck
633 extern "C" {
634 #include <libwnck/libwnck.h>
635@@ -265,4 +267,10 @@
636 m_last_focused_window = None;
637 }
638
639+ScreenInfo*
640+Unity2DDeclarativeView::screen() const
641+{
642+ return m_screenInfo;
643+}
644+
645 #include <unity2ddeclarativeview.moc>
646
647=== modified file 'libunity-2d-private/src/unity2ddeclarativeview.h'
648--- libunity-2d-private/src/unity2ddeclarativeview.h 2011-12-08 19:41:38 +0000
649+++ libunity-2d-private/src/unity2ddeclarativeview.h 2012-02-02 10:59:19 +0000
650@@ -19,6 +19,8 @@
651
652 #include <QDeclarativeView>
653
654+class ScreenInfo;
655+
656 class Unity2DDeclarativeView : public QDeclarativeView
657 {
658 Q_OBJECT
659@@ -26,6 +28,7 @@
660 Q_PROPERTY(bool useOpenGL READ useOpenGL WRITE setUseOpenGL NOTIFY useOpenGLChanged)
661 Q_PROPERTY(bool transparentBackground READ transparentBackground WRITE setTransparentBackground NOTIFY transparentBackgroundChanged)
662 Q_PROPERTY(QPoint globalPosition READ globalPosition NOTIFY globalPositionChanged)
663+ Q_PROPERTY(ScreenInfo* screen READ screen NOTIFY screenChanged)
664
665 public:
666 Unity2DDeclarativeView(QWidget *parent = 0);
667@@ -35,6 +38,7 @@
668 bool useOpenGL() const;
669 bool transparentBackground() const;
670 QPoint globalPosition() const;
671+ ScreenInfo* screen() const;
672
673 // setters
674 void setUseOpenGL(bool);
675@@ -44,10 +48,12 @@
676 void useOpenGLChanged(bool);
677 void transparentBackgroundChanged(bool);
678 void globalPositionChanged(QPoint);
679+ void screenChanged(ScreenInfo*);
680
681 protected:
682 void setupViewport();
683 virtual void moveEvent(QMoveEvent* event);
684+ ScreenInfo* m_screenInfo;
685
686 protected Q_SLOTS:
687 void forceActivateWindow();
688
689=== modified file 'libunity-2d-private/src/unity2dpanel.cpp'
690--- libunity-2d-private/src/unity2dpanel.cpp 2011-11-05 21:14:08 +0000
691+++ libunity-2d-private/src/unity2dpanel.cpp 2012-02-02 10:59:19 +0000
692@@ -36,6 +36,9 @@
693 #include <X11/Xlib.h>
694 #include <X11/Xatom.h>
695
696+// unity-2d
697+#include "screeninfo.h"
698+
699 static const int SLIDE_DURATION = 125;
700
701 struct Unity2dPanelPrivate
702@@ -49,6 +52,7 @@
703 bool m_useStrut;
704 int m_delta;
705 bool m_manualSliding;
706+ ScreenInfo* m_screenInfo;
707
708 void setStrut(ulong* struts)
709 {
710@@ -96,9 +100,8 @@
711
712 void updateGeometry()
713 {
714- QDesktopWidget* desktop = QApplication::desktop();
715- const QRect screen = desktop->screenGeometry(q);
716- const QRect available = desktop->availableGeometry(q);
717+ const QRect screen = m_screenInfo->geometry();
718+ const QRect available = m_screenInfo->availableGeometry();
719
720 QRect rect;
721 switch (m_edge) {
722@@ -144,7 +147,7 @@
723 }
724 };
725
726-Unity2dPanel::Unity2dPanel(bool requiresTransparency, QWidget* parent)
727+Unity2dPanel::Unity2dPanel(bool requiresTransparency, int screen, ScreenInfo::Corner corner, QWidget* parent)
728 : QWidget(parent)
729 , d(new Unity2dPanelPrivate)
730 {
731@@ -157,6 +160,13 @@
732 d->m_layout = new QHBoxLayout(this);
733 d->m_layout->setMargin(0);
734 d->m_layout->setSpacing(0);
735+ if (corner != ScreenInfo::InvalidCorner) {
736+ d->m_screenInfo = new ScreenInfo(corner);
737+ } else if (screen >= 0) {
738+ d->m_screenInfo = new ScreenInfo(screen);
739+ } else {
740+ d->m_screenInfo = new ScreenInfo(this);
741+ }
742
743 d->m_slideInAnimation = new QPropertyAnimation(this);
744 d->m_slideInAnimation->setTargetObject(this);
745@@ -203,6 +213,16 @@
746 return d->m_edge;
747 }
748
749+void Unity2dPanel::setScreen(int screen)
750+{
751+ d->m_screenInfo->setScreen(screen);
752+}
753+
754+int Unity2dPanel::screen() const
755+{
756+ return d->m_screenInfo->screen();
757+}
758+
759 IndicatorsManager* Unity2dPanel::indicatorsManager() const
760 {
761 if (d->m_indicatorsManager == 0) {
762
763=== modified file 'libunity-2d-private/src/unity2dpanel.h'
764--- libunity-2d-private/src/unity2dpanel.h 2011-10-12 16:54:18 +0000
765+++ libunity-2d-private/src/unity2dpanel.h 2012-02-02 10:59:19 +0000
766@@ -29,6 +29,8 @@
767 #include <QWidget>
768 #include <QEvent>
769
770+#include "screeninfo.h"
771+
772 struct Unity2dPanelPrivate;
773 class Unity2dPanel : public QWidget
774 {
775@@ -54,12 +56,16 @@
776
777 static const QEvent::Type SHOW_FIRST_MENU_EVENT = QEvent::User;
778
779- Unity2dPanel(bool requiresTransparency = false, QWidget* parent = 0);
780+ Unity2dPanel(bool requiresTransparency = false, int screen = -1,
781+ ScreenInfo::Corner corner = ScreenInfo::InvalidCorner, QWidget* parent = 0);
782 ~Unity2dPanel();
783
784 void setEdge(Edge);
785 Edge edge() const;
786
787+ void setScreen(int);
788+ int screen() const;
789+
790 void addWidget(QWidget*);
791
792 void addSpacer();
793
794=== modified file 'libunity-2d-private/src/workspacesinfo.cpp'
795--- libunity-2d-private/src/workspacesinfo.cpp 2011-11-10 17:53:54 +0000
796+++ libunity-2d-private/src/workspacesinfo.cpp 2012-02-02 10:59:19 +0000
797@@ -1,5 +1,5 @@
798 #include "workspacesinfo.h"
799-#include "screeninfo.h"
800+#include "desktopinfo.h"
801 #include "signalwaiter.h"
802 #include <debug_p.h>
803
804@@ -74,9 +74,9 @@
805
806 if (notify->atom == _NET_DESKTOP_LAYOUT ||
807 notify->atom == _NET_NUMBER_OF_DESKTOPS) {
808- ScreenInfo::instance()->workspaces()->updateWorkspaceGeometry();
809+ DesktopInfo::instance()->workspaces()->updateWorkspaceGeometry();
810 } else if (notify->atom == _NET_CURRENT_DESKTOP) {
811- ScreenInfo::instance()->workspaces()->updateCurrentWorkspace();
812+ DesktopInfo::instance()->workspaces()->updateCurrentWorkspace();
813 }
814
815 return ret;
816
817=== modified file 'panel/app/panelmanager.cpp'
818--- panel/app/panelmanager.cpp 2012-01-26 11:16:03 +0000
819+++ panel/app/panelmanager.cpp 2012-02-02 10:59:19 +0000
820@@ -116,14 +116,31 @@
821 PanelManager::PanelManager(QObject* parent)
822 : QObject(parent)
823 {
824+ Unity2dPanel* panel;
825 QDesktopWidget* desktop = QApplication::desktop();
826+
827+ QPoint p;
828+ if (QApplication::isRightToLeft()) {
829+ p = QPoint(desktop->width() - 1, 0);
830+ }
831+ int leftmost = desktop->screenNumber(p);
832+
833+ panel = instantiatePanel(leftmost);
834+ m_panels.append(panel);
835+ panel->show();
836+ panel->move(desktop->screenGeometry(leftmost).topLeft());
837+
838 for(int i = 0; i < desktop->screenCount(); ++i) {
839- Unity2dPanel* panel = instantiatePanel(i);
840+ if (i == leftmost) {
841+ continue;
842+ }
843+ panel = instantiatePanel(i);
844 m_panels.append(panel);
845 panel->show();
846 panel->move(desktop->screenGeometry(i).topLeft());
847 }
848- connect(desktop, SIGNAL(screenCountChanged(int)), SLOT(onScreenCountChanged(int)));
849+ connect(desktop, SIGNAL(screenCountChanged(int)), SLOT(updateScreenLayout(int)));
850+ connect(desktop, SIGNAL(resized(int)), SLOT(onScreenResized(int)));
851
852 /* A F10 keypress opens the first menu of the visible application or of the first
853 indicator on the panel */
854@@ -138,7 +155,7 @@
855
856 Unity2dPanel* PanelManager::instantiatePanel(int screen)
857 {
858- Unity2dPanel* panel = new Unity2dPanel;
859+ Unity2dPanel* panel = new Unity2dPanel(false, screen);
860 panel->setAccessibleName("Top Panel");
861 panel->setEdge(Unity2dPanel::TopEdge);
862 panel->setFixedHeight(24);
863@@ -181,7 +198,25 @@
864 }
865
866 void
867-PanelManager::onScreenCountChanged(int newCount)
868+PanelManager::onScreenResized(int screen)
869+{
870+ QPoint p;
871+ QDesktopWidget* desktop = QApplication::desktop();
872+ if (QApplication::isRightToLeft()) {
873+ p = QPoint(desktop->width() - 1, 0);
874+ }
875+ int leftmost = desktop->screenNumber(p);
876+
877+ /* We only care about the leftmost screen being resized,
878+ because there is no screenLayoutChanged signal, we're
879+ abusing it here so that we update the panels */
880+ if (screen == leftmost) {
881+ updateScreenLayout(desktop->screenCount());
882+ }
883+}
884+
885+void
886+PanelManager::updateScreenLayout(int newCount)
887 {
888 if (newCount > 0) {
889 QDesktopWidget* desktop = QApplication::desktop();
890@@ -197,7 +232,7 @@
891 m_panels.append(panel);
892 }
893 panel->show();
894- panel->move(desktop->screenGeometry(leftmost).topLeft());
895+ panel->setScreen(leftmost);
896
897 /* Update the position of other existing panels, and instantiate new
898 panels as needed. */
899@@ -213,7 +248,7 @@
900 m_panels.append(panel);
901 }
902 panel->show();
903- panel->move(desktop->screenGeometry(screen).topLeft());
904+ panel->setScreen(screen);
905 ++i;
906 }
907 }
908
909=== modified file 'panel/app/panelmanager.h'
910--- panel/app/panelmanager.h 2012-01-26 11:16:03 +0000
911+++ panel/app/panelmanager.h 2012-02-02 10:59:19 +0000
912@@ -44,8 +44,9 @@
913 QStringList loadPanelConfiguration() const;
914
915 private Q_SLOTS:
916- void onScreenCountChanged(int newCount);
917+ void updateScreenLayout(int newCount);
918 void onAltF10Pressed();
919+ void onScreenResized(int screen);
920 };
921
922 #endif // PanelManager_H
923
924=== modified file 'panel/applets/appname/windowhelper.cpp'
925--- panel/applets/appname/windowhelper.cpp 2012-01-24 13:03:34 +0000
926+++ panel/applets/appname/windowhelper.cpp 2012-02-02 10:59:19 +0000
927@@ -29,7 +29,6 @@
928 #include <dashclient.h>
929 #include <debug_p.h>
930 #include <gconnector.h>
931-#include <screeninfo.h>
932
933 // Bamf
934 #include <bamf-matcher.h>
935
936=== modified file 'places/app/dashdeclarativeview.cpp'
937--- places/app/dashdeclarativeview.cpp 2012-01-26 13:12:12 +0000
938+++ places/app/dashdeclarativeview.cpp 2012-02-02 10:59:19 +0000
939@@ -23,7 +23,6 @@
940 #include <dashclient.h>
941
942 // Qt
943-#include <QDesktopWidget>
944 #include <QApplication>
945 #include <QBitmap>
946 #include <QCloseEvent>
947@@ -55,20 +54,15 @@
948 setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
949 setTransparentBackground(QX11Info::isCompositingManagerRunning());
950
951- QDesktopWidget* desktop = QApplication::desktop();
952- connect(desktop, SIGNAL(resized(int)), SIGNAL(screenGeometryChanged()));
953- connect(desktop, SIGNAL(workAreaResized(int)), SLOT(onWorkAreaResized(int)));
954+ m_screenInfo = new ScreenInfo(ScreenInfo::TopLeft);
955+ connect(m_screenInfo, SIGNAL(availableGeometryChanged(QRect)), SLOT(onWorkAreaResized()));
956
957 updateSize();
958 }
959
960 void
961-DashDeclarativeView::onWorkAreaResized(int screen)
962+DashDeclarativeView::onWorkAreaResized()
963 {
964- if (QApplication::desktop()->screenNumber(this) != screen) {
965- return;
966- }
967-
968 updateSize();
969 }
970
971@@ -85,7 +79,7 @@
972 void
973 DashDeclarativeView::fitToAvailableSpace()
974 {
975- QRect rect = ScreenInfo::instance()->panelsFreeGeometry();
976+ QRect rect = m_screenInfo->panelsFreeGeometry();
977 move(rect.topLeft());
978 setFixedSize(rect.size());
979 }
980@@ -93,7 +87,7 @@
981 void
982 DashDeclarativeView::resizeToDesktopModeSize()
983 {
984- QRect rect = ScreenInfo::instance()->panelsFreeGeometry();
985+ QRect rect = m_screenInfo->panelsFreeGeometry();
986 int screenRight = rect.right();
987
988 rect.setWidth(qMin(DASH_DESKTOP_WIDTH, rect.width()));
989
990=== modified file 'places/app/dashdeclarativeview.h'
991--- places/app/dashdeclarativeview.h 2012-01-24 12:35:44 +0000
992+++ places/app/dashdeclarativeview.h 2012-02-02 10:59:19 +0000
993@@ -21,6 +21,7 @@
994 #include <unity2ddeclarativeview.h>
995
996 class LauncherClient;
997+class ScreenInfo;
998
999 class DashDeclarativeView : public Unity2DDeclarativeView
1000 {
1001@@ -67,7 +68,7 @@
1002 virtual void showEvent(QShowEvent *event);
1003
1004 private Q_SLOTS:
1005- void onWorkAreaResized(int screen);
1006+ void onWorkAreaResized();
1007 void updateSize();
1008
1009 private:
1010
1011=== modified file 'places/dash.qml'
1012--- places/dash.qml 2012-01-25 11:22:45 +0000
1013+++ places/dash.qml 2012-02-02 10:59:19 +0000
1014@@ -206,7 +206,7 @@
1015 BorderImage {
1016 anchors.fill: parent
1017 visible: dashView.dashMode == DashDeclarativeView.DesktopMode
1018- source: screen.isCompositingManagerRunning ? "artwork/desktop_dash_background.sci" : "artwork/desktop_dash_background_no_transparency.sci"
1019+ source: desktop.isCompositingManagerRunning ? "artwork/desktop_dash_background.sci" : "artwork/desktop_dash_background_no_transparency.sci"
1020 mirror: isRightToLeft()
1021 }
1022 }
1023
1024=== modified file 'spread/Workspace.qml'
1025--- spread/Workspace.qml 2011-10-21 12:46:08 +0000
1026+++ spread/Workspace.qml 2012-02-02 10:59:19 +0000
1027@@ -54,8 +54,8 @@
1028
1029 clip: true
1030 cached: false
1031- offsetX: -screen.panelsFreeGeometry.x
1032- offsetY: -screen.panelsFreeGeometry.y
1033+ offsetX: -declarativeView.screen.panelsFreeGeometry.x
1034+ offsetY: -declarativeView.screen.panelsFreeGeometry.y
1035 }
1036
1037 Windows {
1038
1039=== modified file 'spread/Workspaces.qml'
1040--- spread/Workspaces.qml 2011-12-06 19:37:23 +0000
1041+++ spread/Workspaces.qml 2012-02-02 10:59:19 +0000
1042@@ -25,8 +25,8 @@
1043
1044 color: "black"
1045
1046- property int columns: screen.workspaces.columns
1047- property int rows: screen.workspaces.rows
1048+ property int columns: desktop.workspaces.columns
1049+ property int rows: desktop.workspaces.rows
1050
1051 property int margin: 35
1052 property int spacing: 4
1053@@ -57,7 +57,7 @@
1054
1055 /* Scale of a workspace when the user zooms on it (fills most of the switcher, leaving a margin to see
1056 the corners of the other workspaces below it) */
1057- property bool isDesktopHorizontal: screen.panelsFreeGeometry.width > screen.panelsFreeGeometry.height
1058+ property bool isDesktopHorizontal: declarativeView.screen.panelsFreeGeometry.width > declarativeView.screen.panelsFreeGeometry.height
1059 property real zoomedScale: (isDesktopHorizontal) ? ((width - 2*margin) / switcher.width) :
1060 ((height - 2*margin) / switcher.height)
1061
1062@@ -85,7 +85,7 @@
1063 width: cellWidth * columns
1064 height: cellHeight * rows
1065
1066- model: screen.workspaces.count
1067+ model: desktop.workspaces.count
1068 cellWidth: parent.cellWidth + spacing
1069 cellHeight: parent.cellHeight + spacing
1070 keyNavigationWraps: true
1071@@ -136,7 +136,7 @@
1072 }
1073 state: {
1074 if (initial) {
1075- if (screen.workspaces.current == workspaceNumber) {
1076+ if (desktop.workspaces.current == workspaceNumber) {
1077 return "screen"
1078 } else {
1079 return "unzoomed"
1080@@ -189,12 +189,12 @@
1081 /* Setup application pre-filtering and initially zoomed desktop, if any
1082 were specified as arguments */
1083 applicationFilter = applicationDesktopFile
1084- zoomedWorkspace = screen.workspaces.current
1085+ zoomedWorkspace = desktop.workspaces.current
1086 show()
1087 }
1088
1089 onShowAllWorkspaces: {
1090- if (screen.workspaces.count > 1) {
1091+ if (desktop.workspaces.count > 1) {
1092 applicationFilter = applicationDesktopFile
1093 zoomedWorkspace = -1
1094 show()
1095@@ -211,13 +211,13 @@
1096 function show() {
1097 /* Save the currently active window before showing and activating the switcher,
1098 so that we can use it to pre-select the active window on the workspace */
1099- lastActiveWindow = screen.activeWindow
1100+ lastActiveWindow = desktop.activeWindow
1101
1102 allWindows.load()
1103
1104 spreadView.show()
1105 spreadView.forceActivateWindow()
1106- workspaces.currentIndex = screen.workspaces.current
1107+ workspaces.currentIndex = desktop.workspaces.current
1108 /* This is necessary otherwise we don't get keypresses until the user does a
1109 mouse over on a window */
1110 workspaces.forceActiveFocus()
1111@@ -280,13 +280,13 @@
1112 }
1113
1114 function activateWindow(windowInfo) {
1115- screen.workspaces.changeCurrent(zoomedWorkspace)
1116+ desktop.workspaces.changeCurrent(zoomedWorkspace)
1117 windowInfo.activate()
1118 cancelAndExit()
1119 }
1120
1121 function activateWorkspace(workspaceNumber) {
1122- screen.workspaces.changeCurrent(workspaceNumber)
1123+ desktop.workspaces.changeCurrent(workspaceNumber)
1124 cancelAndExit()
1125 }
1126 }
1127
1128=== modified file 'spread/app/spread.cpp'
1129--- spread/app/spread.cpp 2011-11-11 15:52:49 +0000
1130+++ spread/app/spread.cpp 2012-02-02 10:59:19 +0000
1131@@ -66,10 +66,5 @@
1132 view.rootContext()->setContextProperty("spreadView", &view);
1133 view.setSource(QUrl("./Workspaces.qml"));
1134
1135- /* Always match the size of the desktop */
1136- int current_screen = QApplication::desktop()->screenNumber(&view);
1137- view.fitToAvailableSpace(current_screen);
1138- QObject::connect(QApplication::desktop(), SIGNAL(workAreaResized(int)), &view, SLOT(fitToAvailableSpace(int)));
1139-
1140 return application.exec();
1141 }
1142
1143=== modified file 'spread/app/spreadview.cpp'
1144--- spread/app/spreadview.cpp 2011-12-08 18:39:18 +0000
1145+++ spread/app/spreadview.cpp 2012-02-02 10:59:19 +0000
1146@@ -28,19 +28,17 @@
1147 SpreadView::SpreadView()
1148 : Unity2DDeclarativeView()
1149 {
1150+ m_screenInfo = new ScreenInfo(ScreenInfo::TopLeft);
1151+ connect(m_screenInfo, SIGNAL(availableGeometryChanged(QRect)), SLOT(fitToAvailableSpace()));
1152+
1153+ fitToAvailableSpace();
1154 }
1155
1156-void SpreadView::fitToAvailableSpace(int screen)
1157+void SpreadView::fitToAvailableSpace()
1158 {
1159- QDesktopWidget *desktop = QApplication::desktop();
1160- int current_screen = desktop->screenNumber(this);
1161-
1162- if(screen == current_screen)
1163- {
1164- QRect geometry = ScreenInfo::instance()->panelsFreeGeometry();
1165- setGeometry(geometry);
1166- setFixedSize(geometry.size());
1167- }
1168+ QRect geometry = m_screenInfo->panelsFreeGeometry();
1169+ setGeometry(geometry);
1170+ setFixedSize(geometry.size());
1171 }
1172
1173 /* To be able to call grabMouse() we need to be 100% sure that X11 did
1174
1175=== modified file 'spread/app/spreadview.h'
1176--- spread/app/spreadview.h 2011-12-08 18:39:18 +0000
1177+++ spread/app/spreadview.h 2012-02-02 10:59:19 +0000
1178@@ -34,7 +34,7 @@
1179
1180 public Q_SLOTS:
1181 /* FIXME: copied from places/app/dashdeclarativeview.h */
1182- void fitToAvailableSpace(int screen);
1183+ void fitToAvailableSpace();
1184
1185 protected:
1186 virtual void focusInEvent( QFocusEvent * event );

Subscribers

People subscribed via source and target branches