Merge lp:~gerboland/unity-2d/launcher_Alt+F1_fix into lp:unity-2d/3.0

Proposed by Gerry Boland
Status: Merged
Approved by: Florian Boucault
Approved revision: 655
Merged at revision: 653
Proposed branch: lp:~gerboland/unity-2d/launcher_Alt+F1_fix
Merge into: lp:unity-2d/3.0
Diff against target: 233 lines (+37/-80)
9 files modified
launcher/LauncherList.qml (+1/-1)
launcher/app/launcherview.cpp (+1/-7)
launcher/app/launcherview.h (+0/-3)
libunity-2d-private/src/unity2ddeclarativeview.cpp (+32/-0)
libunity-2d-private/src/unity2ddeclarativeview.h (+3/-0)
places/app/dashdeclarativeview.cpp (+0/-29)
places/app/dashdeclarativeview.h (+0/-1)
spread/app/spreadview.cpp (+0/-36)
spread/app/spreadview.h (+0/-3)
To merge this branch: bzr merge lp:~gerboland/unity-2d/launcher_Alt+F1_fix
Reviewer Review Type Date Requested Status
Florian Boucault (community) Approve
Review via email: mp+69626@code.launchpad.net

Description of the change

[launcher] Fixed failure to appear on first Alt+F1 keypress.

This was because QDeclarative::activateWindow() not reliable. Dash & Spread use forceActivateWindow() instead.
Instead of having a third copy of this method for the Launcher, I've moved it to Unity2DDeclarativeView and removed the copies from Dash & Spread.

To post a comment you must log in.
655. By Gerry Boland

Closing LauncherItem's context menu actually closed Launcher. Fixed.

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

