Merge lp:~fboucault/unity-2d/dash_active_cleanups into lp:~unity-2d-team/unity-2d/unity-2d-shell

Proposed by Florian Boucault
Status: Merged
Approved by: Albert Astals Cid
Approved revision: 999
Merged at revision: 998
Proposed branch: lp:~fboucault/unity-2d/dash_active_cleanups
Merge into: lp:~unity-2d-team/unity-2d/unity-2d-shell
Diff against target: 125 lines (+8/-40)
4 files modified
libunity-2d-private/src/unity2ddeclarativeview.cpp (+3/-0)
shell/app/shelldeclarativeview.cpp (+3/-39)
shell/app/shelldeclarativeview.h (+0/-1)
shell/dash/Dash.qml (+2/-0)
To merge this branch: bzr merge lp:~fboucault/unity-2d/dash_active_cleanups
Reviewer Review Type Date Requested Status
Albert Astals Cid (community) Approve
Review via email: mp+92187@code.launchpad.net

Description of the change

Simplified implementation of:
- ShellDeclarativeView::toggleDash()
- ShellDeclarativeView::setDashActive()

Details:
- Removed ShellDeclarativeView::isSpreadActive().
- Moved forceActivateWindow() from ShellDeclarativeView::setDashActive() to Dash.qml
- Fixed ShellDeclarativeView::toggleDash: no need to setFocus() as forceActivateWindow() will be called upon setting dash.active to true.

Added comments to ShellDeclarativeView::onAltF1Pressed().

ShellDeclarativeView::dashActive property is now only used as storage for the boolean. All behavior is done in Dash.qml's active property.

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

Removed D-Bus spread related constants that are useless now that we removed ShellDeclarativeView::isSpreadActive().

Revision history for this message
Albert Astals Cid (aacid) wrote :

This breaks some tests
"Press Alt+F1 to focus/unfocus Launcher"
"Press Alt+F1 to focus Launcher when dash is open, Alt+F1 to unfocus"
"Check focus goes to dash on Super when launcher menu is open"

Revision history for this message
Florian Boucault (fboucault) wrote :

is "Press Alt F1 esc to focus unfocus Launcher when dash is open" broken for you too?

Revision history for this message
Albert Astals Cid (aacid) wrote :

That one seems to work fine here

997. By Florian Boucault

Reverted revision 995

998. By Florian Boucault

ShellDeclarativeView::onAltF1Pressed():
- added comments
- emit launcherFocusRequested last

Fixes test_Press_Alt_F1_to_focus_unfocus_Launcher

999. By Florian Boucault

Strengten forceActivateThisWindow thus fixing test_Check_focus_goes_to_dash_on_Super_when_launcher_menu_is_open

Revision history for this message
Albert Astals Cid (aacid) wrote :

