Merge lp:~unity-2d-team/unity-2d/unity-2d-dash-always-fullscreen-by-resolution into lp:unity-2d
- unity-2d-dash-always-fullscreen-by-resolution
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Florian Boucault |
Approved revision: | 875 |
Merged at revision: | 875 |
Proposed branch: | lp:~unity-2d-team/unity-2d/unity-2d-dash-always-fullscreen-by-resolution |
Merge into: | lp:unity-2d |
Diff against target: |
857 lines (+243/-267) 15 files modified
config.h.in (+6/-0) data/com.canonical.Unity2d.gschema.xml (+10/-0) libunity-2d-private/Unity2d/plugin.cpp (+6/-5) libunity-2d-private/src/CMakeLists.txt (+0/-1) libunity-2d-private/src/dashclient.cpp (+30/-0) libunity-2d-private/src/dashclient.h (+9/-2) libunity-2d-private/src/dashsettings.cpp (+0/-112) libunity-2d-private/src/dashsettings.h (+0/-72) panel/applets/appname/appnameapplet.cpp (+4/-1) panel/applets/appname/windowhelper.cpp (+6/-51) panel/applets/appname/windowhelper.h (+0/-1) places/app/dashdeclarativeview.cpp (+1/-15) places/app/dashdeclarativeview.h (+0/-1) places/dash.qml (+2/-6) tests/places/fullscreen.rb (+169/-0) |
To merge this branch: | bzr merge lp:~unity-2d-team/unity-2d/unity-2d-dash-always-fullscreen-by-resolution |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Florian Boucault (community) | Needs Fixing | ||
Review via email: mp+89886@code.launchpad.net |
Commit message
Description of the change
[dash][panel] Refactor testing for forced dash fullscreen based on resolution into DashClient
Ugo Riboni (uriboni) wrote : | # |
Florian Boucault (fboucault) wrote : | # |
Any reason why not defining minimumSizeForD
Florian Boucault (fboucault) wrote : | # |
Don't expose the constructor of DashClient. It is private for a reason, because DashClient is a singleton only accessed through ::instance(). You want it accessible from QML alright, expose what ::instance() gives you from the Unity2d QML plugin with "engine-
Florian Boucault (fboucault) wrote : | # |
Otherwise looks great. Will carry slightly more detailed code inspection and functional review.
- 869. By Ugo Riboni
-
Expose DashClient as a singleton to QML
Lohith D Shivamurthy (dyams) wrote : | # |
Functionally no issues found
Ugo Riboni (uriboni) wrote : | # |
Pushed UI tests too
- 870. By Ugo Riboni
-
Merge changes from parent feature branch
- 871. By Ugo Riboni
-
Fix tests so that they check the right thing depending on current screen resolution (we decided it's not proper to force resolution changes during tests)
Ugo Riboni (uriboni) wrote : | # |
As mentioned in commit message 871: the proper way to test that the dash is always full screen when the resolution is lower than a certain threshold is to change the resolution during the test.
However since we're expecting that people will run tests on their own machines, this was not deemed acceptable.
So we decided that as a compromise the tests would work differently based on the current resolution on the test machine.
In any case, I ran the tests both with a very small resolution and a big one and they pass in both cases.
- 872. By Ugo Riboni
-
Merge changes from parent branch
- 873. By Ugo Riboni
-
Merge changes from parent branch
- 874. By Ugo Riboni
-
Adapt the initial fullscreen test to current code
Ugo Riboni (uriboni) wrote : | # |
Updated to match changes in parent branch: https:/
- 875. By Ugo Riboni
-
Merge fixes to tests from parent branch
Preview Diff
1 | === modified file 'config.h.in' |
2 | --- config.h.in 2011-12-07 19:20:54 +0000 |
3 | +++ config.h.in 2012-01-26 18:08:33 +0000 |
4 | @@ -11,6 +11,7 @@ |
5 | static const char* UNITY2D_DCONF_SCHEMA = "com.canonical.Unity2d"; |
6 | static const char* LAUNCHER2D_DCONF_SCHEMA = "com.canonical.Unity2d.Launcher"; |
7 | static const char* PANEL2D_DCONF_SCHEMA = "com.canonical.Unity2d.Panel"; |
8 | +static const char* DASH2D_DCONF_SCHEMA = "com.canonical.Unity2d.Dash"; |
9 | |
10 | static const char* UNITY_DCONF_SCHEMA = "com.canonical.Unity"; |
11 | static const char* LAUNCHER_DCONF_SCHEMA = "com.canonical.Unity.Launcher"; |
12 | @@ -31,6 +32,11 @@ |
13 | return configuration; |
14 | } |
15 | |
16 | +inline QConf& dash2dConfiguration() { |
17 | + static QConf configuration(DASH2D_DCONF_SCHEMA); |
18 | + return configuration; |
19 | +} |
20 | + |
21 | inline QConf& unityConfiguration() { |
22 | static QConf configuration(UNITY_DCONF_SCHEMA); |
23 | return configuration; |
24 | |
25 | === modified file 'data/com.canonical.Unity2d.gschema.xml' |
26 | --- data/com.canonical.Unity2d.gschema.xml 2011-12-01 09:55:45 +0000 |
27 | +++ data/com.canonical.Unity2d.gschema.xml 2012-01-26 18:08:33 +0000 |
28 | @@ -36,4 +36,14 @@ |
29 | </description> |
30 | </key> |
31 | </schema> |
32 | + <schema path="/com/canonical/unity-2d/dash/" id="com.canonical.Unity2d.Dash" gettext-domain="unity-2d"> |
33 | + <key type="b" name="full-screen"> |
34 | + <default>false</default> |
35 | + <summary>The current fullscreen status of the dash</summary> |
36 | + <description> |
37 | + Describe if the dash should be fullscreen or not. If the dash is already running this setting |
38 | + is applied immediately, otherwise it is applied as soon as the dash is activated again. |
39 | + </description> |
40 | + </key> |
41 | + </schema> |
42 | </schemalist> |
43 | |
44 | === modified file 'libunity-2d-private/Unity2d/plugin.cpp' |
45 | --- libunity-2d-private/Unity2d/plugin.cpp 2012-01-19 14:35:41 +0000 |
46 | +++ libunity-2d-private/Unity2d/plugin.cpp 2012-01-26 18:08:33 +0000 |
47 | @@ -22,7 +22,6 @@ |
48 | */ |
49 | #include "plugin.h" |
50 | |
51 | -#include "dashsettings.h" |
52 | #include "launcherapplication.h" |
53 | #include "launcherdevice.h" |
54 | #include "trash.h" |
55 | @@ -50,6 +49,7 @@ |
56 | #include "launcherdropitem.h" |
57 | |
58 | #include "config.h" |
59 | +#include "dashclient.h" |
60 | |
61 | #include "autohidebehavior.h" |
62 | #include "intellihidebehavior.h" |
63 | @@ -81,8 +81,6 @@ |
64 | |
65 | #include <X11/Xlib.h> |
66 | |
67 | -using namespace Unity2d; |
68 | - |
69 | /* FIXME: This should be done more properly, it's just an hack this way. |
70 | We should silence only the errors that we know we can produce. |
71 | We could probably also learn something from gdk-error-trap-push. |
72 | @@ -100,8 +98,6 @@ |
73 | { |
74 | qmlRegisterType<QSortFilterProxyModelQML>(uri, 0, 1, "SortFilterProxyModel"); |
75 | |
76 | - qmlRegisterType<DashSettings>(uri, 0, 1, "DashSettings"); |
77 | - |
78 | qmlRegisterType<WindowInfo>(uri, 0, 1, "WindowInfo"); |
79 | qmlRegisterType<WindowsList>(uri, 0, 1, "WindowsList"); |
80 | qmlRegisterType<ScreenInfo>(); // Register the type as non creatable |
81 | @@ -162,6 +158,7 @@ |
82 | qmlRegisterType<FilterOption>(); |
83 | qmlRegisterType<FilterOptions>(); |
84 | |
85 | + qmlRegisterType<DashClient>(); |
86 | } |
87 | |
88 | void Unity2dPlugin::initializeEngine(QDeclarativeEngine *engine, const char *uri) |
89 | @@ -179,6 +176,10 @@ |
90 | engine->rootContext()->setContextProperty("screen", ScreenInfo::instance()); |
91 | engine->rootContext()->setContextProperty("iconUtilities", new IconUtilities(engine)); |
92 | |
93 | + /* Expose QConf objects as a context property not to initialize it multiple times */ |
94 | + engine->rootContext()->setContextProperty("dash2dConfiguration", &dash2dConfiguration()); |
95 | + engine->rootContext()->setContextProperty("dashClient", DashClient::instance()); |
96 | + |
97 | /* Critically important to set the client type to pager because wnck |
98 | will pass that type over to the window manager through XEvents. |
99 | Window managers tend to respect orders from pagers to the letter by |
100 | |
101 | === modified file 'libunity-2d-private/src/CMakeLists.txt' |
102 | --- libunity-2d-private/src/CMakeLists.txt 2012-01-19 14:35:41 +0000 |
103 | +++ libunity-2d-private/src/CMakeLists.txt 2012-01-26 18:08:33 +0000 |
104 | @@ -4,7 +4,6 @@ |
105 | set(lib${LIB_NAME}_SRCS |
106 | bfb.cpp |
107 | dashclient.cpp |
108 | - dashsettings.cpp |
109 | debug.cpp |
110 | gconnector.cpp |
111 | gimageutils.cpp |
112 | |
113 | === modified file 'libunity-2d-private/src/dashclient.cpp' |
114 | --- libunity-2d-private/src/dashclient.cpp 2011-08-11 15:36:04 +0000 |
115 | +++ libunity-2d-private/src/dashclient.cpp 2012-01-26 18:08:33 +0000 |
116 | @@ -32,15 +32,21 @@ |
117 | #include <QDBusConnectionInterface> |
118 | #include <QDBusInterface> |
119 | #include <QDBusServiceWatcher> |
120 | +#include <QDesktopWidget> |
121 | +#include <QRect> |
122 | |
123 | static const char* DASH_DBUS_SERVICE = "com.canonical.Unity2d.Dash"; |
124 | static const char* DASH_DBUS_PATH = "/Dash"; |
125 | static const char* DASH_DBUS_INTERFACE = "com.canonical.Unity2d.Dash"; |
126 | |
127 | +static const int DASH_MIN_SCREEN_WIDTH = 1280; |
128 | +static const int DASH_MIN_SCREEN_HEIGHT = 1084; |
129 | + |
130 | DashClient::DashClient(QObject* parent) |
131 | : QObject(parent) |
132 | , m_dashDbusIface(0) |
133 | , m_dashActive(false) |
134 | +, m_alwaysFullScreen(false) |
135 | { |
136 | /* Check if the dash is already up and running by asking the bus instead of |
137 | trying to create an instance of the interface. Creating an instance would |
138 | @@ -59,6 +65,9 @@ |
139 | this); |
140 | connect(watcher, SIGNAL(serviceRegistered(QString)), SLOT(connectToDash())); |
141 | } |
142 | + |
143 | + connect(QApplication::desktop(), SIGNAL(resized(int)), SLOT(updateAlwaysFullScreen())); |
144 | + updateAlwaysFullScreen(); |
145 | } |
146 | |
147 | void DashClient::connectToDash() |
148 | @@ -152,4 +161,25 @@ |
149 | } |
150 | } |
151 | |
152 | +QSize DashClient::minimumSizeForDesktop() |
153 | +{ |
154 | + return QSize(DASH_MIN_SCREEN_WIDTH, DASH_MIN_SCREEN_HEIGHT); |
155 | +} |
156 | + |
157 | +void DashClient::updateAlwaysFullScreen() |
158 | +{ |
159 | + QRect rect = QApplication::desktop()->screenGeometry(); |
160 | + QSize minSize = minimumSizeForDesktop(); |
161 | + bool alwaysFullScreen = rect.width() < minSize.width() && rect.height() < minSize.height(); |
162 | + if (m_alwaysFullScreen != alwaysFullScreen) { |
163 | + m_alwaysFullScreen = alwaysFullScreen; |
164 | + Q_EMIT alwaysFullScreenChanged(); |
165 | + } |
166 | +} |
167 | + |
168 | +bool DashClient::alwaysFullScreen() const |
169 | +{ |
170 | + return m_alwaysFullScreen; |
171 | +} |
172 | + |
173 | #include "dashclient.moc" |
174 | |
175 | === modified file 'libunity-2d-private/src/dashclient.h' |
176 | --- libunity-2d-private/src/dashclient.h 2011-08-11 15:36:04 +0000 |
177 | +++ libunity-2d-private/src/dashclient.h 2012-01-26 18:08:33 +0000 |
178 | @@ -25,6 +25,7 @@ |
179 | |
180 | // Qt |
181 | #include <QObject> |
182 | +#include <QSize> |
183 | |
184 | class QDBusInterface; |
185 | |
186 | @@ -34,6 +35,8 @@ |
187 | class DashClient : public QObject |
188 | { |
189 | Q_OBJECT |
190 | + Q_PROPERTY(bool alwaysFullScreen READ alwaysFullScreen NOTIFY alwaysFullScreenChanged) |
191 | + |
192 | public: |
193 | static DashClient* instance(); |
194 | |
195 | @@ -44,25 +47,29 @@ |
196 | * - "" if the dash is not visible |
197 | */ |
198 | QString activePage() const; |
199 | - |
200 | + bool alwaysFullScreen() const; |
201 | void setActivePage(const QString& page, const QString& lensId=QString()); |
202 | + static QSize minimumSizeForDesktop(); |
203 | |
204 | Q_SIGNALS: |
205 | void activePageChanged(const QString&); |
206 | + void alwaysFullScreenChanged(); |
207 | |
208 | private Q_SLOTS: |
209 | void connectToDash(); |
210 | void slotDashActiveChanged(bool); |
211 | void slotDashActiveLensChanged(const QString&); |
212 | + void updateAlwaysFullScreen(); |
213 | |
214 | private: |
215 | - DashClient(QObject* parent=0); |
216 | + DashClient(QObject* parent = 0); |
217 | void updateActivePage(); |
218 | |
219 | QDBusInterface* m_dashDbusIface; |
220 | bool m_dashActive; |
221 | QString m_dashActiveLens; |
222 | QString m_activePage; |
223 | + bool m_alwaysFullScreen; |
224 | }; |
225 | |
226 | #endif /* DASHCLIENT_H */ |
227 | |
228 | === removed file 'libunity-2d-private/src/dashsettings.cpp' |
229 | --- libunity-2d-private/src/dashsettings.cpp 2011-12-09 09:14:11 +0000 |
230 | +++ libunity-2d-private/src/dashsettings.cpp 1970-01-01 00:00:00 +0000 |
231 | @@ -1,112 +0,0 @@ |
232 | -/* |
233 | - * This file is part of unity-2d |
234 | - * |
235 | - * Copyright 2011 Canonical Ltd. |
236 | - * |
237 | - * Authors: |
238 | - * - Alberto Mardegan <alberto.mardegan@canonical.com> |
239 | - * |
240 | - * This program is free software; you can redistribute it and/or modify |
241 | - * it under the terms of the GNU General Public License as published by |
242 | - * the Free Software Foundation; version 3. |
243 | - * |
244 | - * This program is distributed in the hope that it will be useful, |
245 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
246 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
247 | - * GNU General Public License for more details. |
248 | - * |
249 | - * You should have received a copy of the GNU General Public License |
250 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
251 | - */ |
252 | -// Self |
253 | -#include "dashsettings.h" |
254 | - |
255 | -// Local |
256 | - |
257 | -// Qt |
258 | -#include <QMetaEnum> |
259 | -#include <QSize> |
260 | -#include <QVariant> |
261 | - |
262 | -#include <config.h> |
263 | - |
264 | -static const int DASH_MIN_SCREEN_WIDTH = 1280; |
265 | -static const int DASH_MIN_SCREEN_HEIGHT = 1084; |
266 | - |
267 | -static const char* FORM_FACTOR = "formFactor"; |
268 | - |
269 | -namespace Unity2d { |
270 | - |
271 | -class DashSettingsPrivate |
272 | -{ |
273 | - DashSettingsPrivate(DashSettings *dashSettings) |
274 | - { |
275 | - /* proxy the formFactor property signal notifier */ |
276 | - QObject::connect(&unityConfiguration(), SIGNAL(formFactorChanged(QString)), |
277 | - dashSettings, SIGNAL(formFactorChanged())); |
278 | - |
279 | - /* Get the QMetaEnum for FormFactor: we will use it when setting and |
280 | - * getting the property, to convert the string value returned by QConf |
281 | - * to an enum value, and vice versa. */ |
282 | - const QMetaObject *metaObject = dashSettings->metaObject(); |
283 | - int index = metaObject->indexOfEnumerator("FormFactor"); |
284 | - formFactorEnum = metaObject->enumerator(index); |
285 | - } |
286 | - |
287 | - ~DashSettingsPrivate() |
288 | - { |
289 | - } |
290 | - |
291 | -private: |
292 | - DashSettings* q_ptr; |
293 | - Q_DECLARE_PUBLIC(DashSettings) |
294 | - |
295 | - QMetaEnum formFactorEnum; |
296 | -}; |
297 | - |
298 | -DashSettings::DashSettings(QObject* parent): |
299 | - QObject(parent), |
300 | - d_ptr(new DashSettingsPrivate(this)) |
301 | -{ |
302 | -} |
303 | - |
304 | -DashSettings::~DashSettings() |
305 | -{ |
306 | - delete d_ptr; |
307 | -} |
308 | - |
309 | -void DashSettings::setFormFactor(FormFactor formFactor) |
310 | -{ |
311 | - Q_D(DashSettings); |
312 | - |
313 | - const char* name = d->formFactorEnum.valueToKey(formFactor); |
314 | - unityConfiguration().setProperty(FORM_FACTOR, QVariant(QString::fromLatin1(name))); |
315 | -} |
316 | - |
317 | -DashSettings::FormFactor DashSettings::formFactor() const |
318 | -{ |
319 | - Q_D(const DashSettings); |
320 | - QByteArray key = unityConfiguration().property(FORM_FACTOR).toString().toLatin1(); |
321 | - return FormFactor(d->formFactorEnum.keyToValue(key.constData())); |
322 | -} |
323 | - |
324 | -static int getenvInt(const char* name, int defaultValue) |
325 | -{ |
326 | - QByteArray stringValue = qgetenv(name); |
327 | - bool ok; |
328 | - int value = stringValue.toInt(&ok); |
329 | - return ok ? value : defaultValue; |
330 | -} |
331 | - |
332 | -QSize DashSettings::minimumSizeForDesktop() |
333 | -{ |
334 | - static int minWidth = getenvInt("DASH_MIN_SCREEN_WIDTH", |
335 | - DASH_MIN_SCREEN_WIDTH); |
336 | - static int minHeight = getenvInt("DASH_MIN_SCREEN_HEIGHT", |
337 | - DASH_MIN_SCREEN_HEIGHT); |
338 | - return QSize(minWidth, minHeight); |
339 | -} |
340 | - |
341 | -}; // namespace Unity2d |
342 | - |
343 | -#include "dashsettings.moc" |
344 | |
345 | === removed file 'libunity-2d-private/src/dashsettings.h' |
346 | --- libunity-2d-private/src/dashsettings.h 2011-10-17 12:12:10 +0000 |
347 | +++ libunity-2d-private/src/dashsettings.h 1970-01-01 00:00:00 +0000 |
348 | @@ -1,72 +0,0 @@ |
349 | -/* |
350 | - * This file is part of unity-2d |
351 | - * |
352 | - * Copyright 2011 Canonical Ltd. |
353 | - * |
354 | - * Authors: |
355 | - * - Alberto Mardegan <alberto.mardegan@canonical.com> |
356 | - * |
357 | - * This program is free software; you can redistribute it and/or modify |
358 | - * it under the terms of the GNU General Public License as published by |
359 | - * the Free Software Foundation; version 3. |
360 | - * |
361 | - * This program is distributed in the hope that it will be useful, |
362 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
363 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
364 | - * GNU General Public License for more details. |
365 | - * |
366 | - * You should have received a copy of the GNU General Public License |
367 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
368 | - */ |
369 | -#ifndef DASHSETTINGS_H |
370 | -#define DASHSETTINGS_H |
371 | - |
372 | -// Qt |
373 | -#include <QObject> |
374 | -#include <QMetaType> |
375 | - |
376 | -namespace Unity2d { |
377 | - |
378 | -class DashSettingsPrivate; |
379 | - |
380 | -/** |
381 | - * Provide easy access to the Dash settings (from Qt and QML) |
382 | - */ |
383 | -class DashSettings: public QObject |
384 | -{ |
385 | - Q_OBJECT |
386 | - |
387 | - Q_ENUMS(FormFactor) |
388 | - |
389 | - Q_PROPERTY(FormFactor formFactor READ formFactor WRITE setFormFactor NOTIFY formFactorChanged) |
390 | - |
391 | -public: |
392 | - explicit DashSettings(QObject* parent = 0); |
393 | - ~DashSettings(); |
394 | - |
395 | - enum FormFactor |
396 | - { |
397 | - Automatic = 0, |
398 | - Desktop, |
399 | - Netbook |
400 | - }; |
401 | - |
402 | - void setFormFactor(FormFactor formFactor); |
403 | - FormFactor formFactor() const; |
404 | - |
405 | - static QSize minimumSizeForDesktop(); |
406 | - |
407 | -Q_SIGNALS: |
408 | - void formFactorChanged(); |
409 | - |
410 | -private: |
411 | - Q_DISABLE_COPY(DashSettings) |
412 | - DashSettingsPrivate* d_ptr; |
413 | - Q_DECLARE_PRIVATE(DashSettings) |
414 | -}; |
415 | - |
416 | -} // namespace Unity2d |
417 | - |
418 | -Q_DECLARE_METATYPE(Unity2d::DashSettings::FormFactor) |
419 | - |
420 | -#endif /* DASHSETTINGS_H */ |
421 | |
422 | === modified file 'panel/applets/appname/appnameapplet.cpp' |
423 | --- panel/applets/appname/appnameapplet.cpp 2012-01-13 17:33:12 +0000 |
424 | +++ panel/applets/appname/appnameapplet.cpp 2012-01-26 18:08:33 +0000 |
425 | @@ -28,6 +28,7 @@ |
426 | #include "panelstyle.h" |
427 | #include "unity2dpanel.h" |
428 | #include "windowhelper.h" |
429 | +#include "dashclient.h" |
430 | |
431 | // Unity-2d |
432 | #include <debug_p.h> |
433 | @@ -226,6 +227,8 @@ |
434 | d->setupMenuBarWidget(panel->indicatorsManager()); |
435 | d->setupKeyboardModifiersMonitor(); |
436 | |
437 | + connect(DashClient::instance(), SIGNAL(alwaysFullScreenChanged()), SLOT(updateWidgets())); |
438 | + |
439 | QHBoxLayout* layout = new QHBoxLayout(this); |
440 | layout->setMargin(0); |
441 | layout->setSpacing(0); |
442 | @@ -259,7 +262,7 @@ |
443 | || d->m_menuBarWidget->isOpened() |
444 | ); |
445 | bool showMenu = isOpened && !d->m_menuBarWidget->isEmpty() && isUserVisibleApp; |
446 | - bool dashCanResize = d->m_windowHelper->dashCanResize(); |
447 | + bool dashCanResize = !DashClient::instance()->alwaysFullScreen(); |
448 | bool dashIsVisible = d->m_windowHelper->dashIsVisible(); |
449 | bool showWindowButtons = (isOpened && isMaximized) || dashIsVisible; |
450 | bool showAppLabel = !(isMaximized && showMenu) && isUserVisibleApp && isOnSameScreen; |
451 | |
452 | === modified file 'panel/applets/appname/windowhelper.cpp' |
453 | --- panel/applets/appname/windowhelper.cpp 2011-12-02 04:22:53 +0000 |
454 | +++ panel/applets/appname/windowhelper.cpp 2012-01-26 18:08:33 +0000 |
455 | @@ -23,9 +23,10 @@ |
456 | #include "windowhelper.h" |
457 | |
458 | // Local |
459 | +#include "config.h" |
460 | |
461 | // unity-2d |
462 | -#include <dashsettings.h> |
463 | +#include <dashclient.h> |
464 | #include <debug_p.h> |
465 | #include <gconnector.h> |
466 | #include <screeninfo.h> |
467 | @@ -45,38 +46,18 @@ |
468 | #include <QApplication> |
469 | #include <QDesktopWidget> |
470 | #include <QPoint> |
471 | +#include <QVariant> |
472 | |
473 | // X11 |
474 | #include <X11/Xlib.h> |
475 | #include <X11/Xatom.h> |
476 | #include <QX11Info> |
477 | |
478 | -using namespace Unity2d; |
479 | - |
480 | struct WindowHelperPrivate |
481 | { |
482 | - void updateDashCanResize() |
483 | - { |
484 | - WnckScreen* screen = wnck_window_get_screen(m_window); |
485 | - int screenNumber = wnck_screen_get_number(screen); |
486 | - QRect rect = QApplication::desktop()->screenGeometry(screenNumber); |
487 | - |
488 | - /* If the screen size too small, we don't allow the Dash to be used |
489 | - * in Desktop mode (not fullscreen) */ |
490 | - QSize minSize = DashSettings::minimumSizeForDesktop(); |
491 | - if (rect.width() < minSize.width() && |
492 | - rect.height() < minSize.height()) { |
493 | - m_dashCanResize = false; |
494 | - } else { |
495 | - m_dashCanResize = true; |
496 | - } |
497 | - } |
498 | - |
499 | - DashSettings* m_dashSettings; |
500 | WnckWindow* m_window; |
501 | GConnector m_connector; |
502 | bool m_activeWindowIsDash; |
503 | - bool m_dashCanResize; |
504 | }; |
505 | |
506 | WindowHelper::WindowHelper(QObject* parent) |
507 | @@ -84,7 +65,6 @@ |
508 | , d(new WindowHelperPrivate) |
509 | { |
510 | d->m_window = 0; |
511 | - d->m_dashSettings = new DashSettings(this); |
512 | |
513 | WnckScreen* screen = wnck_screen_get_default(); |
514 | wnck_screen_force_update(screen); |
515 | @@ -123,12 +103,6 @@ |
516 | QMetaObject::invokeMethod(watcher, "nameChanged"); |
517 | } |
518 | |
519 | -static void geometryChangedCB(GObject* window, |
520 | - WindowHelper* watcher) |
521 | -{ |
522 | - QMetaObject::invokeMethod(watcher, "stateChanged"); |
523 | -} |
524 | - |
525 | void WindowHelper::update() |
526 | { |
527 | BamfWindow* bamfWindow = BamfMatcher::get_default().active_window(); |
528 | @@ -143,16 +117,6 @@ |
529 | |
530 | const char *name = wnck_window_get_name(d->m_window); |
531 | d->m_activeWindowIsDash = qstrcmp(name, "unity-2d-places") == 0; |
532 | - if (d->m_activeWindowIsDash) { |
533 | - /* Since we are not really minimizing and maximizing the dash we |
534 | - * cannot rely on the wnck "state-changed" signal to be emitted; |
535 | - * instead, listen for the "geometry-changed" and emit our |
536 | - * stateChanged() from that. */ |
537 | - d->m_connector.connect(G_OBJECT(d->m_window), "geometry-changed", |
538 | - G_CALLBACK(geometryChangedCB), this); |
539 | - |
540 | - d->updateDashCanResize(); |
541 | - } |
542 | |
543 | d->m_connector.connect(G_OBJECT(d->m_window), "name-changed", G_CALLBACK(nameChangedCB), this); |
544 | d->m_connector.connect(G_OBJECT(d->m_window), "state-changed", G_CALLBACK(stateChangedCB), this); |
545 | @@ -167,11 +131,7 @@ |
546 | return false; |
547 | } |
548 | if (d->m_activeWindowIsDash) { |
549 | - int x, y, width, height; |
550 | - wnck_window_get_geometry(d->m_window, &x, &y, &width, &height); |
551 | - const QRect windowGeometry(x, y, width, height); |
552 | - ScreenInfo* screenInfo = ScreenInfo::instance(); |
553 | - return screenInfo->panelsFreeGeometry() == windowGeometry; |
554 | + return dash2dConfiguration().property("fullScreen").toBool(); |
555 | } else { |
556 | return wnck_window_is_maximized(d->m_window); |
557 | } |
558 | @@ -205,11 +165,6 @@ |
559 | return d->m_window != 0 && d->m_activeWindowIsDash; |
560 | } |
561 | |
562 | -bool WindowHelper::dashCanResize() const |
563 | -{ |
564 | - return d->m_dashCanResize; |
565 | -} |
566 | - |
567 | void WindowHelper::close() |
568 | { |
569 | guint32 timestamp = QDateTime::currentDateTime().toTime_t(); |
570 | @@ -226,7 +181,7 @@ |
571 | void WindowHelper::maximize() |
572 | { |
573 | if (d->m_activeWindowIsDash) { |
574 | - d->m_dashSettings->setFormFactor(DashSettings::Netbook); |
575 | + dash2dConfiguration().setProperty("fullScreen", QVariant(true)); |
576 | } else { |
577 | /* This currently cannot happen, because the window buttons are not |
578 | * shown in the panel for non maximized windows. It's here just for |
579 | @@ -238,7 +193,7 @@ |
580 | void WindowHelper::unmaximize() |
581 | { |
582 | if (d->m_activeWindowIsDash) { |
583 | - d->m_dashSettings->setFormFactor(DashSettings::Desktop); |
584 | + dash2dConfiguration().setProperty("fullScreen", QVariant(false)); |
585 | } else { |
586 | wnck_window_unmaximize(d->m_window); |
587 | } |
588 | |
589 | === modified file 'panel/applets/appname/windowhelper.h' |
590 | --- panel/applets/appname/windowhelper.h 2011-10-17 12:46:55 +0000 |
591 | +++ panel/applets/appname/windowhelper.h 2012-01-26 18:08:33 +0000 |
592 | @@ -42,7 +42,6 @@ |
593 | bool isMaximized() const; |
594 | bool isMostlyOnScreen(int screen) const; |
595 | bool dashIsVisible() const; |
596 | - bool dashCanResize() const; |
597 | |
598 | public Q_SLOTS: |
599 | void close(); |
600 | |
601 | === modified file 'places/app/dashdeclarativeview.cpp' |
602 | --- places/app/dashdeclarativeview.cpp 2011-12-19 10:54:27 +0000 |
603 | +++ places/app/dashdeclarativeview.cpp 2012-01-26 18:08:33 +0000 |
604 | @@ -18,9 +18,9 @@ |
605 | #include "dashadaptor.h" |
606 | |
607 | // unity-2d |
608 | -#include <dashsettings.h> |
609 | #include <launcherclient.h> |
610 | #include <screeninfo.h> |
611 | +#include <dashclient.h> |
612 | |
613 | // Qt |
614 | #include <QDesktopWidget> |
615 | @@ -57,7 +57,6 @@ |
616 | |
617 | QDesktopWidget* desktop = QApplication::desktop(); |
618 | connect(desktop, SIGNAL(resized(int)), SIGNAL(screenGeometryChanged())); |
619 | - connect(desktop, SIGNAL(resized(int)), SLOT(updateDashModeDependingOnScreenGeometry())); |
620 | connect(desktop, SIGNAL(workAreaResized(int)), SLOT(onWorkAreaResized(int))); |
621 | |
622 | updateSize(); |
623 | @@ -74,18 +73,6 @@ |
624 | } |
625 | |
626 | void |
627 | -DashDeclarativeView::updateDashModeDependingOnScreenGeometry() |
628 | -{ |
629 | - QRect rect = QApplication::desktop()->screenGeometry(this); |
630 | - QSize minSize = Unity2d::DashSettings::minimumSizeForDesktop(); |
631 | - if (rect.width() < minSize.width() && rect.height() < minSize.height()) { |
632 | - setDashMode(FullScreenMode); |
633 | - } else { |
634 | - setDashMode(DesktopMode); |
635 | - } |
636 | -} |
637 | - |
638 | -void |
639 | DashDeclarativeView::updateSize() |
640 | { |
641 | if (m_mode == FullScreenMode) { |
642 | @@ -159,7 +146,6 @@ |
643 | if (value != m_active) { |
644 | m_active = value; |
645 | if (value) { |
646 | - updateDashModeDependingOnScreenGeometry(); |
647 | show(); |
648 | raise(); |
649 | // We need a delay, otherwise the window may not be visible when we try to activate it |
650 | |
651 | === modified file 'places/app/dashdeclarativeview.h' |
652 | --- places/app/dashdeclarativeview.h 2011-12-08 18:39:18 +0000 |
653 | +++ places/app/dashdeclarativeview.h 2012-01-26 18:08:33 +0000 |
654 | @@ -68,7 +68,6 @@ |
655 | |
656 | private Q_SLOTS: |
657 | void onWorkAreaResized(int screen); |
658 | - void updateDashModeDependingOnScreenGeometry(); |
659 | void updateSize(); |
660 | |
661 | private: |
662 | |
663 | === modified file 'places/dash.qml' |
664 | --- places/dash.qml 2012-01-03 11:55:41 +0000 |
665 | +++ places/dash.qml 2012-01-26 18:08:33 +0000 |
666 | @@ -40,15 +40,11 @@ |
667 | value: (currentPage && currentPage.expanded != undefined) ? currentPage.expanded : true |
668 | } |
669 | |
670 | - DashSettings { |
671 | - id: settings |
672 | - } |
673 | - |
674 | Binding { |
675 | target: dashView |
676 | property: "dashMode" |
677 | - value: (settings.formFactor == DashSettings.Desktop) ? |
678 | - DashDeclarativeView.DesktopMode : DashDeclarativeView.FullScreenMode |
679 | + value: dashClient.alwaysFullScreen || dash2dConfiguration.fullScreen ? |
680 | + DashDeclarativeView.FullScreenMode : DashDeclarativeView.DesktopMode |
681 | } |
682 | |
683 | function activatePage(page) { |
684 | |
685 | === added file 'tests/places/fullscreen.rb' |
686 | --- tests/places/fullscreen.rb 1970-01-01 00:00:00 +0000 |
687 | +++ tests/places/fullscreen.rb 2012-01-26 18:08:33 +0000 |
688 | @@ -0,0 +1,169 @@ |
689 | +#!/usr/bin/env ruby1.8 |
690 | +=begin |
691 | +/* |
692 | + * This file is part of unity-2d |
693 | + * |
694 | + * Copyright 2011 Canonical Ltd. |
695 | + * |
696 | + * Authors: |
697 | + * - Ugo Riboni <ugo.riboni@canonical.com> |
698 | + * - Gerry Boland <gerry.boland@canonical.com> |
699 | + * |
700 | + * This program is free software; you can redistribute it and/or modify |
701 | + * it under the terms of the GNU General Public License as published by |
702 | + * the Free Software Foundation; version 3. |
703 | + * |
704 | + * This program is distributed in the hope that it will be useful, |
705 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
706 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
707 | + * GNU General Public License for more details. |
708 | + * |
709 | + * You should have received a copy of the GNU General Public License |
710 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
711 | + */ |
712 | +=end |
713 | + |
714 | +require '../run-tests.rb' unless $INIT_COMPLETED |
715 | +require 'xdo/xwindow' |
716 | +require 'xdo/keyboard' |
717 | +require 'xdo/mouse' |
718 | +require 'timeout' |
719 | +require 'tmpdir' |
720 | +require 'tempfile' |
721 | +include TDriverVerify |
722 | + |
723 | +############################# Test Suite ############################# |
724 | +context "Dash fullscreen tests" do |
725 | + pwd = File.expand_path(File.dirname(__FILE__)) + '/' |
726 | + |
727 | + DASH_FULLSCREEN_KEY = '/com/canonical/unity-2d/dash/full-screen' |
728 | + DASH_MIN_SCREEN_WIDTH = 1280; |
729 | + DASH_MIN_SCREEN_HEIGHT = 1084; |
730 | + |
731 | + # Run once at the beginning of this test suite |
732 | + startup do |
733 | + system 'killall unity-2d-places > /dev/null 2>&1' |
734 | + system 'killall unity-2d-panel > /dev/null 2>&1' |
735 | + system 'killall unity-2d-launcher > /dev/null 2>&1' |
736 | + system 'killall unity-2d-launcher > /dev/null 2>&1' |
737 | + |
738 | + # Minimize all windows |
739 | + XDo::XWindow.toggle_minimize_all |
740 | + end |
741 | + |
742 | + # Run once at the end of this test suite |
743 | + shutdown do |
744 | + end |
745 | + |
746 | + # Run before each test case begins |
747 | + setup do |
748 | + @oldvalue = %x{dconf read #{DASH_FULLSCREEN_KEY}}.chop |
749 | + |
750 | + # Execute the application |
751 | + @sut = TDriver.sut(:Id => "sut_qt") |
752 | + @dash = @sut.run(:name => UNITY_2D_PLACES, |
753 | + :arguments => "-testability", |
754 | + :sleeptime => 2) |
755 | + @panel = @sut.run(:name => UNITY_2D_PANEL, |
756 | + :arguments => "-testability", |
757 | + :sleeptime => 2) |
758 | + @launcher = @sut.run(:name => UNITY_2D_LAUNCHER, |
759 | + :arguments => "-testability", |
760 | + :sleeptime => 2) |
761 | + |
762 | + verify(10){ @panel.Unity2dPanel() } |
763 | + verify(10){ @launcher.Unity2dPanel() } |
764 | + # Dash can't be verified here as the declarative view is hidden until we make it active |
765 | + end |
766 | + |
767 | + # Run after each test case completes |
768 | + teardown do |
769 | + %x{dconf write #{DASH_FULLSCREEN_KEY} #{@oldvalue}} |
770 | + system "pkill -nf unity-2d-panel" |
771 | + system "pkill -nf unity-2d-places" |
772 | + system "pkill -nf unity-2d-launcher" |
773 | + end |
774 | + |
775 | + def dash_always_fullscreen |
776 | + out = %x{xdotool getdisplaygeometry} |
777 | + width, height = out.split.collect { |coord| coord.to_i } |
778 | + return width < DASH_MIN_SCREEN_WIDTH && height < DASH_MIN_SCREEN_HEIGHT |
779 | + end |
780 | + |
781 | + ##################################################################################### |
782 | + # Test cases |
783 | + |
784 | + test "Dash fullscreens on dconf key change" do |
785 | + %x{dconf write #{DASH_FULLSCREEN_KEY} false} |
786 | + XDo::Keyboard.super |
787 | + sleep 1 |
788 | + |
789 | + verify_equal('true', TIMEOUT, 'Dash did not appear') { |
790 | + @dash.DashDeclarativeView()['active'] |
791 | + } |
792 | + |
793 | + expected = dash_always_fullscreen ? 'FullScreenMode' : 'DesktopMode' |
794 | + verify_equal(expected, TIMEOUT, 'Dash is in the wrong fullscreen state') { |
795 | + @dash.DashDeclarativeView()['dashMode'] |
796 | + } |
797 | + |
798 | + %x{dconf write #{DASH_FULLSCREEN_KEY} true} |
799 | + sleep 1 |
800 | + |
801 | + verify_equal('FullScreenMode', TIMEOUT, 'Dash is not fullscreen but should be') { |
802 | + @dash.DashDeclarativeView()['dashMode'] |
803 | + } |
804 | + end |
805 | + |
806 | + test "Dash reacts correctly to panel buttons" do |
807 | + oldvalue = %x{dconf read #{DASH_FULLSCREEN_KEY}} |
808 | + |
809 | + %x{dconf write #{DASH_FULLSCREEN_KEY} false} |
810 | + XDo::Keyboard.super |
811 | + sleep 1 |
812 | + verify_equal('true', TIMEOUT, 'Dash did not appear') { |
813 | + @dash.DashDeclarativeView()['active'] |
814 | + } |
815 | + |
816 | + maxbutton = nil |
817 | + verify(TIMEOUT, 'The "maximize" button did not appear when the dash was visible' ) { |
818 | + maxbutton = @panel.AppNameApplet().children( :type => 'QAbstractButton' )[2] |
819 | + } |
820 | + |
821 | + maxbutton.tap if maxbutton |
822 | + sleep 1 |
823 | + verify_equal('FullScreenMode', TIMEOUT, 'Dash should be fullsceen, but it is not' ) { |
824 | + @dash.DashDeclarativeView()['dashMode'] |
825 | + } |
826 | + |
827 | + # When always fullscreen tapping the max button does nothing, so the key should remain set to |
828 | + # false. |
829 | + expected = dash_always_fullscreen ? 'false' : 'true' |
830 | + verify_equal(expected, TIMEOUT, 'Dash fullscreen key has the wrong value after maximize') { |
831 | + %x{dconf read #{DASH_FULLSCREEN_KEY}}.chop |
832 | + } |
833 | + |
834 | + maxbutton.tap if maxbutton |
835 | + sleep 1 |
836 | + expected = dash_always_fullscreen ? 'FullScreenMode' : 'DesktopMode' |
837 | + verify_equal(expected, TIMEOUT, 'Dash is in the wrong fullscreen state' ) { |
838 | + @dash.DashDeclarativeView()['dashMode'] |
839 | + } |
840 | + verify_equal('false', TIMEOUT, 'Dash fullscreen key was not unset') { |
841 | + %x{dconf read #{DASH_FULLSCREEN_KEY}}.chop |
842 | + } |
843 | + end |
844 | + |
845 | + test "Dash fullscreen initially" do |
846 | + %x{dconf write #{DASH_FULLSCREEN_KEY} true} |
847 | + XDo::Keyboard.super |
848 | + sleep 1 |
849 | + |
850 | + verify_equal('true', TIMEOUT, 'Dash did not appear') { |
851 | + @dash.DashDeclarativeView()['active'] |
852 | + } |
853 | + verify_equal('FullScreenMode', TIMEOUT, 'Dash initial state is wrong') { |
854 | + @dash.DashDeclarativeView()['dashMode'] |
855 | + } |
856 | + end |
857 | +end |
Forgot to mention it depends on https:/ /code.launchpad .net/~unity- 2d-team/ unity-2d/ unity-2d- dash-fullscreen -via-dconf/ +merge/ 89867