Merge lp:~unity-2d-team/unity-2d/unity-2d-shell-panel-dash-buttons into lp:~unity-2d-team/unity-2d/unity-2d-shell

Proposed by Ugo Riboni on 2012-01-27
Status: Merged
Approved by: Michał Sawicz on 2012-02-02
Approved revision: 949
Merged at revision: 948
Proposed branch: lp:~unity-2d-team/unity-2d/unity-2d-shell-panel-dash-buttons
Merge into: lp:~unity-2d-team/unity-2d/unity-2d-shell
Diff against target: 251 lines (+73/-24)
5 files modified
libunity-2d-private/src/dashclient.cpp (+21/-5)
libunity-2d-private/src/dashclient.h (+3/-0)
panel/applets/appname/windowhelper.cpp (+45/-15)
panel/applets/appname/windowhelper.h (+2/-0)
tests/places/fullscreen.rb (+2/-4)
To merge this branch: bzr merge lp:~unity-2d-team/unity-2d/unity-2d-shell-panel-dash-buttons
Reviewer Review Type Date Requested Status
Michał Sawicz 2012-01-27 Approve on 2012-02-03
Review via email: mp+90450@code.launchpad.net

Description of the Change

[dash][panel] Make the panel (un)maximize and close buttons work again with the dash

To post a comment you must log in.
Michał Sawicz (saviq) wrote :

Any reason why we're based off of activePage and not active?

review: Needs Information
Ugo Riboni (uriboni) wrote :

I think basing on active is ok too. Can't think of any particular reason why I did it that way, TBH

Michał Sawicz (saviq) wrote :

Seems better to me to check for the value of "active" on dash instead of activePage.

review: Needs Fixing
947. By Albert Astals Cid on 2012-01-31

Use dashActive instead of dashActivePage to determine if the dash is active or not as requested in the MR

948. By Albert Astals Cid on 2012-01-31

Use setActive(false) instead of setActivePage("")

Albert Astals Cid (aacid) wrote :

Requested fixes done

949. By Albert Astals Cid on 2012-01-31

merge