Tests pass again now :-)

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/unity2ddeclarativeview.cpp'
2--- libunity-2d-private/src/unity2ddeclarativeview.cpp 2012-02-07 11:57:10 +0000
3+++ libunity-2d-private/src/unity2ddeclarativeview.cpp 2012-02-09 10:59:19 +0000
4@@ -260,6 +260,9 @@
5 /* Ensure focus is actually switched to active window */
6 XSetInputFocus(display, window, RevertToParent, CurrentTime);
7 XFlush(display);
8+
9+ /* Use Qt's setFocus mechanism as a safety guard in case the above failed */
10+ setFocus();
11 }
12
13 /* Save WId of window with keyboard focus to m_last_focused_window */
14
15=== modified file 'shell/app/shelldeclarativeview.cpp'
16--- shell/app/shelldeclarativeview.cpp 2012-02-07 11:57:10 +0000
17+++ shell/app/shelldeclarativeview.cpp 2012-02-09 10:59:19 +0000
18@@ -48,11 +48,6 @@
19
20 static const int KEY_HOLD_THRESHOLD = 250;
21
22-static const char* SPREAD_DBUS_SERVICE = "com.canonical.Unity2d.Spread";
23-static const char* SPREAD_DBUS_PATH = "/Spread";
24-static const char* SPREAD_DBUS_INTERFACE = "com.canonical.Unity2d.Spread";
25-static const char* SPREAD_DBUS_METHOD_IS_SHOWN = "IsShown";
26-
27 static const char* COMMANDS_LENS_ID = "commands.lens";
28
29 ShellDeclarativeView::ShellDeclarativeView()
30@@ -164,25 +159,6 @@
31 XA_ATOM, 32, PropModeAppend, (unsigned char *) &propAtom, 1);
32 }
33
34-bool
35-ShellDeclarativeView::isSpreadActive()
36-{
37- /* Check if the spread is present on DBUS first, as we don't want to have DBUS
38- activate it if it's not running yet */
39- QDBusConnectionInterface* sessionBusIFace = QDBusConnection::sessionBus().interface();
40- QDBusReply<bool> reply = sessionBusIFace->isServiceRegistered(SPREAD_DBUS_SERVICE);
41- if (reply.isValid() && reply.value() == true) {
42- QDBusInterface spreadInterface(SPREAD_DBUS_SERVICE, SPREAD_DBUS_PATH,
43- SPREAD_DBUS_INTERFACE);
44-
45- QDBusReply<bool> spreadActiveResult = spreadInterface.call(SPREAD_DBUS_METHOD_IS_SHOWN);
46- if (spreadActiveResult.isValid() && spreadActiveResult.value() == true) {
47- return true;
48- }
49- }
50- return false;
51-}
52-
53 void
54 ShellDeclarativeView::showEvent(QShowEvent *event)
55 {
56@@ -196,19 +172,6 @@
57 ShellDeclarativeView::setDashActive(bool value)
58 {
59 if (value != m_active) {
60- if (value) {
61- /* Check if the spread is active before activating the dash.
62- We need to do this since the spread can't prevent the launcher from
63- monitoring the super key and therefore getting to this point if
64- it's tapped. */
65- if (isSpreadActive()) {
66- return;
67- }
68-
69- // FIXME: should be moved to Shell.qml
70- // We need a delay, otherwise the window may not be visible when we try to activate it
71- QTimer::singleShot(0, this, SLOT(forceActivateWindow()));
72- }
73 m_active = value;
74 Q_EMIT dashActiveChanged(m_active);
75 }
76@@ -276,7 +239,6 @@
77 setDashActive(false);
78 forceDeactivateWindow();
79 } else {
80- setFocus();
81 Q_EMIT activateHome();
82 }
83 }
84@@ -291,13 +253,15 @@
85 ShellDeclarativeView::onAltF1Pressed()
86 {
87 if (!isActiveWindow()) {
88+ forceActivateWindow();
89 Q_EMIT launcherFocusRequested();
90- forceActivateWindow();
91 } else {
92 if (dashActive()) {
93+ // focus the launcher instead of the dash
94 setDashActive(false);
95 Q_EMIT launcherFocusRequested();
96 } else {
97+ // we assume that the launcher is focused; unfocus it by deactivating the shell window
98 forceDeactivateWindow();
99 }
100 }
101
102=== modified file 'shell/app/shelldeclarativeview.h'
103--- shell/app/shelldeclarativeview.h 2012-02-07 11:57:10 +0000
104+++ shell/app/shelldeclarativeview.h 2012-02-09 10:59:19 +0000
105@@ -117,7 +117,6 @@
106 void focusOutEvent(QFocusEvent* event);
107 void focusInEvent(QFocusEvent* event);
108 void setWMFlags();
109- bool isSpreadActive();
110 void updateInputShape();
111
112 DashMode m_mode;
113
114=== modified file 'shell/dash/Dash.qml'
115--- shell/dash/Dash.qml 2012-02-09 02:11:23 +0000
116+++ shell/dash/Dash.qml 2012-02-09 10:59:19 +0000
117@@ -50,6 +50,8 @@
118 value: declarativeView.dashActive
119 }
120
121+ onActiveChanged: if (dash.active) declarativeView.forceActivateWindow()
122+
123 property variant queuedLensId
124
125 function isRightToLeft() {

Subscribers

People subscribed via source and target branches