Merge lp:~dyams/unity-2d/mm-updates-pips into lp:unity-2d
- mm-updates-pips
- Merge into trunk
Proposed by
Lohith D Shivamurthy
Status: | Superseded |
---|---|
Proposed branch: | lp:~dyams/unity-2d/mm-updates-pips |
Merge into: | lp:unity-2d |
Diff against target: |
1218 lines (+638/-222) 15 files modified
libunity-2d-private/src/launcherapplication.cpp (+88/-0) libunity-2d-private/src/launcherapplication.h (+5/-0) libunity-2d-private/src/launcheritem.cpp (+6/-0) libunity-2d-private/src/launcheritem.h (+2/-0) libunity-2d-private/src/screeninfo.cpp (+15/-0) libunity-2d-private/src/screeninfo.h (+2/-0) shell/Shell.qml (+5/-1) shell/app/CMakeLists.txt (+2/-0) shell/app/shell.cpp (+3/-51) shell/app/shelldeclarativeview.cpp (+52/-147) shell/app/shelldeclarativeview.h (+16/-20) shell/app/shellmanager.cpp (+380/-0) shell/app/shellmanager.h (+58/-0) shell/launcher/LauncherList.qml (+3/-2) shell/launcher/LauncherLoader.qml (+1/-1) |
To merge this branch: | bzr merge lp:~dyams/unity-2d/mm-updates-pips |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Albert Astals Cid | Pending | ||
Review via email: mp+93350@code.launchpad.net |
Commit message
Description of the change
[shell]
To post a comment you must log in.
- 922. By Lohith D Shivamurthy
-
fix comments
Unmerged revisions
- 922. By Lohith D Shivamurthy
-
fix comments
- 921. By Lohith D Shivamurthy
-
[shell] update pips to show whether application belongs to current screen or not
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'libunity-2d-private/src/launcherapplication.cpp' | |||
2 | --- libunity-2d-private/src/launcherapplication.cpp 2012-02-06 12:07:47 +0000 | |||
3 | +++ libunity-2d-private/src/launcherapplication.cpp 2012-02-16 08:16:20 +0000 | |||
4 | @@ -43,6 +43,7 @@ | |||
5 | 43 | // libunity-2d | 43 | // libunity-2d |
6 | 44 | #include <unity2dtr.h> | 44 | #include <unity2dtr.h> |
7 | 45 | #include <debug_p.h> | 45 | #include <debug_p.h> |
8 | 46 | #include <screeninfo.h> | ||
9 | 46 | 47 | ||
10 | 47 | // Qt | 48 | // Qt |
11 | 48 | #include <Qt> | 49 | #include <Qt> |
12 | @@ -62,6 +63,14 @@ | |||
13 | 62 | #include <libsn/sn.h> | 63 | #include <libsn/sn.h> |
14 | 63 | } | 64 | } |
15 | 64 | 65 | ||
16 | 66 | #define GOBJECT_CALLBACK0(callbackName, slot) \ | ||
17 | 67 | static void \ | ||
18 | 68 | callbackName(GObject* src, QObject* dst) \ | ||
19 | 69 | { \ | ||
20 | 70 | QMetaObject::invokeMethod(dst, slot); \ | ||
21 | 71 | } | ||
22 | 72 | GOBJECT_CALLBACK0(geometryChangedCB, "onWindowGeometryChanged") | ||
23 | 73 | |||
24 | 65 | const char* SHORTCUT_NICK_PROPERTY = "nick"; | 74 | const char* SHORTCUT_NICK_PROPERTY = "nick"; |
25 | 66 | 75 | ||
26 | 67 | LauncherApplication::LauncherApplication() | 76 | LauncherApplication::LauncherApplication() |
27 | @@ -91,6 +100,7 @@ | |||
28 | 91 | 100 | ||
29 | 92 | LauncherApplication::~LauncherApplication() | 101 | LauncherApplication::~LauncherApplication() |
30 | 93 | { | 102 | { |
31 | 103 | disconnectWindowSignals(); | ||
32 | 94 | } | 104 | } |
33 | 95 | 105 | ||
34 | 96 | bool | 106 | bool |
35 | @@ -526,6 +536,29 @@ | |||
36 | 526 | WnckWindow* window = wnck_window_get(xids->at(i)); | 536 | WnckWindow* window = wnck_window_get(xids->at(i)); |
37 | 527 | g_signal_connect(G_OBJECT(window), "workspace-changed", | 537 | g_signal_connect(G_OBJECT(window), "workspace-changed", |
38 | 528 | G_CALLBACK(LauncherApplication::onWindowWorkspaceChanged), this); | 538 | G_CALLBACK(LauncherApplication::onWindowWorkspaceChanged), this); |
39 | 539 | g_signal_connect(G_OBJECT(window), "geometry-changed", G_CALLBACK(geometryChangedCB), this); | ||
40 | 540 | } | ||
41 | 541 | } | ||
42 | 542 | |||
43 | 543 | void | ||
44 | 544 | LauncherApplication::disconnectWindowSignals() | ||
45 | 545 | { | ||
46 | 546 | if (m_application == NULL || m_application->running() == false) { | ||
47 | 547 | return; | ||
48 | 548 | } | ||
49 | 549 | |||
50 | 550 | QScopedPointer<BamfUintList> xids(m_application->xids()); | ||
51 | 551 | int size = xids->size(); | ||
52 | 552 | if (size < 1) { | ||
53 | 553 | return; | ||
54 | 554 | } | ||
55 | 555 | |||
56 | 556 | WnckScreen* screen = wnck_screen_get_default(); | ||
57 | 557 | wnck_screen_force_update(screen); | ||
58 | 558 | |||
59 | 559 | for (int i = 0; i < size; ++i) { | ||
60 | 560 | WnckWindow* window = wnck_window_get(xids->at(i)); | ||
61 | 561 | g_signal_handlers_disconnect_by_func(window, gpointer(geometryChangedCB), this); | ||
62 | 529 | } | 562 | } |
63 | 530 | } | 563 | } |
64 | 531 | 564 | ||
65 | @@ -537,6 +570,7 @@ | |||
66 | 537 | WnckWindow* wnck_window = wnck_window_get(window->xid()); | 570 | WnckWindow* wnck_window = wnck_window_get(window->xid()); |
67 | 538 | g_signal_connect(G_OBJECT(wnck_window), "workspace-changed", | 571 | g_signal_connect(G_OBJECT(wnck_window), "workspace-changed", |
68 | 539 | G_CALLBACK(LauncherApplication::onWindowWorkspaceChanged), this); | 572 | G_CALLBACK(LauncherApplication::onWindowWorkspaceChanged), this); |
69 | 573 | g_signal_connect(G_OBJECT(window), "geometry-changed", G_CALLBACK(geometryChangedCB), this); | ||
70 | 540 | } | 574 | } |
71 | 541 | } | 575 | } |
72 | 542 | 576 | ||
73 | @@ -665,6 +699,42 @@ | |||
74 | 665 | return windowCount; | 699 | return windowCount; |
75 | 666 | } | 700 | } |
76 | 667 | 701 | ||
77 | 702 | int | ||
78 | 703 | LauncherApplication::windowCountOnCurrentScreen(int screen) | ||
79 | 704 | { | ||
80 | 705 | int windowCount = 0; | ||
81 | 706 | |||
82 | 707 | if (!m_application) { | ||
83 | 708 | return windowCount; | ||
84 | 709 | } | ||
85 | 710 | |||
86 | 711 | ScreenInfo screenInfo(screen); | ||
87 | 712 | QScopedPointer<BamfUintList> xids(m_application->xids()); | ||
88 | 713 | for (int i = 0; i < xids->size(); i++) { | ||
89 | 714 | /* When geting the wnck window, it's possible we get a NULL | ||
90 | 715 | return value because wnck hasn't updated its internal list yet, | ||
91 | 716 | so we need to force it once to be sure */ | ||
92 | 717 | WnckWindow *window = wnck_window_get(xids->at(i)); | ||
93 | 718 | if (window == NULL) { | ||
94 | 719 | wnck_screen_force_update(wnck_screen_get_default()); | ||
95 | 720 | window = wnck_window_get(xids->at(i)); | ||
96 | 721 | if (window == NULL) { | ||
97 | 722 | continue; | ||
98 | 723 | } | ||
99 | 724 | } | ||
100 | 725 | |||
101 | 726 | // Check the window screen | ||
102 | 727 | int x, y, width, height; | ||
103 | 728 | wnck_window_get_geometry(window, &x, &y, &width, &height); | ||
104 | 729 | QRect windowRect(x, y, width, height); | ||
105 | 730 | QPoint pos = windowRect.center(); | ||
106 | 731 | if (ScreenInfo::screenNumber(pos) == screen) { | ||
107 | 732 | windowCount++; | ||
108 | 733 | } | ||
109 | 734 | } | ||
110 | 735 | return windowCount; | ||
111 | 736 | } | ||
112 | 737 | |||
113 | 668 | void | 738 | void |
114 | 669 | LauncherApplication::activate() | 739 | LauncherApplication::activate() |
115 | 670 | { | 740 | { |
116 | @@ -986,6 +1056,18 @@ | |||
117 | 986 | return false; | 1056 | return false; |
118 | 987 | } | 1057 | } |
119 | 988 | 1058 | ||
120 | 1059 | bool | ||
121 | 1060 | LauncherApplication::belongsToDifferentScreen(int screen) | ||
122 | 1061 | { | ||
123 | 1062 | int totalWindows = windowCount(); | ||
124 | 1063 | int windowsInCurrentScreen = windowCountOnCurrentScreen(screen); | ||
125 | 1064 | if (totalWindows > 0 && windowsInCurrentScreen == 0) { | ||
126 | 1065 | return true; | ||
127 | 1066 | } | ||
128 | 1067 | |||
129 | 1068 | return false; | ||
130 | 1069 | } | ||
131 | 1070 | |||
132 | 989 | void | 1071 | void |
133 | 990 | LauncherApplication::onIndicatorMenuUpdated() | 1072 | LauncherApplication::onIndicatorMenuUpdated() |
134 | 991 | { | 1073 | { |
135 | @@ -1110,6 +1192,12 @@ | |||
136 | 1110 | } | 1192 | } |
137 | 1111 | 1193 | ||
138 | 1112 | void | 1194 | void |
139 | 1195 | LauncherApplication::onWindowGeometryChanged() | ||
140 | 1196 | { | ||
141 | 1197 | windowGeometryChanged(); | ||
142 | 1198 | } | ||
143 | 1199 | |||
144 | 1200 | void | ||
145 | 1113 | LauncherApplication::onDragEnter(DeclarativeDragDropEvent* event) | 1201 | LauncherApplication::onDragEnter(DeclarativeDragDropEvent* event) |
146 | 1114 | { | 1202 | { |
147 | 1115 | QList<QUrl> urls = validateUrisForLaunch(event->mimeData()); | 1203 | QList<QUrl> urls = validateUrisForLaunch(event->mimeData()); |
148 | 1116 | 1204 | ||
149 | === modified file 'libunity-2d-private/src/launcherapplication.h' | |||
150 | --- libunity-2d-private/src/launcherapplication.h 2012-02-06 12:07:47 +0000 | |||
151 | +++ libunity-2d-private/src/launcherapplication.h 2012-02-16 08:16:20 +0000 | |||
152 | @@ -105,7 +105,9 @@ | |||
153 | 105 | 105 | ||
154 | 106 | Q_INVOKABLE virtual void createMenuActions(); | 106 | Q_INVOKABLE virtual void createMenuActions(); |
155 | 107 | Q_INVOKABLE virtual bool belongsToDifferentWorkspace(); | 107 | Q_INVOKABLE virtual bool belongsToDifferentWorkspace(); |
156 | 108 | Q_INVOKABLE virtual bool belongsToDifferentScreen(int screen); | ||
157 | 108 | Q_INVOKABLE void connectWindowSignals(); | 109 | Q_INVOKABLE void connectWindowSignals(); |
158 | 110 | void disconnectWindowSignals(); | ||
159 | 109 | 111 | ||
160 | 110 | void updateOverlaysState(const QString& sender, const QMap<QString, QVariant>& properties); | 112 | void updateOverlaysState(const QString& sender, const QMap<QString, QVariant>& properties); |
161 | 111 | 113 | ||
162 | @@ -151,6 +153,8 @@ | |||
163 | 151 | void onDragEnter(DeclarativeDragDropEvent*); | 153 | void onDragEnter(DeclarativeDragDropEvent*); |
164 | 152 | void onDrop(DeclarativeDragDropEvent*); | 154 | void onDrop(DeclarativeDragDropEvent*); |
165 | 153 | 155 | ||
166 | 156 | void onWindowGeometryChanged(); | ||
167 | 157 | |||
168 | 154 | private: | 158 | private: |
169 | 155 | QPointer<BamfApplication> m_application; | 159 | QPointer<BamfApplication> m_application; |
170 | 156 | QFileSystemWatcher *m_desktopFileWatcher; | 160 | QFileSystemWatcher *m_desktopFileWatcher; |
171 | @@ -175,6 +179,7 @@ | |||
172 | 175 | void createDynamicMenuActions(); | 179 | void createDynamicMenuActions(); |
173 | 176 | void createStaticMenuActions(); | 180 | void createStaticMenuActions(); |
174 | 177 | int windowCountOnCurrentWorkspace(); | 181 | int windowCountOnCurrentWorkspace(); |
175 | 182 | int windowCountOnCurrentScreen(int); | ||
176 | 178 | template<typename T> | 183 | template<typename T> |
177 | 179 | bool updateOverlayState(const QMap<QString, QVariant>& properties, | 184 | bool updateOverlayState(const QMap<QString, QVariant>& properties, |
178 | 180 | const QString& propertyName, T* member); | 185 | const QString& propertyName, T* member); |
179 | 181 | 186 | ||
180 | === modified file 'libunity-2d-private/src/launcheritem.cpp' | |||
181 | --- libunity-2d-private/src/launcheritem.cpp 2012-02-06 12:07:47 +0000 | |||
182 | +++ libunity-2d-private/src/launcheritem.cpp 2012-02-16 08:16:20 +0000 | |||
183 | @@ -93,6 +93,12 @@ | |||
184 | 93 | } | 93 | } |
185 | 94 | 94 | ||
186 | 95 | bool | 95 | bool |
187 | 96 | LauncherItem::belongsToDifferentScreen(int) | ||
188 | 97 | { | ||
189 | 98 | return false; | ||
190 | 99 | } | ||
191 | 100 | |||
192 | 101 | bool | ||
193 | 96 | LauncherItem::progressBarVisible() const | 102 | LauncherItem::progressBarVisible() const |
194 | 97 | { | 103 | { |
195 | 98 | return false; | 104 | return false; |
196 | 99 | 105 | ||
197 | === modified file 'libunity-2d-private/src/launcheritem.h' | |||
198 | --- libunity-2d-private/src/launcheritem.h 2012-02-06 12:07:47 +0000 | |||
199 | +++ libunity-2d-private/src/launcheritem.h 2012-02-16 08:16:20 +0000 | |||
200 | @@ -80,6 +80,7 @@ | |||
201 | 80 | Q_INVOKABLE virtual void createMenuActions() = 0; | 80 | Q_INVOKABLE virtual void createMenuActions() = 0; |
202 | 81 | Q_INVOKABLE virtual void launchNewInstance(); | 81 | Q_INVOKABLE virtual void launchNewInstance(); |
203 | 82 | Q_INVOKABLE virtual bool belongsToDifferentWorkspace(); | 82 | Q_INVOKABLE virtual bool belongsToDifferentWorkspace(); |
204 | 83 | Q_INVOKABLE virtual bool belongsToDifferentScreen(int); | ||
205 | 83 | 84 | ||
206 | 84 | protected: | 85 | protected: |
207 | 85 | LauncherContextualMenu* m_menu; | 86 | LauncherContextualMenu* m_menu; |
208 | @@ -102,6 +103,7 @@ | |||
209 | 102 | void emblemVisibleChanged(bool); | 103 | void emblemVisibleChanged(bool); |
210 | 103 | void emblemChanged(QString); | 104 | void emblemChanged(QString); |
211 | 104 | void windowWorkspaceChanged(); | 105 | void windowWorkspaceChanged(); |
212 | 106 | void windowGeometryChanged(); | ||
213 | 105 | 107 | ||
214 | 106 | public Q_SLOTS: | 108 | public Q_SLOTS: |
215 | 107 | /* Default implementation of drag’n’drop handling, should be overridden in | 109 | /* Default implementation of drag’n’drop handling, should be overridden in |
216 | 108 | 110 | ||
217 | === modified file 'libunity-2d-private/src/screeninfo.cpp' | |||
218 | --- libunity-2d-private/src/screeninfo.cpp 2012-02-01 16:28:13 +0000 | |||
219 | +++ libunity-2d-private/src/screeninfo.cpp 2012-02-16 08:16:20 +0000 | |||
220 | @@ -198,6 +198,21 @@ | |||
221 | 198 | return m_corner; | 198 | return m_corner; |
222 | 199 | } | 199 | } |
223 | 200 | 200 | ||
224 | 201 | int | ||
225 | 202 | ScreenInfo::cursorScreen() | ||
226 | 203 | { | ||
227 | 204 | QDesktopWidget* desktop = QApplication::desktop(); | ||
228 | 205 | QPoint cursorPos(QCursor::pos()); | ||
229 | 206 | return desktop->screenNumber(cursorPos); | ||
230 | 207 | } | ||
231 | 208 | |||
232 | 209 | int | ||
233 | 210 | ScreenInfo::screenNumber(QPoint point) | ||
234 | 211 | { | ||
235 | 212 | QDesktopWidget* desktop = QApplication::desktop(); | ||
236 | 213 | return desktop->screenNumber(point); | ||
237 | 214 | } | ||
238 | 215 | |||
239 | 201 | void | 216 | void |
240 | 202 | ScreenInfo::setCorner(Corner corner) | 217 | ScreenInfo::setCorner(Corner corner) |
241 | 203 | { | 218 | { |
242 | 204 | 219 | ||
243 | === modified file 'libunity-2d-private/src/screeninfo.h' | |||
244 | --- libunity-2d-private/src/screeninfo.h 2012-02-01 15:01:21 +0000 | |||
245 | +++ libunity-2d-private/src/screeninfo.h 2012-02-16 08:16:20 +0000 | |||
246 | @@ -39,6 +39,8 @@ | |||
247 | 39 | int screen() const; | 39 | int screen() const; |
248 | 40 | QWidget* widget() const; | 40 | QWidget* widget() const; |
249 | 41 | Corner corner() const; | 41 | Corner corner() const; |
250 | 42 | static int cursorScreen(); | ||
251 | 43 | static int screenNumber(QPoint); | ||
252 | 42 | 44 | ||
253 | 43 | /* Setters */ | 45 | /* Setters */ |
254 | 44 | void setScreen(int screen); | 46 | void setScreen(int screen); |
255 | 45 | 47 | ||
256 | === modified file 'shell/Shell.qml' | |||
257 | --- shell/Shell.qml 2012-02-13 09:15:03 +0000 | |||
258 | +++ shell/Shell.qml 2012-02-16 08:16:20 +0000 | |||
259 | @@ -106,7 +106,11 @@ | |||
260 | 106 | 106 | ||
261 | 107 | Loader { | 107 | Loader { |
262 | 108 | id: dashLoader | 108 | id: dashLoader |
264 | 109 | source: "dash/Dash.qml" | 109 | /* TODO : In case of multi-monitors, there should be only one dash, |
265 | 110 | which could be moved to any screen. | ||
266 | 111 | ATM, we are displaying dash for the leftmost screen only. other screens will not support dash yet. | ||
267 | 112 | */ | ||
268 | 113 | source: (declarativeView.isTopLeftShell ? "dash/Dash.qml" : "") | ||
269 | 110 | anchors.top: parent.top | 114 | anchors.top: parent.top |
270 | 111 | x: Utils.isLeftToRight() ? launcherLoader.width : shell.width - width - launcherLoader.width | 115 | x: Utils.isLeftToRight() ? launcherLoader.width : shell.width - width - launcherLoader.width |
271 | 112 | onLoaded: item.focus = true | 116 | onLoaded: item.focus = true |
272 | 113 | 117 | ||
273 | === modified file 'shell/app/CMakeLists.txt' | |||
274 | --- shell/app/CMakeLists.txt 2012-02-13 23:46:04 +0000 | |||
275 | +++ shell/app/CMakeLists.txt 2012-02-16 08:16:20 +0000 | |||
276 | @@ -8,12 +8,14 @@ | |||
277 | 8 | dashdbus.cpp | 8 | dashdbus.cpp |
278 | 9 | launcherdbus.cpp | 9 | launcherdbus.cpp |
279 | 10 | shelldeclarativeview.cpp | 10 | shelldeclarativeview.cpp |
280 | 11 | shellmanager.cpp | ||
281 | 11 | ) | 12 | ) |
282 | 12 | 13 | ||
283 | 13 | set(shell_MOC_HDRS | 14 | set(shell_MOC_HDRS |
284 | 14 | dashdbus.h | 15 | dashdbus.h |
285 | 15 | launcherdbus.h | 16 | launcherdbus.h |
286 | 16 | shelldeclarativeview.h | 17 | shelldeclarativeview.h |
287 | 18 | shellmanager.h | ||
288 | 17 | ) | 19 | ) |
289 | 18 | 20 | ||
290 | 19 | qt4_wrap_cpp(shell_MOC_SRCS ${shell_MOC_HDRS}) | 21 | qt4_wrap_cpp(shell_MOC_SRCS ${shell_MOC_HDRS}) |
291 | 20 | 22 | ||
292 | === modified file 'shell/app/shell.cpp' | |||
293 | --- shell/app/shell.cpp 2012-02-13 23:46:04 +0000 | |||
294 | +++ shell/app/shell.cpp 2012-02-16 08:16:20 +0000 | |||
295 | @@ -21,30 +21,16 @@ | |||
296 | 21 | // QT | 21 | // QT |
297 | 22 | #include <QApplication> | 22 | #include <QApplication> |
298 | 23 | #include <QDebug> | 23 | #include <QDebug> |
299 | 24 | #include <QtDeclarative> | ||
300 | 25 | #include <QDeclarativeEngine> | ||
301 | 26 | #include <QDeclarativeView> | ||
302 | 27 | #include <QDesktopWidget> | ||
303 | 28 | #include <QDBusConnection> | ||
304 | 29 | #include <QDBusConnectionInterface> | ||
305 | 30 | #include <QDeclarativeContext> | ||
306 | 31 | #include <QAbstractEventDispatcher> | ||
307 | 32 | #include <QDir> | 24 | #include <QDir> |
311 | 33 | 25 | #include <QUrl> | |
309 | 34 | // X11 | ||
310 | 35 | #include <X11/Xlib.h> | ||
312 | 36 | 26 | ||
313 | 37 | // unity-2d | 27 | // unity-2d |
314 | 38 | #include <gnomesessionclient.h> | 28 | #include <gnomesessionclient.h> |
315 | 39 | #include <unity2dapplication.h> | 29 | #include <unity2dapplication.h> |
316 | 40 | #include <unity2ddebug.h> | ||
317 | 41 | 30 | ||
318 | 42 | // Local | 31 | // Local |
319 | 43 | #include "config.h" | 32 | #include "config.h" |
324 | 44 | #include "shelldeclarativeview.h" | 33 | #include "shellmanager.h" |
321 | 45 | #include "dashclient.h" | ||
322 | 46 | #include "dashdbus.h" | ||
323 | 47 | #include "launcherdbus.h" | ||
325 | 48 | 34 | ||
326 | 49 | int main(int argc, char *argv[]) | 35 | int main(int argc, char *argv[]) |
327 | 50 | { | 36 | { |
328 | @@ -71,32 +57,7 @@ | |||
329 | 71 | GnomeSessionClient client(INSTALL_PREFIX "/share/applications/unity-2d-shell.desktop"); | 57 | GnomeSessionClient client(INSTALL_PREFIX "/share/applications/unity-2d-shell.desktop"); |
330 | 72 | client.connectToSessionManager(); | 58 | client.connectToSessionManager(); |
331 | 73 | 59 | ||
358 | 74 | qmlRegisterType<ShellDeclarativeView>("Unity2d", 1, 0, "ShellDeclarativeView"); | 60 | ShellManager shells(rootFileUrl); |
333 | 75 | ShellDeclarativeView view; | ||
334 | 76 | view.setAccessibleName("Shell"); | ||
335 | 77 | if (arguments.contains("-opengl")) { | ||
336 | 78 | view.setUseOpenGL(true); | ||
337 | 79 | } | ||
338 | 80 | |||
339 | 81 | application.installX11EventFilter(&view); | ||
340 | 82 | |||
341 | 83 | view.engine()->addImportPath(unity2dImportPath()); | ||
342 | 84 | view.engine()->setBaseUrl(QUrl::fromLocalFile(unity2dDirectory() + "/shell/")); | ||
343 | 85 | |||
344 | 86 | /* Load the QML UI, focus and show the window */ | ||
345 | 87 | view.setResizeMode(QDeclarativeView::SizeViewToRootObject); | ||
346 | 88 | view.rootContext()->setContextProperty("declarativeView", &view); | ||
347 | 89 | // WARNING This declaration of dashClient used to be in Unity2d/plugin.cpp | ||
348 | 90 | // but it lead to locks when both the shell and the spread were started | ||
349 | 91 | // at the same time since SpreadMonitor QDBusServiceWatcher::serviceRegistered | ||
350 | 92 | // and DashClient QDBusServiceWatcher::serviceRegistered | ||
351 | 93 | // triggered at the same time ending up with both creating QDBusInterface | ||
352 | 94 | // to eachother in the main thread meaning they would block | ||
353 | 95 | // In case you need to have a DashClient in the spread the fix for the problem | ||
354 | 96 | // is moving the QDbusInterface creation to a thread so it does not block | ||
355 | 97 | // the main thread | ||
356 | 98 | view.rootContext()->setContextProperty("dashClient", DashClient::instance()); | ||
357 | 99 | view.setSource(rootFileUrl); | ||
359 | 100 | 61 | ||
360 | 101 | /* Unset DESKTOP_AUTOSTART_ID in order to avoid child processes (launched | 62 | /* Unset DESKTOP_AUTOSTART_ID in order to avoid child processes (launched |
361 | 102 | applications) to use the same client id. | 63 | applications) to use the same client id. |
362 | @@ -113,14 +74,5 @@ | |||
363 | 113 | (see e.g. https://bugs.launchpad.net/bugs/684471). */ | 74 | (see e.g. https://bugs.launchpad.net/bugs/684471). */ |
364 | 114 | QDir::setCurrent(QDir::homePath()); | 75 | QDir::setCurrent(QDir::homePath()); |
365 | 115 | 76 | ||
366 | 116 | DashDBus dashDBus(&view); | ||
367 | 117 | if (!dashDBus.connectToBus()) { | ||
368 | 118 | qCritical() << "Another instance of the Dash already exists. Quitting."; | ||
369 | 119 | return -1; | ||
370 | 120 | } | ||
371 | 121 | |||
372 | 122 | LauncherDBus launcherDBus(&view); | ||
373 | 123 | launcherDBus.connectToBus(); | ||
374 | 124 | |||
375 | 125 | return application.exec(); | 77 | return application.exec(); |
376 | 126 | } | 78 | } |
377 | 127 | 79 | ||
378 | === modified file 'shell/app/shelldeclarativeview.cpp' | |||
379 | --- shell/app/shelldeclarativeview.cpp 2012-02-13 23:46:04 +0000 | |||
380 | +++ shell/app/shelldeclarativeview.cpp 2012-02-16 08:16:20 +0000 | |||
381 | @@ -22,11 +22,6 @@ | |||
382 | 22 | // libunity-2d-private | 22 | // libunity-2d-private |
383 | 23 | #include <debug_p.h> | 23 | #include <debug_p.h> |
384 | 24 | #include <hotkey.h> | 24 | #include <hotkey.h> |
385 | 25 | #include <hotkeymonitor.h> | ||
386 | 26 | #include <keyboardmodifiersmonitor.h> | ||
387 | 27 | #include <keymonitor.h> | ||
388 | 28 | #include <dashclient.h> | ||
389 | 29 | #include <launcherclient.h> | ||
390 | 30 | #include <screeninfo.h> | 25 | #include <screeninfo.h> |
391 | 31 | #include <strutmanager.h> | 26 | #include <strutmanager.h> |
392 | 32 | 27 | ||
393 | @@ -47,46 +42,20 @@ | |||
394 | 47 | #include <X11/Xlib.h> | 42 | #include <X11/Xlib.h> |
395 | 48 | #include <X11/Xatom.h> | 43 | #include <X11/Xatom.h> |
396 | 49 | 44 | ||
397 | 50 | static const int KEY_HOLD_THRESHOLD = 250; | ||
398 | 51 | |||
399 | 52 | static const char* COMMANDS_LENS_ID = "commands.lens"; | 45 | static const char* COMMANDS_LENS_ID = "commands.lens"; |
400 | 53 | 46 | ||
402 | 54 | ShellDeclarativeView::ShellDeclarativeView() | 47 | ShellDeclarativeView::ShellDeclarativeView(const QUrl &sourceFileUrl, bool isTopLeftShell, int screen) |
403 | 55 | : Unity2DDeclarativeView() | 48 | : Unity2DDeclarativeView() |
404 | 56 | , m_mode(DesktopMode) | 49 | , m_mode(DesktopMode) |
405 | 57 | , m_expanded(true) | 50 | , m_expanded(true) |
406 | 58 | , m_active(false) | 51 | , m_active(false) |
409 | 59 | , m_superKeyPressed(false) | 52 | , m_isTopLeftShell(isTopLeftShell) |
410 | 60 | , m_superKeyHeld(false) | 53 | , m_sourceFileUrl(sourceFileUrl) |
411 | 61 | { | 54 | { |
412 | 62 | setAttribute(Qt::WA_X11NetWmWindowTypeDock, true); | 55 | setAttribute(Qt::WA_X11NetWmWindowTypeDock, true); |
413 | 63 | setTransparentBackground(QX11Info::isCompositingManagerRunning()); | 56 | setTransparentBackground(QX11Info::isCompositingManagerRunning()); |
414 | 64 | 57 | ||
440 | 65 | m_screenInfo = new ScreenInfo(ScreenInfo::TopLeft, this); | 58 | m_screenInfo = new ScreenInfo(screen, this); |
416 | 66 | |||
417 | 67 | m_superKeyHoldTimer.setSingleShot(true); | ||
418 | 68 | m_superKeyHoldTimer.setInterval(KEY_HOLD_THRESHOLD); | ||
419 | 69 | connect(&m_superKeyHoldTimer, SIGNAL(timeout()), SLOT(updateSuperKeyHoldState())); | ||
420 | 70 | connect(this, SIGNAL(superKeyTapped()), SLOT(toggleDash())); | ||
421 | 71 | |||
422 | 72 | connect(&launcher2dConfiguration(), SIGNAL(superKeyEnableChanged(bool)), SLOT(updateSuperKeyMonitoring())); | ||
423 | 73 | updateSuperKeyMonitoring(); | ||
424 | 74 | |||
425 | 75 | /* Alt+F1 reveal the launcher and gives the keyboard focus to the Dash Button. */ | ||
426 | 76 | Hotkey* altF1 = HotkeyMonitor::instance().getHotkeyFor(Qt::Key_F1, Qt::AltModifier); | ||
427 | 77 | connect(altF1, SIGNAL(pressed()), SLOT(onAltF1Pressed())); | ||
428 | 78 | |||
429 | 79 | /* Alt+F2 shows the dash with the commands lens activated. */ | ||
430 | 80 | Hotkey* altF2 = HotkeyMonitor::instance().getHotkeyFor(Qt::Key_F2, Qt::AltModifier); | ||
431 | 81 | connect(altF2, SIGNAL(pressed()), SLOT(showCommandsLens())); | ||
432 | 82 | |||
433 | 83 | /* Super+{n} for 0 ≤ n ≤ 9 activates the item with index (n + 9) % 10. */ | ||
434 | 84 | for (Qt::Key key = Qt::Key_0; key <= Qt::Key_9; key = (Qt::Key) (key + 1)) { | ||
435 | 85 | Hotkey* hotkey = HotkeyMonitor::instance().getHotkeyFor(key, Qt::MetaModifier); | ||
436 | 86 | connect(hotkey, SIGNAL(pressed()), SLOT(forwardNumericHotkey())); | ||
437 | 87 | hotkey = HotkeyMonitor::instance().getHotkeyFor(key, Qt::MetaModifier | Qt::ShiftModifier); | ||
438 | 88 | connect(hotkey, SIGNAL(pressed()), SLOT(forwardNumericHotkey())); | ||
439 | 89 | } | ||
441 | 90 | 59 | ||
442 | 91 | connect(m_screenInfo, SIGNAL(availableGeometryChanged(QRect)), SLOT(updateShellPosition())); | 60 | connect(m_screenInfo, SIGNAL(availableGeometryChanged(QRect)), SLOT(updateShellPosition())); |
443 | 92 | updateShellPosition(); | 61 | updateShellPosition(); |
444 | @@ -172,6 +141,9 @@ | |||
445 | 172 | /* Note that this has to be called everytime the window is shown, as the WM | 141 | /* Note that this has to be called everytime the window is shown, as the WM |
446 | 173 | will remove the flags when the window is hidden */ | 142 | will remove the flags when the window is hidden */ |
447 | 174 | setWMFlags(); | 143 | setWMFlags(); |
448 | 144 | if (source().isEmpty()) { | ||
449 | 145 | setSource(m_sourceFileUrl); | ||
450 | 146 | } | ||
451 | 175 | } | 147 | } |
452 | 176 | 148 | ||
453 | 177 | void | 149 | void |
454 | @@ -262,7 +234,7 @@ | |||
455 | 262 | } | 234 | } |
456 | 263 | 235 | ||
457 | 264 | void | 236 | void |
459 | 265 | ShellDeclarativeView::onAltF1Pressed() | 237 | ShellDeclarativeView::toggleLauncher() |
460 | 266 | { | 238 | { |
461 | 267 | if (!isActiveWindow()) { | 239 | if (!isActiveWindow()) { |
462 | 268 | forceActivateWindow(); | 240 | forceActivateWindow(); |
463 | @@ -279,117 +251,27 @@ | |||
464 | 279 | } | 251 | } |
465 | 280 | } | 252 | } |
466 | 281 | 253 | ||
578 | 282 | /* ----------------- super key handling ---------------- */ | 254 | void |
579 | 283 | 255 | ShellDeclarativeView::processNumericHotkey(Hotkey* hotkey) | |
580 | 284 | void | 256 | { |
581 | 285 | ShellDeclarativeView::updateSuperKeyHoldState() | 257 | /* Shortcuts from 1 to 9 should activate the items with index |
582 | 286 | { | 258 | from 1 to 9 (index 0 being the so-called "BFB" or Dash launcher). |
583 | 287 | /* If the key was released in the meantime, just do nothing, otherwise | 259 | Shortcut for 0 should activate item with index 10. |
584 | 288 | consider the key being held, unless we're told to ignore it. */ | 260 | In other words, the indexes are activated in the same order as |
585 | 289 | if (m_superKeyPressed && !m_superPressIgnored) { | 261 | the keys appear on a standard keyboard. */ |
586 | 290 | m_superKeyHeld = true; | 262 | Qt::Key key = hotkey->key(); |
587 | 291 | Q_EMIT superKeyHeldChanged(m_superKeyHeld); | 263 | if (key >= Qt::Key_1 && key <= Qt::Key_9) { |
588 | 292 | } | 264 | int index = key - Qt::Key_0; |
589 | 293 | } | 265 | if (hotkey->modifiers() & Qt::ShiftModifier) { |
590 | 294 | 266 | Q_EMIT newInstanceShortcutPressed(index); | |
591 | 295 | void | 267 | } else { |
592 | 296 | ShellDeclarativeView::updateSuperKeyMonitoring() | 268 | Q_EMIT activateShortcutPressed(index); |
593 | 297 | { | 269 | } |
594 | 298 | KeyboardModifiersMonitor *modifiersMonitor = KeyboardModifiersMonitor::instance(); | 270 | } else if (key == Qt::Key_0) { |
595 | 299 | KeyMonitor *keyMonitor = KeyMonitor::instance(); | 271 | if (hotkey->modifiers() & Qt::ShiftModifier) { |
596 | 300 | HotkeyMonitor& hotkeyMonitor = HotkeyMonitor::instance(); | 272 | Q_EMIT newInstanceShortcutPressed(10); |
597 | 301 | 273 | } else { | |
598 | 302 | QVariant value = launcher2dConfiguration().property("superKeyEnable"); | 274 | Q_EMIT activateShortcutPressed(10); |
488 | 303 | if (!value.isValid() || value.toBool() == true) { | ||
489 | 304 | hotkeyMonitor.enableModifiers(Qt::MetaModifier); | ||
490 | 305 | QObject::connect(modifiersMonitor, | ||
491 | 306 | SIGNAL(keyboardModifiersChanged(Qt::KeyboardModifiers)), | ||
492 | 307 | this, SLOT(setHotkeysForModifiers(Qt::KeyboardModifiers))); | ||
493 | 308 | /* Ignore Super presses if another key was pressed simultaneously | ||
494 | 309 | (i.e. a shortcut). https://bugs.launchpad.net/unity-2d/+bug/801073 */ | ||
495 | 310 | QObject::connect(keyMonitor, | ||
496 | 311 | SIGNAL(keyPressed()), | ||
497 | 312 | this, SLOT(ignoreSuperPress())); | ||
498 | 313 | setHotkeysForModifiers(modifiersMonitor->keyboardModifiers()); | ||
499 | 314 | } else { | ||
500 | 315 | hotkeyMonitor.disableModifiers(Qt::MetaModifier); | ||
501 | 316 | QObject::disconnect(modifiersMonitor, | ||
502 | 317 | SIGNAL(keyboardModifiersChanged(Qt::KeyboardModifiers)), | ||
503 | 318 | this, SLOT(setHotkeysForModifiers(Qt::KeyboardModifiers))); | ||
504 | 319 | QObject::disconnect(keyMonitor, | ||
505 | 320 | SIGNAL(keyPressed()), | ||
506 | 321 | this, SLOT(ignoreSuperPress())); | ||
507 | 322 | m_superKeyHoldTimer.stop(); | ||
508 | 323 | m_superKeyPressed = false; | ||
509 | 324 | if (m_superKeyHeld) { | ||
510 | 325 | m_superKeyHeld = false; | ||
511 | 326 | Q_EMIT superKeyHeldChanged(false); | ||
512 | 327 | } | ||
513 | 328 | } | ||
514 | 329 | } | ||
515 | 330 | |||
516 | 331 | void | ||
517 | 332 | ShellDeclarativeView::setHotkeysForModifiers(Qt::KeyboardModifiers modifiers) | ||
518 | 333 | { | ||
519 | 334 | /* This is the new new state of the Super key (AKA Meta key), while | ||
520 | 335 | m_superKeyPressed is the previous state of the key at the last modifiers change. */ | ||
521 | 336 | bool superKeyPressed = modifiers.testFlag(Qt::MetaModifier); | ||
522 | 337 | |||
523 | 338 | if (m_superKeyPressed != superKeyPressed) { | ||
524 | 339 | m_superKeyPressed = superKeyPressed; | ||
525 | 340 | if (superKeyPressed) { | ||
526 | 341 | m_superPressIgnored = false; | ||
527 | 342 | /* If the key is pressed, start up a timer to monitor if it's being held short | ||
528 | 343 | enough to qualify as just a "tap" or as a proper hold */ | ||
529 | 344 | m_superKeyHoldTimer.start(); | ||
530 | 345 | } else { | ||
531 | 346 | m_superKeyHoldTimer.stop(); | ||
532 | 347 | |||
533 | 348 | /* If the key is released, and was not being held, it means that the user just | ||
534 | 349 | performed a "tap". Unless we're told to ignore that tap, that is. */ | ||
535 | 350 | if (!m_superKeyHeld && !m_superPressIgnored) { | ||
536 | 351 | Q_EMIT superKeyTapped(); | ||
537 | 352 | } | ||
538 | 353 | /* Otherwise the user just terminated a hold. */ | ||
539 | 354 | else if(m_superKeyHeld){ | ||
540 | 355 | m_superKeyHeld = false; | ||
541 | 356 | Q_EMIT superKeyHeldChanged(m_superKeyHeld); | ||
542 | 357 | } | ||
543 | 358 | } | ||
544 | 359 | } | ||
545 | 360 | } | ||
546 | 361 | |||
547 | 362 | void | ||
548 | 363 | ShellDeclarativeView::ignoreSuperPress() | ||
549 | 364 | { | ||
550 | 365 | /* There was a key pressed, ignore current super tap/hold */ | ||
551 | 366 | m_superPressIgnored = true; | ||
552 | 367 | } | ||
553 | 368 | |||
554 | 369 | void | ||
555 | 370 | ShellDeclarativeView::forwardNumericHotkey() | ||
556 | 371 | { | ||
557 | 372 | Hotkey* hotkey = qobject_cast<Hotkey*>(sender()); | ||
558 | 373 | if (hotkey != NULL) { | ||
559 | 374 | /* Shortcuts from 1 to 9 should activate the items with index | ||
560 | 375 | from 1 to 9 (index 0 being the so-called "BFB" or Dash launcher). | ||
561 | 376 | Shortcut for 0 should activate item with index 10. | ||
562 | 377 | In other words, the indexes are activated in the same order as | ||
563 | 378 | the keys appear on a standard keyboard. */ | ||
564 | 379 | Qt::Key key = hotkey->key(); | ||
565 | 380 | if (key >= Qt::Key_1 && key <= Qt::Key_9) { | ||
566 | 381 | int index = key - Qt::Key_0; | ||
567 | 382 | if (hotkey->modifiers() & Qt::ShiftModifier) { | ||
568 | 383 | Q_EMIT newInstanceShortcutPressed(index); | ||
569 | 384 | } else { | ||
570 | 385 | Q_EMIT activateShortcutPressed(index); | ||
571 | 386 | } | ||
572 | 387 | } else if (key == Qt::Key_0) { | ||
573 | 388 | if (hotkey->modifiers() & Qt::ShiftModifier) { | ||
574 | 389 | Q_EMIT newInstanceShortcutPressed(10); | ||
575 | 390 | } else { | ||
576 | 391 | Q_EMIT activateShortcutPressed(10); | ||
577 | 392 | } | ||
599 | 393 | } | 275 | } |
600 | 394 | } | 276 | } |
601 | 395 | } | 277 | } |
602 | @@ -466,3 +348,26 @@ | |||
603 | 466 | { | 348 | { |
604 | 467 | return m_monitoredAreaContainsMouse; | 349 | return m_monitoredAreaContainsMouse; |
605 | 468 | } | 350 | } |
606 | 351 | |||
607 | 352 | void | ||
608 | 353 | ShellDeclarativeView::setIsTopLeftShell(bool ashell) | ||
609 | 354 | { | ||
610 | 355 | if (m_isTopLeftShell == ashell) { | ||
611 | 356 | return; | ||
612 | 357 | } | ||
613 | 358 | |||
614 | 359 | m_isTopLeftShell = ashell; | ||
615 | 360 | Q_EMIT isTopLeftShellChanged(m_isTopLeftShell); | ||
616 | 361 | } | ||
617 | 362 | |||
618 | 363 | void | ||
619 | 364 | ShellDeclarativeView::setScreenNumber(int screen) | ||
620 | 365 | { | ||
621 | 366 | m_screenInfo->setScreen(screen); | ||
622 | 367 | } | ||
623 | 368 | |||
624 | 369 | int | ||
625 | 370 | ShellDeclarativeView::screenNumber() const | ||
626 | 371 | { | ||
627 | 372 | return m_screenInfo->screen(); | ||
628 | 373 | } | ||
629 | 469 | 374 | ||
630 | === modified file 'shell/app/shelldeclarativeview.h' | |||
631 | --- shell/app/shelldeclarativeview.h 2012-02-13 23:46:04 +0000 | |||
632 | +++ shell/app/shelldeclarativeview.h 2012-02-16 08:16:20 +0000 | |||
633 | @@ -27,6 +27,7 @@ | |||
634 | 27 | class LauncherClient; | 27 | class LauncherClient; |
635 | 28 | class DashDBus; | 28 | class DashDBus; |
636 | 29 | class ScreenInfo; | 29 | class ScreenInfo; |
637 | 30 | class Hotkey; | ||
638 | 30 | 31 | ||
639 | 31 | class ShellDeclarativeView : public Unity2DDeclarativeView, public AbstractX11EventFilter | 32 | class ShellDeclarativeView : public Unity2DDeclarativeView, public AbstractX11EventFilter |
640 | 32 | { | 33 | { |
641 | @@ -38,7 +39,7 @@ | |||
642 | 38 | Q_PROPERTY(DashMode dashMode READ dashMode WRITE setDashMode NOTIFY dashModeChanged) | 39 | Q_PROPERTY(DashMode dashMode READ dashMode WRITE setDashMode NOTIFY dashModeChanged) |
643 | 39 | Q_PROPERTY(QString activeLens READ activeLens WRITE setActiveLens NOTIFY activeLensChanged) | 40 | Q_PROPERTY(QString activeLens READ activeLens WRITE setActiveLens NOTIFY activeLensChanged) |
644 | 40 | Q_PROPERTY(bool focus READ hasFocus NOTIFY focusChanged) // overridden to add notify | 41 | Q_PROPERTY(bool focus READ hasFocus NOTIFY focusChanged) // overridden to add notify |
646 | 41 | Q_PROPERTY(bool superKeyHeld READ superKeyHeld NOTIFY superKeyHeldChanged) | 42 | Q_PROPERTY(bool isTopLeftShell READ isTopLeftShell WRITE setIsTopLeftShell NOTIFY isTopLeftShellChanged) |
647 | 42 | Q_PROPERTY(bool haveCustomHomeShortcuts READ haveCustomHomeShortcuts) | 43 | Q_PROPERTY(bool haveCustomHomeShortcuts READ haveCustomHomeShortcuts) |
648 | 43 | 44 | ||
649 | 44 | /* These two properties and mouse movement tracking on the widget are added here only because | 45 | /* These two properties and mouse movement tracking on the widget are added here only because |
650 | @@ -56,7 +57,7 @@ | |||
651 | 56 | DesktopMode, | 57 | DesktopMode, |
652 | 57 | FullScreenMode | 58 | FullScreenMode |
653 | 58 | }; | 59 | }; |
655 | 59 | explicit ShellDeclarativeView(); | 60 | explicit ShellDeclarativeView(const QUrl &sourceFileUrl = QUrl(), bool isTopLeftShell = false, int screen = 0); |
656 | 60 | 61 | ||
657 | 61 | /* getters */ | 62 | /* getters */ |
658 | 62 | bool dashActive() const; | 63 | bool dashActive() const; |
659 | @@ -64,19 +65,28 @@ | |||
660 | 64 | DashMode dashMode() const; | 65 | DashMode dashMode() const; |
661 | 65 | const QString& activeLens() const; | 66 | const QString& activeLens() const; |
662 | 66 | bool expanded() const; | 67 | bool expanded() const; |
663 | 67 | bool superKeyHeld() const { return m_superKeyHeld; } | ||
664 | 68 | QRect monitoredArea() const; | 68 | QRect monitoredArea() const; |
665 | 69 | bool monitoredAreaContainsMouse() const; | 69 | bool monitoredAreaContainsMouse() const; |
666 | 70 | bool isTopLeftShell() const { return m_isTopLeftShell; } | ||
667 | 70 | 71 | ||
668 | 71 | /* setters */ | 72 | /* setters */ |
669 | 72 | Q_SLOT void setDashActive(bool active); | 73 | Q_SLOT void setDashActive(bool active); |
670 | 73 | Q_INVOKABLE void setDashMode(DashMode); | 74 | Q_INVOKABLE void setDashMode(DashMode); |
671 | 74 | Q_INVOKABLE void setActiveLens(const QString& activeLens); | 75 | Q_INVOKABLE void setActiveLens(const QString& activeLens); |
672 | 75 | Q_INVOKABLE void setExpanded(bool); | 76 | Q_INVOKABLE void setExpanded(bool); |
673 | 77 | void setScreenNumber(int); | ||
674 | 78 | int screenNumber() const; | ||
675 | 76 | void setMonitoredArea(QRect monitoredArea); | 79 | void setMonitoredArea(QRect monitoredArea); |
676 | 80 | void setIsTopLeftShell(bool); | ||
677 | 77 | 81 | ||
678 | 78 | virtual bool x11EventFilter(XEvent* event); | 82 | virtual bool x11EventFilter(XEvent* event); |
679 | 79 | 83 | ||
680 | 84 | void toggleDash(); | ||
681 | 85 | void toggleLauncher(); | ||
682 | 86 | void showCommandsLens(); | ||
683 | 87 | |||
684 | 88 | void processNumericHotkey(Hotkey*); | ||
685 | 89 | |||
686 | 80 | Q_SIGNALS: | 90 | Q_SIGNALS: |
687 | 81 | void dashActiveChanged(bool); | 91 | void dashActiveChanged(bool); |
688 | 82 | void dashModeChanged(DashMode); | 92 | void dashModeChanged(DashMode); |
689 | @@ -89,22 +99,10 @@ | |||
690 | 89 | void monitoredAreaContainsMouseChanged(); | 99 | void monitoredAreaContainsMouseChanged(); |
691 | 90 | 100 | ||
692 | 91 | void addWebFavoriteRequested(const QUrl& url); | 101 | void addWebFavoriteRequested(const QUrl& url); |
693 | 92 | void superKeyHeldChanged(bool superKeyHeld); | ||
694 | 93 | void superKeyTapped(); | ||
695 | 94 | void activateShortcutPressed(int itemIndex); | 102 | void activateShortcutPressed(int itemIndex); |
696 | 95 | void newInstanceShortcutPressed(int itemIndex); | 103 | void newInstanceShortcutPressed(int itemIndex); |
697 | 96 | void launcherFocusRequested(); | 104 | void launcherFocusRequested(); |
709 | 97 | 105 | void isTopLeftShellChanged(bool); | |
699 | 98 | private Q_SLOTS: | ||
700 | 99 | void updateSuperKeyMonitoring(); | ||
701 | 100 | void updateSuperKeyHoldState(); | ||
702 | 101 | void setHotkeysForModifiers(Qt::KeyboardModifiers modifiers); | ||
703 | 102 | void forwardNumericHotkey(); | ||
704 | 103 | void ignoreSuperPress(); | ||
705 | 104 | |||
706 | 105 | void toggleDash(); | ||
707 | 106 | void showCommandsLens(); | ||
708 | 107 | void onAltF1Pressed(); | ||
710 | 108 | 106 | ||
711 | 109 | protected: | 107 | protected: |
712 | 110 | virtual void showEvent(QShowEvent *event); | 108 | virtual void showEvent(QShowEvent *event); |
713 | @@ -126,12 +124,10 @@ | |||
714 | 126 | QString m_activeLens; /* Lens id of the active lens */ | 124 | QString m_activeLens; /* Lens id of the active lens */ |
715 | 127 | bool m_active; | 125 | bool m_active; |
716 | 128 | 126 | ||
717 | 129 | bool m_superKeyPressed; | ||
718 | 130 | bool m_superKeyHeld; | ||
719 | 131 | bool m_superPressIgnored; | ||
720 | 132 | QTimer m_superKeyHoldTimer; | ||
721 | 133 | QRect m_monitoredArea; | 127 | QRect m_monitoredArea; |
722 | 134 | bool m_monitoredAreaContainsMouse; | 128 | bool m_monitoredAreaContainsMouse; |
723 | 129 | bool m_isTopLeftShell; | ||
724 | 130 | QUrl m_sourceFileUrl; | ||
725 | 135 | 131 | ||
726 | 136 | friend class DashDBus; | 132 | friend class DashDBus; |
727 | 137 | friend class LauncherDBus; | 133 | friend class LauncherDBus; |
728 | 138 | 134 | ||
729 | === added file 'shell/app/shellmanager.cpp' | |||
730 | --- shell/app/shellmanager.cpp 1970-01-01 00:00:00 +0000 | |||
731 | +++ shell/app/shellmanager.cpp 2012-02-16 08:16:20 +0000 | |||
732 | @@ -0,0 +1,380 @@ | |||
733 | 1 | /* | ||
734 | 2 | * This file is part of unity-2d | ||
735 | 3 | * | ||
736 | 4 | * Copyright 2010 Canonical Ltd. | ||
737 | 5 | * | ||
738 | 6 | * This program is free software; you can redistribute it and/or modify | ||
739 | 7 | * it under the terms of the GNU General Public License as published by | ||
740 | 8 | * the Free Software Foundation; version 3. | ||
741 | 9 | * | ||
742 | 10 | * This program is distributed in the hope that it will be useful, | ||
743 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
744 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
745 | 13 | * GNU General Public License for more details. | ||
746 | 14 | * | ||
747 | 15 | * You should have received a copy of the GNU General Public License | ||
748 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/> | ||
749 | 17 | */ | ||
750 | 18 | |||
751 | 19 | #include "shellmanager.h" | ||
752 | 20 | |||
753 | 21 | // Qt | ||
754 | 22 | #include <QApplication> | ||
755 | 23 | #include <QDebug> | ||
756 | 24 | #include <QtDeclarative> | ||
757 | 25 | #include <QDeclarativeEngine> | ||
758 | 26 | #include <QDeclarativeView> | ||
759 | 27 | #include <QDesktopWidget> | ||
760 | 28 | #include <QDBusConnection> | ||
761 | 29 | #include <QDBusConnectionInterface> | ||
762 | 30 | #include <QDeclarativeContext> | ||
763 | 31 | #include <QAbstractEventDispatcher> | ||
764 | 32 | |||
765 | 33 | // libunity-2d-private | ||
766 | 34 | #include <hotkeymonitor.h> | ||
767 | 35 | #include <hotkey.h> | ||
768 | 36 | #include <keyboardmodifiersmonitor.h> | ||
769 | 37 | #include <keymonitor.h> | ||
770 | 38 | #include <screeninfo.h> | ||
771 | 39 | |||
772 | 40 | // Local | ||
773 | 41 | #include "shelldeclarativeview.h" | ||
774 | 42 | #include "dashclient.h" | ||
775 | 43 | #include "dashdbus.h" | ||
776 | 44 | #include "gesturehandler.h" | ||
777 | 45 | #include "launcherdbus.h" | ||
778 | 46 | #include "config.h" | ||
779 | 47 | |||
780 | 48 | // unity-2d | ||
781 | 49 | #include <unity2ddebug.h> | ||
782 | 50 | #include <unity2dapplication.h> | ||
783 | 51 | |||
784 | 52 | // X11 | ||
785 | 53 | #include <X11/Xlib.h> | ||
786 | 54 | |||
787 | 55 | static const int KEY_HOLD_THRESHOLD = 250; | ||
788 | 56 | |||
789 | 57 | struct ShellManagerPrivate | ||
790 | 58 | { | ||
791 | 59 | ShellManagerPrivate() | ||
792 | 60 | : q(0) | ||
793 | 61 | , m_dashDBus(0) | ||
794 | 62 | , m_launcherDBus(0) | ||
795 | 63 | , m_superKeyPressed(false) | ||
796 | 64 | , m_superKeyHeld(false) | ||
797 | 65 | {} | ||
798 | 66 | |||
799 | 67 | ShellDeclarativeView* initShell(bool isTopLeft, int screen); | ||
800 | 68 | void updateScreenCount(int newCount); | ||
801 | 69 | ShellDeclarativeView* activeShell() const; | ||
802 | 70 | |||
803 | 71 | ShellManager *q; | ||
804 | 72 | QList<ShellDeclarativeView *> m_viewList; | ||
805 | 73 | DashDBus * m_dashDBus; | ||
806 | 74 | LauncherDBus* m_launcherDBus; | ||
807 | 75 | QUrl m_sourceFileUrl; | ||
808 | 76 | |||
809 | 77 | bool m_superKeyPressed; | ||
810 | 78 | bool m_superKeyHeld; | ||
811 | 79 | bool m_superPressIgnored; | ||
812 | 80 | QTimer m_superKeyHoldTimer; | ||
813 | 81 | }; | ||
814 | 82 | |||
815 | 83 | |||
816 | 84 | ShellDeclarativeView * | ||
817 | 85 | ShellManagerPrivate::initShell(bool isTopLeft, int screen) | ||
818 | 86 | { | ||
819 | 87 | const QStringList arguments = qApp->arguments(); | ||
820 | 88 | ShellDeclarativeView * view = new ShellDeclarativeView(m_sourceFileUrl, isTopLeft, screen); | ||
821 | 89 | view->setAccessibleName("Shell"); | ||
822 | 90 | if (arguments.contains("-opengl")) { | ||
823 | 91 | view->setUseOpenGL(true); | ||
824 | 92 | } | ||
825 | 93 | |||
826 | 94 | Unity2dApplication::instance()->installX11EventFilter(view); | ||
827 | 95 | |||
828 | 96 | view->engine()->addImportPath(unity2dImportPath()); | ||
829 | 97 | view->engine()->setBaseUrl(QUrl::fromLocalFile(unity2dDirectory() + "/shell/")); | ||
830 | 98 | |||
831 | 99 | /* Load the QML UI, focus and show the window */ | ||
832 | 100 | view->setResizeMode(QDeclarativeView::SizeViewToRootObject); | ||
833 | 101 | view->rootContext()->setContextProperty("declarativeView", view); | ||
834 | 102 | view->rootContext()->setContextProperty("shellManager", q); | ||
835 | 103 | // WARNING This declaration of dashClient used to be in Unity2d/plugin.cpp | ||
836 | 104 | // but it lead to locks when both the shell and the spread were started | ||
837 | 105 | // at the same time since SpreadMonitor QDBusServiceWatcher::serviceRegistered | ||
838 | 106 | // and DashClient QDBusServiceWatcher::serviceRegistered | ||
839 | 107 | // triggered at the same time ending up with both creating QDBusInterface | ||
840 | 108 | // to eachother in the main thread meaning they would block | ||
841 | 109 | // In case you need to have a DashClient in the spread the fix for the problem | ||
842 | 110 | // is moving the QDbusInterface creation to a thread so it does not block | ||
843 | 111 | // the main thread | ||
844 | 112 | view->rootContext()->setContextProperty("dashClient", DashClient::instance()); | ||
845 | 113 | |||
846 | 114 | if (!m_dashDBus) { | ||
847 | 115 | m_dashDBus = new DashDBus(view); | ||
848 | 116 | if (!m_dashDBus->connectToBus()) { | ||
849 | 117 | qCritical() << "Another instance of the Dash already exists. Quitting."; | ||
850 | 118 | return 0; | ||
851 | 119 | } | ||
852 | 120 | } | ||
853 | 121 | |||
854 | 122 | if (!m_launcherDBus) { | ||
855 | 123 | m_launcherDBus = new LauncherDBus(view); | ||
856 | 124 | m_launcherDBus->connectToBus(); | ||
857 | 125 | } | ||
858 | 126 | |||
859 | 127 | view->show(); | ||
860 | 128 | |||
861 | 129 | return view; | ||
862 | 130 | } | ||
863 | 131 | |||
864 | 132 | ShellDeclarativeView * | ||
865 | 133 | ShellManagerPrivate::activeShell() const | ||
866 | 134 | { | ||
867 | 135 | int cursorScreen = ScreenInfo::cursorScreen(); | ||
868 | 136 | Q_FOREACH(ShellDeclarativeView * shell, m_viewList) { | ||
869 | 137 | if (shell->screenNumber() == cursorScreen) { | ||
870 | 138 | return shell; | ||
871 | 139 | } | ||
872 | 140 | } | ||
873 | 141 | return 0; | ||
874 | 142 | } | ||
875 | 143 | |||
876 | 144 | void | ||
877 | 145 | ShellManagerPrivate::updateScreenCount(int newCount) | ||
878 | 146 | { | ||
879 | 147 | if (newCount > 0) { | ||
880 | 148 | QDesktopWidget* desktop = QApplication::desktop(); | ||
881 | 149 | int size = m_viewList.size(); | ||
882 | 150 | ShellDeclarativeView* shell = 0; | ||
883 | 151 | |||
884 | 152 | /* The first shell is always the one on the leftmost screen. */ | ||
885 | 153 | QPoint p; | ||
886 | 154 | if (QApplication::isRightToLeft()) { | ||
887 | 155 | p = QPoint(desktop->width() - 1, 0); | ||
888 | 156 | } | ||
889 | 157 | int leftmost = desktop->screenNumber(p); | ||
890 | 158 | if (size > 0) { | ||
891 | 159 | shell = m_viewList[0]; | ||
892 | 160 | } else { | ||
893 | 161 | shell = initShell(true, leftmost); | ||
894 | 162 | m_viewList.append(shell); | ||
895 | 163 | } | ||
896 | 164 | shell->setScreenNumber(leftmost); | ||
897 | 165 | |||
898 | 166 | /* Update the position of other existing Shells, and instantiate new | ||
899 | 167 | Shells as needed. */ | ||
900 | 168 | int i = 1; | ||
901 | 169 | for (int screen = 0; screen < newCount; ++screen) { | ||
902 | 170 | if (screen == leftmost) { | ||
903 | 171 | continue; | ||
904 | 172 | } | ||
905 | 173 | if (i < size) { | ||
906 | 174 | shell = m_viewList[i]; | ||
907 | 175 | } else { | ||
908 | 176 | shell = initShell(false, screen); | ||
909 | 177 | m_viewList.append(shell); | ||
910 | 178 | } | ||
911 | 179 | shell->setIsTopLeftShell(false); | ||
912 | 180 | shell->setScreenNumber(screen); | ||
913 | 181 | ++i; | ||
914 | 182 | } | ||
915 | 183 | } | ||
916 | 184 | /* Remove extra Shells if any. */ | ||
917 | 185 | while (m_viewList.size() > newCount) { | ||
918 | 186 | m_viewList.takeLast()->deleteLater(); | ||
919 | 187 | } | ||
920 | 188 | } | ||
921 | 189 | |||
922 | 190 | /* -------------------------- ShellManager -----------------------------*/ | ||
923 | 191 | |||
924 | 192 | ShellManager::ShellManager(const QUrl &sourceFileUrl, QObject* parent) : | ||
925 | 193 | QObject(parent) | ||
926 | 194 | ,d(new ShellManagerPrivate) | ||
927 | 195 | { | ||
928 | 196 | d->q = this; | ||
929 | 197 | d->m_sourceFileUrl = sourceFileUrl; | ||
930 | 198 | |||
931 | 199 | qmlRegisterType<ShellDeclarativeView>("Unity2d", 1, 0, "ShellDeclarativeView"); | ||
932 | 200 | |||
933 | 201 | QDesktopWidget* desktop = QApplication::desktop(); | ||
934 | 202 | |||
935 | 203 | d->updateScreenCount(desktop->screenCount()); | ||
936 | 204 | |||
937 | 205 | connect(desktop, SIGNAL(screenCountChanged(int)), SLOT(onScreenCountChanged(int))); | ||
938 | 206 | |||
939 | 207 | d->m_superKeyHoldTimer.setSingleShot(true); | ||
940 | 208 | d->m_superKeyHoldTimer.setInterval(KEY_HOLD_THRESHOLD); | ||
941 | 209 | connect(&d->m_superKeyHoldTimer, SIGNAL(timeout()), SLOT(updateSuperKeyHoldState())); | ||
942 | 210 | |||
943 | 211 | connect(&launcher2dConfiguration(), SIGNAL(superKeyEnableChanged(bool)), SLOT(updateSuperKeyMonitoring())); | ||
944 | 212 | updateSuperKeyMonitoring(); | ||
945 | 213 | |||
946 | 214 | /* Alt+F1 reveal the launcher and gives the keyboard focus to the Dash Button. */ | ||
947 | 215 | Hotkey* altF1 = HotkeyMonitor::instance().getHotkeyFor(Qt::Key_F1, Qt::AltModifier); | ||
948 | 216 | connect(altF1, SIGNAL(pressed()), SLOT(onAltF1Pressed())); | ||
949 | 217 | |||
950 | 218 | /* Alt+F2 shows the dash with the commands lens activated. */ | ||
951 | 219 | Hotkey* altF2 = HotkeyMonitor::instance().getHotkeyFor(Qt::Key_F2, Qt::AltModifier); | ||
952 | 220 | connect(altF2, SIGNAL(pressed()), SLOT(onAltF2Pressed())); | ||
953 | 221 | |||
954 | 222 | /* Super+{n} for 0 ≤ n ≤ 9 activates the item with index (n + 9) % 10. */ | ||
955 | 223 | for (Qt::Key key = Qt::Key_0; key <= Qt::Key_9; key = (Qt::Key) (key + 1)) { | ||
956 | 224 | Hotkey* hotkey = HotkeyMonitor::instance().getHotkeyFor(key, Qt::MetaModifier); | ||
957 | 225 | connect(hotkey, SIGNAL(pressed()), SLOT(onNumericHotkeyPressed())); | ||
958 | 226 | hotkey = HotkeyMonitor::instance().getHotkeyFor(key, Qt::MetaModifier | Qt::ShiftModifier); | ||
959 | 227 | connect(hotkey, SIGNAL(pressed()), SLOT(onNumericHotkeyPressed())); | ||
960 | 228 | } | ||
961 | 229 | } | ||
962 | 230 | |||
963 | 231 | ShellManager::~ShellManager() | ||
964 | 232 | { | ||
965 | 233 | qDeleteAll(d->m_viewList); | ||
966 | 234 | delete d; | ||
967 | 235 | } | ||
968 | 236 | |||
969 | 237 | void | ||
970 | 238 | ShellManager::onScreenCountChanged(int newCount) | ||
971 | 239 | { | ||
972 | 240 | d->updateScreenCount(newCount); | ||
973 | 241 | } | ||
974 | 242 | |||
975 | 243 | /* ----------------- super key handling ---------------- */ | ||
976 | 244 | |||
977 | 245 | void | ||
978 | 246 | ShellManager::updateSuperKeyHoldState() | ||
979 | 247 | { | ||
980 | 248 | /* If the key was released in the meantime, just do nothing, otherwise | ||
981 | 249 | consider the key being held, unless we're told to ignore it. */ | ||
982 | 250 | if (d->m_superKeyPressed && !d->m_superPressIgnored) { | ||
983 | 251 | d->m_superKeyHeld = true; | ||
984 | 252 | Q_EMIT superKeyHeldChanged(d->m_superKeyHeld); | ||
985 | 253 | } | ||
986 | 254 | } | ||
987 | 255 | |||
988 | 256 | void | ||
989 | 257 | ShellManager::updateSuperKeyMonitoring() | ||
990 | 258 | { | ||
991 | 259 | KeyboardModifiersMonitor *modifiersMonitor = KeyboardModifiersMonitor::instance(); | ||
992 | 260 | KeyMonitor *keyMonitor = KeyMonitor::instance(); | ||
993 | 261 | HotkeyMonitor& hotkeyMonitor = HotkeyMonitor::instance(); | ||
994 | 262 | |||
995 | 263 | QVariant value = launcher2dConfiguration().property("superKeyEnable"); | ||
996 | 264 | if (!value.isValid() || value.toBool() == true) { | ||
997 | 265 | hotkeyMonitor.enableModifiers(Qt::MetaModifier); | ||
998 | 266 | QObject::connect(modifiersMonitor, | ||
999 | 267 | SIGNAL(keyboardModifiersChanged(Qt::KeyboardModifiers)), | ||
1000 | 268 | this, SLOT(setHotkeysForModifiers(Qt::KeyboardModifiers))); | ||
1001 | 269 | /* Ignore Super presses if another key was pressed simultaneously | ||
1002 | 270 | (i.e. a shortcut). https://bugs.launchpad.net/unity-2d/+bug/801073 */ | ||
1003 | 271 | QObject::connect(keyMonitor, | ||
1004 | 272 | SIGNAL(keyPressed()), | ||
1005 | 273 | this, SLOT(ignoreSuperPress())); | ||
1006 | 274 | setHotkeysForModifiers(modifiersMonitor->keyboardModifiers()); | ||
1007 | 275 | } else { | ||
1008 | 276 | hotkeyMonitor.disableModifiers(Qt::MetaModifier); | ||
1009 | 277 | QObject::disconnect(modifiersMonitor, | ||
1010 | 278 | SIGNAL(keyboardModifiersChanged(Qt::KeyboardModifiers)), | ||
1011 | 279 | this, SLOT(setHotkeysForModifiers(Qt::KeyboardModifiers))); | ||
1012 | 280 | QObject::disconnect(keyMonitor, | ||
1013 | 281 | SIGNAL(keyPressed()), | ||
1014 | 282 | this, SLOT(ignoreSuperPress())); | ||
1015 | 283 | d->m_superKeyHoldTimer.stop(); | ||
1016 | 284 | d->m_superKeyPressed = false; | ||
1017 | 285 | if (d->m_superKeyHeld) { | ||
1018 | 286 | d->m_superKeyHeld = false; | ||
1019 | 287 | Q_EMIT superKeyHeldChanged(false); | ||
1020 | 288 | } | ||
1021 | 289 | } | ||
1022 | 290 | } | ||
1023 | 291 | |||
1024 | 292 | void | ||
1025 | 293 | ShellManager::setHotkeysForModifiers(Qt::KeyboardModifiers modifiers) | ||
1026 | 294 | { | ||
1027 | 295 | /* This is the new new state of the Super key (AKA Meta key), while | ||
1028 | 296 | d->m_superKeyPressed is the previous state of the key at the last modifiers change. */ | ||
1029 | 297 | bool superKeyPressed = modifiers.testFlag(Qt::MetaModifier); | ||
1030 | 298 | |||
1031 | 299 | if (d->m_superKeyPressed != superKeyPressed) { | ||
1032 | 300 | d->m_superKeyPressed = superKeyPressed; | ||
1033 | 301 | if (superKeyPressed) { | ||
1034 | 302 | d->m_superPressIgnored = false; | ||
1035 | 303 | /* If the key is pressed, start up a timer to monitor if it's being held short | ||
1036 | 304 | enough to qualify as just a "tap" or as a proper hold */ | ||
1037 | 305 | d->m_superKeyHoldTimer.start(); | ||
1038 | 306 | } else { | ||
1039 | 307 | d->m_superKeyHoldTimer.stop(); | ||
1040 | 308 | |||
1041 | 309 | /* If the key is released, and was not being held, it means that the user just | ||
1042 | 310 | performed a "tap". Unless we're told to ignore that tap, that is. */ | ||
1043 | 311 | if (!d->m_superKeyHeld && !d->m_superPressIgnored) { | ||
1044 | 312 | onSuperKeyTapped(); | ||
1045 | 313 | } | ||
1046 | 314 | /* Otherwise the user just terminated a hold. */ | ||
1047 | 315 | else if(d->m_superKeyHeld){ | ||
1048 | 316 | d->m_superKeyHeld = false; | ||
1049 | 317 | Q_EMIT superKeyHeldChanged(d->m_superKeyHeld); | ||
1050 | 318 | } | ||
1051 | 319 | } | ||
1052 | 320 | } | ||
1053 | 321 | } | ||
1054 | 322 | |||
1055 | 323 | void | ||
1056 | 324 | ShellManager::ignoreSuperPress() | ||
1057 | 325 | { | ||
1058 | 326 | /* There was a key pressed, ignore current super tap/hold */ | ||
1059 | 327 | d->m_superPressIgnored = true; | ||
1060 | 328 | } | ||
1061 | 329 | |||
1062 | 330 | void | ||
1063 | 331 | ShellManager::onSuperKeyTapped() | ||
1064 | 332 | { | ||
1065 | 333 | // TODO : In future, All shells should be able to handle the Dash | ||
1066 | 334 | // Note: Always, first item in the list is the topLeft shell | ||
1067 | 335 | // In any case, just iterate through the list | ||
1068 | 336 | Q_FOREACH(ShellDeclarativeView *shell, d->m_viewList) { | ||
1069 | 337 | if (shell->isTopLeftShell()) { | ||
1070 | 338 | shell->toggleDash(); | ||
1071 | 339 | break; | ||
1072 | 340 | } | ||
1073 | 341 | } | ||
1074 | 342 | } | ||
1075 | 343 | |||
1076 | 344 | bool | ||
1077 | 345 | ShellManager::superKeyHeld() const | ||
1078 | 346 | { | ||
1079 | 347 | return d->m_superKeyHeld; | ||
1080 | 348 | } | ||
1081 | 349 | |||
1082 | 350 | /*------------------ Hotkeys Handling -----------------------*/ | ||
1083 | 351 | |||
1084 | 352 | void | ||
1085 | 353 | ShellManager::onAltF1Pressed() | ||
1086 | 354 | { | ||
1087 | 355 | ShellDeclarativeView * activeShell = d->activeShell(); | ||
1088 | 356 | if (activeShell) { | ||
1089 | 357 | activeShell->toggleLauncher(); | ||
1090 | 358 | } | ||
1091 | 359 | } | ||
1092 | 360 | |||
1093 | 361 | void | ||
1094 | 362 | ShellManager::onAltF2Pressed() | ||
1095 | 363 | { | ||
1096 | 364 | ShellDeclarativeView * activeShell = d->activeShell(); | ||
1097 | 365 | if (activeShell) { | ||
1098 | 366 | activeShell->showCommandsLens(); | ||
1099 | 367 | } | ||
1100 | 368 | } | ||
1101 | 369 | |||
1102 | 370 | void | ||
1103 | 371 | ShellManager::onNumericHotkeyPressed() | ||
1104 | 372 | { | ||
1105 | 373 | Hotkey* hotkey = qobject_cast<Hotkey*>(sender()); | ||
1106 | 374 | if (hotkey) { | ||
1107 | 375 | ShellDeclarativeView * activeShell = d->activeShell(); | ||
1108 | 376 | if (activeShell) { | ||
1109 | 377 | activeShell->processNumericHotkey(hotkey); | ||
1110 | 378 | } | ||
1111 | 379 | } | ||
1112 | 380 | } | ||
1113 | 0 | 381 | ||
1114 | === added file 'shell/app/shellmanager.h' | |||
1115 | --- shell/app/shellmanager.h 1970-01-01 00:00:00 +0000 | |||
1116 | +++ shell/app/shellmanager.h 2012-02-16 08:16:20 +0000 | |||
1117 | @@ -0,0 +1,58 @@ | |||
1118 | 1 | /* | ||
1119 | 2 | * This file is part of unity-2d | ||
1120 | 3 | * | ||
1121 | 4 | * Copyright 2010 Canonical Ltd. | ||
1122 | 5 | * | ||
1123 | 6 | * This program is free software; you can redistribute it and/or modify | ||
1124 | 7 | * it under the terms of the GNU General Public License as published by | ||
1125 | 8 | * the Free Software Foundation; version 3. | ||
1126 | 9 | * | ||
1127 | 10 | * This program is distributed in the hope that it will be useful, | ||
1128 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1129 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1130 | 13 | * GNU General Public License for more details. | ||
1131 | 14 | * | ||
1132 | 15 | * You should have received a copy of the GNU General Public License | ||
1133 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/> | ||
1134 | 17 | */ | ||
1135 | 18 | #ifndef SHELLMANAGER_H | ||
1136 | 19 | #define SHELLMANAGER_H | ||
1137 | 20 | |||
1138 | 21 | #include <QObject> | ||
1139 | 22 | struct ShellManagerPrivate; | ||
1140 | 23 | |||
1141 | 24 | class QUrl; | ||
1142 | 25 | |||
1143 | 26 | class ShellManager : public QObject | ||
1144 | 27 | { | ||
1145 | 28 | Q_OBJECT | ||
1146 | 29 | Q_PROPERTY(bool superKeyHeld READ superKeyHeld NOTIFY superKeyHeldChanged) | ||
1147 | 30 | |||
1148 | 31 | public: | ||
1149 | 32 | ShellManager(const QUrl &sourceFileUrl, QObject* parent = 0); | ||
1150 | 33 | ~ShellManager(); | ||
1151 | 34 | |||
1152 | 35 | bool superKeyHeld() const; | ||
1153 | 36 | |||
1154 | 37 | Q_SIGNALS: | ||
1155 | 38 | void superKeyHeldChanged(bool superKeyHeld); | ||
1156 | 39 | |||
1157 | 40 | private Q_SLOTS: | ||
1158 | 41 | void onScreenCountChanged(int); | ||
1159 | 42 | |||
1160 | 43 | void updateSuperKeyMonitoring(); | ||
1161 | 44 | void updateSuperKeyHoldState(); | ||
1162 | 45 | void setHotkeysForModifiers(Qt::KeyboardModifiers modifiers); | ||
1163 | 46 | void ignoreSuperPress(); | ||
1164 | 47 | void onSuperKeyTapped(); | ||
1165 | 48 | |||
1166 | 49 | void onAltF1Pressed(); | ||
1167 | 50 | void onAltF2Pressed(); | ||
1168 | 51 | void onNumericHotkeyPressed(); | ||
1169 | 52 | |||
1170 | 53 | private: | ||
1171 | 54 | Q_DISABLE_COPY(ShellManager) | ||
1172 | 55 | ShellManagerPrivate * const d; | ||
1173 | 56 | }; | ||
1174 | 57 | |||
1175 | 58 | #endif // SHELLMANAGER_H | ||
1176 | 0 | 59 | ||
1177 | === modified file 'shell/launcher/LauncherList.qml' | |||
1178 | --- shell/launcher/LauncherList.qml 2012-02-09 11:59:16 +0000 | |||
1179 | +++ shell/launcher/LauncherList.qml 2012-02-16 08:16:20 +0000 | |||
1180 | @@ -93,7 +93,7 @@ | |||
1181 | 93 | } | 93 | } |
1182 | 94 | 94 | ||
1183 | 95 | function updatePips() { | 95 | function updatePips() { |
1185 | 96 | if (item.belongsToDifferentWorkspace()) { | 96 | if (item.belongsToDifferentWorkspace() || item.belongsToDifferentScreen(declarativeView.screen.screen)) { |
1186 | 97 | launcherItem.pips = 1 | 97 | launcherItem.pips = 1 |
1187 | 98 | launcherItem.pipSource = "launcher/artwork/launcher_arrow_outline_ltr.png"; | 98 | launcherItem.pipSource = "launcher/artwork/launcher_arrow_outline_ltr.png"; |
1188 | 99 | } else { | 99 | } else { |
1189 | @@ -125,7 +125,7 @@ | |||
1190 | 125 | emblemVisible: item.emblemVisible | 125 | emblemVisible: item.emblemVisible |
1191 | 126 | 126 | ||
1192 | 127 | /* Launcher of index 0 is the so-called BFB or Dash launcher */ | 127 | /* Launcher of index 0 is the so-called BFB or Dash launcher */ |
1194 | 128 | shortcutVisible: declarativeView.superKeyHeld && | 128 | shortcutVisible: shellManager.superKeyHeld && |
1195 | 129 | ((item.toString().indexOf("LauncherApplication") == 0 && index > 0 && index <= 10) || | 129 | ((item.toString().indexOf("LauncherApplication") == 0 && index > 0 && index <= 10) || |
1196 | 130 | item.shortcutKey != 0) | 130 | item.shortcutKey != 0) |
1197 | 131 | shortcutText: { | 131 | shortcutText: { |
1198 | @@ -310,6 +310,7 @@ | |||
1199 | 310 | width, height, xid) | 310 | width, height, xid) |
1200 | 311 | onWindowCountChanged: updatePips() | 311 | onWindowCountChanged: updatePips() |
1201 | 312 | onWindowWorkspaceChanged: updatePips() | 312 | onWindowWorkspaceChanged: updatePips() |
1202 | 313 | onWindowGeometryChanged: updatePips() | ||
1203 | 313 | /* Not all items are applications. */ | 314 | /* Not all items are applications. */ |
1204 | 314 | ignoreUnknownSignals: true | 315 | ignoreUnknownSignals: true |
1205 | 315 | } | 316 | } |
1206 | 316 | 317 | ||
1207 | === modified file 'shell/launcher/LauncherLoader.qml' | |||
1208 | --- shell/launcher/LauncherLoader.qml 2012-02-10 11:17:36 +0000 | |||
1209 | +++ shell/launcher/LauncherLoader.qml 2012-02-16 08:16:20 +0000 | |||
1210 | @@ -70,7 +70,7 @@ | |||
1211 | 70 | } | 70 | } |
1212 | 71 | 71 | ||
1213 | 72 | Connections { | 72 | Connections { |
1215 | 73 | target: declarativeView | 73 | target: shellManager |
1216 | 74 | onSuperKeyHeldChanged: { | 74 | onSuperKeyHeldChanged: { |
1217 | 75 | if (superKeyHeld) visibilityController.beginForceVisible() | 75 | if (superKeyHeld) visibilityController.beginForceVisible() |
1218 | 76 | else visibilityController.endForceVisible() | 76 | else visibilityController.endForceVisible() |