Merge lp:~unity-2d-team/unity-2d/unity-2d-dash-always-fullscreen-by-resolution into lp:unity-2d

Proposed by Ugo Riboni
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
Reviewer Review Type Date Requested Status
Florian Boucault (community) Needs Fixing
Review via email: mp+89886@code.launchpad.net

Description of the change

[dash][panel] Refactor testing for forced dash fullscreen based on resolution into DashClient

To post a comment you must log in.
Revision history for this message
Ugo Riboni (uriboni) wrote :
Revision history for this message
Florian Boucault (fboucault) wrote :

Any reason why not defining minimumSizeForDesktop as a property already?

Revision history for this message
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->rootContext()->setContextProperty(...)"

review: Needs Fixing
Revision history for this message
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

Revision history for this message
Lohith D Shivamurthy (dyams) wrote :

Functionally no issues found

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

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

Revision history for this message
Ugo Riboni (uriboni) wrote :
875. By Ugo Riboni

Merge fixes to tests from parent branch

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'config.h.in'
--- config.h.in 2011-12-07 19:20:54 +0000
+++ config.h.in 2012-01-26 18:08:33 +0000
@@ -11,6 +11,7 @@
11static const char* UNITY2D_DCONF_SCHEMA = "com.canonical.Unity2d";11static const char* UNITY2D_DCONF_SCHEMA = "com.canonical.Unity2d";
12static const char* LAUNCHER2D_DCONF_SCHEMA = "com.canonical.Unity2d.Launcher";12static const char* LAUNCHER2D_DCONF_SCHEMA = "com.canonical.Unity2d.Launcher";
13static const char* PANEL2D_DCONF_SCHEMA = "com.canonical.Unity2d.Panel";13static const char* PANEL2D_DCONF_SCHEMA = "com.canonical.Unity2d.Panel";
14static const char* DASH2D_DCONF_SCHEMA = "com.canonical.Unity2d.Dash";
1415
15static const char* UNITY_DCONF_SCHEMA = "com.canonical.Unity";16static const char* UNITY_DCONF_SCHEMA = "com.canonical.Unity";
16static const char* LAUNCHER_DCONF_SCHEMA = "com.canonical.Unity.Launcher";17static const char* LAUNCHER_DCONF_SCHEMA = "com.canonical.Unity.Launcher";
@@ -31,6 +32,11 @@
31 return configuration;32 return configuration;
32}33}
3334
35inline QConf& dash2dConfiguration() {
36 static QConf configuration(DASH2D_DCONF_SCHEMA);
37 return configuration;
38}
39
34inline QConf& unityConfiguration() {40inline QConf& unityConfiguration() {
35 static QConf configuration(UNITY_DCONF_SCHEMA);41 static QConf configuration(UNITY_DCONF_SCHEMA);
36 return configuration;42 return configuration;
3743
=== modified file 'data/com.canonical.Unity2d.gschema.xml'
--- data/com.canonical.Unity2d.gschema.xml 2011-12-01 09:55:45 +0000
+++ data/com.canonical.Unity2d.gschema.xml 2012-01-26 18:08:33 +0000
@@ -36,4 +36,14 @@
36 </description>36 </description>
37 </key>37 </key>
38 </schema>38 </schema>
39 <schema path="/com/canonical/unity-2d/dash/" id="com.canonical.Unity2d.Dash" gettext-domain="unity-2d">
40 <key type="b" name="full-screen">
41 <default>false</default>
42 <summary>The current fullscreen status of the dash</summary>
43 <description>
44 Describe if the dash should be fullscreen or not. If the dash is already running this setting
45 is applied immediately, otherwise it is applied as soon as the dash is activated again.
46 </description>
47 </key>
48 </schema>
39</schemalist>49</schemalist>
4050
=== modified file 'libunity-2d-private/Unity2d/plugin.cpp'
--- libunity-2d-private/Unity2d/plugin.cpp 2012-01-19 14:35:41 +0000
+++ libunity-2d-private/Unity2d/plugin.cpp 2012-01-26 18:08:33 +0000
@@ -22,7 +22,6 @@
22*/22*/
23#include "plugin.h"23#include "plugin.h"
2424
25#include "dashsettings.h"
26#include "launcherapplication.h"25#include "launcherapplication.h"
27#include "launcherdevice.h"26#include "launcherdevice.h"
28#include "trash.h"27#include "trash.h"
@@ -50,6 +49,7 @@
50#include "launcherdropitem.h"49#include "launcherdropitem.h"
5150
52#include "config.h"51#include "config.h"
52#include "dashclient.h"
5353
54#include "autohidebehavior.h"54#include "autohidebehavior.h"
55#include "intellihidebehavior.h"55#include "intellihidebehavior.h"
@@ -81,8 +81,6 @@
8181
82#include <X11/Xlib.h>82#include <X11/Xlib.h>
8383
84using namespace Unity2d;
85
86/* FIXME: This should be done more properly, it's just an hack this way.84/* FIXME: This should be done more properly, it's just an hack this way.
87 We should silence only the errors that we know we can produce.85 We should silence only the errors that we know we can produce.
88 We could probably also learn something from gdk-error-trap-push.86 We could probably also learn something from gdk-error-trap-push.
@@ -100,8 +98,6 @@
100{98{
101 qmlRegisterType<QSortFilterProxyModelQML>(uri, 0, 1, "SortFilterProxyModel");99 qmlRegisterType<QSortFilterProxyModelQML>(uri, 0, 1, "SortFilterProxyModel");
102100
103 qmlRegisterType<DashSettings>(uri, 0, 1, "DashSettings");
104
105 qmlRegisterType<WindowInfo>(uri, 0, 1, "WindowInfo");101 qmlRegisterType<WindowInfo>(uri, 0, 1, "WindowInfo");
106 qmlRegisterType<WindowsList>(uri, 0, 1, "WindowsList");102 qmlRegisterType<WindowsList>(uri, 0, 1, "WindowsList");
107 qmlRegisterType<ScreenInfo>(); // Register the type as non creatable103 qmlRegisterType<ScreenInfo>(); // Register the type as non creatable
@@ -162,6 +158,7 @@
162 qmlRegisterType<FilterOption>();158 qmlRegisterType<FilterOption>();
163 qmlRegisterType<FilterOptions>();159 qmlRegisterType<FilterOptions>();
164160
161 qmlRegisterType<DashClient>();
165}162}
166163
167void Unity2dPlugin::initializeEngine(QDeclarativeEngine *engine, const char *uri)164void Unity2dPlugin::initializeEngine(QDeclarativeEngine *engine, const char *uri)
@@ -179,6 +176,10 @@
179 engine->rootContext()->setContextProperty("screen", ScreenInfo::instance());176 engine->rootContext()->setContextProperty("screen", ScreenInfo::instance());
180 engine->rootContext()->setContextProperty("iconUtilities", new IconUtilities(engine));177 engine->rootContext()->setContextProperty("iconUtilities", new IconUtilities(engine));
181178
179 /* Expose QConf objects as a context property not to initialize it multiple times */
180 engine->rootContext()->setContextProperty("dash2dConfiguration", &dash2dConfiguration());
181 engine->rootContext()->setContextProperty("dashClient", DashClient::instance());
182
182 /* Critically important to set the client type to pager because wnck183 /* Critically important to set the client type to pager because wnck
183 will pass that type over to the window manager through XEvents.184 will pass that type over to the window manager through XEvents.
184 Window managers tend to respect orders from pagers to the letter by185 Window managers tend to respect orders from pagers to the letter by
185186
=== modified file 'libunity-2d-private/src/CMakeLists.txt'
--- libunity-2d-private/src/CMakeLists.txt 2012-01-19 14:35:41 +0000
+++ libunity-2d-private/src/CMakeLists.txt 2012-01-26 18:08:33 +0000
@@ -4,7 +4,6 @@
4set(lib${LIB_NAME}_SRCS4set(lib${LIB_NAME}_SRCS
5 bfb.cpp5 bfb.cpp
6 dashclient.cpp6 dashclient.cpp
7 dashsettings.cpp
8 debug.cpp7 debug.cpp
9 gconnector.cpp8 gconnector.cpp
10 gimageutils.cpp9 gimageutils.cpp
1110
=== modified file 'libunity-2d-private/src/dashclient.cpp'
--- libunity-2d-private/src/dashclient.cpp 2011-08-11 15:36:04 +0000
+++ libunity-2d-private/src/dashclient.cpp 2012-01-26 18:08:33 +0000
@@ -32,15 +32,21 @@
32#include <QDBusConnectionInterface>32#include <QDBusConnectionInterface>
33#include <QDBusInterface>33#include <QDBusInterface>
34#include <QDBusServiceWatcher>34#include <QDBusServiceWatcher>
35#include <QDesktopWidget>
36#include <QRect>
3537
36static const char* DASH_DBUS_SERVICE = "com.canonical.Unity2d.Dash";38static const char* DASH_DBUS_SERVICE = "com.canonical.Unity2d.Dash";
37static const char* DASH_DBUS_PATH = "/Dash";39static const char* DASH_DBUS_PATH = "/Dash";
38static const char* DASH_DBUS_INTERFACE = "com.canonical.Unity2d.Dash";40static const char* DASH_DBUS_INTERFACE = "com.canonical.Unity2d.Dash";
3941
42static const int DASH_MIN_SCREEN_WIDTH = 1280;
43static const int DASH_MIN_SCREEN_HEIGHT = 1084;
44
40DashClient::DashClient(QObject* parent)45DashClient::DashClient(QObject* parent)
41: QObject(parent)46: QObject(parent)
42, m_dashDbusIface(0)47, m_dashDbusIface(0)
43, m_dashActive(false)48, m_dashActive(false)
49, m_alwaysFullScreen(false)
44{50{
45 /* Check if the dash is already up and running by asking the bus instead of51 /* Check if the dash is already up and running by asking the bus instead of
46 trying to create an instance of the interface. Creating an instance would52 trying to create an instance of the interface. Creating an instance would
@@ -59,6 +65,9 @@
59 this);65 this);
60 connect(watcher, SIGNAL(serviceRegistered(QString)), SLOT(connectToDash()));66 connect(watcher, SIGNAL(serviceRegistered(QString)), SLOT(connectToDash()));
61 }67 }
68
69 connect(QApplication::desktop(), SIGNAL(resized(int)), SLOT(updateAlwaysFullScreen()));
70 updateAlwaysFullScreen();
62}71}
6372
64void DashClient::connectToDash()73void DashClient::connectToDash()
@@ -152,4 +161,25 @@
152 }161 }
153}162}
154163
164QSize DashClient::minimumSizeForDesktop()
165{
166 return QSize(DASH_MIN_SCREEN_WIDTH, DASH_MIN_SCREEN_HEIGHT);
167}
168
169void DashClient::updateAlwaysFullScreen()
170{
171 QRect rect = QApplication::desktop()->screenGeometry();
172 QSize minSize = minimumSizeForDesktop();
173 bool alwaysFullScreen = rect.width() < minSize.width() && rect.height() < minSize.height();
174 if (m_alwaysFullScreen != alwaysFullScreen) {
175 m_alwaysFullScreen = alwaysFullScreen;
176 Q_EMIT alwaysFullScreenChanged();
177 }
178}
179
180bool DashClient::alwaysFullScreen() const
181{
182 return m_alwaysFullScreen;
183}
184
155#include "dashclient.moc"185#include "dashclient.moc"
156186
=== modified file 'libunity-2d-private/src/dashclient.h'
--- libunity-2d-private/src/dashclient.h 2011-08-11 15:36:04 +0000
+++ libunity-2d-private/src/dashclient.h 2012-01-26 18:08:33 +0000
@@ -25,6 +25,7 @@
2525
26// Qt26// Qt
27#include <QObject>27#include <QObject>
28#include <QSize>
2829
29class QDBusInterface;30class QDBusInterface;
3031
@@ -34,6 +35,8 @@
34class DashClient : public QObject35class DashClient : public QObject
35{36{
36 Q_OBJECT37 Q_OBJECT
38 Q_PROPERTY(bool alwaysFullScreen READ alwaysFullScreen NOTIFY alwaysFullScreenChanged)
39
37public:40public:
38 static DashClient* instance();41 static DashClient* instance();
3942
@@ -44,25 +47,29 @@
44 * - "" if the dash is not visible47 * - "" if the dash is not visible
45 */48 */
46 QString activePage() const;49 QString activePage() const;
4750 bool alwaysFullScreen() const;
48 void setActivePage(const QString& page, const QString& lensId=QString());51 void setActivePage(const QString& page, const QString& lensId=QString());
52 static QSize minimumSizeForDesktop();
4953
50Q_SIGNALS:54Q_SIGNALS:
51 void activePageChanged(const QString&);55 void activePageChanged(const QString&);
56 void alwaysFullScreenChanged();
5257
53private Q_SLOTS:58private Q_SLOTS:
54 void connectToDash();59 void connectToDash();
55 void slotDashActiveChanged(bool);60 void slotDashActiveChanged(bool);
56 void slotDashActiveLensChanged(const QString&);61 void slotDashActiveLensChanged(const QString&);
62 void updateAlwaysFullScreen();
5763
58private:64private:
59 DashClient(QObject* parent=0);65 DashClient(QObject* parent = 0);
60 void updateActivePage();66 void updateActivePage();
6167
62 QDBusInterface* m_dashDbusIface;68 QDBusInterface* m_dashDbusIface;
63 bool m_dashActive;69 bool m_dashActive;
64 QString m_dashActiveLens;70 QString m_dashActiveLens;
65 QString m_activePage;71 QString m_activePage;
72 bool m_alwaysFullScreen;
66};73};
6774
68#endif /* DASHCLIENT_H */75#endif /* DASHCLIENT_H */
6976
=== removed file 'libunity-2d-private/src/dashsettings.cpp'
--- libunity-2d-private/src/dashsettings.cpp 2011-12-09 09:14:11 +0000
+++ libunity-2d-private/src/dashsettings.cpp 1970-01-01 00:00:00 +0000
@@ -1,112 +0,0 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2011 Canonical Ltd.
5 *
6 * Authors:
7 * - Alberto Mardegan <alberto.mardegan@canonical.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21// Self
22#include "dashsettings.h"
23
24// Local
25
26// Qt
27#include <QMetaEnum>
28#include <QSize>
29#include <QVariant>
30
31#include <config.h>
32
33static const int DASH_MIN_SCREEN_WIDTH = 1280;
34static const int DASH_MIN_SCREEN_HEIGHT = 1084;
35
36static const char* FORM_FACTOR = "formFactor";
37
38namespace Unity2d {
39
40class DashSettingsPrivate
41{
42 DashSettingsPrivate(DashSettings *dashSettings)
43 {
44 /* proxy the formFactor property signal notifier */
45 QObject::connect(&unityConfiguration(), SIGNAL(formFactorChanged(QString)),
46 dashSettings, SIGNAL(formFactorChanged()));
47
48 /* Get the QMetaEnum for FormFactor: we will use it when setting and
49 * getting the property, to convert the string value returned by QConf
50 * to an enum value, and vice versa. */
51 const QMetaObject *metaObject = dashSettings->metaObject();
52 int index = metaObject->indexOfEnumerator("FormFactor");
53 formFactorEnum = metaObject->enumerator(index);
54 }
55
56 ~DashSettingsPrivate()
57 {
58 }
59
60private:
61 DashSettings* q_ptr;
62 Q_DECLARE_PUBLIC(DashSettings)
63
64 QMetaEnum formFactorEnum;
65};
66
67DashSettings::DashSettings(QObject* parent):
68 QObject(parent),
69 d_ptr(new DashSettingsPrivate(this))
70{
71}
72
73DashSettings::~DashSettings()
74{
75 delete d_ptr;
76}
77
78void DashSettings::setFormFactor(FormFactor formFactor)
79{
80 Q_D(DashSettings);
81
82 const char* name = d->formFactorEnum.valueToKey(formFactor);
83 unityConfiguration().setProperty(FORM_FACTOR, QVariant(QString::fromLatin1(name)));
84}
85
86DashSettings::FormFactor DashSettings::formFactor() const
87{
88 Q_D(const DashSettings);
89 QByteArray key = unityConfiguration().property(FORM_FACTOR).toString().toLatin1();
90 return FormFactor(d->formFactorEnum.keyToValue(key.constData()));
91}
92
93static int getenvInt(const char* name, int defaultValue)
94{
95 QByteArray stringValue = qgetenv(name);
96 bool ok;
97 int value = stringValue.toInt(&ok);
98 return ok ? value : defaultValue;
99}
100
101QSize DashSettings::minimumSizeForDesktop()
102{
103 static int minWidth = getenvInt("DASH_MIN_SCREEN_WIDTH",
104 DASH_MIN_SCREEN_WIDTH);
105 static int minHeight = getenvInt("DASH_MIN_SCREEN_HEIGHT",
106 DASH_MIN_SCREEN_HEIGHT);
107 return QSize(minWidth, minHeight);
108}
109
110}; // namespace Unity2d
111
112#include "dashsettings.moc"
1130
=== removed file 'libunity-2d-private/src/dashsettings.h'
--- libunity-2d-private/src/dashsettings.h 2011-10-17 12:12:10 +0000
+++ libunity-2d-private/src/dashsettings.h 1970-01-01 00:00:00 +0000
@@ -1,72 +0,0 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2011 Canonical Ltd.
5 *
6 * Authors:
7 * - Alberto Mardegan <alberto.mardegan@canonical.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21#ifndef DASHSETTINGS_H
22#define DASHSETTINGS_H
23
24// Qt
25#include <QObject>
26#include <QMetaType>
27
28namespace Unity2d {
29
30class DashSettingsPrivate;
31
32/**
33 * Provide easy access to the Dash settings (from Qt and QML)
34 */
35class DashSettings: public QObject
36{
37 Q_OBJECT
38
39 Q_ENUMS(FormFactor)
40
41 Q_PROPERTY(FormFactor formFactor READ formFactor WRITE setFormFactor NOTIFY formFactorChanged)
42
43public:
44 explicit DashSettings(QObject* parent = 0);
45 ~DashSettings();
46
47 enum FormFactor
48 {
49 Automatic = 0,
50 Desktop,
51 Netbook
52 };
53
54 void setFormFactor(FormFactor formFactor);
55 FormFactor formFactor() const;
56
57 static QSize minimumSizeForDesktop();
58
59Q_SIGNALS:
60 void formFactorChanged();
61
62private:
63 Q_DISABLE_COPY(DashSettings)
64 DashSettingsPrivate* d_ptr;
65 Q_DECLARE_PRIVATE(DashSettings)
66};
67
68} // namespace Unity2d
69
70Q_DECLARE_METATYPE(Unity2d::DashSettings::FormFactor)
71
72#endif /* DASHSETTINGS_H */
730
=== modified file 'panel/applets/appname/appnameapplet.cpp'
--- panel/applets/appname/appnameapplet.cpp 2012-01-13 17:33:12 +0000
+++ panel/applets/appname/appnameapplet.cpp 2012-01-26 18:08:33 +0000
@@ -28,6 +28,7 @@
28#include "panelstyle.h"28#include "panelstyle.h"
29#include "unity2dpanel.h"29#include "unity2dpanel.h"
30#include "windowhelper.h"30#include "windowhelper.h"
31#include "dashclient.h"
3132
32// Unity-2d33// Unity-2d
33#include <debug_p.h>34#include <debug_p.h>
@@ -226,6 +227,8 @@
226 d->setupMenuBarWidget(panel->indicatorsManager());227 d->setupMenuBarWidget(panel->indicatorsManager());
227 d->setupKeyboardModifiersMonitor();228 d->setupKeyboardModifiersMonitor();
228229
230 connect(DashClient::instance(), SIGNAL(alwaysFullScreenChanged()), SLOT(updateWidgets()));
231
229 QHBoxLayout* layout = new QHBoxLayout(this);232 QHBoxLayout* layout = new QHBoxLayout(this);
230 layout->setMargin(0);233 layout->setMargin(0);
231 layout->setSpacing(0);234 layout->setSpacing(0);
@@ -259,7 +262,7 @@
259 || d->m_menuBarWidget->isOpened()262 || d->m_menuBarWidget->isOpened()
260 );263 );
261 bool showMenu = isOpened && !d->m_menuBarWidget->isEmpty() && isUserVisibleApp;264 bool showMenu = isOpened && !d->m_menuBarWidget->isEmpty() && isUserVisibleApp;
262 bool dashCanResize = d->m_windowHelper->dashCanResize();265 bool dashCanResize = !DashClient::instance()->alwaysFullScreen();
263 bool dashIsVisible = d->m_windowHelper->dashIsVisible();266 bool dashIsVisible = d->m_windowHelper->dashIsVisible();
264 bool showWindowButtons = (isOpened && isMaximized) || dashIsVisible;267 bool showWindowButtons = (isOpened && isMaximized) || dashIsVisible;
265 bool showAppLabel = !(isMaximized && showMenu) && isUserVisibleApp && isOnSameScreen;268 bool showAppLabel = !(isMaximized && showMenu) && isUserVisibleApp && isOnSameScreen;
266269
=== modified file 'panel/applets/appname/windowhelper.cpp'
--- panel/applets/appname/windowhelper.cpp 2011-12-02 04:22:53 +0000
+++ panel/applets/appname/windowhelper.cpp 2012-01-26 18:08:33 +0000
@@ -23,9 +23,10 @@
23#include "windowhelper.h"23#include "windowhelper.h"
2424
25// Local25// Local
26#include "config.h"
2627
27// unity-2d28// unity-2d
28#include <dashsettings.h>29#include <dashclient.h>
29#include <debug_p.h>30#include <debug_p.h>
30#include <gconnector.h>31#include <gconnector.h>
31#include <screeninfo.h>32#include <screeninfo.h>
@@ -45,38 +46,18 @@
45#include <QApplication>46#include <QApplication>
46#include <QDesktopWidget>47#include <QDesktopWidget>
47#include <QPoint>48#include <QPoint>
49#include <QVariant>
4850
49// X1151// X11
50#include <X11/Xlib.h>52#include <X11/Xlib.h>
51#include <X11/Xatom.h>53#include <X11/Xatom.h>
52#include <QX11Info>54#include <QX11Info>
5355
54using namespace Unity2d;
55
56struct WindowHelperPrivate56struct WindowHelperPrivate
57{57{
58 void updateDashCanResize()
59 {
60 WnckScreen* screen = wnck_window_get_screen(m_window);
61 int screenNumber = wnck_screen_get_number(screen);
62 QRect rect = QApplication::desktop()->screenGeometry(screenNumber);
63
64 /* If the screen size too small, we don't allow the Dash to be used
65 * in Desktop mode (not fullscreen) */
66 QSize minSize = DashSettings::minimumSizeForDesktop();
67 if (rect.width() < minSize.width() &&
68 rect.height() < minSize.height()) {
69 m_dashCanResize = false;
70 } else {
71 m_dashCanResize = true;
72 }
73 }
74
75 DashSettings* m_dashSettings;
76 WnckWindow* m_window;58 WnckWindow* m_window;
77 GConnector m_connector;59 GConnector m_connector;
78 bool m_activeWindowIsDash;60 bool m_activeWindowIsDash;
79 bool m_dashCanResize;
80};61};
8162
82WindowHelper::WindowHelper(QObject* parent)63WindowHelper::WindowHelper(QObject* parent)
@@ -84,7 +65,6 @@
84, d(new WindowHelperPrivate)65, d(new WindowHelperPrivate)
85{66{
86 d->m_window = 0;67 d->m_window = 0;
87 d->m_dashSettings = new DashSettings(this);
8868
89 WnckScreen* screen = wnck_screen_get_default();69 WnckScreen* screen = wnck_screen_get_default();
90 wnck_screen_force_update(screen);70 wnck_screen_force_update(screen);
@@ -123,12 +103,6 @@
123 QMetaObject::invokeMethod(watcher, "nameChanged");103 QMetaObject::invokeMethod(watcher, "nameChanged");
124}104}
125105
126static void geometryChangedCB(GObject* window,
127 WindowHelper* watcher)
128{
129 QMetaObject::invokeMethod(watcher, "stateChanged");
130}
131
132void WindowHelper::update()106void WindowHelper::update()
133{107{
134 BamfWindow* bamfWindow = BamfMatcher::get_default().active_window();108 BamfWindow* bamfWindow = BamfMatcher::get_default().active_window();
@@ -143,16 +117,6 @@
143117
144 const char *name = wnck_window_get_name(d->m_window);118 const char *name = wnck_window_get_name(d->m_window);
145 d->m_activeWindowIsDash = qstrcmp(name, "unity-2d-places") == 0;119 d->m_activeWindowIsDash = qstrcmp(name, "unity-2d-places") == 0;
146 if (d->m_activeWindowIsDash) {
147 /* Since we are not really minimizing and maximizing the dash we
148 * cannot rely on the wnck "state-changed" signal to be emitted;
149 * instead, listen for the "geometry-changed" and emit our
150 * stateChanged() from that. */
151 d->m_connector.connect(G_OBJECT(d->m_window), "geometry-changed",
152 G_CALLBACK(geometryChangedCB), this);
153
154 d->updateDashCanResize();
155 }
156120
157 d->m_connector.connect(G_OBJECT(d->m_window), "name-changed", G_CALLBACK(nameChangedCB), this);121 d->m_connector.connect(G_OBJECT(d->m_window), "name-changed", G_CALLBACK(nameChangedCB), this);
158 d->m_connector.connect(G_OBJECT(d->m_window), "state-changed", G_CALLBACK(stateChangedCB), this);122 d->m_connector.connect(G_OBJECT(d->m_window), "state-changed", G_CALLBACK(stateChangedCB), this);
@@ -167,11 +131,7 @@
167 return false;131 return false;
168 }132 }
169 if (d->m_activeWindowIsDash) {133 if (d->m_activeWindowIsDash) {
170 int x, y, width, height;134 return dash2dConfiguration().property("fullScreen").toBool();
171 wnck_window_get_geometry(d->m_window, &x, &y, &width, &height);
172 const QRect windowGeometry(x, y, width, height);
173 ScreenInfo* screenInfo = ScreenInfo::instance();
174 return screenInfo->panelsFreeGeometry() == windowGeometry;
175 } else {135 } else {
176 return wnck_window_is_maximized(d->m_window);136 return wnck_window_is_maximized(d->m_window);
177 }137 }
@@ -205,11 +165,6 @@
205 return d->m_window != 0 && d->m_activeWindowIsDash;165 return d->m_window != 0 && d->m_activeWindowIsDash;
206}166}
207167
208bool WindowHelper::dashCanResize() const
209{
210 return d->m_dashCanResize;
211}
212
213void WindowHelper::close()168void WindowHelper::close()
214{169{
215 guint32 timestamp = QDateTime::currentDateTime().toTime_t();170 guint32 timestamp = QDateTime::currentDateTime().toTime_t();
@@ -226,7 +181,7 @@
226void WindowHelper::maximize()181void WindowHelper::maximize()
227{182{
228 if (d->m_activeWindowIsDash) {183 if (d->m_activeWindowIsDash) {
229 d->m_dashSettings->setFormFactor(DashSettings::Netbook);184 dash2dConfiguration().setProperty("fullScreen", QVariant(true));
230 } else {185 } else {
231 /* This currently cannot happen, because the window buttons are not186 /* This currently cannot happen, because the window buttons are not
232 * shown in the panel for non maximized windows. It's here just for187 * shown in the panel for non maximized windows. It's here just for
@@ -238,7 +193,7 @@
238void WindowHelper::unmaximize()193void WindowHelper::unmaximize()
239{194{
240 if (d->m_activeWindowIsDash) {195 if (d->m_activeWindowIsDash) {
241 d->m_dashSettings->setFormFactor(DashSettings::Desktop);196 dash2dConfiguration().setProperty("fullScreen", QVariant(false));
242 } else {197 } else {
243 wnck_window_unmaximize(d->m_window);198 wnck_window_unmaximize(d->m_window);
244 }199 }
245200
=== modified file 'panel/applets/appname/windowhelper.h'
--- panel/applets/appname/windowhelper.h 2011-10-17 12:46:55 +0000
+++ panel/applets/appname/windowhelper.h 2012-01-26 18:08:33 +0000
@@ -42,7 +42,6 @@
42 bool isMaximized() const;42 bool isMaximized() const;
43 bool isMostlyOnScreen(int screen) const;43 bool isMostlyOnScreen(int screen) const;
44 bool dashIsVisible() const;44 bool dashIsVisible() const;
45 bool dashCanResize() const;
4645
47public Q_SLOTS:46public Q_SLOTS:
48 void close();47 void close();
4948
=== modified file 'places/app/dashdeclarativeview.cpp'
--- places/app/dashdeclarativeview.cpp 2011-12-19 10:54:27 +0000
+++ places/app/dashdeclarativeview.cpp 2012-01-26 18:08:33 +0000
@@ -18,9 +18,9 @@
18#include "dashadaptor.h"18#include "dashadaptor.h"
1919
20// unity-2d20// unity-2d
21#include <dashsettings.h>
22#include <launcherclient.h>21#include <launcherclient.h>
23#include <screeninfo.h>22#include <screeninfo.h>
23#include <dashclient.h>
2424
25// Qt25// Qt
26#include <QDesktopWidget>26#include <QDesktopWidget>
@@ -57,7 +57,6 @@
5757
58 QDesktopWidget* desktop = QApplication::desktop();58 QDesktopWidget* desktop = QApplication::desktop();
59 connect(desktop, SIGNAL(resized(int)), SIGNAL(screenGeometryChanged()));59 connect(desktop, SIGNAL(resized(int)), SIGNAL(screenGeometryChanged()));
60 connect(desktop, SIGNAL(resized(int)), SLOT(updateDashModeDependingOnScreenGeometry()));
61 connect(desktop, SIGNAL(workAreaResized(int)), SLOT(onWorkAreaResized(int)));60 connect(desktop, SIGNAL(workAreaResized(int)), SLOT(onWorkAreaResized(int)));
6261
63 updateSize();62 updateSize();
@@ -74,18 +73,6 @@
74}73}
7574
76void75void
77DashDeclarativeView::updateDashModeDependingOnScreenGeometry()
78{
79 QRect rect = QApplication::desktop()->screenGeometry(this);
80 QSize minSize = Unity2d::DashSettings::minimumSizeForDesktop();
81 if (rect.width() < minSize.width() && rect.height() < minSize.height()) {
82 setDashMode(FullScreenMode);
83 } else {
84 setDashMode(DesktopMode);
85 }
86}
87
88void
89DashDeclarativeView::updateSize()76DashDeclarativeView::updateSize()
90{77{
91 if (m_mode == FullScreenMode) {78 if (m_mode == FullScreenMode) {
@@ -159,7 +146,6 @@
159 if (value != m_active) {146 if (value != m_active) {
160 m_active = value;147 m_active = value;
161 if (value) {148 if (value) {
162 updateDashModeDependingOnScreenGeometry();
163 show();149 show();
164 raise();150 raise();
165 // We need a delay, otherwise the window may not be visible when we try to activate it151 // We need a delay, otherwise the window may not be visible when we try to activate it
166152
=== modified file 'places/app/dashdeclarativeview.h'
--- places/app/dashdeclarativeview.h 2011-12-08 18:39:18 +0000
+++ places/app/dashdeclarativeview.h 2012-01-26 18:08:33 +0000
@@ -68,7 +68,6 @@
6868
69private Q_SLOTS:69private Q_SLOTS:
70 void onWorkAreaResized(int screen);70 void onWorkAreaResized(int screen);
71 void updateDashModeDependingOnScreenGeometry();
72 void updateSize();71 void updateSize();
7372
74private:73private:
7574
=== modified file 'places/dash.qml'
--- places/dash.qml 2012-01-03 11:55:41 +0000
+++ places/dash.qml 2012-01-26 18:08:33 +0000
@@ -40,15 +40,11 @@
40 value: (currentPage && currentPage.expanded != undefined) ? currentPage.expanded : true40 value: (currentPage && currentPage.expanded != undefined) ? currentPage.expanded : true
41 }41 }
4242
43 DashSettings {
44 id: settings
45 }
46
47 Binding {43 Binding {
48 target: dashView44 target: dashView
49 property: "dashMode"45 property: "dashMode"
50 value: (settings.formFactor == DashSettings.Desktop) ?46 value: dashClient.alwaysFullScreen || dash2dConfiguration.fullScreen ?
51 DashDeclarativeView.DesktopMode : DashDeclarativeView.FullScreenMode47 DashDeclarativeView.FullScreenMode : DashDeclarativeView.DesktopMode
52 }48 }
5349
54 function activatePage(page) {50 function activatePage(page) {
5551
=== added file 'tests/places/fullscreen.rb'
--- tests/places/fullscreen.rb 1970-01-01 00:00:00 +0000
+++ tests/places/fullscreen.rb 2012-01-26 18:08:33 +0000
@@ -0,0 +1,169 @@
1#!/usr/bin/env ruby1.8
2=begin
3/*
4 * This file is part of unity-2d
5 *
6 * Copyright 2011 Canonical Ltd.
7 *
8 * Authors:
9 * - Ugo Riboni <ugo.riboni@canonical.com>
10 * - Gerry Boland <gerry.boland@canonical.com>
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; version 3.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23 */
24=end
25
26require '../run-tests.rb' unless $INIT_COMPLETED
27require 'xdo/xwindow'
28require 'xdo/keyboard'
29require 'xdo/mouse'
30require 'timeout'
31require 'tmpdir'
32require 'tempfile'
33include TDriverVerify
34
35############################# Test Suite #############################
36context "Dash fullscreen tests" do
37 pwd = File.expand_path(File.dirname(__FILE__)) + '/'
38
39 DASH_FULLSCREEN_KEY = '/com/canonical/unity-2d/dash/full-screen'
40 DASH_MIN_SCREEN_WIDTH = 1280;
41 DASH_MIN_SCREEN_HEIGHT = 1084;
42
43 # Run once at the beginning of this test suite
44 startup do
45 system 'killall unity-2d-places > /dev/null 2>&1'
46 system 'killall unity-2d-panel > /dev/null 2>&1'
47 system 'killall unity-2d-launcher > /dev/null 2>&1'
48 system 'killall unity-2d-launcher > /dev/null 2>&1'
49
50 # Minimize all windows
51 XDo::XWindow.toggle_minimize_all
52 end
53
54 # Run once at the end of this test suite
55 shutdown do
56 end
57
58 # Run before each test case begins
59 setup do
60 @oldvalue = %x{dconf read #{DASH_FULLSCREEN_KEY}}.chop
61
62 # Execute the application
63 @sut = TDriver.sut(:Id => "sut_qt")
64 @dash = @sut.run(:name => UNITY_2D_PLACES,
65 :arguments => "-testability",
66 :sleeptime => 2)
67 @panel = @sut.run(:name => UNITY_2D_PANEL,
68 :arguments => "-testability",
69 :sleeptime => 2)
70 @launcher = @sut.run(:name => UNITY_2D_LAUNCHER,
71 :arguments => "-testability",
72 :sleeptime => 2)
73
74 verify(10){ @panel.Unity2dPanel() }
75 verify(10){ @launcher.Unity2dPanel() }
76 # Dash can't be verified here as the declarative view is hidden until we make it active
77 end
78
79 # Run after each test case completes
80 teardown do
81 %x{dconf write #{DASH_FULLSCREEN_KEY} #{@oldvalue}}
82 system "pkill -nf unity-2d-panel"
83 system "pkill -nf unity-2d-places"
84 system "pkill -nf unity-2d-launcher"
85 end
86
87 def dash_always_fullscreen
88 out = %x{xdotool getdisplaygeometry}
89 width, height = out.split.collect { |coord| coord.to_i }
90 return width < DASH_MIN_SCREEN_WIDTH && height < DASH_MIN_SCREEN_HEIGHT
91 end
92
93 #####################################################################################
94 # Test cases
95
96 test "Dash fullscreens on dconf key change" do
97 %x{dconf write #{DASH_FULLSCREEN_KEY} false}
98 XDo::Keyboard.super
99 sleep 1
100
101 verify_equal('true', TIMEOUT, 'Dash did not appear') {
102 @dash.DashDeclarativeView()['active']
103 }
104
105 expected = dash_always_fullscreen ? 'FullScreenMode' : 'DesktopMode'
106 verify_equal(expected, TIMEOUT, 'Dash is in the wrong fullscreen state') {
107 @dash.DashDeclarativeView()['dashMode']
108 }
109
110 %x{dconf write #{DASH_FULLSCREEN_KEY} true}
111 sleep 1
112
113 verify_equal('FullScreenMode', TIMEOUT, 'Dash is not fullscreen but should be') {
114 @dash.DashDeclarativeView()['dashMode']
115 }
116 end
117
118 test "Dash reacts correctly to panel buttons" do
119 oldvalue = %x{dconf read #{DASH_FULLSCREEN_KEY}}
120
121 %x{dconf write #{DASH_FULLSCREEN_KEY} false}
122 XDo::Keyboard.super
123 sleep 1
124 verify_equal('true', TIMEOUT, 'Dash did not appear') {
125 @dash.DashDeclarativeView()['active']
126 }
127
128 maxbutton = nil
129 verify(TIMEOUT, 'The "maximize" button did not appear when the dash was visible' ) {
130 maxbutton = @panel.AppNameApplet().children( :type => 'QAbstractButton' )[2]
131 }
132
133 maxbutton.tap if maxbutton
134 sleep 1
135 verify_equal('FullScreenMode', TIMEOUT, 'Dash should be fullsceen, but it is not' ) {
136 @dash.DashDeclarativeView()['dashMode']
137 }
138
139 # When always fullscreen tapping the max button does nothing, so the key should remain set to
140 # false.
141 expected = dash_always_fullscreen ? 'false' : 'true'
142 verify_equal(expected, TIMEOUT, 'Dash fullscreen key has the wrong value after maximize') {
143 %x{dconf read #{DASH_FULLSCREEN_KEY}}.chop
144 }
145
146 maxbutton.tap if maxbutton
147 sleep 1
148 expected = dash_always_fullscreen ? 'FullScreenMode' : 'DesktopMode'
149 verify_equal(expected, TIMEOUT, 'Dash is in the wrong fullscreen state' ) {
150 @dash.DashDeclarativeView()['dashMode']
151 }
152 verify_equal('false', TIMEOUT, 'Dash fullscreen key was not unset') {
153 %x{dconf read #{DASH_FULLSCREEN_KEY}}.chop
154 }
155 end
156
157 test "Dash fullscreen initially" do
158 %x{dconf write #{DASH_FULLSCREEN_KEY} true}
159 XDo::Keyboard.super
160 sleep 1
161
162 verify_equal('true', TIMEOUT, 'Dash did not appear') {
163 @dash.DashDeclarativeView()['active']
164 }
165 verify_equal('FullScreenMode', TIMEOUT, 'Dash initial state is wrong') {
166 @dash.DashDeclarativeView()['dashMode']
167 }
168 end
169end

Subscribers

People subscribed via source and target branches