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

Proposed by Michał Sawicz
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) Approve
Albert Astals Cid (community) Needs Fixing
Florian Boucault 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.
Revision history for this message
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

Revision history for this message
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

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

884. By Michał Sawicz

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

885. By Michał Sawicz

[panel] use ScreenInfo to move panels around

886. By Michał Sawicz

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

887. By Michał Sawicz

[lib] remove dead code from DesktopInfo

888. By Michał Sawicz

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

889. By Michał Sawicz

[lib] fix getter in Unity2dPanel

890. By Michał Sawicz

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

891. By Michał Sawicz

[launcher] instantiate a ScreenInfo for LauncherView

Revision history for this message
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.

Revision history for this message
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
Revision history for this message
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
Revision history for this message
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.

Revision history for this message
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

[lib] clean up unused ENUMS in DesktopInfo

893. By Michał Sawicz

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

Revision history for this message
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
=== modified file 'launcher/Launcher.qml'
--- launcher/Launcher.qml 2011-12-11 22:26:34 +0000
+++ launcher/Launcher.qml 2012-02-02 10:59:19 +0000
@@ -56,7 +56,7 @@
56 anchors.fill: parent56 anchors.fill: parent
57 overlay_color: "black"57 overlay_color: "black"
58 overlay_alpha: 0.6658 overlay_alpha: 0.66
59 visible: !screen.isCompositingManagerRunning59 visible: !desktop.isCompositingManagerRunning
60 }60 }
61 }61 }
6262
@@ -65,7 +65,7 @@
65 anchors.fill: parent65 anchors.fill: parent
66 color: "black"66 color: "black"
67 opacity: 0.6667 opacity: 0.66
68 visible: screen.isCompositingManagerRunning68 visible: desktop.isCompositingManagerRunning
69 }69 }
70 70
71 Image {71 Image {
7272
=== modified file 'launcher/app/launcher.cpp'
--- launcher/app/launcher.cpp 2011-12-01 09:55:45 +0000
+++ launcher/app/launcher.cpp 2012-02-02 10:59:19 +0000
@@ -37,6 +37,7 @@
37#include "unity2ddebug.h"37#include "unity2ddebug.h"
38#include "unity2dpanel.h"38#include "unity2dpanel.h"
39#include "gesturehandler.h"39#include "gesturehandler.h"
40#include "screeninfo.h"
4041
41// libc42// libc
42#include <stdlib.h>43#include <stdlib.h>
@@ -82,8 +83,8 @@
82 with that prefix resolves properly. */83 with that prefix resolves properly. */
83 QDir::addSearchPath("artwork", unity2dDirectory() + "/launcher/artwork");84 QDir::addSearchPath("artwork", unity2dDirectory() + "/launcher/artwork");
8485
85 /* Panel containing the QML declarative view */86 /* Panel containing the QML declarative view, topleft screen */
86 Unity2dPanel panel(true);87 Unity2dPanel panel(true, -1, ScreenInfo::TopLeft);
8788
88 panel.setEdge(Unity2dPanel::LeftEdge);89 panel.setEdge(Unity2dPanel::LeftEdge);
89 panel.setFixedWidth(LauncherClient::MaximumWidth);90 panel.setFixedWidth(LauncherClient::MaximumWidth);
9091
=== modified file 'launcher/app/launcherview.cpp'
--- launcher/app/launcherview.cpp 2011-11-25 11:13:44 +0000
+++ launcher/app/launcherview.cpp 2012-02-02 10:59:19 +0000
@@ -41,6 +41,7 @@
41#include <hotkey.h>41#include <hotkey.h>
42#include <hotkeymonitor.h>42#include <hotkeymonitor.h>
43#include <keymonitor.h>43#include <keymonitor.h>
44#include <screeninfo.h>
44#include <debug_p.h>45#include <debug_p.h>
45#include <config.h>46#include <config.h>
4647
@@ -69,6 +70,8 @@
69 connect(&m_superKeyHoldTimer, SIGNAL(timeout()), SLOT(updateSuperKeyHoldState()));70 connect(&m_superKeyHoldTimer, SIGNAL(timeout()), SLOT(updateSuperKeyHoldState()));
70 connect(this, SIGNAL(superKeyTapped()), SLOT(toggleDash()));71 connect(this, SIGNAL(superKeyTapped()), SLOT(toggleDash()));
7172
73 m_screenInfo = new ScreenInfo(ScreenInfo::TopLeft);
74
72 connect(&launcher2dConfiguration(), SIGNAL(superKeyEnableChanged(bool)), SLOT(updateSuperKeyMonitoring()));75 connect(&launcher2dConfiguration(), SIGNAL(superKeyEnableChanged(bool)), SLOT(updateSuperKeyMonitoring()));
73 updateSuperKeyMonitoring();76 updateSuperKeyMonitoring();
7477
7578
=== modified file 'libunity-2d-private/Unity2d/GnomeBackground.qml'
--- libunity-2d-private/Unity2d/GnomeBackground.qml 2011-12-07 02:15:57 +0000
+++ libunity-2d-private/Unity2d/GnomeBackground.qml 2012-02-02 10:59:19 +0000
@@ -80,8 +80,8 @@
80 else80 else
81 return filename81 return filename
82 }82 }
83 width: screen.geometry.width83 width: declarativeView.screen.geometry.width
84 height: screen.geometry.height84 height: declarativeView.screen.geometry.height
8585
86 smooth: true86 smooth: true
8787
8888
=== modified file 'libunity-2d-private/Unity2d/plugin.cpp'
--- libunity-2d-private/Unity2d/plugin.cpp 2012-01-24 16:46:52 +0000
+++ libunity-2d-private/Unity2d/plugin.cpp 2012-02-02 10:59:19 +0000
@@ -36,6 +36,7 @@
36#include "windowinfo.h"36#include "windowinfo.h"
37#include "windowslist.h"37#include "windowslist.h"
38#include "screeninfo.h"38#include "screeninfo.h"
39#include "desktopinfo.h"
39#include "plugin.h"40#include "plugin.h"
40#include "cacheeffect.h"41#include "cacheeffect.h"
41#include "iconutilities.h"42#include "iconutilities.h"
@@ -100,7 +101,8 @@
100101
101 qmlRegisterType<WindowInfo>(uri, 0, 1, "WindowInfo");102 qmlRegisterType<WindowInfo>(uri, 0, 1, "WindowInfo");
102 qmlRegisterType<WindowsList>(uri, 0, 1, "WindowsList");103 qmlRegisterType<WindowsList>(uri, 0, 1, "WindowsList");
103 qmlRegisterType<ScreenInfo>(); // Register the type as non creatable104 qmlRegisterType<ScreenInfo>(uri, 0, 1, "ScreenInfo");
105 qmlRegisterType<DesktopInfo>(); // Register the type as non creatable
104 qmlRegisterType<WorkspacesInfo>(); // Register the type as non creatable106 qmlRegisterType<WorkspacesInfo>(); // Register the type as non creatable
105107
106 qmlRegisterType<CacheEffect>(uri, 0, 1, "CacheEffect");108 qmlRegisterType<CacheEffect>(uri, 0, 1, "CacheEffect");
@@ -173,7 +175,7 @@
173175
174 /* ScreenInfo is exposed as a context property as it's a singleton and therefore176 /* ScreenInfo is exposed as a context property as it's a singleton and therefore
175 not creatable directly in QML */177 not creatable directly in QML */
176 engine->rootContext()->setContextProperty("screen", ScreenInfo::instance());178 engine->rootContext()->setContextProperty("desktop", DesktopInfo::instance());
177 engine->rootContext()->setContextProperty("iconUtilities", new IconUtilities(engine));179 engine->rootContext()->setContextProperty("iconUtilities", new IconUtilities(engine));
178180
179 /* Expose QConf objects as a context property not to initialize it multiple times */181 /* Expose QConf objects as a context property not to initialize it multiple times */
180182
=== modified file 'libunity-2d-private/src/CMakeLists.txt'
--- libunity-2d-private/src/CMakeLists.txt 2012-01-24 11:50:38 +0000
+++ libunity-2d-private/src/CMakeLists.txt 2012-02-02 10:59:19 +0000
@@ -34,6 +34,7 @@
34 windowinfo.cpp34 windowinfo.cpp
35 windowslist.cpp35 windowslist.cpp
36 screeninfo.cpp36 screeninfo.cpp
37 desktopinfo.cpp
37 cacheeffect.cpp38 cacheeffect.cpp
38 workspacesinfo.cpp39 workspacesinfo.cpp
39 signalwaiter.cpp40 signalwaiter.cpp
4041
=== modified file 'libunity-2d-private/src/dashclient.cpp'
--- libunity-2d-private/src/dashclient.cpp 2012-01-27 11:34:36 +0000
+++ libunity-2d-private/src/dashclient.cpp 2012-02-02 10:59:19 +0000
@@ -179,7 +179,7 @@
179 if (unity2dConfiguration().property("formFactor").toString() != "desktop") {179 if (unity2dConfiguration().property("formFactor").toString() != "desktop") {
180 alwaysFullScreen = true;180 alwaysFullScreen = true;
181 } else {181 } else {
182 QRect rect = QApplication::desktop()->screenGeometry();182 QRect rect = QApplication::desktop()->screenGeometry(QPoint());
183 QSize minSize = minimumSizeForDesktop();183 QSize minSize = minimumSizeForDesktop();
184 alwaysFullScreen = rect.width() < minSize.width() && rect.height() < minSize.height();184 alwaysFullScreen = rect.width() < minSize.width() && rect.height() < minSize.height();
185 }185 }
186186
=== renamed file 'libunity-2d-private/src/screeninfo.cpp' => 'libunity-2d-private/src/desktopinfo.cpp'
--- libunity-2d-private/src/screeninfo.cpp 2011-12-07 17:50:45 +0000
+++ libunity-2d-private/src/desktopinfo.cpp 2012-02-02 10:59:19 +0000
@@ -8,109 +8,28 @@
88
9#include "config.h"9#include "config.h"
10#include "launcherclient.h"10#include "launcherclient.h"
11#include "screeninfo.h"11#include "desktopinfo.h"
12#include "workspacesinfo.h"12#include "workspacesinfo.h"
1313
14#include <QX11Info>14#include <QX11Info>
15#include <QApplication>15#include <QApplication>
16#include <QDesktopWidget>16#include <QDesktopWidget>
1717
18ScreenInfo::ScreenInfo(QObject *parent) :18DesktopInfo::DesktopInfo(QObject *parent) :
19 QObject(parent),19 QObject(parent)
20 m_activeWindow(0)
21{20{
22 WnckScreen *screen = wnck_screen_get_default();
23 g_signal_connect(G_OBJECT(screen), "active-window-changed",
24 G_CALLBACK(ScreenInfo::onActiveWindowChanged), NULL);
25
26 updateActiveWindow(screen);
27
28 connect(QApplication::desktop(), SIGNAL(resized(int)),
29 SLOT(updateGeometry(int)));
30 connect(QApplication::desktop(), SIGNAL(workAreaResized(int)),
31 SLOT(updateAvailableGeometry(int)));
32}21}
3322
3423
35ScreenInfo* ScreenInfo::instance()24DesktopInfo* DesktopInfo::instance()
36{25{
37 static ScreenInfo* singleton = new ScreenInfo();26 static DesktopInfo* singleton = new DesktopInfo();
38 return singleton;27 return singleton;
39}28}
4029
41void ScreenInfo::onActiveWindowChanged(WnckScreen *screen,30bool DesktopInfo::isCompositingManagerRunning() const
42 WnckWindow *previously_active_window,
43 gpointer user_data)
44{
45 Q_UNUSED(previously_active_window);
46 Q_UNUSED(user_data);
47
48 ScreenInfo::instance()->updateActiveWindow(screen);
49}
50
51void ScreenInfo::updateActiveWindow(WnckScreen *screen)
52{
53 unsigned int activeWindow = 0;
54 WnckWindow *wnckActiveWindow = wnck_screen_get_active_window(screen);
55 if (wnckActiveWindow != NULL) {
56 activeWindow = wnck_window_get_xid(wnckActiveWindow);
57 }
58
59 if (activeWindow != m_activeWindow) {
60 m_activeWindow = activeWindow;
61 Q_EMIT activeWindowChanged(m_activeWindow);
62 }
63}
64
65QRect ScreenInfo::availableGeometry() const
66{
67 int screen = QX11Info::appScreen();
68 return QApplication::desktop()->availableGeometry(screen);
69}
70
71QRect ScreenInfo::panelsFreeGeometry() const
72{
73 /* We cannot just return the system's availableGeometry(), because that
74 * doesn't consider the Launcher, if it's set to auto-hide. */
75 int screen = QX11Info::appScreen();
76 QRect screenRect = QApplication::desktop()->screenGeometry(screen);
77 QRect availableRect = QApplication::desktop()->availableGeometry(screen);
78
79 QRect availableGeometry(
80 LauncherClient::MaximumWidth,
81 availableRect.top(),
82 screenRect.width() - LauncherClient::MaximumWidth,
83 availableRect.height()
84 );
85 if (QApplication::isRightToLeft()) {
86 availableGeometry.moveLeft(0);
87 }
88 return availableGeometry;
89}
90
91QRect ScreenInfo::geometry() const
92{
93 return QApplication::desktop()->screenGeometry(QX11Info::appScreen());
94}
95
96void ScreenInfo::updateGeometry(int screen)
97{
98 if (screen == QX11Info::appScreen()) {
99 Q_EMIT geometryChanged(geometry());
100 }
101}
102
103void ScreenInfo::updateAvailableGeometry(int screen)
104{
105 if (screen == QX11Info::appScreen()) {
106 Q_EMIT availableGeometryChanged(availableGeometry());
107 Q_EMIT panelsFreeGeometryChanged(panelsFreeGeometry());
108 }
109}
110
111bool ScreenInfo::isCompositingManagerRunning() const
112{31{
113 return QX11Info::isCompositingManagerRunning();32 return QX11Info::isCompositingManagerRunning();
114}33}
11534
116#include "screeninfo.moc"35#include "desktopinfo.moc"
11736
=== renamed file 'libunity-2d-private/src/screeninfo.h' => 'libunity-2d-private/src/desktopinfo.h'
--- libunity-2d-private/src/screeninfo.h 2011-12-07 17:50:45 +0000
+++ libunity-2d-private/src/desktopinfo.h 2012-02-02 10:59:19 +0000
@@ -1,5 +1,5 @@
1#ifndef SCREENINFO_H1#ifndef DESKTOPINFO_H
2#define SCREENINFO_H2#define DESKTOPINFO_H
33
4#include <QObject>4#include <QObject>
5#include <QRect>5#include <QRect>
@@ -10,7 +10,7 @@
10typedef struct _WnckScreen WnckScreen;10typedef struct _WnckScreen WnckScreen;
11typedef struct _WnckWindow WnckWindow;11typedef struct _WnckWindow WnckWindow;
1212
13class ScreenInfo : public QObject13class DesktopInfo : public QObject
14{14{
15 Q_OBJECT15 Q_OBJECT
1616
@@ -18,46 +18,25 @@
18 Q_ENUMS(WorkspacesCorner)18 Q_ENUMS(WorkspacesCorner)
1919
20 Q_PROPERTY(WorkspacesInfo *workspaces READ workspaces NOTIFY workspacesChanged)20 Q_PROPERTY(WorkspacesInfo *workspaces READ workspaces NOTIFY workspacesChanged)
21 Q_PROPERTY(unsigned int activeWindow READ activeWindow NOTIFY activeWindowChanged)
22 Q_PROPERTY(QRect geometry READ geometry NOTIFY geometryChanged)
23 Q_PROPERTY(QRect availableGeometry READ availableGeometry NOTIFY availableGeometryChanged)
24 Q_PROPERTY(QRect panelsFreeGeometry READ panelsFreeGeometry NOTIFY panelsFreeGeometryChanged)
25 Q_PROPERTY(bool isCompositingManagerRunning READ isCompositingManagerRunning21 Q_PROPERTY(bool isCompositingManagerRunning READ isCompositingManagerRunning
26 NOTIFY isCompositingManagerRunningChanged)22 NOTIFY isCompositingManagerRunningChanged)
2723
28public:24public:
29 static ScreenInfo* instance();25 static DesktopInfo* instance();
3026
31 /* Getters */27 /* Getters */
32 WorkspacesInfo *workspaces() { return &m_workspacesInfo; }28 WorkspacesInfo *workspaces() { return &m_workspacesInfo; }
33 unsigned int activeWindow() const { return m_activeWindow; }
34 QRect availableGeometry() const;
35 QRect panelsFreeGeometry() const;
36 QRect geometry() const;
37 bool isCompositingManagerRunning() const;29 bool isCompositingManagerRunning() const;
3830
39Q_SIGNALS:31Q_SIGNALS:
40 void activeWindowChanged(unsigned int activeWindow);
41 void geometryChanged(QRect geometry);
42 void availableGeometryChanged(QRect availableGeometry);
43 void panelsFreeGeometryChanged(QRect panelsFreeGeometry);
44 void workspacesChanged(WorkspacesInfo *workspaces);32 void workspacesChanged(WorkspacesInfo *workspaces);
45 void isCompositingManagerRunningChanged(bool);33 void isCompositingManagerRunningChanged(bool);
4634
47private:35private:
48 explicit ScreenInfo(QObject *parent = 0);36 explicit DesktopInfo(QObject *parent = 0);
49 void updateActiveWindow(WnckScreen *screen);
50
51 static void onActiveWindowChanged(WnckScreen *screen,
52 WnckWindow *previously_active_window,
53 gpointer user_data);
54private Q_SLOTS:
55 void updateGeometry(int screen);
56 void updateAvailableGeometry(int screen);
5737
58private:38private:
59 WorkspacesInfo m_workspacesInfo;39 WorkspacesInfo m_workspacesInfo;
60 unsigned int m_activeWindow;
61};40};
6241
63#endif // SCREENINFO_H42#endif // DESKTOPINFO_H
6443
=== added file 'libunity-2d-private/src/screeninfo.cpp'
--- libunity-2d-private/src/screeninfo.cpp 1970-01-01 00:00:00 +0000
+++ libunity-2d-private/src/screeninfo.cpp 2012-02-02 10:59:19 +0000
@@ -0,0 +1,211 @@
1#include "config.h"
2#include "launcherclient.h"
3#include "screeninfo.h"
4
5#include <QApplication>
6#include <QDesktopWidget>
7#include <QX11Info>
8
9ScreenInfo::ScreenInfo(QObject *parent) :
10 QObject(parent),
11 m_screen(QX11Info::appScreen()),
12 m_widget(NULL),
13 m_corner(InvalidCorner)
14{
15 connect(QApplication::desktop(), SIGNAL(resized(int)),
16 SLOT(updateGeometry(int)));
17 connect(QApplication::desktop(), SIGNAL(workAreaResized(int)),
18 SLOT(updateAvailableGeometry(int)));
19}
20
21ScreenInfo::ScreenInfo(int screen, QObject *parent) :
22 QObject(parent),
23 m_screen(screen),
24 m_widget(NULL),
25 m_corner(InvalidCorner)
26{
27 connect(QApplication::desktop(), SIGNAL(resized(int)),
28 SLOT(updateGeometry(int)));
29 connect(QApplication::desktop(), SIGNAL(workAreaResized(int)),
30 SLOT(updateAvailableGeometry(int)));
31}
32
33ScreenInfo::ScreenInfo(QWidget *widget, QObject *parent) :
34 QObject(parent),
35 m_screen(QApplication::desktop()->screenNumber(widget)),
36 m_widget(widget),
37 m_corner(InvalidCorner)
38{
39 m_widget->installEventFilter(this);
40 connect(QApplication::desktop(), SIGNAL(resized(int)),
41 SLOT(updateGeometry(int)));
42 connect(QApplication::desktop(), SIGNAL(workAreaResized(int)),
43 SLOT(updateAvailableGeometry(int)));
44}
45
46ScreenInfo::ScreenInfo(Corner corner, QObject *parent) :
47 QObject(parent),
48 m_screen(cornerScreen(corner)),
49 m_widget(NULL),
50 m_corner(corner)
51{
52 connect(QApplication::desktop(), SIGNAL(resized(int)),
53 SLOT(updateGeometry(int)));
54 connect(QApplication::desktop(), SIGNAL(workAreaResized(int)),
55 SLOT(updateAvailableGeometry(int)));
56}
57
58ScreenInfo::~ScreenInfo()
59{
60 if (m_widget) {
61 m_widget->removeEventFilter(this);
62 }
63}
64
65QRect ScreenInfo::availableGeometry() const
66{
67 return QApplication::desktop()->availableGeometry(m_screen);
68}
69
70QRect ScreenInfo::panelsFreeGeometry() const
71{
72 /* We cannot just return the system's availableGeometry(), because that
73 * doesn't consider the Launcher, if it's set to auto-hide. */
74 QRect screenRect = QApplication::desktop()->screenGeometry(m_screen);
75 QRect availableRect = QApplication::desktop()->availableGeometry(m_screen);
76
77 QRect availableGeometry(
78 LauncherClient::MaximumWidth,
79 availableRect.top(),
80 screenRect.width() - LauncherClient::MaximumWidth,
81 availableRect.height()
82 );
83 if (QApplication::isRightToLeft()) {
84 availableGeometry.moveLeft(0);
85 }
86 return availableGeometry;
87}
88
89QRect ScreenInfo::geometry() const
90{
91 return QApplication::desktop()->screenGeometry(m_screen);
92}
93
94void ScreenInfo::updateGeometry(int screen)
95{
96 if (m_corner != InvalidCorner) {
97 int screenCorner = cornerScreen(m_corner);
98 if (m_screen != screenCorner) {
99 setScreen(screenCorner);
100 return;
101 }
102 }
103 if (screen == m_screen) {
104 Q_EMIT geometryChanged(geometry());
105 }
106}
107
108void ScreenInfo::updateAvailableGeometry(int screen)
109{
110 if (screen == m_screen) {
111 Q_EMIT availableGeometryChanged(availableGeometry());
112 Q_EMIT panelsFreeGeometryChanged(panelsFreeGeometry());
113 }
114}
115
116void ScreenInfo::updateScreen()
117{
118 int screen;
119 if (m_corner != InvalidCorner) {
120 screen = cornerScreen(m_corner);
121 setScreen(screen);
122 } else if (m_widget) {
123 screen = QApplication::desktop()->screenNumber(m_widget);
124 setScreen(screen);
125 }
126}
127
128int
129ScreenInfo::cornerScreen(Corner corner)
130{
131 QDesktopWidget* desktop = QApplication::desktop();
132 switch(corner) {
133 case TopLeft:
134 return desktop->screenNumber(QPoint());
135 case TopRight:
136 return desktop->screenNumber(QPoint(desktop->width(), 0));
137 case BottomLeft:
138 return desktop->screenNumber(QPoint(0, desktop->height()));
139 case BottomRight:
140 return desktop->screenNumber(QPoint(desktop->width(), desktop->height()));
141 default:
142 return desktop->screenNumber(QPoint());
143 }
144}
145
146bool
147ScreenInfo::eventFilter(QObject *object, QEvent *event)
148{
149 Q_UNUSED(object);
150
151 if (event->type() == QEvent::Move || event->type() == QEvent::Show) {
152 updateScreen();
153 }
154 return QObject::eventFilter(object, event);
155}
156
157int
158ScreenInfo::screen() const
159{
160 return m_screen;
161}
162
163void
164ScreenInfo::setScreen(int screen)
165{
166 if (m_screen != screen) {
167 m_screen = screen;
168 Q_EMIT screenChanged(m_screen);
169 Q_EMIT geometryChanged(geometry());
170 Q_EMIT availableGeometryChanged(availableGeometry());
171 Q_EMIT panelsFreeGeometryChanged(panelsFreeGeometry());
172 }
173}
174
175QWidget*
176ScreenInfo::widget() const
177{
178 return m_widget;
179}
180
181void
182ScreenInfo::setWidget(QWidget *widget)
183{
184 if (m_widget != widget) {
185 m_widget->removeEventFilter(this);
186 m_widget = widget;
187 if (m_widget) {
188 m_widget->installEventFilter(this);
189 }
190 Q_EMIT widgetChanged(m_widget);
191 updateScreen();
192 }
193}
194
195ScreenInfo::Corner
196ScreenInfo::corner() const
197{
198 return m_corner;
199}
200
201void
202ScreenInfo::setCorner(Corner corner)
203{
204 if (m_corner != corner) {
205 m_corner = corner;
206 Q_EMIT cornerChanged(corner);
207 updateScreen();
208 }
209}
210
211#include "screeninfo.moc"
0212
=== added file 'libunity-2d-private/src/screeninfo.h'
--- libunity-2d-private/src/screeninfo.h 1970-01-01 00:00:00 +0000
+++ libunity-2d-private/src/screeninfo.h 2012-02-02 10:59:19 +0000
@@ -0,0 +1,72 @@
1#ifndef SCREENINFO_H
2#define SCREENINFO_H
3
4#include <QObject>
5#include <QRect>
6
7class QEvent;
8class QWidget;
9
10class ScreenInfo : public QObject
11{
12 Q_OBJECT
13
14 Q_PROPERTY(QRect geometry READ geometry NOTIFY geometryChanged)
15 Q_PROPERTY(QRect availableGeometry READ availableGeometry NOTIFY availableGeometryChanged)
16 Q_PROPERTY(QRect panelsFreeGeometry READ panelsFreeGeometry NOTIFY panelsFreeGeometryChanged)
17 Q_PROPERTY(int screen READ screen WRITE setScreen NOTIFY screenChanged)
18 Q_PROPERTY(QWidget* widget READ widget WRITE setWidget NOTIFY widgetChanged)
19 Q_PROPERTY(Corner corner READ corner WRITE setCorner NOTIFY cornerChanged)
20
21public:
22 enum Corner {
23 InvalidCorner,
24 TopLeft,
25 TopRight,
26 BottomLeft,
27 BottomRight
28 };
29
30 /* Getters */
31 explicit ScreenInfo(QObject *parent = 0);
32 ScreenInfo(QWidget* widget, QObject *parent = 0);
33 ScreenInfo(int screen, QObject *parent = 0);
34 ScreenInfo(Corner corner, QObject *parent = 0);
35 ~ScreenInfo();
36 QRect availableGeometry() const;
37 QRect panelsFreeGeometry() const;
38 QRect geometry() const;
39 int screen() const;
40 QWidget* widget() const;
41 Corner corner() const;
42
43 /* Setters */
44 void setScreen(int screen);
45 void setWidget(QWidget* widget);
46 void setCorner(Corner corner);
47
48
49protected:
50 bool eventFilter(QObject *object, QEvent *event);
51
52Q_SIGNALS:
53 void geometryChanged(QRect geometry);
54 void availableGeometryChanged(QRect availableGeometry);
55 void panelsFreeGeometryChanged(QRect panelsFreeGeometry);
56 void screenChanged(int screen);
57 void widgetChanged(QWidget* widget);
58 void cornerChanged(Corner corner);
59
60private Q_SLOTS:
61 void updateGeometry(int screen);
62 void updateAvailableGeometry(int screen);
63
64private:
65 void updateScreen();
66 int cornerScreen(Corner corner);
67 int m_screen;
68 QWidget* m_widget;
69 Corner m_corner;
70};
71
72#endif // SCREENINFO_H
073
=== modified file 'libunity-2d-private/src/unity2ddeclarativeview.cpp'
--- libunity-2d-private/src/unity2ddeclarativeview.cpp 2011-12-08 19:41:38 +0000
+++ libunity-2d-private/src/unity2ddeclarativeview.cpp 2012-02-02 10:59:19 +0000
@@ -28,6 +28,8 @@
28#include <debug_p.h>28#include <debug_p.h>
29#include <config.h>29#include <config.h>
3030
31#include "screeninfo.h"
32
31// libwnck33// libwnck
32extern "C" {34extern "C" {
33#include <libwnck/libwnck.h>35#include <libwnck/libwnck.h>
@@ -265,4 +267,10 @@
265 m_last_focused_window = None;267 m_last_focused_window = None;
266}268}
267269
270ScreenInfo*
271Unity2DDeclarativeView::screen() const
272{
273 return m_screenInfo;
274}
275
268#include <unity2ddeclarativeview.moc>276#include <unity2ddeclarativeview.moc>
269277
=== modified file 'libunity-2d-private/src/unity2ddeclarativeview.h'
--- libunity-2d-private/src/unity2ddeclarativeview.h 2011-12-08 19:41:38 +0000
+++ libunity-2d-private/src/unity2ddeclarativeview.h 2012-02-02 10:59:19 +0000
@@ -19,6 +19,8 @@
1919
20#include <QDeclarativeView>20#include <QDeclarativeView>
2121
22class ScreenInfo;
23
22class Unity2DDeclarativeView : public QDeclarativeView24class Unity2DDeclarativeView : public QDeclarativeView
23{25{
24 Q_OBJECT26 Q_OBJECT
@@ -26,6 +28,7 @@
26 Q_PROPERTY(bool useOpenGL READ useOpenGL WRITE setUseOpenGL NOTIFY useOpenGLChanged)28 Q_PROPERTY(bool useOpenGL READ useOpenGL WRITE setUseOpenGL NOTIFY useOpenGLChanged)
27 Q_PROPERTY(bool transparentBackground READ transparentBackground WRITE setTransparentBackground NOTIFY transparentBackgroundChanged)29 Q_PROPERTY(bool transparentBackground READ transparentBackground WRITE setTransparentBackground NOTIFY transparentBackgroundChanged)
28 Q_PROPERTY(QPoint globalPosition READ globalPosition NOTIFY globalPositionChanged)30 Q_PROPERTY(QPoint globalPosition READ globalPosition NOTIFY globalPositionChanged)
31 Q_PROPERTY(ScreenInfo* screen READ screen NOTIFY screenChanged)
2932
30public:33public:
31 Unity2DDeclarativeView(QWidget *parent = 0);34 Unity2DDeclarativeView(QWidget *parent = 0);
@@ -35,6 +38,7 @@
35 bool useOpenGL() const;38 bool useOpenGL() const;
36 bool transparentBackground() const;39 bool transparentBackground() const;
37 QPoint globalPosition() const;40 QPoint globalPosition() const;
41 ScreenInfo* screen() const;
3842
39 // setters43 // setters
40 void setUseOpenGL(bool);44 void setUseOpenGL(bool);
@@ -44,10 +48,12 @@
44 void useOpenGLChanged(bool);48 void useOpenGLChanged(bool);
45 void transparentBackgroundChanged(bool);49 void transparentBackgroundChanged(bool);
46 void globalPositionChanged(QPoint);50 void globalPositionChanged(QPoint);
51 void screenChanged(ScreenInfo*);
4752
48protected:53protected:
49 void setupViewport();54 void setupViewport();
50 virtual void moveEvent(QMoveEvent* event);55 virtual void moveEvent(QMoveEvent* event);
56 ScreenInfo* m_screenInfo;
5157
52protected Q_SLOTS:58protected Q_SLOTS:
53 void forceActivateWindow();59 void forceActivateWindow();
5460
=== modified file 'libunity-2d-private/src/unity2dpanel.cpp'
--- libunity-2d-private/src/unity2dpanel.cpp 2011-11-05 21:14:08 +0000
+++ libunity-2d-private/src/unity2dpanel.cpp 2012-02-02 10:59:19 +0000
@@ -36,6 +36,9 @@
36#include <X11/Xlib.h>36#include <X11/Xlib.h>
37#include <X11/Xatom.h>37#include <X11/Xatom.h>
3838
39// unity-2d
40#include "screeninfo.h"
41
39static const int SLIDE_DURATION = 125;42static const int SLIDE_DURATION = 125;
4043
41struct Unity2dPanelPrivate44struct Unity2dPanelPrivate
@@ -49,6 +52,7 @@
49 bool m_useStrut;52 bool m_useStrut;
50 int m_delta;53 int m_delta;
51 bool m_manualSliding;54 bool m_manualSliding;
55 ScreenInfo* m_screenInfo;
5256
53 void setStrut(ulong* struts)57 void setStrut(ulong* struts)
54 {58 {
@@ -96,9 +100,8 @@
96100
97 void updateGeometry()101 void updateGeometry()
98 {102 {
99 QDesktopWidget* desktop = QApplication::desktop();103 const QRect screen = m_screenInfo->geometry();
100 const QRect screen = desktop->screenGeometry(q);104 const QRect available = m_screenInfo->availableGeometry();
101 const QRect available = desktop->availableGeometry(q);
102105
103 QRect rect;106 QRect rect;
104 switch (m_edge) {107 switch (m_edge) {
@@ -144,7 +147,7 @@
144 }147 }
145};148};
146149
147Unity2dPanel::Unity2dPanel(bool requiresTransparency, QWidget* parent)150Unity2dPanel::Unity2dPanel(bool requiresTransparency, int screen, ScreenInfo::Corner corner, QWidget* parent)
148: QWidget(parent)151: QWidget(parent)
149, d(new Unity2dPanelPrivate)152, d(new Unity2dPanelPrivate)
150{153{
@@ -157,6 +160,13 @@
157 d->m_layout = new QHBoxLayout(this);160 d->m_layout = new QHBoxLayout(this);
158 d->m_layout->setMargin(0);161 d->m_layout->setMargin(0);
159 d->m_layout->setSpacing(0);162 d->m_layout->setSpacing(0);
163 if (corner != ScreenInfo::InvalidCorner) {
164 d->m_screenInfo = new ScreenInfo(corner);
165 } else if (screen >= 0) {
166 d->m_screenInfo = new ScreenInfo(screen);
167 } else {
168 d->m_screenInfo = new ScreenInfo(this);
169 }
160170
161 d->m_slideInAnimation = new QPropertyAnimation(this);171 d->m_slideInAnimation = new QPropertyAnimation(this);
162 d->m_slideInAnimation->setTargetObject(this);172 d->m_slideInAnimation->setTargetObject(this);
@@ -203,6 +213,16 @@
203 return d->m_edge;213 return d->m_edge;
204}214}
205215
216void Unity2dPanel::setScreen(int screen)
217{
218 d->m_screenInfo->setScreen(screen);
219}
220
221int Unity2dPanel::screen() const
222{
223 return d->m_screenInfo->screen();
224}
225
206IndicatorsManager* Unity2dPanel::indicatorsManager() const226IndicatorsManager* Unity2dPanel::indicatorsManager() const
207{227{
208 if (d->m_indicatorsManager == 0) {228 if (d->m_indicatorsManager == 0) {
209229
=== modified file 'libunity-2d-private/src/unity2dpanel.h'
--- libunity-2d-private/src/unity2dpanel.h 2011-10-12 16:54:18 +0000
+++ libunity-2d-private/src/unity2dpanel.h 2012-02-02 10:59:19 +0000
@@ -29,6 +29,8 @@
29#include <QWidget>29#include <QWidget>
30#include <QEvent>30#include <QEvent>
3131
32#include "screeninfo.h"
33
32struct Unity2dPanelPrivate;34struct Unity2dPanelPrivate;
33class Unity2dPanel : public QWidget35class Unity2dPanel : public QWidget
34{36{
@@ -54,12 +56,16 @@
5456
55 static const QEvent::Type SHOW_FIRST_MENU_EVENT = QEvent::User;57 static const QEvent::Type SHOW_FIRST_MENU_EVENT = QEvent::User;
5658
57 Unity2dPanel(bool requiresTransparency = false, QWidget* parent = 0);59 Unity2dPanel(bool requiresTransparency = false, int screen = -1,
60 ScreenInfo::Corner corner = ScreenInfo::InvalidCorner, QWidget* parent = 0);
58 ~Unity2dPanel();61 ~Unity2dPanel();
5962
60 void setEdge(Edge);63 void setEdge(Edge);
61 Edge edge() const;64 Edge edge() const;
6265
66 void setScreen(int);
67 int screen() const;
68
63 void addWidget(QWidget*);69 void addWidget(QWidget*);
6470
65 void addSpacer();71 void addSpacer();
6672
=== modified file 'libunity-2d-private/src/workspacesinfo.cpp'
--- libunity-2d-private/src/workspacesinfo.cpp 2011-11-10 17:53:54 +0000
+++ libunity-2d-private/src/workspacesinfo.cpp 2012-02-02 10:59:19 +0000
@@ -1,5 +1,5 @@
1#include "workspacesinfo.h"1#include "workspacesinfo.h"
2#include "screeninfo.h"2#include "desktopinfo.h"
3#include "signalwaiter.h"3#include "signalwaiter.h"
4#include <debug_p.h>4#include <debug_p.h>
55
@@ -74,9 +74,9 @@
7474
75 if (notify->atom == _NET_DESKTOP_LAYOUT ||75 if (notify->atom == _NET_DESKTOP_LAYOUT ||
76 notify->atom == _NET_NUMBER_OF_DESKTOPS) {76 notify->atom == _NET_NUMBER_OF_DESKTOPS) {
77 ScreenInfo::instance()->workspaces()->updateWorkspaceGeometry();77 DesktopInfo::instance()->workspaces()->updateWorkspaceGeometry();
78 } else if (notify->atom == _NET_CURRENT_DESKTOP) {78 } else if (notify->atom == _NET_CURRENT_DESKTOP) {
79 ScreenInfo::instance()->workspaces()->updateCurrentWorkspace();79 DesktopInfo::instance()->workspaces()->updateCurrentWorkspace();
80 }80 }
8181
82 return ret;82 return ret;
8383
=== modified file 'panel/app/panelmanager.cpp'
--- panel/app/panelmanager.cpp 2012-01-26 11:16:03 +0000
+++ panel/app/panelmanager.cpp 2012-02-02 10:59:19 +0000
@@ -116,14 +116,31 @@
116PanelManager::PanelManager(QObject* parent)116PanelManager::PanelManager(QObject* parent)
117: QObject(parent)117: QObject(parent)
118{118{
119 Unity2dPanel* panel;
119 QDesktopWidget* desktop = QApplication::desktop();120 QDesktopWidget* desktop = QApplication::desktop();
121
122 QPoint p;
123 if (QApplication::isRightToLeft()) {
124 p = QPoint(desktop->width() - 1, 0);
125 }
126 int leftmost = desktop->screenNumber(p);
127
128 panel = instantiatePanel(leftmost);
129 m_panels.append(panel);
130 panel->show();
131 panel->move(desktop->screenGeometry(leftmost).topLeft());
132
120 for(int i = 0; i < desktop->screenCount(); ++i) {133 for(int i = 0; i < desktop->screenCount(); ++i) {
121 Unity2dPanel* panel = instantiatePanel(i);134 if (i == leftmost) {
135 continue;
136 }
137 panel = instantiatePanel(i);
122 m_panels.append(panel);138 m_panels.append(panel);
123 panel->show();139 panel->show();
124 panel->move(desktop->screenGeometry(i).topLeft());140 panel->move(desktop->screenGeometry(i).topLeft());
125 }141 }
126 connect(desktop, SIGNAL(screenCountChanged(int)), SLOT(onScreenCountChanged(int)));142 connect(desktop, SIGNAL(screenCountChanged(int)), SLOT(updateScreenLayout(int)));
143 connect(desktop, SIGNAL(resized(int)), SLOT(onScreenResized(int)));
127144
128 /* A F10 keypress opens the first menu of the visible application or of the first145 /* A F10 keypress opens the first menu of the visible application or of the first
129 indicator on the panel */146 indicator on the panel */
@@ -138,7 +155,7 @@
138155
139Unity2dPanel* PanelManager::instantiatePanel(int screen)156Unity2dPanel* PanelManager::instantiatePanel(int screen)
140{157{
141 Unity2dPanel* panel = new Unity2dPanel;158 Unity2dPanel* panel = new Unity2dPanel(false, screen);
142 panel->setAccessibleName("Top Panel");159 panel->setAccessibleName("Top Panel");
143 panel->setEdge(Unity2dPanel::TopEdge);160 panel->setEdge(Unity2dPanel::TopEdge);
144 panel->setFixedHeight(24);161 panel->setFixedHeight(24);
@@ -181,7 +198,25 @@
181}198}
182199
183void200void
184PanelManager::onScreenCountChanged(int newCount)201PanelManager::onScreenResized(int screen)
202{
203 QPoint p;
204 QDesktopWidget* desktop = QApplication::desktop();
205 if (QApplication::isRightToLeft()) {
206 p = QPoint(desktop->width() - 1, 0);
207 }
208 int leftmost = desktop->screenNumber(p);
209
210 /* We only care about the leftmost screen being resized,
211 because there is no screenLayoutChanged signal, we're
212 abusing it here so that we update the panels */
213 if (screen == leftmost) {
214 updateScreenLayout(desktop->screenCount());
215 }
216}
217
218void
219PanelManager::updateScreenLayout(int newCount)
185{220{
186 if (newCount > 0) {221 if (newCount > 0) {
187 QDesktopWidget* desktop = QApplication::desktop();222 QDesktopWidget* desktop = QApplication::desktop();
@@ -197,7 +232,7 @@
197 m_panels.append(panel);232 m_panels.append(panel);
198 }233 }
199 panel->show();234 panel->show();
200 panel->move(desktop->screenGeometry(leftmost).topLeft());235 panel->setScreen(leftmost);
201236
202 /* Update the position of other existing panels, and instantiate new237 /* Update the position of other existing panels, and instantiate new
203 panels as needed. */238 panels as needed. */
@@ -213,7 +248,7 @@
213 m_panels.append(panel);248 m_panels.append(panel);
214 }249 }
215 panel->show();250 panel->show();
216 panel->move(desktop->screenGeometry(screen).topLeft());251 panel->setScreen(screen);
217 ++i;252 ++i;
218 }253 }
219 }254 }
220255
=== modified file 'panel/app/panelmanager.h'
--- panel/app/panelmanager.h 2012-01-26 11:16:03 +0000
+++ panel/app/panelmanager.h 2012-02-02 10:59:19 +0000
@@ -44,8 +44,9 @@
44 QStringList loadPanelConfiguration() const;44 QStringList loadPanelConfiguration() const;
4545
46private Q_SLOTS:46private Q_SLOTS:
47 void onScreenCountChanged(int newCount);47 void updateScreenLayout(int newCount);
48 void onAltF10Pressed();48 void onAltF10Pressed();
49 void onScreenResized(int screen);
49};50};
5051
51#endif // PanelManager_H52#endif // PanelManager_H
5253
=== modified file 'panel/applets/appname/windowhelper.cpp'
--- panel/applets/appname/windowhelper.cpp 2012-01-24 13:03:34 +0000
+++ panel/applets/appname/windowhelper.cpp 2012-02-02 10:59:19 +0000
@@ -29,7 +29,6 @@
29#include <dashclient.h>29#include <dashclient.h>
30#include <debug_p.h>30#include <debug_p.h>
31#include <gconnector.h>31#include <gconnector.h>
32#include <screeninfo.h>
3332
34// Bamf33// Bamf
35#include <bamf-matcher.h>34#include <bamf-matcher.h>
3635
=== modified file 'places/app/dashdeclarativeview.cpp'
--- places/app/dashdeclarativeview.cpp 2012-01-26 13:12:12 +0000
+++ places/app/dashdeclarativeview.cpp 2012-02-02 10:59:19 +0000
@@ -23,7 +23,6 @@
23#include <dashclient.h>23#include <dashclient.h>
2424
25// Qt25// Qt
26#include <QDesktopWidget>
27#include <QApplication>26#include <QApplication>
28#include <QBitmap>27#include <QBitmap>
29#include <QCloseEvent>28#include <QCloseEvent>
@@ -55,20 +54,15 @@
55 setWindowFlags(Qt::Window | Qt::FramelessWindowHint);54 setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
56 setTransparentBackground(QX11Info::isCompositingManagerRunning());55 setTransparentBackground(QX11Info::isCompositingManagerRunning());
5756
58 QDesktopWidget* desktop = QApplication::desktop();57 m_screenInfo = new ScreenInfo(ScreenInfo::TopLeft);
59 connect(desktop, SIGNAL(resized(int)), SIGNAL(screenGeometryChanged()));58 connect(m_screenInfo, SIGNAL(availableGeometryChanged(QRect)), SLOT(onWorkAreaResized()));
60 connect(desktop, SIGNAL(workAreaResized(int)), SLOT(onWorkAreaResized(int)));
6159
62 updateSize();60 updateSize();
63}61}
6462
65void63void
66DashDeclarativeView::onWorkAreaResized(int screen)64DashDeclarativeView::onWorkAreaResized()
67{65{
68 if (QApplication::desktop()->screenNumber(this) != screen) {
69 return;
70 }
71
72 updateSize();66 updateSize();
73}67}
7468
@@ -85,7 +79,7 @@
85void79void
86DashDeclarativeView::fitToAvailableSpace()80DashDeclarativeView::fitToAvailableSpace()
87{81{
88 QRect rect = ScreenInfo::instance()->panelsFreeGeometry();82 QRect rect = m_screenInfo->panelsFreeGeometry();
89 move(rect.topLeft());83 move(rect.topLeft());
90 setFixedSize(rect.size());84 setFixedSize(rect.size());
91}85}
@@ -93,7 +87,7 @@
93void87void
94DashDeclarativeView::resizeToDesktopModeSize()88DashDeclarativeView::resizeToDesktopModeSize()
95{89{
96 QRect rect = ScreenInfo::instance()->panelsFreeGeometry();90 QRect rect = m_screenInfo->panelsFreeGeometry();
97 int screenRight = rect.right();91 int screenRight = rect.right();
9892
99 rect.setWidth(qMin(DASH_DESKTOP_WIDTH, rect.width()));93 rect.setWidth(qMin(DASH_DESKTOP_WIDTH, rect.width()));
10094
=== modified file 'places/app/dashdeclarativeview.h'
--- places/app/dashdeclarativeview.h 2012-01-24 12:35:44 +0000
+++ places/app/dashdeclarativeview.h 2012-02-02 10:59:19 +0000
@@ -21,6 +21,7 @@
21#include <unity2ddeclarativeview.h>21#include <unity2ddeclarativeview.h>
2222
23class LauncherClient;23class LauncherClient;
24class ScreenInfo;
2425
25class DashDeclarativeView : public Unity2DDeclarativeView26class DashDeclarativeView : public Unity2DDeclarativeView
26{27{
@@ -67,7 +68,7 @@
67 virtual void showEvent(QShowEvent *event);68 virtual void showEvent(QShowEvent *event);
6869
69private Q_SLOTS:70private Q_SLOTS:
70 void onWorkAreaResized(int screen);71 void onWorkAreaResized();
71 void updateSize();72 void updateSize();
7273
73private:74private:
7475
=== modified file 'places/dash.qml'
--- places/dash.qml 2012-01-25 11:22:45 +0000
+++ places/dash.qml 2012-02-02 10:59:19 +0000
@@ -206,7 +206,7 @@
206 BorderImage {206 BorderImage {
207 anchors.fill: parent207 anchors.fill: parent
208 visible: dashView.dashMode == DashDeclarativeView.DesktopMode208 visible: dashView.dashMode == DashDeclarativeView.DesktopMode
209 source: screen.isCompositingManagerRunning ? "artwork/desktop_dash_background.sci" : "artwork/desktop_dash_background_no_transparency.sci"209 source: desktop.isCompositingManagerRunning ? "artwork/desktop_dash_background.sci" : "artwork/desktop_dash_background_no_transparency.sci"
210 mirror: isRightToLeft()210 mirror: isRightToLeft()
211 }211 }
212 }212 }
213213
=== modified file 'spread/Workspace.qml'
--- spread/Workspace.qml 2011-10-21 12:46:08 +0000
+++ spread/Workspace.qml 2012-02-02 10:59:19 +0000
@@ -54,8 +54,8 @@
5454
55 clip: true55 clip: true
56 cached: false56 cached: false
57 offsetX: -screen.panelsFreeGeometry.x57 offsetX: -declarativeView.screen.panelsFreeGeometry.x
58 offsetY: -screen.panelsFreeGeometry.y58 offsetY: -declarativeView.screen.panelsFreeGeometry.y
59 }59 }
6060
61 Windows {61 Windows {
6262
=== modified file 'spread/Workspaces.qml'
--- spread/Workspaces.qml 2011-12-06 19:37:23 +0000
+++ spread/Workspaces.qml 2012-02-02 10:59:19 +0000
@@ -25,8 +25,8 @@
2525
26 color: "black"26 color: "black"
2727
28 property int columns: screen.workspaces.columns28 property int columns: desktop.workspaces.columns
29 property int rows: screen.workspaces.rows29 property int rows: desktop.workspaces.rows
3030
31 property int margin: 3531 property int margin: 35
32 property int spacing: 432 property int spacing: 4
@@ -57,7 +57,7 @@
5757
58 /* Scale of a workspace when the user zooms on it (fills most of the switcher, leaving a margin to see58 /* Scale of a workspace when the user zooms on it (fills most of the switcher, leaving a margin to see
59 the corners of the other workspaces below it) */59 the corners of the other workspaces below it) */
60 property bool isDesktopHorizontal: screen.panelsFreeGeometry.width > screen.panelsFreeGeometry.height60 property bool isDesktopHorizontal: declarativeView.screen.panelsFreeGeometry.width > declarativeView.screen.panelsFreeGeometry.height
61 property real zoomedScale: (isDesktopHorizontal) ? ((width - 2*margin) / switcher.width) :61 property real zoomedScale: (isDesktopHorizontal) ? ((width - 2*margin) / switcher.width) :
62 ((height - 2*margin) / switcher.height)62 ((height - 2*margin) / switcher.height)
6363
@@ -85,7 +85,7 @@
85 width: cellWidth * columns85 width: cellWidth * columns
86 height: cellHeight * rows86 height: cellHeight * rows
8787
88 model: screen.workspaces.count88 model: desktop.workspaces.count
89 cellWidth: parent.cellWidth + spacing89 cellWidth: parent.cellWidth + spacing
90 cellHeight: parent.cellHeight + spacing90 cellHeight: parent.cellHeight + spacing
91 keyNavigationWraps: true91 keyNavigationWraps: true
@@ -136,7 +136,7 @@
136 }136 }
137 state: {137 state: {
138 if (initial) {138 if (initial) {
139 if (screen.workspaces.current == workspaceNumber) {139 if (desktop.workspaces.current == workspaceNumber) {
140 return "screen"140 return "screen"
141 } else {141 } else {
142 return "unzoomed"142 return "unzoomed"
@@ -189,12 +189,12 @@
189 /* Setup application pre-filtering and initially zoomed desktop, if any189 /* Setup application pre-filtering and initially zoomed desktop, if any
190 were specified as arguments */190 were specified as arguments */
191 applicationFilter = applicationDesktopFile191 applicationFilter = applicationDesktopFile
192 zoomedWorkspace = screen.workspaces.current192 zoomedWorkspace = desktop.workspaces.current
193 show()193 show()
194 }194 }
195195
196 onShowAllWorkspaces: {196 onShowAllWorkspaces: {
197 if (screen.workspaces.count > 1) {197 if (desktop.workspaces.count > 1) {
198 applicationFilter = applicationDesktopFile198 applicationFilter = applicationDesktopFile
199 zoomedWorkspace = -1199 zoomedWorkspace = -1
200 show()200 show()
@@ -211,13 +211,13 @@
211 function show() {211 function show() {
212 /* Save the currently active window before showing and activating the switcher,212 /* Save the currently active window before showing and activating the switcher,
213 so that we can use it to pre-select the active window on the workspace */213 so that we can use it to pre-select the active window on the workspace */
214 lastActiveWindow = screen.activeWindow214 lastActiveWindow = desktop.activeWindow
215215
216 allWindows.load()216 allWindows.load()
217217
218 spreadView.show()218 spreadView.show()
219 spreadView.forceActivateWindow()219 spreadView.forceActivateWindow()
220 workspaces.currentIndex = screen.workspaces.current220 workspaces.currentIndex = desktop.workspaces.current
221 /* This is necessary otherwise we don't get keypresses until the user does a221 /* This is necessary otherwise we don't get keypresses until the user does a
222 mouse over on a window */222 mouse over on a window */
223 workspaces.forceActiveFocus()223 workspaces.forceActiveFocus()
@@ -280,13 +280,13 @@
280 }280 }
281281
282 function activateWindow(windowInfo) {282 function activateWindow(windowInfo) {
283 screen.workspaces.changeCurrent(zoomedWorkspace)283 desktop.workspaces.changeCurrent(zoomedWorkspace)
284 windowInfo.activate()284 windowInfo.activate()
285 cancelAndExit()285 cancelAndExit()
286 }286 }
287287
288 function activateWorkspace(workspaceNumber) {288 function activateWorkspace(workspaceNumber) {
289 screen.workspaces.changeCurrent(workspaceNumber)289 desktop.workspaces.changeCurrent(workspaceNumber)
290 cancelAndExit()290 cancelAndExit()
291 }291 }
292}292}
293293
=== modified file 'spread/app/spread.cpp'
--- spread/app/spread.cpp 2011-11-11 15:52:49 +0000
+++ spread/app/spread.cpp 2012-02-02 10:59:19 +0000
@@ -66,10 +66,5 @@
66 view.rootContext()->setContextProperty("spreadView", &view);66 view.rootContext()->setContextProperty("spreadView", &view);
67 view.setSource(QUrl("./Workspaces.qml"));67 view.setSource(QUrl("./Workspaces.qml"));
6868
69 /* Always match the size of the desktop */
70 int current_screen = QApplication::desktop()->screenNumber(&view);
71 view.fitToAvailableSpace(current_screen);
72 QObject::connect(QApplication::desktop(), SIGNAL(workAreaResized(int)), &view, SLOT(fitToAvailableSpace(int)));
73
74 return application.exec();69 return application.exec();
75}70}
7671
=== modified file 'spread/app/spreadview.cpp'
--- spread/app/spreadview.cpp 2011-12-08 18:39:18 +0000
+++ spread/app/spreadview.cpp 2012-02-02 10:59:19 +0000
@@ -28,19 +28,17 @@
28SpreadView::SpreadView()28SpreadView::SpreadView()
29: Unity2DDeclarativeView()29: Unity2DDeclarativeView()
30{30{
31 m_screenInfo = new ScreenInfo(ScreenInfo::TopLeft);
32 connect(m_screenInfo, SIGNAL(availableGeometryChanged(QRect)), SLOT(fitToAvailableSpace()));
33
34 fitToAvailableSpace();
31}35}
3236
33void SpreadView::fitToAvailableSpace(int screen)37void SpreadView::fitToAvailableSpace()
34{38{
35 QDesktopWidget *desktop = QApplication::desktop();39 QRect geometry = m_screenInfo->panelsFreeGeometry();
36 int current_screen = desktop->screenNumber(this);40 setGeometry(geometry);
3741 setFixedSize(geometry.size());
38 if(screen == current_screen)
39 {
40 QRect geometry = ScreenInfo::instance()->panelsFreeGeometry();
41 setGeometry(geometry);
42 setFixedSize(geometry.size());
43 }
44}42}
4543
46/* To be able to call grabMouse() we need to be 100% sure that X11 did44/* To be able to call grabMouse() we need to be 100% sure that X11 did
4745
=== modified file 'spread/app/spreadview.h'
--- spread/app/spreadview.h 2011-12-08 18:39:18 +0000
+++ spread/app/spreadview.h 2012-02-02 10:59:19 +0000
@@ -34,7 +34,7 @@
3434
35public Q_SLOTS:35public Q_SLOTS:
36 /* FIXME: copied from places/app/dashdeclarativeview.h */36 /* FIXME: copied from places/app/dashdeclarativeview.h */
37 void fitToAvailableSpace(int screen);37 void fitToAvailableSpace();
3838
39protected:39protected:
40 virtual void focusInEvent( QFocusEvent * event );40 virtual void focusInEvent( QFocusEvent * event );

Subscribers

People subscribed via source and target branches