Merge lp:~fboucault/unity-2d/no_dash_when_spread_shown into lp:unity-2d
- no_dash_when_spread_shown
- Merge into trunk
Proposed by
Florian Boucault
Status: | Superseded |
---|---|
Proposed branch: | lp:~fboucault/unity-2d/no_dash_when_spread_shown |
Merge into: | lp:unity-2d |
Diff against target: |
10395 lines (+3863/-3645) 141 files modified
.bzrignore (+7/-12) CMakeLists.txt (+2/-2) README (+8/-9) debian/control (+36/-26) debian/manpages/unity-2d-launcher.1 (+0/-12) debian/manpages/unity-2d-places.1 (+0/-12) debian/manpages/unity-2d-shell.1 (+17/-0) debian/unity-2d-launcher.install.in (+0/-5) debian/unity-2d-launcher.manpages (+0/-1) debian/unity-2d-places.install.in (+0/-6) debian/unity-2d-places.manpages (+0/-1) debian/unity-2d-shell.install.in (+9/-0) debian/unity-2d-shell.manpages (+1/-0) launcher/CMakeLists.txt (+0/-20) launcher/app/CMakeLists.txt (+0/-70) launcher/app/launcher.cpp (+0/-137) launcher/app/launcherview.cpp (+0/-299) launcher/app/launcherview.h (+0/-79) launcher/app/unity-2d-launcher.desktop (+0/-13) launcher/app/visibilitycontroller.cpp (+0/-163) launcher/app/visibilitycontroller.h (+0/-93) launcher/launcher.qmlproject (+0/-18) launcher/tests/CMakeLists.txt (+0/-29) launcher/tests/launcherviewtest.cpp (+0/-42) libunity-2d-private/CMakeLists.txt (+1/-0) libunity-2d-private/Unity2d/CMakeLists.txt (+0/-2) libunity-2d-private/Unity2d/plugin.cpp (+26/-10) libunity-2d-private/Unity2d/qmldir (+0/-1) libunity-2d-private/src/CMakeLists.txt (+10/-6) libunity-2d-private/src/abstractdbusservicemonitor.cpp (+86/-0) libunity-2d-private/src/abstractdbusservicemonitor.h (+59/-0) libunity-2d-private/src/abstractvisibilitybehavior.cpp (+0/-59) libunity-2d-private/src/abstractvisibilitybehavior.h (+0/-63) libunity-2d-private/src/autohidebehavior.cpp (+0/-143) libunity-2d-private/src/autohidebehavior.h (+0/-69) libunity-2d-private/src/bfb.cpp (+39/-14) libunity-2d-private/src/bfb.h (+9/-1) libunity-2d-private/src/edgehitdetector.cpp (+0/-65) libunity-2d-private/src/edgehitdetector.h (+0/-44) libunity-2d-private/src/forcevisiblebehavior.cpp (+0/-36) libunity-2d-private/src/forcevisiblebehavior.h (+0/-41) libunity-2d-private/src/gesturehandler.cpp (+27/-15) libunity-2d-private/src/gesturehandler.h (+15/-4) libunity-2d-private/src/inputshapemanager.cpp (+105/-0) libunity-2d-private/src/inputshapemanager.h (+59/-0) libunity-2d-private/src/inputshapemask.cpp (+111/-0) libunity-2d-private/src/inputshapemask.h (+71/-0) libunity-2d-private/src/inputshaperectangle.cpp (+126/-0) libunity-2d-private/src/inputshaperectangle.h (+75/-0) libunity-2d-private/src/intellihidebehavior.cpp (+0/-256) libunity-2d-private/src/intellihidebehavior.h (+0/-75) libunity-2d-private/src/launcherclient.cpp (+0/-48) libunity-2d-private/src/launcherclient.h (+1/-14) libunity-2d-private/src/mousearea.cpp (+0/-117) libunity-2d-private/src/mousearea.h (+0/-60) libunity-2d-private/src/spreadmonitor.cpp (+61/-0) libunity-2d-private/src/spreadmonitor.h (+48/-0) libunity-2d-private/src/strutmanager.cpp (+191/-0) libunity-2d-private/src/strutmanager.h (+92/-0) libunity-2d-private/src/unity2dpanel.cpp (+9/-109) libunity-2d-private/src/unity2dpanel.h (+1/-5) libunity-2d-private/src/windowsintersectmonitor.cpp (+183/-0) libunity-2d-private/src/windowsintersectmonitor.h (+55/-0) libunity-2d-private/tests/CMakeLists.txt (+0/-7) libunity-2d-private/tests/mouseareademo.cpp (+0/-48) panel/applets/CMakeLists.txt (+0/-1) panel/applets/homebutton/CMakeLists.txt (+0/-33) panel/applets/homebutton/homebutton.cpp (+0/-63) panel/applets/homebutton/homebutton.h (+0/-43) panel/applets/homebutton/homebuttonapplet.cpp (+0/-112) panel/applets/homebutton/homebuttonapplet.h (+0/-55) panel/applets/homebutton/plugin.cpp (+0/-39) panel/applets/homebutton/plugin.h (+0/-40) shell/CMakeLists.txt (+18/-5) shell/Shell.qml (+178/-0) shell/app/CMakeLists.txt (+30/-19) shell/app/dashdbus.cpp (+92/-0) shell/app/dashdbus.h (+64/-0) shell/app/launcher.xml (+0/-14) shell/app/launcherdbus.cpp (+3/-22) shell/app/launcherdbus.h (+3/-7) shell/app/shell.cpp (+64/-17) shell/app/shelldeclarativeview.cpp (+376/-182) shell/app/shelldeclarativeview.h (+75/-25) shell/app/unity-2d-launcher.service.in (+1/-1) shell/app/unity-2d-places.service.in (+1/-1) shell/app/unity-2d-shell.desktop (+6/-5) shell/common/AlwaysVisibleBehavior.qml (+23/-0) shell/common/BaseBehavior.qml (+26/-0) shell/common/VisibilityController.qml (+71/-0) shell/common/utils.js (+13/-0) shell/dash/CategoryHeader.qml (+1/-0) shell/dash/Dash.qml (+106/-21) shell/dash/FilterLoader.qml (+2/-1) shell/dash/FilterPane.qml (+1/-0) shell/dash/FoldingArrow.qml (+1/-1) shell/dash/Home.qml (+10/-7) shell/dash/HomeButton.qml (+1/-0) shell/dash/HomeButtonApplication.qml (+1/-4) shell/dash/HomeButtonDefaultApplication.qml (+1/-4) shell/dash/HomeShortcuts.qml (+8/-0) shell/dash/LensBar.qml (+1/-1) shell/dash/LensButton.qml (+2/-1) shell/dash/LensView.qml (+5/-4) shell/dash/ListViewWithScrollbar.qml (+2/-2) shell/dash/MultiRangeButton.qml (+1/-0) shell/dash/RatingStars.qml (+1/-1) shell/dash/SearchEntry.qml (+4/-3) shell/dash/TickBox.qml (+1/-0) shell/dash/TileHorizontal.qml (+2/-4) shell/dash/TileVertical.qml (+2/-4) shell/launcher/AutoHideBehavior.qml (+46/-0) shell/launcher/IntelliHideBehavior.qml (+90/-0) shell/launcher/Launcher.qml (+19/-28) shell/launcher/LauncherItem.qml (+8/-7) shell/launcher/LauncherList.qml (+22/-13) shell/launcher/LauncherLoader.qml (+94/-0) shell/tests/CMakeLists.txt (+29/-0) shell/tests/launcherviewtest.cpp (+42/-0) spread/app/spread.cpp (+2/-1) spread/app/spreadcontrol.cpp (+1/-8) spread/app/spreadview.h (+0/-1) tests/dash/dash-tests.rb (+59/-67) tests/dash/fullscreen.rb (+24/-27) tests/getshape/CMakeLists.txt (+22/-0) tests/getshape/getshape.cpp (+131/-0) tests/launcher/always_visible_tests.rb (+5/-5) tests/launcher/autohide_show_tests.rb (+11/-11) tests/launcher/autohide_show_tests_common.rb (+1/-1) tests/launcher/autohide_show_tests_rtl.rb (+12/-12) tests/launcher/launcher_sizing.rb (+11/-20) tests/launcher/update_pips_tests.rb (+0/-316) tests/launcher/visual_verification.rb (+7/-7) tests/manual-tests/dash.txt (+1/-1) tests/run-tests.rb (+8/-9) tests/shell/input_shaping.rb (+92/-0) tests/shell/input_shaping_common.rb (+180/-0) tests/shell/input_shaping_rtl.rb (+92/-0) tests/shell/root_qml_param.rb (+97/-0) tests/shell/rootqmlparamtest.qml (+12/-0) tests/spread/spread-tests.rb (+8/-8) |
To merge this branch: | bzr merge lp:~fboucault/unity-2d/no_dash_when_spread_shown |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Albert Astals Cid | Pending | ||
Review via email: mp+92181@code.launchpad.net |
Commit message
Description of the change
Inhibit Dash.qml's activateLens() and activateHome() if spread is shown.
To post a comment you must log in.
Unmerged revisions
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file '.bzrignore' | |||
2 | --- .bzrignore 2012-01-18 16:08:06 +0000 | |||
3 | +++ .bzrignore 2012-02-09 02:13:26 +0000 | |||
4 | @@ -1,14 +1,10 @@ | |||
5 | 1 | config.h | 1 | config.h |
6 | 2 | 2 | ||
16 | 3 | launcher/app/unity-2d-launcher | 3 | shell/app/dashadaptor.* |
17 | 4 | launcher/app/launcheradaptor.* | 4 | shell/app/launcheradaptor.* |
18 | 5 | launcher/app/unity-2d-launcher.service | 5 | shell/app/unity-2d-launcher.service |
19 | 6 | launcher/tests/launchermenutest | 6 | shell/app/unity-2d-places.service |
20 | 7 | launcher/tests/launcherviewtest | 7 | shell/app/unity-2d-shell |
12 | 8 | |||
13 | 9 | places/app/unity-2d-places | ||
14 | 10 | places/app/unity-2d-places.service | ||
15 | 11 | places/app/dashadaptor.* | ||
21 | 12 | 8 | ||
22 | 13 | spread/app/unity-2d-spread | 9 | spread/app/unity-2d-spread |
23 | 14 | spread/app/unity-2d-spread.service | 10 | spread/app/unity-2d-spread.service |
24 | @@ -19,7 +15,6 @@ | |||
25 | 19 | panel/applets/indicator/indicator-config.h | 15 | panel/applets/indicator/indicator-config.h |
26 | 20 | panel/applets/libpanelplugin-*.so.* | 16 | panel/applets/libpanelplugin-*.so.* |
27 | 21 | panel/lib/libuqpanel.so* | 17 | panel/lib/libuqpanel.so* |
28 | 22 | panel/tests/homebuttonapplettest | ||
29 | 23 | 18 | ||
30 | 24 | libunity-2d-private/src/libunity-2d-private.so.* | 19 | libunity-2d-private/src/libunity-2d-private.so.* |
31 | 25 | libunity-2d-private/src/unity-2d-private.pc | 20 | libunity-2d-private/src/unity-2d-private.pc |
32 | @@ -44,6 +39,7 @@ | |||
33 | 44 | po/*.gmo | 39 | po/*.gmo |
34 | 45 | 40 | ||
35 | 46 | tests/misc/binary_dir.txt | 41 | tests/misc/binary_dir.txt |
36 | 42 | tests/getshape/getshape | ||
37 | 47 | 43 | ||
38 | 48 | # Cmake files and generated files | 44 | # Cmake files and generated files |
39 | 49 | Makefile | 45 | Makefile |
40 | @@ -77,10 +73,9 @@ | |||
41 | 77 | debian/stamp-* | 73 | debian/stamp-* |
42 | 78 | debian/tmp | 74 | debian/tmp |
43 | 79 | debian/unity-2d | 75 | debian/unity-2d |
44 | 80 | debian/unity-2d-launcher | ||
45 | 81 | debian/unity-2d-panel | 76 | debian/unity-2d-panel |
46 | 82 | debian/unity-2d-places | ||
47 | 83 | debian/unity-2d-spread | 77 | debian/unity-2d-spread |
48 | 78 | debian/unity-2d-shell | ||
49 | 84 | debian/libunity-2d-private0 | 79 | debian/libunity-2d-private0 |
50 | 85 | debian/libunity-2d-private-dev | 80 | debian/libunity-2d-private-dev |
51 | 86 | data/gschemas.compiled | 81 | data/gschemas.compiled |
52 | 87 | 82 | ||
53 | === modified file 'CMakeLists.txt' | |||
54 | --- CMakeLists.txt 2011-12-15 15:34:37 +0000 | |||
55 | +++ CMakeLists.txt 2012-02-09 02:13:26 +0000 | |||
56 | @@ -93,11 +93,11 @@ | |||
57 | 93 | 93 | ||
58 | 94 | # Source | 94 | # Source |
59 | 95 | add_subdirectory(libunity-2d-private) | 95 | add_subdirectory(libunity-2d-private) |
60 | 96 | add_subdirectory(launcher) | ||
61 | 97 | add_subdirectory(panel) | 96 | add_subdirectory(panel) |
62 | 98 | add_subdirectory(places) | ||
63 | 99 | add_subdirectory(spread) | 97 | add_subdirectory(spread) |
64 | 98 | add_subdirectory(shell) | ||
65 | 100 | add_subdirectory(po) | 99 | add_subdirectory(po) |
66 | 100 | add_subdirectory(tests/getshape) | ||
67 | 101 | 101 | ||
68 | 102 | # uninstall target | 102 | # uninstall target |
69 | 103 | configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY) | 103 | configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY) |
70 | 104 | 104 | ||
71 | === modified file 'README' | |||
72 | --- README 2011-03-22 23:20:29 +0000 | |||
73 | +++ README 2012-02-09 02:13:26 +0000 | |||
74 | @@ -1,19 +1,18 @@ | |||
76 | 1 | Compiling unity-2d | 1 | Compiling Unity 2D |
77 | 2 | ================== | 2 | ================== |
78 | 3 | 3 | ||
79 | 4 | cmake . && make | 4 | cmake . && make |
80 | 5 | 5 | ||
81 | 6 | 6 | ||
84 | 7 | Running separate components | 7 | Running |
85 | 8 | =========================== | 8 | ======= |
86 | 9 | 9 | ||
88 | 10 | ./launcher/app/unity-2d-launcher | 10 | ./shell/app/unity-2d-shell |
89 | 11 | ./panel/app/unity-2d-panel | 11 | ./panel/app/unity-2d-panel |
95 | 12 | ./places/app/unity-2d-places | 12 | |
96 | 13 | 13 | ||
97 | 14 | 14 | Notes on the Dash | |
98 | 15 | Notes on the dash (places) | 15 | ================= |
94 | 16 | ========================== | ||
99 | 17 | 16 | ||
100 | 18 | The dash exposes a D-Bus property for activation and deactivation: | 17 | The dash exposes a D-Bus property for activation and deactivation: |
101 | 19 | 18 | ||
102 | 20 | 19 | ||
103 | === modified file 'debian/control' | |||
104 | --- debian/control 2012-02-03 09:51:46 +0000 | |||
105 | +++ debian/control 2012-02-09 02:13:26 +0000 | |||
106 | @@ -31,10 +31,9 @@ | |||
107 | 31 | Package: unity-2d | 31 | Package: unity-2d |
108 | 32 | Architecture: all | 32 | Architecture: all |
109 | 33 | Depends: ${misc:Depends}, | 33 | Depends: ${misc:Depends}, |
110 | 34 | unity-2d-launcher, | ||
111 | 35 | unity-2d-panel, | 34 | unity-2d-panel, |
112 | 36 | unity-2d-places, | ||
113 | 37 | unity-2d-spread, | 35 | unity-2d-spread, |
114 | 36 | unity-2d-shell, | ||
115 | 38 | metacity (>= 2.30.3-0ubuntu5) | 37 | metacity (>= 2.30.3-0ubuntu5) |
116 | 39 | Description: Unity interface for non-accelerated graphics cards | 38 | Description: Unity interface for non-accelerated graphics cards |
117 | 40 | The Unity 2D interface installs a fully usable 2D session and provides the | 39 | The Unity 2D interface installs a fully usable 2D session and provides the |
118 | @@ -72,21 +71,13 @@ | |||
119 | 72 | This package contains the development header files. | 71 | This package contains the development header files. |
120 | 73 | 72 | ||
121 | 74 | Package: unity-2d-launcher | 73 | Package: unity-2d-launcher |
137 | 75 | Architecture: any | 74 | Architecture: all |
138 | 76 | Depends: ${shlibs:Depends}, | 75 | Depends: ${misc:Depends}, |
139 | 77 | ${misc:Depends}, | 76 | unity-2d-shell, |
140 | 78 | unity-asset-pool, | 77 | Description: Transitional package for unity-2d-launcher |
141 | 79 | libunity-2d-private0 (= ${binary:Version}), | 78 | This is a transitional package for unity-2d-launcher, and can be safely removed |
142 | 80 | libqt4-svg, | 79 | after the installation is complete. |
143 | 81 | Recommends: unity-lens-files, | 80 | |
129 | 82 | unity-lens-applications, | ||
130 | 83 | unity-lens-music, | ||
131 | 84 | Description: Unity 2D Launcher | ||
132 | 85 | The Unity 2D launcher displays a list of running applications as well as a | ||
133 | 86 | list of favorite applications in a panel at the left of the screen. | ||
134 | 87 | Notifications from individual applications are also highlighted in the | ||
135 | 88 | launcher. | ||
136 | 89 | |||
144 | 90 | Package: unity-2d-panel | 81 | Package: unity-2d-panel |
145 | 91 | Architecture: any | 82 | Architecture: any |
146 | 92 | Depends: ${shlibs:Depends}, | 83 | Depends: ${shlibs:Depends}, |
147 | @@ -105,15 +96,12 @@ | |||
148 | 105 | application outside of the Unity 2D environment. | 96 | application outside of the Unity 2D environment. |
149 | 106 | 97 | ||
150 | 107 | Package: unity-2d-places | 98 | Package: unity-2d-places |
160 | 108 | Architecture: any | 99 | Architecture: all |
161 | 109 | Depends: ${shlibs:Depends}, | 100 | Depends: ${misc:Depends}, |
162 | 110 | ${misc:Depends}, | 101 | unity-2d-shell, |
163 | 111 | libunity-2d-private0 (= ${binary:Version}), | 102 | Description: Transitional package for unity-2d-places |
164 | 112 | libqt4-svg | 103 | This is a transitional package for unity-2d-places, and can be safely removed |
165 | 113 | Description: Unity 2D Places | 104 | after the installation is complete. |
157 | 114 | The Unity 2D places overlay over the desktop to provide quick access to | ||
158 | 115 | various categories of applications. It is part of Unity 2D and can not run | ||
159 | 116 | as a standalone application outside of the Unity 2D environment. | ||
166 | 117 | 105 | ||
167 | 118 | Package: unity-2d-spread | 106 | Package: unity-2d-spread |
168 | 119 | Architecture: any | 107 | Architecture: any |
169 | @@ -127,6 +115,28 @@ | |||
170 | 127 | switch to. It is part of Unity 2D and can not run as a standalone application | 115 | switch to. It is part of Unity 2D and can not run as a standalone application |
171 | 128 | outside of the Unity 2D environment. | 116 | outside of the Unity 2D environment. |
172 | 129 | 117 | ||
173 | 118 | Package: unity-2d-shell | ||
174 | 119 | Architecture: any | ||
175 | 120 | Depends: ${shlibs:Depends}, | ||
176 | 121 | ${misc:Depends}, | ||
177 | 122 | unity-asset-pool, | ||
178 | 123 | libunity-2d-private0 (= ${binary:Version}), | ||
179 | 124 | libqt4-svg, | ||
180 | 125 | Recommends: unity-lens-files, | ||
181 | 126 | unity-lens-applications, | ||
182 | 127 | unity-lens-music, | ||
183 | 128 | Replaces: unity-2d-launcher (<< 5.4~), | ||
184 | 129 | unity-2d-places (<< 5.4~), | ||
185 | 130 | Breaks: unity-2d-launcher (<< 5.4~), | ||
186 | 131 | unity-2d-places (<< 5.4~), | ||
187 | 132 | Description: Dash and Launcher for the Unity 2D environment | ||
188 | 133 | This is part of Unity 2D and can not run as a standalone application outside | ||
189 | 134 | of the Unity 2D environment. The components included are: | ||
190 | 135 | * Dash: an overlay over the desktop to provide quick access to | ||
191 | 136 | various categories of applications. | ||
192 | 137 | * Launcher: displays in a panel at the left of the screen a list of running | ||
193 | 138 | and favorite applications as well as highlighting their notifications. | ||
194 | 139 | |||
195 | 130 | Package: unity-2d-dbg | 140 | Package: unity-2d-dbg |
196 | 131 | Architecture: any | 141 | Architecture: any |
197 | 132 | Section: debug | 142 | Section: debug |
198 | 133 | 143 | ||
199 | === removed file 'debian/manpages/unity-2d-launcher.1' | |||
200 | --- debian/manpages/unity-2d-launcher.1 2011-01-14 22:41:51 +0000 | |||
201 | +++ debian/manpages/unity-2d-launcher.1 1970-01-01 00:00:00 +0000 | |||
202 | @@ -1,12 +0,0 @@ | |||
203 | 1 | .TH unity-2d-launcher 1 | ||
204 | 2 | .SH NAME | ||
205 | 3 | unity-2d-launcher \- Provides launcher sidebar in the Unity 2D environment | ||
206 | 4 | .SH SYNOPSIS | ||
207 | 5 | .B unity-2d-launcher | ||
208 | 6 | provides the launcher sidebar for the Unity 2D launcher, which provides the | ||
209 | 7 | icons and application switcher. It is meant to be used as the full Unity 2D | ||
210 | 8 | environment | ||
211 | 9 | .SH OPTIONS | ||
212 | 10 | .TP | ||
213 | 11 | This application takes no arguments. | ||
214 | 12 | |||
215 | 13 | 0 | ||
216 | === removed file 'debian/manpages/unity-2d-places.1' | |||
217 | --- debian/manpages/unity-2d-places.1 2011-01-14 23:08:50 +0000 | |||
218 | +++ debian/manpages/unity-2d-places.1 1970-01-01 00:00:00 +0000 | |||
219 | @@ -1,12 +0,0 @@ | |||
220 | 1 | .TH unity-2d-places 1 | ||
221 | 2 | .SH NAME | ||
222 | 3 | unity-2d-places \- Unity 2D Places | ||
223 | 4 | .SH SYNOPSIS | ||
224 | 5 | .B unity-2d-places | ||
225 | 6 | displays a top panel containing the application menu and various indicators. | ||
226 | 7 | It functions as part Unity 2D, and is not meant to be used as a standalone | ||
227 | 8 | application. | ||
228 | 9 | .SH OPTIONS | ||
229 | 10 | .TP | ||
230 | 11 | This application takes no arguments. | ||
231 | 12 | |||
232 | 13 | 0 | ||
233 | === added file 'debian/manpages/unity-2d-shell.1' | |||
234 | --- debian/manpages/unity-2d-shell.1 1970-01-01 00:00:00 +0000 | |||
235 | +++ debian/manpages/unity-2d-shell.1 2012-02-09 02:13:26 +0000 | |||
236 | @@ -0,0 +1,17 @@ | |||
237 | 1 | .TH unity-2d-shell 1 | ||
238 | 2 | .SH NAME | ||
239 | 3 | unity-2d-shell \- Unity 2D Shell | ||
240 | 4 | .SH SYNOPSIS | ||
241 | 5 | .B unity-2d-shell [-opengl] [-rootqml File.qml] | ||
242 | 6 | displays some components of Unity 2D. It contains the launcher and dash. | ||
243 | 7 | It functions as part Unity 2D, and is not meant to be used as a standalone | ||
244 | 8 | application. | ||
245 | 9 | It can however be used for testing or prototyping of only specific components | ||
246 | 10 | of Unity 2D by using the rootqml argument. | ||
247 | 11 | .SH OPTIONS | ||
248 | 12 | .TP | ||
249 | 13 | \fB\-opengl\fR | ||
250 | 14 | Run the application using an openGL-enabled widget | ||
251 | 15 | .TP | ||
252 | 16 | \fB\qmlfile\fR | ||
253 | 17 | The path of a QML file to load instead of the full shell | ||
254 | 0 | 18 | ||
255 | === removed file 'debian/unity-2d-launcher.install.in' | |||
256 | --- debian/unity-2d-launcher.install.in 2011-11-09 22:26:57 +0000 | |||
257 | +++ debian/unity-2d-launcher.install.in 1970-01-01 00:00:00 +0000 | |||
258 | @@ -1,5 +0,0 @@ | |||
259 | 1 | @DEBIAN_INSTALL_PREFIX@/@CMAKE_INSTALL_BINDIR@/unity-2d-launcher | ||
260 | 2 | @DEBIAN_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/dbus-1/services/unity-2d-launcher.service | ||
261 | 3 | @DEBIAN_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/applications/unity-2d-launcher.desktop | ||
262 | 4 | @DEBIAN_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/unity-2d/launcher/*.qml | ||
263 | 5 | @DEBIAN_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/unity-2d/launcher/artwork | ||
264 | 6 | 0 | ||
265 | === removed file 'debian/unity-2d-launcher.manpages' | |||
266 | --- debian/unity-2d-launcher.manpages 2011-01-14 22:28:06 +0000 | |||
267 | +++ debian/unity-2d-launcher.manpages 1970-01-01 00:00:00 +0000 | |||
268 | @@ -1,1 +0,0 @@ | |||
269 | 1 | debian/manpages/unity-2d-launcher.1 | ||
270 | 2 | 0 | ||
271 | === removed file 'debian/unity-2d-places.install.in' | |||
272 | --- debian/unity-2d-places.install.in 2011-11-09 22:26:57 +0000 | |||
273 | +++ debian/unity-2d-places.install.in 1970-01-01 00:00:00 +0000 | |||
274 | @@ -1,6 +0,0 @@ | |||
275 | 1 | @DEBIAN_INSTALL_PREFIX@/@CMAKE_INSTALL_BINDIR@/unity-2d-places | ||
276 | 2 | @DEBIAN_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/applications/unity-2d-places.desktop | ||
277 | 3 | @DEBIAN_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/dbus-1/services/unity-2d-places.service | ||
278 | 4 | @DEBIAN_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/unity-2d/places/*.qml | ||
279 | 5 | @DEBIAN_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/unity-2d/places/*.js | ||
280 | 6 | @DEBIAN_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/unity-2d/places/artwork | ||
281 | 7 | 0 | ||
282 | === removed file 'debian/unity-2d-places.manpages' | |||
283 | --- debian/unity-2d-places.manpages 2011-01-14 23:08:50 +0000 | |||
284 | +++ debian/unity-2d-places.manpages 1970-01-01 00:00:00 +0000 | |||
285 | @@ -1,1 +0,0 @@ | |||
286 | 1 | debian/manpages/unity-2d-places.1 | ||
287 | 2 | 0 | ||
288 | === added file 'debian/unity-2d-shell.install.in' | |||
289 | --- debian/unity-2d-shell.install.in 1970-01-01 00:00:00 +0000 | |||
290 | +++ debian/unity-2d-shell.install.in 2012-02-09 02:13:26 +0000 | |||
291 | @@ -0,0 +1,9 @@ | |||
292 | 1 | @DEBIAN_INSTALL_PREFIX@/@CMAKE_INSTALL_BINDIR@/unity-2d-shell | ||
293 | 2 | @DEBIAN_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/applications/unity-2d-shell.desktop | ||
294 | 3 | @DEBIAN_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/dbus-1/services/unity-2d-places.service | ||
295 | 4 | @DEBIAN_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/dbus-1/services/unity-2d-launcher.service | ||
296 | 5 | @DEBIAN_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/unity-2d/shell/*.qml | ||
297 | 6 | @DEBIAN_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/unity-2d/shell/dash | ||
298 | 7 | @DEBIAN_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/unity-2d/shell/launcher | ||
299 | 8 | @DEBIAN_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/unity-2d/shell/common | ||
300 | 9 | @DEBIAN_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/unity-2d/shell/artwork | ||
301 | 0 | 10 | ||
302 | === added file 'debian/unity-2d-shell.manpages' | |||
303 | --- debian/unity-2d-shell.manpages 1970-01-01 00:00:00 +0000 | |||
304 | +++ debian/unity-2d-shell.manpages 2012-02-09 02:13:26 +0000 | |||
305 | @@ -0,0 +1,1 @@ | |||
306 | 1 | debian/manpages/unity-2d-shell.1 | ||
307 | 0 | 2 | ||
308 | === removed directory 'launcher' | |||
309 | === removed file 'launcher/CMakeLists.txt' | |||
310 | --- launcher/CMakeLists.txt 2011-06-08 20:43:09 +0000 | |||
311 | +++ launcher/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
312 | @@ -1,20 +0,0 @@ | |||
313 | 1 | project(unity-2d-launcher) | ||
314 | 2 | |||
315 | 3 | include_directories( | ||
316 | 4 | ${libunity-2d-private_SOURCE_DIR}/src | ||
317 | 5 | ) | ||
318 | 6 | |||
319 | 7 | # Source | ||
320 | 8 | add_subdirectory(app) | ||
321 | 9 | add_subdirectory(tests) | ||
322 | 10 | |||
323 | 11 | file(GLOB launcher_QML *.qml) | ||
324 | 12 | |||
325 | 13 | # Install | ||
326 | 14 | install(FILES ${launcher_QML} | ||
327 | 15 | DESTINATION ${UNITY_2D_DIR}/launcher | ||
328 | 16 | ) | ||
329 | 17 | |||
330 | 18 | install(DIRECTORY artwork | ||
331 | 19 | DESTINATION ${UNITY_2D_DIR}/launcher | ||
332 | 20 | ) | ||
333 | 21 | 0 | ||
334 | === removed directory 'launcher/app' | |||
335 | === removed file 'launcher/app/CMakeLists.txt' | |||
336 | --- launcher/app/CMakeLists.txt 2011-11-18 10:15:49 +0000 | |||
337 | +++ launcher/app/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
338 | @@ -1,70 +0,0 @@ | |||
339 | 1 | # Dependencies | ||
340 | 2 | pkg_check_modules(GEIS REQUIRED libutouch-geis) | ||
341 | 3 | pkg_check_modules(QTGCONF REQUIRED libqtgconf) | ||
342 | 4 | |||
343 | 5 | # Sources | ||
344 | 6 | set(launcher_SRCS | ||
345 | 7 | visibilitycontroller.cpp | ||
346 | 8 | launcherview.cpp | ||
347 | 9 | launcherdbus.cpp | ||
348 | 10 | gesturehandler.cpp | ||
349 | 11 | ) | ||
350 | 12 | |||
351 | 13 | set(launcher_MOC_HDRS | ||
352 | 14 | visibilitycontroller.h | ||
353 | 15 | launcherview.h | ||
354 | 16 | launcherdbus.h | ||
355 | 17 | gesturehandler.h | ||
356 | 18 | ) | ||
357 | 19 | |||
358 | 20 | qt4_wrap_cpp(launcher_MOC_SRCS ${launcher_MOC_HDRS}) | ||
359 | 21 | |||
360 | 22 | configure_file(unity-2d-launcher.service.in unity-2d-launcher.service) | ||
361 | 23 | |||
362 | 24 | qt4_add_dbus_adaptor(launcher_SRCS launcher.xml | ||
363 | 25 | launcherdbus.h LauncherDBus | ||
364 | 26 | ) | ||
365 | 27 | |||
366 | 28 | # Build | ||
367 | 29 | add_library(uqlauncher ${launcher_SRCS} ${launcher_MOC_SRCS}) | ||
368 | 30 | add_executable(unity-2d-launcher launcher.cpp) | ||
369 | 31 | |||
370 | 32 | include_directories( | ||
371 | 33 | ${CMAKE_CURRENT_SOURCE_DIR} | ||
372 | 34 | ${CMAKE_CURRENT_BINARY_DIR} | ||
373 | 35 | ${GTK_INCLUDE_DIRS} | ||
374 | 36 | ${X11_INCLUDE_DIRS} | ||
375 | 37 | ${GEIS_INCLUDE_DIRS} | ||
376 | 38 | ${QTGCONF_INCLUDE_DIRS} | ||
377 | 39 | ${libunity-2d-private_SOURCE_DIR}/src | ||
378 | 40 | ) | ||
379 | 41 | |||
380 | 42 | target_link_libraries(uqlauncher | ||
381 | 43 | ${QT_QTCORE_LIBRARIES} | ||
382 | 44 | ${QT_QTGUI_LIBRARIES} | ||
383 | 45 | ${QT_QTDBUS_LIBRARIES} | ||
384 | 46 | ${QT_QTDECLARATIVE_LIBRARIES} | ||
385 | 47 | ${GTK_LDFLAGS} | ||
386 | 48 | ${X11_LDFLAGS} | ||
387 | 49 | ${GEIS_LDFLAGS} | ||
388 | 50 | ${QTGCONF_LDFLAGS} | ||
389 | 51 | ${DCONFQT_LDFLAGS} | ||
390 | 52 | unity-2d-private | ||
391 | 53 | ) | ||
392 | 54 | |||
393 | 55 | target_link_libraries(unity-2d-launcher | ||
394 | 56 | uqlauncher) | ||
395 | 57 | |||
396 | 58 | # Install | ||
397 | 59 | install(TARGETS unity-2d-launcher | ||
398 | 60 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} | ||
399 | 61 | ) | ||
400 | 62 | |||
401 | 63 | install(FILES unity-2d-launcher.desktop | ||
402 | 64 | DESTINATION ${CMAKE_INSTALL_DATADIR}/applications | ||
403 | 65 | ) | ||
404 | 66 | |||
405 | 67 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/unity-2d-launcher.service | ||
406 | 68 | DESTINATION ${CMAKE_INSTALL_DATADIR}/dbus-1/services | ||
407 | 69 | ) | ||
408 | 70 | |||
409 | 71 | 0 | ||
410 | === removed file 'launcher/app/launcher.cpp' | |||
411 | --- launcher/app/launcher.cpp 2012-02-01 15:01:21 +0000 | |||
412 | +++ launcher/app/launcher.cpp 1970-01-01 00:00:00 +0000 | |||
413 | @@ -1,137 +0,0 @@ | |||
414 | 1 | /* | ||
415 | 2 | * Copyright (C) 2010 Canonical, Ltd. | ||
416 | 3 | * | ||
417 | 4 | * Authors: | ||
418 | 5 | * Olivier Tilloy <olivier.tilloy@canonical.com> | ||
419 | 6 | * | ||
420 | 7 | * This program is free software; you can redistribute it and/or modify | ||
421 | 8 | * it under the terms of the GNU General Public License as published by | ||
422 | 9 | * the Free Software Foundation; version 3. | ||
423 | 10 | * | ||
424 | 11 | * This program is distributed in the hope that it will be useful, | ||
425 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
426 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
427 | 14 | * GNU General Public License for more details. | ||
428 | 15 | * | ||
429 | 16 | * You should have received a copy of the GNU General Public License | ||
430 | 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
431 | 18 | */ | ||
432 | 19 | |||
433 | 20 | // unity-2d | ||
434 | 21 | #include <gnomesessionclient.h> | ||
435 | 22 | #include <launcherclient.h> | ||
436 | 23 | #include <unity2dapplication.h> | ||
437 | 24 | |||
438 | 25 | // Qt | ||
439 | 26 | #include <QApplication> | ||
440 | 27 | #include <QDesktopWidget> | ||
441 | 28 | #include <QDeclarativeEngine> | ||
442 | 29 | #include <QDeclarativeContext> | ||
443 | 30 | #include <QDir> | ||
444 | 31 | #include <QGraphicsObject> | ||
445 | 32 | |||
446 | 33 | #include "config.h" | ||
447 | 34 | #include "launcherview.h" | ||
448 | 35 | #include "launcherdbus.h" | ||
449 | 36 | #include "visibilitycontroller.h" | ||
450 | 37 | #include "unity2ddebug.h" | ||
451 | 38 | #include "unity2dpanel.h" | ||
452 | 39 | #include "gesturehandler.h" | ||
453 | 40 | #include "screeninfo.h" | ||
454 | 41 | |||
455 | 42 | // libc | ||
456 | 43 | #include <stdlib.h> | ||
457 | 44 | |||
458 | 45 | #if defined(QMLJSDEBUGGER) | ||
459 | 46 | #include <qt_private/qdeclarativedebughelper_p.h> | ||
460 | 47 | #endif | ||
461 | 48 | |||
462 | 49 | #if defined(QMLJSDEBUGGER) && !defined(NO_JSDEBUGGER) | ||
463 | 50 | #include <jsdebuggeragent.h> | ||
464 | 51 | #endif | ||
465 | 52 | #if defined(QMLJSDEBUGGER) && !defined(NO_QMLOBSERVER) | ||
466 | 53 | #include <qdeclarativeviewobserver.h> | ||
467 | 54 | #endif | ||
468 | 55 | |||
469 | 56 | #if defined(QMLJSDEBUGGER) | ||
470 | 57 | |||
471 | 58 | // Enable debugging before any QDeclarativeEngine is created | ||
472 | 59 | struct QmlJsDebuggingEnabler | ||
473 | 60 | { | ||
474 | 61 | QmlJsDebuggingEnabler() | ||
475 | 62 | { | ||
476 | 63 | QDeclarativeDebugHelper::enableDebugging(); | ||
477 | 64 | } | ||
478 | 65 | }; | ||
479 | 66 | |||
480 | 67 | // Execute code in constructor before first QDeclarativeEngine is instantiated | ||
481 | 68 | static QmlJsDebuggingEnabler enableDebuggingHelper; | ||
482 | 69 | |||
483 | 70 | #endif // QMLJSDEBUGGER | ||
484 | 71 | |||
485 | 72 | int main(int argc, char *argv[]) | ||
486 | 73 | { | ||
487 | 74 | Unity2dApplication::earlySetup(argc, argv); | ||
488 | 75 | Unity2dApplication application(argc, argv); | ||
489 | 76 | application.setApplicationName("Unity 2D Launcher"); | ||
490 | 77 | QSet<QString> arguments = QSet<QString>::fromList(QCoreApplication::arguments()); | ||
491 | 78 | |||
492 | 79 | GnomeSessionClient client(INSTALL_PREFIX "/share/applications/unity-2d-launcher.desktop"); | ||
493 | 80 | client.connectToSessionManager(); | ||
494 | 81 | |||
495 | 82 | /* Configure "artwork:" prefix so that any access to a file whose name starts | ||
496 | 83 | with that prefix resolves properly. */ | ||
497 | 84 | QDir::addSearchPath("artwork", unity2dDirectory() + "/launcher/artwork"); | ||
498 | 85 | |||
499 | 86 | /* Panel containing the QML declarative view, topleft screen */ | ||
500 | 87 | Unity2dPanel panel(true, -1, ScreenInfo::TopLeft); | ||
501 | 88 | |||
502 | 89 | panel.setEdge(Unity2dPanel::LeftEdge); | ||
503 | 90 | panel.setFixedWidth(LauncherClient::MaximumWidth); | ||
504 | 91 | panel.setAccessibleName("Launcher"); | ||
505 | 92 | |||
506 | 93 | VisibilityController* visibilityController = new VisibilityController(&panel); | ||
507 | 94 | |||
508 | 95 | /* QML declarative view */ | ||
509 | 96 | LauncherView *launcherView = new LauncherView(&panel); | ||
510 | 97 | if (arguments.contains("-opengl")) { | ||
511 | 98 | launcherView->setUseOpenGL(true); | ||
512 | 99 | } | ||
513 | 100 | |||
514 | 101 | launcherView->setResizeMode(QDeclarativeView::SizeRootObjectToView); | ||
515 | 102 | launcherView->setFocus(); | ||
516 | 103 | |||
517 | 104 | launcherView->engine()->addImportPath(unity2dImportPath()); | ||
518 | 105 | /* Note: baseUrl seems to be picky: if it does not end with a slash, | ||
519 | 106 | setSource() will fail */ | ||
520 | 107 | launcherView->engine()->setBaseUrl(QUrl::fromLocalFile(unity2dDirectory() + "/launcher/")); | ||
521 | 108 | |||
522 | 109 | launcherView->rootContext()->setContextProperty("declarativeView", launcherView); | ||
523 | 110 | launcherView->rootContext()->setContextProperty("launcherView", launcherView); | ||
524 | 111 | launcherView->rootContext()->setContextProperty("panel", &panel); | ||
525 | 112 | launcherView->rootContext()->setContextProperty("visibilityController", visibilityController); | ||
526 | 113 | |||
527 | 114 | LauncherDBus launcherDBus(visibilityController, launcherView); | ||
528 | 115 | launcherDBus.connectToBus(); | ||
529 | 116 | |||
530 | 117 | launcherView->setSource(QUrl("./Launcher.qml")); | ||
531 | 118 | |||
532 | 119 | /* Composing the QML declarative view inside the panel */ | ||
533 | 120 | panel.addWidget(launcherView); | ||
534 | 121 | panel.show(); | ||
535 | 122 | |||
536 | 123 | /* Unset DESKTOP_AUTOSTART_ID in order to avoid child processes (launched | ||
537 | 124 | applications) to use the same client id. | ||
538 | 125 | This would prevent some applications (e.g. nautilus) from launching when | ||
539 | 126 | the launcher itself was autostarted (which is the common case when | ||
540 | 127 | running installed). | ||
541 | 128 | For a discussion, see https://bugs.launchpad.net/upicek/+bug/684160. */ | ||
542 | 129 | unsetenv("DESKTOP_AUTOSTART_ID"); | ||
543 | 130 | |||
544 | 131 | /* Gesture handler instance in charge of listening to gesture events and | ||
545 | 132 | trigger appropriate actions in response. */ | ||
546 | 133 | GestureHandler gestureHandler(&panel); | ||
547 | 134 | |||
548 | 135 | return application.exec(); | ||
549 | 136 | } | ||
550 | 137 | |||
551 | 138 | 0 | ||
552 | === removed file 'launcher/app/launcherview.cpp' | |||
553 | --- launcher/app/launcherview.cpp 2012-02-07 10:43:40 +0000 | |||
554 | +++ launcher/app/launcherview.cpp 1970-01-01 00:00:00 +0000 | |||
555 | @@ -1,299 +0,0 @@ | |||
556 | 1 | /* | ||
557 | 2 | * Copyright (C) 2010 Canonical, Ltd. | ||
558 | 3 | * | ||
559 | 4 | * Authors: | ||
560 | 5 | * Olivier Tilloy <olivier.tilloy@canonical.com> | ||
561 | 6 | * | ||
562 | 7 | * This program is free software; you can redistribute it and/or modify | ||
563 | 8 | * it under the terms of the GNU General Public License as published by | ||
564 | 9 | * the Free Software Foundation; version 3. | ||
565 | 10 | * | ||
566 | 11 | * This program is distributed in the hope that it will be useful, | ||
567 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
568 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
569 | 14 | * GNU General Public License for more details. | ||
570 | 15 | * | ||
571 | 16 | * You should have received a copy of the GNU General Public License | ||
572 | 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
573 | 18 | */ | ||
574 | 19 | |||
575 | 20 | #include "launcherview.h" | ||
576 | 21 | |||
577 | 22 | #include <config.h> | ||
578 | 23 | #include <keyboardmodifiersmonitor.h> | ||
579 | 24 | #include <hotkey.h> | ||
580 | 25 | #include <hotkeymonitor.h> | ||
581 | 26 | #include <keymonitor.h> | ||
582 | 27 | #include <screeninfo.h> | ||
583 | 28 | #include <debug_p.h> | ||
584 | 29 | |||
585 | 30 | #include <QApplication> | ||
586 | 31 | #include <QDesktopWidget> | ||
587 | 32 | #include <QX11Info> | ||
588 | 33 | #include <QDebug> | ||
589 | 34 | #include <QGraphicsObject> | ||
590 | 35 | |||
591 | 36 | #include <QtDeclarative/qdeclarative.h> | ||
592 | 37 | #include <QDeclarativeEngine> | ||
593 | 38 | #include <QDeclarativeContext> | ||
594 | 39 | #include <QDeclarativeImageProvider> | ||
595 | 40 | #include <QtDBus/QDBusInterface> | ||
596 | 41 | #include <QtDBus/QDBusPendingCall> | ||
597 | 42 | #include <QtDBus/QDBusReply> | ||
598 | 43 | #include <QtDBus/QDBusConnectionInterface> | ||
599 | 44 | |||
600 | 45 | #include <X11/Xlib.h> | ||
601 | 46 | #include <X11/Xatom.h> | ||
602 | 47 | |||
603 | 48 | static const int KEY_HOLD_THRESHOLD = 250; | ||
604 | 49 | |||
605 | 50 | static const char* DASH_DBUS_SERVICE = "com.canonical.Unity2d.Dash"; | ||
606 | 51 | static const char* DASH_DBUS_PATH = "/Dash"; | ||
607 | 52 | static const char* DASH_DBUS_INTERFACE = "com.canonical.Unity2d.Dash"; | ||
608 | 53 | static const char* SPREAD_DBUS_SERVICE = "com.canonical.Unity2d.Spread"; | ||
609 | 54 | static const char* SPREAD_DBUS_PATH = "/Spread"; | ||
610 | 55 | static const char* SPREAD_DBUS_INTERFACE = "com.canonical.Unity2d.Spread"; | ||
611 | 56 | |||
612 | 57 | static const char* DASH_DBUS_PROPERTY_ACTIVE = "active"; | ||
613 | 58 | static const char* DASH_DBUS_METHOD_ACTIVATE_HOME = "activateHome"; | ||
614 | 59 | static const char* SPREAD_DBUS_METHOD_IS_SHOWN = "IsShown"; | ||
615 | 60 | static const char* COMMANDS_LENS_ID = "commands.lens"; | ||
616 | 61 | |||
617 | 62 | LauncherView::LauncherView(QWidget* parent) : | ||
618 | 63 | Unity2DDeclarativeView(parent), | ||
619 | 64 | m_superKeyPressed(false), m_superKeyHeld(false) | ||
620 | 65 | { | ||
621 | 66 | setTransparentBackground(QX11Info::isCompositingManagerRunning()); | ||
622 | 67 | |||
623 | 68 | m_superKeyHoldTimer.setSingleShot(true); | ||
624 | 69 | m_superKeyHoldTimer.setInterval(KEY_HOLD_THRESHOLD); | ||
625 | 70 | connect(&m_superKeyHoldTimer, SIGNAL(timeout()), SLOT(updateSuperKeyHoldState())); | ||
626 | 71 | connect(this, SIGNAL(superKeyTapped()), SLOT(toggleDash())); | ||
627 | 72 | |||
628 | 73 | m_screenInfo = new ScreenInfo(ScreenInfo::TopLeft, this); | ||
629 | 74 | |||
630 | 75 | connect(&launcher2dConfiguration(), SIGNAL(superKeyEnableChanged(bool)), SLOT(updateSuperKeyMonitoring())); | ||
631 | 76 | updateSuperKeyMonitoring(); | ||
632 | 77 | |||
633 | 78 | /* Alt+F1 toggle the keyboard focus between laucher and other(previous) application. */ | ||
634 | 79 | Hotkey* altF1 = HotkeyMonitor::instance().getHotkeyFor(Qt::Key_F1, Qt::AltModifier); | ||
635 | 80 | connect(altF1, SIGNAL(pressed()), SLOT(onAltF1Pressed())); | ||
636 | 81 | |||
637 | 82 | /* Alt+F2 shows the dash with the commands lens activated. */ | ||
638 | 83 | Hotkey* altF2 = HotkeyMonitor::instance().getHotkeyFor(Qt::Key_F2, Qt::AltModifier); | ||
639 | 84 | connect(altF2, SIGNAL(pressed()), SLOT(showCommandsLens())); | ||
640 | 85 | |||
641 | 86 | /* Super+S before 'Spread'ing, close all the contextual menus/tooltips in the launcher. */ | ||
642 | 87 | Hotkey* superS = HotkeyMonitor::instance().getHotkeyFor(Qt::Key_S, Qt::MetaModifier); | ||
643 | 88 | connect(superS, SIGNAL(pressed()), SLOT(onSuperSPressed())); | ||
644 | 89 | |||
645 | 90 | /* Super+{n} for 0 ≤ n ≤ 9 activates the item with index (n + 9) % 10. */ | ||
646 | 91 | for (Qt::Key key = Qt::Key_0; key <= Qt::Key_9; key = (Qt::Key) (key + 1)) { | ||
647 | 92 | Hotkey* hotkey = HotkeyMonitor::instance().getHotkeyFor(key, Qt::MetaModifier); | ||
648 | 93 | connect(hotkey, SIGNAL(pressed()), SLOT(forwardNumericHotkey())); | ||
649 | 94 | hotkey = HotkeyMonitor::instance().getHotkeyFor(key, Qt::MetaModifier | Qt::ShiftModifier); | ||
650 | 95 | connect(hotkey, SIGNAL(pressed()), SLOT(forwardNumericHotkey())); | ||
651 | 96 | } | ||
652 | 97 | } | ||
653 | 98 | |||
654 | 99 | LauncherView::~LauncherView() | ||
655 | 100 | { | ||
656 | 101 | } | ||
657 | 102 | |||
658 | 103 | void | ||
659 | 104 | LauncherView::focusInEvent(QFocusEvent* event) | ||
660 | 105 | { | ||
661 | 106 | QDeclarativeView::focusInEvent(event); | ||
662 | 107 | Q_EMIT focusChanged(true); | ||
663 | 108 | } | ||
664 | 109 | |||
665 | 110 | void | ||
666 | 111 | LauncherView::focusOutEvent(QFocusEvent* event) | ||
667 | 112 | { | ||
668 | 113 | QDeclarativeView::focusOutEvent(event); | ||
669 | 114 | Q_EMIT focusChanged(false); | ||
670 | 115 | } | ||
671 | 116 | |||
672 | 117 | void | ||
673 | 118 | LauncherView::updateSuperKeyMonitoring() | ||
674 | 119 | { | ||
675 | 120 | KeyboardModifiersMonitor *modifiersMonitor = KeyboardModifiersMonitor::instance(); | ||
676 | 121 | KeyMonitor *keyMonitor = KeyMonitor::instance(); | ||
677 | 122 | HotkeyMonitor& hotkeyMonitor = HotkeyMonitor::instance(); | ||
678 | 123 | |||
679 | 124 | QVariant value = launcher2dConfiguration().property("superKeyEnable"); | ||
680 | 125 | if (!value.isValid() || value.toBool() == true) { | ||
681 | 126 | hotkeyMonitor.enableModifiers(Qt::MetaModifier); | ||
682 | 127 | QObject::connect(modifiersMonitor, | ||
683 | 128 | SIGNAL(keyboardModifiersChanged(Qt::KeyboardModifiers)), | ||
684 | 129 | this, SLOT(setHotkeysForModifiers(Qt::KeyboardModifiers))); | ||
685 | 130 | /* Ignore Super presses if another key was pressed simultaneously | ||
686 | 131 | (i.e. a shortcut). https://bugs.launchpad.net/unity-2d/+bug/801073 */ | ||
687 | 132 | QObject::connect(keyMonitor, | ||
688 | 133 | SIGNAL(keyPressed()), | ||
689 | 134 | this, SLOT(ignoreSuperPress())); | ||
690 | 135 | setHotkeysForModifiers(modifiersMonitor->keyboardModifiers()); | ||
691 | 136 | } else { | ||
692 | 137 | hotkeyMonitor.disableModifiers(Qt::MetaModifier); | ||
693 | 138 | QObject::disconnect(modifiersMonitor, | ||
694 | 139 | SIGNAL(keyboardModifiersChanged(Qt::KeyboardModifiers)), | ||
695 | 140 | this, SLOT(setHotkeysForModifiers(Qt::KeyboardModifiers))); | ||
696 | 141 | QObject::disconnect(keyMonitor, | ||
697 | 142 | SIGNAL(keyPressed()), | ||
698 | 143 | this, SLOT(ignoreSuperPress())); | ||
699 | 144 | m_superKeyHoldTimer.stop(); | ||
700 | 145 | m_superKeyPressed = false; | ||
701 | 146 | if (m_superKeyHeld) { | ||
702 | 147 | m_superKeyHeld = false; | ||
703 | 148 | Q_EMIT superKeyHeldChanged(false); | ||
704 | 149 | } | ||
705 | 150 | } | ||
706 | 151 | } | ||
707 | 152 | |||
708 | 153 | void | ||
709 | 154 | LauncherView::setHotkeysForModifiers(Qt::KeyboardModifiers modifiers) | ||
710 | 155 | { | ||
711 | 156 | /* This is the new new state of the Super key (AKA Meta key), while | ||
712 | 157 | m_superKeyPressed is the previous state of the key at the last modifiers change. */ | ||
713 | 158 | bool superKeyPressed = modifiers.testFlag(Qt::MetaModifier); | ||
714 | 159 | |||
715 | 160 | if (m_superKeyPressed != superKeyPressed) { | ||
716 | 161 | m_superKeyPressed = superKeyPressed; | ||
717 | 162 | if (superKeyPressed) { | ||
718 | 163 | m_superPressIgnored = false; | ||
719 | 164 | /* If the key is pressed, start up a timer to monitor if it's being held short | ||
720 | 165 | enough to qualify as just a "tap" or as a proper hold */ | ||
721 | 166 | m_superKeyHoldTimer.start(); | ||
722 | 167 | } else { | ||
723 | 168 | m_superKeyHoldTimer.stop(); | ||
724 | 169 | |||
725 | 170 | /* If the key is released, and was not being held, it means that the user just | ||
726 | 171 | performed a "tap". Unless we're told to ignore that tap, that is. */ | ||
727 | 172 | if (!m_superKeyHeld && !m_superPressIgnored) { | ||
728 | 173 | Q_EMIT superKeyTapped(); | ||
729 | 174 | } | ||
730 | 175 | /* Otherwise the user just terminated a hold. */ | ||
731 | 176 | else if(m_superKeyHeld){ | ||
732 | 177 | m_superKeyHeld = false; | ||
733 | 178 | Q_EMIT superKeyHeldChanged(m_superKeyHeld); | ||
734 | 179 | } | ||
735 | 180 | } | ||
736 | 181 | } | ||
737 | 182 | } | ||
738 | 183 | |||
739 | 184 | void | ||
740 | 185 | LauncherView::updateSuperKeyHoldState() | ||
741 | 186 | { | ||
742 | 187 | /* If the key was released in the meantime, just do nothing, otherwise | ||
743 | 188 | consider the key being held, unless we're told to ignore it. */ | ||
744 | 189 | if (m_superKeyPressed && !m_superPressIgnored) { | ||
745 | 190 | m_superKeyHeld = true; | ||
746 | 191 | Q_EMIT superKeyHeldChanged(m_superKeyHeld); | ||
747 | 192 | } | ||
748 | 193 | } | ||
749 | 194 | |||
750 | 195 | void | ||
751 | 196 | LauncherView::ignoreSuperPress() | ||
752 | 197 | { | ||
753 | 198 | /* There was a key pressed, ignore current super tap/hold */ | ||
754 | 199 | m_superPressIgnored = true; | ||
755 | 200 | } | ||
756 | 201 | |||
757 | 202 | void | ||
758 | 203 | LauncherView::forwardNumericHotkey() | ||
759 | 204 | { | ||
760 | 205 | Hotkey* hotkey = qobject_cast<Hotkey*>(sender()); | ||
761 | 206 | if (hotkey != NULL) { | ||
762 | 207 | /* Shortcuts from 1 to 9 should activate the items with index | ||
763 | 208 | from 1 to 9 (index 0 being the so-called "BFB" or Dash launcher). | ||
764 | 209 | Shortcut for 0 should activate item with index 10. | ||
765 | 210 | In other words, the indexes are activated in the same order as | ||
766 | 211 | the keys appear on a standard keyboard. */ | ||
767 | 212 | Qt::Key key = hotkey->key(); | ||
768 | 213 | if (key >= Qt::Key_1 && key <= Qt::Key_9) { | ||
769 | 214 | int index = key - Qt::Key_0; | ||
770 | 215 | if (hotkey->modifiers() & Qt::ShiftModifier) { | ||
771 | 216 | Q_EMIT newInstanceShortcutPressed(index); | ||
772 | 217 | } else { | ||
773 | 218 | Q_EMIT activateShortcutPressed(index); | ||
774 | 219 | } | ||
775 | 220 | } else if (key == Qt::Key_0) { | ||
776 | 221 | if (hotkey->modifiers() & Qt::ShiftModifier) { | ||
777 | 222 | Q_EMIT newInstanceShortcutPressed(10); | ||
778 | 223 | } else { | ||
779 | 224 | Q_EMIT activateShortcutPressed(10); | ||
780 | 225 | } | ||
781 | 226 | } | ||
782 | 227 | } | ||
783 | 228 | } | ||
784 | 229 | |||
785 | 230 | void | ||
786 | 231 | LauncherView::toggleDash() | ||
787 | 232 | { | ||
788 | 233 | QDBusInterface dashInterface(DASH_DBUS_SERVICE, DASH_DBUS_PATH, DASH_DBUS_INTERFACE); | ||
789 | 234 | |||
790 | 235 | QVariant dashActiveResult = dashInterface.property(DASH_DBUS_PROPERTY_ACTIVE); | ||
791 | 236 | if (!dashActiveResult.isValid()) { | ||
792 | 237 | UQ_WARNING << "Can't read the DBUS Dash property" << DASH_DBUS_PROPERTY_ACTIVE | ||
793 | 238 | << "on" << DASH_DBUS_SERVICE << DASH_DBUS_PATH << DASH_DBUS_INTERFACE; | ||
794 | 239 | return; | ||
795 | 240 | } | ||
796 | 241 | |||
797 | 242 | bool dashActive = dashActiveResult.toBool(); | ||
798 | 243 | if (dashActive) { | ||
799 | 244 | if (!dashInterface.setProperty(DASH_DBUS_PROPERTY_ACTIVE, false)) { | ||
800 | 245 | UQ_WARNING << "Can't set the DBUS Dash property" << DASH_DBUS_PROPERTY_ACTIVE | ||
801 | 246 | << "on" << DASH_DBUS_SERVICE << DASH_DBUS_PATH << DASH_DBUS_INTERFACE; | ||
802 | 247 | } | ||
803 | 248 | } else { | ||
804 | 249 | /* Check if the spread is active before activating the dash. | ||
805 | 250 | We need to do this since the spread can't prevent the launcher from | ||
806 | 251 | monitoring the super key and therefore getting to this point if | ||
807 | 252 | it's tapped. */ | ||
808 | 253 | |||
809 | 254 | /* Check if the spread is present on DBUS first, as we don't want to have DBUS | ||
810 | 255 | activate it if it's not running yet */ | ||
811 | 256 | QDBusConnectionInterface* sessionBusIFace = QDBusConnection::sessionBus().interface(); | ||
812 | 257 | QDBusReply<bool> reply = sessionBusIFace->isServiceRegistered(SPREAD_DBUS_SERVICE); | ||
813 | 258 | if (reply.isValid() && reply.value() == true) { | ||
814 | 259 | QDBusInterface spreadInterface(SPREAD_DBUS_SERVICE, SPREAD_DBUS_PATH, | ||
815 | 260 | SPREAD_DBUS_INTERFACE); | ||
816 | 261 | |||
817 | 262 | QDBusReply<bool> spreadActiveResult = spreadInterface.call(SPREAD_DBUS_METHOD_IS_SHOWN); | ||
818 | 263 | if (spreadActiveResult.isValid() && spreadActiveResult.value() == true) { | ||
819 | 264 | return; | ||
820 | 265 | } | ||
821 | 266 | } | ||
822 | 267 | |||
823 | 268 | dashInterface.asyncCall(DASH_DBUS_METHOD_ACTIVATE_HOME); | ||
824 | 269 | } | ||
825 | 270 | } | ||
826 | 271 | |||
827 | 272 | void | ||
828 | 273 | LauncherView::showCommandsLens() | ||
829 | 274 | { | ||
830 | 275 | QDBusInterface dashInterface(DASH_DBUS_SERVICE, DASH_DBUS_PATH, DASH_DBUS_INTERFACE); | ||
831 | 276 | dashInterface.asyncCall("activateLens", COMMANDS_LENS_ID); | ||
832 | 277 | } | ||
833 | 278 | |||
834 | 279 | /* BUGFIX:881458 */ | ||
835 | 280 | void | ||
836 | 281 | LauncherView::onSuperSPressed() | ||
837 | 282 | { | ||
838 | 283 | QGraphicsObject* launcher = rootObject(); | ||
839 | 284 | QMetaObject::invokeMethod(launcher, "hideMenu", Qt::AutoConnection); | ||
840 | 285 | } | ||
841 | 286 | |||
842 | 287 | void | ||
843 | 288 | LauncherView::onAltF1Pressed() | ||
844 | 289 | { | ||
845 | 290 | QGraphicsObject* launcher = rootObject(); | ||
846 | 291 | |||
847 | 292 | if (hasFocus()) { | ||
848 | 293 | QMetaObject::invokeMethod(launcher, "hideMenu", Qt::AutoConnection); | ||
849 | 294 | forceDeactivateWindow(); | ||
850 | 295 | } else { | ||
851 | 296 | forceActivateWindow(); | ||
852 | 297 | QMetaObject::invokeMethod(launcher, "focusBFB", Qt::AutoConnection); | ||
853 | 298 | } | ||
854 | 299 | } | ||
855 | 300 | 0 | ||
856 | === removed file 'launcher/app/launcherview.h' | |||
857 | --- launcher/app/launcherview.h 2011-11-25 12:32:03 +0000 | |||
858 | +++ launcher/app/launcherview.h 1970-01-01 00:00:00 +0000 | |||
859 | @@ -1,79 +0,0 @@ | |||
860 | 1 | /* | ||
861 | 2 | * Copyright (C) 2010 Canonical, Ltd. | ||
862 | 3 | * | ||
863 | 4 | * Authors: | ||
864 | 5 | * Olivier Tilloy <olivier.tilloy@canonical.com> | ||
865 | 6 | * | ||
866 | 7 | * This program is free software; you can redistribute it and/or modify | ||
867 | 8 | * it under the terms of the GNU General Public License as published by | ||
868 | 9 | * the Free Software Foundation; version 3. | ||
869 | 10 | * | ||
870 | 11 | * This program is distributed in the hope that it will be useful, | ||
871 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
872 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
873 | 14 | * GNU General Public License for more details. | ||
874 | 15 | * | ||
875 | 16 | * You should have received a copy of the GNU General Public License | ||
876 | 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
877 | 18 | */ | ||
878 | 19 | |||
879 | 20 | #ifndef LAUNCHERVIEW | ||
880 | 21 | #define LAUNCHERVIEW | ||
881 | 22 | |||
882 | 23 | #include <QDeclarativeView> | ||
883 | 24 | #include <QList> | ||
884 | 25 | #include <QUrl> | ||
885 | 26 | #include <QTimer> | ||
886 | 27 | #include <QVariant> | ||
887 | 28 | |||
888 | 29 | #include <unity2ddeclarativeview.h> | ||
889 | 30 | |||
890 | 31 | class DeclarativeDragDropEvent; | ||
891 | 32 | class LauncherDBus; | ||
892 | 33 | |||
893 | 34 | class LauncherView : public Unity2DDeclarativeView | ||
894 | 35 | { | ||
895 | 36 | Q_OBJECT | ||
896 | 37 | Q_PROPERTY(bool superKeyHeld READ superKeyHeld NOTIFY superKeyHeldChanged) | ||
897 | 38 | Q_PROPERTY(bool focus READ hasFocus NOTIFY focusChanged) // overridden | ||
898 | 39 | |||
899 | 40 | public: | ||
900 | 41 | explicit LauncherView(QWidget* parent = NULL); | ||
901 | 42 | ~LauncherView(); | ||
902 | 43 | |||
903 | 44 | bool superKeyHeld() const { return m_superKeyHeld; } | ||
904 | 45 | |||
905 | 46 | Q_SIGNALS: | ||
906 | 47 | void activateShortcutPressed(int itemIndex); | ||
907 | 48 | void newInstanceShortcutPressed(int itemIndex); | ||
908 | 49 | void superKeyHeldChanged(bool superKeyHeld); | ||
909 | 50 | void superKeyTapped(); | ||
910 | 51 | void addWebFavoriteRequested(const QUrl& url); | ||
911 | 52 | void focusChanged(bool focus); | ||
912 | 53 | |||
913 | 54 | private Q_SLOTS: | ||
914 | 55 | void setHotkeysForModifiers(Qt::KeyboardModifiers modifiers); | ||
915 | 56 | void forwardNumericHotkey(); | ||
916 | 57 | void ignoreSuperPress(); | ||
917 | 58 | void updateSuperKeyMonitoring(); | ||
918 | 59 | void updateSuperKeyHoldState(); | ||
919 | 60 | void toggleDash(); | ||
920 | 61 | void showCommandsLens(); | ||
921 | 62 | void onSuperSPressed(); | ||
922 | 63 | void onAltF1Pressed(); | ||
923 | 64 | |||
924 | 65 | protected: | ||
925 | 66 | void focusInEvent(QFocusEvent* event); | ||
926 | 67 | void focusOutEvent(QFocusEvent* event); | ||
927 | 68 | |||
928 | 69 | private: | ||
929 | 70 | bool m_superKeyPressed; | ||
930 | 71 | bool m_superKeyHeld; | ||
931 | 72 | bool m_superPressIgnored; | ||
932 | 73 | QTimer m_superKeyHoldTimer; | ||
933 | 74 | |||
934 | 75 | friend class LauncherDBus; | ||
935 | 76 | }; | ||
936 | 77 | |||
937 | 78 | #endif // LAUNCHERVIEW | ||
938 | 79 | |||
939 | 80 | 0 | ||
940 | === removed file 'launcher/app/unity-2d-launcher.desktop' | |||
941 | --- launcher/app/unity-2d-launcher.desktop 2011-09-19 16:29:49 +0000 | |||
942 | +++ launcher/app/unity-2d-launcher.desktop 1970-01-01 00:00:00 +0000 | |||
943 | @@ -1,13 +0,0 @@ | |||
944 | 1 | [Desktop Entry] | ||
945 | 2 | Name=Unity 2d Launcher | ||
946 | 3 | Comment=A Qt-based applications launcher | ||
947 | 4 | Icon=gnome-fs-desktop | ||
948 | 5 | Exec=unity-2d-launcher | ||
949 | 6 | Terminal=false | ||
950 | 7 | Type=Application | ||
951 | 8 | Categories=Utility; | ||
952 | 9 | NoDisplay=true | ||
953 | 10 | X-Ubuntu-Gettext-Domain=unity-2d-launcher | ||
954 | 11 | X-GNOME-Autostart-Notify=false | ||
955 | 12 | X-GNOME-Autostart-Phase=Panel | ||
956 | 13 | X-GNOME-AutoRestart=true | ||
957 | 14 | 0 | ||
958 | === removed file 'launcher/app/visibilitycontroller.cpp' | |||
959 | --- launcher/app/visibilitycontroller.cpp 2011-12-01 09:55:45 +0000 | |||
960 | +++ launcher/app/visibilitycontroller.cpp 1970-01-01 00:00:00 +0000 | |||
961 | @@ -1,163 +0,0 @@ | |||
962 | 1 | /* | ||
963 | 2 | * This file is part of unity-2d | ||
964 | 3 | * | ||
965 | 4 | * Copyright 2011 Canonical Ltd. | ||
966 | 5 | * | ||
967 | 6 | * Authors: | ||
968 | 7 | * - Aurélien Gâteau <aurelien.gateau@canonical.com> | ||
969 | 8 | * | ||
970 | 9 | * This program is free software; you can redistribute it and/or modify | ||
971 | 10 | * it under the terms of the GNU General Public License as published by | ||
972 | 11 | * the Free Software Foundation; version 3. | ||
973 | 12 | * | ||
974 | 13 | * This program is distributed in the hope that it will be useful, | ||
975 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
976 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
977 | 16 | * GNU General Public License for more details. | ||
978 | 17 | * | ||
979 | 18 | * You should have received a copy of the GNU General Public License | ||
980 | 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
981 | 20 | */ | ||
982 | 21 | // Self | ||
983 | 22 | #include "visibilitycontroller.h" | ||
984 | 23 | |||
985 | 24 | // Local | ||
986 | 25 | #include <autohidebehavior.h> | ||
987 | 26 | #include <forcevisiblebehavior.h> | ||
988 | 27 | #include <intellihidebehavior.h> | ||
989 | 28 | |||
990 | 29 | // unity-2d | ||
991 | 30 | #include <debug_p.h> | ||
992 | 31 | #include <unity2dpanel.h> | ||
993 | 32 | #include <config.h> | ||
994 | 33 | |||
995 | 34 | // Qt | ||
996 | 35 | #include <QDBusConnection> | ||
997 | 36 | #include <QDBusServiceWatcher> | ||
998 | 37 | |||
999 | 38 | VisibilityController::VisibilityController(Unity2dPanel* panel) | ||
1000 | 39 | : QObject(panel) | ||
1001 | 40 | , m_panel(panel) | ||
1002 | 41 | , m_dbusWatcher(new QDBusServiceWatcher(this)) | ||
1003 | 42 | { | ||
1004 | 43 | m_dbusWatcher->setConnection(QDBusConnection::sessionBus()); | ||
1005 | 44 | m_dbusWatcher->setWatchMode(QDBusServiceWatcher::WatchForUnregistration); | ||
1006 | 45 | |||
1007 | 46 | connect(&launcher2dConfiguration(), SIGNAL(hideModeChanged(int)), SLOT(update())); | ||
1008 | 47 | connect(m_panel, SIGNAL(manualSlidingChanged(bool)), SLOT(update())); | ||
1009 | 48 | connect(m_dbusWatcher, SIGNAL(serviceUnregistered(const QString&)), SLOT(slotServiceUnregistered(const QString&))); | ||
1010 | 49 | update(); | ||
1011 | 50 | } | ||
1012 | 51 | |||
1013 | 52 | VisibilityController::~VisibilityController() | ||
1014 | 53 | { | ||
1015 | 54 | } | ||
1016 | 55 | |||
1017 | 56 | void VisibilityController::update(UpdateReason reason) | ||
1018 | 57 | { | ||
1019 | 58 | if (!m_forceVisibleCountHash.isEmpty()) { | ||
1020 | 59 | return; | ||
1021 | 60 | } | ||
1022 | 61 | AutoHideMode mode = AutoHideMode(launcher2dConfiguration().property("hideMode").toInt()); | ||
1023 | 62 | |||
1024 | 63 | setBehavior(0); | ||
1025 | 64 | |||
1026 | 65 | /* Do not use any hiding controller if the panel is being slid manually */ | ||
1027 | 66 | if (!m_panel->manualSliding()) { | ||
1028 | 67 | switch (mode) { | ||
1029 | 68 | case ManualHide: | ||
1030 | 69 | m_panel->setUseStrut(true); | ||
1031 | 70 | m_panel->slideIn(); | ||
1032 | 71 | break; | ||
1033 | 72 | case AutoHide: | ||
1034 | 73 | m_panel->setUseStrut(false); | ||
1035 | 74 | setBehavior(new AutoHideBehavior(m_panel)); | ||
1036 | 75 | break; | ||
1037 | 76 | case IntelliHide: | ||
1038 | 77 | m_panel->setUseStrut(false); | ||
1039 | 78 | setBehavior(new IntelliHideBehavior(m_panel)); | ||
1040 | 79 | if (reason == UpdateFromForceVisibilityEnded && !m_panel->geometry().contains(QCursor::pos())) { | ||
1041 | 80 | // The first thing IntelliHideBehavior does is checking if there is | ||
1042 | 81 | // a window behind the panel, and if there is one, hide the panel immediately | ||
1043 | 82 | // This is correct for some cases, but in the case we come from an update because the | ||
1044 | 83 | // panel is not forced visible anymore and the mouse is not in the panel, | ||
1045 | 84 | // i.e. the launcher was visible and the user clicked in an action of the tile menu, | ||
1046 | 85 | // we should still give the user the wait 1 second before hiding behaviour. | ||
1047 | 86 | // To achieve this we tell the behaviour controller to show the panel | ||
1048 | 87 | // and simulate a mouse leave on the panel to start the hiding timer | ||
1049 | 88 | QMetaObject::invokeMethod(m_behavior.data(), "showPanel"); | ||
1050 | 89 | QEvent e(QEvent::Leave); | ||
1051 | 90 | QCoreApplication::sendEvent(m_panel, &e); | ||
1052 | 91 | } | ||
1053 | 92 | break; | ||
1054 | 93 | } | ||
1055 | 94 | } | ||
1056 | 95 | } | ||
1057 | 96 | |||
1058 | 97 | void VisibilityController::beginForceVisible(const QString& service) | ||
1059 | 98 | { | ||
1060 | 99 | bool wasEmpty = m_forceVisibleCountHash.isEmpty(); | ||
1061 | 100 | if (m_forceVisibleCountHash.contains(service)) { | ||
1062 | 101 | ++m_forceVisibleCountHash[service]; | ||
1063 | 102 | } else { | ||
1064 | 103 | m_forceVisibleCountHash[service] = 1; | ||
1065 | 104 | if (!service.isEmpty()) { | ||
1066 | 105 | m_dbusWatcher->addWatchedService(service); | ||
1067 | 106 | } | ||
1068 | 107 | } | ||
1069 | 108 | if (wasEmpty) { | ||
1070 | 109 | setBehavior(new ForceVisibleBehavior(m_panel)); | ||
1071 | 110 | } | ||
1072 | 111 | } | ||
1073 | 112 | |||
1074 | 113 | void VisibilityController::endForceVisible(const QString& service) | ||
1075 | 114 | { | ||
1076 | 115 | if (m_forceVisibleCountHash.contains(service)) { | ||
1077 | 116 | if (m_forceVisibleCountHash[service] == 1) { | ||
1078 | 117 | m_forceVisibleCountHash.remove(service); | ||
1079 | 118 | m_dbusWatcher->removeWatchedService(service); | ||
1080 | 119 | } else { | ||
1081 | 120 | --m_forceVisibleCountHash[service]; | ||
1082 | 121 | } | ||
1083 | 122 | } else { | ||
1084 | 123 | UQ_WARNING << "Application" << service << "called endForceVisible() more than beginForceVisible()."; | ||
1085 | 124 | } | ||
1086 | 125 | if (m_forceVisibleCountHash.isEmpty()) { | ||
1087 | 126 | update(UpdateFromForceVisibilityEnded); | ||
1088 | 127 | } | ||
1089 | 128 | } | ||
1090 | 129 | |||
1091 | 130 | void VisibilityController::setBehavior(AbstractVisibilityBehavior* behavior) | ||
1092 | 131 | { | ||
1093 | 132 | // This method could be replaced by code calling reset() directly but | ||
1094 | 133 | // having only one point where the behavior is changed makes it easy to log | ||
1095 | 134 | // behavior changes using something like: UQ_VAR(behavior); | ||
1096 | 135 | m_behavior.reset(behavior); | ||
1097 | 136 | if (behavior != NULL) { | ||
1098 | 137 | connect(behavior, SIGNAL(visibleChanged(bool)), SLOT(updatePanelVisibility(bool))); | ||
1099 | 138 | updatePanelVisibility(behavior->visible()); | ||
1100 | 139 | } | ||
1101 | 140 | } | ||
1102 | 141 | |||
1103 | 142 | void VisibilityController::updatePanelVisibility(bool visible) | ||
1104 | 143 | { | ||
1105 | 144 | if (visible) { | ||
1106 | 145 | m_panel->slideIn(); | ||
1107 | 146 | } else { | ||
1108 | 147 | m_panel->slideOut(); | ||
1109 | 148 | } | ||
1110 | 149 | } | ||
1111 | 150 | |||
1112 | 151 | void VisibilityController::slotServiceUnregistered(const QString& service) | ||
1113 | 152 | { | ||
1114 | 153 | if (!m_forceVisibleCountHash.contains(service)) { | ||
1115 | 154 | return; | ||
1116 | 155 | } | ||
1117 | 156 | |||
1118 | 157 | UQ_WARNING << "Application" << service << "quit without calling endForceVisible()."; | ||
1119 | 158 | m_forceVisibleCountHash.remove(service); | ||
1120 | 159 | m_dbusWatcher->removeWatchedService(service); | ||
1121 | 160 | if (m_forceVisibleCountHash.isEmpty()) { | ||
1122 | 161 | update(UpdateFromForceVisibilityEnded); | ||
1123 | 162 | } | ||
1124 | 163 | } | ||
1125 | 164 | 0 | ||
1126 | === removed file 'launcher/app/visibilitycontroller.h' | |||
1127 | --- launcher/app/visibilitycontroller.h 2011-11-24 15:12:00 +0000 | |||
1128 | +++ launcher/app/visibilitycontroller.h 1970-01-01 00:00:00 +0000 | |||
1129 | @@ -1,93 +0,0 @@ | |||
1130 | 1 | /* | ||
1131 | 2 | * This file is part of unity-2d | ||
1132 | 3 | * | ||
1133 | 4 | * Copyright 2011 Canonical Ltd. | ||
1134 | 5 | * | ||
1135 | 6 | * Authors: | ||
1136 | 7 | * - Aurélien Gâteau <aurelien.gateau@canonical.com> | ||
1137 | 8 | * | ||
1138 | 9 | * This program is free software; you can redistribute it and/or modify | ||
1139 | 10 | * it under the terms of the GNU General Public License as published by | ||
1140 | 11 | * the Free Software Foundation; version 3. | ||
1141 | 12 | * | ||
1142 | 13 | * This program is distributed in the hope that it will be useful, | ||
1143 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1144 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1145 | 16 | * GNU General Public License for more details. | ||
1146 | 17 | * | ||
1147 | 18 | * You should have received a copy of the GNU General Public License | ||
1148 | 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1149 | 20 | */ | ||
1150 | 21 | #ifndef VISIBILITYCONTROLLER_H | ||
1151 | 22 | #define VISIBILITYCONTROLLER_H | ||
1152 | 23 | |||
1153 | 24 | // Local | ||
1154 | 25 | |||
1155 | 26 | // Qt | ||
1156 | 27 | #include <QHash> | ||
1157 | 28 | #include <QObject> | ||
1158 | 29 | #include <QScopedPointer> | ||
1159 | 30 | |||
1160 | 31 | class AbstractVisibilityBehavior; | ||
1161 | 32 | class Unity2dPanel; | ||
1162 | 33 | class QDBusServiceWatcher; | ||
1163 | 34 | |||
1164 | 35 | /** | ||
1165 | 36 | * This class monitors the hide_mode dconf key and set up an instance of | ||
1166 | 37 | * AbstractVisibilityBehavior depending on its value | ||
1167 | 38 | * | ||
1168 | 39 | * It also tracks requests for forced visibility: the launcher or another | ||
1169 | 40 | * application (through launcher DBus API) can request the launcher to stay | ||
1170 | 41 | * visible for a while, for example because an application requests attention | ||
1171 | 42 | * or because the dash is visible. This is handled by the beginForceVisible() | ||
1172 | 43 | * and endForceVisible() methods. | ||
1173 | 44 | * | ||
1174 | 45 | * Internally it maintains a refcount-per-app of forced visibility requests so | ||
1175 | 46 | * that it can restore the default mode if an application quits without calling | ||
1176 | 47 | * endForceVisible(). | ||
1177 | 48 | */ | ||
1178 | 49 | class VisibilityController : public QObject | ||
1179 | 50 | { | ||
1180 | 51 | Q_OBJECT | ||
1181 | 52 | public: | ||
1182 | 53 | VisibilityController(Unity2dPanel* panel); | ||
1183 | 54 | ~VisibilityController(); | ||
1184 | 55 | |||
1185 | 56 | /** | ||
1186 | 57 | * Force visibility of the launcher. | ||
1187 | 58 | * service is the dbus service (@see QDBusConnection::baseService()) of the | ||
1188 | 59 | * application which requested forced visibility. It is set to an empty | ||
1189 | 60 | * string for internal requests. | ||
1190 | 61 | */ | ||
1191 | 62 | Q_INVOKABLE void beginForceVisible(const QString& service = QString()); | ||
1192 | 63 | Q_INVOKABLE void endForceVisible(const QString& service = QString()); | ||
1193 | 64 | |||
1194 | 65 | private: | ||
1195 | 66 | enum UpdateReason { | ||
1196 | 67 | RegularUpdate, | ||
1197 | 68 | UpdateFromForceVisibilityEnded | ||
1198 | 69 | }; | ||
1199 | 70 | |||
1200 | 71 | private Q_SLOTS: | ||
1201 | 72 | void update(UpdateReason reason = RegularUpdate); | ||
1202 | 73 | void slotServiceUnregistered(const QString&); | ||
1203 | 74 | void updatePanelVisibility(bool); | ||
1204 | 75 | |||
1205 | 76 | private: | ||
1206 | 77 | enum AutoHideMode { | ||
1207 | 78 | ManualHide, | ||
1208 | 79 | AutoHide, | ||
1209 | 80 | IntelliHide | ||
1210 | 81 | }; | ||
1211 | 82 | Q_DISABLE_COPY(VisibilityController); | ||
1212 | 83 | Unity2dPanel* m_panel; | ||
1213 | 84 | QDBusServiceWatcher* m_dbusWatcher; | ||
1214 | 85 | QScopedPointer<AbstractVisibilityBehavior> m_behavior; | ||
1215 | 86 | |||
1216 | 87 | typedef QHash<QString, int> ForceVisibleCountHash; | ||
1217 | 88 | ForceVisibleCountHash m_forceVisibleCountHash; | ||
1218 | 89 | |||
1219 | 90 | void setBehavior(AbstractVisibilityBehavior*); | ||
1220 | 91 | }; | ||
1221 | 92 | |||
1222 | 93 | #endif /* VISIBILITYCONTROLLER_H */ | ||
1223 | 94 | 0 | ||
1224 | === removed directory 'launcher/artwork' | |||
1225 | === removed file 'launcher/artwork/launcher_arrow_outline_ltr.png' | |||
1226 | 95 | Binary files launcher/artwork/launcher_arrow_outline_ltr.png 2012-02-03 13:48:01 +0000 and launcher/artwork/launcher_arrow_outline_ltr.png 1970-01-01 00:00:00 +0000 differ | 1 | Binary files launcher/artwork/launcher_arrow_outline_ltr.png 2012-02-03 13:48:01 +0000 and launcher/artwork/launcher_arrow_outline_ltr.png 1970-01-01 00:00:00 +0000 differ |
1227 | === removed file 'launcher/launcher.qmlproject' | |||
1228 | --- launcher/launcher.qmlproject 2010-10-12 00:33:09 +0000 | |||
1229 | +++ launcher/launcher.qmlproject 1970-01-01 00:00:00 +0000 | |||
1230 | @@ -1,18 +0,0 @@ | |||
1231 | 1 | /* File generated by QtCreator */ | ||
1232 | 2 | |||
1233 | 3 | import QmlProject 1.0 | ||
1234 | 4 | |||
1235 | 5 | Project { | ||
1236 | 6 | /* Include .qml, .js, and image files from current directory and subdirectories */ | ||
1237 | 7 | QmlFiles { | ||
1238 | 8 | directory: "." | ||
1239 | 9 | } | ||
1240 | 10 | JavaScriptFiles { | ||
1241 | 11 | directory: "." | ||
1242 | 12 | } | ||
1243 | 13 | ImageFiles { | ||
1244 | 14 | directory: "." | ||
1245 | 15 | } | ||
1246 | 16 | /* List of plugin directories passed to QML runtime */ | ||
1247 | 17 | // importPaths: [ "../exampleplugin" ] | ||
1248 | 18 | } | ||
1249 | 19 | 0 | ||
1250 | === removed directory 'launcher/tests' | |||
1251 | === removed file 'launcher/tests/CMakeLists.txt' | |||
1252 | --- launcher/tests/CMakeLists.txt 2011-12-07 12:46:10 +0000 | |||
1253 | +++ launcher/tests/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
1254 | @@ -1,29 +0,0 @@ | |||
1255 | 1 | macro(launcher_tests) | ||
1256 | 2 | set(_test_list "") | ||
1257 | 3 | foreach(_test ${ARGN}) | ||
1258 | 4 | add_test(NAME ${_test} | ||
1259 | 5 | COMMAND /bin/bash ${CMAKE_SOURCE_DIR}/tests/misc/run-with-xvfb.sh ./${_test} | ||
1260 | 6 | ) | ||
1261 | 7 | add_executable(${_test} ${_test}.cpp ${_test}.moc) | ||
1262 | 8 | qt4_generate_moc(${_test}.cpp ${_test}.moc) | ||
1263 | 9 | target_link_libraries(${_test} | ||
1264 | 10 | ${QT_QTTEST_LIBRARIES} | ||
1265 | 11 | uqlauncher | ||
1266 | 12 | ) | ||
1267 | 13 | set(_test_list "${_test_list};${_test}") | ||
1268 | 14 | endforeach(_test) | ||
1269 | 15 | endmacro(launcher_tests) | ||
1270 | 16 | |||
1271 | 17 | include_directories( | ||
1272 | 18 | ${CMAKE_SOURCE_DIR}/tests | ||
1273 | 19 | ${CMAKE_CURRENT_SOURCE_DIR}/../app | ||
1274 | 20 | ${CMAKE_CURRENT_BINARY_DIR} | ||
1275 | 21 | ${QT_QTTEST_INCLUDE_DIR} | ||
1276 | 22 | ${QTGCONF_INCLUDE_DIRS} | ||
1277 | 23 | ) | ||
1278 | 24 | |||
1279 | 25 | launcher_tests( | ||
1280 | 26 | # FIXME: test need a mock dbus object to message with via dbus-test-runner | ||
1281 | 27 | # launcherviewtest | ||
1282 | 28 | ) | ||
1283 | 29 | |||
1284 | 30 | 0 | ||
1285 | === removed file 'launcher/tests/launcherviewtest.cpp' | |||
1286 | --- launcher/tests/launcherviewtest.cpp 2011-11-17 20:10:19 +0000 | |||
1287 | +++ launcher/tests/launcherviewtest.cpp 1970-01-01 00:00:00 +0000 | |||
1288 | @@ -1,42 +0,0 @@ | |||
1289 | 1 | /* | ||
1290 | 2 | * This file is part of unity-2d | ||
1291 | 3 | * | ||
1292 | 4 | * Copyright 2010 Canonical Ltd. | ||
1293 | 5 | * | ||
1294 | 6 | * Authors: | ||
1295 | 7 | * - Aurélien Gâteau <aurelien.gateau@canonical.com> | ||
1296 | 8 | * | ||
1297 | 9 | * This program is free software; you can redistribute it and/or modify | ||
1298 | 10 | * it under the terms of the GNU General Public License as published by | ||
1299 | 11 | * the Free Software Foundation; version 3. | ||
1300 | 12 | * | ||
1301 | 13 | * This program is distributed in the hope that it will be useful, | ||
1302 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1303 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1304 | 16 | * GNU General Public License for more details. | ||
1305 | 17 | * | ||
1306 | 18 | * You should have received a copy of the GNU General Public License | ||
1307 | 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1308 | 20 | */ | ||
1309 | 21 | |||
1310 | 22 | // Local | ||
1311 | 23 | #include <unitytestmacro.h> | ||
1312 | 24 | #include <launcherview.h> | ||
1313 | 25 | |||
1314 | 26 | // Qt | ||
1315 | 27 | #include <QtTestGui> | ||
1316 | 28 | |||
1317 | 29 | class LauncherViewTest : public QObject | ||
1318 | 30 | { | ||
1319 | 31 | Q_OBJECT | ||
1320 | 32 | private Q_SLOTS: | ||
1321 | 33 | void testCreate() | ||
1322 | 34 | { | ||
1323 | 35 | LauncherView view; | ||
1324 | 36 | } | ||
1325 | 37 | }; | ||
1326 | 38 | |||
1327 | 39 | QAPP_TEST_MAIN(LauncherViewTest) | ||
1328 | 40 | |||
1329 | 41 | #include "launcherviewtest.moc" | ||
1330 | 42 | |||
1331 | 43 | 0 | ||
1332 | === modified file 'libunity-2d-private/CMakeLists.txt' | |||
1333 | --- libunity-2d-private/CMakeLists.txt 2011-12-07 13:05:37 +0000 | |||
1334 | +++ libunity-2d-private/CMakeLists.txt 2012-02-09 02:13:26 +0000 | |||
1335 | @@ -10,6 +10,7 @@ | |||
1336 | 10 | pkg_check_modules(UNITYCORE REQUIRED unity-core-5.0) | 10 | pkg_check_modules(UNITYCORE REQUIRED unity-core-5.0) |
1337 | 11 | pkg_check_modules(DEE REQUIRED dee-1.0) | 11 | pkg_check_modules(DEE REQUIRED dee-1.0) |
1338 | 12 | pkg_check_modules(XINPUT REQUIRED xi) | 12 | pkg_check_modules(XINPUT REQUIRED xi) |
1339 | 13 | pkg_check_modules(GEIS REQUIRED libutouch-geis) | ||
1340 | 13 | 14 | ||
1341 | 14 | set(libunity-2d-private_SOVERSION 0) | 15 | set(libunity-2d-private_SOVERSION 0) |
1342 | 15 | set(libunity-2d-private_VERSION ${libunity-2d-private_SOVERSION}.0.0) | 16 | set(libunity-2d-private_VERSION ${libunity-2d-private_SOVERSION}.0.0) |
1343 | 16 | 17 | ||
1344 | === modified file 'libunity-2d-private/Unity2d/CMakeLists.txt' | |||
1345 | --- libunity-2d-private/Unity2d/CMakeLists.txt 2011-11-29 17:17:35 +0000 | |||
1346 | +++ libunity-2d-private/Unity2d/CMakeLists.txt 2012-02-09 02:13:26 +0000 | |||
1347 | @@ -59,7 +59,5 @@ | |||
1348 | 59 | #Allow build in different directory | 59 | #Allow build in different directory |
1349 | 60 | execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/GnomeBackground.qml" | 60 | execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/GnomeBackground.qml" |
1350 | 61 | "${CMAKE_CURRENT_BINARY_DIR}/GnomeBackground.qml") | 61 | "${CMAKE_CURRENT_BINARY_DIR}/GnomeBackground.qml") |
1351 | 62 | execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/AbstractScrollbar.qml" | ||
1352 | 63 | "${CMAKE_CURRENT_BINARY_DIR}/AbstractScrollbar.qml") | ||
1353 | 64 | execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/qmldir" | 62 | execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/qmldir" |
1354 | 65 | "${CMAKE_CURRENT_BINARY_DIR}/qmldir") | 63 | "${CMAKE_CURRENT_BINARY_DIR}/qmldir") |
1355 | 66 | 64 | ||
1356 | === modified file 'libunity-2d-private/Unity2d/plugin.cpp' | |||
1357 | --- libunity-2d-private/Unity2d/plugin.cpp 2012-02-01 13:59:49 +0000 | |||
1358 | +++ libunity-2d-private/Unity2d/plugin.cpp 2012-02-09 02:13:26 +0000 | |||
1359 | @@ -22,6 +22,7 @@ | |||
1360 | 22 | */ | 22 | */ |
1361 | 23 | #include "plugin.h" | 23 | #include "plugin.h" |
1362 | 24 | 24 | ||
1363 | 25 | #include "dashclient.h" | ||
1364 | 25 | #include "launcherapplication.h" | 26 | #include "launcherapplication.h" |
1365 | 26 | #include "launcherdevice.h" | 27 | #include "launcherdevice.h" |
1366 | 27 | #include "trash.h" | 28 | #include "trash.h" |
1367 | @@ -50,12 +51,9 @@ | |||
1368 | 50 | #include "launcherdropitem.h" | 51 | #include "launcherdropitem.h" |
1369 | 51 | 52 | ||
1370 | 52 | #include "config.h" | 53 | #include "config.h" |
1371 | 53 | #include "dashclient.h" | ||
1372 | 54 | 54 | ||
1373 | 55 | #include "autohidebehavior.h" | ||
1374 | 56 | #include "intellihidebehavior.h" | ||
1375 | 57 | #include "forcevisiblebehavior.h" | ||
1376 | 58 | #include "bfb.h" | 55 | #include "bfb.h" |
1377 | 56 | #include "gesturehandler.h" | ||
1378 | 59 | 57 | ||
1379 | 60 | #include "lenses.h" | 58 | #include "lenses.h" |
1380 | 61 | #include "lens.h" | 59 | #include "lens.h" |
1381 | @@ -68,8 +66,17 @@ | |||
1382 | 68 | #include "radiooptionfilter.h" | 66 | #include "radiooptionfilter.h" |
1383 | 69 | #include "checkoptionfilter.h" | 67 | #include "checkoptionfilter.h" |
1384 | 70 | #include "multirangefilter.h" | 68 | #include "multirangefilter.h" |
1385 | 69 | #include "windowsintersectmonitor.h" | ||
1386 | 70 | #include "spreadmonitor.h" | ||
1387 | 71 | #include "focuspath.h" | 71 | #include "focuspath.h" |
1388 | 72 | 72 | ||
1389 | 73 | #include "unity2ddeclarativeview.h" | ||
1390 | 74 | #include "inputshapemanager.h" | ||
1391 | 75 | #include "inputshaperectangle.h" | ||
1392 | 76 | #include "inputshapemask.h" | ||
1393 | 77 | #include "unity2dpanel.h" | ||
1394 | 78 | #include "strutmanager.h" | ||
1395 | 79 | |||
1396 | 73 | #include <QtDeclarative/qdeclarative.h> | 80 | #include <QtDeclarative/qdeclarative.h> |
1397 | 74 | #include <QDeclarativeEngine> | 81 | #include <QDeclarativeEngine> |
1398 | 75 | #include <QDeclarativeContext> | 82 | #include <QDeclarativeContext> |
1399 | @@ -99,6 +106,8 @@ | |||
1400 | 99 | { | 106 | { |
1401 | 100 | qmlRegisterType<QSortFilterProxyModelQML>(uri, 0, 1, "SortFilterProxyModel"); | 107 | qmlRegisterType<QSortFilterProxyModelQML>(uri, 0, 1, "SortFilterProxyModel"); |
1402 | 101 | 108 | ||
1403 | 109 | qmlRegisterType<DashClient>(); | ||
1404 | 110 | |||
1405 | 102 | qmlRegisterType<WindowInfo>(uri, 0, 1, "WindowInfo"); | 111 | qmlRegisterType<WindowInfo>(uri, 0, 1, "WindowInfo"); |
1406 | 103 | qmlRegisterType<WindowsList>(uri, 0, 1, "WindowsList"); | 112 | qmlRegisterType<WindowsList>(uri, 0, 1, "WindowsList"); |
1407 | 104 | qmlRegisterType<ScreenInfo>(uri, 0, 1, "ScreenInfo"); | 113 | qmlRegisterType<ScreenInfo>(uri, 0, 1, "ScreenInfo"); |
1408 | @@ -136,10 +145,6 @@ | |||
1409 | 136 | qmlRegisterType<WorkspacesList>(uri, 0, 1, "WorkspacesList"); | 145 | qmlRegisterType<WorkspacesList>(uri, 0, 1, "WorkspacesList"); |
1410 | 137 | qmlRegisterType<Workspaces>(uri, 0, 1, "Workspaces"); | 146 | qmlRegisterType<Workspaces>(uri, 0, 1, "Workspaces"); |
1411 | 138 | 147 | ||
1412 | 139 | qmlRegisterType<IntelliHideBehavior>(uri, 0, 1, "IntelliHideBehavior"); | ||
1413 | 140 | qmlRegisterType<AutoHideBehavior>(uri, 0, 1, "AutoHideBehavior"); | ||
1414 | 141 | qmlRegisterType<ForceVisibleBehavior>(uri, 0, 1, "ForceVisibleBehavior"); | ||
1415 | 142 | |||
1416 | 143 | qmlRegisterType<IconUtilities>(); // Register the type as non creatable | 148 | qmlRegisterType<IconUtilities>(); // Register the type as non creatable |
1417 | 144 | 149 | ||
1418 | 145 | qmlRegisterType<GioDefaultApplication>(uri, 0, 1, "GioDefaultApplication"); | 150 | qmlRegisterType<GioDefaultApplication>(uri, 0, 1, "GioDefaultApplication"); |
1419 | @@ -160,7 +165,17 @@ | |||
1420 | 160 | qmlRegisterType<FilterOption>(); | 165 | qmlRegisterType<FilterOption>(); |
1421 | 161 | qmlRegisterType<FilterOptions>(); | 166 | qmlRegisterType<FilterOptions>(); |
1422 | 162 | 167 | ||
1424 | 163 | qmlRegisterType<DashClient>(); | 168 | qmlRegisterType<GestureHandler>(uri, 0, 1, "GestureHandler"); |
1425 | 169 | qmlRegisterType<WindowsIntersectMonitor>(uri, 0, 1, "WindowsIntersectMonitor"); | ||
1426 | 170 | qmlRegisterType<SpreadMonitor>(uri, 0, 1, "SpreadMonitor"); | ||
1427 | 171 | |||
1428 | 172 | qmlRegisterType<InputShapeManager>(uri, 0, 1, "InputShapeManager"); | ||
1429 | 173 | qmlRegisterType<InputShapeRectangle>(uri, 0, 1, "InputShapeRectangle"); | ||
1430 | 174 | qmlRegisterType<InputShapeMask>(uri, 0, 1, "InputShapeMask"); | ||
1431 | 175 | qmlRegisterType<Unity2DDeclarativeView>(); | ||
1432 | 176 | |||
1433 | 177 | qmlRegisterType<Unity2dPanel>(uri, 0, 1, "Unity2dPanel"); | ||
1434 | 178 | qmlRegisterType<StrutManager>(uri, 0, 1, "StrutManager"); | ||
1435 | 164 | } | 179 | } |
1436 | 165 | 180 | ||
1437 | 166 | void Unity2dPlugin::initializeEngine(QDeclarativeEngine *engine, const char *uri) | 181 | void Unity2dPlugin::initializeEngine(QDeclarativeEngine *engine, const char *uri) |
1438 | @@ -179,8 +194,9 @@ | |||
1439 | 179 | engine->rootContext()->setContextProperty("iconUtilities", new IconUtilities(engine)); | 194 | engine->rootContext()->setContextProperty("iconUtilities", new IconUtilities(engine)); |
1440 | 180 | 195 | ||
1441 | 181 | /* Expose QConf objects as a context property not to initialize it multiple times */ | 196 | /* Expose QConf objects as a context property not to initialize it multiple times */ |
1442 | 197 | engine->rootContext()->setContextProperty("unity2dConfiguration", &unity2dConfiguration()); | ||
1443 | 198 | engine->rootContext()->setContextProperty("launcher2dConfiguration", &launcher2dConfiguration()); | ||
1444 | 182 | engine->rootContext()->setContextProperty("dash2dConfiguration", &dash2dConfiguration()); | 199 | engine->rootContext()->setContextProperty("dash2dConfiguration", &dash2dConfiguration()); |
1445 | 183 | engine->rootContext()->setContextProperty("dashClient", DashClient::instance()); | ||
1446 | 184 | 200 | ||
1447 | 185 | /* Critically important to set the client type to pager because wnck | 201 | /* Critically important to set the client type to pager because wnck |
1448 | 186 | will pass that type over to the window manager through XEvents. | 202 | will pass that type over to the window manager through XEvents. |
1449 | 187 | 203 | ||
1450 | === modified file 'libunity-2d-private/Unity2d/qmldir' | |||
1451 | --- libunity-2d-private/Unity2d/qmldir 2011-11-29 17:17:35 +0000 | |||
1452 | +++ libunity-2d-private/Unity2d/qmldir 2012-02-09 02:13:26 +0000 | |||
1453 | @@ -1,4 +1,3 @@ | |||
1454 | 1 | plugin unity-2d-private-qml | 1 | plugin unity-2d-private-qml |
1455 | 2 | 2 | ||
1456 | 3 | GnomeBackground 1.0 GnomeBackground.qml | 3 | GnomeBackground 1.0 GnomeBackground.qml |
1457 | 4 | AbstractScrollbar 1.0 AbstractScrollbar.qml | ||
1458 | 5 | 4 | ||
1459 | === modified file 'libunity-2d-private/src/CMakeLists.txt' | |||
1460 | --- libunity-2d-private/src/CMakeLists.txt 2012-01-31 15:09:02 +0000 | |||
1461 | +++ libunity-2d-private/src/CMakeLists.txt 2012-02-09 02:13:26 +0000 | |||
1462 | @@ -13,7 +13,6 @@ | |||
1463 | 13 | hotkey.cpp | 13 | hotkey.cpp |
1464 | 14 | keymonitor.cpp | 14 | keymonitor.cpp |
1465 | 15 | launcherclient.cpp | 15 | launcherclient.cpp |
1466 | 16 | mousearea.cpp | ||
1467 | 17 | unity2dapplication.cpp | 16 | unity2dapplication.cpp |
1468 | 18 | unity2ddebug.cpp | 17 | unity2ddebug.cpp |
1469 | 19 | unity2dpanel.cpp | 18 | unity2dpanel.cpp |
1470 | @@ -22,11 +21,7 @@ | |||
1471 | 22 | mimedata.cpp | 21 | mimedata.cpp |
1472 | 23 | dragdropevent.cpp | 22 | dragdropevent.cpp |
1473 | 24 | propertybinder.cpp | 23 | propertybinder.cpp |
1479 | 25 | abstractvisibilitybehavior.cpp | 24 | gesturehandler.cpp |
1475 | 26 | autohidebehavior.cpp | ||
1476 | 27 | edgehitdetector.cpp | ||
1477 | 28 | forcevisiblebehavior.cpp | ||
1478 | 29 | intellihidebehavior.cpp | ||
1480 | 30 | giodefaultapplication.cpp | 25 | giodefaultapplication.cpp |
1481 | 31 | qsortfilterproxymodelqml.cpp | 26 | qsortfilterproxymodelqml.cpp |
1482 | 32 | blendedimageprovider.cpp | 27 | blendedimageprovider.cpp |
1483 | @@ -72,7 +67,14 @@ | |||
1484 | 72 | panelapplet.cpp | 67 | panelapplet.cpp |
1485 | 73 | panelstyle.cpp | 68 | panelstyle.cpp |
1486 | 74 | percentcoder.cpp | 69 | percentcoder.cpp |
1487 | 70 | windowsintersectmonitor.cpp | ||
1488 | 71 | abstractdbusservicemonitor.cpp | ||
1489 | 72 | spreadmonitor.cpp | ||
1490 | 75 | focuspath.cpp | 73 | focuspath.cpp |
1491 | 74 | inputshapemanager.cpp | ||
1492 | 75 | inputshaperectangle.cpp | ||
1493 | 76 | inputshapemask.cpp | ||
1494 | 77 | strutmanager.cpp | ||
1495 | 76 | ) | 78 | ) |
1496 | 77 | 79 | ||
1497 | 78 | # Build | 80 | # Build |
1498 | @@ -100,6 +102,7 @@ | |||
1499 | 100 | ${NUXCORE_INCLUDE_DIRS} | 102 | ${NUXCORE_INCLUDE_DIRS} |
1500 | 101 | ${DEE_INCLUDE_DIRS} | 103 | ${DEE_INCLUDE_DIRS} |
1501 | 102 | ${XINPUT_INCLUDE_DIRS} | 104 | ${XINPUT_INCLUDE_DIRS} |
1502 | 105 | ${GEIS_INCLUDE_DIRS} | ||
1503 | 103 | ) | 106 | ) |
1504 | 104 | 107 | ||
1505 | 105 | add_library(${LIB_NAME} SHARED ${libunity-2d-private_SRCS} listmodelwrapper.h) | 108 | add_library(${LIB_NAME} SHARED ${libunity-2d-private_SRCS} listmodelwrapper.h) |
1506 | @@ -135,6 +138,7 @@ | |||
1507 | 135 | ${NUXCORE_LDFLAGS} | 138 | ${NUXCORE_LDFLAGS} |
1508 | 136 | ${DEE_LDFLAGS} | 139 | ${DEE_LDFLAGS} |
1509 | 137 | ${XINPUT_LDFLAGS} | 140 | ${XINPUT_LDFLAGS} |
1510 | 141 | ${GEIS_LDFLAGS} | ||
1511 | 138 | ) | 142 | ) |
1512 | 139 | 143 | ||
1513 | 140 | # Install | 144 | # Install |
1514 | 141 | 145 | ||
1515 | === added file 'libunity-2d-private/src/abstractdbusservicemonitor.cpp' | |||
1516 | --- libunity-2d-private/src/abstractdbusservicemonitor.cpp 1970-01-01 00:00:00 +0000 | |||
1517 | +++ libunity-2d-private/src/abstractdbusservicemonitor.cpp 2012-02-09 02:13:26 +0000 | |||
1518 | @@ -0,0 +1,86 @@ | |||
1519 | 1 | /* | ||
1520 | 2 | * Copyright (C) 2011 Canonical, Ltd. | ||
1521 | 3 | * | ||
1522 | 4 | * Authors: | ||
1523 | 5 | * Ugo Riboni <ugo.riboni@canonical.com> | ||
1524 | 6 | * | ||
1525 | 7 | * This program is free software; you can redistribute it and/or modify | ||
1526 | 8 | * it under the terms of the GNU General Public License as published by | ||
1527 | 9 | * the Free Software Foundation; version 3. | ||
1528 | 10 | * | ||
1529 | 11 | * This program is distributed in the hope that it will be useful, | ||
1530 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1531 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1532 | 14 | * GNU General Public License for more details. | ||
1533 | 15 | * | ||
1534 | 16 | * You should have received a copy of the GNU General Public License | ||
1535 | 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1536 | 18 | */ | ||
1537 | 19 | |||
1538 | 20 | #include "abstractdbusservicemonitor.h" | ||
1539 | 21 | |||
1540 | 22 | #include <QDBusConnection> | ||
1541 | 23 | #include <QDBusConnectionInterface> | ||
1542 | 24 | #include <QDBusReply> | ||
1543 | 25 | |||
1544 | 26 | AbstractDBusServiceMonitor::AbstractDBusServiceMonitor(QString service, QString path, | ||
1545 | 27 | QString interface, QObject *parent) | ||
1546 | 28 | : QObject(parent) | ||
1547 | 29 | , m_service(service) | ||
1548 | 30 | , m_path(path) | ||
1549 | 31 | , m_interface(interface) | ||
1550 | 32 | , m_watcher(new QDBusServiceWatcher(service, QDBusConnection::sessionBus())) | ||
1551 | 33 | , m_dbusInterface(0) | ||
1552 | 34 | { | ||
1553 | 35 | connect(m_watcher, SIGNAL(serviceRegistered(QString)), SLOT(createInterface())); | ||
1554 | 36 | connect(m_watcher, SIGNAL(serviceUnregistered(QString)), SLOT(destroyInterface())); | ||
1555 | 37 | |||
1556 | 38 | // Connect to the service if it's up already | ||
1557 | 39 | QDBusConnectionInterface* sessionBus = QDBusConnection::sessionBus().interface(); | ||
1558 | 40 | QDBusReply<bool> reply = sessionBus->isServiceRegistered(m_service); | ||
1559 | 41 | if (reply.isValid() && reply.value()) { | ||
1560 | 42 | createInterface(); | ||
1561 | 43 | } | ||
1562 | 44 | } | ||
1563 | 45 | |||
1564 | 46 | AbstractDBusServiceMonitor::~AbstractDBusServiceMonitor() | ||
1565 | 47 | { | ||
1566 | 48 | delete m_watcher; | ||
1567 | 49 | if (m_dbusInterface) { | ||
1568 | 50 | delete m_dbusInterface; | ||
1569 | 51 | } | ||
1570 | 52 | } | ||
1571 | 53 | |||
1572 | 54 | void AbstractDBusServiceMonitor::createInterface() | ||
1573 | 55 | { | ||
1574 | 56 | if (m_dbusInterface != 0) { | ||
1575 | 57 | delete m_dbusInterface; | ||
1576 | 58 | m_dbusInterface = 0; | ||
1577 | 59 | } | ||
1578 | 60 | |||
1579 | 61 | m_dbusInterface = new QDBusInterface(m_service, m_path, m_interface, | ||
1580 | 62 | QDBusConnection::sessionBus()); | ||
1581 | 63 | Q_EMIT serviceAvailableChanged(true); | ||
1582 | 64 | } | ||
1583 | 65 | |||
1584 | 66 | void AbstractDBusServiceMonitor::destroyInterface() | ||
1585 | 67 | { | ||
1586 | 68 | if (m_dbusInterface != 0) { | ||
1587 | 69 | delete m_dbusInterface; | ||
1588 | 70 | m_dbusInterface = 0; | ||
1589 | 71 | } | ||
1590 | 72 | |||
1591 | 73 | Q_EMIT serviceAvailableChanged(false); | ||
1592 | 74 | } | ||
1593 | 75 | |||
1594 | 76 | QDBusInterface* AbstractDBusServiceMonitor::dbusInterface() const | ||
1595 | 77 | { | ||
1596 | 78 | return m_dbusInterface; | ||
1597 | 79 | } | ||
1598 | 80 | |||
1599 | 81 | bool AbstractDBusServiceMonitor::serviceAvailable() const | ||
1600 | 82 | { | ||
1601 | 83 | return m_dbusInterface != 0; | ||
1602 | 84 | } | ||
1603 | 85 | |||
1604 | 86 | #include "abstractdbusservicemonitor.moc" | ||
1605 | 0 | 87 | ||
1606 | === added file 'libunity-2d-private/src/abstractdbusservicemonitor.h' | |||
1607 | --- libunity-2d-private/src/abstractdbusservicemonitor.h 1970-01-01 00:00:00 +0000 | |||
1608 | +++ libunity-2d-private/src/abstractdbusservicemonitor.h 2012-02-09 02:13:26 +0000 | |||
1609 | @@ -0,0 +1,59 @@ | |||
1610 | 1 | /* | ||
1611 | 2 | * Copyright (C) 2011 Canonical, Ltd. | ||
1612 | 3 | * | ||
1613 | 4 | * Authors: | ||
1614 | 5 | * Ugo Riboni <ugo.riboni@canonical.com> | ||
1615 | 6 | * | ||
1616 | 7 | * This program is free software; you can redistribute it and/or modify | ||
1617 | 8 | * it under the terms of the GNU General Public License as published by | ||
1618 | 9 | * the Free Software Foundation; version 3. | ||
1619 | 10 | * | ||
1620 | 11 | * This program is distributed in the hope that it will be useful, | ||
1621 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1622 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1623 | 14 | * GNU General Public License for more details. | ||
1624 | 15 | * | ||
1625 | 16 | * You should have received a copy of the GNU General Public License | ||
1626 | 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1627 | 18 | */ | ||
1628 | 19 | |||
1629 | 20 | #ifndef ABSTRACTDBUSSERVICEMONITOR_H | ||
1630 | 21 | #define ABSTRACTDBUSSERVICEMONITOR_H | ||
1631 | 22 | |||
1632 | 23 | #include <QObject> | ||
1633 | 24 | |||
1634 | 25 | #include <QDBusInterface> | ||
1635 | 26 | #include <QDBusServiceWatcher> | ||
1636 | 27 | #include <QObject> | ||
1637 | 28 | #include <QString> | ||
1638 | 29 | |||
1639 | 30 | class AbstractDBusServiceMonitor : public QObject | ||
1640 | 31 | { | ||
1641 | 32 | Q_OBJECT | ||
1642 | 33 | Q_PROPERTY(bool serviceAvailable READ serviceAvailable NOTIFY serviceAvailableChanged) | ||
1643 | 34 | |||
1644 | 35 | public: | ||
1645 | 36 | explicit AbstractDBusServiceMonitor(QString service, QString path, QString interface, | ||
1646 | 37 | QObject *parent = 0); | ||
1647 | 38 | ~AbstractDBusServiceMonitor(); | ||
1648 | 39 | |||
1649 | 40 | QDBusInterface* dbusInterface() const; | ||
1650 | 41 | |||
1651 | 42 | bool serviceAvailable() const; | ||
1652 | 43 | |||
1653 | 44 | Q_SIGNALS: | ||
1654 | 45 | void serviceAvailableChanged(bool available); | ||
1655 | 46 | |||
1656 | 47 | private Q_SLOTS: | ||
1657 | 48 | void createInterface(); | ||
1658 | 49 | void destroyInterface(); | ||
1659 | 50 | |||
1660 | 51 | protected: | ||
1661 | 52 | QString m_service; | ||
1662 | 53 | QString m_path; | ||
1663 | 54 | QString m_interface; | ||
1664 | 55 | QDBusServiceWatcher* m_watcher; | ||
1665 | 56 | QDBusInterface* m_dbusInterface; | ||
1666 | 57 | }; | ||
1667 | 58 | |||
1668 | 59 | #endif // ABSTRACTDBUSSERVICEMONITOR_H | ||
1669 | 0 | 60 | ||
1670 | === removed file 'libunity-2d-private/src/abstractvisibilitybehavior.cpp' | |||
1671 | --- libunity-2d-private/src/abstractvisibilitybehavior.cpp 2011-06-11 11:33:52 +0000 | |||
1672 | +++ libunity-2d-private/src/abstractvisibilitybehavior.cpp 1970-01-01 00:00:00 +0000 | |||
1673 | @@ -1,59 +0,0 @@ | |||
1674 | 1 | /* | ||
1675 | 2 | * This file is part of unity-2d | ||
1676 | 3 | * | ||
1677 | 4 | * Copyright 2011 Canonical Ltd. | ||
1678 | 5 | * | ||
1679 | 6 | * Authors: | ||
1680 | 7 | * - Aurélien Gâteau <aurelien.gateau@canonical.com> | ||
1681 | 8 | * - Florian Boucault <florian.boucault@canonical.com> | ||
1682 | 9 | * | ||
1683 | 10 | * This program is free software; you can redistribute it and/or modify | ||
1684 | 11 | * it under the terms of the GNU General Public License as published by | ||
1685 | 12 | * the Free Software Foundation; version 3. | ||
1686 | 13 | * | ||
1687 | 14 | * This program is distributed in the hope that it will be useful, | ||
1688 | 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1689 | 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1690 | 17 | * GNU General Public License for more details. | ||
1691 | 18 | * | ||
1692 | 19 | * You should have received a copy of the GNU General Public License | ||
1693 | 20 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1694 | 21 | */ | ||
1695 | 22 | // Self | ||
1696 | 23 | #include "abstractvisibilitybehavior.h" | ||
1697 | 24 | |||
1698 | 25 | // Local | ||
1699 | 26 | |||
1700 | 27 | // libunity-2d | ||
1701 | 28 | |||
1702 | 29 | // Qt | ||
1703 | 30 | #include <QWidget> | ||
1704 | 31 | |||
1705 | 32 | AbstractVisibilityBehavior::AbstractVisibilityBehavior(QWidget* panel) | ||
1706 | 33 | : QObject(panel) | ||
1707 | 34 | , m_panel(panel) | ||
1708 | 35 | , m_visible(true) | ||
1709 | 36 | { | ||
1710 | 37 | } | ||
1711 | 38 | |||
1712 | 39 | AbstractVisibilityBehavior::~AbstractVisibilityBehavior() | ||
1713 | 40 | { | ||
1714 | 41 | } | ||
1715 | 42 | |||
1716 | 43 | bool AbstractVisibilityBehavior::visible() const | ||
1717 | 44 | { | ||
1718 | 45 | return m_visible; | ||
1719 | 46 | } | ||
1720 | 47 | |||
1721 | 48 | QWidget* AbstractVisibilityBehavior::panel() const | ||
1722 | 49 | { | ||
1723 | 50 | return m_panel; | ||
1724 | 51 | } | ||
1725 | 52 | |||
1726 | 53 | void AbstractVisibilityBehavior::setPanel(QWidget* panel) | ||
1727 | 54 | { | ||
1728 | 55 | m_panel = panel; | ||
1729 | 56 | Q_EMIT panelChanged(m_panel); | ||
1730 | 57 | } | ||
1731 | 58 | |||
1732 | 59 | #include "abstractvisibilitybehavior.moc" | ||
1733 | 60 | 0 | ||
1734 | === removed file 'libunity-2d-private/src/abstractvisibilitybehavior.h' | |||
1735 | --- libunity-2d-private/src/abstractvisibilitybehavior.h 2011-06-11 11:33:52 +0000 | |||
1736 | +++ libunity-2d-private/src/abstractvisibilitybehavior.h 1970-01-01 00:00:00 +0000 | |||
1737 | @@ -1,63 +0,0 @@ | |||
1738 | 1 | /* | ||
1739 | 2 | * This file is part of unity-2d | ||
1740 | 3 | * | ||
1741 | 4 | * Copyright 2011 Canonical Ltd. | ||
1742 | 5 | * | ||
1743 | 6 | * Authors: | ||
1744 | 7 | * - Aurélien Gâteau <aurelien.gateau@canonical.com> | ||
1745 | 8 | * - Florian Boucault <florian.boucault@canonical.com> | ||
1746 | 9 | * | ||
1747 | 10 | * This program is free software; you can redistribute it and/or modify | ||
1748 | 11 | * it under the terms of the GNU General Public License as published by | ||
1749 | 12 | * the Free Software Foundation; version 3. | ||
1750 | 13 | * | ||
1751 | 14 | * This program is distributed in the hope that it will be useful, | ||
1752 | 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1753 | 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1754 | 17 | * GNU General Public License for more details. | ||
1755 | 18 | * | ||
1756 | 19 | * You should have received a copy of the GNU General Public License | ||
1757 | 20 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1758 | 21 | */ | ||
1759 | 22 | #ifndef ABSTRACTVISIBILITYBEHAVIOR_H | ||
1760 | 23 | #define ABSTRACTVISIBILITYBEHAVIOR_H | ||
1761 | 24 | |||
1762 | 25 | // Local | ||
1763 | 26 | |||
1764 | 27 | // Qt | ||
1765 | 28 | #include <QObject> | ||
1766 | 29 | |||
1767 | 30 | class QWidget; | ||
1768 | 31 | |||
1769 | 32 | /** | ||
1770 | 33 | * Base class for various visibility behaviors. | ||
1771 | 34 | * | ||
1772 | 35 | */ | ||
1773 | 36 | class AbstractVisibilityBehavior : public QObject | ||
1774 | 37 | { | ||
1775 | 38 | Q_OBJECT | ||
1776 | 39 | |||
1777 | 40 | Q_PROPERTY(bool visible READ visible NOTIFY visibleChanged) | ||
1778 | 41 | Q_PROPERTY(QWidget* panel READ panel WRITE setPanel NOTIFY panelChanged) | ||
1779 | 42 | |||
1780 | 43 | public: | ||
1781 | 44 | AbstractVisibilityBehavior(QWidget* panel=0); | ||
1782 | 45 | ~AbstractVisibilityBehavior(); | ||
1783 | 46 | |||
1784 | 47 | // getters | ||
1785 | 48 | bool visible() const; | ||
1786 | 49 | QWidget* panel() const; | ||
1787 | 50 | |||
1788 | 51 | // setters | ||
1789 | 52 | void setPanel(QWidget* panel); | ||
1790 | 53 | |||
1791 | 54 | Q_SIGNALS: | ||
1792 | 55 | void visibleChanged(bool visible); | ||
1793 | 56 | void panelChanged(QWidget* panel); | ||
1794 | 57 | |||
1795 | 58 | protected: | ||
1796 | 59 | QWidget* m_panel; | ||
1797 | 60 | bool m_visible; | ||
1798 | 61 | }; | ||
1799 | 62 | |||
1800 | 63 | #endif /* ABSTRACTVISIBILITYBEHAVIOR_H */ | ||
1801 | 64 | 0 | ||
1802 | === removed file 'libunity-2d-private/src/autohidebehavior.cpp' | |||
1803 | --- libunity-2d-private/src/autohidebehavior.cpp 2011-12-01 12:22:18 +0000 | |||
1804 | +++ libunity-2d-private/src/autohidebehavior.cpp 1970-01-01 00:00:00 +0000 | |||
1805 | @@ -1,143 +0,0 @@ | |||
1806 | 1 | /* | ||
1807 | 2 | * This file is part of unity-2d | ||
1808 | 3 | * | ||
1809 | 4 | * Copyright 2011 Canonical Ltd. | ||
1810 | 5 | * | ||
1811 | 6 | * Authors: | ||
1812 | 7 | * - Aurélien Gâteau <aurelien.gateau@canonical.com> | ||
1813 | 8 | * - Florian Boucault <florian.boucault@canonical.com> | ||
1814 | 9 | * | ||
1815 | 10 | * This program is free software; you can redistribute it and/or modify | ||
1816 | 11 | * it under the terms of the GNU General Public License as published by | ||
1817 | 12 | * the Free Software Foundation; version 3. | ||
1818 | 13 | * | ||
1819 | 14 | * This program is distributed in the hope that it will be useful, | ||
1820 | 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1821 | 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1822 | 17 | * GNU General Public License for more details. | ||
1823 | 18 | * | ||
1824 | 19 | * You should have received a copy of the GNU General Public License | ||
1825 | 20 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1826 | 21 | */ | ||
1827 | 22 | // Self | ||
1828 | 23 | #include "autohidebehavior.h" | ||
1829 | 24 | |||
1830 | 25 | // Local | ||
1831 | 26 | #include <edgehitdetector.h> | ||
1832 | 27 | |||
1833 | 28 | // libunity-2d | ||
1834 | 29 | #include <debug_p.h> | ||
1835 | 30 | |||
1836 | 31 | // Qt | ||
1837 | 32 | #include <QCursor> | ||
1838 | 33 | #include <QTimer> | ||
1839 | 34 | #include <QWidget> | ||
1840 | 35 | |||
1841 | 36 | // libwnck | ||
1842 | 37 | extern "C" { | ||
1843 | 38 | #define WNCK_I_KNOW_THIS_IS_UNSTABLE | ||
1844 | 39 | #include <libwnck/libwnck.h> | ||
1845 | 40 | } | ||
1846 | 41 | |||
1847 | 42 | static const int AUTOHIDE_TIMEOUT = 1000; | ||
1848 | 43 | |||
1849 | 44 | #define GOBJECT_CALLBACK0(callbackName, slot) \ | ||
1850 | 45 | static void \ | ||
1851 | 46 | callbackName(GObject* src, QObject* dst) \ | ||
1852 | 47 | { \ | ||
1853 | 48 | QMetaObject::invokeMethod(dst, slot); \ | ||
1854 | 49 | } | ||
1855 | 50 | |||
1856 | 51 | GOBJECT_CALLBACK0(showingDesktopChangedCB, "onShowingDesktopChanged"); | ||
1857 | 52 | |||
1858 | 53 | AutoHideBehavior::AutoHideBehavior(QWidget* panel) | ||
1859 | 54 | : AbstractVisibilityBehavior(panel) | ||
1860 | 55 | , m_autohideTimer(new QTimer(this)) | ||
1861 | 56 | , m_edgeHitDetector(0) | ||
1862 | 57 | { | ||
1863 | 58 | m_autohideTimer->setSingleShot(true); | ||
1864 | 59 | m_autohideTimer->setInterval(AUTOHIDE_TIMEOUT); | ||
1865 | 60 | connect(m_autohideTimer, SIGNAL(timeout()), SLOT(hidePanel())); | ||
1866 | 61 | |||
1867 | 62 | setPanel(panel); | ||
1868 | 63 | |||
1869 | 64 | WnckScreen* screen = wnck_screen_get_default(); | ||
1870 | 65 | g_signal_connect(G_OBJECT(screen), "showing_desktop_changed", G_CALLBACK(showingDesktopChangedCB), this); | ||
1871 | 66 | } | ||
1872 | 67 | |||
1873 | 68 | AutoHideBehavior::~AutoHideBehavior() | ||
1874 | 69 | { | ||
1875 | 70 | WnckScreen* screen = wnck_screen_get_default(); | ||
1876 | 71 | g_signal_handlers_disconnect_by_func(G_OBJECT(screen), gpointer(showingDesktopChangedCB), this); | ||
1877 | 72 | } | ||
1878 | 73 | |||
1879 | 74 | bool AutoHideBehavior::eventFilter(QObject*, QEvent* event) | ||
1880 | 75 | { | ||
1881 | 76 | switch (event->type()) { | ||
1882 | 77 | case QEvent::Enter: | ||
1883 | 78 | m_autohideTimer->stop(); | ||
1884 | 79 | m_visible = true; | ||
1885 | 80 | Q_EMIT visibleChanged(m_visible); | ||
1886 | 81 | break; | ||
1887 | 82 | case QEvent::Leave: | ||
1888 | 83 | m_autohideTimer->start(); | ||
1889 | 84 | break; | ||
1890 | 85 | default: | ||
1891 | 86 | break; | ||
1892 | 87 | } | ||
1893 | 88 | return false; | ||
1894 | 89 | } | ||
1895 | 90 | |||
1896 | 91 | void AutoHideBehavior::hidePanel() | ||
1897 | 92 | { | ||
1898 | 93 | m_visible = false; | ||
1899 | 94 | Q_EMIT visibleChanged(m_visible); | ||
1900 | 95 | createEdgeHitDetector(); | ||
1901 | 96 | } | ||
1902 | 97 | |||
1903 | 98 | void AutoHideBehavior::showPanel() | ||
1904 | 99 | { | ||
1905 | 100 | // Delete the mouse area so that it does not prevent mouse events from | ||
1906 | 101 | // reaching the panel | ||
1907 | 102 | delete m_edgeHitDetector; | ||
1908 | 103 | m_edgeHitDetector = 0; | ||
1909 | 104 | m_autohideTimer->stop(); | ||
1910 | 105 | m_visible = true; | ||
1911 | 106 | Q_EMIT visibleChanged(m_visible); | ||
1912 | 107 | } | ||
1913 | 108 | |||
1914 | 109 | void AutoHideBehavior::onShowingDesktopChanged() | ||
1915 | 110 | { | ||
1916 | 111 | WnckScreen* screen = wnck_screen_get_default(); | ||
1917 | 112 | gboolean isShowingDesktop = wnck_screen_get_showing_desktop(screen); | ||
1918 | 113 | if (isShowingDesktop) { | ||
1919 | 114 | showPanel(); | ||
1920 | 115 | m_autohideTimer->start(); | ||
1921 | 116 | } else { | ||
1922 | 117 | hidePanel(); | ||
1923 | 118 | } | ||
1924 | 119 | } | ||
1925 | 120 | |||
1926 | 121 | |||
1927 | 122 | void AutoHideBehavior::createEdgeHitDetector() | ||
1928 | 123 | { | ||
1929 | 124 | m_edgeHitDetector = new EdgeHitDetector(this); | ||
1930 | 125 | connect(m_edgeHitDetector, SIGNAL(edgeHit()), SLOT(showPanel())); | ||
1931 | 126 | } | ||
1932 | 127 | |||
1933 | 128 | |||
1934 | 129 | void AutoHideBehavior::setPanel(QWidget *panel) | ||
1935 | 130 | { | ||
1936 | 131 | if (m_panel != NULL) { | ||
1937 | 132 | m_panel->removeEventFilter(this); | ||
1938 | 133 | } | ||
1939 | 134 | AbstractVisibilityBehavior::setPanel(panel); | ||
1940 | 135 | if (m_panel != NULL) { | ||
1941 | 136 | m_panel->installEventFilter(this); | ||
1942 | 137 | if (!m_panel->geometry().contains(QCursor::pos())) { | ||
1943 | 138 | m_autohideTimer->start(); | ||
1944 | 139 | } | ||
1945 | 140 | } | ||
1946 | 141 | } | ||
1947 | 142 | |||
1948 | 143 | #include "autohidebehavior.moc" | ||
1949 | 144 | 0 | ||
1950 | === removed file 'libunity-2d-private/src/autohidebehavior.h' | |||
1951 | --- libunity-2d-private/src/autohidebehavior.h 2011-12-01 12:22:18 +0000 | |||
1952 | +++ libunity-2d-private/src/autohidebehavior.h 1970-01-01 00:00:00 +0000 | |||
1953 | @@ -1,69 +0,0 @@ | |||
1954 | 1 | /* | ||
1955 | 2 | * This file is part of unity-2d | ||
1956 | 3 | * | ||
1957 | 4 | * Copyright 2011 Canonical Ltd. | ||
1958 | 5 | * | ||
1959 | 6 | * Authors: | ||
1960 | 7 | * - Aurélien Gâteau <aurelien.gateau@canonical.com> | ||
1961 | 8 | * - Florian Boucault <florian.boucault@canonical.com> | ||
1962 | 9 | * | ||
1963 | 10 | * This program is free software; you can redistribute it and/or modify | ||
1964 | 11 | * it under the terms of the GNU General Public License as published by | ||
1965 | 12 | * the Free Software Foundation; version 3. | ||
1966 | 13 | * | ||
1967 | 14 | * This program is distributed in the hope that it will be useful, | ||
1968 | 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1969 | 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1970 | 17 | * GNU General Public License for more details. | ||
1971 | 18 | * | ||
1972 | 19 | * You should have received a copy of the GNU General Public License | ||
1973 | 20 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1974 | 21 | */ | ||
1975 | 22 | #ifndef AUTOHIDEBEHAVIOR_H | ||
1976 | 23 | #define AUTOHIDEBEHAVIOR_H | ||
1977 | 24 | |||
1978 | 25 | // Local | ||
1979 | 26 | #include <abstractvisibilitybehavior.h> | ||
1980 | 27 | |||
1981 | 28 | // Qt | ||
1982 | 29 | #include <QObject> | ||
1983 | 30 | |||
1984 | 31 | class EdgeHitDetector; | ||
1985 | 32 | class QTimer; | ||
1986 | 33 | class QWidget; | ||
1987 | 34 | |||
1988 | 35 | /** | ||
1989 | 36 | * This class implements the classic autohide-on-timeout behavior | ||
1990 | 37 | */ | ||
1991 | 38 | class AutoHideBehavior : public AbstractVisibilityBehavior | ||
1992 | 39 | { | ||
1993 | 40 | Q_OBJECT | ||
1994 | 41 | |||
1995 | 42 | Q_PROPERTY(QWidget* panel READ panel WRITE setPanel NOTIFY panelChanged) | ||
1996 | 43 | |||
1997 | 44 | public: | ||
1998 | 45 | AutoHideBehavior(QWidget* panel=0); | ||
1999 | 46 | ~AutoHideBehavior(); | ||
2000 | 47 | |||
2001 | 48 | // setters | ||
2002 | 49 | void setPanel(QWidget *panel); | ||
2003 | 50 | |||
2004 | 51 | Q_SIGNALS: | ||
2005 | 52 | void panelChanged(QWidget *panel); | ||
2006 | 53 | |||
2007 | 54 | protected: | ||
2008 | 55 | bool eventFilter(QObject*, QEvent*); | ||
2009 | 56 | |||
2010 | 57 | private Q_SLOTS: | ||
2011 | 58 | void hidePanel(); | ||
2012 | 59 | void showPanel(); | ||
2013 | 60 | void onShowingDesktopChanged(); | ||
2014 | 61 | |||
2015 | 62 | private: | ||
2016 | 63 | QTimer* m_autohideTimer; | ||
2017 | 64 | EdgeHitDetector* m_edgeHitDetector; | ||
2018 | 65 | |||
2019 | 66 | void createEdgeHitDetector(); | ||
2020 | 67 | }; | ||
2021 | 68 | |||
2022 | 69 | #endif /* AUTOHIDEBEHAVIOR_H */ | ||
2023 | 70 | 0 | ||
2024 | === modified file 'libunity-2d-private/src/bfb.cpp' | |||
2025 | --- libunity-2d-private/src/bfb.cpp 2011-12-09 13:46:10 +0000 | |||
2026 | +++ libunity-2d-private/src/bfb.cpp 2012-02-09 02:13:26 +0000 | |||
2027 | @@ -21,17 +21,14 @@ | |||
2028 | 21 | #include "bfb.h" | 21 | #include "bfb.h" |
2029 | 22 | 22 | ||
2030 | 23 | // libunity-2d | 23 | // libunity-2d |
2031 | 24 | #include <dashclient.h> | ||
2032 | 25 | #include <debug_p.h> | 24 | #include <debug_p.h> |
2033 | 26 | #include <unity2dtr.h> | 25 | #include <unity2dtr.h> |
2034 | 27 | 26 | ||
2035 | 28 | // Qt | 27 | // Qt |
2036 | 29 | 28 | ||
2037 | 30 | BfbItem::BfbItem() | 29 | BfbItem::BfbItem() |
2039 | 31 | : m_active(false) | 30 | : m_active(false), m_view(NULL) |
2040 | 32 | { | 31 | { |
2041 | 33 | connect(DashClient::instance(), SIGNAL(activePageChanged(const QString&)), | ||
2042 | 34 | SLOT(slotActivePageChanged(const QString&))); | ||
2043 | 35 | } | 32 | } |
2044 | 36 | 33 | ||
2045 | 37 | BfbItem::~BfbItem() | 34 | BfbItem::~BfbItem() |
2046 | @@ -43,15 +40,6 @@ | |||
2047 | 43 | return m_active; | 40 | return m_active; |
2048 | 44 | } | 41 | } |
2049 | 45 | 42 | ||
2050 | 46 | void BfbItem::slotActivePageChanged(const QString& page) | ||
2051 | 47 | { | ||
2052 | 48 | bool active = !page.isEmpty(); | ||
2053 | 49 | if (m_active != active) { | ||
2054 | 50 | m_active = active; | ||
2055 | 51 | activeChanged(m_active); | ||
2056 | 52 | } | ||
2057 | 53 | } | ||
2058 | 54 | |||
2059 | 55 | bool BfbItem::running() const | 43 | bool BfbItem::running() const |
2060 | 56 | { | 44 | { |
2061 | 57 | return false; | 45 | return false; |
2062 | @@ -82,15 +70,42 @@ | |||
2063 | 82 | return false; | 70 | return false; |
2064 | 83 | } | 71 | } |
2065 | 84 | 72 | ||
2066 | 73 | QObject* BfbItem::dashView() const | ||
2067 | 74 | { | ||
2068 | 75 | return m_view; | ||
2069 | 76 | } | ||
2070 | 77 | |||
2071 | 78 | void BfbItem::setDashView(QObject* view) | ||
2072 | 79 | { | ||
2073 | 80 | if (m_view != NULL) { | ||
2074 | 81 | disconnect(view); | ||
2075 | 82 | } | ||
2076 | 83 | m_view = view; | ||
2077 | 84 | if (m_view != NULL) { | ||
2078 | 85 | connect(view, SIGNAL(dashActiveChanged(bool)), this, SLOT(slotDashActiveChanged(bool))); | ||
2079 | 86 | } | ||
2080 | 87 | } | ||
2081 | 88 | |||
2082 | 85 | void BfbItem::activate() | 89 | void BfbItem::activate() |
2083 | 86 | { | 90 | { |
2085 | 87 | DashClient::instance()->setActivePage(m_active ? "" : "home"); | 91 | Q_ASSERT(m_view != NULL); |
2086 | 92 | if (m_view != NULL) { | ||
2087 | 93 | QMetaObject::invokeMethod(m_view, "toggleDash"); | ||
2088 | 94 | } | ||
2089 | 88 | } | 95 | } |
2090 | 89 | 96 | ||
2091 | 90 | void BfbItem::createMenuActions() | 97 | void BfbItem::createMenuActions() |
2092 | 91 | { | 98 | { |
2093 | 92 | } | 99 | } |
2094 | 93 | 100 | ||
2095 | 101 | void BfbItem::slotDashActiveChanged(bool active) | ||
2096 | 102 | { | ||
2097 | 103 | if (m_active != active) { | ||
2098 | 104 | m_active = active; | ||
2099 | 105 | Q_EMIT activeChanged(m_active); | ||
2100 | 106 | } | ||
2101 | 107 | } | ||
2102 | 108 | |||
2103 | 94 | //////////////////////////////////////////////////////////// | 109 | //////////////////////////////////////////////////////////// |
2104 | 95 | BfbModel::BfbModel(QObject* parent) | 110 | BfbModel::BfbModel(QObject* parent) |
2105 | 96 | : QAbstractListModel(parent) | 111 | : QAbstractListModel(parent) |
2106 | @@ -117,4 +132,14 @@ | |||
2107 | 117 | return QVariant::fromValue(m_bfbItem); | 132 | return QVariant::fromValue(m_bfbItem); |
2108 | 118 | } | 133 | } |
2109 | 119 | 134 | ||
2110 | 135 | QObject* BfbModel::dashView() const | ||
2111 | 136 | { | ||
2112 | 137 | return m_bfbItem->dashView(); | ||
2113 | 138 | } | ||
2114 | 139 | |||
2115 | 140 | void BfbModel::setDashView(QObject* view) | ||
2116 | 141 | { | ||
2117 | 142 | m_bfbItem->setDashView(view); | ||
2118 | 143 | } | ||
2119 | 144 | |||
2120 | 120 | #include <bfb.moc> | 145 | #include <bfb.moc> |
2121 | 121 | 146 | ||
2122 | === modified file 'libunity-2d-private/src/bfb.h' | |||
2123 | --- libunity-2d-private/src/bfb.h 2011-08-11 09:25:35 +0000 | |||
2124 | +++ libunity-2d-private/src/bfb.h 2012-02-09 02:13:26 +0000 | |||
2125 | @@ -42,16 +42,20 @@ | |||
2126 | 42 | virtual QString icon() const; | 42 | virtual QString icon() const; |
2127 | 43 | virtual bool launching() const; | 43 | virtual bool launching() const; |
2128 | 44 | 44 | ||
2129 | 45 | QObject* dashView() const; | ||
2130 | 46 | void setDashView(QObject* view); | ||
2131 | 47 | |||
2132 | 45 | /* methods */ | 48 | /* methods */ |
2133 | 46 | Q_INVOKABLE virtual void activate(); | 49 | Q_INVOKABLE virtual void activate(); |
2134 | 47 | Q_INVOKABLE virtual void createMenuActions(); | 50 | Q_INVOKABLE virtual void createMenuActions(); |
2135 | 48 | 51 | ||
2136 | 49 | private Q_SLOTS: | 52 | private Q_SLOTS: |
2138 | 50 | void slotActivePageChanged(const QString&); | 53 | void slotDashActiveChanged(bool active); |
2139 | 51 | 54 | ||
2140 | 52 | private: | 55 | private: |
2141 | 53 | Q_DISABLE_COPY(BfbItem) | 56 | Q_DISABLE_COPY(BfbItem) |
2142 | 54 | bool m_active; | 57 | bool m_active; |
2143 | 58 | QObject* m_view; | ||
2144 | 55 | }; | 59 | }; |
2145 | 56 | 60 | ||
2146 | 57 | Q_DECLARE_METATYPE(BfbItem*) | 61 | Q_DECLARE_METATYPE(BfbItem*) |
2147 | @@ -60,6 +64,7 @@ | |||
2148 | 60 | class BfbModel : public QAbstractListModel | 64 | class BfbModel : public QAbstractListModel |
2149 | 61 | { | 65 | { |
2150 | 62 | Q_OBJECT | 66 | Q_OBJECT |
2151 | 67 | Q_PROPERTY(QObject* dashView READ dashView WRITE setDashView) | ||
2152 | 63 | public: | 68 | public: |
2153 | 64 | BfbModel(QObject* parent = 0); | 69 | BfbModel(QObject* parent = 0); |
2154 | 65 | ~BfbModel(); | 70 | ~BfbModel(); |
2155 | @@ -67,6 +72,9 @@ | |||
2156 | 67 | QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const; | 72 | QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const; |
2157 | 68 | int rowCount(const QModelIndex& parent = QModelIndex()) const; | 73 | int rowCount(const QModelIndex& parent = QModelIndex()) const; |
2158 | 69 | 74 | ||
2159 | 75 | QObject* dashView() const; | ||
2160 | 76 | void setDashView(QObject* view); | ||
2161 | 77 | |||
2162 | 70 | private: | 78 | private: |
2163 | 71 | Q_DISABLE_COPY(BfbModel) | 79 | Q_DISABLE_COPY(BfbModel) |
2164 | 72 | BfbItem* m_bfbItem; | 80 | BfbItem* m_bfbItem; |
2165 | 73 | 81 | ||
2166 | === removed file 'libunity-2d-private/src/edgehitdetector.cpp' | |||
2167 | --- libunity-2d-private/src/edgehitdetector.cpp 2011-11-29 11:46:34 +0000 | |||
2168 | +++ libunity-2d-private/src/edgehitdetector.cpp 1970-01-01 00:00:00 +0000 | |||
2169 | @@ -1,65 +0,0 @@ | |||
2170 | 1 | /* | ||
2171 | 2 | * This file is part of unity-2d | ||
2172 | 3 | * | ||
2173 | 4 | * Copyright 2011 Canonical Ltd. | ||
2174 | 5 | * | ||
2175 | 6 | * Authors: | ||
2176 | 7 | * - Aurélien Gâteau <aurelien.gateau@canonical.com> | ||
2177 | 8 | * | ||
2178 | 9 | * License: GPL v3 | ||
2179 | 10 | */ | ||
2180 | 11 | // Self | ||
2181 | 12 | #include "edgehitdetector.h" | ||
2182 | 13 | |||
2183 | 14 | // Local | ||
2184 | 15 | |||
2185 | 16 | // libunity-2d | ||
2186 | 17 | #include <debug_p.h> | ||
2187 | 18 | |||
2188 | 19 | // Qt | ||
2189 | 20 | #include <QDesktopWidget> | ||
2190 | 21 | #include <QTimer> | ||
2191 | 22 | |||
2192 | 23 | static const int EDGE_HIT_DELAY = 500; | ||
2193 | 24 | |||
2194 | 25 | EdgeHitDetector::EdgeHitDetector(QObject* parent) | ||
2195 | 26 | : QObject(parent) | ||
2196 | 27 | , m_mouseArea(new MouseArea(this)) | ||
2197 | 28 | , m_updateTimer(new QTimer(this)) | ||
2198 | 29 | , m_edgeHitTimer(new QTimer(this)) | ||
2199 | 30 | { | ||
2200 | 31 | updateGeometryFromScreen(); | ||
2201 | 32 | |||
2202 | 33 | // Use a timer to delay geometry updates because sometimes when | ||
2203 | 34 | // QDesktopWidget emits its signals, immediatly asking for screen geometry | ||
2204 | 35 | // yields wrong results. | ||
2205 | 36 | m_updateTimer->setSingleShot(true); | ||
2206 | 37 | m_updateTimer->setInterval(1000); | ||
2207 | 38 | connect(m_updateTimer, SIGNAL(timeout()), SLOT(updateGeometryFromScreen())); | ||
2208 | 39 | |||
2209 | 40 | QDesktopWidget* desktop = QApplication::desktop(); | ||
2210 | 41 | connect(desktop, SIGNAL(resized(int)), m_updateTimer, SLOT(start())); | ||
2211 | 42 | connect(desktop, SIGNAL(screenCountChanged(int)), m_updateTimer, SLOT(start())); | ||
2212 | 43 | |||
2213 | 44 | m_edgeHitTimer->setInterval(EDGE_HIT_DELAY); | ||
2214 | 45 | m_edgeHitTimer->setSingleShot(true); | ||
2215 | 46 | connect(m_edgeHitTimer, SIGNAL(timeout()), SIGNAL(edgeHit())); | ||
2216 | 47 | |||
2217 | 48 | connect(m_mouseArea, SIGNAL(entered()), m_edgeHitTimer, SLOT(start())); | ||
2218 | 49 | connect(m_mouseArea, SIGNAL(exited()), m_edgeHitTimer, SLOT(stop())); | ||
2219 | 50 | } | ||
2220 | 51 | |||
2221 | 52 | void EdgeHitDetector::updateGeometryFromScreen() | ||
2222 | 53 | { | ||
2223 | 54 | QPoint p = QApplication::isLeftToRight() ? | ||
2224 | 55 | QPoint() : | ||
2225 | 56 | QPoint(QApplication::desktop()->width() - 1, 0); | ||
2226 | 57 | QRect rect = QApplication::desktop()->availableGeometry(p); | ||
2227 | 58 | if (QApplication::isLeftToRight()) { | ||
2228 | 59 | m_mouseArea->setGeometry(rect.left(), rect.top(), 1, rect.height()); | ||
2229 | 60 | } else { | ||
2230 | 61 | m_mouseArea->setGeometry(rect.right() - 1, rect.top(), 1, rect.height()); | ||
2231 | 62 | } | ||
2232 | 63 | } | ||
2233 | 64 | |||
2234 | 65 | #include "edgehitdetector.moc" | ||
2235 | 66 | 0 | ||
2236 | === removed file 'libunity-2d-private/src/edgehitdetector.h' | |||
2237 | --- libunity-2d-private/src/edgehitdetector.h 2011-06-11 11:33:52 +0000 | |||
2238 | +++ libunity-2d-private/src/edgehitdetector.h 1970-01-01 00:00:00 +0000 | |||
2239 | @@ -1,44 +0,0 @@ | |||
2240 | 1 | /* | ||
2241 | 2 | * This file is part of unity-2d | ||
2242 | 3 | * | ||
2243 | 4 | * Copyright 2011 Canonical Ltd. | ||
2244 | 5 | * | ||
2245 | 6 | * Authors: | ||
2246 | 7 | * - Aurélien Gâteau <aurelien.gateau@canonical.com> | ||
2247 | 8 | * | ||
2248 | 9 | * License: GPL v3 | ||
2249 | 10 | */ | ||
2250 | 11 | #ifndef EDGEHITDETECTOR_H | ||
2251 | 12 | #define EDGEHITDETECTOR_H | ||
2252 | 13 | |||
2253 | 14 | // Local | ||
2254 | 15 | |||
2255 | 16 | // libunity-2d | ||
2256 | 17 | #include <mousearea.h> | ||
2257 | 18 | |||
2258 | 19 | // Qt | ||
2259 | 20 | |||
2260 | 21 | class QTimer; | ||
2261 | 22 | |||
2262 | 23 | /** | ||
2263 | 24 | * A mouse area which stays on the left edge of the leftmost screen | ||
2264 | 25 | */ | ||
2265 | 26 | class EdgeHitDetector : public QObject | ||
2266 | 27 | { | ||
2267 | 28 | Q_OBJECT | ||
2268 | 29 | public: | ||
2269 | 30 | EdgeHitDetector(QObject* parent = 0); | ||
2270 | 31 | |||
2271 | 32 | Q_SIGNALS: | ||
2272 | 33 | void edgeHit(); | ||
2273 | 34 | |||
2274 | 35 | private Q_SLOTS: | ||
2275 | 36 | void updateGeometryFromScreen(); | ||
2276 | 37 | |||
2277 | 38 | private: | ||
2278 | 39 | MouseArea* m_mouseArea; | ||
2279 | 40 | QTimer* m_updateTimer; | ||
2280 | 41 | QTimer* m_edgeHitTimer; | ||
2281 | 42 | }; | ||
2282 | 43 | |||
2283 | 44 | #endif /* EDGEHITDETECTOR_H */ | ||
2284 | 45 | 0 | ||
2285 | === removed file 'libunity-2d-private/src/forcevisiblebehavior.cpp' | |||
2286 | --- libunity-2d-private/src/forcevisiblebehavior.cpp 2011-06-11 11:33:52 +0000 | |||
2287 | +++ libunity-2d-private/src/forcevisiblebehavior.cpp 1970-01-01 00:00:00 +0000 | |||
2288 | @@ -1,36 +0,0 @@ | |||
2289 | 1 | /* | ||
2290 | 2 | * This file is part of unity-2d | ||
2291 | 3 | * | ||
2292 | 4 | * Copyright 2011 Canonical Ltd. | ||
2293 | 5 | * | ||
2294 | 6 | * Authors: | ||
2295 | 7 | * - Aurélien Gâteau <aurelien.gateau@canonical.com> | ||
2296 | 8 | * | ||
2297 | 9 | * This program is free software; you can redistribute it and/or modify | ||
2298 | 10 | * it under the terms of the GNU General Public License as published by | ||
2299 | 11 | * the Free Software Foundation; version 3. | ||
2300 | 12 | * | ||
2301 | 13 | * This program is distributed in the hope that it will be useful, | ||
2302 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2303 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2304 | 16 | * GNU General Public License for more details. | ||
2305 | 17 | * | ||
2306 | 18 | * You should have received a copy of the GNU General Public License | ||
2307 | 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2308 | 20 | */ | ||
2309 | 21 | // Self | ||
2310 | 22 | #include "forcevisiblebehavior.h" | ||
2311 | 23 | |||
2312 | 24 | // Local | ||
2313 | 25 | |||
2314 | 26 | // libunity-2d | ||
2315 | 27 | |||
2316 | 28 | // Qt | ||
2317 | 29 | #include <QWidget> | ||
2318 | 30 | |||
2319 | 31 | ForceVisibleBehavior::ForceVisibleBehavior(QWidget* panel) | ||
2320 | 32 | : AbstractVisibilityBehavior(panel) | ||
2321 | 33 | { | ||
2322 | 34 | } | ||
2323 | 35 | |||
2324 | 36 | #include "forcevisiblebehavior.moc" | ||
2325 | 37 | 0 | ||
2326 | === removed file 'libunity-2d-private/src/forcevisiblebehavior.h' | |||
2327 | --- libunity-2d-private/src/forcevisiblebehavior.h 2011-06-11 11:33:52 +0000 | |||
2328 | +++ libunity-2d-private/src/forcevisiblebehavior.h 1970-01-01 00:00:00 +0000 | |||
2329 | @@ -1,41 +0,0 @@ | |||
2330 | 1 | /* | ||
2331 | 2 | * This file is part of unity-2d | ||
2332 | 3 | * | ||
2333 | 4 | * Copyright 2011 Canonical Ltd. | ||
2334 | 5 | * | ||
2335 | 6 | * Authors: | ||
2336 | 7 | * - Aurélien Gâteau <aurelien.gateau@canonical.com> | ||
2337 | 8 | * | ||
2338 | 9 | * This program is free software; you can redistribute it and/or modify | ||
2339 | 10 | * it under the terms of the GNU General Public License as published by | ||
2340 | 11 | * the Free Software Foundation; version 3. | ||
2341 | 12 | * | ||
2342 | 13 | * This program is distributed in the hope that it will be useful, | ||
2343 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2344 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2345 | 16 | * GNU General Public License for more details. | ||
2346 | 17 | * | ||
2347 | 18 | * You should have received a copy of the GNU General Public License | ||
2348 | 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2349 | 20 | */ | ||
2350 | 21 | #ifndef FORCEVISIBLEBEHAVIOR_H | ||
2351 | 22 | #define FORCEVISIBLEBEHAVIOR_H | ||
2352 | 23 | |||
2353 | 24 | // Local | ||
2354 | 25 | #include <abstractvisibilitybehavior.h> | ||
2355 | 26 | |||
2356 | 27 | // Qt | ||
2357 | 28 | #include <QObject> | ||
2358 | 29 | |||
2359 | 30 | /** | ||
2360 | 31 | * Behavior used when someone requested the launcher to be visible even if it | ||
2361 | 32 | * is supposed to be hidden | ||
2362 | 33 | */ | ||
2363 | 34 | class ForceVisibleBehavior : public AbstractVisibilityBehavior | ||
2364 | 35 | { | ||
2365 | 36 | Q_OBJECT | ||
2366 | 37 | public: | ||
2367 | 38 | ForceVisibleBehavior(QWidget* panel=0); | ||
2368 | 39 | }; | ||
2369 | 40 | |||
2370 | 41 | #endif /* FORCEVISIBLEBEHAVIOR_H */ | ||
2371 | 42 | 0 | ||
2372 | === renamed file 'launcher/app/gesturehandler.cpp' => 'libunity-2d-private/src/gesturehandler.cpp' | |||
2373 | --- launcher/app/gesturehandler.cpp 2011-11-08 13:33:33 +0000 | |||
2374 | +++ libunity-2d-private/src/gesturehandler.cpp 2012-02-09 02:13:26 +0000 | |||
2375 | @@ -25,10 +25,10 @@ | |||
2376 | 25 | 25 | ||
2377 | 26 | #include <debug_p.h> | 26 | #include <debug_p.h> |
2378 | 27 | 27 | ||
2380 | 28 | GestureHandler::GestureHandler(Unity2dPanel* launcher, QObject *parent) | 28 | GestureHandler::GestureHandler(QObject *parent) |
2381 | 29 | : QObject(parent) | 29 | : QObject(parent) |
2382 | 30 | , m_geisInstance(NULL) | 30 | , m_geisInstance(NULL) |
2384 | 31 | , m_launcher(launcher) | 31 | , m_isDragging(false) |
2385 | 32 | { | 32 | { |
2386 | 33 | if (geisInitialize() != GEIS_STATUS_SUCCESS) { | 33 | if (geisInitialize() != GEIS_STATUS_SUCCESS) { |
2387 | 34 | UQ_WARNING << "GEIS initialization failed: multitouch support disabled"; | 34 | UQ_WARNING << "GEIS initialization failed: multitouch support disabled"; |
2388 | @@ -218,9 +218,10 @@ | |||
2389 | 218 | /* 4 fingers drag reveals the launcher progressively; if the drag goes far | 218 | /* 4 fingers drag reveals the launcher progressively; if the drag goes far |
2390 | 219 | enough, the launcher is then locked in place and does not autohide anymore */ | 219 | enough, the launcher is then locked in place and does not autohide anymore */ |
2391 | 220 | /* FIXME: only supports the launcher positioned on the left edge of the screen */ | 220 | /* FIXME: only supports the launcher positioned on the left edge of the screen */ |
2395 | 221 | m_launcher->setManualSliding(true); | 221 | m_isDragging = true; |
2396 | 222 | m_dragDelta = m_launcher->delta() + attributes[GEIS_GESTURE_ATTRIBUTE_DELTA_X].float_val; | 222 | Q_EMIT isDraggingChanged(); |
2397 | 223 | m_launcher->setDelta(m_dragDelta); | 223 | m_dragDelta = attributes[GEIS_GESTURE_ATTRIBUTE_DELTA_X].float_val; |
2398 | 224 | Q_EMIT dragDeltaChanged(); | ||
2399 | 224 | } | 225 | } |
2400 | 225 | } | 226 | } |
2401 | 226 | 227 | ||
2402 | @@ -262,18 +263,17 @@ | |||
2403 | 262 | m_pinchPreviousTimestamp = timestamp; | 263 | m_pinchPreviousTimestamp = timestamp; |
2404 | 263 | } | 264 | } |
2405 | 264 | } else if (gestureName == GEIS_GESTURE_TYPE_DRAG4) { | 265 | } else if (gestureName == GEIS_GESTURE_TYPE_DRAG4) { |
2406 | 265 | /* FIXME: only supports the launcher positioned on the left edge of the screen */ | ||
2407 | 266 | m_dragDelta += attributes[GEIS_GESTURE_ATTRIBUTE_DELTA_X].float_val; | 266 | m_dragDelta += attributes[GEIS_GESTURE_ATTRIBUTE_DELTA_X].float_val; |
2409 | 267 | m_launcher->setDelta(m_dragDelta); | 267 | Q_EMIT dragDeltaChanged(); |
2410 | 268 | /* If the drag goes sufficiently above than the maximum delta then | 268 | /* If the drag goes sufficiently above than the maximum delta then |
2411 | 269 | lock the launcher in place by reserving the area so that no windows | 269 | lock the launcher in place by reserving the area so that no windows |
2413 | 270 | overlap it. | 270 | overlap it. TODO: move to QML. |
2414 | 271 | */ | 271 | */ |
2420 | 272 | if (m_dragDelta - m_launcher->delta() > 240) { | 272 | // if (m_dragDelta - m_launcher->delta() > 240) { |
2421 | 273 | m_launcher->setUseStrut(true); | 273 | // m_launcher->setUseStrut(true); |
2422 | 274 | } else { | 274 | // } else { |
2423 | 275 | m_launcher->setUseStrut(false); | 275 | // m_launcher->setUseStrut(false); |
2424 | 276 | } | 276 | // } |
2425 | 277 | } | 277 | } |
2426 | 278 | } | 278 | } |
2427 | 279 | 279 | ||
2428 | @@ -284,8 +284,20 @@ | |||
2429 | 284 | 284 | ||
2430 | 285 | if (gestureName == GEIS_GESTURE_TYPE_DRAG4) { | 285 | if (gestureName == GEIS_GESTURE_TYPE_DRAG4) { |
2431 | 286 | m_dragDelta += attributes[GEIS_GESTURE_ATTRIBUTE_DELTA_X].float_val; | 286 | m_dragDelta += attributes[GEIS_GESTURE_ATTRIBUTE_DELTA_X].float_val; |
2434 | 287 | m_launcher->setDelta(m_dragDelta); | 287 | Q_EMIT dragDeltaChanged(); |
2435 | 288 | m_launcher->setManualSliding(false); | 288 | m_isDragging = false; |
2436 | 289 | Q_EMIT isDraggingChanged(); | ||
2437 | 289 | } | 290 | } |
2438 | 290 | } | 291 | } |
2439 | 291 | 292 | ||
2440 | 293 | double GestureHandler::dragDelta() const | ||
2441 | 294 | { | ||
2442 | 295 | return m_dragDelta; | ||
2443 | 296 | } | ||
2444 | 297 | |||
2445 | 298 | bool GestureHandler::isDragging() const | ||
2446 | 299 | { | ||
2447 | 300 | return m_isDragging; | ||
2448 | 301 | } | ||
2449 | 302 | |||
2450 | 303 | #include "gesturehandler.moc" | ||
2451 | 292 | 304 | ||
2452 | === renamed file 'launcher/app/gesturehandler.h' => 'libunity-2d-private/src/gesturehandler.h' | |||
2453 | --- launcher/app/gesturehandler.h 2011-02-21 00:25:44 +0000 | |||
2454 | +++ libunity-2d-private/src/gesturehandler.h 2012-02-09 02:13:26 +0000 | |||
2455 | @@ -22,20 +22,29 @@ | |||
2456 | 22 | 22 | ||
2457 | 23 | #include <QObject> | 23 | #include <QObject> |
2458 | 24 | #include <QHash> | 24 | #include <QHash> |
2459 | 25 | #include <QMetaType> | ||
2460 | 25 | 26 | ||
2461 | 26 | extern "C" { | 27 | extern "C" { |
2462 | 27 | #include <geis/geis.h> | 28 | #include <geis/geis.h> |
2463 | 28 | } | 29 | } |
2464 | 29 | 30 | ||
2465 | 30 | #include "unity2dpanel.h" | ||
2466 | 31 | |||
2467 | 32 | class GestureHandler : public QObject | 31 | class GestureHandler : public QObject |
2468 | 33 | { | 32 | { |
2469 | 34 | Q_OBJECT | 33 | Q_OBJECT |
2470 | 34 | Q_PROPERTY(double dragDelta READ dragDelta NOTIFY dragDeltaChanged) | ||
2471 | 35 | Q_PROPERTY(bool isDragging READ isDragging NOTIFY isDraggingChanged) | ||
2472 | 36 | |||
2473 | 35 | public: | 37 | public: |
2475 | 36 | explicit GestureHandler(Unity2dPanel* launcher, QObject *parent = 0); | 38 | explicit GestureHandler(QObject *parent = 0); |
2476 | 37 | ~GestureHandler(); | 39 | ~GestureHandler(); |
2477 | 38 | 40 | ||
2478 | 41 | double dragDelta() const; | ||
2479 | 42 | bool isDragging() const; | ||
2480 | 43 | |||
2481 | 44 | Q_SIGNALS: | ||
2482 | 45 | void dragDeltaChanged(); | ||
2483 | 46 | void isDraggingChanged(); | ||
2484 | 47 | |||
2485 | 39 | private Q_SLOTS: | 48 | private Q_SLOTS: |
2486 | 40 | void geisEventDispatch(); | 49 | void geisEventDispatch(); |
2487 | 41 | 50 | ||
2488 | @@ -60,7 +69,9 @@ | |||
2489 | 60 | float m_pinchPreviousRadius; | 69 | float m_pinchPreviousRadius; |
2490 | 61 | int m_pinchPreviousTimestamp; | 70 | int m_pinchPreviousTimestamp; |
2491 | 62 | float m_dragDelta; | 71 | float m_dragDelta; |
2493 | 63 | Unity2dPanel* m_launcher; | 72 | bool m_isDragging; |
2494 | 64 | }; | 73 | }; |
2495 | 65 | 74 | ||
2496 | 75 | Q_DECLARE_METATYPE(GestureHandler*) | ||
2497 | 76 | |||
2498 | 66 | #endif // GESTUREHANDLER_H | 77 | #endif // GESTUREHANDLER_H |
2499 | 67 | 78 | ||
2500 | === added file 'libunity-2d-private/src/inputshapemanager.cpp' | |||
2501 | --- libunity-2d-private/src/inputshapemanager.cpp 1970-01-01 00:00:00 +0000 | |||
2502 | +++ libunity-2d-private/src/inputshapemanager.cpp 2012-02-09 02:13:26 +0000 | |||
2503 | @@ -0,0 +1,105 @@ | |||
2504 | 1 | /* | ||
2505 | 2 | * This file is part of unity-2d | ||
2506 | 3 | * | ||
2507 | 4 | * Copyright 2012 Canonical Ltd. | ||
2508 | 5 | * | ||
2509 | 6 | * Authors: | ||
2510 | 7 | * - Ugo Riboni <ugo.riboni@canonical.com> | ||
2511 | 8 | * | ||
2512 | 9 | * This program is free software; you can redistribute it and/or modify | ||
2513 | 10 | * it under the terms of the GNU General Public License as published by | ||
2514 | 11 | * the Free Software Foundation; version 3. | ||
2515 | 12 | * | ||
2516 | 13 | * This program is distributed in the hope that it will be useful, | ||
2517 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2518 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2519 | 16 | * GNU General Public License for more details. | ||
2520 | 17 | * | ||
2521 | 18 | * You should have received a copy of the GNU General Public License | ||
2522 | 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2523 | 20 | */ | ||
2524 | 21 | |||
2525 | 22 | #include <QDebug> | ||
2526 | 23 | #include <QRect> | ||
2527 | 24 | #include <QX11Info> | ||
2528 | 25 | #include <QRegion> | ||
2529 | 26 | |||
2530 | 27 | #include "inputshapemanager.h" | ||
2531 | 28 | #include "unity2ddeclarativeview.h" | ||
2532 | 29 | #include "desktopinfo.h" | ||
2533 | 30 | |||
2534 | 31 | // X11 | ||
2535 | 32 | #include <X11/Xlib.h> | ||
2536 | 33 | #include <X11/Xregion.h> | ||
2537 | 34 | #include <X11/extensions/shape.h> | ||
2538 | 35 | |||
2539 | 36 | InputShapeManager::InputShapeManager(QObject *parent) : | ||
2540 | 37 | QObject(parent), | ||
2541 | 38 | m_target(0) | ||
2542 | 39 | { | ||
2543 | 40 | } | ||
2544 | 41 | |||
2545 | 42 | void InputShapeManager::updateManagedShape() | ||
2546 | 43 | { | ||
2547 | 44 | if (m_target == NULL || !m_target->isVisible()) { | ||
2548 | 45 | return; | ||
2549 | 46 | } | ||
2550 | 47 | |||
2551 | 48 | QBitmap inputShape(m_target->width(), m_target->height()); | ||
2552 | 49 | inputShape.fill(Qt::color0); | ||
2553 | 50 | QPainter painter(&inputShape); | ||
2554 | 51 | |||
2555 | 52 | Q_FOREACH(InputShapeRectangle* shape, m_shapes) { | ||
2556 | 53 | if (shape->enabled()) { | ||
2557 | 54 | painter.drawPixmap(shape->rectangle().x(), shape->rectangle().y(), | ||
2558 | 55 | shape->shape()); | ||
2559 | 56 | } | ||
2560 | 57 | } | ||
2561 | 58 | |||
2562 | 59 | XShapeCombineRegion(QX11Info::display(), m_target->effectiveWinId(), | ||
2563 | 60 | DesktopInfo::instance()->isCompositingManagerRunning() ? ShapeInput : ShapeBounding, | ||
2564 | 61 | 0, 0, QRegion(inputShape).handle(), ShapeSet); | ||
2565 | 62 | } | ||
2566 | 63 | |||
2567 | 64 | Unity2DDeclarativeView* InputShapeManager::target() const | ||
2568 | 65 | { | ||
2569 | 66 | return m_target; | ||
2570 | 67 | } | ||
2571 | 68 | |||
2572 | 69 | void InputShapeManager::setTarget(Unity2DDeclarativeView *target) | ||
2573 | 70 | { | ||
2574 | 71 | if (m_target != target) { | ||
2575 | 72 | if (m_target != NULL) m_target->disconnect(this); | ||
2576 | 73 | |||
2577 | 74 | //TODO: de-shape the current target view, if any, before shaping the new one. not used now | ||
2578 | 75 | // as we never change the view anyway. | ||
2579 | 76 | |||
2580 | 77 | m_target = target; | ||
2581 | 78 | if (m_target != NULL) { | ||
2582 | 79 | // due to the way xshape works we need to re-apply the shaping every time the target window | ||
2583 | 80 | // is mapped again. | ||
2584 | 81 | connect(m_target, SIGNAL(visibleChanged(bool)), SLOT(updateManagedShape())); | ||
2585 | 82 | connect(m_target, SIGNAL(sceneResized(QSize)), SLOT(updateManagedShape())); | ||
2586 | 83 | } | ||
2587 | 84 | Q_EMIT targetChanged(); | ||
2588 | 85 | updateManagedShape(); | ||
2589 | 86 | } | ||
2590 | 87 | } | ||
2591 | 88 | |||
2592 | 89 | QDeclarativeListProperty<InputShapeRectangle> InputShapeManager::shapes() | ||
2593 | 90 | { | ||
2594 | 91 | return QDeclarativeListProperty<InputShapeRectangle>(this, this, &InputShapeManager::appendShape); | ||
2595 | 92 | } | ||
2596 | 93 | |||
2597 | 94 | void InputShapeManager::appendShape(QDeclarativeListProperty<InputShapeRectangle> *list, InputShapeRectangle *shape) | ||
2598 | 95 | { | ||
2599 | 96 | InputShapeManager* instance = qobject_cast<InputShapeManager*>(list->object); | ||
2600 | 97 | if (instance != NULL) { | ||
2601 | 98 | instance->m_shapes.append(shape); | ||
2602 | 99 | instance->connect(shape, SIGNAL(shapeChanged()), SLOT(updateManagedShape())); | ||
2603 | 100 | instance->connect(shape, SIGNAL(enabledChanged()), SLOT(updateManagedShape())); | ||
2604 | 101 | instance->updateManagedShape(); | ||
2605 | 102 | } | ||
2606 | 103 | } | ||
2607 | 104 | |||
2608 | 105 | #include "inputshapemanager.moc" | ||
2609 | 0 | 106 | ||
2610 | === added file 'libunity-2d-private/src/inputshapemanager.h' | |||
2611 | --- libunity-2d-private/src/inputshapemanager.h 1970-01-01 00:00:00 +0000 | |||
2612 | +++ libunity-2d-private/src/inputshapemanager.h 2012-02-09 02:13:26 +0000 | |||
2613 | @@ -0,0 +1,59 @@ | |||
2614 | 1 | /* | ||
2615 | 2 | * This file is part of unity-2d | ||
2616 | 3 | * | ||
2617 | 4 | * Copyright 2012 Canonical Ltd. | ||
2618 | 5 | * | ||
2619 | 6 | * Authors: | ||
2620 | 7 | * - Ugo Riboni <ugo.riboni@canonical.com> | ||
2621 | 8 | * | ||
2622 | 9 | * This program is free software; you can redistribute it and/or modify | ||
2623 | 10 | * it under the terms of the GNU General Public License as published by | ||
2624 | 11 | * the Free Software Foundation; version 3. | ||
2625 | 12 | * | ||
2626 | 13 | * This program is distributed in the hope that it will be useful, | ||
2627 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2628 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2629 | 16 | * GNU General Public License for more details. | ||
2630 | 17 | * | ||
2631 | 18 | * You should have received a copy of the GNU General Public License | ||
2632 | 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2633 | 20 | */ | ||
2634 | 21 | |||
2635 | 22 | #ifndef INPUTSHAPEMANAGER_H | ||
2636 | 23 | #define INPUTSHAPEMANAGER_H | ||
2637 | 24 | |||
2638 | 25 | #include <QObject> | ||
2639 | 26 | #include <QDeclarativeListProperty> | ||
2640 | 27 | |||
2641 | 28 | #include "inputshaperectangle.h" | ||
2642 | 29 | |||
2643 | 30 | class Unity2DDeclarativeView; | ||
2644 | 31 | |||
2645 | 32 | class InputShapeManager : public QObject | ||
2646 | 33 | { | ||
2647 | 34 | Q_OBJECT | ||
2648 | 35 | Q_PROPERTY(Unity2DDeclarativeView* target READ target WRITE setTarget NOTIFY targetChanged) | ||
2649 | 36 | Q_PROPERTY(QDeclarativeListProperty<InputShapeRectangle> shapes READ shapes) | ||
2650 | 37 | Q_CLASSINFO("DefaultProperty", "shapes") | ||
2651 | 38 | |||
2652 | 39 | public: | ||
2653 | 40 | explicit InputShapeManager(QObject *parent = 0); | ||
2654 | 41 | Unity2DDeclarativeView* target() const; | ||
2655 | 42 | void setTarget(Unity2DDeclarativeView* target); | ||
2656 | 43 | QDeclarativeListProperty<InputShapeRectangle> shapes(); | ||
2657 | 44 | |||
2658 | 45 | Q_SIGNALS: | ||
2659 | 46 | void targetChanged(); | ||
2660 | 47 | |||
2661 | 48 | public Q_SLOTS: | ||
2662 | 49 | void updateManagedShape(); | ||
2663 | 50 | |||
2664 | 51 | protected: | ||
2665 | 52 | static void appendShape(QDeclarativeListProperty<InputShapeRectangle> *property, InputShapeRectangle *value); | ||
2666 | 53 | |||
2667 | 54 | private: | ||
2668 | 55 | Unity2DDeclarativeView* m_target; | ||
2669 | 56 | QList<InputShapeRectangle*> m_shapes; | ||
2670 | 57 | }; | ||
2671 | 58 | |||
2672 | 59 | #endif // INPUTSHAPEMANAGER_H | ||
2673 | 0 | 60 | ||
2674 | === added file 'libunity-2d-private/src/inputshapemask.cpp' | |||
2675 | --- libunity-2d-private/src/inputshapemask.cpp 1970-01-01 00:00:00 +0000 | |||
2676 | +++ libunity-2d-private/src/inputshapemask.cpp 2012-02-09 02:13:26 +0000 | |||
2677 | @@ -0,0 +1,111 @@ | |||
2678 | 1 | /* | ||
2679 | 2 | * This file is part of unity-2d | ||
2680 | 3 | * | ||
2681 | 4 | * Copyright 2012 Canonical Ltd. | ||
2682 | 5 | * | ||
2683 | 6 | * Authors: | ||
2684 | 7 | * - Ugo Riboni <ugo.riboni@canonical.com> | ||
2685 | 8 | * | ||
2686 | 9 | * This program is free software; you can redistribute it and/or modify | ||
2687 | 10 | * it under the terms of the GNU General Public License as published by | ||
2688 | 11 | * the Free Software Foundation; version 3. | ||
2689 | 12 | * | ||
2690 | 13 | * This program is distributed in the hope that it will be useful, | ||
2691 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2692 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2693 | 16 | * GNU General Public License for more details. | ||
2694 | 17 | * | ||
2695 | 18 | * You should have received a copy of the GNU General Public License | ||
2696 | 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2697 | 20 | */ | ||
2698 | 21 | |||
2699 | 22 | #include "inputshapemask.h" | ||
2700 | 23 | #include "config.h" | ||
2701 | 24 | |||
2702 | 25 | #include <QBitmap> | ||
2703 | 26 | #include <QDebug> | ||
2704 | 27 | |||
2705 | 28 | InputShapeMask::InputShapeMask(QObject *parent) : | ||
2706 | 29 | QObject(parent), | ||
2707 | 30 | m_enabled(true) | ||
2708 | 31 | { | ||
2709 | 32 | } | ||
2710 | 33 | |||
2711 | 34 | void InputShapeMask::updateShape() | ||
2712 | 35 | { | ||
2713 | 36 | QBitmap newShape; | ||
2714 | 37 | |||
2715 | 38 | if (!m_source.isEmpty() && m_color.isValid()) { | ||
2716 | 39 | QPixmap image; | ||
2717 | 40 | QString path = unity2dDirectory() + "/" + m_source; | ||
2718 | 41 | if (image.load(path)) { | ||
2719 | 42 | newShape = image.createMaskFromColor(m_color.rgb(), Qt::MaskInColor); | ||
2720 | 43 | } else { | ||
2721 | 44 | qWarning() << "Failed to load input shape mask image from" << path; | ||
2722 | 45 | } | ||
2723 | 46 | } | ||
2724 | 47 | |||
2725 | 48 | m_shape = newShape; | ||
2726 | 49 | Q_EMIT shapeChanged(); | ||
2727 | 50 | } | ||
2728 | 51 | |||
2729 | 52 | QString InputShapeMask::source() const | ||
2730 | 53 | { | ||
2731 | 54 | return m_source; | ||
2732 | 55 | } | ||
2733 | 56 | |||
2734 | 57 | QColor InputShapeMask::color() const | ||
2735 | 58 | { | ||
2736 | 59 | return m_color; | ||
2737 | 60 | } | ||
2738 | 61 | |||
2739 | 62 | QPoint InputShapeMask::position() const | ||
2740 | 63 | { | ||
2741 | 64 | return m_position; | ||
2742 | 65 | } | ||
2743 | 66 | |||
2744 | 67 | bool InputShapeMask::enabled() const | ||
2745 | 68 | { | ||
2746 | 69 | return m_enabled; | ||
2747 | 70 | } | ||
2748 | 71 | |||
2749 | 72 | QBitmap InputShapeMask::shape() const | ||
2750 | 73 | { | ||
2751 | 74 | return m_shape; | ||
2752 | 75 | } | ||
2753 | 76 | |||
2754 | 77 | void InputShapeMask::setSource(const QString &source) | ||
2755 | 78 | { | ||
2756 | 79 | if (m_source != source) { | ||
2757 | 80 | m_source = source; | ||
2758 | 81 | Q_EMIT sourceChanged(m_source); | ||
2759 | 82 | updateShape(); | ||
2760 | 83 | } | ||
2761 | 84 | } | ||
2762 | 85 | |||
2763 | 86 | void InputShapeMask::setColor(const QColor &color) | ||
2764 | 87 | { | ||
2765 | 88 | if (m_color != color) { | ||
2766 | 89 | m_color = color; | ||
2767 | 90 | Q_EMIT colorChanged(m_color); | ||
2768 | 91 | updateShape(); | ||
2769 | 92 | } | ||
2770 | 93 | } | ||
2771 | 94 | |||
2772 | 95 | void InputShapeMask::setPosition(const QPoint &position) | ||
2773 | 96 | { | ||
2774 | 97 | if (m_position != position) { | ||
2775 | 98 | m_position = position; | ||
2776 | 99 | Q_EMIT positionChanged(); | ||
2777 | 100 | } | ||
2778 | 101 | } | ||
2779 | 102 | |||
2780 | 103 | void InputShapeMask::setEnabled(bool enabled) | ||
2781 | 104 | { | ||
2782 | 105 | if (m_enabled != enabled) { | ||
2783 | 106 | m_enabled = enabled; | ||
2784 | 107 | Q_EMIT enabledChanged(); | ||
2785 | 108 | } | ||
2786 | 109 | } | ||
2787 | 110 | |||
2788 | 111 | #include "inputshapemask.moc" | ||
2789 | 0 | 112 | ||
2790 | === added file 'libunity-2d-private/src/inputshapemask.h' | |||
2791 | --- libunity-2d-private/src/inputshapemask.h 1970-01-01 00:00:00 +0000 | |||
2792 | +++ libunity-2d-private/src/inputshapemask.h 2012-02-09 02:13:26 +0000 | |||
2793 | @@ -0,0 +1,71 @@ | |||
2794 | 1 | /* | ||
2795 | 2 | * This file is part of unity-2d | ||
2796 | 3 | * | ||
2797 | 4 | * Copyright 2012 Canonical Ltd. | ||
2798 | 5 | * | ||
2799 | 6 | * Authors: | ||
2800 | 7 | * - Ugo Riboni <ugo.riboni@canonical.com> | ||
2801 | 8 | * | ||
2802 | 9 | * This program is free software; you can redistribute it and/or modify | ||
2803 | 10 | * it under the terms of the GNU General Public License as published by | ||
2804 | 11 | * the Free Software Foundation; version 3. | ||
2805 | 12 | * | ||
2806 | 13 | * This program is distributed in the hope that it will be useful, | ||
2807 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2808 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2809 | 16 | * GNU General Public License for more details. | ||
2810 | 17 | * | ||
2811 | 18 | * You should have received a copy of the GNU General Public License | ||
2812 | 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2813 | 20 | */ | ||
2814 | 21 | |||
2815 | 22 | #ifndef INPUTSHAPEMASK_H | ||
2816 | 23 | #define INPUTSHAPEMASK_H | ||
2817 | 24 | |||
2818 | 25 | #include <QObject> | ||
2819 | 26 | #include <QColor> | ||
2820 | 27 | #include <QPoint> | ||
2821 | 28 | #include <QBitmap> | ||
2822 | 29 | |||
2823 | 30 | class InputShapeMask : public QObject | ||
2824 | 31 | { | ||
2825 | 32 | Q_OBJECT | ||
2826 | 33 | Q_PROPERTY(QString source READ source WRITE setSource NOTIFY sourceChanged) | ||
2827 | 34 | Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) | ||
2828 | 35 | Q_PROPERTY(QPoint position READ position WRITE setPosition NOTIFY positionChanged) | ||
2829 | 36 | Q_PROPERTY(QBitmap shape READ shape NOTIFY shapeChanged) | ||
2830 | 37 | Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) | ||
2831 | 38 | |||
2832 | 39 | public: | ||
2833 | 40 | explicit InputShapeMask(QObject *parent = 0); | ||
2834 | 41 | |||
2835 | 42 | QString source() const; | ||
2836 | 43 | QColor color() const; | ||
2837 | 44 | QPoint position() const; | ||
2838 | 45 | bool enabled() const; | ||
2839 | 46 | QBitmap shape() const; | ||
2840 | 47 | |||
2841 | 48 | void setSource(const QString& source); | ||
2842 | 49 | void setColor(const QColor& color); | ||
2843 | 50 | void setPosition(const QPoint& position); | ||
2844 | 51 | void setEnabled(bool enabled); | ||
2845 | 52 | |||
2846 | 53 | Q_SIGNALS: | ||
2847 | 54 | void sourceChanged(const QString& source); | ||
2848 | 55 | void colorChanged(const QColor& color); | ||
2849 | 56 | void enabledChanged(); | ||
2850 | 57 | void shapeChanged(); | ||
2851 | 58 | void positionChanged(); | ||
2852 | 59 | |||
2853 | 60 | protected: | ||
2854 | 61 | void updateShape(); | ||
2855 | 62 | |||
2856 | 63 | private: | ||
2857 | 64 | QString m_source; | ||
2858 | 65 | QColor m_color; | ||
2859 | 66 | QPoint m_position; | ||
2860 | 67 | bool m_enabled; | ||
2861 | 68 | QBitmap m_shape; | ||
2862 | 69 | }; | ||
2863 | 70 | |||
2864 | 71 | #endif // INPUTSHAPEMASK_H | ||
2865 | 0 | 72 | ||
2866 | === added file 'libunity-2d-private/src/inputshaperectangle.cpp' | |||
2867 | --- libunity-2d-private/src/inputshaperectangle.cpp 1970-01-01 00:00:00 +0000 | |||
2868 | +++ libunity-2d-private/src/inputshaperectangle.cpp 2012-02-09 02:13:26 +0000 | |||
2869 | @@ -0,0 +1,126 @@ | |||
2870 | 1 | /* | ||
2871 | 2 | * This file is part of unity-2d | ||
2872 | 3 | * | ||
2873 | 4 | * Copyright 2012 Canonical Ltd. | ||
2874 | 5 | * | ||
2875 | 6 | * Authors: | ||
2876 | 7 | * - Ugo Riboni <ugo.riboni@canonical.com> | ||
2877 | 8 | * | ||
2878 | 9 | * This program is free software; you can redistribute it and/or modify | ||
2879 | 10 | * it under the terms of the GNU General Public License as published by | ||
2880 | 11 | * the Free Software Foundation; version 3. | ||
2881 | 12 | * | ||
2882 | 13 | * This program is distributed in the hope that it will be useful, | ||
2883 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2884 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2885 | 16 | * GNU General Public License for more details. | ||
2886 | 17 | * | ||
2887 | 18 | * You should have received a copy of the GNU General Public License | ||
2888 | 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2889 | 20 | */ | ||
2890 | 21 | |||
2891 | 22 | #include "inputshaperectangle.h" | ||
2892 | 23 | #include "inputshapemask.h" | ||
2893 | 24 | |||
2894 | 25 | #include <QBitmap> | ||
2895 | 26 | #include <QPainter> | ||
2896 | 27 | #include <QPainterPath> | ||
2897 | 28 | #include <QDebug> | ||
2898 | 29 | #include <QRect> | ||
2899 | 30 | |||
2900 | 31 | InputShapeRectangle::InputShapeRectangle(QObject *parent) : | ||
2901 | 32 | QObject(parent), | ||
2902 | 33 | m_enabled(true), | ||
2903 | 34 | m_mirrorHorizontally(false) | ||
2904 | 35 | { | ||
2905 | 36 | } | ||
2906 | 37 | |||
2907 | 38 | void InputShapeRectangle::updateShape() | ||
2908 | 39 | { | ||
2909 | 40 | QBitmap newShape(m_rectangle.width(), m_rectangle.height()); | ||
2910 | 41 | newShape.fill(Qt::color1); | ||
2911 | 42 | |||
2912 | 43 | if (!m_rectangle.isEmpty() && m_masks.count() > 0) { | ||
2913 | 44 | QPainter painter(&newShape); | ||
2914 | 45 | painter.setBackgroundMode(Qt::OpaqueMode); | ||
2915 | 46 | |||
2916 | 47 | Q_FOREACH (InputShapeMask* mask, m_masks) { | ||
2917 | 48 | if (mask->enabled()) { | ||
2918 | 49 | painter.drawPixmap(mask->position(), mask->shape()); | ||
2919 | 50 | } | ||
2920 | 51 | } | ||
2921 | 52 | } | ||
2922 | 53 | |||
2923 | 54 | if (m_mirrorHorizontally) { | ||
2924 | 55 | newShape = QBitmap::fromImage(newShape.toImage().mirrored(true, false)); | ||
2925 | 56 | } | ||
2926 | 57 | |||
2927 | 58 | m_shape = newShape; | ||
2928 | 59 | Q_EMIT shapeChanged(); | ||
2929 | 60 | } | ||
2930 | 61 | |||
2931 | 62 | QRect InputShapeRectangle::rectangle() const | ||
2932 | 63 | { | ||
2933 | 64 | return m_rectangle; | ||
2934 | 65 | } | ||
2935 | 66 | |||
2936 | 67 | void InputShapeRectangle::setRectangle(QRect rectangle) | ||
2937 | 68 | { | ||
2938 | 69 | if (rectangle != m_rectangle) { | ||
2939 | 70 | m_rectangle = rectangle; | ||
2940 | 71 | updateShape(); | ||
2941 | 72 | Q_EMIT rectangleChanged(); | ||
2942 | 73 | } | ||
2943 | 74 | } | ||
2944 | 75 | |||
2945 | 76 | bool InputShapeRectangle::enabled() const | ||
2946 | 77 | { | ||
2947 | 78 | return m_enabled; | ||
2948 | 79 | } | ||
2949 | 80 | |||
2950 | 81 | void InputShapeRectangle::setEnabled(bool enabled) | ||
2951 | 82 | { | ||
2952 | 83 | if (enabled != m_enabled) { | ||
2953 | 84 | m_enabled = enabled; | ||
2954 | 85 | Q_EMIT enabledChanged(); | ||
2955 | 86 | |||
2956 | 87 | } | ||
2957 | 88 | } | ||
2958 | 89 | |||
2959 | 90 | QBitmap InputShapeRectangle::shape() const | ||
2960 | 91 | { | ||
2961 | 92 | return m_shape; | ||
2962 | 93 | } | ||
2963 | 94 | |||
2964 | 95 | QDeclarativeListProperty<InputShapeMask> InputShapeRectangle::masks() | ||
2965 | 96 | { | ||
2966 | 97 | return QDeclarativeListProperty<InputShapeMask>(this, this, &InputShapeRectangle::appendMask); | ||
2967 | 98 | } | ||
2968 | 99 | |||
2969 | 100 | bool InputShapeRectangle::mirrorHorizontally() const | ||
2970 | 101 | { | ||
2971 | 102 | return m_mirrorHorizontally; | ||
2972 | 103 | } | ||
2973 | 104 | |||
2974 | 105 | void InputShapeRectangle::setMirrorHorizontally(bool mirror) | ||
2975 | 106 | { | ||
2976 | 107 | if (mirror != m_mirrorHorizontally) { | ||
2977 | 108 | m_mirrorHorizontally = mirror; | ||
2978 | 109 | updateShape(); | ||
2979 | 110 | Q_EMIT mirrorHorizontallyChanged(m_mirrorHorizontally); | ||
2980 | 111 | } | ||
2981 | 112 | } | ||
2982 | 113 | |||
2983 | 114 | void InputShapeRectangle::appendMask(QDeclarativeListProperty<InputShapeMask> *list, InputShapeMask *mask) | ||
2984 | 115 | { | ||
2985 | 116 | InputShapeRectangle* instance = qobject_cast<InputShapeRectangle*>(list->object); | ||
2986 | 117 | if (instance != NULL) { | ||
2987 | 118 | instance->m_masks.append(mask); | ||
2988 | 119 | instance->connect(mask, SIGNAL(enabledChanged()), SLOT(updateShape())); | ||
2989 | 120 | instance->connect(mask, SIGNAL(shapeChanged()), SLOT(updateShape())); | ||
2990 | 121 | instance->connect(mask, SIGNAL(positionChanged()), SLOT(updateShape())); | ||
2991 | 122 | instance->updateShape(); | ||
2992 | 123 | } | ||
2993 | 124 | } | ||
2994 | 125 | |||
2995 | 126 | #include "inputshaperectangle.moc" | ||
2996 | 0 | 127 | ||
2997 | === added file 'libunity-2d-private/src/inputshaperectangle.h' | |||
2998 | --- libunity-2d-private/src/inputshaperectangle.h 1970-01-01 00:00:00 +0000 | |||
2999 | +++ libunity-2d-private/src/inputshaperectangle.h 2012-02-09 02:13:26 +0000 | |||
3000 | @@ -0,0 +1,75 @@ | |||
3001 | 1 | /* | ||
3002 | 2 | * This file is part of unity-2d | ||
3003 | 3 | * | ||
3004 | 4 | * Copyright 2012 Canonical Ltd. | ||
3005 | 5 | * | ||
3006 | 6 | * Authors: | ||
3007 | 7 | * - Ugo Riboni <ugo.riboni@canonical.com> | ||
3008 | 8 | * | ||
3009 | 9 | * This program is free software; you can redistribute it and/or modify | ||
3010 | 10 | * it under the terms of the GNU General Public License as published by | ||
3011 | 11 | * the Free Software Foundation; version 3. | ||
3012 | 12 | * | ||
3013 | 13 | * This program is distributed in the hope that it will be useful, | ||
3014 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3015 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3016 | 16 | * GNU General Public License for more details. | ||
3017 | 17 | * | ||
3018 | 18 | * You should have received a copy of the GNU General Public License | ||
3019 | 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3020 | 20 | */ | ||
3021 | 21 | |||
3022 | 22 | #ifndef INPUTSHAPERECTANGLE_H | ||
3023 | 23 | #define INPUTSHAPERECTANGLE_H | ||
3024 | 24 | |||
3025 | 25 | #include <QObject> | ||
3026 | 26 | #include <QRect> | ||
3027 | 27 | #include <QBitmap> | ||
3028 | 28 | #include <QDeclarativeListProperty> | ||
3029 | 29 | #include <QList> | ||
3030 | 30 | |||
3031 | 31 | class InputShapeMask; | ||
3032 | 32 | |||
3033 | 33 | class InputShapeRectangle : public QObject | ||
3034 | 34 | { | ||
3035 | 35 | Q_OBJECT | ||
3036 | 36 | Q_PROPERTY(QRect rectangle READ rectangle WRITE setRectangle NOTIFY rectangleChanged) | ||
3037 | 37 | Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) | ||
3038 | 38 | Q_PROPERTY(bool mirrorHorizontally READ mirrorHorizontally WRITE setMirrorHorizontally NOTIFY mirrorHorizontallyChanged) | ||
3039 | 39 | Q_PROPERTY(QBitmap shape READ shape NOTIFY shapeChanged) | ||
3040 | 40 | Q_PROPERTY(QDeclarativeListProperty<InputShapeMask> masks READ masks) | ||
3041 | 41 | Q_CLASSINFO("DefaultProperty", "masks") | ||
3042 | 42 | |||
3043 | 43 | public: | ||
3044 | 44 | explicit InputShapeRectangle(QObject *parent = 0); | ||
3045 | 45 | |||
3046 | 46 | QRect rectangle() const; | ||
3047 | 47 | void setRectangle(QRect rectangle); | ||
3048 | 48 | bool enabled() const; | ||
3049 | 49 | void setEnabled(bool enabled); | ||
3050 | 50 | QBitmap shape() const; | ||
3051 | 51 | QDeclarativeListProperty<InputShapeMask> masks(); | ||
3052 | 52 | bool mirrorHorizontally() const; | ||
3053 | 53 | void setMirrorHorizontally(bool mirror); | ||
3054 | 54 | |||
3055 | 55 | protected: | ||
3056 | 56 | static void appendMask(QDeclarativeListProperty<InputShapeMask> *list, InputShapeMask *mask); | ||
3057 | 57 | |||
3058 | 58 | protected Q_SLOTS: | ||
3059 | 59 | void updateShape(); | ||
3060 | 60 | |||
3061 | 61 | Q_SIGNALS: | ||
3062 | 62 | void rectangleChanged(); | ||
3063 | 63 | void enabledChanged(); | ||
3064 | 64 | void shapeChanged(); | ||
3065 | 65 | void mirrorHorizontallyChanged(bool mirrorHorizontally); | ||
3066 | 66 | |||
3067 | 67 | private: | ||
3068 | 68 | QRect m_rectangle; | ||
3069 | 69 | bool m_enabled; | ||
3070 | 70 | bool m_mirrorHorizontally; | ||
3071 | 71 | QBitmap m_shape; | ||
3072 | 72 | QList<InputShapeMask*> m_masks; | ||
3073 | 73 | }; | ||
3074 | 74 | |||
3075 | 75 | #endif // INPUTSHAPERECTANGLE_H | ||
3076 | 0 | 76 | ||
3077 | === removed file 'libunity-2d-private/src/intellihidebehavior.cpp' | |||
3078 | --- libunity-2d-private/src/intellihidebehavior.cpp 2012-01-17 14:31:19 +0000 | |||
3079 | +++ libunity-2d-private/src/intellihidebehavior.cpp 1970-01-01 00:00:00 +0000 | |||
3080 | @@ -1,256 +0,0 @@ | |||
3081 | 1 | /* | ||
3082 | 2 | * This file is part of unity-2d | ||
3083 | 3 | * | ||
3084 | 4 | * Copyright 2011 Canonical Ltd. | ||
3085 | 5 | * | ||
3086 | 6 | * Authors: | ||
3087 | 7 | * - Aurélien Gâteau <aurelien.gateau@canonical.com> | ||
3088 | 8 | * - Florian Boucault <florian.boucault@canonical.com> | ||
3089 | 9 | * | ||
3090 | 10 | * License: GPL v3 | ||
3091 | 11 | */ | ||
3092 | 12 | // Self | ||
3093 | 13 | #include "intellihidebehavior.h" | ||
3094 | 14 | |||
3095 | 15 | // Local | ||
3096 | 16 | #include "unity2dpanel.h" | ||
3097 | 17 | |||
3098 | 18 | // libunity-2d | ||
3099 | 19 | #include <debug_p.h> | ||
3100 | 20 | #include <edgehitdetector.h> | ||
3101 | 21 | |||
3102 | 22 | // Qt | ||
3103 | 23 | #include <QCursor> | ||
3104 | 24 | #include <QEvent> | ||
3105 | 25 | #include <QTimer> | ||
3106 | 26 | #include <QWidget> | ||
3107 | 27 | #include <QDesktopWidget> | ||
3108 | 28 | |||
3109 | 29 | // libwnck | ||
3110 | 30 | extern "C" { | ||
3111 | 31 | #define WNCK_I_KNOW_THIS_IS_UNSTABLE | ||
3112 | 32 | #include <libwnck/libwnck.h> | ||
3113 | 33 | } | ||
3114 | 34 | |||
3115 | 35 | static const int AUTOHIDE_TIMEOUT = 1000; | ||
3116 | 36 | |||
3117 | 37 | // Handy macros to declare GObject callbacks. The 'n' in CALLBACKn refers to | ||
3118 | 38 | // the number of dummy arguments the callback returns | ||
3119 | 39 | #define GOBJECT_CALLBACK0(callbackName, slot) \ | ||
3120 | 40 | static void \ | ||
3121 | 41 | callbackName(GObject* src, QObject* dst) \ | ||
3122 | 42 | { \ | ||
3123 | 43 | QMetaObject::invokeMethod(dst, slot); \ | ||
3124 | 44 | } | ||
3125 | 45 | |||
3126 | 46 | #define GOBJECT_CALLBACK1(callbackName, slot) \ | ||
3127 | 47 | static void \ | ||
3128 | 48 | callbackName(GObject* src, void* dummy1, QObject* dst) \ | ||
3129 | 49 | { \ | ||
3130 | 50 | QMetaObject::invokeMethod(dst, slot); \ | ||
3131 | 51 | } | ||
3132 | 52 | |||
3133 | 53 | #define GOBJECT_CALLBACK2(callbackName, slot) \ | ||
3134 | 54 | static void \ | ||
3135 | 55 | callbackName(GObject* src, void* dummy1, void* dummy2, QObject* dst) \ | ||
3136 | 56 | { \ | ||
3137 | 57 | QMetaObject::invokeMethod(dst, slot); \ | ||
3138 | 58 | } | ||
3139 | 59 | |||
3140 | 60 | // Screen callbacks | ||
3141 | 61 | GOBJECT_CALLBACK1(activeWindowChangedCB, "updateActiveWindowConnections"); | ||
3142 | 62 | GOBJECT_CALLBACK1(activeWorkspaceChangedCB, "updateVisibility"); | ||
3143 | 63 | |||
3144 | 64 | // Window callbacks | ||
3145 | 65 | GOBJECT_CALLBACK2(stateChangedCB, "updateVisibility"); | ||
3146 | 66 | GOBJECT_CALLBACK0(geometryChangedCB, "updateVisibility"); | ||
3147 | 67 | GOBJECT_CALLBACK0(workspaceChangedCB, "updateVisibility"); | ||
3148 | 68 | |||
3149 | 69 | IntelliHideBehavior::IntelliHideBehavior(QWidget* panel) | ||
3150 | 70 | : AbstractVisibilityBehavior(panel) | ||
3151 | 71 | , m_updateVisibilityTimer(new QTimer(this)) | ||
3152 | 72 | , m_edgeHitDetector(0) | ||
3153 | 73 | , m_activeWindow(0) | ||
3154 | 74 | { | ||
3155 | 75 | m_updateVisibilityTimer->setSingleShot(true); | ||
3156 | 76 | m_updateVisibilityTimer->setInterval(AUTOHIDE_TIMEOUT); | ||
3157 | 77 | connect(m_updateVisibilityTimer, SIGNAL(timeout()), SLOT(updateVisibility())); | ||
3158 | 78 | |||
3159 | 79 | setPanel(panel); | ||
3160 | 80 | |||
3161 | 81 | WnckScreen* screen = wnck_screen_get_default(); | ||
3162 | 82 | g_signal_connect(G_OBJECT(screen), "active-window-changed", G_CALLBACK(activeWindowChangedCB), this); | ||
3163 | 83 | g_signal_connect(G_OBJECT(screen), "active-workspace-changed", G_CALLBACK(activeWorkspaceChangedCB), this); | ||
3164 | 84 | |||
3165 | 85 | updateActiveWindowConnections(); | ||
3166 | 86 | } | ||
3167 | 87 | |||
3168 | 88 | IntelliHideBehavior::~IntelliHideBehavior() | ||
3169 | 89 | { | ||
3170 | 90 | disconnectFromGSignals(); | ||
3171 | 91 | WnckScreen* screen = wnck_screen_get_default(); | ||
3172 | 92 | g_signal_handlers_disconnect_by_func(G_OBJECT(screen), gpointer(activeWindowChangedCB), this); | ||
3173 | 93 | g_signal_handlers_disconnect_by_func(G_OBJECT(screen), gpointer(activeWorkspaceChangedCB), this); | ||
3174 | 94 | } | ||
3175 | 95 | |||
3176 | 96 | void IntelliHideBehavior::disconnectFromGSignals() | ||
3177 | 97 | { | ||
3178 | 98 | if (m_activeWindow) { | ||
3179 | 99 | g_signal_handlers_disconnect_by_func(m_activeWindow, gpointer(stateChangedCB), this); | ||
3180 | 100 | g_signal_handlers_disconnect_by_func(m_activeWindow, gpointer(geometryChangedCB), this); | ||
3181 | 101 | g_signal_handlers_disconnect_by_func(m_activeWindow, gpointer(workspaceChangedCB), this); | ||
3182 | 102 | } | ||
3183 | 103 | } | ||
3184 | 104 | |||
3185 | 105 | void IntelliHideBehavior::updateActiveWindowConnections() | ||
3186 | 106 | { | ||
3187 | 107 | WnckScreen* screen = wnck_screen_get_default(); | ||
3188 | 108 | |||
3189 | 109 | disconnectFromGSignals(); | ||
3190 | 110 | m_activeWindow = 0; | ||
3191 | 111 | |||
3192 | 112 | WnckWindow* window = wnck_screen_get_active_window(screen); | ||
3193 | 113 | if (window) { | ||
3194 | 114 | m_activeWindow = window; | ||
3195 | 115 | g_signal_connect(G_OBJECT(window), "state-changed", G_CALLBACK(stateChangedCB), this); | ||
3196 | 116 | g_signal_connect(G_OBJECT(window), "geometry-changed", G_CALLBACK(geometryChangedCB), this); | ||
3197 | 117 | g_signal_connect(G_OBJECT(window), "workspace-changed", G_CALLBACK(workspaceChangedCB), this); | ||
3198 | 118 | } | ||
3199 | 119 | |||
3200 | 120 | gboolean isShowingDesktop = wnck_screen_get_showing_desktop(screen); | ||
3201 | 121 | if (isShowingDesktop) { | ||
3202 | 122 | showPanel(); | ||
3203 | 123 | } else { | ||
3204 | 124 | updateVisibility(); | ||
3205 | 125 | } | ||
3206 | 126 | } | ||
3207 | 127 | |||
3208 | 128 | void IntelliHideBehavior::updateVisibility() | ||
3209 | 129 | { | ||
3210 | 130 | if (m_panel == NULL) { | ||
3211 | 131 | return; | ||
3212 | 132 | } | ||
3213 | 133 | if (isMouseForcingVisibility()) { | ||
3214 | 134 | return; | ||
3215 | 135 | } | ||
3216 | 136 | int launcherPid = getpid(); | ||
3217 | 137 | |||
3218 | 138 | // Compute launcherRect, adjust "left" to the position where the launcher | ||
3219 | 139 | // is fully visible. | ||
3220 | 140 | QRect launcherRect = m_panel->geometry(); | ||
3221 | 141 | // FIXME: the following code assumes that the launcher is on the left edge | ||
3222 | 142 | // of the screen | ||
3223 | 143 | if (QApplication::isLeftToRight()) { | ||
3224 | 144 | launcherRect.moveLeft(0); | ||
3225 | 145 | } else { | ||
3226 | 146 | QDesktopWidget* desktop = QApplication::desktop(); | ||
3227 | 147 | const QRect screen = desktop->screenGeometry(m_panel); | ||
3228 | 148 | launcherRect.moveRight(screen.right()); | ||
3229 | 149 | } | ||
3230 | 150 | |||
3231 | 151 | WnckScreen* screen = wnck_screen_get_default(); | ||
3232 | 152 | WnckWorkspace* workspace = wnck_screen_get_active_workspace(screen); | ||
3233 | 153 | |||
3234 | 154 | // Check whether a window is crossing our launcher rect | ||
3235 | 155 | bool crossWindow = false; | ||
3236 | 156 | GList* list = wnck_screen_get_windows(screen); | ||
3237 | 157 | for (; list; list = g_list_next(list)) { | ||
3238 | 158 | WnckWindow* window = WNCK_WINDOW(list->data); | ||
3239 | 159 | if (wnck_window_is_on_workspace(window, workspace) && wnck_window_get_pid(window) != launcherPid) { | ||
3240 | 160 | WnckWindowType type = wnck_window_get_window_type(window); | ||
3241 | 161 | |||
3242 | 162 | // Only take into account typical application windows | ||
3243 | 163 | if (type != WNCK_WINDOW_NORMAL && | ||
3244 | 164 | type != WNCK_WINDOW_DIALOG && | ||
3245 | 165 | type != WNCK_WINDOW_TOOLBAR && | ||
3246 | 166 | type != WNCK_WINDOW_MENU && | ||
3247 | 167 | type != WNCK_WINDOW_UTILITY) { | ||
3248 | 168 | continue; | ||
3249 | 169 | } | ||
3250 | 170 | |||
3251 | 171 | WnckWindowState state = wnck_window_get_state(window); | ||
3252 | 172 | |||
3253 | 173 | // Skip hidden (==minimized and other states) windows | ||
3254 | 174 | if (state & WNCK_WINDOW_STATE_HIDDEN) { | ||
3255 | 175 | continue; | ||
3256 | 176 | } | ||
3257 | 177 | |||
3258 | 178 | // Check the window rect | ||
3259 | 179 | int x, y, width, height; | ||
3260 | 180 | wnck_window_get_geometry(window, &x, &y, &width, &height); | ||
3261 | 181 | QRect rect(x, y, width, height); | ||
3262 | 182 | if (rect.intersects(launcherRect)) { | ||
3263 | 183 | crossWindow = true; | ||
3264 | 184 | break; | ||
3265 | 185 | } | ||
3266 | 186 | } | ||
3267 | 187 | } | ||
3268 | 188 | |||
3269 | 189 | if (crossWindow) { | ||
3270 | 190 | hidePanel(); | ||
3271 | 191 | } else { | ||
3272 | 192 | showPanel(); | ||
3273 | 193 | } | ||
3274 | 194 | } | ||
3275 | 195 | |||
3276 | 196 | bool IntelliHideBehavior::eventFilter(QObject* object, QEvent* event) | ||
3277 | 197 | { | ||
3278 | 198 | switch (event->type()) { | ||
3279 | 199 | case QEvent::Enter: | ||
3280 | 200 | m_updateVisibilityTimer->stop(); | ||
3281 | 201 | break; | ||
3282 | 202 | case QEvent::Leave: | ||
3283 | 203 | m_updateVisibilityTimer->start(); | ||
3284 | 204 | break; | ||
3285 | 205 | default: | ||
3286 | 206 | break; | ||
3287 | 207 | } | ||
3288 | 208 | return false; | ||
3289 | 209 | } | ||
3290 | 210 | |||
3291 | 211 | bool IntelliHideBehavior::isMouseForcingVisibility() const | ||
3292 | 212 | { | ||
3293 | 213 | // We check the cursor position ourself because using QWidget::underMouse() | ||
3294 | 214 | // is unreliable. It causes LP bug #740280 | ||
3295 | 215 | return m_panel != NULL && m_panel->geometry().contains(QCursor::pos()); | ||
3296 | 216 | } | ||
3297 | 217 | |||
3298 | 218 | void IntelliHideBehavior::hidePanel() | ||
3299 | 219 | { | ||
3300 | 220 | if (m_visible) { | ||
3301 | 221 | m_visible = false; | ||
3302 | 222 | Q_EMIT visibleChanged(m_visible); | ||
3303 | 223 | createEdgeHitDetector(); | ||
3304 | 224 | } | ||
3305 | 225 | } | ||
3306 | 226 | |||
3307 | 227 | void IntelliHideBehavior::showPanel() | ||
3308 | 228 | { | ||
3309 | 229 | if (!m_visible) { | ||
3310 | 230 | // Delete the edge hit detector so that it does not prevent mouse events | ||
3311 | 231 | // from reaching the panel | ||
3312 | 232 | delete m_edgeHitDetector; | ||
3313 | 233 | m_edgeHitDetector = 0; | ||
3314 | 234 | m_visible = true; | ||
3315 | 235 | Q_EMIT visibleChanged(m_visible); | ||
3316 | 236 | } | ||
3317 | 237 | } | ||
3318 | 238 | |||
3319 | 239 | void IntelliHideBehavior::createEdgeHitDetector() | ||
3320 | 240 | { | ||
3321 | 241 | m_edgeHitDetector = new EdgeHitDetector(this); | ||
3322 | 242 | connect(m_edgeHitDetector, SIGNAL(edgeHit()), SLOT(showPanel())); | ||
3323 | 243 | } | ||
3324 | 244 | |||
3325 | 245 | void IntelliHideBehavior::setPanel(QWidget *panel) | ||
3326 | 246 | { | ||
3327 | 247 | if (m_panel != NULL) { | ||
3328 | 248 | m_panel->removeEventFilter(this); | ||
3329 | 249 | } | ||
3330 | 250 | AbstractVisibilityBehavior::setPanel(panel); | ||
3331 | 251 | if (m_panel != NULL) { | ||
3332 | 252 | m_panel->installEventFilter(this); | ||
3333 | 253 | } | ||
3334 | 254 | } | ||
3335 | 255 | |||
3336 | 256 | #include "intellihidebehavior.moc" | ||
3337 | 257 | 0 | ||
3338 | === removed file 'libunity-2d-private/src/intellihidebehavior.h' | |||
3339 | --- libunity-2d-private/src/intellihidebehavior.h 2011-06-11 11:33:52 +0000 | |||
3340 | +++ libunity-2d-private/src/intellihidebehavior.h 1970-01-01 00:00:00 +0000 | |||
3341 | @@ -1,75 +0,0 @@ | |||
3342 | 1 | /* | ||
3343 | 2 | * This file is part of unity-2d | ||
3344 | 3 | * | ||
3345 | 4 | * Copyright 2011 Canonical Ltd. | ||
3346 | 5 | * | ||
3347 | 6 | * Authors: | ||
3348 | 7 | * - Aurélien Gâteau <aurelien.gateau@canonical.com> | ||
3349 | 8 | * - Florian Boucault <florian.boucault@canonical.com> | ||
3350 | 9 | * | ||
3351 | 10 | * License: GPL v3 | ||
3352 | 11 | */ | ||
3353 | 12 | #ifndef INTELLIHIDEBEHAVIOR_H | ||
3354 | 13 | #define INTELLIHIDEBEHAVIOR_H | ||
3355 | 14 | |||
3356 | 15 | // Local | ||
3357 | 16 | #include <abstractvisibilitybehavior.h> | ||
3358 | 17 | |||
3359 | 18 | // Qt | ||
3360 | 19 | #include <QObject> | ||
3361 | 20 | |||
3362 | 21 | struct _WnckWindow; | ||
3363 | 22 | |||
3364 | 23 | class QTimer; | ||
3365 | 24 | |||
3366 | 25 | class QWidget; | ||
3367 | 26 | class EdgeHitDetector; | ||
3368 | 27 | |||
3369 | 28 | /** | ||
3370 | 29 | * This class implements the Intellihide behavior of the launcher | ||
3371 | 30 | */ | ||
3372 | 31 | class IntelliHideBehavior : public AbstractVisibilityBehavior | ||
3373 | 32 | { | ||
3374 | 33 | Q_OBJECT | ||
3375 | 34 | |||
3376 | 35 | Q_PROPERTY(QWidget* panel READ panel WRITE setPanel NOTIFY panelChanged) | ||
3377 | 36 | |||
3378 | 37 | public: | ||
3379 | 38 | IntelliHideBehavior(QWidget* panel=0); | ||
3380 | 39 | ~IntelliHideBehavior(); | ||
3381 | 40 | |||
3382 | 41 | // setters | ||
3383 | 42 | void setPanel(QWidget *panel); | ||
3384 | 43 | |||
3385 | 44 | Q_SIGNALS: | ||
3386 | 45 | void panelChanged(QWidget *panel); | ||
3387 | 46 | |||
3388 | 47 | protected: | ||
3389 | 48 | bool eventFilter(QObject*, QEvent*); | ||
3390 | 49 | |||
3391 | 50 | private Q_SLOTS: | ||
3392 | 51 | void updateVisibility(); | ||
3393 | 52 | void updateActiveWindowConnections(); | ||
3394 | 53 | void showPanel(); | ||
3395 | 54 | void hidePanel(); | ||
3396 | 55 | |||
3397 | 56 | private: | ||
3398 | 57 | Q_DISABLE_COPY(IntelliHideBehavior); | ||
3399 | 58 | |||
3400 | 59 | enum PanelVisibility { | ||
3401 | 60 | VisiblePanel, | ||
3402 | 61 | HiddenPanel | ||
3403 | 62 | }; | ||
3404 | 63 | QTimer* m_updateVisibilityTimer; | ||
3405 | 64 | EdgeHitDetector* m_edgeHitDetector; | ||
3406 | 65 | |||
3407 | 66 | struct _WnckWindow* m_activeWindow; | ||
3408 | 67 | |||
3409 | 68 | void disconnectFromGSignals(); | ||
3410 | 69 | |||
3411 | 70 | bool isMouseForcingVisibility() const; | ||
3412 | 71 | |||
3413 | 72 | void createEdgeHitDetector(); | ||
3414 | 73 | }; | ||
3415 | 74 | |||
3416 | 75 | #endif /* INTELLIHIDEBEHAVIOR_H */ | ||
3417 | 76 | 0 | ||
3418 | === modified file 'libunity-2d-private/src/launcherclient.cpp' | |||
3419 | --- libunity-2d-private/src/launcherclient.cpp 2011-12-11 16:36:28 +0000 | |||
3420 | +++ libunity-2d-private/src/launcherclient.cpp 2012-02-09 02:13:26 +0000 | |||
3421 | @@ -21,54 +21,6 @@ | |||
3422 | 21 | // Self | 21 | // Self |
3423 | 22 | #include "launcherclient.h" | 22 | #include "launcherclient.h" |
3424 | 23 | 23 | ||
3425 | 24 | // Qt | ||
3426 | 25 | #include <QDBusConnection> | ||
3427 | 26 | #include <QDBusMessage> | ||
3428 | 27 | #include <QDBusPendingCall> | ||
3429 | 28 | |||
3430 | 29 | static const char* LAUNCHER_DBUS_SERVICE = "com.canonical.Unity2d.Launcher"; | ||
3431 | 30 | static const char* LAUNCHER_DBUS_OBJECT_PATH = "/Launcher"; | ||
3432 | 31 | static const char* LAUNCHER_DBUS_INTERFACE = "com.canonical.Unity2d.Launcher"; | ||
3433 | 32 | |||
3434 | 33 | const int LauncherClient::MaximumWidth = 65; | 24 | const int LauncherClient::MaximumWidth = 65; |
3435 | 34 | 25 | ||
3436 | 35 | struct LauncherClientPrivate | ||
3437 | 36 | { | ||
3438 | 37 | LauncherClient* q; | ||
3439 | 38 | |||
3440 | 39 | void asyncDBusCall(const QString& methodName) | ||
3441 | 40 | { | ||
3442 | 41 | /* The constructor for QDBusInterface potentially does synchronous | ||
3443 | 42 | introspection calls. In contrast, this is really asynchronous. | ||
3444 | 43 | See rationale at https://bugs.launchpad.net/unity-2d/+bug/738025. */ | ||
3445 | 44 | QDBusMessage call = QDBusMessage::createMethodCall(LAUNCHER_DBUS_SERVICE, | ||
3446 | 45 | LAUNCHER_DBUS_OBJECT_PATH, | ||
3447 | 46 | LAUNCHER_DBUS_INTERFACE, | ||
3448 | 47 | methodName); | ||
3449 | 48 | QDBusConnection::sessionBus().asyncCall(call); | ||
3450 | 49 | } | ||
3451 | 50 | }; | ||
3452 | 51 | |||
3453 | 52 | LauncherClient::LauncherClient(QObject* parent) | ||
3454 | 53 | : QObject(parent) | ||
3455 | 54 | , d(new LauncherClientPrivate) | ||
3456 | 55 | { | ||
3457 | 56 | d->q = this; | ||
3458 | 57 | } | ||
3459 | 58 | |||
3460 | 59 | LauncherClient::~LauncherClient() | ||
3461 | 60 | { | ||
3462 | 61 | delete d; | ||
3463 | 62 | } | ||
3464 | 63 | |||
3465 | 64 | void LauncherClient::beginForceVisible() | ||
3466 | 65 | { | ||
3467 | 66 | d->asyncDBusCall("BeginForceVisible"); | ||
3468 | 67 | } | ||
3469 | 68 | |||
3470 | 69 | void LauncherClient::endForceVisible() | ||
3471 | 70 | { | ||
3472 | 71 | d->asyncDBusCall("EndForceVisible"); | ||
3473 | 72 | } | ||
3474 | 73 | |||
3475 | 74 | #include "launcherclient.moc" | 26 | #include "launcherclient.moc" |
3476 | 75 | 27 | ||
3477 | === modified file 'libunity-2d-private/src/launcherclient.h' | |||
3478 | --- libunity-2d-private/src/launcherclient.h 2011-03-22 11:30:53 +0000 | |||
3479 | +++ libunity-2d-private/src/launcherclient.h 2012-02-09 02:13:26 +0000 | |||
3480 | @@ -26,26 +26,13 @@ | |||
3481 | 26 | // Qt | 26 | // Qt |
3482 | 27 | #include <QObject> | 27 | #include <QObject> |
3483 | 28 | 28 | ||
3484 | 29 | struct LauncherClientPrivate; | ||
3485 | 30 | /** | 29 | /** |
3486 | 31 | * Makes it easy for unity-2d components to communicate with unity-2d-launcher | 30 | * Makes it easy for unity-2d components to communicate with unity-2d-launcher |
3487 | 32 | */ | 31 | */ |
3489 | 33 | class LauncherClient : public QObject | 32 | class LauncherClient |
3490 | 34 | { | 33 | { |
3491 | 35 | Q_OBJECT | ||
3492 | 36 | public: | 34 | public: |
3493 | 37 | // The amount of pixels used by the launcher on the left edge when it is | ||
3494 | 38 | // fully visible. | ||
3495 | 39 | static const int MaximumWidth; | 35 | static const int MaximumWidth; |
3496 | 40 | |||
3497 | 41 | LauncherClient(QObject* parent = 0); | ||
3498 | 42 | ~LauncherClient(); | ||
3499 | 43 | |||
3500 | 44 | void beginForceVisible(); | ||
3501 | 45 | void endForceVisible(); | ||
3502 | 46 | |||
3503 | 47 | private: | ||
3504 | 48 | LauncherClientPrivate* const d; | ||
3505 | 49 | }; | 36 | }; |
3506 | 50 | 37 | ||
3507 | 51 | #endif /* LAUNCHERCLIENT_H */ | 38 | #endif /* LAUNCHERCLIENT_H */ |
3508 | 52 | 39 | ||
3509 | === removed file 'libunity-2d-private/src/mousearea.cpp' | |||
3510 | --- libunity-2d-private/src/mousearea.cpp 2011-06-11 10:50:03 +0000 | |||
3511 | +++ libunity-2d-private/src/mousearea.cpp 1970-01-01 00:00:00 +0000 | |||
3512 | @@ -1,117 +0,0 @@ | |||
3513 | 1 | /* | ||
3514 | 2 | * This file is part of unity-2d | ||
3515 | 3 | * | ||
3516 | 4 | * Copyright 2011 Canonical Ltd. | ||
3517 | 5 | * | ||
3518 | 6 | * Authors: | ||
3519 | 7 | * - Aurélien Gâteau <aurelien.gateau@canonical.com> | ||
3520 | 8 | * | ||
3521 | 9 | * This program is free software; you can redistribute it and/or modify | ||
3522 | 10 | * it under the terms of the GNU General Public License as published | ||
3523 | 11 | * by the Free Software Foundation; version 3. | ||
3524 | 12 | * | ||
3525 | 13 | * This program is distributed in the hope that it will be useful, | ||
3526 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3527 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3528 | 16 | * GNU General Public License for more details. | ||
3529 | 17 | * | ||
3530 | 18 | * You should have received a copy of the GNU General Public License | ||
3531 | 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3532 | 20 | */ | ||
3533 | 21 | // Self | ||
3534 | 22 | #include "mousearea.h" | ||
3535 | 23 | |||
3536 | 24 | // Local | ||
3537 | 25 | #include <debug_p.h> | ||
3538 | 26 | |||
3539 | 27 | // Qt | ||
3540 | 28 | #include <QX11Info> | ||
3541 | 29 | |||
3542 | 30 | // X11 | ||
3543 | 31 | #include <X11/Xlib.h> | ||
3544 | 32 | |||
3545 | 33 | struct MouseAreaPrivate | ||
3546 | 34 | { | ||
3547 | 35 | Window m_window; | ||
3548 | 36 | QRect m_geometry; | ||
3549 | 37 | bool m_containsMouse; | ||
3550 | 38 | }; | ||
3551 | 39 | |||
3552 | 40 | MouseArea::MouseArea(QObject* parent) | ||
3553 | 41 | : QObject(parent) | ||
3554 | 42 | , d(new MouseAreaPrivate) | ||
3555 | 43 | { | ||
3556 | 44 | Unity2dApplication* application = Unity2dApplication::instance(); | ||
3557 | 45 | if (application == NULL) { | ||
3558 | 46 | /* This can happen for example when using qmlviewer */ | ||
3559 | 47 | UQ_WARNING << "The application is not an Unity2dApplication." | ||
3560 | 48 | "MouseArea disabled."; | ||
3561 | 49 | } else { | ||
3562 | 50 | application->installX11EventFilter(this); | ||
3563 | 51 | } | ||
3564 | 52 | |||
3565 | 53 | d->m_containsMouse = false; | ||
3566 | 54 | |||
3567 | 55 | XSetWindowAttributes attributes; | ||
3568 | 56 | attributes.override_redirect = True; | ||
3569 | 57 | attributes.event_mask = EnterWindowMask | LeaveWindowMask; | ||
3570 | 58 | unsigned long attributesMask = CWOverrideRedirect | CWEventMask; | ||
3571 | 59 | |||
3572 | 60 | d->m_geometry = QRect(0, 0, 1, 1); | ||
3573 | 61 | |||
3574 | 62 | d->m_window = XCreateWindow(QX11Info::display(), QX11Info::appRootWindow(), | ||
3575 | 63 | 0, 0, 1, 1, // geometry | ||
3576 | 64 | 0, // border_width | ||
3577 | 65 | 0, // depth | ||
3578 | 66 | InputOnly, // class | ||
3579 | 67 | CopyFromParent, // visual | ||
3580 | 68 | attributesMask, | ||
3581 | 69 | &attributes); | ||
3582 | 70 | |||
3583 | 71 | XMapWindow(QX11Info::display(), d->m_window); | ||
3584 | 72 | } | ||
3585 | 73 | |||
3586 | 74 | MouseArea::~MouseArea() | ||
3587 | 75 | { | ||
3588 | 76 | XDestroyWindow(QX11Info::display(), d->m_window); | ||
3589 | 77 | delete d; | ||
3590 | 78 | } | ||
3591 | 79 | |||
3592 | 80 | QRect MouseArea::geometry() const | ||
3593 | 81 | { | ||
3594 | 82 | return d->m_geometry; | ||
3595 | 83 | } | ||
3596 | 84 | |||
3597 | 85 | void MouseArea::setGeometry(const QRect& rect) | ||
3598 | 86 | { | ||
3599 | 87 | setGeometry(rect.x(), rect.y(), rect.width(), rect.height()); | ||
3600 | 88 | } | ||
3601 | 89 | |||
3602 | 90 | void MouseArea::setGeometry(int x, int y, int width, int height) | ||
3603 | 91 | { | ||
3604 | 92 | d->m_geometry = QRect(x, y, width, height); | ||
3605 | 93 | XMoveResizeWindow(QX11Info::display(), d->m_window, x, y, width, height); | ||
3606 | 94 | } | ||
3607 | 95 | |||
3608 | 96 | bool MouseArea::x11EventFilter(XEvent* _event) | ||
3609 | 97 | { | ||
3610 | 98 | if (_event->type == EnterNotify || _event->type == LeaveNotify) { | ||
3611 | 99 | XCrossingEvent* event = (XCrossingEvent*)(_event); | ||
3612 | 100 | if (event->window == d->m_window) { | ||
3613 | 101 | d->m_containsMouse = event->type == EnterNotify; | ||
3614 | 102 | if (d->m_containsMouse) { | ||
3615 | 103 | entered(); | ||
3616 | 104 | } else { | ||
3617 | 105 | exited(); | ||
3618 | 106 | } | ||
3619 | 107 | } | ||
3620 | 108 | } | ||
3621 | 109 | return false; | ||
3622 | 110 | } | ||
3623 | 111 | |||
3624 | 112 | bool MouseArea::containsMouse() const | ||
3625 | 113 | { | ||
3626 | 114 | return d->m_containsMouse; | ||
3627 | 115 | } | ||
3628 | 116 | |||
3629 | 117 | #include "mousearea.moc" | ||
3630 | 118 | 0 | ||
3631 | === removed file 'libunity-2d-private/src/mousearea.h' | |||
3632 | --- libunity-2d-private/src/mousearea.h 2011-02-15 18:18:13 +0000 | |||
3633 | +++ libunity-2d-private/src/mousearea.h 1970-01-01 00:00:00 +0000 | |||
3634 | @@ -1,60 +0,0 @@ | |||
3635 | 1 | /* | ||
3636 | 2 | * This file is part of unity-2d | ||
3637 | 3 | * | ||
3638 | 4 | * Copyright 2011 Canonical Ltd. | ||
3639 | 5 | * | ||
3640 | 6 | * Authors: | ||
3641 | 7 | * - Aurélien Gâteau <aurelien.gateau@canonical.com> | ||
3642 | 8 | * | ||
3643 | 9 | * This program is free software; you can redistribute it and/or modify | ||
3644 | 10 | * it under the terms of the GNU General Public License as published | ||
3645 | 11 | * by the Free Software Foundation; version 3. | ||
3646 | 12 | * | ||
3647 | 13 | * This program is distributed in the hope that it will be useful, | ||
3648 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3649 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3650 | 16 | * GNU General Public License for more details. | ||
3651 | 17 | * | ||
3652 | 18 | * You should have received a copy of the GNU General Public License | ||
3653 | 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3654 | 20 | */ | ||
3655 | 21 | #ifndef MOUSEAREA_H | ||
3656 | 22 | #define MOUSEAREA_H | ||
3657 | 23 | |||
3658 | 24 | // Local | ||
3659 | 25 | #include <unity2dapplication.h> | ||
3660 | 26 | |||
3661 | 27 | // Qt | ||
3662 | 28 | #include <QObject> | ||
3663 | 29 | #include <QRect> | ||
3664 | 30 | |||
3665 | 31 | struct MouseAreaPrivate; | ||
3666 | 32 | /** | ||
3667 | 33 | * A class to help detecting when the mouse cursor enters an area. | ||
3668 | 34 | * Quite similar to QML MouseArea item. | ||
3669 | 35 | */ | ||
3670 | 36 | class MouseArea : public QObject, protected AbstractX11EventFilter | ||
3671 | 37 | { | ||
3672 | 38 | Q_OBJECT | ||
3673 | 39 | public: | ||
3674 | 40 | MouseArea(QObject* parent = 0); | ||
3675 | 41 | ~MouseArea(); | ||
3676 | 42 | |||
3677 | 43 | QRect geometry() const; | ||
3678 | 44 | void setGeometry(int x, int y, int width, int height); | ||
3679 | 45 | void setGeometry(const QRect&); | ||
3680 | 46 | |||
3681 | 47 | bool containsMouse() const; | ||
3682 | 48 | |||
3683 | 49 | Q_SIGNALS: | ||
3684 | 50 | void entered(); | ||
3685 | 51 | void exited(); | ||
3686 | 52 | |||
3687 | 53 | protected: | ||
3688 | 54 | bool x11EventFilter(XEvent*); | ||
3689 | 55 | |||
3690 | 56 | private: | ||
3691 | 57 | MouseAreaPrivate* const d; | ||
3692 | 58 | }; | ||
3693 | 59 | |||
3694 | 60 | #endif /* MOUSEAREA_H */ | ||
3695 | 61 | 0 | ||
3696 | === added file 'libunity-2d-private/src/spreadmonitor.cpp' | |||
3697 | --- libunity-2d-private/src/spreadmonitor.cpp 1970-01-01 00:00:00 +0000 | |||
3698 | +++ libunity-2d-private/src/spreadmonitor.cpp 2012-02-09 02:13:26 +0000 | |||
3699 | @@ -0,0 +1,61 @@ | |||
3700 | 1 | /* | ||
3701 | 2 | * Copyright (C) 2011 Canonical, Ltd. | ||
3702 | 3 | * | ||
3703 | 4 | * Authors: | ||
3704 | 5 | * Ugo Riboni <ugo.riboni@canonical.com> | ||
3705 | 6 | * | ||
3706 | 7 | * This program is free software; you can redistribute it and/or modify | ||
3707 | 8 | * it under the terms of the GNU General Public License as published by | ||
3708 | 9 | * the Free Software Foundation; version 3. | ||
3709 | 10 | * | ||
3710 | 11 | * This program is distributed in the hope that it will be useful, | ||
3711 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3712 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3713 | 14 | * GNU General Public License for more details. | ||
3714 | 15 | * | ||
3715 | 16 | * You should have received a copy of the GNU General Public License | ||
3716 | 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3717 | 18 | */ | ||
3718 | 19 | |||
3719 | 20 | // local | ||
3720 | 21 | #include "abstractdbusservicemonitor.h" | ||
3721 | 22 | #include "spreadmonitor.h" | ||
3722 | 23 | |||
3723 | 24 | // QT | ||
3724 | 25 | #include <QDBusConnection> | ||
3725 | 26 | #include <QDBusConnectionInterface> | ||
3726 | 27 | #include <QDBusReply> | ||
3727 | 28 | |||
3728 | 29 | SpreadMonitor::SpreadMonitor(QObject *parent) | ||
3729 | 30 | : AbstractDBusServiceMonitor("com.canonical.Unity2d.Spread", "/Spread", | ||
3730 | 31 | "com.canonical.Unity2d.Spread", parent) | ||
3731 | 32 | { | ||
3732 | 33 | connect(this, SIGNAL(serviceAvailableChanged(bool)), SLOT(onServiceAvailableChanged(bool))); | ||
3733 | 34 | |||
3734 | 35 | if (serviceAvailable()) { | ||
3735 | 36 | onServiceAvailableChanged(true); | ||
3736 | 37 | } | ||
3737 | 38 | } | ||
3738 | 39 | |||
3739 | 40 | void SpreadMonitor::onServiceAvailableChanged(bool available) | ||
3740 | 41 | { | ||
3741 | 42 | if (available) { | ||
3742 | 43 | connect(dbusInterface(), SIGNAL(IsShownChanged(bool)), SIGNAL(shownChanged(bool))); | ||
3743 | 44 | |||
3744 | 45 | Q_EMIT shownChanged(shown()); | ||
3745 | 46 | } else { | ||
3746 | 47 | Q_EMIT shownChanged(false); | ||
3747 | 48 | } | ||
3748 | 49 | } | ||
3749 | 50 | |||
3750 | 51 | bool SpreadMonitor::shown() const | ||
3751 | 52 | { | ||
3752 | 53 | if (dbusInterface() == 0) { | ||
3753 | 54 | return false; | ||
3754 | 55 | } else { | ||
3755 | 56 | QDBusReply<bool> result = dbusInterface()->call("IsShown"); | ||
3756 | 57 | return result.isValid() && result.value() == true; | ||
3757 | 58 | } | ||
3758 | 59 | } | ||
3759 | 60 | |||
3760 | 61 | #include "spreadmonitor.moc" | ||
3761 | 0 | 62 | ||
3762 | === added file 'libunity-2d-private/src/spreadmonitor.h' | |||
3763 | --- libunity-2d-private/src/spreadmonitor.h 1970-01-01 00:00:00 +0000 | |||
3764 | +++ libunity-2d-private/src/spreadmonitor.h 2012-02-09 02:13:26 +0000 | |||
3765 | @@ -0,0 +1,48 @@ | |||
3766 | 1 | /* | ||
3767 | 2 | * Copyright (C) 2011 Canonical, Ltd. | ||
3768 | 3 | * | ||
3769 | 4 | * Authors: | ||
3770 | 5 | * Ugo Riboni <ugo.riboni@canonical.com> | ||
3771 | 6 | * | ||
3772 | 7 | * This program is free software; you can redistribute it and/or modify | ||
3773 | 8 | * it under the terms of the GNU General Public License as published by | ||
3774 | 9 | * the Free Software Foundation; version 3. | ||
3775 | 10 | * | ||
3776 | 11 | * This program is distributed in the hope that it will be useful, | ||
3777 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3778 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3779 | 14 | * GNU General Public License for more details. | ||
3780 | 15 | * | ||
3781 | 16 | * You should have received a copy of the GNU General Public License | ||
3782 | 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3783 | 18 | */ | ||
3784 | 19 | |||
3785 | 20 | #ifndef SPREADMONITOR_H | ||
3786 | 21 | #define SPREADMONITOR_H | ||
3787 | 22 | |||
3788 | 23 | // QT | ||
3789 | 24 | #include <QObject> | ||
3790 | 25 | #include <QMetaType> | ||
3791 | 26 | |||
3792 | 27 | // local | ||
3793 | 28 | #include "abstractdbusservicemonitor.h" | ||
3794 | 29 | |||
3795 | 30 | class SpreadMonitor : public AbstractDBusServiceMonitor | ||
3796 | 31 | { | ||
3797 | 32 | Q_OBJECT | ||
3798 | 33 | Q_PROPERTY(bool shown READ shown NOTIFY shownChanged) | ||
3799 | 34 | |||
3800 | 35 | public: | ||
3801 | 36 | explicit SpreadMonitor(QObject *parent = 0); | ||
3802 | 37 | bool shown() const; | ||
3803 | 38 | |||
3804 | 39 | protected Q_SLOTS: | ||
3805 | 40 | void onServiceAvailableChanged(bool available); | ||
3806 | 41 | |||
3807 | 42 | Q_SIGNALS: | ||
3808 | 43 | void shownChanged(bool visible); | ||
3809 | 44 | }; | ||
3810 | 45 | |||
3811 | 46 | Q_DECLARE_METATYPE(SpreadMonitor*) | ||
3812 | 47 | |||
3813 | 48 | #endif // SPREADMONITOR_H | ||
3814 | 0 | 49 | ||
3815 | === added file 'libunity-2d-private/src/strutmanager.cpp' | |||
3816 | --- libunity-2d-private/src/strutmanager.cpp 1970-01-01 00:00:00 +0000 | |||
3817 | +++ libunity-2d-private/src/strutmanager.cpp 2012-02-09 02:13:26 +0000 | |||
3818 | @@ -0,0 +1,191 @@ | |||
3819 | 1 | /* | ||
3820 | 2 | * This file is part of unity-2d | ||
3821 | 3 | * | ||
3822 | 4 | * Copyright 2010, 2012 Canonical Ltd. | ||
3823 | 5 | * | ||
3824 | 6 | * Authors: | ||
3825 | 7 | * - Aurélien Gâteau <aurelien.gateau@canonical.com> | ||
3826 | 8 | * - Albert Astals Cid <albert.astals@canonical.com> | ||
3827 | 9 | * | ||
3828 | 10 | * This program is free software; you can redistribute it and/or modify | ||
3829 | 11 | * it under the terms of the GNU General Public License as published | ||
3830 | 12 | * by the Free Software Foundation; version 3. | ||
3831 | 13 | * | ||
3832 | 14 | * This program is distributed in the hope that it will be useful, | ||
3833 | 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3834 | 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3835 | 17 | * GNU General Public License for more details. | ||
3836 | 18 | * | ||
3837 | 19 | * You should have received a copy of the GNU General Public License | ||
3838 | 20 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3839 | 21 | */ | ||
3840 | 22 | |||
3841 | 23 | // Self | ||
3842 | 24 | #include "strutmanager.h" | ||
3843 | 25 | |||
3844 | 26 | // Qt | ||
3845 | 27 | #include <QApplication> | ||
3846 | 28 | #include <QDesktopWidget> | ||
3847 | 29 | #include <QX11Info> | ||
3848 | 30 | |||
3849 | 31 | // X | ||
3850 | 32 | #include <X11/Xlib.h> | ||
3851 | 33 | #include <X11/Xatom.h> | ||
3852 | 34 | |||
3853 | 35 | static void setStrut(ulong* struts, WId effectiveWinId) | ||
3854 | 36 | { | ||
3855 | 37 | static Atom atom = XInternAtom(QX11Info::display(), "_NET_WM_STRUT_PARTIAL", False); | ||
3856 | 38 | XChangeProperty(QX11Info::display(), effectiveWinId, atom, | ||
3857 | 39 | XA_CARDINAL, 32, PropModeReplace, | ||
3858 | 40 | (unsigned char *) struts, 12); | ||
3859 | 41 | } | ||
3860 | 42 | |||
3861 | 43 | StrutManager::StrutManager() | ||
3862 | 44 | : m_enabled(true), | ||
3863 | 45 | m_widget(NULL), | ||
3864 | 46 | m_edge(Unity2dPanel::TopEdge), | ||
3865 | 47 | m_width(-1), | ||
3866 | 48 | m_height(-1) | ||
3867 | 49 | { | ||
3868 | 50 | } | ||
3869 | 51 | |||
3870 | 52 | StrutManager::~StrutManager() | ||
3871 | 53 | { | ||
3872 | 54 | if (m_enabled) { | ||
3873 | 55 | releaseStrut(); | ||
3874 | 56 | } | ||
3875 | 57 | } | ||
3876 | 58 | |||
3877 | 59 | bool StrutManager::enabled() const | ||
3878 | 60 | { | ||
3879 | 61 | return m_enabled; | ||
3880 | 62 | } | ||
3881 | 63 | |||
3882 | 64 | void StrutManager::setEnabled(bool value) | ||
3883 | 65 | { | ||
3884 | 66 | if (m_enabled != value) { | ||
3885 | 67 | if (value) { | ||
3886 | 68 | reserveStrut(); | ||
3887 | 69 | } else { | ||
3888 | 70 | releaseStrut(); | ||
3889 | 71 | } | ||
3890 | 72 | m_enabled = value; | ||
3891 | 73 | Q_EMIT enabledChanged(value); | ||
3892 | 74 | } | ||
3893 | 75 | } | ||
3894 | 76 | |||
3895 | 77 | QObject *StrutManager::widget() const | ||
3896 | 78 | { | ||
3897 | 79 | return m_widget; | ||
3898 | 80 | } | ||
3899 | 81 | |||
3900 | 82 | void StrutManager::setWidget(QObject *widget) | ||
3901 | 83 | { | ||
3902 | 84 | m_widget = qobject_cast<QWidget*>(widget); | ||
3903 | 85 | Q_ASSERT(m_widget != NULL); | ||
3904 | 86 | } | ||
3905 | 87 | |||
3906 | 88 | Unity2dPanel::Edge StrutManager::edge() const | ||
3907 | 89 | { | ||
3908 | 90 | return m_edge; | ||
3909 | 91 | } | ||
3910 | 92 | |||
3911 | 93 | void StrutManager::setEdge(Unity2dPanel::Edge edge) | ||
3912 | 94 | { | ||
3913 | 95 | m_edge = edge; | ||
3914 | 96 | updateStrut(); | ||
3915 | 97 | } | ||
3916 | 98 | |||
3917 | 99 | int StrutManager::width() const | ||
3918 | 100 | { | ||
3919 | 101 | return m_width; | ||
3920 | 102 | } | ||
3921 | 103 | |||
3922 | 104 | void StrutManager::setWidth(int width) | ||
3923 | 105 | { | ||
3924 | 106 | m_width = width; | ||
3925 | 107 | } | ||
3926 | 108 | |||
3927 | 109 | int StrutManager::realWidth() const | ||
3928 | 110 | { | ||
3929 | 111 | if (m_widget == NULL) | ||
3930 | 112 | return m_width; | ||
3931 | 113 | |||
3932 | 114 | if (m_width == -1) | ||
3933 | 115 | return m_widget->width(); | ||
3934 | 116 | |||
3935 | 117 | return m_width; | ||
3936 | 118 | } | ||
3937 | 119 | |||
3938 | 120 | int StrutManager::height() const | ||
3939 | 121 | { | ||
3940 | 122 | return m_height; | ||
3941 | 123 | } | ||
3942 | 124 | |||
3943 | 125 | void StrutManager::setHeight(int height) | ||
3944 | 126 | { | ||
3945 | 127 | m_height = height; | ||
3946 | 128 | } | ||
3947 | 129 | |||
3948 | 130 | int StrutManager::realHeight() const | ||
3949 | 131 | { | ||
3950 | 132 | if (m_widget == NULL) | ||
3951 | 133 | return m_height; | ||
3952 | 134 | |||
3953 | 135 | if (m_height == -1) | ||
3954 | 136 | return m_widget->height(); | ||
3955 | 137 | |||
3956 | 138 | return m_height; | ||
3957 | 139 | } | ||
3958 | 140 | |||
3959 | 141 | void StrutManager::updateStrut() | ||
3960 | 142 | { | ||
3961 | 143 | if (m_enabled) { | ||
3962 | 144 | reserveStrut(); | ||
3963 | 145 | } | ||
3964 | 146 | } | ||
3965 | 147 | |||
3966 | 148 | |||
3967 | 149 | void StrutManager::reserveStrut() | ||
3968 | 150 | { | ||
3969 | 151 | if (m_widget == NULL) | ||
3970 | 152 | return; | ||
3971 | 153 | |||
3972 | 154 | QDesktopWidget* desktop = QApplication::desktop(); | ||
3973 | 155 | const QRect screen = desktop->screenGeometry(m_widget); | ||
3974 | 156 | const QRect available = desktop->availableGeometry(m_widget); | ||
3975 | 157 | |||
3976 | 158 | ulong struts[12] = {}; | ||
3977 | 159 | switch (m_edge) { | ||
3978 | 160 | case Unity2dPanel::LeftEdge: | ||
3979 | 161 | if (QApplication::isLeftToRight()) { | ||
3980 | 162 | struts[0] = realWidth(); | ||
3981 | 163 | struts[4] = available.top(); | ||
3982 | 164 | struts[5] = available.y() + available.height(); | ||
3983 | 165 | } else { | ||
3984 | 166 | struts[1] = realWidth(); | ||
3985 | 167 | struts[6] = available.top(); | ||
3986 | 168 | struts[7] = available.y() + available.height(); | ||
3987 | 169 | } | ||
3988 | 170 | break; | ||
3989 | 171 | case Unity2dPanel::TopEdge: | ||
3990 | 172 | struts[2] = realHeight(); | ||
3991 | 173 | struts[8] = screen.left(); | ||
3992 | 174 | struts[9] = screen.x() + screen.width(); | ||
3993 | 175 | break; | ||
3994 | 176 | } | ||
3995 | 177 | |||
3996 | 178 | setStrut(struts, m_widget->effectiveWinId()); | ||
3997 | 179 | } | ||
3998 | 180 | |||
3999 | 181 | void StrutManager::releaseStrut() | ||
4000 | 182 | { | ||
4001 | 183 | if (m_widget == NULL) | ||
4002 | 184 | return; | ||
4003 | 185 | |||
4004 | 186 | ulong struts[12]; | ||
4005 | 187 | memset(struts, 0, sizeof struts); | ||
4006 | 188 | setStrut(struts, m_widget->effectiveWinId()); | ||
4007 | 189 | } | ||
4008 | 190 | |||
4009 | 191 | #include "strutmanager.moc" | ||
4010 | 0 | 192 | ||
4011 | === added file 'libunity-2d-private/src/strutmanager.h' | |||
4012 | --- libunity-2d-private/src/strutmanager.h 1970-01-01 00:00:00 +0000 | |||
4013 | +++ libunity-2d-private/src/strutmanager.h 2012-02-09 02:13:26 +0000 | |||
4014 | @@ -0,0 +1,92 @@ | |||
4015 | 1 | /* | ||
4016 | 2 | * This file is part of unity-2d | ||
4017 | 3 | * | ||
4018 | 4 | * Copyright 2010, 2012 Canonical Ltd. | ||
4019 | 5 | * | ||
4020 | 6 | * Authors: | ||
4021 | 7 | * - Aurélien Gâteau <aurelien.gateau@canonical.com> | ||
4022 | 8 | * - Albert Astals Cid <albert.astals@canonical.com> | ||
4023 | 9 | * | ||
4024 | 10 | * This program is free software; you can redistribute it and/or modify | ||
4025 | 11 | * it under the terms of the GNU General Public License as published | ||
4026 | 12 | * by the Free Software Foundation; version 3. | ||
4027 | 13 | * | ||
4028 | 14 | * This program is distributed in the hope that it will be useful, | ||
4029 | 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4030 | 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
4031 | 17 | * GNU General Public License for more details. | ||
4032 | 18 | * | ||
4033 | 19 | * You should have received a copy of the GNU General Public License | ||
4034 | 20 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
4035 | 21 | */ | ||
4036 | 22 | |||
4037 | 23 | #ifndef STRUTMANAGER_H | ||
4038 | 24 | #define STRUTMANAGER_H | ||
4039 | 25 | |||
4040 | 26 | // Unity 2D | ||
4041 | 27 | #include "unity2dpanel.h" | ||
4042 | 28 | |||
4043 | 29 | class StrutManager : public QObject | ||
4044 | 30 | { | ||
4045 | 31 | Q_OBJECT | ||
4046 | 32 | Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) | ||
4047 | 33 | Q_PROPERTY(QObject* widget READ widget WRITE setWidget) | ||
4048 | 34 | Q_PROPERTY(Unity2dPanel::Edge edge READ edge WRITE setEdge) | ||
4049 | 35 | Q_PROPERTY(int width READ width WRITE setWidth) | ||
4050 | 36 | Q_PROPERTY(int height READ height WRITE setHeight) | ||
4051 | 37 | |||
4052 | 38 | public: | ||
4053 | 39 | StrutManager(); | ||
4054 | 40 | ~StrutManager(); | ||
4055 | 41 | |||
4056 | 42 | bool enabled() const; | ||
4057 | 43 | void setEnabled(bool value); | ||
4058 | 44 | |||
4059 | 45 | // QObject due to QML constraints | ||
4060 | 46 | QObject *widget() const; | ||
4061 | 47 | void setWidget(QObject *widget); | ||
4062 | 48 | |||
4063 | 49 | Unity2dPanel::Edge edge() const; | ||
4064 | 50 | void setEdge(Unity2dPanel::Edge edge); | ||
4065 | 51 | |||
4066 | 52 | /** | ||
4067 | 53 | * Returns the width set to the strut manager | ||
4068 | 54 | * If is -1 (the default value) will use the width of the widget given in setWidget | ||
4069 | 55 | */ | ||
4070 | 56 | int width() const; | ||
4071 | 57 | void setWidth(int width); | ||
4072 | 58 | /** | ||
4073 | 59 | * Returns the actual width in use by the strut manager | ||
4074 | 60 | * It is either width() or m_widget->width() | ||
4075 | 61 | */ | ||
4076 | 62 | int realWidth() const; | ||
4077 | 63 | |||
4078 | 64 | /** | ||
4079 | 65 | * Returns the height set to the strut manager | ||
4080 | 66 | * If is -1 (the default value) will use the height of the widget given in setWidget | ||
4081 | 67 | */ | ||
4082 | 68 | int height() const; | ||
4083 | 69 | void setHeight(int height); | ||
4084 | 70 | /** | ||
4085 | 71 | * Returns the actual height in use by the strut manager | ||
4086 | 72 | * It is either width() or m_widget->width() | ||
4087 | 73 | */ | ||
4088 | 74 | int realHeight() const; | ||
4089 | 75 | |||
4090 | 76 | Q_INVOKABLE void updateStrut(); | ||
4091 | 77 | |||
4092 | 78 | Q_SIGNALS: | ||
4093 | 79 | void enabledChanged(bool enabled); | ||
4094 | 80 | |||
4095 | 81 | private: | ||
4096 | 82 | void reserveStrut(); | ||
4097 | 83 | void releaseStrut(); | ||
4098 | 84 | |||
4099 | 85 | bool m_enabled; | ||
4100 | 86 | QWidget *m_widget; | ||
4101 | 87 | Unity2dPanel::Edge m_edge; | ||
4102 | 88 | int m_width; | ||
4103 | 89 | int m_height; | ||
4104 | 90 | }; | ||
4105 | 91 | |||
4106 | 92 | #endif /* STRUTMANAGER_H */ | ||
4107 | 0 | \ No newline at end of file | 93 | \ No newline at end of file |
4108 | 1 | 94 | ||
4109 | === modified file 'libunity-2d-private/src/unity2dpanel.cpp' | |||
4110 | --- libunity-2d-private/src/unity2dpanel.cpp 2012-02-03 18:05:42 +0000 | |||
4111 | +++ libunity-2d-private/src/unity2dpanel.cpp 2012-02-09 02:13:26 +0000 | |||
4112 | @@ -21,6 +21,7 @@ | |||
4113 | 21 | 21 | ||
4114 | 22 | // Self | 22 | // Self |
4115 | 23 | #include "unity2dpanel.h" | 23 | #include "unity2dpanel.h" |
4116 | 24 | #include "strutmanager.h" | ||
4117 | 24 | #include <debug_p.h> | 25 | #include <debug_p.h> |
4118 | 25 | #include <indicatorsmanager.h> | 26 | #include <indicatorsmanager.h> |
4119 | 26 | 27 | ||
4120 | @@ -32,10 +33,6 @@ | |||
4121 | 32 | #include <QHBoxLayout> | 33 | #include <QHBoxLayout> |
4122 | 33 | #include <QX11Info> | 34 | #include <QX11Info> |
4123 | 34 | 35 | ||
4124 | 35 | // X | ||
4125 | 36 | #include <X11/Xlib.h> | ||
4126 | 37 | #include <X11/Xatom.h> | ||
4127 | 38 | |||
4128 | 39 | // unity-2d | 36 | // unity-2d |
4129 | 40 | #include "screeninfo.h" | 37 | #include "screeninfo.h" |
4130 | 41 | 38 | ||
4131 | @@ -47,57 +44,11 @@ | |||
4132 | 47 | Unity2dPanel::Edge m_edge; | 44 | Unity2dPanel::Edge m_edge; |
4133 | 48 | mutable IndicatorsManager* m_indicatorsManager; | 45 | mutable IndicatorsManager* m_indicatorsManager; |
4134 | 49 | QHBoxLayout* m_layout; | 46 | QHBoxLayout* m_layout; |
4135 | 50 | QPropertyAnimation* m_slideInAnimation; | ||
4136 | 51 | QPropertyAnimation* m_slideOutAnimation; | ||
4137 | 52 | bool m_useStrut; | ||
4138 | 53 | int m_delta; | 47 | int m_delta; |
4139 | 54 | bool m_manualSliding; | 48 | bool m_manualSliding; |
4140 | 49 | StrutManager m_strutManager; | ||
4141 | 55 | ScreenInfo* m_screenInfo; | 50 | ScreenInfo* m_screenInfo; |
4142 | 56 | 51 | ||
4143 | 57 | void setStrut(ulong* struts) | ||
4144 | 58 | { | ||
4145 | 59 | static Atom atom = XInternAtom(QX11Info::display(), "_NET_WM_STRUT_PARTIAL", False); | ||
4146 | 60 | XChangeProperty(QX11Info::display(), q->effectiveWinId(), atom, | ||
4147 | 61 | XA_CARDINAL, 32, PropModeReplace, | ||
4148 | 62 | (unsigned char *) struts, 12); | ||
4149 | 63 | } | ||
4150 | 64 | |||
4151 | 65 | void reserveStrut() | ||
4152 | 66 | { | ||
4153 | 67 | QDesktopWidget* desktop = QApplication::desktop(); | ||
4154 | 68 | const QRect screen = desktop->screenGeometry(q); | ||
4155 | 69 | const QRect available = desktop->availableGeometry(q); | ||
4156 | 70 | |||
4157 | 71 | ulong struts[12] = {}; | ||
4158 | 72 | switch (m_edge) { | ||
4159 | 73 | case Unity2dPanel::LeftEdge: | ||
4160 | 74 | if (QApplication::isLeftToRight()) { | ||
4161 | 75 | struts[0] = q->width(); | ||
4162 | 76 | struts[4] = available.top(); | ||
4163 | 77 | struts[5] = available.y() + available.height(); | ||
4164 | 78 | } else { | ||
4165 | 79 | struts[1] = q->width(); | ||
4166 | 80 | struts[6] = available.top(); | ||
4167 | 81 | struts[7] = available.y() + available.height(); | ||
4168 | 82 | } | ||
4169 | 83 | break; | ||
4170 | 84 | case Unity2dPanel::TopEdge: | ||
4171 | 85 | struts[2] = q->height(); | ||
4172 | 86 | struts[8] = screen.left(); | ||
4173 | 87 | struts[9] = screen.x() + screen.width(); | ||
4174 | 88 | break; | ||
4175 | 89 | } | ||
4176 | 90 | |||
4177 | 91 | setStrut(struts); | ||
4178 | 92 | } | ||
4179 | 93 | |||
4180 | 94 | void releaseStrut() | ||
4181 | 95 | { | ||
4182 | 96 | ulong struts[12]; | ||
4183 | 97 | memset(struts, 0, sizeof struts); | ||
4184 | 98 | setStrut(struts); | ||
4185 | 99 | } | ||
4186 | 100 | |||
4187 | 101 | void updateGeometry() | 52 | void updateGeometry() |
4188 | 102 | { | 53 | { |
4189 | 103 | const QRect screen = m_screenInfo->geometry(); | 54 | const QRect screen = m_screenInfo->geometry(); |
4190 | @@ -139,9 +90,7 @@ | |||
4191 | 139 | 90 | ||
4192 | 140 | void updateEdge() | 91 | void updateEdge() |
4193 | 141 | { | 92 | { |
4197 | 142 | if (m_useStrut) { | 93 | m_strutManager.updateStrut(); |
4195 | 143 | reserveStrut(); | ||
4196 | 144 | } | ||
4198 | 145 | updateGeometry(); | 94 | updateGeometry(); |
4199 | 146 | updateLayoutDirection(); | 95 | updateLayoutDirection(); |
4200 | 147 | } | 96 | } |
4201 | @@ -151,10 +100,11 @@ | |||
4202 | 151 | : QWidget(parent) | 100 | : QWidget(parent) |
4203 | 152 | , d(new Unity2dPanelPrivate) | 101 | , d(new Unity2dPanelPrivate) |
4204 | 153 | { | 102 | { |
4205 | 103 | d->m_strutManager.setWidget(this); | ||
4206 | 104 | d->m_strutManager.setEdge(Unity2dPanel::TopEdge); | ||
4207 | 154 | d->q = this; | 105 | d->q = this; |
4208 | 155 | d->m_edge = Unity2dPanel::TopEdge; | 106 | d->m_edge = Unity2dPanel::TopEdge; |
4209 | 156 | d->m_indicatorsManager = 0; | 107 | d->m_indicatorsManager = 0; |
4210 | 157 | d->m_useStrut = true; | ||
4211 | 158 | d->m_delta = 0; | 108 | d->m_delta = 0; |
4212 | 159 | d->m_manualSliding = false; | 109 | d->m_manualSliding = false; |
4213 | 160 | d->m_layout = new QHBoxLayout(this); | 110 | d->m_layout = new QHBoxLayout(this); |
4214 | @@ -168,18 +118,6 @@ | |||
4215 | 168 | d->m_screenInfo = new ScreenInfo(this, this); | 118 | d->m_screenInfo = new ScreenInfo(this, this); |
4216 | 169 | } | 119 | } |
4217 | 170 | 120 | ||
4218 | 171 | d->m_slideInAnimation = new QPropertyAnimation(this); | ||
4219 | 172 | d->m_slideInAnimation->setTargetObject(this); | ||
4220 | 173 | d->m_slideInAnimation->setPropertyName("delta"); | ||
4221 | 174 | d->m_slideInAnimation->setDuration(SLIDE_DURATION); | ||
4222 | 175 | d->m_slideInAnimation->setEndValue(0); | ||
4223 | 176 | |||
4224 | 177 | d->m_slideOutAnimation = new QPropertyAnimation(this); | ||
4225 | 178 | d->m_slideOutAnimation->setTargetObject(this); | ||
4226 | 179 | d->m_slideOutAnimation->setPropertyName("delta"); | ||
4227 | 180 | d->m_slideOutAnimation->setDuration(SLIDE_DURATION); | ||
4228 | 181 | d->m_slideOutAnimation->setEndValue(-panelSize()); | ||
4229 | 182 | |||
4230 | 183 | setAttribute(Qt::WA_X11NetWmWindowTypeDock); | 121 | setAttribute(Qt::WA_X11NetWmWindowTypeDock); |
4231 | 184 | setAttribute(Qt::WA_Hover); | 122 | setAttribute(Qt::WA_Hover); |
4232 | 185 | 123 | ||
4233 | @@ -190,19 +128,18 @@ | |||
4234 | 190 | } | 128 | } |
4235 | 191 | 129 | ||
4236 | 192 | connect(QApplication::desktop(), SIGNAL(workAreaResized(int)), SLOT(slotWorkAreaResized(int))); | 130 | connect(QApplication::desktop(), SIGNAL(workAreaResized(int)), SLOT(slotWorkAreaResized(int))); |
4237 | 131 | connect(&d->m_strutManager, SIGNAL(enabledChanged(bool)), SIGNAL(useStrutChanged(bool))); | ||
4238 | 193 | } | 132 | } |
4239 | 194 | 133 | ||
4240 | 195 | Unity2dPanel::~Unity2dPanel() | 134 | Unity2dPanel::~Unity2dPanel() |
4241 | 196 | { | 135 | { |
4242 | 197 | if (d->m_useStrut) { | ||
4243 | 198 | d->releaseStrut(); | ||
4244 | 199 | } | ||
4245 | 200 | delete d; | 136 | delete d; |
4246 | 201 | } | 137 | } |
4247 | 202 | 138 | ||
4248 | 203 | void Unity2dPanel::setEdge(Unity2dPanel::Edge edge) | 139 | void Unity2dPanel::setEdge(Unity2dPanel::Edge edge) |
4249 | 204 | { | 140 | { |
4250 | 205 | d->m_edge = edge; | 141 | d->m_edge = edge; |
4251 | 142 | d->m_strutManager.setEdge(edge); | ||
4252 | 206 | if (isVisible()) { | 143 | if (isVisible()) { |
4253 | 207 | d->updateEdge(); | 144 | d->updateEdge(); |
4254 | 208 | } | 145 | } |
4255 | @@ -237,13 +174,6 @@ | |||
4256 | 237 | { | 174 | { |
4257 | 238 | QWidget::showEvent(event); | 175 | QWidget::showEvent(event); |
4258 | 239 | d->updateEdge(); | 176 | d->updateEdge(); |
4259 | 240 | d->m_slideOutAnimation->setEndValue(-panelSize()); | ||
4260 | 241 | } | ||
4261 | 242 | |||
4262 | 243 | void Unity2dPanel::resizeEvent(QResizeEvent* event) | ||
4263 | 244 | { | ||
4264 | 245 | QWidget::resizeEvent(event); | ||
4265 | 246 | d->m_slideOutAnimation->setEndValue(-panelSize()); | ||
4266 | 247 | } | 177 | } |
4267 | 248 | 178 | ||
4268 | 249 | void Unity2dPanel::slotWorkAreaResized(int screen) | 179 | void Unity2dPanel::slotWorkAreaResized(int screen) |
4269 | @@ -273,20 +203,12 @@ | |||
4270 | 273 | 203 | ||
4271 | 274 | bool Unity2dPanel::useStrut() const | 204 | bool Unity2dPanel::useStrut() const |
4272 | 275 | { | 205 | { |
4274 | 276 | return d->m_useStrut; | 206 | return d->m_strutManager.enabled(); |
4275 | 277 | } | 207 | } |
4276 | 278 | 208 | ||
4277 | 279 | void Unity2dPanel::setUseStrut(bool value) | 209 | void Unity2dPanel::setUseStrut(bool value) |
4278 | 280 | { | 210 | { |
4288 | 281 | if (d->m_useStrut != value) { | 211 | d->m_strutManager.setEnabled(value); |
4280 | 282 | if (value) { | ||
4281 | 283 | d->reserveStrut(); | ||
4282 | 284 | } else { | ||
4283 | 285 | d->releaseStrut(); | ||
4284 | 286 | } | ||
4285 | 287 | d->m_useStrut = value; | ||
4286 | 288 | Q_EMIT useStrutChanged(value); | ||
4287 | 289 | } | ||
4289 | 290 | } | 212 | } |
4290 | 291 | 213 | ||
4291 | 292 | int Unity2dPanel::delta() const | 214 | int Unity2dPanel::delta() const |
4292 | @@ -309,24 +231,6 @@ | |||
4293 | 309 | return (d->m_edge == Unity2dPanel::TopEdge) ? height() : width(); | 231 | return (d->m_edge == Unity2dPanel::TopEdge) ? height() : width(); |
4294 | 310 | } | 232 | } |
4295 | 311 | 233 | ||
4296 | 312 | void Unity2dPanel::slideIn() | ||
4297 | 313 | { | ||
4298 | 314 | d->m_slideOutAnimation->stop(); | ||
4299 | 315 | if (d->m_slideInAnimation->state() != QAbstractAnimation::Running) { | ||
4300 | 316 | d->m_slideInAnimation->setStartValue(d->m_delta); | ||
4301 | 317 | d->m_slideInAnimation->start(); | ||
4302 | 318 | } | ||
4303 | 319 | } | ||
4304 | 320 | |||
4305 | 321 | void Unity2dPanel::slideOut() | ||
4306 | 322 | { | ||
4307 | 323 | d->m_slideInAnimation->stop(); | ||
4308 | 324 | if (d->m_slideOutAnimation->state() != QAbstractAnimation::Running) { | ||
4309 | 325 | d->m_slideOutAnimation->setStartValue(d->m_delta); | ||
4310 | 326 | d->m_slideOutAnimation->start(); | ||
4311 | 327 | } | ||
4312 | 328 | } | ||
4313 | 329 | |||
4314 | 330 | bool Unity2dPanel::manualSliding() const | 234 | bool Unity2dPanel::manualSliding() const |
4315 | 331 | { | 235 | { |
4316 | 332 | return d->m_manualSliding; | 236 | return d->m_manualSliding; |
4317 | @@ -336,10 +240,6 @@ | |||
4318 | 336 | { | 240 | { |
4319 | 337 | if (d->m_manualSliding != manualSliding) { | 241 | if (d->m_manualSliding != manualSliding) { |
4320 | 338 | d->m_manualSliding = manualSliding; | 242 | d->m_manualSliding = manualSliding; |
4321 | 339 | if (manualSliding) { | ||
4322 | 340 | d->m_slideInAnimation->stop(); | ||
4323 | 341 | d->m_slideOutAnimation->stop(); | ||
4324 | 342 | } | ||
4325 | 343 | Q_EMIT manualSlidingChanged(d->m_manualSliding); | 243 | Q_EMIT manualSlidingChanged(d->m_manualSliding); |
4326 | 344 | } | 244 | } |
4327 | 345 | } | 245 | } |
4328 | 346 | 246 | ||
4329 | === modified file 'libunity-2d-private/src/unity2dpanel.h' | |||
4330 | --- libunity-2d-private/src/unity2dpanel.h 2012-02-01 16:00:48 +0000 | |||
4331 | +++ libunity-2d-private/src/unity2dpanel.h 2012-02-09 02:13:26 +0000 | |||
4332 | @@ -47,6 +47,7 @@ | |||
4333 | 47 | */ | 47 | */ |
4334 | 48 | Q_PROPERTY(int manualSliding READ manualSliding WRITE setManualSliding NOTIFY manualSlidingChanged) | 48 | Q_PROPERTY(int manualSliding READ manualSliding WRITE setManualSliding NOTIFY manualSlidingChanged) |
4335 | 49 | Q_PROPERTY(bool useStrut READ useStrut WRITE setUseStrut NOTIFY useStrutChanged) | 49 | Q_PROPERTY(bool useStrut READ useStrut WRITE setUseStrut NOTIFY useStrutChanged) |
4336 | 50 | Q_ENUMS(Edge) | ||
4337 | 50 | 51 | ||
4338 | 51 | public: | 52 | public: |
4339 | 52 | enum Edge { | 53 | enum Edge { |
4340 | @@ -89,17 +90,12 @@ | |||
4341 | 89 | 90 | ||
4342 | 90 | QString id() const; | 91 | QString id() const; |
4343 | 91 | 92 | ||
4344 | 92 | public Q_SLOTS: | ||
4345 | 93 | void slideIn(); | ||
4346 | 94 | void slideOut(); | ||
4347 | 95 | |||
4348 | 96 | Q_SIGNALS: | 93 | Q_SIGNALS: |
4349 | 97 | void manualSlidingChanged(bool); | 94 | void manualSlidingChanged(bool); |
4350 | 98 | void useStrutChanged(bool); | 95 | void useStrutChanged(bool); |
4351 | 99 | 96 | ||
4352 | 100 | protected: | 97 | protected: |
4353 | 101 | virtual void showEvent(QShowEvent*); | 98 | virtual void showEvent(QShowEvent*); |
4354 | 102 | virtual void resizeEvent(QResizeEvent*); | ||
4355 | 103 | virtual void paintEvent(QPaintEvent*); | 99 | virtual void paintEvent(QPaintEvent*); |
4356 | 104 | 100 | ||
4357 | 105 | private Q_SLOTS: | 101 | private Q_SLOTS: |
4358 | 106 | 102 | ||
4359 | === added file 'libunity-2d-private/src/windowsintersectmonitor.cpp' | |||
4360 | --- libunity-2d-private/src/windowsintersectmonitor.cpp 1970-01-01 00:00:00 +0000 | |||
4361 | +++ libunity-2d-private/src/windowsintersectmonitor.cpp 2012-02-09 02:13:26 +0000 | |||
4362 | @@ -0,0 +1,183 @@ | |||
4363 | 1 | /* | ||
4364 | 2 | * This file is part of unity-2d | ||
4365 | 3 | * | ||
4366 | 4 | * Copyright 2011 Canonical Ltd. | ||
4367 | 5 | * | ||
4368 | 6 | * Authors: | ||
4369 | 7 | * - Aurélien Gâteau <aurelien.gateau@canonical.com> | ||
4370 | 8 | * - Florian Boucault <florian.boucault@canonical.com> | ||
4371 | 9 | * - Ugo Riboni <ugo.riboni@canonical.com> | ||
4372 | 10 | * | ||
4373 | 11 | * License: GPL v3 | ||
4374 | 12 | */ | ||
4375 | 13 | |||
4376 | 14 | // Self | ||
4377 | 15 | #include "windowsintersectmonitor.h" | ||
4378 | 16 | |||
4379 | 17 | // libunity-2d | ||
4380 | 18 | #include <debug_p.h> | ||
4381 | 19 | |||
4382 | 20 | // Qt | ||
4383 | 21 | #include <QCursor> | ||
4384 | 22 | #include <QEvent> | ||
4385 | 23 | #include <QTimer> | ||
4386 | 24 | #include <QWidget> | ||
4387 | 25 | #include <QDesktopWidget> | ||
4388 | 26 | |||
4389 | 27 | // libwnck | ||
4390 | 28 | extern "C" { | ||
4391 | 29 | #include <libwnck/libwnck.h> | ||
4392 | 30 | } | ||
4393 | 31 | |||
4394 | 32 | // Handy macros to declare GObject callbacks. The 'n' in CALLBACKn refers to | ||
4395 | 33 | // the number of dummy arguments the callback returns | ||
4396 | 34 | #define GOBJECT_CALLBACK0(callbackName, slot) \ | ||
4397 | 35 | static void \ | ||
4398 | 36 | callbackName(GObject* src, QObject* dst) \ | ||
4399 | 37 | { \ | ||
4400 | 38 | QMetaObject::invokeMethod(dst, slot); \ | ||
4401 | 39 | } | ||
4402 | 40 | |||
4403 | 41 | #define GOBJECT_CALLBACK1(callbackName, slot) \ | ||
4404 | 42 | static void \ | ||
4405 | 43 | callbackName(GObject* src, void* dummy1, QObject* dst) \ | ||
4406 | 44 | { \ | ||
4407 | 45 | QMetaObject::invokeMethod(dst, slot); \ | ||
4408 | 46 | } | ||
4409 | 47 | |||
4410 | 48 | #define GOBJECT_CALLBACK2(callbackName, slot) \ | ||
4411 | 49 | static void \ | ||
4412 | 50 | callbackName(GObject* src, void* dummy1, void* dummy2, QObject* dst) \ | ||
4413 | 51 | { \ | ||
4414 | 52 | QMetaObject::invokeMethod(dst, slot); \ | ||
4415 | 53 | } | ||
4416 | 54 | |||
4417 | 55 | // Screen callbacks | ||
4418 | 56 | GOBJECT_CALLBACK1(activeWindowChangedCB, "updateActiveWindowConnections"); | ||
4419 | 57 | GOBJECT_CALLBACK1(activeWorkspaceChangedCB, "updateIntersect"); | ||
4420 | 58 | GOBJECT_CALLBACK0(showingDesktopChangedCB, "updateIntersect"); | ||
4421 | 59 | |||
4422 | 60 | // Window callbacks | ||
4423 | 61 | GOBJECT_CALLBACK2(stateChangedCB, "updateIntersect"); | ||
4424 | 62 | GOBJECT_CALLBACK0(geometryChangedCB, "updateIntersect"); | ||
4425 | 63 | GOBJECT_CALLBACK0(workspaceChangedCB, "updateIntersect"); | ||
4426 | 64 | |||
4427 | 65 | WindowsIntersectMonitor::WindowsIntersectMonitor() | ||
4428 | 66 | : QObject() | ||
4429 | 67 | , m_activeWindow(0) | ||
4430 | 68 | { | ||
4431 | 69 | WnckScreen* screen = wnck_screen_get_default(); | ||
4432 | 70 | g_signal_connect(G_OBJECT(screen), "active-window-changed", G_CALLBACK(activeWindowChangedCB), this); | ||
4433 | 71 | g_signal_connect(G_OBJECT(screen), "active-workspace-changed", G_CALLBACK(activeWorkspaceChangedCB), this); | ||
4434 | 72 | g_signal_connect(G_OBJECT(screen), "showing-desktop-changed", G_CALLBACK(showingDesktopChangedCB), this); | ||
4435 | 73 | |||
4436 | 74 | updateActiveWindowConnections(); | ||
4437 | 75 | } | ||
4438 | 76 | |||
4439 | 77 | WindowsIntersectMonitor::~WindowsIntersectMonitor() | ||
4440 | 78 | { | ||
4441 | 79 | disconnectFromGSignals(); | ||
4442 | 80 | WnckScreen* screen = wnck_screen_get_default(); | ||
4443 | 81 | g_signal_handlers_disconnect_by_func(G_OBJECT(screen), gpointer(activeWindowChangedCB), this); | ||
4444 | 82 | g_signal_handlers_disconnect_by_func(G_OBJECT(screen), gpointer(activeWorkspaceChangedCB), this); | ||
4445 | 83 | g_signal_handlers_disconnect_by_func(G_OBJECT(screen), gpointer(showingDesktopChangedCB), this); | ||
4446 | 84 | } | ||
4447 | 85 | |||
4448 | 86 | void WindowsIntersectMonitor::disconnectFromGSignals() | ||
4449 | 87 | { | ||
4450 | 88 | if (m_activeWindow) { | ||
4451 | 89 | g_signal_handlers_disconnect_by_func(m_activeWindow, gpointer(stateChangedCB), this); | ||
4452 | 90 | g_signal_handlers_disconnect_by_func(m_activeWindow, gpointer(geometryChangedCB), this); | ||
4453 | 91 | g_signal_handlers_disconnect_by_func(m_activeWindow, gpointer(workspaceChangedCB), this); | ||
4454 | 92 | } | ||
4455 | 93 | } | ||
4456 | 94 | |||
4457 | 95 | void WindowsIntersectMonitor::updateActiveWindowConnections() | ||
4458 | 96 | { | ||
4459 | 97 | WnckScreen* screen = wnck_screen_get_default(); | ||
4460 | 98 | |||
4461 | 99 | disconnectFromGSignals(); | ||
4462 | 100 | m_activeWindow = 0; | ||
4463 | 101 | |||
4464 | 102 | WnckWindow* window = wnck_screen_get_active_window(screen); | ||
4465 | 103 | if (window) { | ||
4466 | 104 | m_activeWindow = window; | ||
4467 | 105 | g_signal_connect(G_OBJECT(window), "state-changed", G_CALLBACK(stateChangedCB), this); | ||
4468 | 106 | g_signal_connect(G_OBJECT(window), "geometry-changed", G_CALLBACK(geometryChangedCB), this); | ||
4469 | 107 | g_signal_connect(G_OBJECT(window), "workspace-changed", G_CALLBACK(workspaceChangedCB), this); | ||
4470 | 108 | } | ||
4471 | 109 | |||
4472 | 110 | updateIntersect(); | ||
4473 | 111 | } | ||
4474 | 112 | |||
4475 | 113 | void WindowsIntersectMonitor::updateIntersect() | ||
4476 | 114 | { | ||
4477 | 115 | int thisProcessPid = getpid(); | ||
4478 | 116 | |||
4479 | 117 | WnckScreen* screen = wnck_screen_get_default(); | ||
4480 | 118 | WnckWorkspace* workspace = wnck_screen_get_active_workspace(screen); | ||
4481 | 119 | |||
4482 | 120 | // Check whether a window is crossing our rect | ||
4483 | 121 | bool crossWindow = false; | ||
4484 | 122 | if (!wnck_screen_get_showing_desktop(screen)) { | ||
4485 | 123 | GList* list = wnck_screen_get_windows(screen); | ||
4486 | 124 | for (; list; list = g_list_next(list)) { | ||
4487 | 125 | WnckWindow* window = WNCK_WINDOW(list->data); | ||
4488 | 126 | if (wnck_window_is_on_workspace(window, workspace) && | ||
4489 | 127 | wnck_window_get_pid(window) != thisProcessPid) { | ||
4490 | 128 | WnckWindowType type = wnck_window_get_window_type(window); | ||
4491 | 129 | |||
4492 | 130 | // Only take into account typical application windows | ||
4493 | 131 | if (type != WNCK_WINDOW_NORMAL && | ||
4494 | 132 | type != WNCK_WINDOW_DIALOG && | ||
4495 | 133 | type != WNCK_WINDOW_TOOLBAR && | ||
4496 | 134 | type != WNCK_WINDOW_MENU && | ||
4497 | 135 | type != WNCK_WINDOW_UTILITY) { | ||
4498 | 136 | continue; | ||
4499 | 137 | } | ||
4500 | 138 | |||
4501 | 139 | WnckWindowState state = wnck_window_get_state(window); | ||
4502 | 140 | |||
4503 | 141 | // Skip hidden (==minimized and other states) windows | ||
4504 | 142 | if (state & WNCK_WINDOW_STATE_HIDDEN) { | ||
4505 | 143 | continue; | ||
4506 | 144 | } | ||
4507 | 145 | |||
4508 | 146 | // Check the window rect | ||
4509 | 147 | int x, y, width, height; | ||
4510 | 148 | wnck_window_get_geometry(window, &x, &y, &width, &height); | ||
4511 | 149 | QRectF rect(x, y, width, height); | ||
4512 | 150 | if (rect.intersects(m_monitoredArea)) { | ||
4513 | 151 | crossWindow = true; | ||
4514 | 152 | break; | ||
4515 | 153 | } | ||
4516 | 154 | } | ||
4517 | 155 | } | ||
4518 | 156 | } | ||
4519 | 157 | |||
4520 | 158 | if (crossWindow != m_intersects) { | ||
4521 | 159 | m_intersects = crossWindow; | ||
4522 | 160 | Q_EMIT intersectsChanged(); | ||
4523 | 161 | } | ||
4524 | 162 | } | ||
4525 | 163 | |||
4526 | 164 | QRectF WindowsIntersectMonitor::monitoredArea() const | ||
4527 | 165 | { | ||
4528 | 166 | return m_monitoredArea; | ||
4529 | 167 | } | ||
4530 | 168 | |||
4531 | 169 | void WindowsIntersectMonitor::setMonitoredArea(const QRectF& monitoredArea) | ||
4532 | 170 | { | ||
4533 | 171 | if (m_monitoredArea != monitoredArea) { | ||
4534 | 172 | m_monitoredArea = monitoredArea; | ||
4535 | 173 | Q_EMIT monitoredAreaChanged(); | ||
4536 | 174 | updateIntersect(); | ||
4537 | 175 | } | ||
4538 | 176 | } | ||
4539 | 177 | |||
4540 | 178 | bool WindowsIntersectMonitor::intersects() const | ||
4541 | 179 | { | ||
4542 | 180 | return m_intersects; | ||
4543 | 181 | } | ||
4544 | 182 | |||
4545 | 183 | #include "windowsintersectmonitor.moc" | ||
4546 | 0 | 184 | ||
4547 | === added file 'libunity-2d-private/src/windowsintersectmonitor.h' | |||
4548 | --- libunity-2d-private/src/windowsintersectmonitor.h 1970-01-01 00:00:00 +0000 | |||
4549 | +++ libunity-2d-private/src/windowsintersectmonitor.h 2012-02-09 02:13:26 +0000 | |||
4550 | @@ -0,0 +1,55 @@ | |||
4551 | 1 | /* | ||
4552 | 2 | * This file is part of unity-2d | ||
4553 | 3 | * | ||
4554 | 4 | * Copyright 2011 Canonical Ltd. | ||
4555 | 5 | * | ||
4556 | 6 | * Authors: | ||
4557 | 7 | * - Aurélien Gâteau <aurelien.gateau@canonical.com> | ||
4558 | 8 | * - Florian Boucault <florian.boucault@canonical.com> | ||
4559 | 9 | * - Ugo Riboni <ugo.riboni@canonical.com> | ||
4560 | 10 | * | ||
4561 | 11 | * License: GPL v3 | ||
4562 | 12 | */ | ||
4563 | 13 | #ifndef WINDOWSINTERSECTMONITOR_H | ||
4564 | 14 | #define WINDOWSINTERSECTMONITOR_H | ||
4565 | 15 | |||
4566 | 16 | // Qt | ||
4567 | 17 | #include <QObject> | ||
4568 | 18 | #include <QRectF> | ||
4569 | 19 | |||
4570 | 20 | struct _WnckWindow; | ||
4571 | 21 | |||
4572 | 22 | class WindowsIntersectMonitor : public QObject | ||
4573 | 23 | { | ||
4574 | 24 | Q_OBJECT | ||
4575 | 25 | |||
4576 | 26 | Q_PROPERTY(QRectF monitoredArea READ monitoredArea WRITE setMonitoredArea | ||
4577 | 27 | NOTIFY monitoredAreaChanged) | ||
4578 | 28 | Q_PROPERTY(bool intersects READ intersects NOTIFY intersectsChanged) | ||
4579 | 29 | |||
4580 | 30 | public: | ||
4581 | 31 | WindowsIntersectMonitor(); | ||
4582 | 32 | ~WindowsIntersectMonitor(); | ||
4583 | 33 | |||
4584 | 34 | QRectF monitoredArea() const; | ||
4585 | 35 | void setMonitoredArea(const QRectF& monitoredArea); | ||
4586 | 36 | bool intersects() const; | ||
4587 | 37 | |||
4588 | 38 | Q_SIGNALS: | ||
4589 | 39 | void monitoredAreaChanged(); | ||
4590 | 40 | void intersectsChanged(); | ||
4591 | 41 | |||
4592 | 42 | private Q_SLOTS: | ||
4593 | 43 | void updateIntersect(); | ||
4594 | 44 | void updateActiveWindowConnections(); | ||
4595 | 45 | |||
4596 | 46 | private: | ||
4597 | 47 | Q_DISABLE_COPY(WindowsIntersectMonitor); | ||
4598 | 48 | void disconnectFromGSignals(); | ||
4599 | 49 | |||
4600 | 50 | struct _WnckWindow* m_activeWindow; | ||
4601 | 51 | QRectF m_monitoredArea; | ||
4602 | 52 | bool m_intersects; | ||
4603 | 53 | }; | ||
4604 | 54 | |||
4605 | 55 | #endif /* WINDOWSINTERSECTMONITOR_H */ | ||
4606 | 0 | 56 | ||
4607 | === modified file 'libunity-2d-private/tests/CMakeLists.txt' | |||
4608 | --- libunity-2d-private/tests/CMakeLists.txt 2011-12-07 12:46:10 +0000 | |||
4609 | +++ libunity-2d-private/tests/CMakeLists.txt 2012-02-09 02:13:26 +0000 | |||
4610 | @@ -83,10 +83,3 @@ | |||
4611 | 83 | # COMMAND /bin/sh gnomesessionclienttest.sh | 83 | # COMMAND /bin/sh gnomesessionclienttest.sh |
4612 | 84 | # ) | 84 | # ) |
4613 | 85 | 85 | ||
4614 | 86 | # mouseareademo | ||
4615 | 87 | add_executable(mouseareademo | ||
4616 | 88 | mouseareademo.cpp | ||
4617 | 89 | ) | ||
4618 | 90 | target_link_libraries(mouseareademo | ||
4619 | 91 | unity-2d-private | ||
4620 | 92 | ) | ||
4621 | 93 | 86 | ||
4622 | === removed file 'libunity-2d-private/tests/mouseareademo.cpp' | |||
4623 | --- libunity-2d-private/tests/mouseareademo.cpp 2011-07-18 14:36:34 +0000 | |||
4624 | +++ libunity-2d-private/tests/mouseareademo.cpp 1970-01-01 00:00:00 +0000 | |||
4625 | @@ -1,48 +0,0 @@ | |||
4626 | 1 | /* | ||
4627 | 2 | * This file is part of unity-2d | ||
4628 | 3 | * | ||
4629 | 4 | * Copyright 2011 Canonical Ltd. | ||
4630 | 5 | * | ||
4631 | 6 | * Authors: | ||
4632 | 7 | * - Aurélien Gâteau <aurelien.gateau@canonical.com> | ||
4633 | 8 | * | ||
4634 | 9 | * This program is free software; you can redistribute it and/or modify | ||
4635 | 10 | * it under the terms of the GNU General Public License as published | ||
4636 | 11 | * by the Free Software Foundation; version 3. | ||
4637 | 12 | * | ||
4638 | 13 | * This program is distributed in the hope that it will be useful, | ||
4639 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4640 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
4641 | 16 | * GNU General Public License for more details. | ||
4642 | 17 | * | ||
4643 | 18 | * You should have received a copy of the GNU General Public License | ||
4644 | 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
4645 | 20 | */ | ||
4646 | 21 | |||
4647 | 22 | // Local | ||
4648 | 23 | #include <mousearea.h> | ||
4649 | 24 | #include <unity2dapplication.h> | ||
4650 | 25 | |||
4651 | 26 | // Qt | ||
4652 | 27 | #include <QLabel> | ||
4653 | 28 | #include <QVBoxLayout> | ||
4654 | 29 | |||
4655 | 30 | int main(int argc, char** argv) | ||
4656 | 31 | { | ||
4657 | 32 | Unity2dApplication::earlySetup(argc, argv); | ||
4658 | 33 | Unity2dApplication app(argc, argv); | ||
4659 | 34 | QWidget window; | ||
4660 | 35 | QLabel* enteredLabel = new QLabel("Entered"); | ||
4661 | 36 | QVBoxLayout* layout = new QVBoxLayout(&window); | ||
4662 | 37 | layout->addWidget(enteredLabel); | ||
4663 | 38 | |||
4664 | 39 | MouseArea* area = new MouseArea(&window); | ||
4665 | 40 | area->setGeometry(QRect(10, 10, 200, 100)); | ||
4666 | 41 | QObject::connect(area, SIGNAL(entered()), enteredLabel, SLOT(show())); | ||
4667 | 42 | QObject::connect(area, SIGNAL(exited()), enteredLabel, SLOT(hide())); | ||
4668 | 43 | |||
4669 | 44 | enteredLabel->setVisible(area->containsMouse()); | ||
4670 | 45 | |||
4671 | 46 | window.show(); | ||
4672 | 47 | return app.exec(); | ||
4673 | 48 | } | ||
4674 | 49 | 0 | ||
4675 | === modified file 'panel/applets/CMakeLists.txt' | |||
4676 | --- panel/applets/CMakeLists.txt 2011-08-29 00:47:24 +0000 | |||
4677 | +++ panel/applets/CMakeLists.txt 2012-02-09 02:13:26 +0000 | |||
4678 | @@ -1,5 +1,4 @@ | |||
4679 | 1 | add_subdirectory(separator) | 1 | add_subdirectory(separator) |
4680 | 2 | add_subdirectory(homebutton) | ||
4681 | 3 | add_subdirectory(appname) | 2 | add_subdirectory(appname) |
4682 | 4 | add_subdirectory(legacytray) | 3 | add_subdirectory(legacytray) |
4683 | 5 | add_subdirectory(indicator) | 4 | add_subdirectory(indicator) |
4684 | 6 | 5 | ||
4685 | === removed directory 'panel/applets/homebutton' | |||
4686 | === removed file 'panel/applets/homebutton/CMakeLists.txt' | |||
4687 | --- panel/applets/homebutton/CMakeLists.txt 2011-11-09 21:28:49 +0000 | |||
4688 | +++ panel/applets/homebutton/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
4689 | @@ -1,33 +0,0 @@ | |||
4690 | 1 | project(panelplugin-homebutton) | ||
4691 | 2 | |||
4692 | 3 | # Sources | ||
4693 | 4 | set(homebutton_SRCS | ||
4694 | 5 | homebuttonapplet.cpp | ||
4695 | 6 | homebutton.cpp | ||
4696 | 7 | plugin.cpp | ||
4697 | 8 | ) | ||
4698 | 9 | |||
4699 | 10 | # Build | ||
4700 | 11 | include_directories( | ||
4701 | 12 | ${CMAKE_CURRENT_SOURCE_DIR} | ||
4702 | 13 | ${CMAKE_CURRENT_BINARY_DIR} | ||
4703 | 14 | ${libunity-2d-private_SOURCE_DIR}/src | ||
4704 | 15 | ) | ||
4705 | 16 | |||
4706 | 17 | qt4_automoc(${homebutton_SRCS}) | ||
4707 | 18 | add_library(panelplugin-homebutton SHARED ${homebutton_SRCS}) | ||
4708 | 19 | set_target_properties(panelplugin-homebutton PROPERTIES | ||
4709 | 20 | LIBRARY_OUTPUT_DIRECTORY ".." | ||
4710 | 21 | VERSION 0 | ||
4711 | 22 | SOVERSION 0.0 | ||
4712 | 23 | ) | ||
4713 | 24 | |||
4714 | 25 | target_link_libraries(panelplugin-homebutton | ||
4715 | 26 | ${QT_QTGUI_LIBRARIES} | ||
4716 | 27 | ${QT_QTCORE_LIBRARIES} | ||
4717 | 28 | unity-2d-private | ||
4718 | 29 | ) | ||
4719 | 30 | |||
4720 | 31 | install(TARGETS panelplugin-homebutton | ||
4721 | 32 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/unity-2d/plugins/panel | ||
4722 | 33 | ) | ||
4723 | 34 | 0 | ||
4724 | === removed file 'panel/applets/homebutton/homebutton.cpp' | |||
4725 | --- panel/applets/homebutton/homebutton.cpp 2011-08-22 10:47:51 +0000 | |||
4726 | +++ panel/applets/homebutton/homebutton.cpp 1970-01-01 00:00:00 +0000 | |||
4727 | @@ -1,63 +0,0 @@ | |||
4728 | 1 | /* | ||
4729 | 2 | * This file is part of unity-2d | ||
4730 | 3 | * | ||
4731 | 4 | * Copyright 2011 Canonical Ltd. | ||
4732 | 5 | * | ||
4733 | 6 | * Authors: | ||
4734 | 7 | * - Alberto Mardegan <mardy@users.sourceforge.net> | ||
4735 | 8 | * | ||
4736 | 9 | * This program is free software; you can redistribute it and/or modify | ||
4737 | 10 | * it under the terms of the GNU General Public License as published by | ||
4738 | 11 | * the Free Software Foundation; version 3. | ||
4739 | 12 | * | ||
4740 | 13 | * This program is distributed in the hope that it will be useful, | ||
4741 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4742 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
4743 | 16 | * GNU General Public License for more details. | ||
4744 | 17 | * | ||
4745 | 18 | * You should have received a copy of the GNU General Public License | ||
4746 | 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
4747 | 20 | */ | ||
4748 | 21 | |||
4749 | 22 | // Self | ||
4750 | 23 | #include "homebutton.h" | ||
4751 | 24 | |||
4752 | 25 | // Local | ||
4753 | 26 | #include <debug_p.h> | ||
4754 | 27 | |||
4755 | 28 | // Qt | ||
4756 | 29 | #include <QApplication> | ||
4757 | 30 | |||
4758 | 31 | HomeButton::HomeButton(QWidget *parent) | ||
4759 | 32 | : QToolButton(parent) | ||
4760 | 33 | { | ||
4761 | 34 | setAutoRaise(true); | ||
4762 | 35 | setIconSize(QSize(24, 24)); | ||
4763 | 36 | QString themeIconName = QIcon::hasThemeIcon("start-here") ? "start-here" : "distributor-logo"; | ||
4764 | 37 | setIcon(QIcon::fromTheme(themeIconName)); | ||
4765 | 38 | setCheckable(true); | ||
4766 | 39 | |||
4767 | 40 | setStyleSheet( | ||
4768 | 41 | "QToolButton { border: none; margin: 0; padding: 0; width: 61 }" | ||
4769 | 42 | "QToolButton:checked, QToolButton:pressed {" | ||
4770 | 43 | " padding-top: 1px;" | ||
4771 | 44 | " padding-left: 1px;" | ||
4772 | 45 | " padding-right: -1px;" | ||
4773 | 46 | " padding-bottom: -1px;" | ||
4774 | 47 | "}" | ||
4775 | 48 | ); | ||
4776 | 49 | } | ||
4777 | 50 | |||
4778 | 51 | void HomeButton::mousePressEvent(QMouseEvent *event) | ||
4779 | 52 | { | ||
4780 | 53 | if (lastClickTime.isValid() && | ||
4781 | 54 | lastClickTime.elapsed() < QApplication::doubleClickInterval()) { | ||
4782 | 55 | /* ignore this click */ | ||
4783 | 56 | return; | ||
4784 | 57 | } | ||
4785 | 58 | |||
4786 | 59 | QToolButton::mousePressEvent(event); | ||
4787 | 60 | lastClickTime.restart(); | ||
4788 | 61 | } | ||
4789 | 62 | |||
4790 | 63 | #include "homebutton.moc" | ||
4791 | 64 | 0 | ||
4792 | === removed file 'panel/applets/homebutton/homebutton.h' | |||
4793 | --- panel/applets/homebutton/homebutton.h 2011-08-22 09:17:03 +0000 | |||
4794 | +++ panel/applets/homebutton/homebutton.h 1970-01-01 00:00:00 +0000 | |||
4795 | @@ -1,43 +0,0 @@ | |||
4796 | 1 | /* | ||
4797 | 2 | * This file is part of unity-2d | ||
4798 | 3 | * | ||
4799 | 4 | * Copyright 2011 Canonical Ltd. | ||
4800 | 5 | * | ||
4801 | 6 | * Authors: | ||
4802 | 7 | * - Alberto Mardegan <mardy@users.sourceforge.net> | ||
4803 | 8 | * | ||
4804 | 9 | * This program is free software; you can redistribute it and/or modify | ||
4805 | 10 | * it under the terms of the GNU General Public License as published by | ||
4806 | 11 | * the Free Software Foundation; version 3. | ||
4807 | 12 | * | ||
4808 | 13 | * This program is distributed in the hope that it will be useful, | ||
4809 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4810 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
4811 | 16 | * GNU General Public License for more details. | ||
4812 | 17 | * | ||
4813 | 18 | * You should have received a copy of the GNU General Public License | ||
4814 | 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
4815 | 20 | */ | ||
4816 | 21 | |||
4817 | 22 | #ifndef HOMEBUTTON_H | ||
4818 | 23 | #define HOMEBUTTON_H | ||
4819 | 24 | |||
4820 | 25 | // Qt | ||
4821 | 26 | #include <QTime> | ||
4822 | 27 | #include <QToolButton> | ||
4823 | 28 | |||
4824 | 29 | class HomeButton : public QToolButton | ||
4825 | 30 | { | ||
4826 | 31 | Q_OBJECT | ||
4827 | 32 | public: | ||
4828 | 33 | HomeButton(QWidget *parent = 0); | ||
4829 | 34 | |||
4830 | 35 | protected: | ||
4831 | 36 | void mousePressEvent(QMouseEvent*); | ||
4832 | 37 | |||
4833 | 38 | private: | ||
4834 | 39 | Q_DISABLE_COPY(HomeButton) | ||
4835 | 40 | QTime lastClickTime; | ||
4836 | 41 | }; | ||
4837 | 42 | |||
4838 | 43 | #endif /* HOMEBUTTON_H */ | ||
4839 | 44 | 0 | ||
4840 | === removed file 'panel/applets/homebutton/homebuttonapplet.cpp' | |||
4841 | --- panel/applets/homebutton/homebuttonapplet.cpp 2011-08-22 09:17:03 +0000 | |||
4842 | +++ panel/applets/homebutton/homebuttonapplet.cpp 1970-01-01 00:00:00 +0000 | |||
4843 | @@ -1,112 +0,0 @@ | |||
4844 | 1 | /* | ||
4845 | 2 | * This file is part of unity-2d | ||
4846 | 3 | * | ||
4847 | 4 | * Copyright 2010 Canonical Ltd. | ||
4848 | 5 | * | ||
4849 | 6 | * Authors: | ||
4850 | 7 | * - Aurélien Gâteau <aurelien.gateau@canonical.com> | ||
4851 | 8 | * | ||
4852 | 9 | * This program is free software; you can redistribute it and/or modify | ||
4853 | 10 | * it under the terms of the GNU General Public License as published by | ||
4854 | 11 | * the Free Software Foundation; version 3. | ||
4855 | 12 | * | ||
4856 | 13 | * This program is distributed in the hope that it will be useful, | ||
4857 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4858 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
4859 | 16 | * GNU General Public License for more details. | ||
4860 | 17 | * | ||
4861 | 18 | * You should have received a copy of the GNU General Public License | ||
4862 | 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
4863 | 20 | */ | ||
4864 | 21 | |||
4865 | 22 | // Self | ||
4866 | 23 | #include "homebuttonapplet.h" | ||
4867 | 24 | |||
4868 | 25 | // Local | ||
4869 | 26 | #include <debug_p.h> | ||
4870 | 27 | |||
4871 | 28 | // libunity-2d | ||
4872 | 29 | #include <launcherclient.h> | ||
4873 | 30 | |||
4874 | 31 | // Qt | ||
4875 | 32 | #include <QHBoxLayout> | ||
4876 | 33 | #include <QDBusInterface> | ||
4877 | 34 | #include <QDBusServiceWatcher> | ||
4878 | 35 | #include <QDBusConnectionInterface> | ||
4879 | 36 | |||
4880 | 37 | static const char* DBUS_SERVICE = "com.canonical.Unity2d.Dash"; | ||
4881 | 38 | static const char* DBUS_PATH = "/Dash"; | ||
4882 | 39 | static const char* DBUS_IFACE = "com.canonical.Unity2d.Dash"; | ||
4883 | 40 | |||
4884 | 41 | HomeButtonApplet::HomeButtonApplet(Unity2dPanel* panel) | ||
4885 | 42 | : Unity2d::PanelApplet(panel) | ||
4886 | 43 | , m_button(new HomeButton) | ||
4887 | 44 | , m_dashInterface(NULL) | ||
4888 | 45 | , m_launcherClient(new LauncherClient(this)) | ||
4889 | 46 | { | ||
4890 | 47 | connect(m_button, SIGNAL(clicked()), SLOT(toggleDash())); | ||
4891 | 48 | |||
4892 | 49 | QHBoxLayout* layout = new QHBoxLayout(this); | ||
4893 | 50 | layout->setMargin(0); | ||
4894 | 51 | layout->addWidget(m_button); | ||
4895 | 52 | |||
4896 | 53 | /* Check if the dash is already up and running by asking the bus instead of | ||
4897 | 54 | trying to create an instance of the interface. Creating an instance | ||
4898 | 55 | will cause DBUS to activate the dash and we don't want this to happen, especially | ||
4899 | 56 | during startup where the dash is started with a delay. */ | ||
4900 | 57 | QDBusConnectionInterface* sessionBusIFace = QDBusConnection::sessionBus().interface(); | ||
4901 | 58 | QDBusReply<bool> reply = sessionBusIFace->isServiceRegistered(DBUS_SERVICE); | ||
4902 | 59 | if (reply.isValid() && reply.value() == true) { | ||
4903 | 60 | connectToDash(); | ||
4904 | 61 | } else { | ||
4905 | 62 | /* If the dash is not running, setup a notification so that we can | ||
4906 | 63 | connect to it later when it comes up */ | ||
4907 | 64 | QDBusServiceWatcher* serviceWatcher = new QDBusServiceWatcher(DBUS_SERVICE, QDBusConnection::sessionBus(), | ||
4908 | 65 | QDBusServiceWatcher::WatchForRegistration, this); | ||
4909 | 66 | connect(serviceWatcher, SIGNAL(serviceRegistered(QString)), SLOT(connectToDash())); | ||
4910 | 67 | } | ||
4911 | 68 | } | ||
4912 | 69 | |||
4913 | 70 | void HomeButtonApplet::connectToDash() | ||
4914 | 71 | { | ||
4915 | 72 | if (m_dashInterface != NULL) { | ||
4916 | 73 | return; | ||
4917 | 74 | } | ||
4918 | 75 | |||
4919 | 76 | m_dashInterface = new QDBusInterface(DBUS_SERVICE, DBUS_PATH, DBUS_IFACE, | ||
4920 | 77 | QDBusConnection::sessionBus(), this); | ||
4921 | 78 | m_button->connect(m_dashInterface, SIGNAL(activeChanged(bool)), SLOT(setChecked(bool))); | ||
4922 | 79 | |||
4923 | 80 | /* Immediately update the home button with the current state of the dash */ | ||
4924 | 81 | m_button->setChecked(m_dashInterface->property("active").toBool()); | ||
4925 | 82 | } | ||
4926 | 83 | |||
4927 | 84 | void HomeButtonApplet::toggleDash() | ||
4928 | 85 | { | ||
4929 | 86 | if (m_dashInterface == NULL || !m_dashInterface->isValid()) { | ||
4930 | 87 | connectToDash(); | ||
4931 | 88 | } | ||
4932 | 89 | |||
4933 | 90 | bool dashActive = m_dashInterface->property("active").toBool(); | ||
4934 | 91 | |||
4935 | 92 | if (dashActive) { | ||
4936 | 93 | m_dashInterface->setProperty("active", false); | ||
4937 | 94 | } else { | ||
4938 | 95 | /* Call com.canonical.Unity2d.Dash.activateHome (will set com.canonical.Unity2d.Dash.active to true */ | ||
4939 | 96 | m_dashInterface->call(QDBus::Block, "activateHome"); | ||
4940 | 97 | } | ||
4941 | 98 | } | ||
4942 | 99 | |||
4943 | 100 | void HomeButtonApplet::enterEvent(QEvent* event) | ||
4944 | 101 | { | ||
4945 | 102 | QWidget::enterEvent(event); | ||
4946 | 103 | m_launcherClient->beginForceVisible(); | ||
4947 | 104 | } | ||
4948 | 105 | |||
4949 | 106 | void HomeButtonApplet::leaveEvent(QEvent* event) | ||
4950 | 107 | { | ||
4951 | 108 | QWidget::leaveEvent(event); | ||
4952 | 109 | m_launcherClient->endForceVisible(); | ||
4953 | 110 | } | ||
4954 | 111 | |||
4955 | 112 | #include "homebuttonapplet.moc" | ||
4956 | 113 | 0 | ||
4957 | === removed file 'panel/applets/homebutton/homebuttonapplet.h' | |||
4958 | --- panel/applets/homebutton/homebuttonapplet.h 2011-08-22 09:17:03 +0000 | |||
4959 | +++ panel/applets/homebutton/homebuttonapplet.h 1970-01-01 00:00:00 +0000 | |||
4960 | @@ -1,55 +0,0 @@ | |||
4961 | 1 | /* | ||
4962 | 2 | * This file is part of unity-2d | ||
4963 | 3 | * | ||
4964 | 4 | * Copyright 2010 Canonical Ltd. | ||
4965 | 5 | * | ||
4966 | 6 | * Authors: | ||
4967 | 7 | * - Aurélien Gâteau <aurelien.gateau@canonical.com> | ||
4968 | 8 | * | ||
4969 | 9 | * This program is free software; you can redistribute it and/or modify | ||
4970 | 10 | * it under the terms of the GNU General Public License as published by | ||
4971 | 11 | * the Free Software Foundation; version 3. | ||
4972 | 12 | * | ||
4973 | 13 | * This program is distributed in the hope that it will be useful, | ||
4974 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4975 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
4976 | 16 | * GNU General Public License for more details. | ||
4977 | 17 | * | ||
4978 | 18 | * You should have received a copy of the GNU General Public License | ||
4979 | 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
4980 | 20 | */ | ||
4981 | 21 | |||
4982 | 22 | #ifndef HOMEBUTTONAPPLET_H | ||
4983 | 23 | #define HOMEBUTTONAPPLET_H | ||
4984 | 24 | |||
4985 | 25 | // Local | ||
4986 | 26 | #include "homebutton.h" | ||
4987 | 27 | |||
4988 | 28 | // Unity-2d | ||
4989 | 29 | #include <panelapplet.h> | ||
4990 | 30 | |||
4991 | 31 | class QDBusInterface; | ||
4992 | 32 | class LauncherClient; | ||
4993 | 33 | |||
4994 | 34 | class HomeButtonApplet : public Unity2d::PanelApplet | ||
4995 | 35 | { | ||
4996 | 36 | Q_OBJECT | ||
4997 | 37 | public: | ||
4998 | 38 | HomeButtonApplet(Unity2dPanel* panel); | ||
4999 | 39 | |||
5000 | 40 | protected: |
The diff has been truncated for viewing.