Merge lp:~mardy/unity-2d/unmaximize into lp:unity-2d
- unmaximize
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Didier Roche-Tolomelli |
Approved revision: | 759 |
Merged at revision: | 797 |
Proposed branch: | lp:~mardy/unity-2d/unmaximize |
Merge into: | lp:unity-2d |
Diff against target: |
679 lines (+351/-53) 12 files modified
libunity-2d-private/Unity2d/plugin.cpp (+5/-0) libunity-2d-private/src/CMakeLists.txt (+1/-0) libunity-2d-private/src/dashsettings.cpp (+117/-0) libunity-2d-private/src/dashsettings.h (+72/-0) libunity-2d-private/src/panelstyle.cpp (+6/-0) libunity-2d-private/src/panelstyle.h (+2/-1) panel/applets/appname/appnameapplet.cpp (+36/-10) panel/applets/appname/windowhelper.cpp (+93/-3) panel/applets/appname/windowhelper.h (+4/-0) places/app/dashdeclarativeview.cpp (+3/-15) places/app/places.cpp (+1/-0) places/dash.qml (+11/-24) |
To merge this branch: | bzr merge lp:~mardy/unity-2d/unmaximize |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Lohith D Shivamurthy | Pending | ||
Michał Sawicz | functional | Pending | |
Review via email: mp+83763@code.launchpad.net |
This proposal supersedes a proposal from 2011-10-05.
Commit message
Description of the change
(resubmitting without prerequisite branch)
[dash, panel] Add window controls to dash window
Show window controls for closing, minimizing and maximizing the Dash.
One potentially big issue:
Although the Dash window state (maximized/
Michał Sawicz (saviq) wrote : Posted in a previous version of this proposal | # |
Michał Sawicz (saviq) wrote : Posted in a previous version of this proposal | # |
> Works fine here. Only thing I'm not sure of - what's the purpose of minimizing
> the Dash?
Talking to @fboucault, the minimize button should be disabled / greyed out for the dash.
Alberto Mardegan (mardy) wrote : Posted in a previous version of this proposal | # |
I will change the minimize button not to do anything when pressed, and remove the highlight effect when hovering it.
However, I'm not sure it's the good solution, seeing bug 867910 and bug 862775.
Alberto Mardegan (mardy) wrote : Posted in a previous version of this proposal | # |
Merge request updated: the minimize button is now insensitive.
Michał Sawicz (saviq) wrote : Posted in a previous version of this proposal | # |
I agree with the bugs mentioned - the minimize button looks out-of-place - broken, not inactive, with that change. Unless we have a "inactive" state of the buttons elsewhere in the desktop - which we don't - we should simply remove the minimize button. Modal windows, for example, only have the close button, not all of them, but with only the close one working.
That will probably require ACK from design.
Michał Sawicz (saviq) wrote : Posted in a previous version of this proposal | # |
When we're always fullscreen (Netbook form factor?), the unmaximize button should also be disabled.
Also, when the dash or alt+f2 is active, panel still displays the "Desktop" label.
Alberto Mardegan (mardy) wrote : Posted in a previous version of this proposal | # |
Updated:
- Don't show desktop title when Dash is running
- Disable the maximize/unmaximize button when the screen resolution is too low
Michał Sawicz (saviq) wrote : Posted in a previous version of this proposal | # |
Functionally works great, will have to take a longer look at the code, unless someone else wants to do that :]
Lohith D Shivamurthy (dyams) wrote : Posted in a previous version of this proposal | # |
> Functionally works great, will have to take a longer look at the code, unless
> someone else wants to do that :]
I finished reviewing this MR. IMO, We should merge it already.
I have noticed a functional issue though.
But this patch itself is worth more than that small issue. :)
I can log a separate lp bug for that issue later.
Lohith D Shivamurthy (dyams) wrote : Posted in a previous version of this proposal | # |
The issue is :
1) Open Dash
2) Make sure its window buttons are not visible.
3) Move the mouse over panel
4) Window buttons(Close, Minimize, Maximize) not visible yet
5) Move the mouse away from panel
6) The Window buttons becomes visible now.
Expected:
at (4) the buttons should have been visible and
at (6) they should have been hidden.
Actual:
Moving the mouse over panel when window buttons are not visible, the buttons are still hidden.
When cursor is moved away, they become visible.
Alberto Mardegan (mardy) wrote : Posted in a previous version of this proposal | # |
I'm rather sure that the issue your found was not present when I tested this -- it's a rather big issue that wouldn't pass unnoticed.
However, unfortunately I won't be able to work on this either. :-(
Lohith D Shivamurthy (dyams) wrote : Posted in a previous version of this proposal | # |
The code is neat and clean. Happy to approve it.
Thanks a lot.
Gerry Boland (gerboland) wrote : Posted in a previous version of this proposal | # |
Sorry, but make check not passing yet, so merge will fail.
Unity Merger (unity-merger) wrote : Posted in a previous version of this proposal | # |
No proposals found for merge of lp:~mardy/unity-2d/spread-geometry into lp:unity-2d.
Preview Diff
1 | === modified file 'libunity-2d-private/Unity2d/plugin.cpp' |
2 | --- libunity-2d-private/Unity2d/plugin.cpp 2011-11-07 14:04:55 +0000 |
3 | +++ libunity-2d-private/Unity2d/plugin.cpp 2011-11-29 12:07:27 +0000 |
4 | @@ -22,6 +22,7 @@ |
5 | */ |
6 | #include "plugin.h" |
7 | |
8 | +#include "dashsettings.h" |
9 | #include "launcherapplication.h" |
10 | #include "place.h" |
11 | #include "placeentry.h" |
12 | @@ -83,6 +84,8 @@ |
13 | |
14 | #include <X11/Xlib.h> |
15 | |
16 | +using namespace Unity2d; |
17 | + |
18 | /* FIXME: This should be done more properly, it's just an hack this way. |
19 | We should silence only the errors that we know we can produce. |
20 | We could probably also learn something from gdk-error-trap-push. |
21 | @@ -100,6 +103,8 @@ |
22 | { |
23 | qmlRegisterType<QSortFilterProxyModelQML>(uri, 0, 1, "SortFilterProxyModel"); |
24 | |
25 | + qmlRegisterType<DashSettings>(uri, 0, 1, "DashSettings"); |
26 | + |
27 | qmlRegisterType<WindowInfo>(uri, 0, 1, "WindowInfo"); |
28 | qmlRegisterType<WindowsList>(uri, 0, 1, "WindowsList"); |
29 | qmlRegisterType<ScreenInfo>(); // Register the type as non creatable |
30 | |
31 | === modified file 'libunity-2d-private/src/CMakeLists.txt' |
32 | --- libunity-2d-private/src/CMakeLists.txt 2011-11-21 17:27:57 +0000 |
33 | +++ libunity-2d-private/src/CMakeLists.txt 2011-11-29 12:07:27 +0000 |
34 | @@ -4,6 +4,7 @@ |
35 | set(lib${LIB_NAME}_SRCS |
36 | bfb.cpp |
37 | dashclient.cpp |
38 | + dashsettings.cpp |
39 | debug.cpp |
40 | gconnector.cpp |
41 | gimageutils.cpp |
42 | |
43 | === added file 'libunity-2d-private/src/dashsettings.cpp' |
44 | --- libunity-2d-private/src/dashsettings.cpp 1970-01-01 00:00:00 +0000 |
45 | +++ libunity-2d-private/src/dashsettings.cpp 2011-11-29 12:07:27 +0000 |
46 | @@ -0,0 +1,117 @@ |
47 | +/* |
48 | + * This file is part of unity-2d |
49 | + * |
50 | + * Copyright 2011 Canonical Ltd. |
51 | + * |
52 | + * Authors: |
53 | + * - Alberto Mardegan <alberto.mardegan@canonical.com> |
54 | + * |
55 | + * This program is free software; you can redistribute it and/or modify |
56 | + * it under the terms of the GNU General Public License as published by |
57 | + * the Free Software Foundation; version 3. |
58 | + * |
59 | + * This program is distributed in the hope that it will be useful, |
60 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
61 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
62 | + * GNU General Public License for more details. |
63 | + * |
64 | + * You should have received a copy of the GNU General Public License |
65 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
66 | + */ |
67 | +// Self |
68 | +#include "dashsettings.h" |
69 | + |
70 | +// Local |
71 | + |
72 | +// libdconf-qt |
73 | +#include "qconf.h" |
74 | + |
75 | +// Qt |
76 | +#include <QMetaEnum> |
77 | +#include <QSize> |
78 | +#include <QVariant> |
79 | + |
80 | +static const int DASH_MIN_SCREEN_WIDTH = 1280; |
81 | +static const int DASH_MIN_SCREEN_HEIGHT = 1084; |
82 | + |
83 | +static const char* DASH_DCONF_SCHEMA = "com.canonical.Unity"; |
84 | +static const char* FORM_FACTOR = "formFactor"; |
85 | + |
86 | +namespace Unity2d { |
87 | + |
88 | +class DashSettingsPrivate |
89 | +{ |
90 | + DashSettingsPrivate(DashSettings *dashSettings): |
91 | + conf(new QConf(DASH_DCONF_SCHEMA)) |
92 | + { |
93 | + /* proxy the formFactor property signal notifier */ |
94 | + QObject::connect(conf, SIGNAL(formFactorChanged(QString)), |
95 | + dashSettings, SIGNAL(formFactorChanged())); |
96 | + |
97 | + /* Get the QMetaEnum for FormFactor: we will use it when setting and |
98 | + * getting the property, to convert the string value returned by QConf |
99 | + * to an enum value, and vice versa. */ |
100 | + const QMetaObject *metaObject = dashSettings->metaObject(); |
101 | + int index = metaObject->indexOfEnumerator("FormFactor"); |
102 | + formFactorEnum = metaObject->enumerator(index); |
103 | + } |
104 | + |
105 | + ~DashSettingsPrivate() |
106 | + { |
107 | + delete conf; |
108 | + } |
109 | + |
110 | +private: |
111 | + DashSettings* q_ptr; |
112 | + Q_DECLARE_PUBLIC(DashSettings) |
113 | + |
114 | + QConf* conf; |
115 | + QMetaEnum formFactorEnum; |
116 | +}; |
117 | + |
118 | +DashSettings::DashSettings(QObject* parent): |
119 | + QObject(parent), |
120 | + d_ptr(new DashSettingsPrivate(this)) |
121 | +{ |
122 | +} |
123 | + |
124 | +DashSettings::~DashSettings() |
125 | +{ |
126 | + delete d_ptr; |
127 | +} |
128 | + |
129 | +void DashSettings::setFormFactor(FormFactor formFactor) |
130 | +{ |
131 | + Q_D(DashSettings); |
132 | + |
133 | + const char* name = d->formFactorEnum.valueToKey(formFactor); |
134 | + d->conf->setProperty(FORM_FACTOR, QVariant(QString::fromLatin1(name))); |
135 | +} |
136 | + |
137 | +DashSettings::FormFactor DashSettings::formFactor() const |
138 | +{ |
139 | + Q_D(const DashSettings); |
140 | + QByteArray key = d->conf->property(FORM_FACTOR).toString().toLatin1(); |
141 | + return FormFactor(d->formFactorEnum.keyToValue(key.constData())); |
142 | +} |
143 | + |
144 | +static int getenvInt(const char* name, int defaultValue) |
145 | +{ |
146 | + QByteArray stringValue = qgetenv(name); |
147 | + bool ok; |
148 | + int value = stringValue.toInt(&ok); |
149 | + return ok ? value : defaultValue; |
150 | +} |
151 | + |
152 | +QSize DashSettings::minimumSizeForDesktop() |
153 | +{ |
154 | + static int minWidth = getenvInt("DASH_MIN_SCREEN_WIDTH", |
155 | + DASH_MIN_SCREEN_WIDTH); |
156 | + static int minHeight = getenvInt("DASH_MIN_SCREEN_HEIGHT", |
157 | + DASH_MIN_SCREEN_HEIGHT); |
158 | + return QSize(minWidth, minHeight); |
159 | +} |
160 | + |
161 | +}; // namespace Unity2d |
162 | + |
163 | +#include "dashsettings.moc" |
164 | |
165 | === added file 'libunity-2d-private/src/dashsettings.h' |
166 | --- libunity-2d-private/src/dashsettings.h 1970-01-01 00:00:00 +0000 |
167 | +++ libunity-2d-private/src/dashsettings.h 2011-11-29 12:07:27 +0000 |
168 | @@ -0,0 +1,72 @@ |
169 | +/* |
170 | + * This file is part of unity-2d |
171 | + * |
172 | + * Copyright 2011 Canonical Ltd. |
173 | + * |
174 | + * Authors: |
175 | + * - Alberto Mardegan <alberto.mardegan@canonical.com> |
176 | + * |
177 | + * This program is free software; you can redistribute it and/or modify |
178 | + * it under the terms of the GNU General Public License as published by |
179 | + * the Free Software Foundation; version 3. |
180 | + * |
181 | + * This program is distributed in the hope that it will be useful, |
182 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
183 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
184 | + * GNU General Public License for more details. |
185 | + * |
186 | + * You should have received a copy of the GNU General Public License |
187 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
188 | + */ |
189 | +#ifndef DASHSETTINGS_H |
190 | +#define DASHSETTINGS_H |
191 | + |
192 | +// Qt |
193 | +#include <QObject> |
194 | +#include <QMetaType> |
195 | + |
196 | +namespace Unity2d { |
197 | + |
198 | +class DashSettingsPrivate; |
199 | + |
200 | +/** |
201 | + * Provide easy access to the Dash settings (from Qt and QML) |
202 | + */ |
203 | +class DashSettings: public QObject |
204 | +{ |
205 | + Q_OBJECT |
206 | + |
207 | + Q_ENUMS(FormFactor) |
208 | + |
209 | + Q_PROPERTY(FormFactor formFactor READ formFactor WRITE setFormFactor NOTIFY formFactorChanged) |
210 | + |
211 | +public: |
212 | + explicit DashSettings(QObject* parent = 0); |
213 | + ~DashSettings(); |
214 | + |
215 | + enum FormFactor |
216 | + { |
217 | + Automatic = 0, |
218 | + Desktop, |
219 | + Netbook |
220 | + }; |
221 | + |
222 | + void setFormFactor(FormFactor formFactor); |
223 | + FormFactor formFactor() const; |
224 | + |
225 | + static QSize minimumSizeForDesktop(); |
226 | + |
227 | +Q_SIGNALS: |
228 | + void formFactorChanged(); |
229 | + |
230 | +private: |
231 | + Q_DISABLE_COPY(DashSettings) |
232 | + DashSettingsPrivate* d_ptr; |
233 | + Q_DECLARE_PRIVATE(DashSettings) |
234 | +}; |
235 | + |
236 | +} // namespace Unity2d |
237 | + |
238 | +Q_DECLARE_METATYPE(Unity2d::DashSettings::FormFactor) |
239 | + |
240 | +#endif /* DASHSETTINGS_H */ |
241 | |
242 | === modified file 'libunity-2d-private/src/panelstyle.cpp' |
243 | --- libunity-2d-private/src/panelstyle.cpp 2011-09-14 16:08:49 +0000 |
244 | +++ libunity-2d-private/src/panelstyle.cpp 2011-11-29 12:07:27 +0000 |
245 | @@ -98,6 +98,9 @@ |
246 | case PanelStyle::UnmaximizeWindowButton: |
247 | typeString = "unmaximize"; |
248 | break; |
249 | + case PanelStyle::MaximizeWindowButton: |
250 | + typeString = "maximize"; |
251 | + break; |
252 | } |
253 | |
254 | switch (state) { |
255 | @@ -132,6 +135,9 @@ |
256 | case PanelStyle::UnmaximizeWindowButton: |
257 | standardIcon = QStyle::SP_TitleBarNormalButton; |
258 | break; |
259 | + case PanelStyle::MaximizeWindowButton: |
260 | + standardIcon = QStyle::SP_TitleBarMaxButton; |
261 | + break; |
262 | } |
263 | |
264 | QIcon icon = QApplication::style()->standardIcon(standardIcon); |
265 | |
266 | === modified file 'libunity-2d-private/src/panelstyle.h' |
267 | --- libunity-2d-private/src/panelstyle.h 2011-08-22 09:17:03 +0000 |
268 | +++ libunity-2d-private/src/panelstyle.h 2011-11-29 12:07:27 +0000 |
269 | @@ -48,7 +48,8 @@ |
270 | enum WindowButtonType { |
271 | CloseWindowButton, |
272 | MinimizeWindowButton, |
273 | - UnmaximizeWindowButton |
274 | + UnmaximizeWindowButton, |
275 | + MaximizeWindowButton |
276 | }; |
277 | |
278 | enum WindowButtonState { |
279 | |
280 | === modified file 'panel/applets/appname/appnameapplet.cpp' |
281 | --- panel/applets/appname/appnameapplet.cpp 2011-11-14 10:45:33 +0000 |
282 | +++ panel/applets/appname/appnameapplet.cpp 2011-11-29 12:07:27 +0000 |
283 | @@ -61,15 +61,25 @@ |
284 | public: |
285 | WindowButton(const PanelStyle::WindowButtonType& buttonType, QWidget* parent = 0) |
286 | : QAbstractButton(parent) |
287 | - , m_buttonType(buttonType) |
288 | + , m_initialized(false) |
289 | { |
290 | - loadPixmaps(); |
291 | + setButtonType(buttonType); |
292 | if (buttonType == PanelStyle::MinimizeWindowButton) { |
293 | setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum); |
294 | } else { |
295 | setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); |
296 | } |
297 | setAttribute(Qt::WA_Hover); |
298 | + m_initialized = true; |
299 | + } |
300 | + |
301 | + void setButtonType(const PanelStyle::WindowButtonType& buttonType) |
302 | + { |
303 | + if (m_initialized && m_buttonType == buttonType) return; |
304 | + |
305 | + m_buttonType = buttonType; |
306 | + loadPixmaps(); |
307 | + update(); |
308 | } |
309 | |
310 | QSize minimumSizeHint() const |
311 | @@ -90,10 +100,14 @@ |
312 | { |
313 | QPainter painter(this); |
314 | QPixmap pix; |
315 | - if (isDown()) { |
316 | - pix = m_downPix; |
317 | - } else if (underMouse()) { |
318 | - pix = m_hoverPix; |
319 | + if (isEnabled()) { |
320 | + if (isDown()) { |
321 | + pix = m_downPix; |
322 | + } else if (underMouse()) { |
323 | + pix = m_hoverPix; |
324 | + } else { |
325 | + pix = m_normalPix; |
326 | + } |
327 | } else { |
328 | pix = m_normalPix; |
329 | } |
330 | @@ -111,6 +125,7 @@ |
331 | QPixmap m_normalPix; |
332 | QPixmap m_hoverPix; |
333 | QPixmap m_downPix; |
334 | + bool m_initialized; |
335 | |
336 | void loadPixmaps() |
337 | { |
338 | @@ -170,7 +185,7 @@ |
339 | m_windowButtonWidget->setFixedWidth(LauncherClient::MaximumWidth); |
340 | QObject::connect(m_closeButton, SIGNAL(clicked()), m_windowHelper, SLOT(close())); |
341 | QObject::connect(m_minimizeButton, SIGNAL(clicked()), m_windowHelper, SLOT(minimize())); |
342 | - QObject::connect(m_maximizeButton, SIGNAL(clicked()), m_windowHelper, SLOT(unmaximize())); |
343 | + QObject::connect(m_maximizeButton, SIGNAL(clicked()), m_windowHelper, SLOT(toggleMaximize())); |
344 | } |
345 | |
346 | void setupWindowHelper() |
347 | @@ -244,13 +259,22 @@ |
348 | || d->m_menuBarWidget->isOpened() |
349 | ); |
350 | bool showMenu = isOpened && !d->m_menuBarWidget->isEmpty() && isUserVisibleApp; |
351 | - bool showWindowButtons = isOpened && isMaximized; |
352 | + bool dashCanResize = d->m_windowHelper->dashCanResize(); |
353 | + bool dashIsVisible = d->m_windowHelper->dashIsVisible(); |
354 | + bool showWindowButtons = (isOpened && isMaximized) || dashIsVisible; |
355 | bool showAppLabel = !(isMaximized && showMenu) && isUserVisibleApp && isOnSameScreen; |
356 | - bool showDesktopLabel = !isUserVisibleApp; |
357 | + bool showDesktopLabel = !app; |
358 | |
359 | d->m_windowButtonWidget->setVisible(showWindowButtons); |
360 | + d->m_maximizeButton->setButtonType(isMaximized ? |
361 | + PanelStyle::UnmaximizeWindowButton : |
362 | + PanelStyle::MaximizeWindowButton); |
363 | + /* disable the minimize button for the dash */ |
364 | + d->m_minimizeButton->setEnabled(!dashIsVisible); |
365 | + /* and the maximize button, if the dash is not resizeable */ |
366 | + d->m_maximizeButton->setEnabled(!dashIsVisible || dashCanResize); |
367 | |
368 | - if (showAppLabel || showDesktopLabel) { |
369 | + if (showAppLabel || showDesktopLabel || dashIsVisible) { |
370 | d->m_label->setVisible(true); |
371 | if (showAppLabel) { |
372 | // Define text |
373 | @@ -270,6 +294,8 @@ |
374 | d->m_label->setText(text); |
375 | } else if (showDesktopLabel) { |
376 | d->m_label->setText(u2dTr("Desktop", "nautilus")); |
377 | + } else { |
378 | + d->m_label->setText(""); |
379 | } |
380 | |
381 | // Define label width |
382 | |
383 | === modified file 'panel/applets/appname/windowhelper.cpp' |
384 | --- panel/applets/appname/windowhelper.cpp 2011-09-27 11:57:06 +0000 |
385 | +++ panel/applets/appname/windowhelper.cpp 2011-11-29 12:07:27 +0000 |
386 | @@ -25,8 +25,10 @@ |
387 | // Local |
388 | |
389 | // unity-2d |
390 | +#include <dashsettings.h> |
391 | #include <debug_p.h> |
392 | #include <gconnector.h> |
393 | +#include <screeninfo.h> |
394 | |
395 | // Bamf |
396 | #include <bamf-matcher.h> |
397 | @@ -49,10 +51,32 @@ |
398 | #include <X11/Xatom.h> |
399 | #include <QX11Info> |
400 | |
401 | +using namespace Unity2d; |
402 | + |
403 | struct WindowHelperPrivate |
404 | { |
405 | + void updateDashCanResize() |
406 | + { |
407 | + WnckScreen* screen = wnck_window_get_screen(m_window); |
408 | + int screenNumber = wnck_screen_get_number(screen); |
409 | + QRect rect = QApplication::desktop()->screenGeometry(screenNumber); |
410 | + |
411 | + /* If the screen size too small, we don't allow the Dash to be used |
412 | + * in Desktop mode (not fullscreen) */ |
413 | + QSize minSize = DashSettings::minimumSizeForDesktop(); |
414 | + if (rect.width() < minSize.width() && |
415 | + rect.height() < minSize.height()) { |
416 | + m_dashCanResize = false; |
417 | + } else { |
418 | + m_dashCanResize = true; |
419 | + } |
420 | + } |
421 | + |
422 | + DashSettings* m_dashSettings; |
423 | WnckWindow* m_window; |
424 | GConnector m_connector; |
425 | + bool m_activeWindowIsDash; |
426 | + bool m_dashCanResize; |
427 | }; |
428 | |
429 | WindowHelper::WindowHelper(QObject* parent) |
430 | @@ -60,6 +84,7 @@ |
431 | , d(new WindowHelperPrivate) |
432 | { |
433 | d->m_window = 0; |
434 | + d->m_dashSettings = new DashSettings(this); |
435 | |
436 | WnckScreen* screen = wnck_screen_get_default(); |
437 | wnck_screen_force_update(screen); |
438 | @@ -98,6 +123,12 @@ |
439 | QMetaObject::invokeMethod(watcher, "nameChanged"); |
440 | } |
441 | |
442 | +static void geometryChangedCB(GObject* window, |
443 | + WindowHelper* watcher) |
444 | +{ |
445 | + QMetaObject::invokeMethod(watcher, "stateChanged"); |
446 | +} |
447 | + |
448 | void WindowHelper::update() |
449 | { |
450 | BamfWindow* bamfWindow = BamfMatcher::get_default().active_window(); |
451 | @@ -109,6 +140,20 @@ |
452 | } |
453 | if (xid != 0) { |
454 | d->m_window = wnck_window_get(xid); |
455 | + |
456 | + const char *name = wnck_window_get_name(d->m_window); |
457 | + d->m_activeWindowIsDash = qstrcmp(name, "unity-2d-places") == 0; |
458 | + if (d->m_activeWindowIsDash) { |
459 | + /* Since we are not really minimizing and maximizing the dash we |
460 | + * cannot rely on the wnck "state-changed" signal to be emitted; |
461 | + * instead, listen for the "geometry-changed" and emit our |
462 | + * stateChanged() from that. */ |
463 | + d->m_connector.connect(G_OBJECT(d->m_window), "geometry-changed", |
464 | + G_CALLBACK(geometryChangedCB), this); |
465 | + |
466 | + d->updateDashCanResize(); |
467 | + } |
468 | + |
469 | d->m_connector.connect(G_OBJECT(d->m_window), "name-changed", G_CALLBACK(nameChangedCB), this); |
470 | d->m_connector.connect(G_OBJECT(d->m_window), "state-changed", G_CALLBACK(stateChangedCB), this); |
471 | } |
472 | @@ -121,7 +166,15 @@ |
473 | if (!d->m_window) { |
474 | return false; |
475 | } |
476 | - return wnck_window_is_maximized(d->m_window); |
477 | + if (d->m_activeWindowIsDash) { |
478 | + int x, y, width, height; |
479 | + wnck_window_get_geometry(d->m_window, &x, &y, &width, &height); |
480 | + const QRect windowGeometry(x, y, width, height); |
481 | + ScreenInfo* screenInfo = ScreenInfo::instance(); |
482 | + return screenInfo->availableGeometry() == windowGeometry; |
483 | + } else { |
484 | + return wnck_window_is_maximized(d->m_window); |
485 | + } |
486 | } |
487 | |
488 | bool WindowHelper::isMostlyOnScreen(int screen) const |
489 | @@ -147,6 +200,16 @@ |
490 | return true; |
491 | } |
492 | |
493 | +bool WindowHelper::dashIsVisible() const |
494 | +{ |
495 | + return d->m_window != 0 && d->m_activeWindowIsDash; |
496 | +} |
497 | + |
498 | +bool WindowHelper::dashCanResize() const |
499 | +{ |
500 | + return d->m_dashCanResize; |
501 | +} |
502 | + |
503 | void WindowHelper::close() |
504 | { |
505 | guint32 timestamp = QDateTime::currentDateTime().toTime_t(); |
506 | @@ -155,12 +218,39 @@ |
507 | |
508 | void WindowHelper::minimize() |
509 | { |
510 | - wnck_window_minimize(d->m_window); |
511 | + if (!d->m_activeWindowIsDash) { |
512 | + wnck_window_minimize(d->m_window); |
513 | + } |
514 | +} |
515 | + |
516 | +void WindowHelper::maximize() |
517 | +{ |
518 | + if (d->m_activeWindowIsDash) { |
519 | + d->m_dashSettings->setFormFactor(DashSettings::Netbook); |
520 | + } else { |
521 | + /* This currently cannot happen, because the window buttons are not |
522 | + * shown in the panel for non maximized windows. It's here just for |
523 | + * completeness. */ |
524 | + wnck_window_maximize(d->m_window); |
525 | + } |
526 | } |
527 | |
528 | void WindowHelper::unmaximize() |
529 | { |
530 | - wnck_window_unmaximize(d->m_window); |
531 | + if (d->m_activeWindowIsDash) { |
532 | + d->m_dashSettings->setFormFactor(DashSettings::Desktop); |
533 | + } else { |
534 | + wnck_window_unmaximize(d->m_window); |
535 | + } |
536 | +} |
537 | + |
538 | +void WindowHelper::toggleMaximize() |
539 | +{ |
540 | + if (isMaximized()) { |
541 | + unmaximize(); |
542 | + } else { |
543 | + maximize(); |
544 | + } |
545 | } |
546 | |
547 | void WindowHelper::drag(const QPoint& pos) |
548 | |
549 | === modified file 'panel/applets/appname/windowhelper.h' |
550 | --- panel/applets/appname/windowhelper.h 2011-09-23 15:00:34 +0000 |
551 | +++ panel/applets/appname/windowhelper.h 2011-11-29 12:07:27 +0000 |
552 | @@ -41,11 +41,15 @@ |
553 | |
554 | bool isMaximized() const; |
555 | bool isMostlyOnScreen(int screen) const; |
556 | + bool dashIsVisible() const; |
557 | + bool dashCanResize() const; |
558 | |
559 | public Q_SLOTS: |
560 | void close(); |
561 | void minimize(); |
562 | void unmaximize(); |
563 | + void maximize(); |
564 | + void toggleMaximize(); |
565 | void drag(const QPoint& pos); |
566 | |
567 | private Q_SLOTS: |
568 | |
569 | === modified file 'places/app/dashdeclarativeview.cpp' |
570 | --- places/app/dashdeclarativeview.cpp 2011-11-18 10:54:50 +0000 |
571 | +++ places/app/dashdeclarativeview.cpp 2011-11-29 12:07:27 +0000 |
572 | @@ -18,6 +18,7 @@ |
573 | #include "dashadaptor.h" |
574 | |
575 | // unity-2d |
576 | +#include <dashsettings.h> |
577 | #include <launcherclient.h> |
578 | #include <screeninfo.h> |
579 | |
580 | @@ -37,9 +38,6 @@ |
581 | |
582 | #include <config.h> |
583 | |
584 | -static const int DASH_MIN_SCREEN_WIDTH = 1280; |
585 | -static const int DASH_MIN_SCREEN_HEIGHT = 1084; |
586 | - |
587 | static const int DASH_DESKTOP_WIDTH = 989; |
588 | static const int DASH_DESKTOP_COLLAPSED_HEIGHT = 115; |
589 | static const int DASH_DESKTOP_EXPANDED_HEIGHT = 606; |
590 | @@ -77,22 +75,12 @@ |
591 | availableGeometryChanged(); |
592 | } |
593 | |
594 | - |
595 | -static int getenvInt(const char* name, int defaultValue) |
596 | -{ |
597 | - QByteArray stringValue = qgetenv(name); |
598 | - bool ok; |
599 | - int value = stringValue.toInt(&ok); |
600 | - return ok ? value : defaultValue; |
601 | -} |
602 | - |
603 | void |
604 | DashDeclarativeView::updateDashModeDependingOnScreenGeometry() |
605 | { |
606 | QRect rect = QApplication::desktop()->screenGeometry(this); |
607 | - static int minWidth = getenvInt("DASH_MIN_SCREEN_WIDTH", DASH_MIN_SCREEN_WIDTH); |
608 | - static int minHeight = getenvInt("DASH_MIN_SCREEN_HEIGHT", DASH_MIN_SCREEN_HEIGHT); |
609 | - if (rect.width() < minWidth && rect.height() < minHeight) { |
610 | + QSize minSize = Unity2d::DashSettings::minimumSizeForDesktop(); |
611 | + if (rect.width() < minSize.width() && rect.height() < minSize.height()) { |
612 | setDashMode(FullScreenMode); |
613 | } else { |
614 | setDashMode(DesktopMode); |
615 | |
616 | === modified file 'places/app/places.cpp' |
617 | --- places/app/places.cpp 2011-11-11 15:52:49 +0000 |
618 | +++ places/app/places.cpp 2011-11-29 12:07:27 +0000 |
619 | @@ -43,6 +43,7 @@ |
620 | Unity2dApplication::earlySetup(argc, argv); |
621 | Unity2dApplication application(argc, argv); |
622 | application.setApplicationName("Unity 2D Dash"); |
623 | + application.setQuitOnLastWindowClosed(false); |
624 | QSet<QString> arguments = QSet<QString>::fromList(QCoreApplication::arguments()); |
625 | |
626 | qmlRegisterType<DashDeclarativeView>("Unity2d", 1, 0, "DashDeclarativeView"); |
627 | |
628 | === removed file 'places/artwork/fullscreen_button.png' |
629 | Binary files places/artwork/fullscreen_button.png 2011-02-11 17:29:15 +0000 and places/artwork/fullscreen_button.png 1970-01-01 00:00:00 +0000 differ |
630 | === modified file 'places/dash.qml' |
631 | --- places/dash.qml 2011-11-18 11:33:28 +0000 |
632 | +++ places/dash.qml 2011-11-29 12:07:27 +0000 |
633 | @@ -39,6 +39,17 @@ |
634 | value: (currentPage && currentPage.expanded != undefined) ? currentPage.expanded : true |
635 | } |
636 | |
637 | + DashSettings { |
638 | + id: settings |
639 | + } |
640 | + |
641 | + Binding { |
642 | + target: dashView |
643 | + property: "dashMode" |
644 | + value: (settings.formFactor == DashSettings.Desktop) ? |
645 | + DashDeclarativeView.DesktopMode : DashDeclarativeView.FullScreenMode |
646 | + } |
647 | + |
648 | /* Unload the current page when closing the dash */ |
649 | Connections { |
650 | target: dashView |
651 | @@ -294,28 +305,4 @@ |
652 | visible: dashView.expanded |
653 | } |
654 | } |
655 | - |
656 | - AbstractButton { |
657 | - id: fullScreenButton |
658 | - |
659 | - Accessible.name: "Full Screen" |
660 | - |
661 | - anchors.bottom: parent.bottom |
662 | - anchors.right: parent.right |
663 | - anchors.rightMargin: 15 |
664 | - anchors.bottomMargin: 15 |
665 | - width: fullScreenButtonImage.sourceSize.width |
666 | - height: fullScreenButtonImage.sourceSize.height |
667 | - visible: dashView.dashMode != DashDeclarativeView.FullScreenMode |
668 | - |
669 | - Image { |
670 | - id: fullScreenButtonImage |
671 | - source: "artwork/fullscreen_button.png" |
672 | - mirror: isRightToLeft() |
673 | - } |
674 | - |
675 | - onClicked: { |
676 | - dashView.dashMode = DashDeclarativeView.FullScreenMode |
677 | - } |
678 | - } |
679 | } |
Works fine here. Only thing I'm not sure of - what's the purpose of minimizing the Dash?