Michał Sawicz (saviq) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libunity-2d-private/src/dashclient.cpp'
2--- libunity-2d-private/src/dashclient.cpp 2012-01-27 11:34:36 +0000
3+++ libunity-2d-private/src/dashclient.cpp 2012-01-31 15:27:35 +0000
4@@ -92,7 +92,7 @@
5
6 QVariant value = m_dashDbusIface->property("active");
7 if (value.isValid()) {
8- m_dashActive = value.toBool();
9+ slotDashActiveChanged(value.toBool());
10 } else {
11 UQ_WARNING << "Fetching Dash.active property failed";
12 }
13@@ -117,6 +117,7 @@
14 if (m_dashActive != value) {
15 m_dashActive = value;
16 updateActivePage();
17+ Q_EMIT activeChanged(value);
18 }
19 }
20
21@@ -128,6 +129,24 @@
22 }
23 }
24
25+bool DashClient::active() const
26+{
27+ return m_dashActive;
28+}
29+
30+void DashClient::setActive(bool active)
31+{
32+ if (!active) {
33+ // Use m_dashDbusIface to close the dash, but only if it is running
34+ if (m_dashDbusIface) {
35+ m_dashDbusIface->setProperty("active", false);
36+ }
37+ } else {
38+ QDBusInterface iface(DASH_DBUS_SERVICE, DASH_DBUS_PATH, DASH_DBUS_INTERFACE);
39+ iface.setProperty("active", true);
40+ }
41+}
42+
43 QString DashClient::activePage() const
44 {
45 return m_activePage;
46@@ -139,10 +158,7 @@
47 return;
48 }
49 if (page.isEmpty()) {
50- // Use m_dashDbusIface to close the dash, but only if it is running
51- if (m_dashDbusIface) {
52- m_dashDbusIface->setProperty("active", false);
53- }
54+ setActive(false);
55 return;
56 }
57 // Use a separate QDBusInterface so that the dash is started if it is not
58
59=== modified file 'libunity-2d-private/src/dashclient.h'
60--- libunity-2d-private/src/dashclient.h 2012-01-24 16:46:52 +0000
61+++ libunity-2d-private/src/dashclient.h 2012-01-31 15:27:35 +0000
62@@ -40,6 +40,8 @@
63 public:
64 static DashClient* instance();
65
66+ bool active() const;
67+ void setActive(bool active);
68 /**
69 * Returns the active page. This is either:
70 * - The lens id of the active lens
71@@ -52,6 +54,7 @@
72 static QSize minimumSizeForDesktop();
73
74 Q_SIGNALS:
75+ void activeChanged(bool active);
76 void activePageChanged(const QString&);
77 void alwaysFullScreenChanged();
78
79
80=== modified file 'panel/applets/appname/windowhelper.cpp'
81--- panel/applets/appname/windowhelper.cpp 2012-01-24 13:03:34 +0000
82+++ panel/applets/appname/windowhelper.cpp 2012-01-31 15:27:35 +0000
83@@ -30,6 +30,7 @@
84 #include <debug_p.h>
85 #include <gconnector.h>
86 #include <screeninfo.h>
87+#include <dashclient.h>
88
89 // Bamf
90 #include <bamf-matcher.h>
91@@ -57,7 +58,9 @@
92 {
93 WnckWindow* m_window;
94 GConnector m_connector;
95- bool m_activeWindowIsDash;
96+ bool m_activeWindowIsShell;
97+ bool m_dashIsVisible;
98+ bool m_dashIsFullScreen;
99 };
100
101 WindowHelper::WindowHelper(QObject* parent)
102@@ -82,6 +85,15 @@
103 // last window is closed. Should be removed when this bug is fixed.
104 connect(&BamfMatcher::get_default(), SIGNAL(ViewClosed(BamfView*)),
105 SLOT(update()));
106+
107+ connect(DashClient::instance(), SIGNAL(activeChanged(bool)), SLOT(updateDashVisible(bool)));
108+ d->m_dashIsVisible = DashClient::instance()->active();
109+
110+ // FIXME: the queued connection should not be needed, however if it's not used when
111+ // (un)maximizing the dash, the panel will deadlock for some reason.
112+ connect(&dash2dConfiguration(), SIGNAL(fullScreenChanged(bool)), SLOT(updateDashFullScreen(bool)),
113+ Qt::QueuedConnection);
114+ d->m_dashIsFullScreen = dash2dConfiguration().property("fullScreen").toBool();
115 }
116
117 WindowHelper::~WindowHelper()
118@@ -103,6 +115,18 @@
119 QMetaObject::invokeMethod(watcher, "nameChanged");
120 }
121
122+void WindowHelper::updateDashVisible(bool visible)
123+{
124+ d->m_dashIsVisible = visible;
125+ update();
126+}
127+
128+void WindowHelper::updateDashFullScreen(bool fullScreen)
129+{
130+ d->m_dashIsFullScreen = fullScreen;
131+ update();
132+}
133+
134 void WindowHelper::update()
135 {
136 BamfWindow* bamfWindow = BamfMatcher::get_default().active_window();
137@@ -116,8 +140,7 @@
138 d->m_window = wnck_window_get(xid);
139
140 const char *name = wnck_window_get_name(d->m_window);
141- d->m_activeWindowIsDash = qstrcmp(name, "unity-2d-places") == 0;
142-
143+ d->m_activeWindowIsShell = qstrcmp(name, "unity-2d-shell") == 0;
144 d->m_connector.connect(G_OBJECT(d->m_window), "name-changed", G_CALLBACK(nameChangedCB), this);
145 d->m_connector.connect(G_OBJECT(d->m_window), "state-changed", G_CALLBACK(stateChangedCB), this);
146 }
147@@ -130,8 +153,9 @@
148 if (!d->m_window) {
149 return false;
150 }
151- if (d->m_activeWindowIsDash) {
152- return dash2dConfiguration().property("fullScreen").toBool();
153+
154+ if (d->m_activeWindowIsShell) {
155+ return d->m_dashIsVisible && d->m_dashIsFullScreen;
156 } else {
157 return wnck_window_is_maximized(d->m_window);
158 }
159@@ -162,40 +186,46 @@
160
161 bool WindowHelper::dashIsVisible() const
162 {
163- return d->m_window != 0 && d->m_activeWindowIsDash;
164+ return d->m_window != 0 && d->m_activeWindowIsShell && d->m_dashIsVisible;
165 }
166
167 void WindowHelper::close()
168 {
169- guint32 timestamp = QDateTime::currentDateTime().toTime_t();
170- wnck_window_close(d->m_window, timestamp);
171+ if (d->m_window != 0 && !d->m_activeWindowIsShell) {
172+ guint32 timestamp = QDateTime::currentDateTime().toTime_t();
173+ wnck_window_close(d->m_window, timestamp);
174+ } else {
175+ DashClient::instance()->setActive(false);
176+ }
177 }
178
179 void WindowHelper::minimize()
180 {
181- if (!d->m_activeWindowIsDash) {
182+ if (d->m_window != 0 && !d->m_activeWindowIsShell) {
183 wnck_window_minimize(d->m_window);
184 }
185+ // If the dash is up, we can't get here, since the minimize button
186+ // should be greyed out or hidden in that case.
187 }
188
189 void WindowHelper::maximize()
190 {
191- if (d->m_activeWindowIsDash) {
192- dash2dConfiguration().setProperty("fullScreen", QVariant(true));
193- } else {
194+ if (d->m_window != 0 && !d->m_activeWindowIsShell) {
195 /* This currently cannot happen, because the window buttons are not
196 * shown in the panel for non maximized windows. It's here just for
197 * completeness. */
198 wnck_window_maximize(d->m_window);
199+ } else {
200+ dash2dConfiguration().setProperty("fullScreen", QVariant(true));
201 }
202 }
203
204 void WindowHelper::unmaximize()
205 {
206- if (d->m_activeWindowIsDash) {
207+ if (d->m_window != 0 && !d->m_activeWindowIsShell) {
208+ wnck_window_unmaximize(d->m_window);
209+ } else {
210 dash2dConfiguration().setProperty("fullScreen", QVariant(false));
211- } else {
212- wnck_window_unmaximize(d->m_window);
213 }
214 }
215
216
217=== modified file 'panel/applets/appname/windowhelper.h'
218--- panel/applets/appname/windowhelper.h 2012-01-24 13:03:34 +0000
219+++ panel/applets/appname/windowhelper.h 2012-01-31 15:27:35 +0000
220@@ -53,6 +53,8 @@
221
222 private Q_SLOTS:
223 void update();
224+ void updateDashVisible(bool);
225+ void updateDashFullScreen(bool);
226
227 Q_SIGNALS:
228 void nameChanged();
229
230=== modified file 'tests/places/fullscreen.rb'
231--- tests/places/fullscreen.rb 2012-01-27 12:39:09 +0000
232+++ tests/places/fullscreen.rb 2012-01-31 15:27:35 +0000
233@@ -116,9 +116,7 @@
234 }
235 end
236
237- # FIXME: this test is temporarily disabled until we add back the panel buttons for the dash in
238- # the shell branch.
239- xtest "Dash reacts correctly to panel buttons" do
240+ test "Dash reacts correctly to panel buttons" do
241 %x{dconf write #{DASH_FULLSCREEN_KEY} false}
242 %x{dconf write #{DASH_FORMFACTOR_KEY} #{'\"desktop\"'}}
243 XDo::Keyboard.super
244@@ -128,7 +126,7 @@
245 }
246
247 maxbutton = nil
248- verify(TIMEOUT, 'The "maximize" button did not appear when the dash was visible' ) {
249+ verify(1, 'The "maximize" button did not appear when the dash was visible' ) {
250 maxbutton = @panel.AppNameApplet().children( :type => 'QAbstractButton' )[2]
251 }
252

Subscribers

People subscribed via source and target branches

to all changes: