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