Just perfect!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'launcher/LauncherList.qml'
2--- launcher/LauncherList.qml 2011-06-23 17:08:53 +0000
3+++ launcher/LauncherList.qml 2011-07-28 12:28:29 +0000
4@@ -201,7 +201,7 @@
5 target: item.menu
6 /* The menu had the keyboard focus because the launcher had
7 activated it. Restore it. */
8- onDismissedByKeyEvent: launcherView.activateWindow()
9+ onDismissedByKeyEvent: launcherView.forceActivateWindow()
10 }
11
12 Connections {
13
14=== modified file 'launcher/app/launcherview.cpp'
15--- launcher/app/launcherview.cpp 2011-07-14 14:36:53 +0000
16+++ launcher/app/launcherview.cpp 2011-07-28 12:28:29 +0000
17@@ -77,7 +77,7 @@
18
19 /* Alt+F1 gives the keyboard focus to the launcher. */
20 Hotkey* altF1 = HotkeyMonitor::instance().getHotkeyFor(Qt::Key_F1, Qt::AltModifier);
21- connect(altF1, SIGNAL(pressed()), SLOT(activateWindow()));
22+ connect(altF1, SIGNAL(pressed()), SLOT(forceActivateWindow()));
23
24 /* Alt+F2 shows the dash with the commands place entry activated. */
25 Hotkey* altF2 = HotkeyMonitor::instance().getHotkeyFor(Qt::Key_F2, Qt::AltModifier);
26@@ -96,12 +96,6 @@
27 }
28
29 void
30-LauncherView::activateWindow()
31-{
32- QDeclarativeView::activateWindow();
33-}
34-
35-void
36 LauncherView::focusInEvent(QFocusEvent* event)
37 {
38 QDeclarativeView::focusInEvent(event);
39
40=== modified file 'launcher/app/launcherview.h'
41--- launcher/app/launcherview.h 2011-07-14 14:36:53 +0000
42+++ launcher/app/launcherview.h 2011-07-28 12:28:29 +0000
43@@ -59,9 +59,6 @@
44 void toggleDash();
45 void showCommandsPlace();
46
47-public Q_SLOTS:
48- void activateWindow();
49-
50 protected:
51 void focusInEvent(QFocusEvent* event);
52 void focusOutEvent(QFocusEvent* event);
53
54=== modified file 'libunity-2d-private/src/unity2ddeclarativeview.cpp'
55--- libunity-2d-private/src/unity2ddeclarativeview.cpp 2011-07-05 18:51:34 +0000
56+++ libunity-2d-private/src/unity2ddeclarativeview.cpp 2011-07-28 12:28:29 +0000
57@@ -1,5 +1,9 @@
58 #include "unity2ddeclarativeview.h"
59 #include <QGLWidget>
60+#include <QX11Info>
61+
62+#include <X11/Xlib.h>
63+#include <X11/Xatom.h>
64
65 Unity2DDeclarativeView::Unity2DDeclarativeView(QWidget *parent) :
66 QDeclarativeView(parent), m_useOpenGL(false), m_transparentBackground(false)
67@@ -91,4 +95,32 @@
68 }
69 }
70
71+void Unity2DDeclarativeView::forceActivateWindow()
72+{
73+ /* Workaround focus stealing prevention implemented by some window
74+ managers such as Compiz. This is the exact same code you will find in
75+ libwnck::wnck_window_activate().
76+
77+ ref.: http://permalink.gmane.org/gmane.comp.lib.qt.general/4733
78+ */
79+ Display* display = QX11Info::display();
80+ Atom net_wm_active_window = XInternAtom(display, "_NET_ACTIVE_WINDOW",
81+ False);
82+ XEvent xev;
83+ xev.xclient.type = ClientMessage;
84+ xev.xclient.send_event = True;
85+ xev.xclient.display = display;
86+ xev.xclient.window = this->effectiveWinId();
87+ xev.xclient.message_type = net_wm_active_window;
88+ xev.xclient.format = 32;
89+ xev.xclient.data.l[0] = 2;
90+ xev.xclient.data.l[1] = CurrentTime;
91+ xev.xclient.data.l[2] = 0;
92+ xev.xclient.data.l[3] = 0;
93+ xev.xclient.data.l[4] = 0;
94+
95+ XSendEvent(display, QX11Info::appRootWindow(), False,
96+ SubstructureRedirectMask | SubstructureNotifyMask, &xev);
97+}
98+
99 #include <unity2ddeclarativeview.moc>
100
101=== modified file 'libunity-2d-private/src/unity2ddeclarativeview.h'
102--- libunity-2d-private/src/unity2ddeclarativeview.h 2011-07-05 16:40:08 +0000
103+++ libunity-2d-private/src/unity2ddeclarativeview.h 2011-07-28 12:28:29 +0000
104@@ -28,6 +28,9 @@
105 protected:
106 void setupViewport();
107
108+protected Q_SLOTS:
109+ void forceActivateWindow();
110+
111 private:
112 bool m_useOpenGL;
113 bool m_transparentBackground;
114
115=== modified file 'places/app/dashdeclarativeview.cpp'
116--- places/app/dashdeclarativeview.cpp 2011-06-13 00:31:52 +0000
117+++ places/app/dashdeclarativeview.cpp 2011-07-28 12:28:29 +0000
118@@ -235,35 +235,6 @@
119 }
120
121 void
122-DashDeclarativeView::forceActivateWindow()
123-{
124- /* Workaround focus stealing prevention implemented by some window
125- managers such as Compiz. This is the exact same code you will find in
126- libwnck::wnck_window_activate().
127-
128- ref.: http://permalink.gmane.org/gmane.comp.lib.qt.general/4733
129- */
130- Display* display = QX11Info::display();
131- Atom net_wm_active_window = XInternAtom(display, "_NET_ACTIVE_WINDOW",
132- False);
133- XEvent xev;
134- xev.xclient.type = ClientMessage;
135- xev.xclient.send_event = True;
136- xev.xclient.display = display;
137- xev.xclient.window = this->effectiveWinId();
138- xev.xclient.message_type = net_wm_active_window;
139- xev.xclient.format = 32;
140- xev.xclient.data.l[0] = 2;
141- xev.xclient.data.l[1] = CurrentTime;
142- xev.xclient.data.l[2] = 0;
143- xev.xclient.data.l[3] = 0;
144- xev.xclient.data.l[4] = 0;
145-
146- XSendEvent(display, QX11Info::appRootWindow(), False,
147- SubstructureRedirectMask | SubstructureNotifyMask, &xev);
148-}
149-
150-void
151 DashDeclarativeView::activatePlaceEntry(const QString& file, const QString& entry, const int section)
152 {
153 QGraphicsObject* dash = rootObject();
154
155=== modified file 'places/app/dashdeclarativeview.h'
156--- places/app/dashdeclarativeview.h 2011-05-23 17:23:38 +0000
157+++ places/app/dashdeclarativeview.h 2011-07-28 12:28:29 +0000
158@@ -76,7 +76,6 @@
159
160 private Q_SLOTS:
161 void onWorkAreaResized(int screen);
162- void forceActivateWindow();
163
164 private:
165 void fitToAvailableSpace();
166
167=== modified file 'spread/app/spreadview.cpp'
168--- spread/app/spreadview.cpp 2011-04-29 16:26:25 +0000
169+++ spread/app/spreadview.cpp 2011-07-28 12:28:29 +0000
170@@ -22,10 +22,6 @@
171 #include <QDesktopWidget>
172 #include <QApplication>
173 #include <QMouseEvent>
174-#include <QX11Info>
175-
176-#include <X11/Xlib.h>
177-#include <X11/Xatom.h>
178
179 #include "launcherclient.h"
180
181@@ -48,38 +44,6 @@
182 }
183 }
184
185-/* Since we are a dock window, the WM never gives us keyboard focus.
186- The workaround below, copied from places, will fix this */
187-/* FIXME: copied from places/app/dashdeclarativeview.cpp */
188-void
189-SpreadView::forceActivateWindow()
190-{
191- /* Workaround focus stealing prevention implemented by some window
192- managers such as Compiz. This is the exact same code you will find in
193- libwnck::wnck_window_activate().
194-
195- ref.: http://permalink.gmane.org/gmane.comp.lib.qt.general/4733
196- */
197- Display* display = QX11Info::display();
198- Atom net_wm_active_window = XInternAtom(display, "_NET_ACTIVE_WINDOW",
199- False);
200- XEvent xev;
201- xev.xclient.type = ClientMessage;
202- xev.xclient.send_event = True;
203- xev.xclient.display = display;
204- xev.xclient.window = this->effectiveWinId();
205- xev.xclient.message_type = net_wm_active_window;
206- xev.xclient.format = 32;
207- xev.xclient.data.l[0] = 2;
208- xev.xclient.data.l[1] = CurrentTime;
209- xev.xclient.data.l[2] = 0;
210- xev.xclient.data.l[3] = 0;
211- xev.xclient.data.l[4] = 0;
212-
213- XSendEvent(display, QX11Info::appRootWindow(), False,
214- SubstructureRedirectMask | SubstructureNotifyMask, &xev);
215-}
216-
217 /* To be able to call grabMouse() we need to be 100% sure that X11 did
218 already map the window. Otherwise grabMouse() will silently fail (and
219 confusingly incorrectly reports the widget to be the mouseGrabber())
220
221=== modified file 'spread/app/spreadview.h'
222--- spread/app/spreadview.h 2011-04-29 16:26:25 +0000
223+++ spread/app/spreadview.h 2011-07-28 12:28:29 +0000
224@@ -36,9 +36,6 @@
225 /* FIXME: copied from places/app/dashdeclarativeview.h */
226 void fitToAvailableSpace(int screen);
227
228- /* FIXME: copied from places/app/dashdeclarativeview.h */
229- void forceActivateWindow();
230-
231 protected:
232 virtual void focusInEvent( QFocusEvent * event );
233 virtual void focusOutEvent( QFocusEvent * event );

Subscribers

People subscribed via source and target branches