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

Proposed by Ugo Riboni
Status: Superseded
Proposed branch: lp:~unity-2d-team/unity-2d/unity-2d-dash-fullscreen-by-formfactor
Merge into: lp:unity-2d
Prerequisite: lp:~unity-2d-team/unity-2d/unity-2d-dash-fullscreen-via-dconf
Diff against target: 517 lines (+72/-161)
13 files modified
data/com.canonical.Unity2d.gschema.xml (+7/-0)
libunity-2d-private/Unity2d/plugin.cpp (+2/-5)
libunity-2d-private/src/CMakeLists.txt (+0/-1)
libunity-2d-private/src/dashclient.cpp (+42/-0)
libunity-2d-private/src/dashclient.h (+9/-2)
libunity-2d-private/src/dashsettings.cpp (+0/-55)
libunity-2d-private/src/dashsettings.h (+0/-48)
panel/applets/appname/appnameapplet.cpp (+4/-1)
panel/applets/appname/windowhelper.cpp (+1/-31)
panel/applets/appname/windowhelper.h (+0/-1)
places/app/dashdeclarativeview.cpp (+1/-14)
places/app/dashdeclarativeview.h (+0/-1)
places/dash.qml (+6/-2)
To merge this branch: bzr merge lp:~unity-2d-team/unity-2d/unity-2d-dash-fullscreen-by-formfactor
Reviewer Review Type Date Requested Status
Florian Boucault Pending
Review via email: mp+89912@code.launchpad.net

This proposal has been superseded by a proposal from 2012-01-24.

Description of the change

[dash][panel] Add a new dconf key that defines the device form factor (tv, tablet, phone, desktop...) and force dash fullscreen if it's not desktop

To post a comment you must log in.
870. By Ugo Riboni

Merge changes from parent branch

871. By Ugo Riboni

Update tests and add a new one for the new feature

872. By Ugo Riboni

Merge fixes to tests from parent branch

873. By Ugo Riboni

Fix wrong quoting in dconf calls in tests

874. By Ugo Riboni

Merge changes from trunk

875. By Ugo Riboni

Add FIXME on workaround for dconf-qt deadlock

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'data/com.canonical.Unity2d.gschema.xml'
2--- data/com.canonical.Unity2d.gschema.xml 2012-01-24 14:41:27 +0000
3+++ data/com.canonical.Unity2d.gschema.xml 2012-01-24 14:41:27 +0000
4@@ -8,6 +8,13 @@
5 When set to false, the raster engine is used.
6 </description>
7 </key>
8+ <key type="s" name="form-factor">
9+ <default>"desktop"</default>
10+ <summary>What sort of device Unity is running on.</summary>
11+ <description>
12+ Unity will adapt its shape and form to the device it is running on.
13+ </description>
14+ </key>
15 </schema>
16 <schema path="/com/canonical/unity-2d/launcher/" id="com.canonical.Unity2d.Launcher" gettext-domain="unity-2d">
17 <key type="b" name="super-key-enable">
18
19=== modified file 'libunity-2d-private/Unity2d/plugin.cpp'
20--- libunity-2d-private/Unity2d/plugin.cpp 2012-01-24 14:41:27 +0000
21+++ libunity-2d-private/Unity2d/plugin.cpp 2012-01-24 14:41:27 +0000
22@@ -22,7 +22,6 @@
23 */
24 #include "plugin.h"
25
26-#include "dashsettings.h"
27 #include "launcherapplication.h"
28 #include "launcherdevice.h"
29 #include "trash.h"
30@@ -50,6 +49,7 @@
31 #include "launcherdropitem.h"
32
33 #include "config.h"
34+#include "dashclient.h"
35
36 #include "autohidebehavior.h"
37 #include "intellihidebehavior.h"
38@@ -81,8 +81,6 @@
39
40 #include <X11/Xlib.h>
41
42-using namespace Unity2d;
43-
44 /* FIXME: This should be done more properly, it's just an hack this way.
45 We should silence only the errors that we know we can produce.
46 We could probably also learn something from gdk-error-trap-push.
47@@ -100,8 +98,6 @@
48 {
49 qmlRegisterType<QSortFilterProxyModelQML>(uri, 0, 1, "SortFilterProxyModel");
50
51- qmlRegisterType<DashSettings>(uri, 0, 1, "DashSettings");
52-
53 qmlRegisterType<WindowInfo>(uri, 0, 1, "WindowInfo");
54 qmlRegisterType<WindowsList>(uri, 0, 1, "WindowsList");
55 qmlRegisterType<ScreenInfo>(); // Register the type as non creatable
56@@ -162,6 +158,7 @@
57 qmlRegisterType<FilterOption>();
58 qmlRegisterType<FilterOptions>();
59
60+ qmlRegisterType<DashClient>(uri, 0, 1, "DashClient");
61 }
62
63 void Unity2dPlugin::initializeEngine(QDeclarativeEngine *engine, const char *uri)
64
65=== modified file 'libunity-2d-private/src/CMakeLists.txt'
66--- libunity-2d-private/src/CMakeLists.txt 2012-01-19 14:35:41 +0000
67+++ libunity-2d-private/src/CMakeLists.txt 2012-01-24 14:41:27 +0000
68@@ -4,7 +4,6 @@
69 set(lib${LIB_NAME}_SRCS
70 bfb.cpp
71 dashclient.cpp
72- dashsettings.cpp
73 debug.cpp
74 gconnector.cpp
75 gimageutils.cpp
76
77=== modified file 'libunity-2d-private/src/dashclient.cpp'
78--- libunity-2d-private/src/dashclient.cpp 2011-08-11 15:36:04 +0000
79+++ libunity-2d-private/src/dashclient.cpp 2012-01-24 14:41:27 +0000
80@@ -22,6 +22,7 @@
81 #include "dashclient.h"
82
83 // Local
84+#include "config.h"
85
86 // libunity-2d
87 #include <debug_p.h>
88@@ -32,15 +33,21 @@
89 #include <QDBusConnectionInterface>
90 #include <QDBusInterface>
91 #include <QDBusServiceWatcher>
92+#include <QDesktopWidget>
93+#include <QRect>
94
95 static const char* DASH_DBUS_SERVICE = "com.canonical.Unity2d.Dash";
96 static const char* DASH_DBUS_PATH = "/Dash";
97 static const char* DASH_DBUS_INTERFACE = "com.canonical.Unity2d.Dash";
98
99+static const int DASH_MIN_SCREEN_WIDTH = 1280;
100+static const int DASH_MIN_SCREEN_HEIGHT = 1084;
101+
102 DashClient::DashClient(QObject* parent)
103 : QObject(parent)
104 , m_dashDbusIface(0)
105 , m_dashActive(false)
106+, m_alwaysFullScreen(false)
107 {
108 /* Check if the dash is already up and running by asking the bus instead of
109 trying to create an instance of the interface. Creating an instance would
110@@ -59,6 +66,14 @@
111 this);
112 connect(watcher, SIGNAL(serviceRegistered(QString)), SLOT(connectToDash()));
113 }
114+
115+ connect(QApplication::desktop(), SIGNAL(resized(int)), SLOT(updateAlwaysFullScreen()));
116+
117+ // NOTE: we need to use a queued connection here otherwise QConf will deadlock for some reason
118+ // when we read any property from the slot (which we need to do).
119+ connect(&unity2dConfiguration(), SIGNAL(formFactorChanged(QString)),
120+ SLOT(updateAlwaysFullScreen()), Qt::QueuedConnection);
121+ updateAlwaysFullScreen();
122 }
123
124 void DashClient::connectToDash()
125@@ -152,4 +167,31 @@
126 }
127 }
128
129+QSize DashClient::minimumSizeForDesktop()
130+{
131+ return QSize(DASH_MIN_SCREEN_WIDTH, DASH_MIN_SCREEN_HEIGHT);
132+}
133+
134+void DashClient::updateAlwaysFullScreen()
135+{
136+ bool alwaysFullScreen;
137+ if (unity2dConfiguration().property("formFactor").toString() != "desktop") {
138+ alwaysFullScreen = true;
139+ } else {
140+ QRect rect = QApplication::desktop()->screenGeometry();
141+ QSize minSize = minimumSizeForDesktop();
142+ alwaysFullScreen = rect.width() < minSize.width() && rect.height() < minSize.height();
143+ }
144+
145+ if (m_alwaysFullScreen != alwaysFullScreen) {
146+ m_alwaysFullScreen = alwaysFullScreen;
147+ Q_EMIT alwaysFullScreenChanged();
148+ }
149+}
150+
151+bool DashClient::alwaysFullScreen() const
152+{
153+ return m_alwaysFullScreen;
154+}
155+
156 #include "dashclient.moc"
157
158=== modified file 'libunity-2d-private/src/dashclient.h'
159--- libunity-2d-private/src/dashclient.h 2011-08-11 15:36:04 +0000
160+++ libunity-2d-private/src/dashclient.h 2012-01-24 14:41:27 +0000
161@@ -25,6 +25,7 @@
162
163 // Qt
164 #include <QObject>
165+#include <QSize>
166
167 class QDBusInterface;
168
169@@ -34,7 +35,10 @@
170 class DashClient : public QObject
171 {
172 Q_OBJECT
173+ Q_PROPERTY(bool alwaysFullScreen READ alwaysFullScreen NOTIFY alwaysFullScreenChanged)
174+
175 public:
176+ DashClient(QObject* parent = 0);
177 static DashClient* instance();
178
179 /**
180@@ -44,25 +48,28 @@
181 * - "" if the dash is not visible
182 */
183 QString activePage() const;
184-
185+ bool alwaysFullScreen() const;
186 void setActivePage(const QString& page, const QString& lensId=QString());
187+ static QSize minimumSizeForDesktop();
188
189 Q_SIGNALS:
190 void activePageChanged(const QString&);
191+ void alwaysFullScreenChanged();
192
193 private Q_SLOTS:
194 void connectToDash();
195 void slotDashActiveChanged(bool);
196 void slotDashActiveLensChanged(const QString&);
197+ void updateAlwaysFullScreen();
198
199 private:
200- DashClient(QObject* parent=0);
201 void updateActivePage();
202
203 QDBusInterface* m_dashDbusIface;
204 bool m_dashActive;
205 QString m_dashActiveLens;
206 QString m_activePage;
207+ bool m_alwaysFullScreen;
208 };
209
210 #endif /* DASHCLIENT_H */
211
212=== removed file 'libunity-2d-private/src/dashsettings.cpp'
213--- libunity-2d-private/src/dashsettings.cpp 2012-01-24 14:41:27 +0000
214+++ libunity-2d-private/src/dashsettings.cpp 1970-01-01 00:00:00 +0000
215@@ -1,55 +0,0 @@
216-/*
217- * This file is part of unity-2d
218- *
219- * Copyright 2011 Canonical Ltd.
220- *
221- * Authors:
222- * - Alberto Mardegan <alberto.mardegan@canonical.com>
223- *
224- * This program is free software; you can redistribute it and/or modify
225- * it under the terms of the GNU General Public License as published by
226- * the Free Software Foundation; version 3.
227- *
228- * This program is distributed in the hope that it will be useful,
229- * but WITHOUT ANY WARRANTY; without even the implied warranty of
230- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
231- * GNU General Public License for more details.
232- *
233- * You should have received a copy of the GNU General Public License
234- * along with this program. If not, see <http://www.gnu.org/licenses/>.
235- */
236-// Self
237-#include "dashsettings.h"
238-
239-#include <config.h>
240-
241-static const int DASH_MIN_SCREEN_WIDTH = 1280;
242-static const int DASH_MIN_SCREEN_HEIGHT = 1084;
243-
244-namespace Unity2d {
245-
246-DashSettings::DashSettings(QObject* parent):
247- QObject(parent)
248-{
249-}
250-
251-static int getenvInt(const char* name, int defaultValue)
252-{
253- QByteArray stringValue = qgetenv(name);
254- bool ok;
255- int value = stringValue.toInt(&ok);
256- return ok ? value : defaultValue;
257-}
258-
259-QSize DashSettings::minimumSizeForDesktop()
260-{
261- static int minWidth = getenvInt("DASH_MIN_SCREEN_WIDTH",
262- DASH_MIN_SCREEN_WIDTH);
263- static int minHeight = getenvInt("DASH_MIN_SCREEN_HEIGHT",
264- DASH_MIN_SCREEN_HEIGHT);
265- return QSize(minWidth, minHeight);
266-}
267-
268-}; // namespace Unity2d
269-
270-#include "dashsettings.moc"
271
272=== removed file 'libunity-2d-private/src/dashsettings.h'
273--- libunity-2d-private/src/dashsettings.h 2012-01-24 14:41:27 +0000
274+++ libunity-2d-private/src/dashsettings.h 1970-01-01 00:00:00 +0000
275@@ -1,48 +0,0 @@
276-/*
277- * This file is part of unity-2d
278- *
279- * Copyright 2011 Canonical Ltd.
280- *
281- * Authors:
282- * - Alberto Mardegan <alberto.mardegan@canonical.com>
283- *
284- * This program is free software; you can redistribute it and/or modify
285- * it under the terms of the GNU General Public License as published by
286- * the Free Software Foundation; version 3.
287- *
288- * This program is distributed in the hope that it will be useful,
289- * but WITHOUT ANY WARRANTY; without even the implied warranty of
290- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
291- * GNU General Public License for more details.
292- *
293- * You should have received a copy of the GNU General Public License
294- * along with this program. If not, see <http://www.gnu.org/licenses/>.
295- */
296-#ifndef DASHSETTINGS_H
297-#define DASHSETTINGS_H
298-
299-// Qt
300-#include <QObject>
301-#include <QSize>
302-
303-namespace Unity2d {
304-
305-/**
306- * Provide easy access to the Dash settings (from Qt and QML)
307- */
308-class DashSettings: public QObject
309-{
310- Q_OBJECT
311-
312-public:
313- explicit DashSettings(QObject* parent = 0);
314-
315- static QSize minimumSizeForDesktop();
316-
317-private:
318- Q_DISABLE_COPY(DashSettings)
319-};
320-
321-} // namespace Unity2d
322-
323-#endif /* DASHSETTINGS_H */
324
325=== modified file 'panel/applets/appname/appnameapplet.cpp'
326--- panel/applets/appname/appnameapplet.cpp 2012-01-13 17:33:12 +0000
327+++ panel/applets/appname/appnameapplet.cpp 2012-01-24 14:41:27 +0000
328@@ -28,6 +28,7 @@
329 #include "panelstyle.h"
330 #include "unity2dpanel.h"
331 #include "windowhelper.h"
332+#include "dashclient.h"
333
334 // Unity-2d
335 #include <debug_p.h>
336@@ -226,6 +227,8 @@
337 d->setupMenuBarWidget(panel->indicatorsManager());
338 d->setupKeyboardModifiersMonitor();
339
340+ connect(DashClient::instance(), SIGNAL(alwaysFullScreenChanged()), SLOT(updateWidgets()));
341+
342 QHBoxLayout* layout = new QHBoxLayout(this);
343 layout->setMargin(0);
344 layout->setSpacing(0);
345@@ -259,7 +262,7 @@
346 || d->m_menuBarWidget->isOpened()
347 );
348 bool showMenu = isOpened && !d->m_menuBarWidget->isEmpty() && isUserVisibleApp;
349- bool dashCanResize = d->m_windowHelper->dashCanResize();
350+ bool dashCanResize = !DashClient::instance()->alwaysFullScreen();
351 bool dashIsVisible = d->m_windowHelper->dashIsVisible();
352 bool showWindowButtons = (isOpened && isMaximized) || dashIsVisible;
353 bool showAppLabel = !(isMaximized && showMenu) && isUserVisibleApp && isOnSameScreen;
354
355=== modified file 'panel/applets/appname/windowhelper.cpp'
356--- panel/applets/appname/windowhelper.cpp 2012-01-24 14:41:27 +0000
357+++ panel/applets/appname/windowhelper.cpp 2012-01-24 14:41:27 +0000
358@@ -26,7 +26,7 @@
359 #include "config.h"
360
361 // unity-2d
362-#include <dashsettings.h>
363+#include <dashclient.h>
364 #include <debug_p.h>
365 #include <gconnector.h>
366 #include <screeninfo.h>
367@@ -53,32 +53,11 @@
368 #include <X11/Xatom.h>
369 #include <QX11Info>
370
371-using namespace Unity2d;
372-
373 struct WindowHelperPrivate
374 {
375- void updateDashCanResize()
376- {
377- WnckScreen* screen = wnck_window_get_screen(m_window);
378- int screenNumber = wnck_screen_get_number(screen);
379- QRect rect = QApplication::desktop()->screenGeometry(screenNumber);
380-
381- /* If the screen size too small, we don't allow the Dash to be used
382- * in Desktop mode (not fullscreen) */
383- QSize minSize = DashSettings::minimumSizeForDesktop();
384- if (rect.width() < minSize.width() &&
385- rect.height() < minSize.height()) {
386- m_dashCanResize = false;
387- } else {
388- m_dashCanResize = true;
389- }
390- }
391-
392- DashSettings* m_dashSettings;
393 WnckWindow* m_window;
394 GConnector m_connector;
395 bool m_activeWindowIsDash;
396- bool m_dashCanResize;
397 };
398
399 WindowHelper::WindowHelper(QObject* parent)
400@@ -86,7 +65,6 @@
401 , d(new WindowHelperPrivate)
402 {
403 d->m_window = 0;
404- d->m_dashSettings = new DashSettings(this);
405
406 WnckScreen* screen = wnck_screen_get_default();
407 wnck_screen_force_update(screen);
408@@ -139,9 +117,6 @@
409
410 const char *name = wnck_window_get_name(d->m_window);
411 d->m_activeWindowIsDash = qstrcmp(name, "unity-2d-places") == 0;
412- if (d->m_activeWindowIsDash) {
413- d->updateDashCanResize();
414- }
415
416 d->m_connector.connect(G_OBJECT(d->m_window), "name-changed", G_CALLBACK(nameChangedCB), this);
417 d->m_connector.connect(G_OBJECT(d->m_window), "state-changed", G_CALLBACK(stateChangedCB), this);
418@@ -190,11 +165,6 @@
419 return d->m_window != 0 && d->m_activeWindowIsDash;
420 }
421
422-bool WindowHelper::dashCanResize() const
423-{
424- return d->m_dashCanResize;
425-}
426-
427 void WindowHelper::close()
428 {
429 guint32 timestamp = QDateTime::currentDateTime().toTime_t();
430
431=== modified file 'panel/applets/appname/windowhelper.h'
432--- panel/applets/appname/windowhelper.h 2011-10-17 12:46:55 +0000
433+++ panel/applets/appname/windowhelper.h 2012-01-24 14:41:27 +0000
434@@ -42,7 +42,6 @@
435 bool isMaximized() const;
436 bool isMostlyOnScreen(int screen) const;
437 bool dashIsVisible() const;
438- bool dashCanResize() const;
439
440 public Q_SLOTS:
441 void close();
442
443=== modified file 'places/app/dashdeclarativeview.cpp'
444--- places/app/dashdeclarativeview.cpp 2012-01-24 14:41:27 +0000
445+++ places/app/dashdeclarativeview.cpp 2012-01-24 14:41:27 +0000
446@@ -18,9 +18,9 @@
447 #include "dashadaptor.h"
448
449 // unity-2d
450-#include <dashsettings.h>
451 #include <launcherclient.h>
452 #include <screeninfo.h>
453+#include <dashclient.h>
454
455 // Qt
456 #include <QDesktopWidget>
457@@ -57,7 +57,6 @@
458
459 QDesktopWidget* desktop = QApplication::desktop();
460 connect(desktop, SIGNAL(resized(int)), SIGNAL(screenGeometryChanged()));
461- connect(desktop, SIGNAL(resized(int)), SLOT(updateDashModeDependingOnScreenGeometry()));
462 connect(desktop, SIGNAL(workAreaResized(int)), SLOT(onWorkAreaResized(int)));
463
464 updateSize();
465@@ -74,18 +73,6 @@
466 }
467
468 void
469-DashDeclarativeView::updateDashModeDependingOnScreenGeometry()
470-{
471- QRect rect = QApplication::desktop()->screenGeometry(this);
472- QSize minSize = Unity2d::DashSettings::minimumSizeForDesktop();
473- if (rect.width() < minSize.width() && rect.height() < minSize.height()) {
474- setDashMode(FullScreenMode);
475- } else {
476- setDashMode(DesktopMode);
477- }
478-}
479-
480-void
481 DashDeclarativeView::updateSize()
482 {
483 if (m_mode == FullScreenMode) {
484
485=== modified file 'places/app/dashdeclarativeview.h'
486--- places/app/dashdeclarativeview.h 2011-12-08 18:39:18 +0000
487+++ places/app/dashdeclarativeview.h 2012-01-24 14:41:27 +0000
488@@ -68,7 +68,6 @@
489
490 private Q_SLOTS:
491 void onWorkAreaResized(int screen);
492- void updateDashModeDependingOnScreenGeometry();
493 void updateSize();
494
495 private:
496
497=== modified file 'places/dash.qml'
498--- places/dash.qml 2012-01-24 14:41:27 +0000
499+++ places/dash.qml 2012-01-24 14:41:27 +0000
500@@ -40,11 +40,15 @@
501 value: (currentPage && currentPage.expanded != undefined) ? currentPage.expanded : true
502 }
503
504+ DashClient {
505+ id: dashClient
506+ }
507+
508 Binding {
509 target: dashView
510 property: "dashMode"
511- value: return dash2dConfiguration.fullScreen ? DashDeclarativeView.FullScreenMode :
512- DashDeclarativeView.DesktopMode
513+ value: dashClient.alwaysFullScreen || dash2dConfiguration.fullScreen ?
514+ DashDeclarativeView.FullScreenMode : DashDeclarativeView.DesktopMode
515 }
516
517 function activatePage(page) {

Subscribers

People subscribed via source and target branches