Merge lp:~fboucault/unity-2d/no_dash_when_spread_shown into lp:unity-2d

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
Reviewer Review Type Date Requested Status
Albert Astals Cid Pending
Review via email: mp+92181@code.launchpad.net

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
=== modified file '.bzrignore'
--- .bzrignore 2012-01-18 16:08:06 +0000
+++ .bzrignore 2012-02-09 02:13:26 +0000
@@ -1,14 +1,10 @@
1config.h1config.h
22
3launcher/app/unity-2d-launcher3shell/app/dashadaptor.*
4launcher/app/launcheradaptor.*4shell/app/launcheradaptor.*
5launcher/app/unity-2d-launcher.service5shell/app/unity-2d-launcher.service
6launcher/tests/launchermenutest6shell/app/unity-2d-places.service
7launcher/tests/launcherviewtest7shell/app/unity-2d-shell
8
9places/app/unity-2d-places
10places/app/unity-2d-places.service
11places/app/dashadaptor.*
128
13spread/app/unity-2d-spread9spread/app/unity-2d-spread
14spread/app/unity-2d-spread.service10spread/app/unity-2d-spread.service
@@ -19,7 +15,6 @@
19panel/applets/indicator/indicator-config.h15panel/applets/indicator/indicator-config.h
20panel/applets/libpanelplugin-*.so.*16panel/applets/libpanelplugin-*.so.*
21panel/lib/libuqpanel.so*17panel/lib/libuqpanel.so*
22panel/tests/homebuttonapplettest
2318
24libunity-2d-private/src/libunity-2d-private.so.*19libunity-2d-private/src/libunity-2d-private.so.*
25libunity-2d-private/src/unity-2d-private.pc20libunity-2d-private/src/unity-2d-private.pc
@@ -44,6 +39,7 @@
44po/*.gmo39po/*.gmo
4540
46tests/misc/binary_dir.txt41tests/misc/binary_dir.txt
42tests/getshape/getshape
4743
48# Cmake files and generated files44# Cmake files and generated files
49Makefile45Makefile
@@ -77,10 +73,9 @@
77debian/stamp-*73debian/stamp-*
78debian/tmp74debian/tmp
79debian/unity-2d75debian/unity-2d
80debian/unity-2d-launcher
81debian/unity-2d-panel76debian/unity-2d-panel
82debian/unity-2d-places
83debian/unity-2d-spread77debian/unity-2d-spread
78debian/unity-2d-shell
84debian/libunity-2d-private079debian/libunity-2d-private0
85debian/libunity-2d-private-dev80debian/libunity-2d-private-dev
86data/gschemas.compiled81data/gschemas.compiled
8782
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2011-12-15 15:34:37 +0000
+++ CMakeLists.txt 2012-02-09 02:13:26 +0000
@@ -93,11 +93,11 @@
9393
94# Source94# Source
95add_subdirectory(libunity-2d-private)95add_subdirectory(libunity-2d-private)
96add_subdirectory(launcher)
97add_subdirectory(panel)96add_subdirectory(panel)
98add_subdirectory(places)
99add_subdirectory(spread)97add_subdirectory(spread)
98add_subdirectory(shell)
100add_subdirectory(po)99add_subdirectory(po)
100add_subdirectory(tests/getshape)
101101
102# uninstall target102# uninstall target
103configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY)103configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY)
104104
=== modified file 'README'
--- README 2011-03-22 23:20:29 +0000
+++ README 2012-02-09 02:13:26 +0000
@@ -1,19 +1,18 @@
1Compiling unity-2d1Compiling Unity 2D
2==================2==================
33
4cmake . && make4cmake . && make
55
66
7Running separate components7Running
8===========================8=======
99
10./launcher/app/unity-2d-launcher10./shell/app/unity-2d-shell
11./panel/app/unity-2d-panel11./panel/app/unity-2d-panel
12./places/app/unity-2d-places12
1313
1414Notes on the Dash
15Notes on the dash (places)15=================
16==========================
1716
18The dash exposes a D-Bus property for activation and deactivation:17The dash exposes a D-Bus property for activation and deactivation:
1918
2019
=== modified file 'debian/control'
--- debian/control 2012-02-03 09:51:46 +0000
+++ debian/control 2012-02-09 02:13:26 +0000
@@ -31,10 +31,9 @@
31Package: unity-2d31Package: unity-2d
32Architecture: all32Architecture: all
33Depends: ${misc:Depends},33Depends: ${misc:Depends},
34 unity-2d-launcher,
35 unity-2d-panel,34 unity-2d-panel,
36 unity-2d-places,
37 unity-2d-spread,35 unity-2d-spread,
36 unity-2d-shell,
38 metacity (>= 2.30.3-0ubuntu5)37 metacity (>= 2.30.3-0ubuntu5)
39Description: Unity interface for non-accelerated graphics cards38Description: Unity interface for non-accelerated graphics cards
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
@@ -72,21 +71,13 @@
72 This package contains the development header files.71 This package contains the development header files.
7372
74Package: unity-2d-launcher73Package: unity-2d-launcher
75Architecture: any74Architecture: all
76Depends: ${shlibs:Depends},75Depends: ${misc:Depends},
77 ${misc:Depends},76 unity-2d-shell,
78 unity-asset-pool,77Description: Transitional package for unity-2d-launcher
79 libunity-2d-private0 (= ${binary:Version}),78 This is a transitional package for unity-2d-launcher, and can be safely removed
80 libqt4-svg,79 after the installation is complete.
81Recommends: unity-lens-files,80
82 unity-lens-applications,
83 unity-lens-music,
84Description: Unity 2D Launcher
85 The Unity 2D launcher displays a list of running applications as well as a
86 list of favorite applications in a panel at the left of the screen.
87 Notifications from individual applications are also highlighted in the
88 launcher.
89
90Package: unity-2d-panel81Package: unity-2d-panel
91Architecture: any82Architecture: any
92Depends: ${shlibs:Depends},83Depends: ${shlibs:Depends},
@@ -105,15 +96,12 @@
105 application outside of the Unity 2D environment.96 application outside of the Unity 2D environment.
10697
107Package: unity-2d-places98Package: unity-2d-places
108Architecture: any99Architecture: all
109Depends: ${shlibs:Depends},100Depends: ${misc:Depends},
110 ${misc:Depends},101 unity-2d-shell,
111 libunity-2d-private0 (= ${binary:Version}),102Description: Transitional package for unity-2d-places
112 libqt4-svg103 This is a transitional package for unity-2d-places, and can be safely removed
113Description: Unity 2D Places104 after the installation is complete.
114 The Unity 2D places overlay over the desktop to provide quick access to
115 various categories of applications. It is part of Unity 2D and can not run
116 as a standalone application outside of the Unity 2D environment.
117105
118Package: unity-2d-spread106Package: unity-2d-spread
119Architecture: any107Architecture: any
@@ -127,6 +115,28 @@
127 switch to. It is part of Unity 2D and can not run as a standalone application115 switch to. It is part of Unity 2D and can not run as a standalone application
128 outside of the Unity 2D environment.116 outside of the Unity 2D environment.
129117
118Package: unity-2d-shell
119Architecture: any
120Depends: ${shlibs:Depends},
121 ${misc:Depends},
122 unity-asset-pool,
123 libunity-2d-private0 (= ${binary:Version}),
124 libqt4-svg,
125Recommends: unity-lens-files,
126 unity-lens-applications,
127 unity-lens-music,
128Replaces: unity-2d-launcher (<< 5.4~),
129 unity-2d-places (<< 5.4~),
130Breaks: unity-2d-launcher (<< 5.4~),
131 unity-2d-places (<< 5.4~),
132Description: Dash and Launcher for the Unity 2D environment
133 This is part of Unity 2D and can not run as a standalone application outside
134 of the Unity 2D environment. The components included are:
135 * Dash: an overlay over the desktop to provide quick access to
136 various categories of applications.
137 * Launcher: displays in a panel at the left of the screen a list of running
138 and favorite applications as well as highlighting their notifications.
139
130Package: unity-2d-dbg140Package: unity-2d-dbg
131Architecture: any141Architecture: any
132Section: debug142Section: debug
133143
=== removed file 'debian/manpages/unity-2d-launcher.1'
--- debian/manpages/unity-2d-launcher.1 2011-01-14 22:41:51 +0000
+++ debian/manpages/unity-2d-launcher.1 1970-01-01 00:00:00 +0000
@@ -1,12 +0,0 @@
1.TH unity-2d-launcher 1
2.SH NAME
3unity-2d-launcher \- Provides launcher sidebar in the Unity 2D environment
4.SH SYNOPSIS
5.B unity-2d-launcher
6provides the launcher sidebar for the Unity 2D launcher, which provides the
7icons and application switcher. It is meant to be used as the full Unity 2D
8environment
9.SH OPTIONS
10.TP
11This application takes no arguments.
12
130
=== removed file 'debian/manpages/unity-2d-places.1'
--- debian/manpages/unity-2d-places.1 2011-01-14 23:08:50 +0000
+++ debian/manpages/unity-2d-places.1 1970-01-01 00:00:00 +0000
@@ -1,12 +0,0 @@
1.TH unity-2d-places 1
2.SH NAME
3unity-2d-places \- Unity 2D Places
4.SH SYNOPSIS
5.B unity-2d-places
6displays a top panel containing the application menu and various indicators.
7It functions as part Unity 2D, and is not meant to be used as a standalone
8application.
9.SH OPTIONS
10.TP
11This application takes no arguments.
12
130
=== added file 'debian/manpages/unity-2d-shell.1'
--- debian/manpages/unity-2d-shell.1 1970-01-01 00:00:00 +0000
+++ debian/manpages/unity-2d-shell.1 2012-02-09 02:13:26 +0000
@@ -0,0 +1,17 @@
1.TH unity-2d-shell 1
2.SH NAME
3unity-2d-shell \- Unity 2D Shell
4.SH SYNOPSIS
5.B unity-2d-shell [-opengl] [-rootqml File.qml]
6displays some components of Unity 2D. It contains the launcher and dash.
7It functions as part Unity 2D, and is not meant to be used as a standalone
8application.
9It can however be used for testing or prototyping of only specific components
10of Unity 2D by using the rootqml argument.
11.SH OPTIONS
12.TP
13\fB\-opengl\fR
14Run the application using an openGL-enabled widget
15.TP
16\fB\qmlfile\fR
17The path of a QML file to load instead of the full shell
018
=== removed file 'debian/unity-2d-launcher.install.in'
--- debian/unity-2d-launcher.install.in 2011-11-09 22:26:57 +0000
+++ debian/unity-2d-launcher.install.in 1970-01-01 00:00:00 +0000
@@ -1,5 +0,0 @@
1@DEBIAN_INSTALL_PREFIX@/@CMAKE_INSTALL_BINDIR@/unity-2d-launcher
2@DEBIAN_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/dbus-1/services/unity-2d-launcher.service
3@DEBIAN_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/applications/unity-2d-launcher.desktop
4@DEBIAN_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/unity-2d/launcher/*.qml
5@DEBIAN_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/unity-2d/launcher/artwork
60
=== removed file 'debian/unity-2d-launcher.manpages'
--- debian/unity-2d-launcher.manpages 2011-01-14 22:28:06 +0000
+++ debian/unity-2d-launcher.manpages 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1debian/manpages/unity-2d-launcher.1
20
=== removed file 'debian/unity-2d-places.install.in'
--- debian/unity-2d-places.install.in 2011-11-09 22:26:57 +0000
+++ debian/unity-2d-places.install.in 1970-01-01 00:00:00 +0000
@@ -1,6 +0,0 @@
1@DEBIAN_INSTALL_PREFIX@/@CMAKE_INSTALL_BINDIR@/unity-2d-places
2@DEBIAN_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/applications/unity-2d-places.desktop
3@DEBIAN_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/dbus-1/services/unity-2d-places.service
4@DEBIAN_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/unity-2d/places/*.qml
5@DEBIAN_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/unity-2d/places/*.js
6@DEBIAN_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/unity-2d/places/artwork
70
=== removed file 'debian/unity-2d-places.manpages'
--- debian/unity-2d-places.manpages 2011-01-14 23:08:50 +0000
+++ debian/unity-2d-places.manpages 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1debian/manpages/unity-2d-places.1
20
=== added file 'debian/unity-2d-shell.install.in'
--- debian/unity-2d-shell.install.in 1970-01-01 00:00:00 +0000
+++ debian/unity-2d-shell.install.in 2012-02-09 02:13:26 +0000
@@ -0,0 +1,9 @@
1@DEBIAN_INSTALL_PREFIX@/@CMAKE_INSTALL_BINDIR@/unity-2d-shell
2@DEBIAN_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/applications/unity-2d-shell.desktop
3@DEBIAN_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/dbus-1/services/unity-2d-places.service
4@DEBIAN_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/dbus-1/services/unity-2d-launcher.service
5@DEBIAN_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/unity-2d/shell/*.qml
6@DEBIAN_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/unity-2d/shell/dash
7@DEBIAN_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/unity-2d/shell/launcher
8@DEBIAN_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/unity-2d/shell/common
9@DEBIAN_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/unity-2d/shell/artwork
010
=== added file 'debian/unity-2d-shell.manpages'
--- debian/unity-2d-shell.manpages 1970-01-01 00:00:00 +0000
+++ debian/unity-2d-shell.manpages 2012-02-09 02:13:26 +0000
@@ -0,0 +1,1 @@
1debian/manpages/unity-2d-shell.1
02
=== removed directory 'launcher'
=== removed file 'launcher/CMakeLists.txt'
--- launcher/CMakeLists.txt 2011-06-08 20:43:09 +0000
+++ launcher/CMakeLists.txt 1970-01-01 00:00:00 +0000
@@ -1,20 +0,0 @@
1project(unity-2d-launcher)
2
3include_directories(
4 ${libunity-2d-private_SOURCE_DIR}/src
5 )
6
7# Source
8add_subdirectory(app)
9add_subdirectory(tests)
10
11file(GLOB launcher_QML *.qml)
12
13# Install
14install(FILES ${launcher_QML}
15 DESTINATION ${UNITY_2D_DIR}/launcher
16 )
17
18install(DIRECTORY artwork
19 DESTINATION ${UNITY_2D_DIR}/launcher
20 )
210
=== removed directory 'launcher/app'
=== removed file 'launcher/app/CMakeLists.txt'
--- launcher/app/CMakeLists.txt 2011-11-18 10:15:49 +0000
+++ launcher/app/CMakeLists.txt 1970-01-01 00:00:00 +0000
@@ -1,70 +0,0 @@
1# Dependencies
2pkg_check_modules(GEIS REQUIRED libutouch-geis)
3pkg_check_modules(QTGCONF REQUIRED libqtgconf)
4
5# Sources
6set(launcher_SRCS
7 visibilitycontroller.cpp
8 launcherview.cpp
9 launcherdbus.cpp
10 gesturehandler.cpp
11 )
12
13set(launcher_MOC_HDRS
14 visibilitycontroller.h
15 launcherview.h
16 launcherdbus.h
17 gesturehandler.h
18 )
19
20qt4_wrap_cpp(launcher_MOC_SRCS ${launcher_MOC_HDRS})
21
22configure_file(unity-2d-launcher.service.in unity-2d-launcher.service)
23
24qt4_add_dbus_adaptor(launcher_SRCS launcher.xml
25 launcherdbus.h LauncherDBus
26 )
27
28# Build
29add_library(uqlauncher ${launcher_SRCS} ${launcher_MOC_SRCS})
30add_executable(unity-2d-launcher launcher.cpp)
31
32include_directories(
33 ${CMAKE_CURRENT_SOURCE_DIR}
34 ${CMAKE_CURRENT_BINARY_DIR}
35 ${GTK_INCLUDE_DIRS}
36 ${X11_INCLUDE_DIRS}
37 ${GEIS_INCLUDE_DIRS}
38 ${QTGCONF_INCLUDE_DIRS}
39 ${libunity-2d-private_SOURCE_DIR}/src
40 )
41
42target_link_libraries(uqlauncher
43 ${QT_QTCORE_LIBRARIES}
44 ${QT_QTGUI_LIBRARIES}
45 ${QT_QTDBUS_LIBRARIES}
46 ${QT_QTDECLARATIVE_LIBRARIES}
47 ${GTK_LDFLAGS}
48 ${X11_LDFLAGS}
49 ${GEIS_LDFLAGS}
50 ${QTGCONF_LDFLAGS}
51 ${DCONFQT_LDFLAGS}
52 unity-2d-private
53 )
54
55target_link_libraries(unity-2d-launcher
56 uqlauncher)
57
58# Install
59install(TARGETS unity-2d-launcher
60 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
61 )
62
63install(FILES unity-2d-launcher.desktop
64 DESTINATION ${CMAKE_INSTALL_DATADIR}/applications
65 )
66
67install(FILES ${CMAKE_CURRENT_BINARY_DIR}/unity-2d-launcher.service
68 DESTINATION ${CMAKE_INSTALL_DATADIR}/dbus-1/services
69 )
70
710
=== removed file 'launcher/app/launcher.cpp'
--- launcher/app/launcher.cpp 2012-02-01 15:01:21 +0000
+++ launcher/app/launcher.cpp 1970-01-01 00:00:00 +0000
@@ -1,137 +0,0 @@
1/*
2 * Copyright (C) 2010 Canonical, Ltd.
3 *
4 * Authors:
5 * Olivier Tilloy <olivier.tilloy@canonical.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 3.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20// unity-2d
21#include <gnomesessionclient.h>
22#include <launcherclient.h>
23#include <unity2dapplication.h>
24
25// Qt
26#include <QApplication>
27#include <QDesktopWidget>
28#include <QDeclarativeEngine>
29#include <QDeclarativeContext>
30#include <QDir>
31#include <QGraphicsObject>
32
33#include "config.h"
34#include "launcherview.h"
35#include "launcherdbus.h"
36#include "visibilitycontroller.h"
37#include "unity2ddebug.h"
38#include "unity2dpanel.h"
39#include "gesturehandler.h"
40#include "screeninfo.h"
41
42// libc
43#include <stdlib.h>
44
45#if defined(QMLJSDEBUGGER)
46#include <qt_private/qdeclarativedebughelper_p.h>
47#endif
48
49#if defined(QMLJSDEBUGGER) && !defined(NO_JSDEBUGGER)
50#include <jsdebuggeragent.h>
51#endif
52#if defined(QMLJSDEBUGGER) && !defined(NO_QMLOBSERVER)
53#include <qdeclarativeviewobserver.h>
54#endif
55
56#if defined(QMLJSDEBUGGER)
57
58// Enable debugging before any QDeclarativeEngine is created
59struct QmlJsDebuggingEnabler
60{
61 QmlJsDebuggingEnabler()
62 {
63 QDeclarativeDebugHelper::enableDebugging();
64 }
65};
66
67// Execute code in constructor before first QDeclarativeEngine is instantiated
68static QmlJsDebuggingEnabler enableDebuggingHelper;
69
70#endif // QMLJSDEBUGGER
71
72int main(int argc, char *argv[])
73{
74 Unity2dApplication::earlySetup(argc, argv);
75 Unity2dApplication application(argc, argv);
76 application.setApplicationName("Unity 2D Launcher");
77 QSet<QString> arguments = QSet<QString>::fromList(QCoreApplication::arguments());
78
79 GnomeSessionClient client(INSTALL_PREFIX "/share/applications/unity-2d-launcher.desktop");
80 client.connectToSessionManager();
81
82 /* Configure "artwork:" prefix so that any access to a file whose name starts
83 with that prefix resolves properly. */
84 QDir::addSearchPath("artwork", unity2dDirectory() + "/launcher/artwork");
85
86 /* Panel containing the QML declarative view, topleft screen */
87 Unity2dPanel panel(true, -1, ScreenInfo::TopLeft);
88
89 panel.setEdge(Unity2dPanel::LeftEdge);
90 panel.setFixedWidth(LauncherClient::MaximumWidth);
91 panel.setAccessibleName("Launcher");
92
93 VisibilityController* visibilityController = new VisibilityController(&panel);
94
95 /* QML declarative view */
96 LauncherView *launcherView = new LauncherView(&panel);
97 if (arguments.contains("-opengl")) {
98 launcherView->setUseOpenGL(true);
99 }
100
101 launcherView->setResizeMode(QDeclarativeView::SizeRootObjectToView);
102 launcherView->setFocus();
103
104 launcherView->engine()->addImportPath(unity2dImportPath());
105 /* Note: baseUrl seems to be picky: if it does not end with a slash,
106 setSource() will fail */
107 launcherView->engine()->setBaseUrl(QUrl::fromLocalFile(unity2dDirectory() + "/launcher/"));
108
109 launcherView->rootContext()->setContextProperty("declarativeView", launcherView);
110 launcherView->rootContext()->setContextProperty("launcherView", launcherView);
111 launcherView->rootContext()->setContextProperty("panel", &panel);
112 launcherView->rootContext()->setContextProperty("visibilityController", visibilityController);
113
114 LauncherDBus launcherDBus(visibilityController, launcherView);
115 launcherDBus.connectToBus();
116
117 launcherView->setSource(QUrl("./Launcher.qml"));
118
119 /* Composing the QML declarative view inside the panel */
120 panel.addWidget(launcherView);
121 panel.show();
122
123 /* Unset DESKTOP_AUTOSTART_ID in order to avoid child processes (launched
124 applications) to use the same client id.
125 This would prevent some applications (e.g. nautilus) from launching when
126 the launcher itself was autostarted (which is the common case when
127 running installed).
128 For a discussion, see https://bugs.launchpad.net/upicek/+bug/684160. */
129 unsetenv("DESKTOP_AUTOSTART_ID");
130
131 /* Gesture handler instance in charge of listening to gesture events and
132 trigger appropriate actions in response. */
133 GestureHandler gestureHandler(&panel);
134
135 return application.exec();
136}
137
1380
=== removed file 'launcher/app/launcherview.cpp'
--- launcher/app/launcherview.cpp 2012-02-07 10:43:40 +0000
+++ launcher/app/launcherview.cpp 1970-01-01 00:00:00 +0000
@@ -1,299 +0,0 @@
1/*
2 * Copyright (C) 2010 Canonical, Ltd.
3 *
4 * Authors:
5 * Olivier Tilloy <olivier.tilloy@canonical.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 3.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include "launcherview.h"
21
22#include <config.h>
23#include <keyboardmodifiersmonitor.h>
24#include <hotkey.h>
25#include <hotkeymonitor.h>
26#include <keymonitor.h>
27#include <screeninfo.h>
28#include <debug_p.h>
29
30#include <QApplication>
31#include <QDesktopWidget>
32#include <QX11Info>
33#include <QDebug>
34#include <QGraphicsObject>
35
36#include <QtDeclarative/qdeclarative.h>
37#include <QDeclarativeEngine>
38#include <QDeclarativeContext>
39#include <QDeclarativeImageProvider>
40#include <QtDBus/QDBusInterface>
41#include <QtDBus/QDBusPendingCall>
42#include <QtDBus/QDBusReply>
43#include <QtDBus/QDBusConnectionInterface>
44
45#include <X11/Xlib.h>
46#include <X11/Xatom.h>
47
48static const int KEY_HOLD_THRESHOLD = 250;
49
50static const char* DASH_DBUS_SERVICE = "com.canonical.Unity2d.Dash";
51static const char* DASH_DBUS_PATH = "/Dash";
52static const char* DASH_DBUS_INTERFACE = "com.canonical.Unity2d.Dash";
53static const char* SPREAD_DBUS_SERVICE = "com.canonical.Unity2d.Spread";
54static const char* SPREAD_DBUS_PATH = "/Spread";
55static const char* SPREAD_DBUS_INTERFACE = "com.canonical.Unity2d.Spread";
56
57static const char* DASH_DBUS_PROPERTY_ACTIVE = "active";
58static const char* DASH_DBUS_METHOD_ACTIVATE_HOME = "activateHome";
59static const char* SPREAD_DBUS_METHOD_IS_SHOWN = "IsShown";
60static const char* COMMANDS_LENS_ID = "commands.lens";
61
62LauncherView::LauncherView(QWidget* parent) :
63 Unity2DDeclarativeView(parent),
64 m_superKeyPressed(false), m_superKeyHeld(false)
65{
66 setTransparentBackground(QX11Info::isCompositingManagerRunning());
67
68 m_superKeyHoldTimer.setSingleShot(true);
69 m_superKeyHoldTimer.setInterval(KEY_HOLD_THRESHOLD);
70 connect(&m_superKeyHoldTimer, SIGNAL(timeout()), SLOT(updateSuperKeyHoldState()));
71 connect(this, SIGNAL(superKeyTapped()), SLOT(toggleDash()));
72
73 m_screenInfo = new ScreenInfo(ScreenInfo::TopLeft, this);
74
75 connect(&launcher2dConfiguration(), SIGNAL(superKeyEnableChanged(bool)), SLOT(updateSuperKeyMonitoring()));
76 updateSuperKeyMonitoring();
77
78 /* Alt+F1 toggle the keyboard focus between laucher and other(previous) application. */
79 Hotkey* altF1 = HotkeyMonitor::instance().getHotkeyFor(Qt::Key_F1, Qt::AltModifier);
80 connect(altF1, SIGNAL(pressed()), SLOT(onAltF1Pressed()));
81
82 /* Alt+F2 shows the dash with the commands lens activated. */
83 Hotkey* altF2 = HotkeyMonitor::instance().getHotkeyFor(Qt::Key_F2, Qt::AltModifier);
84 connect(altF2, SIGNAL(pressed()), SLOT(showCommandsLens()));
85
86 /* Super+S before 'Spread'ing, close all the contextual menus/tooltips in the launcher. */
87 Hotkey* superS = HotkeyMonitor::instance().getHotkeyFor(Qt::Key_S, Qt::MetaModifier);
88 connect(superS, SIGNAL(pressed()), SLOT(onSuperSPressed()));
89
90 /* Super+{n} for 0 ≤ n ≤ 9 activates the item with index (n + 9) % 10. */
91 for (Qt::Key key = Qt::Key_0; key <= Qt::Key_9; key = (Qt::Key) (key + 1)) {
92 Hotkey* hotkey = HotkeyMonitor::instance().getHotkeyFor(key, Qt::MetaModifier);
93 connect(hotkey, SIGNAL(pressed()), SLOT(forwardNumericHotkey()));
94 hotkey = HotkeyMonitor::instance().getHotkeyFor(key, Qt::MetaModifier | Qt::ShiftModifier);
95 connect(hotkey, SIGNAL(pressed()), SLOT(forwardNumericHotkey()));
96 }
97}
98
99LauncherView::~LauncherView()
100{
101}
102
103void
104LauncherView::focusInEvent(QFocusEvent* event)
105{
106 QDeclarativeView::focusInEvent(event);
107 Q_EMIT focusChanged(true);
108}
109
110void
111LauncherView::focusOutEvent(QFocusEvent* event)
112{
113 QDeclarativeView::focusOutEvent(event);
114 Q_EMIT focusChanged(false);
115}
116
117void
118LauncherView::updateSuperKeyMonitoring()
119{
120 KeyboardModifiersMonitor *modifiersMonitor = KeyboardModifiersMonitor::instance();
121 KeyMonitor *keyMonitor = KeyMonitor::instance();
122 HotkeyMonitor& hotkeyMonitor = HotkeyMonitor::instance();
123
124 QVariant value = launcher2dConfiguration().property("superKeyEnable");
125 if (!value.isValid() || value.toBool() == true) {
126 hotkeyMonitor.enableModifiers(Qt::MetaModifier);
127 QObject::connect(modifiersMonitor,
128 SIGNAL(keyboardModifiersChanged(Qt::KeyboardModifiers)),
129 this, SLOT(setHotkeysForModifiers(Qt::KeyboardModifiers)));
130 /* Ignore Super presses if another key was pressed simultaneously
131 (i.e. a shortcut). https://bugs.launchpad.net/unity-2d/+bug/801073 */
132 QObject::connect(keyMonitor,
133 SIGNAL(keyPressed()),
134 this, SLOT(ignoreSuperPress()));
135 setHotkeysForModifiers(modifiersMonitor->keyboardModifiers());
136 } else {
137 hotkeyMonitor.disableModifiers(Qt::MetaModifier);
138 QObject::disconnect(modifiersMonitor,
139 SIGNAL(keyboardModifiersChanged(Qt::KeyboardModifiers)),
140 this, SLOT(setHotkeysForModifiers(Qt::KeyboardModifiers)));
141 QObject::disconnect(keyMonitor,
142 SIGNAL(keyPressed()),
143 this, SLOT(ignoreSuperPress()));
144 m_superKeyHoldTimer.stop();
145 m_superKeyPressed = false;
146 if (m_superKeyHeld) {
147 m_superKeyHeld = false;
148 Q_EMIT superKeyHeldChanged(false);
149 }
150 }
151}
152
153void
154LauncherView::setHotkeysForModifiers(Qt::KeyboardModifiers modifiers)
155{
156 /* This is the new new state of the Super key (AKA Meta key), while
157 m_superKeyPressed is the previous state of the key at the last modifiers change. */
158 bool superKeyPressed = modifiers.testFlag(Qt::MetaModifier);
159
160 if (m_superKeyPressed != superKeyPressed) {
161 m_superKeyPressed = superKeyPressed;
162 if (superKeyPressed) {
163 m_superPressIgnored = false;
164 /* If the key is pressed, start up a timer to monitor if it's being held short
165 enough to qualify as just a "tap" or as a proper hold */
166 m_superKeyHoldTimer.start();
167 } else {
168 m_superKeyHoldTimer.stop();
169
170 /* If the key is released, and was not being held, it means that the user just
171 performed a "tap". Unless we're told to ignore that tap, that is. */
172 if (!m_superKeyHeld && !m_superPressIgnored) {
173 Q_EMIT superKeyTapped();
174 }
175 /* Otherwise the user just terminated a hold. */
176 else if(m_superKeyHeld){
177 m_superKeyHeld = false;
178 Q_EMIT superKeyHeldChanged(m_superKeyHeld);
179 }
180 }
181 }
182}
183
184void
185LauncherView::updateSuperKeyHoldState()
186{
187 /* If the key was released in the meantime, just do nothing, otherwise
188 consider the key being held, unless we're told to ignore it. */
189 if (m_superKeyPressed && !m_superPressIgnored) {
190 m_superKeyHeld = true;
191 Q_EMIT superKeyHeldChanged(m_superKeyHeld);
192 }
193}
194
195void
196LauncherView::ignoreSuperPress()
197{
198 /* There was a key pressed, ignore current super tap/hold */
199 m_superPressIgnored = true;
200}
201
202void
203LauncherView::forwardNumericHotkey()
204{
205 Hotkey* hotkey = qobject_cast<Hotkey*>(sender());
206 if (hotkey != NULL) {
207 /* Shortcuts from 1 to 9 should activate the items with index
208 from 1 to 9 (index 0 being the so-called "BFB" or Dash launcher).
209 Shortcut for 0 should activate item with index 10.
210 In other words, the indexes are activated in the same order as
211 the keys appear on a standard keyboard. */
212 Qt::Key key = hotkey->key();
213 if (key >= Qt::Key_1 && key <= Qt::Key_9) {
214 int index = key - Qt::Key_0;
215 if (hotkey->modifiers() & Qt::ShiftModifier) {
216 Q_EMIT newInstanceShortcutPressed(index);
217 } else {
218 Q_EMIT activateShortcutPressed(index);
219 }
220 } else if (key == Qt::Key_0) {
221 if (hotkey->modifiers() & Qt::ShiftModifier) {
222 Q_EMIT newInstanceShortcutPressed(10);
223 } else {
224 Q_EMIT activateShortcutPressed(10);
225 }
226 }
227 }
228}
229
230void
231LauncherView::toggleDash()
232{
233 QDBusInterface dashInterface(DASH_DBUS_SERVICE, DASH_DBUS_PATH, DASH_DBUS_INTERFACE);
234
235 QVariant dashActiveResult = dashInterface.property(DASH_DBUS_PROPERTY_ACTIVE);
236 if (!dashActiveResult.isValid()) {
237 UQ_WARNING << "Can't read the DBUS Dash property" << DASH_DBUS_PROPERTY_ACTIVE
238 << "on" << DASH_DBUS_SERVICE << DASH_DBUS_PATH << DASH_DBUS_INTERFACE;
239 return;
240 }
241
242 bool dashActive = dashActiveResult.toBool();
243 if (dashActive) {
244 if (!dashInterface.setProperty(DASH_DBUS_PROPERTY_ACTIVE, false)) {
245 UQ_WARNING << "Can't set the DBUS Dash property" << DASH_DBUS_PROPERTY_ACTIVE
246 << "on" << DASH_DBUS_SERVICE << DASH_DBUS_PATH << DASH_DBUS_INTERFACE;
247 }
248 } else {
249 /* Check if the spread is active before activating the dash.
250 We need to do this since the spread can't prevent the launcher from
251 monitoring the super key and therefore getting to this point if
252 it's tapped. */
253
254 /* Check if the spread is present on DBUS first, as we don't want to have DBUS
255 activate it if it's not running yet */
256 QDBusConnectionInterface* sessionBusIFace = QDBusConnection::sessionBus().interface();
257 QDBusReply<bool> reply = sessionBusIFace->isServiceRegistered(SPREAD_DBUS_SERVICE);
258 if (reply.isValid() && reply.value() == true) {
259 QDBusInterface spreadInterface(SPREAD_DBUS_SERVICE, SPREAD_DBUS_PATH,
260 SPREAD_DBUS_INTERFACE);
261
262 QDBusReply<bool> spreadActiveResult = spreadInterface.call(SPREAD_DBUS_METHOD_IS_SHOWN);
263 if (spreadActiveResult.isValid() && spreadActiveResult.value() == true) {
264 return;
265 }
266 }
267
268 dashInterface.asyncCall(DASH_DBUS_METHOD_ACTIVATE_HOME);
269 }
270}
271
272void
273LauncherView::showCommandsLens()
274{
275 QDBusInterface dashInterface(DASH_DBUS_SERVICE, DASH_DBUS_PATH, DASH_DBUS_INTERFACE);
276 dashInterface.asyncCall("activateLens", COMMANDS_LENS_ID);
277}
278
279/* BUGFIX:881458 */
280void
281LauncherView::onSuperSPressed()
282{
283 QGraphicsObject* launcher = rootObject();
284 QMetaObject::invokeMethod(launcher, "hideMenu", Qt::AutoConnection);
285}
286
287void
288LauncherView::onAltF1Pressed()
289{
290 QGraphicsObject* launcher = rootObject();
291
292 if (hasFocus()) {
293 QMetaObject::invokeMethod(launcher, "hideMenu", Qt::AutoConnection);
294 forceDeactivateWindow();
295 } else {
296 forceActivateWindow();
297 QMetaObject::invokeMethod(launcher, "focusBFB", Qt::AutoConnection);
298 }
299}
3000
=== removed file 'launcher/app/launcherview.h'
--- launcher/app/launcherview.h 2011-11-25 12:32:03 +0000
+++ launcher/app/launcherview.h 1970-01-01 00:00:00 +0000
@@ -1,79 +0,0 @@
1/*
2 * Copyright (C) 2010 Canonical, Ltd.
3 *
4 * Authors:
5 * Olivier Tilloy <olivier.tilloy@canonical.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 3.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef LAUNCHERVIEW
21#define LAUNCHERVIEW
22
23#include <QDeclarativeView>
24#include <QList>
25#include <QUrl>
26#include <QTimer>
27#include <QVariant>
28
29#include <unity2ddeclarativeview.h>
30
31class DeclarativeDragDropEvent;
32class LauncherDBus;
33
34class LauncherView : public Unity2DDeclarativeView
35{
36 Q_OBJECT
37 Q_PROPERTY(bool superKeyHeld READ superKeyHeld NOTIFY superKeyHeldChanged)
38 Q_PROPERTY(bool focus READ hasFocus NOTIFY focusChanged) // overridden
39
40public:
41 explicit LauncherView(QWidget* parent = NULL);
42 ~LauncherView();
43
44 bool superKeyHeld() const { return m_superKeyHeld; }
45
46Q_SIGNALS:
47 void activateShortcutPressed(int itemIndex);
48 void newInstanceShortcutPressed(int itemIndex);
49 void superKeyHeldChanged(bool superKeyHeld);
50 void superKeyTapped();
51 void addWebFavoriteRequested(const QUrl& url);
52 void focusChanged(bool focus);
53
54private Q_SLOTS:
55 void setHotkeysForModifiers(Qt::KeyboardModifiers modifiers);
56 void forwardNumericHotkey();
57 void ignoreSuperPress();
58 void updateSuperKeyMonitoring();
59 void updateSuperKeyHoldState();
60 void toggleDash();
61 void showCommandsLens();
62 void onSuperSPressed();
63 void onAltF1Pressed();
64
65protected:
66 void focusInEvent(QFocusEvent* event);
67 void focusOutEvent(QFocusEvent* event);
68
69private:
70 bool m_superKeyPressed;
71 bool m_superKeyHeld;
72 bool m_superPressIgnored;
73 QTimer m_superKeyHoldTimer;
74
75 friend class LauncherDBus;
76};
77
78#endif // LAUNCHERVIEW
79
800
=== removed file 'launcher/app/unity-2d-launcher.desktop'
--- launcher/app/unity-2d-launcher.desktop 2011-09-19 16:29:49 +0000
+++ launcher/app/unity-2d-launcher.desktop 1970-01-01 00:00:00 +0000
@@ -1,13 +0,0 @@
1[Desktop Entry]
2Name=Unity 2d Launcher
3Comment=A Qt-based applications launcher
4Icon=gnome-fs-desktop
5Exec=unity-2d-launcher
6Terminal=false
7Type=Application
8Categories=Utility;
9NoDisplay=true
10X-Ubuntu-Gettext-Domain=unity-2d-launcher
11X-GNOME-Autostart-Notify=false
12X-GNOME-Autostart-Phase=Panel
13X-GNOME-AutoRestart=true
140
=== removed file 'launcher/app/visibilitycontroller.cpp'
--- launcher/app/visibilitycontroller.cpp 2011-12-01 09:55:45 +0000
+++ launcher/app/visibilitycontroller.cpp 1970-01-01 00:00:00 +0000
@@ -1,163 +0,0 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2011 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21// Self
22#include "visibilitycontroller.h"
23
24// Local
25#include <autohidebehavior.h>
26#include <forcevisiblebehavior.h>
27#include <intellihidebehavior.h>
28
29// unity-2d
30#include <debug_p.h>
31#include <unity2dpanel.h>
32#include <config.h>
33
34// Qt
35#include <QDBusConnection>
36#include <QDBusServiceWatcher>
37
38VisibilityController::VisibilityController(Unity2dPanel* panel)
39: QObject(panel)
40, m_panel(panel)
41, m_dbusWatcher(new QDBusServiceWatcher(this))
42{
43 m_dbusWatcher->setConnection(QDBusConnection::sessionBus());
44 m_dbusWatcher->setWatchMode(QDBusServiceWatcher::WatchForUnregistration);
45
46 connect(&launcher2dConfiguration(), SIGNAL(hideModeChanged(int)), SLOT(update()));
47 connect(m_panel, SIGNAL(manualSlidingChanged(bool)), SLOT(update()));
48 connect(m_dbusWatcher, SIGNAL(serviceUnregistered(const QString&)), SLOT(slotServiceUnregistered(const QString&)));
49 update();
50}
51
52VisibilityController::~VisibilityController()
53{
54}
55
56void VisibilityController::update(UpdateReason reason)
57{
58 if (!m_forceVisibleCountHash.isEmpty()) {
59 return;
60 }
61 AutoHideMode mode = AutoHideMode(launcher2dConfiguration().property("hideMode").toInt());
62
63 setBehavior(0);
64
65 /* Do not use any hiding controller if the panel is being slid manually */
66 if (!m_panel->manualSliding()) {
67 switch (mode) {
68 case ManualHide:
69 m_panel->setUseStrut(true);
70 m_panel->slideIn();
71 break;
72 case AutoHide:
73 m_panel->setUseStrut(false);
74 setBehavior(new AutoHideBehavior(m_panel));
75 break;
76 case IntelliHide:
77 m_panel->setUseStrut(false);
78 setBehavior(new IntelliHideBehavior(m_panel));
79 if (reason == UpdateFromForceVisibilityEnded && !m_panel->geometry().contains(QCursor::pos())) {
80 // The first thing IntelliHideBehavior does is checking if there is
81 // a window behind the panel, and if there is one, hide the panel immediately
82 // This is correct for some cases, but in the case we come from an update because the
83 // panel is not forced visible anymore and the mouse is not in the panel,
84 // i.e. the launcher was visible and the user clicked in an action of the tile menu,
85 // we should still give the user the wait 1 second before hiding behaviour.
86 // To achieve this we tell the behaviour controller to show the panel
87 // and simulate a mouse leave on the panel to start the hiding timer
88 QMetaObject::invokeMethod(m_behavior.data(), "showPanel");
89 QEvent e(QEvent::Leave);
90 QCoreApplication::sendEvent(m_panel, &e);
91 }
92 break;
93 }
94 }
95}
96
97void VisibilityController::beginForceVisible(const QString& service)
98{
99 bool wasEmpty = m_forceVisibleCountHash.isEmpty();
100 if (m_forceVisibleCountHash.contains(service)) {
101 ++m_forceVisibleCountHash[service];
102 } else {
103 m_forceVisibleCountHash[service] = 1;
104 if (!service.isEmpty()) {
105 m_dbusWatcher->addWatchedService(service);
106 }
107 }
108 if (wasEmpty) {
109 setBehavior(new ForceVisibleBehavior(m_panel));
110 }
111}
112
113void VisibilityController::endForceVisible(const QString& service)
114{
115 if (m_forceVisibleCountHash.contains(service)) {
116 if (m_forceVisibleCountHash[service] == 1) {
117 m_forceVisibleCountHash.remove(service);
118 m_dbusWatcher->removeWatchedService(service);
119 } else {
120 --m_forceVisibleCountHash[service];
121 }
122 } else {
123 UQ_WARNING << "Application" << service << "called endForceVisible() more than beginForceVisible().";
124 }
125 if (m_forceVisibleCountHash.isEmpty()) {
126 update(UpdateFromForceVisibilityEnded);
127 }
128}
129
130void VisibilityController::setBehavior(AbstractVisibilityBehavior* behavior)
131{
132 // This method could be replaced by code calling reset() directly but
133 // having only one point where the behavior is changed makes it easy to log
134 // behavior changes using something like: UQ_VAR(behavior);
135 m_behavior.reset(behavior);
136 if (behavior != NULL) {
137 connect(behavior, SIGNAL(visibleChanged(bool)), SLOT(updatePanelVisibility(bool)));
138 updatePanelVisibility(behavior->visible());
139 }
140}
141
142void VisibilityController::updatePanelVisibility(bool visible)
143{
144 if (visible) {
145 m_panel->slideIn();
146 } else {
147 m_panel->slideOut();
148 }
149}
150
151void VisibilityController::slotServiceUnregistered(const QString& service)
152{
153 if (!m_forceVisibleCountHash.contains(service)) {
154 return;
155 }
156
157 UQ_WARNING << "Application" << service << "quit without calling endForceVisible().";
158 m_forceVisibleCountHash.remove(service);
159 m_dbusWatcher->removeWatchedService(service);
160 if (m_forceVisibleCountHash.isEmpty()) {
161 update(UpdateFromForceVisibilityEnded);
162 }
163}
1640
=== removed file 'launcher/app/visibilitycontroller.h'
--- launcher/app/visibilitycontroller.h 2011-11-24 15:12:00 +0000
+++ launcher/app/visibilitycontroller.h 1970-01-01 00:00:00 +0000
@@ -1,93 +0,0 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2011 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21#ifndef VISIBILITYCONTROLLER_H
22#define VISIBILITYCONTROLLER_H
23
24// Local
25
26// Qt
27#include <QHash>
28#include <QObject>
29#include <QScopedPointer>
30
31class AbstractVisibilityBehavior;
32class Unity2dPanel;
33class QDBusServiceWatcher;
34
35/**
36 * This class monitors the hide_mode dconf key and set up an instance of
37 * AbstractVisibilityBehavior depending on its value
38 *
39 * It also tracks requests for forced visibility: the launcher or another
40 * application (through launcher DBus API) can request the launcher to stay
41 * visible for a while, for example because an application requests attention
42 * or because the dash is visible. This is handled by the beginForceVisible()
43 * and endForceVisible() methods.
44 *
45 * Internally it maintains a refcount-per-app of forced visibility requests so
46 * that it can restore the default mode if an application quits without calling
47 * endForceVisible().
48 */
49class VisibilityController : public QObject
50{
51Q_OBJECT
52public:
53 VisibilityController(Unity2dPanel* panel);
54 ~VisibilityController();
55
56 /**
57 * Force visibility of the launcher.
58 * service is the dbus service (@see QDBusConnection::baseService()) of the
59 * application which requested forced visibility. It is set to an empty
60 * string for internal requests.
61 */
62 Q_INVOKABLE void beginForceVisible(const QString& service = QString());
63 Q_INVOKABLE void endForceVisible(const QString& service = QString());
64
65private:
66 enum UpdateReason {
67 RegularUpdate,
68 UpdateFromForceVisibilityEnded
69 };
70
71private Q_SLOTS:
72 void update(UpdateReason reason = RegularUpdate);
73 void slotServiceUnregistered(const QString&);
74 void updatePanelVisibility(bool);
75
76private:
77 enum AutoHideMode {
78 ManualHide,
79 AutoHide,
80 IntelliHide
81 };
82 Q_DISABLE_COPY(VisibilityController);
83 Unity2dPanel* m_panel;
84 QDBusServiceWatcher* m_dbusWatcher;
85 QScopedPointer<AbstractVisibilityBehavior> m_behavior;
86
87 typedef QHash<QString, int> ForceVisibleCountHash;
88 ForceVisibleCountHash m_forceVisibleCountHash;
89
90 void setBehavior(AbstractVisibilityBehavior*);
91};
92
93#endif /* VISIBILITYCONTROLLER_H */
940
=== removed directory 'launcher/artwork'
=== removed file 'launcher/artwork/launcher_arrow_outline_ltr.png'
95Binary 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 differ1Binary 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
=== removed file 'launcher/launcher.qmlproject'
--- launcher/launcher.qmlproject 2010-10-12 00:33:09 +0000
+++ launcher/launcher.qmlproject 1970-01-01 00:00:00 +0000
@@ -1,18 +0,0 @@
1/* File generated by QtCreator */
2
3import QmlProject 1.0
4
5Project {
6 /* Include .qml, .js, and image files from current directory and subdirectories */
7 QmlFiles {
8 directory: "."
9 }
10 JavaScriptFiles {
11 directory: "."
12 }
13 ImageFiles {
14 directory: "."
15 }
16 /* List of plugin directories passed to QML runtime */
17 // importPaths: [ "../exampleplugin" ]
18}
190
=== removed directory 'launcher/tests'
=== removed file 'launcher/tests/CMakeLists.txt'
--- launcher/tests/CMakeLists.txt 2011-12-07 12:46:10 +0000
+++ launcher/tests/CMakeLists.txt 1970-01-01 00:00:00 +0000
@@ -1,29 +0,0 @@
1macro(launcher_tests)
2 set(_test_list "")
3 foreach(_test ${ARGN})
4 add_test(NAME ${_test}
5 COMMAND /bin/bash ${CMAKE_SOURCE_DIR}/tests/misc/run-with-xvfb.sh ./${_test}
6 )
7 add_executable(${_test} ${_test}.cpp ${_test}.moc)
8 qt4_generate_moc(${_test}.cpp ${_test}.moc)
9 target_link_libraries(${_test}
10 ${QT_QTTEST_LIBRARIES}
11 uqlauncher
12 )
13 set(_test_list "${_test_list};${_test}")
14 endforeach(_test)
15endmacro(launcher_tests)
16
17include_directories(
18 ${CMAKE_SOURCE_DIR}/tests
19 ${CMAKE_CURRENT_SOURCE_DIR}/../app
20 ${CMAKE_CURRENT_BINARY_DIR}
21 ${QT_QTTEST_INCLUDE_DIR}
22 ${QTGCONF_INCLUDE_DIRS}
23 )
24
25launcher_tests(
26# FIXME: test need a mock dbus object to message with via dbus-test-runner
27# launcherviewtest
28 )
29
300
=== removed file 'launcher/tests/launcherviewtest.cpp'
--- launcher/tests/launcherviewtest.cpp 2011-11-17 20:10:19 +0000
+++ launcher/tests/launcherviewtest.cpp 1970-01-01 00:00:00 +0000
@@ -1,42 +0,0 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2010 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22// Local
23#include <unitytestmacro.h>
24#include <launcherview.h>
25
26// Qt
27#include <QtTestGui>
28
29class LauncherViewTest : public QObject
30{
31 Q_OBJECT
32private Q_SLOTS:
33 void testCreate()
34 {
35 LauncherView view;
36 }
37};
38
39QAPP_TEST_MAIN(LauncherViewTest)
40
41#include "launcherviewtest.moc"
42
430
=== modified file 'libunity-2d-private/CMakeLists.txt'
--- libunity-2d-private/CMakeLists.txt 2011-12-07 13:05:37 +0000
+++ libunity-2d-private/CMakeLists.txt 2012-02-09 02:13:26 +0000
@@ -10,6 +10,7 @@
10pkg_check_modules(UNITYCORE REQUIRED unity-core-5.0)10pkg_check_modules(UNITYCORE REQUIRED unity-core-5.0)
11pkg_check_modules(DEE REQUIRED dee-1.0)11pkg_check_modules(DEE REQUIRED dee-1.0)
12pkg_check_modules(XINPUT REQUIRED xi)12pkg_check_modules(XINPUT REQUIRED xi)
13pkg_check_modules(GEIS REQUIRED libutouch-geis)
1314
14set(libunity-2d-private_SOVERSION 0)15set(libunity-2d-private_SOVERSION 0)
15set(libunity-2d-private_VERSION ${libunity-2d-private_SOVERSION}.0.0)16set(libunity-2d-private_VERSION ${libunity-2d-private_SOVERSION}.0.0)
1617
=== modified file 'libunity-2d-private/Unity2d/CMakeLists.txt'
--- libunity-2d-private/Unity2d/CMakeLists.txt 2011-11-29 17:17:35 +0000
+++ libunity-2d-private/Unity2d/CMakeLists.txt 2012-02-09 02:13:26 +0000
@@ -59,7 +59,5 @@
59#Allow build in different directory59#Allow build in different directory
60execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/GnomeBackground.qml"60execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/GnomeBackground.qml"
61 "${CMAKE_CURRENT_BINARY_DIR}/GnomeBackground.qml")61 "${CMAKE_CURRENT_BINARY_DIR}/GnomeBackground.qml")
62execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/AbstractScrollbar.qml"
63 "${CMAKE_CURRENT_BINARY_DIR}/AbstractScrollbar.qml")
64execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/qmldir"62execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/qmldir"
65 "${CMAKE_CURRENT_BINARY_DIR}/qmldir")63 "${CMAKE_CURRENT_BINARY_DIR}/qmldir")
6664
=== modified file 'libunity-2d-private/Unity2d/plugin.cpp'
--- libunity-2d-private/Unity2d/plugin.cpp 2012-02-01 13:59:49 +0000
+++ libunity-2d-private/Unity2d/plugin.cpp 2012-02-09 02:13:26 +0000
@@ -22,6 +22,7 @@
22*/22*/
23#include "plugin.h"23#include "plugin.h"
2424
25#include "dashclient.h"
25#include "launcherapplication.h"26#include "launcherapplication.h"
26#include "launcherdevice.h"27#include "launcherdevice.h"
27#include "trash.h"28#include "trash.h"
@@ -50,12 +51,9 @@
50#include "launcherdropitem.h"51#include "launcherdropitem.h"
5152
52#include "config.h"53#include "config.h"
53#include "dashclient.h"
5454
55#include "autohidebehavior.h"
56#include "intellihidebehavior.h"
57#include "forcevisiblebehavior.h"
58#include "bfb.h"55#include "bfb.h"
56#include "gesturehandler.h"
5957
60#include "lenses.h"58#include "lenses.h"
61#include "lens.h"59#include "lens.h"
@@ -68,8 +66,17 @@
68#include "radiooptionfilter.h"66#include "radiooptionfilter.h"
69#include "checkoptionfilter.h"67#include "checkoptionfilter.h"
70#include "multirangefilter.h"68#include "multirangefilter.h"
69#include "windowsintersectmonitor.h"
70#include "spreadmonitor.h"
71#include "focuspath.h"71#include "focuspath.h"
7272
73#include "unity2ddeclarativeview.h"
74#include "inputshapemanager.h"
75#include "inputshaperectangle.h"
76#include "inputshapemask.h"
77#include "unity2dpanel.h"
78#include "strutmanager.h"
79
73#include <QtDeclarative/qdeclarative.h>80#include <QtDeclarative/qdeclarative.h>
74#include <QDeclarativeEngine>81#include <QDeclarativeEngine>
75#include <QDeclarativeContext>82#include <QDeclarativeContext>
@@ -99,6 +106,8 @@
99{106{
100 qmlRegisterType<QSortFilterProxyModelQML>(uri, 0, 1, "SortFilterProxyModel");107 qmlRegisterType<QSortFilterProxyModelQML>(uri, 0, 1, "SortFilterProxyModel");
101108
109 qmlRegisterType<DashClient>();
110
102 qmlRegisterType<WindowInfo>(uri, 0, 1, "WindowInfo");111 qmlRegisterType<WindowInfo>(uri, 0, 1, "WindowInfo");
103 qmlRegisterType<WindowsList>(uri, 0, 1, "WindowsList");112 qmlRegisterType<WindowsList>(uri, 0, 1, "WindowsList");
104 qmlRegisterType<ScreenInfo>(uri, 0, 1, "ScreenInfo");113 qmlRegisterType<ScreenInfo>(uri, 0, 1, "ScreenInfo");
@@ -136,10 +145,6 @@
136 qmlRegisterType<WorkspacesList>(uri, 0, 1, "WorkspacesList");145 qmlRegisterType<WorkspacesList>(uri, 0, 1, "WorkspacesList");
137 qmlRegisterType<Workspaces>(uri, 0, 1, "Workspaces");146 qmlRegisterType<Workspaces>(uri, 0, 1, "Workspaces");
138147
139 qmlRegisterType<IntelliHideBehavior>(uri, 0, 1, "IntelliHideBehavior");
140 qmlRegisterType<AutoHideBehavior>(uri, 0, 1, "AutoHideBehavior");
141 qmlRegisterType<ForceVisibleBehavior>(uri, 0, 1, "ForceVisibleBehavior");
142
143 qmlRegisterType<IconUtilities>(); // Register the type as non creatable148 qmlRegisterType<IconUtilities>(); // Register the type as non creatable
144149
145 qmlRegisterType<GioDefaultApplication>(uri, 0, 1, "GioDefaultApplication");150 qmlRegisterType<GioDefaultApplication>(uri, 0, 1, "GioDefaultApplication");
@@ -160,7 +165,17 @@
160 qmlRegisterType<FilterOption>();165 qmlRegisterType<FilterOption>();
161 qmlRegisterType<FilterOptions>();166 qmlRegisterType<FilterOptions>();
162167
163 qmlRegisterType<DashClient>();168 qmlRegisterType<GestureHandler>(uri, 0, 1, "GestureHandler");
169 qmlRegisterType<WindowsIntersectMonitor>(uri, 0, 1, "WindowsIntersectMonitor");
170 qmlRegisterType<SpreadMonitor>(uri, 0, 1, "SpreadMonitor");
171
172 qmlRegisterType<InputShapeManager>(uri, 0, 1, "InputShapeManager");
173 qmlRegisterType<InputShapeRectangle>(uri, 0, 1, "InputShapeRectangle");
174 qmlRegisterType<InputShapeMask>(uri, 0, 1, "InputShapeMask");
175 qmlRegisterType<Unity2DDeclarativeView>();
176
177 qmlRegisterType<Unity2dPanel>(uri, 0, 1, "Unity2dPanel");
178 qmlRegisterType<StrutManager>(uri, 0, 1, "StrutManager");
164}179}
165180
166void Unity2dPlugin::initializeEngine(QDeclarativeEngine *engine, const char *uri)181void Unity2dPlugin::initializeEngine(QDeclarativeEngine *engine, const char *uri)
@@ -179,8 +194,9 @@
179 engine->rootContext()->setContextProperty("iconUtilities", new IconUtilities(engine));194 engine->rootContext()->setContextProperty("iconUtilities", new IconUtilities(engine));
180195
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 */
197 engine->rootContext()->setContextProperty("unity2dConfiguration", &unity2dConfiguration());
198 engine->rootContext()->setContextProperty("launcher2dConfiguration", &launcher2dConfiguration());
182 engine->rootContext()->setContextProperty("dash2dConfiguration", &dash2dConfiguration());199 engine->rootContext()->setContextProperty("dash2dConfiguration", &dash2dConfiguration());
183 engine->rootContext()->setContextProperty("dashClient", DashClient::instance());
184200
185 /* Critically important to set the client type to pager because wnck201 /* Critically important to set the client type to pager because wnck
186 will pass that type over to the window manager through XEvents.202 will pass that type over to the window manager through XEvents.
187203
=== modified file 'libunity-2d-private/Unity2d/qmldir'
--- libunity-2d-private/Unity2d/qmldir 2011-11-29 17:17:35 +0000
+++ libunity-2d-private/Unity2d/qmldir 2012-02-09 02:13:26 +0000
@@ -1,4 +1,3 @@
1plugin unity-2d-private-qml1plugin unity-2d-private-qml
22
3GnomeBackground 1.0 GnomeBackground.qml3GnomeBackground 1.0 GnomeBackground.qml
4AbstractScrollbar 1.0 AbstractScrollbar.qml
54
=== modified file 'libunity-2d-private/src/CMakeLists.txt'
--- libunity-2d-private/src/CMakeLists.txt 2012-01-31 15:09:02 +0000
+++ libunity-2d-private/src/CMakeLists.txt 2012-02-09 02:13:26 +0000
@@ -13,7 +13,6 @@
13 hotkey.cpp13 hotkey.cpp
14 keymonitor.cpp14 keymonitor.cpp
15 launcherclient.cpp15 launcherclient.cpp
16 mousearea.cpp
17 unity2dapplication.cpp16 unity2dapplication.cpp
18 unity2ddebug.cpp17 unity2ddebug.cpp
19 unity2dpanel.cpp18 unity2dpanel.cpp
@@ -22,11 +21,7 @@
22 mimedata.cpp21 mimedata.cpp
23 dragdropevent.cpp22 dragdropevent.cpp
24 propertybinder.cpp23 propertybinder.cpp
25 abstractvisibilitybehavior.cpp24 gesturehandler.cpp
26 autohidebehavior.cpp
27 edgehitdetector.cpp
28 forcevisiblebehavior.cpp
29 intellihidebehavior.cpp
30 giodefaultapplication.cpp25 giodefaultapplication.cpp
31 qsortfilterproxymodelqml.cpp26 qsortfilterproxymodelqml.cpp
32 blendedimageprovider.cpp27 blendedimageprovider.cpp
@@ -72,7 +67,14 @@
72 panelapplet.cpp67 panelapplet.cpp
73 panelstyle.cpp68 panelstyle.cpp
74 percentcoder.cpp69 percentcoder.cpp
70 windowsintersectmonitor.cpp
71 abstractdbusservicemonitor.cpp
72 spreadmonitor.cpp
75 focuspath.cpp73 focuspath.cpp
74 inputshapemanager.cpp
75 inputshaperectangle.cpp
76 inputshapemask.cpp
77 strutmanager.cpp
76 )78 )
7779
78# Build80# Build
@@ -100,6 +102,7 @@
100 ${NUXCORE_INCLUDE_DIRS}102 ${NUXCORE_INCLUDE_DIRS}
101 ${DEE_INCLUDE_DIRS}103 ${DEE_INCLUDE_DIRS}
102 ${XINPUT_INCLUDE_DIRS}104 ${XINPUT_INCLUDE_DIRS}
105 ${GEIS_INCLUDE_DIRS}
103 )106 )
104107
105add_library(${LIB_NAME} SHARED ${libunity-2d-private_SRCS} listmodelwrapper.h)108add_library(${LIB_NAME} SHARED ${libunity-2d-private_SRCS} listmodelwrapper.h)
@@ -135,6 +138,7 @@
135 ${NUXCORE_LDFLAGS}138 ${NUXCORE_LDFLAGS}
136 ${DEE_LDFLAGS}139 ${DEE_LDFLAGS}
137 ${XINPUT_LDFLAGS}140 ${XINPUT_LDFLAGS}
141 ${GEIS_LDFLAGS}
138 )142 )
139143
140# Install144# Install
141145
=== added file 'libunity-2d-private/src/abstractdbusservicemonitor.cpp'
--- libunity-2d-private/src/abstractdbusservicemonitor.cpp 1970-01-01 00:00:00 +0000
+++ libunity-2d-private/src/abstractdbusservicemonitor.cpp 2012-02-09 02:13:26 +0000
@@ -0,0 +1,86 @@
1/*
2 * Copyright (C) 2011 Canonical, Ltd.
3 *
4 * Authors:
5 * Ugo Riboni <ugo.riboni@canonical.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 3.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include "abstractdbusservicemonitor.h"
21
22#include <QDBusConnection>
23#include <QDBusConnectionInterface>
24#include <QDBusReply>
25
26AbstractDBusServiceMonitor::AbstractDBusServiceMonitor(QString service, QString path,
27 QString interface, QObject *parent)
28 : QObject(parent)
29 , m_service(service)
30 , m_path(path)
31 , m_interface(interface)
32 , m_watcher(new QDBusServiceWatcher(service, QDBusConnection::sessionBus()))
33 , m_dbusInterface(0)
34{
35 connect(m_watcher, SIGNAL(serviceRegistered(QString)), SLOT(createInterface()));
36 connect(m_watcher, SIGNAL(serviceUnregistered(QString)), SLOT(destroyInterface()));
37
38 // Connect to the service if it's up already
39 QDBusConnectionInterface* sessionBus = QDBusConnection::sessionBus().interface();
40 QDBusReply<bool> reply = sessionBus->isServiceRegistered(m_service);
41 if (reply.isValid() && reply.value()) {
42 createInterface();
43 }
44}
45
46AbstractDBusServiceMonitor::~AbstractDBusServiceMonitor()
47{
48 delete m_watcher;
49 if (m_dbusInterface) {
50 delete m_dbusInterface;
51 }
52}
53
54void AbstractDBusServiceMonitor::createInterface()
55{
56 if (m_dbusInterface != 0) {
57 delete m_dbusInterface;
58 m_dbusInterface = 0;
59 }
60
61 m_dbusInterface = new QDBusInterface(m_service, m_path, m_interface,
62 QDBusConnection::sessionBus());
63 Q_EMIT serviceAvailableChanged(true);
64}
65
66void AbstractDBusServiceMonitor::destroyInterface()
67{
68 if (m_dbusInterface != 0) {
69 delete m_dbusInterface;
70 m_dbusInterface = 0;
71 }
72
73 Q_EMIT serviceAvailableChanged(false);
74}
75
76QDBusInterface* AbstractDBusServiceMonitor::dbusInterface() const
77{
78 return m_dbusInterface;
79}
80
81bool AbstractDBusServiceMonitor::serviceAvailable() const
82{
83 return m_dbusInterface != 0;
84}
85
86#include "abstractdbusservicemonitor.moc"
087
=== added file 'libunity-2d-private/src/abstractdbusservicemonitor.h'
--- libunity-2d-private/src/abstractdbusservicemonitor.h 1970-01-01 00:00:00 +0000
+++ libunity-2d-private/src/abstractdbusservicemonitor.h 2012-02-09 02:13:26 +0000
@@ -0,0 +1,59 @@
1/*
2 * Copyright (C) 2011 Canonical, Ltd.
3 *
4 * Authors:
5 * Ugo Riboni <ugo.riboni@canonical.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 3.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef ABSTRACTDBUSSERVICEMONITOR_H
21#define ABSTRACTDBUSSERVICEMONITOR_H
22
23#include <QObject>
24
25#include <QDBusInterface>
26#include <QDBusServiceWatcher>
27#include <QObject>
28#include <QString>
29
30class AbstractDBusServiceMonitor : public QObject
31{
32 Q_OBJECT
33 Q_PROPERTY(bool serviceAvailable READ serviceAvailable NOTIFY serviceAvailableChanged)
34
35public:
36 explicit AbstractDBusServiceMonitor(QString service, QString path, QString interface,
37 QObject *parent = 0);
38 ~AbstractDBusServiceMonitor();
39
40 QDBusInterface* dbusInterface() const;
41
42 bool serviceAvailable() const;
43
44Q_SIGNALS:
45 void serviceAvailableChanged(bool available);
46
47private Q_SLOTS:
48 void createInterface();
49 void destroyInterface();
50
51protected:
52 QString m_service;
53 QString m_path;
54 QString m_interface;
55 QDBusServiceWatcher* m_watcher;
56 QDBusInterface* m_dbusInterface;
57};
58
59#endif // ABSTRACTDBUSSERVICEMONITOR_H
060
=== removed file 'libunity-2d-private/src/abstractvisibilitybehavior.cpp'
--- libunity-2d-private/src/abstractvisibilitybehavior.cpp 2011-06-11 11:33:52 +0000
+++ libunity-2d-private/src/abstractvisibilitybehavior.cpp 1970-01-01 00:00:00 +0000
@@ -1,59 +0,0 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2011 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 * - Florian Boucault <florian.boucault@canonical.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; version 3.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 */
22// Self
23#include "abstractvisibilitybehavior.h"
24
25// Local
26
27// libunity-2d
28
29// Qt
30#include <QWidget>
31
32AbstractVisibilityBehavior::AbstractVisibilityBehavior(QWidget* panel)
33: QObject(panel)
34, m_panel(panel)
35, m_visible(true)
36{
37}
38
39AbstractVisibilityBehavior::~AbstractVisibilityBehavior()
40{
41}
42
43bool AbstractVisibilityBehavior::visible() const
44{
45 return m_visible;
46}
47
48QWidget* AbstractVisibilityBehavior::panel() const
49{
50 return m_panel;
51}
52
53void AbstractVisibilityBehavior::setPanel(QWidget* panel)
54{
55 m_panel = panel;
56 Q_EMIT panelChanged(m_panel);
57}
58
59#include "abstractvisibilitybehavior.moc"
600
=== removed file 'libunity-2d-private/src/abstractvisibilitybehavior.h'
--- libunity-2d-private/src/abstractvisibilitybehavior.h 2011-06-11 11:33:52 +0000
+++ libunity-2d-private/src/abstractvisibilitybehavior.h 1970-01-01 00:00:00 +0000
@@ -1,63 +0,0 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2011 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 * - Florian Boucault <florian.boucault@canonical.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; version 3.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 */
22#ifndef ABSTRACTVISIBILITYBEHAVIOR_H
23#define ABSTRACTVISIBILITYBEHAVIOR_H
24
25// Local
26
27// Qt
28#include <QObject>
29
30class QWidget;
31
32/**
33 * Base class for various visibility behaviors.
34 *
35 */
36class AbstractVisibilityBehavior : public QObject
37{
38 Q_OBJECT
39
40 Q_PROPERTY(bool visible READ visible NOTIFY visibleChanged)
41 Q_PROPERTY(QWidget* panel READ panel WRITE setPanel NOTIFY panelChanged)
42
43public:
44 AbstractVisibilityBehavior(QWidget* panel=0);
45 ~AbstractVisibilityBehavior();
46
47 // getters
48 bool visible() const;
49 QWidget* panel() const;
50
51 // setters
52 void setPanel(QWidget* panel);
53
54Q_SIGNALS:
55 void visibleChanged(bool visible);
56 void panelChanged(QWidget* panel);
57
58protected:
59 QWidget* m_panel;
60 bool m_visible;
61};
62
63#endif /* ABSTRACTVISIBILITYBEHAVIOR_H */
640
=== removed file 'libunity-2d-private/src/autohidebehavior.cpp'
--- libunity-2d-private/src/autohidebehavior.cpp 2011-12-01 12:22:18 +0000
+++ libunity-2d-private/src/autohidebehavior.cpp 1970-01-01 00:00:00 +0000
@@ -1,143 +0,0 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2011 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 * - Florian Boucault <florian.boucault@canonical.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; version 3.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 */
22// Self
23#include "autohidebehavior.h"
24
25// Local
26#include <edgehitdetector.h>
27
28// libunity-2d
29#include <debug_p.h>
30
31// Qt
32#include <QCursor>
33#include <QTimer>
34#include <QWidget>
35
36// libwnck
37extern "C" {
38#define WNCK_I_KNOW_THIS_IS_UNSTABLE
39#include <libwnck/libwnck.h>
40}
41
42static const int AUTOHIDE_TIMEOUT = 1000;
43
44#define GOBJECT_CALLBACK0(callbackName, slot) \
45static void \
46callbackName(GObject* src, QObject* dst) \
47{ \
48 QMetaObject::invokeMethod(dst, slot); \
49}
50
51GOBJECT_CALLBACK0(showingDesktopChangedCB, "onShowingDesktopChanged");
52
53AutoHideBehavior::AutoHideBehavior(QWidget* panel)
54: AbstractVisibilityBehavior(panel)
55, m_autohideTimer(new QTimer(this))
56, m_edgeHitDetector(0)
57{
58 m_autohideTimer->setSingleShot(true);
59 m_autohideTimer->setInterval(AUTOHIDE_TIMEOUT);
60 connect(m_autohideTimer, SIGNAL(timeout()), SLOT(hidePanel()));
61
62 setPanel(panel);
63
64 WnckScreen* screen = wnck_screen_get_default();
65 g_signal_connect(G_OBJECT(screen), "showing_desktop_changed", G_CALLBACK(showingDesktopChangedCB), this);
66}
67
68AutoHideBehavior::~AutoHideBehavior()
69{
70 WnckScreen* screen = wnck_screen_get_default();
71 g_signal_handlers_disconnect_by_func(G_OBJECT(screen), gpointer(showingDesktopChangedCB), this);
72}
73
74bool AutoHideBehavior::eventFilter(QObject*, QEvent* event)
75{
76 switch (event->type()) {
77 case QEvent::Enter:
78 m_autohideTimer->stop();
79 m_visible = true;
80 Q_EMIT visibleChanged(m_visible);
81 break;
82 case QEvent::Leave:
83 m_autohideTimer->start();
84 break;
85 default:
86 break;
87 }
88 return false;
89}
90
91void AutoHideBehavior::hidePanel()
92{
93 m_visible = false;
94 Q_EMIT visibleChanged(m_visible);
95 createEdgeHitDetector();
96}
97
98void AutoHideBehavior::showPanel()
99{
100 // Delete the mouse area so that it does not prevent mouse events from
101 // reaching the panel
102 delete m_edgeHitDetector;
103 m_edgeHitDetector = 0;
104 m_autohideTimer->stop();
105 m_visible = true;
106 Q_EMIT visibleChanged(m_visible);
107}
108
109void AutoHideBehavior::onShowingDesktopChanged()
110{
111 WnckScreen* screen = wnck_screen_get_default();
112 gboolean isShowingDesktop = wnck_screen_get_showing_desktop(screen);
113 if (isShowingDesktop) {
114 showPanel();
115 m_autohideTimer->start();
116 } else {
117 hidePanel();
118 }
119}
120
121
122void AutoHideBehavior::createEdgeHitDetector()
123{
124 m_edgeHitDetector = new EdgeHitDetector(this);
125 connect(m_edgeHitDetector, SIGNAL(edgeHit()), SLOT(showPanel()));
126}
127
128
129void AutoHideBehavior::setPanel(QWidget *panel)
130{
131 if (m_panel != NULL) {
132 m_panel->removeEventFilter(this);
133 }
134 AbstractVisibilityBehavior::setPanel(panel);
135 if (m_panel != NULL) {
136 m_panel->installEventFilter(this);
137 if (!m_panel->geometry().contains(QCursor::pos())) {
138 m_autohideTimer->start();
139 }
140 }
141}
142
143#include "autohidebehavior.moc"
1440
=== removed file 'libunity-2d-private/src/autohidebehavior.h'
--- libunity-2d-private/src/autohidebehavior.h 2011-12-01 12:22:18 +0000
+++ libunity-2d-private/src/autohidebehavior.h 1970-01-01 00:00:00 +0000
@@ -1,69 +0,0 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2011 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 * - Florian Boucault <florian.boucault@canonical.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; version 3.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 */
22#ifndef AUTOHIDEBEHAVIOR_H
23#define AUTOHIDEBEHAVIOR_H
24
25// Local
26#include <abstractvisibilitybehavior.h>
27
28// Qt
29#include <QObject>
30
31class EdgeHitDetector;
32class QTimer;
33class QWidget;
34
35/**
36 * This class implements the classic autohide-on-timeout behavior
37 */
38class AutoHideBehavior : public AbstractVisibilityBehavior
39{
40 Q_OBJECT
41
42 Q_PROPERTY(QWidget* panel READ panel WRITE setPanel NOTIFY panelChanged)
43
44public:
45 AutoHideBehavior(QWidget* panel=0);
46 ~AutoHideBehavior();
47
48 // setters
49 void setPanel(QWidget *panel);
50
51Q_SIGNALS:
52 void panelChanged(QWidget *panel);
53
54protected:
55 bool eventFilter(QObject*, QEvent*);
56
57private Q_SLOTS:
58 void hidePanel();
59 void showPanel();
60 void onShowingDesktopChanged();
61
62private:
63 QTimer* m_autohideTimer;
64 EdgeHitDetector* m_edgeHitDetector;
65
66 void createEdgeHitDetector();
67};
68
69#endif /* AUTOHIDEBEHAVIOR_H */
700
=== modified file 'libunity-2d-private/src/bfb.cpp'
--- libunity-2d-private/src/bfb.cpp 2011-12-09 13:46:10 +0000
+++ libunity-2d-private/src/bfb.cpp 2012-02-09 02:13:26 +0000
@@ -21,17 +21,14 @@
21#include "bfb.h"21#include "bfb.h"
2222
23// libunity-2d23// libunity-2d
24#include <dashclient.h>
25#include <debug_p.h>24#include <debug_p.h>
26#include <unity2dtr.h>25#include <unity2dtr.h>
2726
28// Qt27// Qt
2928
30BfbItem::BfbItem()29BfbItem::BfbItem()
31: m_active(false)30: m_active(false), m_view(NULL)
32{31{
33 connect(DashClient::instance(), SIGNAL(activePageChanged(const QString&)),
34 SLOT(slotActivePageChanged(const QString&)));
35}32}
3633
37BfbItem::~BfbItem()34BfbItem::~BfbItem()
@@ -43,15 +40,6 @@
43 return m_active;40 return m_active;
44}41}
4542
46void BfbItem::slotActivePageChanged(const QString& page)
47{
48 bool active = !page.isEmpty();
49 if (m_active != active) {
50 m_active = active;
51 activeChanged(m_active);
52 }
53}
54
55bool BfbItem::running() const43bool BfbItem::running() const
56{44{
57 return false;45 return false;
@@ -82,15 +70,42 @@
82 return false;70 return false;
83}71}
8472
73QObject* BfbItem::dashView() const
74{
75 return m_view;
76}
77
78void BfbItem::setDashView(QObject* view)
79{
80 if (m_view != NULL) {
81 disconnect(view);
82 }
83 m_view = view;
84 if (m_view != NULL) {
85 connect(view, SIGNAL(dashActiveChanged(bool)), this, SLOT(slotDashActiveChanged(bool)));
86 }
87}
88
85void BfbItem::activate()89void BfbItem::activate()
86{90{
87 DashClient::instance()->setActivePage(m_active ? "" : "home");91 Q_ASSERT(m_view != NULL);
92 if (m_view != NULL) {
93 QMetaObject::invokeMethod(m_view, "toggleDash");
94 }
88}95}
8996
90void BfbItem::createMenuActions()97void BfbItem::createMenuActions()
91{98{
92}99}
93100
101void BfbItem::slotDashActiveChanged(bool active)
102{
103 if (m_active != active) {
104 m_active = active;
105 Q_EMIT activeChanged(m_active);
106 }
107}
108
94////////////////////////////////////////////////////////////109////////////////////////////////////////////////////////////
95BfbModel::BfbModel(QObject* parent)110BfbModel::BfbModel(QObject* parent)
96: QAbstractListModel(parent)111: QAbstractListModel(parent)
@@ -117,4 +132,14 @@
117 return QVariant::fromValue(m_bfbItem);132 return QVariant::fromValue(m_bfbItem);
118}133}
119134
135QObject* BfbModel::dashView() const
136{
137 return m_bfbItem->dashView();
138}
139
140void BfbModel::setDashView(QObject* view)
141{
142 m_bfbItem->setDashView(view);
143}
144
120#include <bfb.moc>145#include <bfb.moc>
121146
=== modified file 'libunity-2d-private/src/bfb.h'
--- libunity-2d-private/src/bfb.h 2011-08-11 09:25:35 +0000
+++ libunity-2d-private/src/bfb.h 2012-02-09 02:13:26 +0000
@@ -42,16 +42,20 @@
42 virtual QString icon() const;42 virtual QString icon() const;
43 virtual bool launching() const;43 virtual bool launching() const;
4444
45 QObject* dashView() const;
46 void setDashView(QObject* view);
47
45 /* methods */48 /* methods */
46 Q_INVOKABLE virtual void activate();49 Q_INVOKABLE virtual void activate();
47 Q_INVOKABLE virtual void createMenuActions();50 Q_INVOKABLE virtual void createMenuActions();
4851
49private Q_SLOTS:52private Q_SLOTS:
50 void slotActivePageChanged(const QString&);53 void slotDashActiveChanged(bool active);
5154
52private:55private:
53 Q_DISABLE_COPY(BfbItem)56 Q_DISABLE_COPY(BfbItem)
54 bool m_active;57 bool m_active;
58 QObject* m_view;
55};59};
5660
57Q_DECLARE_METATYPE(BfbItem*)61Q_DECLARE_METATYPE(BfbItem*)
@@ -60,6 +64,7 @@
60class BfbModel : public QAbstractListModel64class BfbModel : public QAbstractListModel
61{65{
62 Q_OBJECT66 Q_OBJECT
67 Q_PROPERTY(QObject* dashView READ dashView WRITE setDashView)
63public:68public:
64 BfbModel(QObject* parent = 0);69 BfbModel(QObject* parent = 0);
65 ~BfbModel();70 ~BfbModel();
@@ -67,6 +72,9 @@
67 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;72 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
68 int rowCount(const QModelIndex& parent = QModelIndex()) const;73 int rowCount(const QModelIndex& parent = QModelIndex()) const;
6974
75 QObject* dashView() const;
76 void setDashView(QObject* view);
77
70private:78private:
71 Q_DISABLE_COPY(BfbModel)79 Q_DISABLE_COPY(BfbModel)
72 BfbItem* m_bfbItem;80 BfbItem* m_bfbItem;
7381
=== removed file 'libunity-2d-private/src/edgehitdetector.cpp'
--- libunity-2d-private/src/edgehitdetector.cpp 2011-11-29 11:46:34 +0000
+++ libunity-2d-private/src/edgehitdetector.cpp 1970-01-01 00:00:00 +0000
@@ -1,65 +0,0 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2011 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 *
9 * License: GPL v3
10 */
11// Self
12#include "edgehitdetector.h"
13
14// Local
15
16// libunity-2d
17#include <debug_p.h>
18
19// Qt
20#include <QDesktopWidget>
21#include <QTimer>
22
23static const int EDGE_HIT_DELAY = 500;
24
25EdgeHitDetector::EdgeHitDetector(QObject* parent)
26: QObject(parent)
27, m_mouseArea(new MouseArea(this))
28, m_updateTimer(new QTimer(this))
29, m_edgeHitTimer(new QTimer(this))
30{
31 updateGeometryFromScreen();
32
33 // Use a timer to delay geometry updates because sometimes when
34 // QDesktopWidget emits its signals, immediatly asking for screen geometry
35 // yields wrong results.
36 m_updateTimer->setSingleShot(true);
37 m_updateTimer->setInterval(1000);
38 connect(m_updateTimer, SIGNAL(timeout()), SLOT(updateGeometryFromScreen()));
39
40 QDesktopWidget* desktop = QApplication::desktop();
41 connect(desktop, SIGNAL(resized(int)), m_updateTimer, SLOT(start()));
42 connect(desktop, SIGNAL(screenCountChanged(int)), m_updateTimer, SLOT(start()));
43
44 m_edgeHitTimer->setInterval(EDGE_HIT_DELAY);
45 m_edgeHitTimer->setSingleShot(true);
46 connect(m_edgeHitTimer, SIGNAL(timeout()), SIGNAL(edgeHit()));
47
48 connect(m_mouseArea, SIGNAL(entered()), m_edgeHitTimer, SLOT(start()));
49 connect(m_mouseArea, SIGNAL(exited()), m_edgeHitTimer, SLOT(stop()));
50}
51
52void EdgeHitDetector::updateGeometryFromScreen()
53{
54 QPoint p = QApplication::isLeftToRight() ?
55 QPoint() :
56 QPoint(QApplication::desktop()->width() - 1, 0);
57 QRect rect = QApplication::desktop()->availableGeometry(p);
58 if (QApplication::isLeftToRight()) {
59 m_mouseArea->setGeometry(rect.left(), rect.top(), 1, rect.height());
60 } else {
61 m_mouseArea->setGeometry(rect.right() - 1, rect.top(), 1, rect.height());
62 }
63}
64
65#include "edgehitdetector.moc"
660
=== removed file 'libunity-2d-private/src/edgehitdetector.h'
--- libunity-2d-private/src/edgehitdetector.h 2011-06-11 11:33:52 +0000
+++ libunity-2d-private/src/edgehitdetector.h 1970-01-01 00:00:00 +0000
@@ -1,44 +0,0 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2011 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 *
9 * License: GPL v3
10 */
11#ifndef EDGEHITDETECTOR_H
12#define EDGEHITDETECTOR_H
13
14// Local
15
16// libunity-2d
17#include <mousearea.h>
18
19// Qt
20
21class QTimer;
22
23/**
24 * A mouse area which stays on the left edge of the leftmost screen
25 */
26class EdgeHitDetector : public QObject
27{
28Q_OBJECT
29public:
30 EdgeHitDetector(QObject* parent = 0);
31
32Q_SIGNALS:
33 void edgeHit();
34
35private Q_SLOTS:
36 void updateGeometryFromScreen();
37
38private:
39 MouseArea* m_mouseArea;
40 QTimer* m_updateTimer;
41 QTimer* m_edgeHitTimer;
42};
43
44#endif /* EDGEHITDETECTOR_H */
450
=== removed file 'libunity-2d-private/src/forcevisiblebehavior.cpp'
--- libunity-2d-private/src/forcevisiblebehavior.cpp 2011-06-11 11:33:52 +0000
+++ libunity-2d-private/src/forcevisiblebehavior.cpp 1970-01-01 00:00:00 +0000
@@ -1,36 +0,0 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2011 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21// Self
22#include "forcevisiblebehavior.h"
23
24// Local
25
26// libunity-2d
27
28// Qt
29#include <QWidget>
30
31ForceVisibleBehavior::ForceVisibleBehavior(QWidget* panel)
32: AbstractVisibilityBehavior(panel)
33{
34}
35
36#include "forcevisiblebehavior.moc"
370
=== removed file 'libunity-2d-private/src/forcevisiblebehavior.h'
--- libunity-2d-private/src/forcevisiblebehavior.h 2011-06-11 11:33:52 +0000
+++ libunity-2d-private/src/forcevisiblebehavior.h 1970-01-01 00:00:00 +0000
@@ -1,41 +0,0 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2011 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21#ifndef FORCEVISIBLEBEHAVIOR_H
22#define FORCEVISIBLEBEHAVIOR_H
23
24// Local
25#include <abstractvisibilitybehavior.h>
26
27// Qt
28#include <QObject>
29
30/**
31 * Behavior used when someone requested the launcher to be visible even if it
32 * is supposed to be hidden
33 */
34class ForceVisibleBehavior : public AbstractVisibilityBehavior
35{
36 Q_OBJECT
37public:
38 ForceVisibleBehavior(QWidget* panel=0);
39};
40
41#endif /* FORCEVISIBLEBEHAVIOR_H */
420
=== renamed file 'launcher/app/gesturehandler.cpp' => 'libunity-2d-private/src/gesturehandler.cpp'
--- launcher/app/gesturehandler.cpp 2011-11-08 13:33:33 +0000
+++ libunity-2d-private/src/gesturehandler.cpp 2012-02-09 02:13:26 +0000
@@ -25,10 +25,10 @@
2525
26#include <debug_p.h>26#include <debug_p.h>
2727
28GestureHandler::GestureHandler(Unity2dPanel* launcher, QObject *parent)28GestureHandler::GestureHandler(QObject *parent)
29: QObject(parent)29: QObject(parent)
30, m_geisInstance(NULL)30, m_geisInstance(NULL)
31, m_launcher(launcher)31, m_isDragging(false)
32{32{
33 if (geisInitialize() != GEIS_STATUS_SUCCESS) {33 if (geisInitialize() != GEIS_STATUS_SUCCESS) {
34 UQ_WARNING << "GEIS initialization failed: multitouch support disabled";34 UQ_WARNING << "GEIS initialization failed: multitouch support disabled";
@@ -218,9 +218,10 @@
218 /* 4 fingers drag reveals the launcher progressively; if the drag goes far218 /* 4 fingers drag reveals the launcher progressively; if the drag goes far
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 */
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 */
221 m_launcher->setManualSliding(true);221 m_isDragging = true;
222 m_dragDelta = m_launcher->delta() + attributes[GEIS_GESTURE_ATTRIBUTE_DELTA_X].float_val;222 Q_EMIT isDraggingChanged();
223 m_launcher->setDelta(m_dragDelta);223 m_dragDelta = attributes[GEIS_GESTURE_ATTRIBUTE_DELTA_X].float_val;
224 Q_EMIT dragDeltaChanged();
224 }225 }
225}226}
226227
@@ -262,18 +263,17 @@
262 m_pinchPreviousTimestamp = timestamp;263 m_pinchPreviousTimestamp = timestamp;
263 }264 }
264 } else if (gestureName == GEIS_GESTURE_TYPE_DRAG4) {265 } else if (gestureName == GEIS_GESTURE_TYPE_DRAG4) {
265 /* FIXME: only supports the launcher positioned on the left edge of the screen */
266 m_dragDelta += attributes[GEIS_GESTURE_ATTRIBUTE_DELTA_X].float_val;266 m_dragDelta += attributes[GEIS_GESTURE_ATTRIBUTE_DELTA_X].float_val;
267 m_launcher->setDelta(m_dragDelta);267 Q_EMIT dragDeltaChanged();
268 /* If the drag goes sufficiently above than the maximum delta then268 /* If the drag goes sufficiently above than the maximum delta then
269 lock the launcher in place by reserving the area so that no windows269 lock the launcher in place by reserving the area so that no windows
270 overlap it.270 overlap it. TODO: move to QML.
271 */271 */
272 if (m_dragDelta - m_launcher->delta() > 240) {272// if (m_dragDelta - m_launcher->delta() > 240) {
273 m_launcher->setUseStrut(true);273// m_launcher->setUseStrut(true);
274 } else {274// } else {
275 m_launcher->setUseStrut(false);275// m_launcher->setUseStrut(false);
276 }276// }
277 }277 }
278}278}
279279
@@ -284,8 +284,20 @@
284284
285 if (gestureName == GEIS_GESTURE_TYPE_DRAG4) {285 if (gestureName == GEIS_GESTURE_TYPE_DRAG4) {
286 m_dragDelta += attributes[GEIS_GESTURE_ATTRIBUTE_DELTA_X].float_val;286 m_dragDelta += attributes[GEIS_GESTURE_ATTRIBUTE_DELTA_X].float_val;
287 m_launcher->setDelta(m_dragDelta);287 Q_EMIT dragDeltaChanged();
288 m_launcher->setManualSliding(false);288 m_isDragging = false;
289 Q_EMIT isDraggingChanged();
289 }290 }
290}291}
291292
293double GestureHandler::dragDelta() const
294{
295 return m_dragDelta;
296}
297
298bool GestureHandler::isDragging() const
299{
300 return m_isDragging;
301}
302
303#include "gesturehandler.moc"
292304
=== renamed file 'launcher/app/gesturehandler.h' => 'libunity-2d-private/src/gesturehandler.h'
--- launcher/app/gesturehandler.h 2011-02-21 00:25:44 +0000
+++ libunity-2d-private/src/gesturehandler.h 2012-02-09 02:13:26 +0000
@@ -22,20 +22,29 @@
2222
23#include <QObject>23#include <QObject>
24#include <QHash>24#include <QHash>
25#include <QMetaType>
2526
26extern "C" {27extern "C" {
27 #include <geis/geis.h>28 #include <geis/geis.h>
28}29}
2930
30#include "unity2dpanel.h"
31
32class GestureHandler : public QObject31class GestureHandler : public QObject
33{32{
34 Q_OBJECT33 Q_OBJECT
34 Q_PROPERTY(double dragDelta READ dragDelta NOTIFY dragDeltaChanged)
35 Q_PROPERTY(bool isDragging READ isDragging NOTIFY isDraggingChanged)
36
35public:37public:
36 explicit GestureHandler(Unity2dPanel* launcher, QObject *parent = 0);38 explicit GestureHandler(QObject *parent = 0);
37 ~GestureHandler();39 ~GestureHandler();
3840
41 double dragDelta() const;
42 bool isDragging() const;
43
44Q_SIGNALS:
45 void dragDeltaChanged();
46 void isDraggingChanged();
47
39private Q_SLOTS:48private Q_SLOTS:
40 void geisEventDispatch();49 void geisEventDispatch();
4150
@@ -60,7 +69,9 @@
60 float m_pinchPreviousRadius;69 float m_pinchPreviousRadius;
61 int m_pinchPreviousTimestamp;70 int m_pinchPreviousTimestamp;
62 float m_dragDelta;71 float m_dragDelta;
63 Unity2dPanel* m_launcher;72 bool m_isDragging;
64};73};
6574
75Q_DECLARE_METATYPE(GestureHandler*)
76
66#endif // GESTUREHANDLER_H77#endif // GESTUREHANDLER_H
6778
=== added file 'libunity-2d-private/src/inputshapemanager.cpp'
--- libunity-2d-private/src/inputshapemanager.cpp 1970-01-01 00:00:00 +0000
+++ libunity-2d-private/src/inputshapemanager.cpp 2012-02-09 02:13:26 +0000
@@ -0,0 +1,105 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2012 Canonical Ltd.
5 *
6 * Authors:
7 * - Ugo Riboni <ugo.riboni@canonical.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#include <QDebug>
23#include <QRect>
24#include <QX11Info>
25#include <QRegion>
26
27#include "inputshapemanager.h"
28#include "unity2ddeclarativeview.h"
29#include "desktopinfo.h"
30
31// X11
32#include <X11/Xlib.h>
33#include <X11/Xregion.h>
34#include <X11/extensions/shape.h>
35
36InputShapeManager::InputShapeManager(QObject *parent) :
37 QObject(parent),
38 m_target(0)
39{
40}
41
42void InputShapeManager::updateManagedShape()
43{
44 if (m_target == NULL || !m_target->isVisible()) {
45 return;
46 }
47
48 QBitmap inputShape(m_target->width(), m_target->height());
49 inputShape.fill(Qt::color0);
50 QPainter painter(&inputShape);
51
52 Q_FOREACH(InputShapeRectangle* shape, m_shapes) {
53 if (shape->enabled()) {
54 painter.drawPixmap(shape->rectangle().x(), shape->rectangle().y(),
55 shape->shape());
56 }
57 }
58
59 XShapeCombineRegion(QX11Info::display(), m_target->effectiveWinId(),
60 DesktopInfo::instance()->isCompositingManagerRunning() ? ShapeInput : ShapeBounding,
61 0, 0, QRegion(inputShape).handle(), ShapeSet);
62}
63
64Unity2DDeclarativeView* InputShapeManager::target() const
65{
66 return m_target;
67}
68
69void InputShapeManager::setTarget(Unity2DDeclarativeView *target)
70{
71 if (m_target != target) {
72 if (m_target != NULL) m_target->disconnect(this);
73
74 //TODO: de-shape the current target view, if any, before shaping the new one. not used now
75 // as we never change the view anyway.
76
77 m_target = target;
78 if (m_target != NULL) {
79 // due to the way xshape works we need to re-apply the shaping every time the target window
80 // is mapped again.
81 connect(m_target, SIGNAL(visibleChanged(bool)), SLOT(updateManagedShape()));
82 connect(m_target, SIGNAL(sceneResized(QSize)), SLOT(updateManagedShape()));
83 }
84 Q_EMIT targetChanged();
85 updateManagedShape();
86 }
87}
88
89QDeclarativeListProperty<InputShapeRectangle> InputShapeManager::shapes()
90{
91 return QDeclarativeListProperty<InputShapeRectangle>(this, this, &InputShapeManager::appendShape);
92}
93
94void InputShapeManager::appendShape(QDeclarativeListProperty<InputShapeRectangle> *list, InputShapeRectangle *shape)
95{
96 InputShapeManager* instance = qobject_cast<InputShapeManager*>(list->object);
97 if (instance != NULL) {
98 instance->m_shapes.append(shape);
99 instance->connect(shape, SIGNAL(shapeChanged()), SLOT(updateManagedShape()));
100 instance->connect(shape, SIGNAL(enabledChanged()), SLOT(updateManagedShape()));
101 instance->updateManagedShape();
102 }
103}
104
105#include "inputshapemanager.moc"
0106
=== added file 'libunity-2d-private/src/inputshapemanager.h'
--- libunity-2d-private/src/inputshapemanager.h 1970-01-01 00:00:00 +0000
+++ libunity-2d-private/src/inputshapemanager.h 2012-02-09 02:13:26 +0000
@@ -0,0 +1,59 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2012 Canonical Ltd.
5 *
6 * Authors:
7 * - Ugo Riboni <ugo.riboni@canonical.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#ifndef INPUTSHAPEMANAGER_H
23#define INPUTSHAPEMANAGER_H
24
25#include <QObject>
26#include <QDeclarativeListProperty>
27
28#include "inputshaperectangle.h"
29
30class Unity2DDeclarativeView;
31
32class InputShapeManager : public QObject
33{
34 Q_OBJECT
35 Q_PROPERTY(Unity2DDeclarativeView* target READ target WRITE setTarget NOTIFY targetChanged)
36 Q_PROPERTY(QDeclarativeListProperty<InputShapeRectangle> shapes READ shapes)
37 Q_CLASSINFO("DefaultProperty", "shapes")
38
39public:
40 explicit InputShapeManager(QObject *parent = 0);
41 Unity2DDeclarativeView* target() const;
42 void setTarget(Unity2DDeclarativeView* target);
43 QDeclarativeListProperty<InputShapeRectangle> shapes();
44
45Q_SIGNALS:
46 void targetChanged();
47
48public Q_SLOTS:
49 void updateManagedShape();
50
51protected:
52 static void appendShape(QDeclarativeListProperty<InputShapeRectangle> *property, InputShapeRectangle *value);
53
54private:
55 Unity2DDeclarativeView* m_target;
56 QList<InputShapeRectangle*> m_shapes;
57};
58
59#endif // INPUTSHAPEMANAGER_H
060
=== added file 'libunity-2d-private/src/inputshapemask.cpp'
--- libunity-2d-private/src/inputshapemask.cpp 1970-01-01 00:00:00 +0000
+++ libunity-2d-private/src/inputshapemask.cpp 2012-02-09 02:13:26 +0000
@@ -0,0 +1,111 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2012 Canonical Ltd.
5 *
6 * Authors:
7 * - Ugo Riboni <ugo.riboni@canonical.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#include "inputshapemask.h"
23#include "config.h"
24
25#include <QBitmap>
26#include <QDebug>
27
28InputShapeMask::InputShapeMask(QObject *parent) :
29 QObject(parent),
30 m_enabled(true)
31{
32}
33
34void InputShapeMask::updateShape()
35{
36 QBitmap newShape;
37
38 if (!m_source.isEmpty() && m_color.isValid()) {
39 QPixmap image;
40 QString path = unity2dDirectory() + "/" + m_source;
41 if (image.load(path)) {
42 newShape = image.createMaskFromColor(m_color.rgb(), Qt::MaskInColor);
43 } else {
44 qWarning() << "Failed to load input shape mask image from" << path;
45 }
46 }
47
48 m_shape = newShape;
49 Q_EMIT shapeChanged();
50}
51
52QString InputShapeMask::source() const
53{
54 return m_source;
55}
56
57QColor InputShapeMask::color() const
58{
59 return m_color;
60}
61
62QPoint InputShapeMask::position() const
63{
64 return m_position;
65}
66
67bool InputShapeMask::enabled() const
68{
69 return m_enabled;
70}
71
72QBitmap InputShapeMask::shape() const
73{
74 return m_shape;
75}
76
77void InputShapeMask::setSource(const QString &source)
78{
79 if (m_source != source) {
80 m_source = source;
81 Q_EMIT sourceChanged(m_source);
82 updateShape();
83 }
84}
85
86void InputShapeMask::setColor(const QColor &color)
87{
88 if (m_color != color) {
89 m_color = color;
90 Q_EMIT colorChanged(m_color);
91 updateShape();
92 }
93}
94
95void InputShapeMask::setPosition(const QPoint &position)
96{
97 if (m_position != position) {
98 m_position = position;
99 Q_EMIT positionChanged();
100 }
101}
102
103void InputShapeMask::setEnabled(bool enabled)
104{
105 if (m_enabled != enabled) {
106 m_enabled = enabled;
107 Q_EMIT enabledChanged();
108 }
109}
110
111#include "inputshapemask.moc"
0112
=== added file 'libunity-2d-private/src/inputshapemask.h'
--- libunity-2d-private/src/inputshapemask.h 1970-01-01 00:00:00 +0000
+++ libunity-2d-private/src/inputshapemask.h 2012-02-09 02:13:26 +0000
@@ -0,0 +1,71 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2012 Canonical Ltd.
5 *
6 * Authors:
7 * - Ugo Riboni <ugo.riboni@canonical.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#ifndef INPUTSHAPEMASK_H
23#define INPUTSHAPEMASK_H
24
25#include <QObject>
26#include <QColor>
27#include <QPoint>
28#include <QBitmap>
29
30class InputShapeMask : public QObject
31{
32 Q_OBJECT
33 Q_PROPERTY(QString source READ source WRITE setSource NOTIFY sourceChanged)
34 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
35 Q_PROPERTY(QPoint position READ position WRITE setPosition NOTIFY positionChanged)
36 Q_PROPERTY(QBitmap shape READ shape NOTIFY shapeChanged)
37 Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
38
39public:
40 explicit InputShapeMask(QObject *parent = 0);
41
42 QString source() const;
43 QColor color() const;
44 QPoint position() const;
45 bool enabled() const;
46 QBitmap shape() const;
47
48 void setSource(const QString& source);
49 void setColor(const QColor& color);
50 void setPosition(const QPoint& position);
51 void setEnabled(bool enabled);
52
53Q_SIGNALS:
54 void sourceChanged(const QString& source);
55 void colorChanged(const QColor& color);
56 void enabledChanged();
57 void shapeChanged();
58 void positionChanged();
59
60protected:
61 void updateShape();
62
63private:
64 QString m_source;
65 QColor m_color;
66 QPoint m_position;
67 bool m_enabled;
68 QBitmap m_shape;
69};
70
71#endif // INPUTSHAPEMASK_H
072
=== added file 'libunity-2d-private/src/inputshaperectangle.cpp'
--- libunity-2d-private/src/inputshaperectangle.cpp 1970-01-01 00:00:00 +0000
+++ libunity-2d-private/src/inputshaperectangle.cpp 2012-02-09 02:13:26 +0000
@@ -0,0 +1,126 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2012 Canonical Ltd.
5 *
6 * Authors:
7 * - Ugo Riboni <ugo.riboni@canonical.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#include "inputshaperectangle.h"
23#include "inputshapemask.h"
24
25#include <QBitmap>
26#include <QPainter>
27#include <QPainterPath>
28#include <QDebug>
29#include <QRect>
30
31InputShapeRectangle::InputShapeRectangle(QObject *parent) :
32 QObject(parent),
33 m_enabled(true),
34 m_mirrorHorizontally(false)
35{
36}
37
38void InputShapeRectangle::updateShape()
39{
40 QBitmap newShape(m_rectangle.width(), m_rectangle.height());
41 newShape.fill(Qt::color1);
42
43 if (!m_rectangle.isEmpty() && m_masks.count() > 0) {
44 QPainter painter(&newShape);
45 painter.setBackgroundMode(Qt::OpaqueMode);
46
47 Q_FOREACH (InputShapeMask* mask, m_masks) {
48 if (mask->enabled()) {
49 painter.drawPixmap(mask->position(), mask->shape());
50 }
51 }
52 }
53
54 if (m_mirrorHorizontally) {
55 newShape = QBitmap::fromImage(newShape.toImage().mirrored(true, false));
56 }
57
58 m_shape = newShape;
59 Q_EMIT shapeChanged();
60}
61
62QRect InputShapeRectangle::rectangle() const
63{
64 return m_rectangle;
65}
66
67void InputShapeRectangle::setRectangle(QRect rectangle)
68{
69 if (rectangle != m_rectangle) {
70 m_rectangle = rectangle;
71 updateShape();
72 Q_EMIT rectangleChanged();
73 }
74}
75
76bool InputShapeRectangle::enabled() const
77{
78 return m_enabled;
79}
80
81void InputShapeRectangle::setEnabled(bool enabled)
82{
83 if (enabled != m_enabled) {
84 m_enabled = enabled;
85 Q_EMIT enabledChanged();
86
87 }
88}
89
90QBitmap InputShapeRectangle::shape() const
91{
92 return m_shape;
93}
94
95QDeclarativeListProperty<InputShapeMask> InputShapeRectangle::masks()
96{
97 return QDeclarativeListProperty<InputShapeMask>(this, this, &InputShapeRectangle::appendMask);
98}
99
100bool InputShapeRectangle::mirrorHorizontally() const
101{
102 return m_mirrorHorizontally;
103}
104
105void InputShapeRectangle::setMirrorHorizontally(bool mirror)
106{
107 if (mirror != m_mirrorHorizontally) {
108 m_mirrorHorizontally = mirror;
109 updateShape();
110 Q_EMIT mirrorHorizontallyChanged(m_mirrorHorizontally);
111 }
112}
113
114void InputShapeRectangle::appendMask(QDeclarativeListProperty<InputShapeMask> *list, InputShapeMask *mask)
115{
116 InputShapeRectangle* instance = qobject_cast<InputShapeRectangle*>(list->object);
117 if (instance != NULL) {
118 instance->m_masks.append(mask);
119 instance->connect(mask, SIGNAL(enabledChanged()), SLOT(updateShape()));
120 instance->connect(mask, SIGNAL(shapeChanged()), SLOT(updateShape()));
121 instance->connect(mask, SIGNAL(positionChanged()), SLOT(updateShape()));
122 instance->updateShape();
123 }
124}
125
126#include "inputshaperectangle.moc"
0127
=== added file 'libunity-2d-private/src/inputshaperectangle.h'
--- libunity-2d-private/src/inputshaperectangle.h 1970-01-01 00:00:00 +0000
+++ libunity-2d-private/src/inputshaperectangle.h 2012-02-09 02:13:26 +0000
@@ -0,0 +1,75 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2012 Canonical Ltd.
5 *
6 * Authors:
7 * - Ugo Riboni <ugo.riboni@canonical.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#ifndef INPUTSHAPERECTANGLE_H
23#define INPUTSHAPERECTANGLE_H
24
25#include <QObject>
26#include <QRect>
27#include <QBitmap>
28#include <QDeclarativeListProperty>
29#include <QList>
30
31class InputShapeMask;
32
33class InputShapeRectangle : public QObject
34{
35 Q_OBJECT
36 Q_PROPERTY(QRect rectangle READ rectangle WRITE setRectangle NOTIFY rectangleChanged)
37 Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
38 Q_PROPERTY(bool mirrorHorizontally READ mirrorHorizontally WRITE setMirrorHorizontally NOTIFY mirrorHorizontallyChanged)
39 Q_PROPERTY(QBitmap shape READ shape NOTIFY shapeChanged)
40 Q_PROPERTY(QDeclarativeListProperty<InputShapeMask> masks READ masks)
41 Q_CLASSINFO("DefaultProperty", "masks")
42
43public:
44 explicit InputShapeRectangle(QObject *parent = 0);
45
46 QRect rectangle() const;
47 void setRectangle(QRect rectangle);
48 bool enabled() const;
49 void setEnabled(bool enabled);
50 QBitmap shape() const;
51 QDeclarativeListProperty<InputShapeMask> masks();
52 bool mirrorHorizontally() const;
53 void setMirrorHorizontally(bool mirror);
54
55protected:
56 static void appendMask(QDeclarativeListProperty<InputShapeMask> *list, InputShapeMask *mask);
57
58protected Q_SLOTS:
59 void updateShape();
60
61Q_SIGNALS:
62 void rectangleChanged();
63 void enabledChanged();
64 void shapeChanged();
65 void mirrorHorizontallyChanged(bool mirrorHorizontally);
66
67private:
68 QRect m_rectangle;
69 bool m_enabled;
70 bool m_mirrorHorizontally;
71 QBitmap m_shape;
72 QList<InputShapeMask*> m_masks;
73};
74
75#endif // INPUTSHAPERECTANGLE_H
076
=== removed file 'libunity-2d-private/src/intellihidebehavior.cpp'
--- libunity-2d-private/src/intellihidebehavior.cpp 2012-01-17 14:31:19 +0000
+++ libunity-2d-private/src/intellihidebehavior.cpp 1970-01-01 00:00:00 +0000
@@ -1,256 +0,0 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2011 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 * - Florian Boucault <florian.boucault@canonical.com>
9 *
10 * License: GPL v3
11 */
12// Self
13#include "intellihidebehavior.h"
14
15// Local
16#include "unity2dpanel.h"
17
18// libunity-2d
19#include <debug_p.h>
20#include <edgehitdetector.h>
21
22// Qt
23#include <QCursor>
24#include <QEvent>
25#include <QTimer>
26#include <QWidget>
27#include <QDesktopWidget>
28
29// libwnck
30extern "C" {
31#define WNCK_I_KNOW_THIS_IS_UNSTABLE
32#include <libwnck/libwnck.h>
33}
34
35static const int AUTOHIDE_TIMEOUT = 1000;
36
37// Handy macros to declare GObject callbacks. The 'n' in CALLBACKn refers to
38// the number of dummy arguments the callback returns
39#define GOBJECT_CALLBACK0(callbackName, slot) \
40static void \
41callbackName(GObject* src, QObject* dst) \
42{ \
43 QMetaObject::invokeMethod(dst, slot); \
44}
45
46#define GOBJECT_CALLBACK1(callbackName, slot) \
47static void \
48callbackName(GObject* src, void* dummy1, QObject* dst) \
49{ \
50 QMetaObject::invokeMethod(dst, slot); \
51}
52
53#define GOBJECT_CALLBACK2(callbackName, slot) \
54static void \
55callbackName(GObject* src, void* dummy1, void* dummy2, QObject* dst) \
56{ \
57 QMetaObject::invokeMethod(dst, slot); \
58}
59
60// Screen callbacks
61GOBJECT_CALLBACK1(activeWindowChangedCB, "updateActiveWindowConnections");
62GOBJECT_CALLBACK1(activeWorkspaceChangedCB, "updateVisibility");
63
64// Window callbacks
65GOBJECT_CALLBACK2(stateChangedCB, "updateVisibility");
66GOBJECT_CALLBACK0(geometryChangedCB, "updateVisibility");
67GOBJECT_CALLBACK0(workspaceChangedCB, "updateVisibility");
68
69IntelliHideBehavior::IntelliHideBehavior(QWidget* panel)
70: AbstractVisibilityBehavior(panel)
71, m_updateVisibilityTimer(new QTimer(this))
72, m_edgeHitDetector(0)
73, m_activeWindow(0)
74{
75 m_updateVisibilityTimer->setSingleShot(true);
76 m_updateVisibilityTimer->setInterval(AUTOHIDE_TIMEOUT);
77 connect(m_updateVisibilityTimer, SIGNAL(timeout()), SLOT(updateVisibility()));
78
79 setPanel(panel);
80
81 WnckScreen* screen = wnck_screen_get_default();
82 g_signal_connect(G_OBJECT(screen), "active-window-changed", G_CALLBACK(activeWindowChangedCB), this);
83 g_signal_connect(G_OBJECT(screen), "active-workspace-changed", G_CALLBACK(activeWorkspaceChangedCB), this);
84
85 updateActiveWindowConnections();
86}
87
88IntelliHideBehavior::~IntelliHideBehavior()
89{
90 disconnectFromGSignals();
91 WnckScreen* screen = wnck_screen_get_default();
92 g_signal_handlers_disconnect_by_func(G_OBJECT(screen), gpointer(activeWindowChangedCB), this);
93 g_signal_handlers_disconnect_by_func(G_OBJECT(screen), gpointer(activeWorkspaceChangedCB), this);
94}
95
96void IntelliHideBehavior::disconnectFromGSignals()
97{
98 if (m_activeWindow) {
99 g_signal_handlers_disconnect_by_func(m_activeWindow, gpointer(stateChangedCB), this);
100 g_signal_handlers_disconnect_by_func(m_activeWindow, gpointer(geometryChangedCB), this);
101 g_signal_handlers_disconnect_by_func(m_activeWindow, gpointer(workspaceChangedCB), this);
102 }
103}
104
105void IntelliHideBehavior::updateActiveWindowConnections()
106{
107 WnckScreen* screen = wnck_screen_get_default();
108
109 disconnectFromGSignals();
110 m_activeWindow = 0;
111
112 WnckWindow* window = wnck_screen_get_active_window(screen);
113 if (window) {
114 m_activeWindow = window;
115 g_signal_connect(G_OBJECT(window), "state-changed", G_CALLBACK(stateChangedCB), this);
116 g_signal_connect(G_OBJECT(window), "geometry-changed", G_CALLBACK(geometryChangedCB), this);
117 g_signal_connect(G_OBJECT(window), "workspace-changed", G_CALLBACK(workspaceChangedCB), this);
118 }
119
120 gboolean isShowingDesktop = wnck_screen_get_showing_desktop(screen);
121 if (isShowingDesktop) {
122 showPanel();
123 } else {
124 updateVisibility();
125 }
126}
127
128void IntelliHideBehavior::updateVisibility()
129{
130 if (m_panel == NULL) {
131 return;
132 }
133 if (isMouseForcingVisibility()) {
134 return;
135 }
136 int launcherPid = getpid();
137
138 // Compute launcherRect, adjust "left" to the position where the launcher
139 // is fully visible.
140 QRect launcherRect = m_panel->geometry();
141 // FIXME: the following code assumes that the launcher is on the left edge
142 // of the screen
143 if (QApplication::isLeftToRight()) {
144 launcherRect.moveLeft(0);
145 } else {
146 QDesktopWidget* desktop = QApplication::desktop();
147 const QRect screen = desktop->screenGeometry(m_panel);
148 launcherRect.moveRight(screen.right());
149 }
150
151 WnckScreen* screen = wnck_screen_get_default();
152 WnckWorkspace* workspace = wnck_screen_get_active_workspace(screen);
153
154 // Check whether a window is crossing our launcher rect
155 bool crossWindow = false;
156 GList* list = wnck_screen_get_windows(screen);
157 for (; list; list = g_list_next(list)) {
158 WnckWindow* window = WNCK_WINDOW(list->data);
159 if (wnck_window_is_on_workspace(window, workspace) && wnck_window_get_pid(window) != launcherPid) {
160 WnckWindowType type = wnck_window_get_window_type(window);
161
162 // Only take into account typical application windows
163 if (type != WNCK_WINDOW_NORMAL &&
164 type != WNCK_WINDOW_DIALOG &&
165 type != WNCK_WINDOW_TOOLBAR &&
166 type != WNCK_WINDOW_MENU &&
167 type != WNCK_WINDOW_UTILITY) {
168 continue;
169 }
170
171 WnckWindowState state = wnck_window_get_state(window);
172
173 // Skip hidden (==minimized and other states) windows
174 if (state & WNCK_WINDOW_STATE_HIDDEN) {
175 continue;
176 }
177
178 // Check the window rect
179 int x, y, width, height;
180 wnck_window_get_geometry(window, &x, &y, &width, &height);
181 QRect rect(x, y, width, height);
182 if (rect.intersects(launcherRect)) {
183 crossWindow = true;
184 break;
185 }
186 }
187 }
188
189 if (crossWindow) {
190 hidePanel();
191 } else {
192 showPanel();
193 }
194}
195
196bool IntelliHideBehavior::eventFilter(QObject* object, QEvent* event)
197{
198 switch (event->type()) {
199 case QEvent::Enter:
200 m_updateVisibilityTimer->stop();
201 break;
202 case QEvent::Leave:
203 m_updateVisibilityTimer->start();
204 break;
205 default:
206 break;
207 }
208 return false;
209}
210
211bool IntelliHideBehavior::isMouseForcingVisibility() const
212{
213 // We check the cursor position ourself because using QWidget::underMouse()
214 // is unreliable. It causes LP bug #740280
215 return m_panel != NULL && m_panel->geometry().contains(QCursor::pos());
216}
217
218void IntelliHideBehavior::hidePanel()
219{
220 if (m_visible) {
221 m_visible = false;
222 Q_EMIT visibleChanged(m_visible);
223 createEdgeHitDetector();
224 }
225}
226
227void IntelliHideBehavior::showPanel()
228{
229 if (!m_visible) {
230 // Delete the edge hit detector so that it does not prevent mouse events
231 // from reaching the panel
232 delete m_edgeHitDetector;
233 m_edgeHitDetector = 0;
234 m_visible = true;
235 Q_EMIT visibleChanged(m_visible);
236 }
237}
238
239void IntelliHideBehavior::createEdgeHitDetector()
240{
241 m_edgeHitDetector = new EdgeHitDetector(this);
242 connect(m_edgeHitDetector, SIGNAL(edgeHit()), SLOT(showPanel()));
243}
244
245void IntelliHideBehavior::setPanel(QWidget *panel)
246{
247 if (m_panel != NULL) {
248 m_panel->removeEventFilter(this);
249 }
250 AbstractVisibilityBehavior::setPanel(panel);
251 if (m_panel != NULL) {
252 m_panel->installEventFilter(this);
253 }
254}
255
256#include "intellihidebehavior.moc"
2570
=== removed file 'libunity-2d-private/src/intellihidebehavior.h'
--- libunity-2d-private/src/intellihidebehavior.h 2011-06-11 11:33:52 +0000
+++ libunity-2d-private/src/intellihidebehavior.h 1970-01-01 00:00:00 +0000
@@ -1,75 +0,0 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2011 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 * - Florian Boucault <florian.boucault@canonical.com>
9 *
10 * License: GPL v3
11 */
12#ifndef INTELLIHIDEBEHAVIOR_H
13#define INTELLIHIDEBEHAVIOR_H
14
15// Local
16#include <abstractvisibilitybehavior.h>
17
18// Qt
19#include <QObject>
20
21struct _WnckWindow;
22
23class QTimer;
24
25class QWidget;
26class EdgeHitDetector;
27
28/**
29 * This class implements the Intellihide behavior of the launcher
30 */
31class IntelliHideBehavior : public AbstractVisibilityBehavior
32{
33 Q_OBJECT
34
35 Q_PROPERTY(QWidget* panel READ panel WRITE setPanel NOTIFY panelChanged)
36
37public:
38 IntelliHideBehavior(QWidget* panel=0);
39 ~IntelliHideBehavior();
40
41 // setters
42 void setPanel(QWidget *panel);
43
44Q_SIGNALS:
45 void panelChanged(QWidget *panel);
46
47protected:
48 bool eventFilter(QObject*, QEvent*);
49
50private Q_SLOTS:
51 void updateVisibility();
52 void updateActiveWindowConnections();
53 void showPanel();
54 void hidePanel();
55
56private:
57 Q_DISABLE_COPY(IntelliHideBehavior);
58
59 enum PanelVisibility {
60 VisiblePanel,
61 HiddenPanel
62 };
63 QTimer* m_updateVisibilityTimer;
64 EdgeHitDetector* m_edgeHitDetector;
65
66 struct _WnckWindow* m_activeWindow;
67
68 void disconnectFromGSignals();
69
70 bool isMouseForcingVisibility() const;
71
72 void createEdgeHitDetector();
73};
74
75#endif /* INTELLIHIDEBEHAVIOR_H */
760
=== modified file 'libunity-2d-private/src/launcherclient.cpp'
--- libunity-2d-private/src/launcherclient.cpp 2011-12-11 16:36:28 +0000
+++ libunity-2d-private/src/launcherclient.cpp 2012-02-09 02:13:26 +0000
@@ -21,54 +21,6 @@
21// Self21// Self
22#include "launcherclient.h"22#include "launcherclient.h"
2323
24// Qt
25#include <QDBusConnection>
26#include <QDBusMessage>
27#include <QDBusPendingCall>
28
29static const char* LAUNCHER_DBUS_SERVICE = "com.canonical.Unity2d.Launcher";
30static const char* LAUNCHER_DBUS_OBJECT_PATH = "/Launcher";
31static const char* LAUNCHER_DBUS_INTERFACE = "com.canonical.Unity2d.Launcher";
32
33const int LauncherClient::MaximumWidth = 65;24const int LauncherClient::MaximumWidth = 65;
3425
35struct LauncherClientPrivate
36{
37 LauncherClient* q;
38
39 void asyncDBusCall(const QString& methodName)
40 {
41 /* The constructor for QDBusInterface potentially does synchronous
42 introspection calls. In contrast, this is really asynchronous.
43 See rationale at https://bugs.launchpad.net/unity-2d/+bug/738025. */
44 QDBusMessage call = QDBusMessage::createMethodCall(LAUNCHER_DBUS_SERVICE,
45 LAUNCHER_DBUS_OBJECT_PATH,
46 LAUNCHER_DBUS_INTERFACE,
47 methodName);
48 QDBusConnection::sessionBus().asyncCall(call);
49 }
50};
51
52LauncherClient::LauncherClient(QObject* parent)
53: QObject(parent)
54, d(new LauncherClientPrivate)
55{
56 d->q = this;
57}
58
59LauncherClient::~LauncherClient()
60{
61 delete d;
62}
63
64void LauncherClient::beginForceVisible()
65{
66 d->asyncDBusCall("BeginForceVisible");
67}
68
69void LauncherClient::endForceVisible()
70{
71 d->asyncDBusCall("EndForceVisible");
72}
73
74#include "launcherclient.moc"26#include "launcherclient.moc"
7527
=== modified file 'libunity-2d-private/src/launcherclient.h'
--- libunity-2d-private/src/launcherclient.h 2011-03-22 11:30:53 +0000
+++ libunity-2d-private/src/launcherclient.h 2012-02-09 02:13:26 +0000
@@ -26,26 +26,13 @@
26// Qt26// Qt
27#include <QObject>27#include <QObject>
2828
29struct LauncherClientPrivate;
30/**29/**
31 * Makes it easy for unity-2d components to communicate with unity-2d-launcher30 * Makes it easy for unity-2d components to communicate with unity-2d-launcher
32 */31 */
33class LauncherClient : public QObject32class LauncherClient
34{33{
35 Q_OBJECT
36public:34public:
37 // The amount of pixels used by the launcher on the left edge when it is
38 // fully visible.
39 static const int MaximumWidth;35 static const int MaximumWidth;
40
41 LauncherClient(QObject* parent = 0);
42 ~LauncherClient();
43
44 void beginForceVisible();
45 void endForceVisible();
46
47private:
48 LauncherClientPrivate* const d;
49};36};
5037
51#endif /* LAUNCHERCLIENT_H */38#endif /* LAUNCHERCLIENT_H */
5239
=== removed file 'libunity-2d-private/src/mousearea.cpp'
--- libunity-2d-private/src/mousearea.cpp 2011-06-11 10:50:03 +0000
+++ libunity-2d-private/src/mousearea.cpp 1970-01-01 00:00:00 +0000
@@ -1,117 +0,0 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2011 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published
11 * by the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21// Self
22#include "mousearea.h"
23
24// Local
25#include <debug_p.h>
26
27// Qt
28#include <QX11Info>
29
30// X11
31#include <X11/Xlib.h>
32
33struct MouseAreaPrivate
34{
35 Window m_window;
36 QRect m_geometry;
37 bool m_containsMouse;
38};
39
40MouseArea::MouseArea(QObject* parent)
41: QObject(parent)
42, d(new MouseAreaPrivate)
43{
44 Unity2dApplication* application = Unity2dApplication::instance();
45 if (application == NULL) {
46 /* This can happen for example when using qmlviewer */
47 UQ_WARNING << "The application is not an Unity2dApplication."
48 "MouseArea disabled.";
49 } else {
50 application->installX11EventFilter(this);
51 }
52
53 d->m_containsMouse = false;
54
55 XSetWindowAttributes attributes;
56 attributes.override_redirect = True;
57 attributes.event_mask = EnterWindowMask | LeaveWindowMask;
58 unsigned long attributesMask = CWOverrideRedirect | CWEventMask;
59
60 d->m_geometry = QRect(0, 0, 1, 1);
61
62 d->m_window = XCreateWindow(QX11Info::display(), QX11Info::appRootWindow(),
63 0, 0, 1, 1, // geometry
64 0, // border_width
65 0, // depth
66 InputOnly, // class
67 CopyFromParent, // visual
68 attributesMask,
69 &attributes);
70
71 XMapWindow(QX11Info::display(), d->m_window);
72}
73
74MouseArea::~MouseArea()
75{
76 XDestroyWindow(QX11Info::display(), d->m_window);
77 delete d;
78}
79
80QRect MouseArea::geometry() const
81{
82 return d->m_geometry;
83}
84
85void MouseArea::setGeometry(const QRect& rect)
86{
87 setGeometry(rect.x(), rect.y(), rect.width(), rect.height());
88}
89
90void MouseArea::setGeometry(int x, int y, int width, int height)
91{
92 d->m_geometry = QRect(x, y, width, height);
93 XMoveResizeWindow(QX11Info::display(), d->m_window, x, y, width, height);
94}
95
96bool MouseArea::x11EventFilter(XEvent* _event)
97{
98 if (_event->type == EnterNotify || _event->type == LeaveNotify) {
99 XCrossingEvent* event = (XCrossingEvent*)(_event);
100 if (event->window == d->m_window) {
101 d->m_containsMouse = event->type == EnterNotify;
102 if (d->m_containsMouse) {
103 entered();
104 } else {
105 exited();
106 }
107 }
108 }
109 return false;
110}
111
112bool MouseArea::containsMouse() const
113{
114 return d->m_containsMouse;
115}
116
117#include "mousearea.moc"
1180
=== removed file 'libunity-2d-private/src/mousearea.h'
--- libunity-2d-private/src/mousearea.h 2011-02-15 18:18:13 +0000
+++ libunity-2d-private/src/mousearea.h 1970-01-01 00:00:00 +0000
@@ -1,60 +0,0 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2011 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published
11 * by the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21#ifndef MOUSEAREA_H
22#define MOUSEAREA_H
23
24// Local
25#include <unity2dapplication.h>
26
27// Qt
28#include <QObject>
29#include <QRect>
30
31struct MouseAreaPrivate;
32/**
33 * A class to help detecting when the mouse cursor enters an area.
34 * Quite similar to QML MouseArea item.
35 */
36class MouseArea : public QObject, protected AbstractX11EventFilter
37{
38Q_OBJECT
39public:
40 MouseArea(QObject* parent = 0);
41 ~MouseArea();
42
43 QRect geometry() const;
44 void setGeometry(int x, int y, int width, int height);
45 void setGeometry(const QRect&);
46
47 bool containsMouse() const;
48
49Q_SIGNALS:
50 void entered();
51 void exited();
52
53protected:
54 bool x11EventFilter(XEvent*);
55
56private:
57 MouseAreaPrivate* const d;
58};
59
60#endif /* MOUSEAREA_H */
610
=== added file 'libunity-2d-private/src/spreadmonitor.cpp'
--- libunity-2d-private/src/spreadmonitor.cpp 1970-01-01 00:00:00 +0000
+++ libunity-2d-private/src/spreadmonitor.cpp 2012-02-09 02:13:26 +0000
@@ -0,0 +1,61 @@
1/*
2 * Copyright (C) 2011 Canonical, Ltd.
3 *
4 * Authors:
5 * Ugo Riboni <ugo.riboni@canonical.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 3.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20// local
21#include "abstractdbusservicemonitor.h"
22#include "spreadmonitor.h"
23
24// QT
25#include <QDBusConnection>
26#include <QDBusConnectionInterface>
27#include <QDBusReply>
28
29SpreadMonitor::SpreadMonitor(QObject *parent)
30 : AbstractDBusServiceMonitor("com.canonical.Unity2d.Spread", "/Spread",
31 "com.canonical.Unity2d.Spread", parent)
32{
33 connect(this, SIGNAL(serviceAvailableChanged(bool)), SLOT(onServiceAvailableChanged(bool)));
34
35 if (serviceAvailable()) {
36 onServiceAvailableChanged(true);
37 }
38}
39
40void SpreadMonitor::onServiceAvailableChanged(bool available)
41{
42 if (available) {
43 connect(dbusInterface(), SIGNAL(IsShownChanged(bool)), SIGNAL(shownChanged(bool)));
44
45 Q_EMIT shownChanged(shown());
46 } else {
47 Q_EMIT shownChanged(false);
48 }
49}
50
51bool SpreadMonitor::shown() const
52{
53 if (dbusInterface() == 0) {
54 return false;
55 } else {
56 QDBusReply<bool> result = dbusInterface()->call("IsShown");
57 return result.isValid() && result.value() == true;
58 }
59}
60
61#include "spreadmonitor.moc"
062
=== added file 'libunity-2d-private/src/spreadmonitor.h'
--- libunity-2d-private/src/spreadmonitor.h 1970-01-01 00:00:00 +0000
+++ libunity-2d-private/src/spreadmonitor.h 2012-02-09 02:13:26 +0000
@@ -0,0 +1,48 @@
1/*
2 * Copyright (C) 2011 Canonical, Ltd.
3 *
4 * Authors:
5 * Ugo Riboni <ugo.riboni@canonical.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 3.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef SPREADMONITOR_H
21#define SPREADMONITOR_H
22
23// QT
24#include <QObject>
25#include <QMetaType>
26
27// local
28#include "abstractdbusservicemonitor.h"
29
30class SpreadMonitor : public AbstractDBusServiceMonitor
31{
32 Q_OBJECT
33 Q_PROPERTY(bool shown READ shown NOTIFY shownChanged)
34
35public:
36 explicit SpreadMonitor(QObject *parent = 0);
37 bool shown() const;
38
39protected Q_SLOTS:
40 void onServiceAvailableChanged(bool available);
41
42Q_SIGNALS:
43 void shownChanged(bool visible);
44};
45
46Q_DECLARE_METATYPE(SpreadMonitor*)
47
48#endif // SPREADMONITOR_H
049
=== added file 'libunity-2d-private/src/strutmanager.cpp'
--- libunity-2d-private/src/strutmanager.cpp 1970-01-01 00:00:00 +0000
+++ libunity-2d-private/src/strutmanager.cpp 2012-02-09 02:13:26 +0000
@@ -0,0 +1,191 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2010, 2012 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 * - Albert Astals Cid <albert.astals@canonical.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published
12 * by the Free Software Foundation; version 3.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 */
22
23// Self
24#include "strutmanager.h"
25
26// Qt
27#include <QApplication>
28#include <QDesktopWidget>
29#include <QX11Info>
30
31// X
32#include <X11/Xlib.h>
33#include <X11/Xatom.h>
34
35static void setStrut(ulong* struts, WId effectiveWinId)
36{
37 static Atom atom = XInternAtom(QX11Info::display(), "_NET_WM_STRUT_PARTIAL", False);
38 XChangeProperty(QX11Info::display(), effectiveWinId, atom,
39 XA_CARDINAL, 32, PropModeReplace,
40 (unsigned char *) struts, 12);
41}
42
43StrutManager::StrutManager()
44 : m_enabled(true),
45 m_widget(NULL),
46 m_edge(Unity2dPanel::TopEdge),
47 m_width(-1),
48 m_height(-1)
49{
50}
51
52StrutManager::~StrutManager()
53{
54 if (m_enabled) {
55 releaseStrut();
56 }
57}
58
59bool StrutManager::enabled() const
60{
61 return m_enabled;
62}
63
64void StrutManager::setEnabled(bool value)
65{
66 if (m_enabled != value) {
67 if (value) {
68 reserveStrut();
69 } else {
70 releaseStrut();
71 }
72 m_enabled = value;
73 Q_EMIT enabledChanged(value);
74 }
75}
76
77QObject *StrutManager::widget() const
78{
79 return m_widget;
80}
81
82void StrutManager::setWidget(QObject *widget)
83{
84 m_widget = qobject_cast<QWidget*>(widget);
85 Q_ASSERT(m_widget != NULL);
86}
87
88Unity2dPanel::Edge StrutManager::edge() const
89{
90 return m_edge;
91}
92
93void StrutManager::setEdge(Unity2dPanel::Edge edge)
94{
95 m_edge = edge;
96 updateStrut();
97}
98
99int StrutManager::width() const
100{
101 return m_width;
102}
103
104void StrutManager::setWidth(int width)
105{
106 m_width = width;
107}
108
109int StrutManager::realWidth() const
110{
111 if (m_widget == NULL)
112 return m_width;
113
114 if (m_width == -1)
115 return m_widget->width();
116
117 return m_width;
118}
119
120int StrutManager::height() const
121{
122 return m_height;
123}
124
125void StrutManager::setHeight(int height)
126{
127 m_height = height;
128}
129
130int StrutManager::realHeight() const
131{
132 if (m_widget == NULL)
133 return m_height;
134
135 if (m_height == -1)
136 return m_widget->height();
137
138 return m_height;
139}
140
141void StrutManager::updateStrut()
142{
143 if (m_enabled) {
144 reserveStrut();
145 }
146}
147
148
149void StrutManager::reserveStrut()
150{
151 if (m_widget == NULL)
152 return;
153
154 QDesktopWidget* desktop = QApplication::desktop();
155 const QRect screen = desktop->screenGeometry(m_widget);
156 const QRect available = desktop->availableGeometry(m_widget);
157
158 ulong struts[12] = {};
159 switch (m_edge) {
160 case Unity2dPanel::LeftEdge:
161 if (QApplication::isLeftToRight()) {
162 struts[0] = realWidth();
163 struts[4] = available.top();
164 struts[5] = available.y() + available.height();
165 } else {
166 struts[1] = realWidth();
167 struts[6] = available.top();
168 struts[7] = available.y() + available.height();
169 }
170 break;
171 case Unity2dPanel::TopEdge:
172 struts[2] = realHeight();
173 struts[8] = screen.left();
174 struts[9] = screen.x() + screen.width();
175 break;
176 }
177
178 setStrut(struts, m_widget->effectiveWinId());
179}
180
181void StrutManager::releaseStrut()
182{
183 if (m_widget == NULL)
184 return;
185
186 ulong struts[12];
187 memset(struts, 0, sizeof struts);
188 setStrut(struts, m_widget->effectiveWinId());
189}
190
191#include "strutmanager.moc"
0192
=== added file 'libunity-2d-private/src/strutmanager.h'
--- libunity-2d-private/src/strutmanager.h 1970-01-01 00:00:00 +0000
+++ libunity-2d-private/src/strutmanager.h 2012-02-09 02:13:26 +0000
@@ -0,0 +1,92 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2010, 2012 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 * - Albert Astals Cid <albert.astals@canonical.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published
12 * by the Free Software Foundation; version 3.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 */
22
23#ifndef STRUTMANAGER_H
24#define STRUTMANAGER_H
25
26// Unity 2D
27#include "unity2dpanel.h"
28
29class StrutManager : public QObject
30{
31 Q_OBJECT
32 Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
33 Q_PROPERTY(QObject* widget READ widget WRITE setWidget)
34 Q_PROPERTY(Unity2dPanel::Edge edge READ edge WRITE setEdge)
35 Q_PROPERTY(int width READ width WRITE setWidth)
36 Q_PROPERTY(int height READ height WRITE setHeight)
37
38public:
39 StrutManager();
40 ~StrutManager();
41
42 bool enabled() const;
43 void setEnabled(bool value);
44
45 // QObject due to QML constraints
46 QObject *widget() const;
47 void setWidget(QObject *widget);
48
49 Unity2dPanel::Edge edge() const;
50 void setEdge(Unity2dPanel::Edge edge);
51
52 /**
53 * Returns the width set to the strut manager
54 * If is -1 (the default value) will use the width of the widget given in setWidget
55 */
56 int width() const;
57 void setWidth(int width);
58 /**
59 * Returns the actual width in use by the strut manager
60 * It is either width() or m_widget->width()
61 */
62 int realWidth() const;
63
64 /**
65 * Returns the height set to the strut manager
66 * If is -1 (the default value) will use the height of the widget given in setWidget
67 */
68 int height() const;
69 void setHeight(int height);
70 /**
71 * Returns the actual height in use by the strut manager
72 * It is either width() or m_widget->width()
73 */
74 int realHeight() const;
75
76 Q_INVOKABLE void updateStrut();
77
78Q_SIGNALS:
79 void enabledChanged(bool enabled);
80
81private:
82 void reserveStrut();
83 void releaseStrut();
84
85 bool m_enabled;
86 QWidget *m_widget;
87 Unity2dPanel::Edge m_edge;
88 int m_width;
89 int m_height;
90};
91
92#endif /* STRUTMANAGER_H */
0\ No newline at end of file93\ No newline at end of file
194
=== modified file 'libunity-2d-private/src/unity2dpanel.cpp'
--- libunity-2d-private/src/unity2dpanel.cpp 2012-02-03 18:05:42 +0000
+++ libunity-2d-private/src/unity2dpanel.cpp 2012-02-09 02:13:26 +0000
@@ -21,6 +21,7 @@
2121
22// Self22// Self
23#include "unity2dpanel.h"23#include "unity2dpanel.h"
24#include "strutmanager.h"
24#include <debug_p.h>25#include <debug_p.h>
25#include <indicatorsmanager.h>26#include <indicatorsmanager.h>
2627
@@ -32,10 +33,6 @@
32#include <QHBoxLayout>33#include <QHBoxLayout>
33#include <QX11Info>34#include <QX11Info>
3435
35// X
36#include <X11/Xlib.h>
37#include <X11/Xatom.h>
38
39// unity-2d36// unity-2d
40#include "screeninfo.h"37#include "screeninfo.h"
4138
@@ -47,57 +44,11 @@
47 Unity2dPanel::Edge m_edge;44 Unity2dPanel::Edge m_edge;
48 mutable IndicatorsManager* m_indicatorsManager;45 mutable IndicatorsManager* m_indicatorsManager;
49 QHBoxLayout* m_layout;46 QHBoxLayout* m_layout;
50 QPropertyAnimation* m_slideInAnimation;
51 QPropertyAnimation* m_slideOutAnimation;
52 bool m_useStrut;
53 int m_delta;47 int m_delta;
54 bool m_manualSliding;48 bool m_manualSliding;
49 StrutManager m_strutManager;
55 ScreenInfo* m_screenInfo;50 ScreenInfo* m_screenInfo;
5651
57 void setStrut(ulong* struts)
58 {
59 static Atom atom = XInternAtom(QX11Info::display(), "_NET_WM_STRUT_PARTIAL", False);
60 XChangeProperty(QX11Info::display(), q->effectiveWinId(), atom,
61 XA_CARDINAL, 32, PropModeReplace,
62 (unsigned char *) struts, 12);
63 }
64
65 void reserveStrut()
66 {
67 QDesktopWidget* desktop = QApplication::desktop();
68 const QRect screen = desktop->screenGeometry(q);
69 const QRect available = desktop->availableGeometry(q);
70
71 ulong struts[12] = {};
72 switch (m_edge) {
73 case Unity2dPanel::LeftEdge:
74 if (QApplication::isLeftToRight()) {
75 struts[0] = q->width();
76 struts[4] = available.top();
77 struts[5] = available.y() + available.height();
78 } else {
79 struts[1] = q->width();
80 struts[6] = available.top();
81 struts[7] = available.y() + available.height();
82 }
83 break;
84 case Unity2dPanel::TopEdge:
85 struts[2] = q->height();
86 struts[8] = screen.left();
87 struts[9] = screen.x() + screen.width();
88 break;
89 }
90
91 setStrut(struts);
92 }
93
94 void releaseStrut()
95 {
96 ulong struts[12];
97 memset(struts, 0, sizeof struts);
98 setStrut(struts);
99 }
100
101 void updateGeometry()52 void updateGeometry()
102 {53 {
103 const QRect screen = m_screenInfo->geometry();54 const QRect screen = m_screenInfo->geometry();
@@ -139,9 +90,7 @@
13990
140 void updateEdge()91 void updateEdge()
141 {92 {
142 if (m_useStrut) {93 m_strutManager.updateStrut();
143 reserveStrut();
144 }
145 updateGeometry();94 updateGeometry();
146 updateLayoutDirection();95 updateLayoutDirection();
147 }96 }
@@ -151,10 +100,11 @@
151: QWidget(parent)100: QWidget(parent)
152, d(new Unity2dPanelPrivate)101, d(new Unity2dPanelPrivate)
153{102{
103 d->m_strutManager.setWidget(this);
104 d->m_strutManager.setEdge(Unity2dPanel::TopEdge);
154 d->q = this;105 d->q = this;
155 d->m_edge = Unity2dPanel::TopEdge;106 d->m_edge = Unity2dPanel::TopEdge;
156 d->m_indicatorsManager = 0;107 d->m_indicatorsManager = 0;
157 d->m_useStrut = true;
158 d->m_delta = 0;108 d->m_delta = 0;
159 d->m_manualSliding = false;109 d->m_manualSliding = false;
160 d->m_layout = new QHBoxLayout(this);110 d->m_layout = new QHBoxLayout(this);
@@ -168,18 +118,6 @@
168 d->m_screenInfo = new ScreenInfo(this, this);118 d->m_screenInfo = new ScreenInfo(this, this);
169 }119 }
170120
171 d->m_slideInAnimation = new QPropertyAnimation(this);
172 d->m_slideInAnimation->setTargetObject(this);
173 d->m_slideInAnimation->setPropertyName("delta");
174 d->m_slideInAnimation->setDuration(SLIDE_DURATION);
175 d->m_slideInAnimation->setEndValue(0);
176
177 d->m_slideOutAnimation = new QPropertyAnimation(this);
178 d->m_slideOutAnimation->setTargetObject(this);
179 d->m_slideOutAnimation->setPropertyName("delta");
180 d->m_slideOutAnimation->setDuration(SLIDE_DURATION);
181 d->m_slideOutAnimation->setEndValue(-panelSize());
182
183 setAttribute(Qt::WA_X11NetWmWindowTypeDock);121 setAttribute(Qt::WA_X11NetWmWindowTypeDock);
184 setAttribute(Qt::WA_Hover);122 setAttribute(Qt::WA_Hover);
185123
@@ -190,19 +128,18 @@
190 }128 }
191 129
192 connect(QApplication::desktop(), SIGNAL(workAreaResized(int)), SLOT(slotWorkAreaResized(int)));130 connect(QApplication::desktop(), SIGNAL(workAreaResized(int)), SLOT(slotWorkAreaResized(int)));
131 connect(&d->m_strutManager, SIGNAL(enabledChanged(bool)), SIGNAL(useStrutChanged(bool)));
193}132}
194133
195Unity2dPanel::~Unity2dPanel()134Unity2dPanel::~Unity2dPanel()
196{135{
197 if (d->m_useStrut) {
198 d->releaseStrut();
199 }
200 delete d;136 delete d;
201}137}
202138
203void Unity2dPanel::setEdge(Unity2dPanel::Edge edge)139void Unity2dPanel::setEdge(Unity2dPanel::Edge edge)
204{140{
205 d->m_edge = edge;141 d->m_edge = edge;
142 d->m_strutManager.setEdge(edge);
206 if (isVisible()) {143 if (isVisible()) {
207 d->updateEdge();144 d->updateEdge();
208 }145 }
@@ -237,13 +174,6 @@
237{174{
238 QWidget::showEvent(event);175 QWidget::showEvent(event);
239 d->updateEdge();176 d->updateEdge();
240 d->m_slideOutAnimation->setEndValue(-panelSize());
241}
242
243void Unity2dPanel::resizeEvent(QResizeEvent* event)
244{
245 QWidget::resizeEvent(event);
246 d->m_slideOutAnimation->setEndValue(-panelSize());
247}177}
248178
249void Unity2dPanel::slotWorkAreaResized(int screen)179void Unity2dPanel::slotWorkAreaResized(int screen)
@@ -273,20 +203,12 @@
273203
274bool Unity2dPanel::useStrut() const204bool Unity2dPanel::useStrut() const
275{205{
276 return d->m_useStrut;206 return d->m_strutManager.enabled();
277}207}
278208
279void Unity2dPanel::setUseStrut(bool value)209void Unity2dPanel::setUseStrut(bool value)
280{210{
281 if (d->m_useStrut != value) {211 d->m_strutManager.setEnabled(value);
282 if (value) {
283 d->reserveStrut();
284 } else {
285 d->releaseStrut();
286 }
287 d->m_useStrut = value;
288 Q_EMIT useStrutChanged(value);
289 }
290}212}
291213
292int Unity2dPanel::delta() const214int Unity2dPanel::delta() const
@@ -309,24 +231,6 @@
309 return (d->m_edge == Unity2dPanel::TopEdge) ? height() : width();231 return (d->m_edge == Unity2dPanel::TopEdge) ? height() : width();
310}232}
311233
312void Unity2dPanel::slideIn()
313{
314 d->m_slideOutAnimation->stop();
315 if (d->m_slideInAnimation->state() != QAbstractAnimation::Running) {
316 d->m_slideInAnimation->setStartValue(d->m_delta);
317 d->m_slideInAnimation->start();
318 }
319}
320
321void Unity2dPanel::slideOut()
322{
323 d->m_slideInAnimation->stop();
324 if (d->m_slideOutAnimation->state() != QAbstractAnimation::Running) {
325 d->m_slideOutAnimation->setStartValue(d->m_delta);
326 d->m_slideOutAnimation->start();
327 }
328}
329
330bool Unity2dPanel::manualSliding() const234bool Unity2dPanel::manualSliding() const
331{235{
332 return d->m_manualSliding;236 return d->m_manualSliding;
@@ -336,10 +240,6 @@
336{240{
337 if (d->m_manualSliding != manualSliding) {241 if (d->m_manualSliding != manualSliding) {
338 d->m_manualSliding = manualSliding;242 d->m_manualSliding = manualSliding;
339 if (manualSliding) {
340 d->m_slideInAnimation->stop();
341 d->m_slideOutAnimation->stop();
342 }
343 Q_EMIT manualSlidingChanged(d->m_manualSliding);243 Q_EMIT manualSlidingChanged(d->m_manualSliding);
344 }244 }
345}245}
346246
=== modified file 'libunity-2d-private/src/unity2dpanel.h'
--- libunity-2d-private/src/unity2dpanel.h 2012-02-01 16:00:48 +0000
+++ libunity-2d-private/src/unity2dpanel.h 2012-02-09 02:13:26 +0000
@@ -47,6 +47,7 @@
47 */47 */
48 Q_PROPERTY(int manualSliding READ manualSliding WRITE setManualSliding NOTIFY manualSlidingChanged)48 Q_PROPERTY(int manualSliding READ manualSliding WRITE setManualSliding NOTIFY manualSlidingChanged)
49 Q_PROPERTY(bool useStrut READ useStrut WRITE setUseStrut NOTIFY useStrutChanged)49 Q_PROPERTY(bool useStrut READ useStrut WRITE setUseStrut NOTIFY useStrutChanged)
50 Q_ENUMS(Edge)
5051
51public:52public:
52 enum Edge {53 enum Edge {
@@ -89,17 +90,12 @@
8990
90 QString id() const;91 QString id() const;
9192
92public Q_SLOTS:
93 void slideIn();
94 void slideOut();
95
96Q_SIGNALS:93Q_SIGNALS:
97 void manualSlidingChanged(bool);94 void manualSlidingChanged(bool);
98 void useStrutChanged(bool);95 void useStrutChanged(bool);
9996
100protected:97protected:
101 virtual void showEvent(QShowEvent*);98 virtual void showEvent(QShowEvent*);
102 virtual void resizeEvent(QResizeEvent*);
103 virtual void paintEvent(QPaintEvent*);99 virtual void paintEvent(QPaintEvent*);
104100
105private Q_SLOTS:101private Q_SLOTS:
106102
=== added file 'libunity-2d-private/src/windowsintersectmonitor.cpp'
--- libunity-2d-private/src/windowsintersectmonitor.cpp 1970-01-01 00:00:00 +0000
+++ libunity-2d-private/src/windowsintersectmonitor.cpp 2012-02-09 02:13:26 +0000
@@ -0,0 +1,183 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2011 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 * - Florian Boucault <florian.boucault@canonical.com>
9 * - Ugo Riboni <ugo.riboni@canonical.com>
10 *
11 * License: GPL v3
12 */
13
14// Self
15#include "windowsintersectmonitor.h"
16
17// libunity-2d
18#include <debug_p.h>
19
20// Qt
21#include <QCursor>
22#include <QEvent>
23#include <QTimer>
24#include <QWidget>
25#include <QDesktopWidget>
26
27// libwnck
28extern "C" {
29#include <libwnck/libwnck.h>
30}
31
32// Handy macros to declare GObject callbacks. The 'n' in CALLBACKn refers to
33// the number of dummy arguments the callback returns
34#define GOBJECT_CALLBACK0(callbackName, slot) \
35static void \
36callbackName(GObject* src, QObject* dst) \
37{ \
38 QMetaObject::invokeMethod(dst, slot); \
39}
40
41#define GOBJECT_CALLBACK1(callbackName, slot) \
42static void \
43callbackName(GObject* src, void* dummy1, QObject* dst) \
44{ \
45 QMetaObject::invokeMethod(dst, slot); \
46}
47
48#define GOBJECT_CALLBACK2(callbackName, slot) \
49static void \
50callbackName(GObject* src, void* dummy1, void* dummy2, QObject* dst) \
51{ \
52 QMetaObject::invokeMethod(dst, slot); \
53}
54
55// Screen callbacks
56GOBJECT_CALLBACK1(activeWindowChangedCB, "updateActiveWindowConnections");
57GOBJECT_CALLBACK1(activeWorkspaceChangedCB, "updateIntersect");
58GOBJECT_CALLBACK0(showingDesktopChangedCB, "updateIntersect");
59
60// Window callbacks
61GOBJECT_CALLBACK2(stateChangedCB, "updateIntersect");
62GOBJECT_CALLBACK0(geometryChangedCB, "updateIntersect");
63GOBJECT_CALLBACK0(workspaceChangedCB, "updateIntersect");
64
65WindowsIntersectMonitor::WindowsIntersectMonitor()
66 : QObject()
67 , m_activeWindow(0)
68{
69 WnckScreen* screen = wnck_screen_get_default();
70 g_signal_connect(G_OBJECT(screen), "active-window-changed", G_CALLBACK(activeWindowChangedCB), this);
71 g_signal_connect(G_OBJECT(screen), "active-workspace-changed", G_CALLBACK(activeWorkspaceChangedCB), this);
72 g_signal_connect(G_OBJECT(screen), "showing-desktop-changed", G_CALLBACK(showingDesktopChangedCB), this);
73
74 updateActiveWindowConnections();
75}
76
77WindowsIntersectMonitor::~WindowsIntersectMonitor()
78{
79 disconnectFromGSignals();
80 WnckScreen* screen = wnck_screen_get_default();
81 g_signal_handlers_disconnect_by_func(G_OBJECT(screen), gpointer(activeWindowChangedCB), this);
82 g_signal_handlers_disconnect_by_func(G_OBJECT(screen), gpointer(activeWorkspaceChangedCB), this);
83 g_signal_handlers_disconnect_by_func(G_OBJECT(screen), gpointer(showingDesktopChangedCB), this);
84}
85
86void WindowsIntersectMonitor::disconnectFromGSignals()
87{
88 if (m_activeWindow) {
89 g_signal_handlers_disconnect_by_func(m_activeWindow, gpointer(stateChangedCB), this);
90 g_signal_handlers_disconnect_by_func(m_activeWindow, gpointer(geometryChangedCB), this);
91 g_signal_handlers_disconnect_by_func(m_activeWindow, gpointer(workspaceChangedCB), this);
92 }
93}
94
95void WindowsIntersectMonitor::updateActiveWindowConnections()
96{
97 WnckScreen* screen = wnck_screen_get_default();
98
99 disconnectFromGSignals();
100 m_activeWindow = 0;
101
102 WnckWindow* window = wnck_screen_get_active_window(screen);
103 if (window) {
104 m_activeWindow = window;
105 g_signal_connect(G_OBJECT(window), "state-changed", G_CALLBACK(stateChangedCB), this);
106 g_signal_connect(G_OBJECT(window), "geometry-changed", G_CALLBACK(geometryChangedCB), this);
107 g_signal_connect(G_OBJECT(window), "workspace-changed", G_CALLBACK(workspaceChangedCB), this);
108 }
109
110 updateIntersect();
111}
112
113void WindowsIntersectMonitor::updateIntersect()
114{
115 int thisProcessPid = getpid();
116
117 WnckScreen* screen = wnck_screen_get_default();
118 WnckWorkspace* workspace = wnck_screen_get_active_workspace(screen);
119
120 // Check whether a window is crossing our rect
121 bool crossWindow = false;
122 if (!wnck_screen_get_showing_desktop(screen)) {
123 GList* list = wnck_screen_get_windows(screen);
124 for (; list; list = g_list_next(list)) {
125 WnckWindow* window = WNCK_WINDOW(list->data);
126 if (wnck_window_is_on_workspace(window, workspace) &&
127 wnck_window_get_pid(window) != thisProcessPid) {
128 WnckWindowType type = wnck_window_get_window_type(window);
129
130 // Only take into account typical application windows
131 if (type != WNCK_WINDOW_NORMAL &&
132 type != WNCK_WINDOW_DIALOG &&
133 type != WNCK_WINDOW_TOOLBAR &&
134 type != WNCK_WINDOW_MENU &&
135 type != WNCK_WINDOW_UTILITY) {
136 continue;
137 }
138
139 WnckWindowState state = wnck_window_get_state(window);
140
141 // Skip hidden (==minimized and other states) windows
142 if (state & WNCK_WINDOW_STATE_HIDDEN) {
143 continue;
144 }
145
146 // Check the window rect
147 int x, y, width, height;
148 wnck_window_get_geometry(window, &x, &y, &width, &height);
149 QRectF rect(x, y, width, height);
150 if (rect.intersects(m_monitoredArea)) {
151 crossWindow = true;
152 break;
153 }
154 }
155 }
156 }
157
158 if (crossWindow != m_intersects) {
159 m_intersects = crossWindow;
160 Q_EMIT intersectsChanged();
161 }
162}
163
164QRectF WindowsIntersectMonitor::monitoredArea() const
165{
166 return m_monitoredArea;
167}
168
169void WindowsIntersectMonitor::setMonitoredArea(const QRectF& monitoredArea)
170{
171 if (m_monitoredArea != monitoredArea) {
172 m_monitoredArea = monitoredArea;
173 Q_EMIT monitoredAreaChanged();
174 updateIntersect();
175 }
176}
177
178bool WindowsIntersectMonitor::intersects() const
179{
180 return m_intersects;
181}
182
183#include "windowsintersectmonitor.moc"
0184
=== added file 'libunity-2d-private/src/windowsintersectmonitor.h'
--- libunity-2d-private/src/windowsintersectmonitor.h 1970-01-01 00:00:00 +0000
+++ libunity-2d-private/src/windowsintersectmonitor.h 2012-02-09 02:13:26 +0000
@@ -0,0 +1,55 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2011 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 * - Florian Boucault <florian.boucault@canonical.com>
9 * - Ugo Riboni <ugo.riboni@canonical.com>
10 *
11 * License: GPL v3
12 */
13#ifndef WINDOWSINTERSECTMONITOR_H
14#define WINDOWSINTERSECTMONITOR_H
15
16// Qt
17#include <QObject>
18#include <QRectF>
19
20struct _WnckWindow;
21
22class WindowsIntersectMonitor : public QObject
23{
24 Q_OBJECT
25
26 Q_PROPERTY(QRectF monitoredArea READ monitoredArea WRITE setMonitoredArea
27 NOTIFY monitoredAreaChanged)
28 Q_PROPERTY(bool intersects READ intersects NOTIFY intersectsChanged)
29
30public:
31 WindowsIntersectMonitor();
32 ~WindowsIntersectMonitor();
33
34 QRectF monitoredArea() const;
35 void setMonitoredArea(const QRectF& monitoredArea);
36 bool intersects() const;
37
38Q_SIGNALS:
39 void monitoredAreaChanged();
40 void intersectsChanged();
41
42private Q_SLOTS:
43 void updateIntersect();
44 void updateActiveWindowConnections();
45
46private:
47 Q_DISABLE_COPY(WindowsIntersectMonitor);
48 void disconnectFromGSignals();
49
50 struct _WnckWindow* m_activeWindow;
51 QRectF m_monitoredArea;
52 bool m_intersects;
53};
54
55#endif /* WINDOWSINTERSECTMONITOR_H */
056
=== modified file 'libunity-2d-private/tests/CMakeLists.txt'
--- libunity-2d-private/tests/CMakeLists.txt 2011-12-07 12:46:10 +0000
+++ libunity-2d-private/tests/CMakeLists.txt 2012-02-09 02:13:26 +0000
@@ -83,10 +83,3 @@
83# COMMAND /bin/sh gnomesessionclienttest.sh83# COMMAND /bin/sh gnomesessionclienttest.sh
84# )84# )
8585
86# mouseareademo
87add_executable(mouseareademo
88 mouseareademo.cpp
89 )
90target_link_libraries(mouseareademo
91 unity-2d-private
92 )
9386
=== removed file 'libunity-2d-private/tests/mouseareademo.cpp'
--- libunity-2d-private/tests/mouseareademo.cpp 2011-07-18 14:36:34 +0000
+++ libunity-2d-private/tests/mouseareademo.cpp 1970-01-01 00:00:00 +0000
@@ -1,48 +0,0 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2011 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published
11 * by the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22// Local
23#include <mousearea.h>
24#include <unity2dapplication.h>
25
26// Qt
27#include <QLabel>
28#include <QVBoxLayout>
29
30int main(int argc, char** argv)
31{
32 Unity2dApplication::earlySetup(argc, argv);
33 Unity2dApplication app(argc, argv);
34 QWidget window;
35 QLabel* enteredLabel = new QLabel("Entered");
36 QVBoxLayout* layout = new QVBoxLayout(&window);
37 layout->addWidget(enteredLabel);
38
39 MouseArea* area = new MouseArea(&window);
40 area->setGeometry(QRect(10, 10, 200, 100));
41 QObject::connect(area, SIGNAL(entered()), enteredLabel, SLOT(show()));
42 QObject::connect(area, SIGNAL(exited()), enteredLabel, SLOT(hide()));
43
44 enteredLabel->setVisible(area->containsMouse());
45
46 window.show();
47 return app.exec();
48}
490
=== modified file 'panel/applets/CMakeLists.txt'
--- panel/applets/CMakeLists.txt 2011-08-29 00:47:24 +0000
+++ panel/applets/CMakeLists.txt 2012-02-09 02:13:26 +0000
@@ -1,5 +1,4 @@
1add_subdirectory(separator)1add_subdirectory(separator)
2add_subdirectory(homebutton)
3add_subdirectory(appname)2add_subdirectory(appname)
4add_subdirectory(legacytray)3add_subdirectory(legacytray)
5add_subdirectory(indicator)4add_subdirectory(indicator)
65
=== removed directory 'panel/applets/homebutton'
=== removed file 'panel/applets/homebutton/CMakeLists.txt'
--- panel/applets/homebutton/CMakeLists.txt 2011-11-09 21:28:49 +0000
+++ panel/applets/homebutton/CMakeLists.txt 1970-01-01 00:00:00 +0000
@@ -1,33 +0,0 @@
1project(panelplugin-homebutton)
2
3# Sources
4set(homebutton_SRCS
5 homebuttonapplet.cpp
6 homebutton.cpp
7 plugin.cpp
8 )
9
10# Build
11include_directories(
12 ${CMAKE_CURRENT_SOURCE_DIR}
13 ${CMAKE_CURRENT_BINARY_DIR}
14 ${libunity-2d-private_SOURCE_DIR}/src
15 )
16
17qt4_automoc(${homebutton_SRCS})
18add_library(panelplugin-homebutton SHARED ${homebutton_SRCS})
19set_target_properties(panelplugin-homebutton PROPERTIES
20 LIBRARY_OUTPUT_DIRECTORY ".."
21 VERSION 0
22 SOVERSION 0.0
23 )
24
25target_link_libraries(panelplugin-homebutton
26 ${QT_QTGUI_LIBRARIES}
27 ${QT_QTCORE_LIBRARIES}
28 unity-2d-private
29 )
30
31install(TARGETS panelplugin-homebutton
32 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/unity-2d/plugins/panel
33 )
340
=== removed file 'panel/applets/homebutton/homebutton.cpp'
--- panel/applets/homebutton/homebutton.cpp 2011-08-22 10:47:51 +0000
+++ panel/applets/homebutton/homebutton.cpp 1970-01-01 00:00:00 +0000
@@ -1,63 +0,0 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2011 Canonical Ltd.
5 *
6 * Authors:
7 * - Alberto Mardegan <mardy@users.sourceforge.net>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22// Self
23#include "homebutton.h"
24
25// Local
26#include <debug_p.h>
27
28// Qt
29#include <QApplication>
30
31HomeButton::HomeButton(QWidget *parent)
32: QToolButton(parent)
33{
34 setAutoRaise(true);
35 setIconSize(QSize(24, 24));
36 QString themeIconName = QIcon::hasThemeIcon("start-here") ? "start-here" : "distributor-logo";
37 setIcon(QIcon::fromTheme(themeIconName));
38 setCheckable(true);
39
40 setStyleSheet(
41 "QToolButton { border: none; margin: 0; padding: 0; width: 61 }"
42 "QToolButton:checked, QToolButton:pressed {"
43 " padding-top: 1px;"
44 " padding-left: 1px;"
45 " padding-right: -1px;"
46 " padding-bottom: -1px;"
47 "}"
48 );
49}
50
51void HomeButton::mousePressEvent(QMouseEvent *event)
52{
53 if (lastClickTime.isValid() &&
54 lastClickTime.elapsed() < QApplication::doubleClickInterval()) {
55 /* ignore this click */
56 return;
57 }
58
59 QToolButton::mousePressEvent(event);
60 lastClickTime.restart();
61}
62
63#include "homebutton.moc"
640
=== removed file 'panel/applets/homebutton/homebutton.h'
--- panel/applets/homebutton/homebutton.h 2011-08-22 09:17:03 +0000
+++ panel/applets/homebutton/homebutton.h 1970-01-01 00:00:00 +0000
@@ -1,43 +0,0 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2011 Canonical Ltd.
5 *
6 * Authors:
7 * - Alberto Mardegan <mardy@users.sourceforge.net>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#ifndef HOMEBUTTON_H
23#define HOMEBUTTON_H
24
25// Qt
26#include <QTime>
27#include <QToolButton>
28
29class HomeButton : public QToolButton
30{
31Q_OBJECT
32public:
33 HomeButton(QWidget *parent = 0);
34
35protected:
36 void mousePressEvent(QMouseEvent*);
37
38private:
39 Q_DISABLE_COPY(HomeButton)
40 QTime lastClickTime;
41};
42
43#endif /* HOMEBUTTON_H */
440
=== removed file 'panel/applets/homebutton/homebuttonapplet.cpp'
--- panel/applets/homebutton/homebuttonapplet.cpp 2011-08-22 09:17:03 +0000
+++ panel/applets/homebutton/homebuttonapplet.cpp 1970-01-01 00:00:00 +0000
@@ -1,112 +0,0 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2010 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22// Self
23#include "homebuttonapplet.h"
24
25// Local
26#include <debug_p.h>
27
28// libunity-2d
29#include <launcherclient.h>
30
31// Qt
32#include <QHBoxLayout>
33#include <QDBusInterface>
34#include <QDBusServiceWatcher>
35#include <QDBusConnectionInterface>
36
37static const char* DBUS_SERVICE = "com.canonical.Unity2d.Dash";
38static const char* DBUS_PATH = "/Dash";
39static const char* DBUS_IFACE = "com.canonical.Unity2d.Dash";
40
41HomeButtonApplet::HomeButtonApplet(Unity2dPanel* panel)
42: Unity2d::PanelApplet(panel)
43, m_button(new HomeButton)
44, m_dashInterface(NULL)
45, m_launcherClient(new LauncherClient(this))
46{
47 connect(m_button, SIGNAL(clicked()), SLOT(toggleDash()));
48
49 QHBoxLayout* layout = new QHBoxLayout(this);
50 layout->setMargin(0);
51 layout->addWidget(m_button);
52
53 /* Check if the dash is already up and running by asking the bus instead of
54 trying to create an instance of the interface. Creating an instance
55 will cause DBUS to activate the dash and we don't want this to happen, especially
56 during startup where the dash is started with a delay. */
57 QDBusConnectionInterface* sessionBusIFace = QDBusConnection::sessionBus().interface();
58 QDBusReply<bool> reply = sessionBusIFace->isServiceRegistered(DBUS_SERVICE);
59 if (reply.isValid() && reply.value() == true) {
60 connectToDash();
61 } else {
62 /* If the dash is not running, setup a notification so that we can
63 connect to it later when it comes up */
64 QDBusServiceWatcher* serviceWatcher = new QDBusServiceWatcher(DBUS_SERVICE, QDBusConnection::sessionBus(),
65 QDBusServiceWatcher::WatchForRegistration, this);
66 connect(serviceWatcher, SIGNAL(serviceRegistered(QString)), SLOT(connectToDash()));
67 }
68}
69
70void HomeButtonApplet::connectToDash()
71{
72 if (m_dashInterface != NULL) {
73 return;
74 }
75
76 m_dashInterface = new QDBusInterface(DBUS_SERVICE, DBUS_PATH, DBUS_IFACE,
77 QDBusConnection::sessionBus(), this);
78 m_button->connect(m_dashInterface, SIGNAL(activeChanged(bool)), SLOT(setChecked(bool)));
79
80 /* Immediately update the home button with the current state of the dash */
81 m_button->setChecked(m_dashInterface->property("active").toBool());
82}
83
84void HomeButtonApplet::toggleDash()
85{
86 if (m_dashInterface == NULL || !m_dashInterface->isValid()) {
87 connectToDash();
88 }
89
90 bool dashActive = m_dashInterface->property("active").toBool();
91
92 if (dashActive) {
93 m_dashInterface->setProperty("active", false);
94 } else {
95 /* Call com.canonical.Unity2d.Dash.activateHome (will set com.canonical.Unity2d.Dash.active to true */
96 m_dashInterface->call(QDBus::Block, "activateHome");
97 }
98}
99
100void HomeButtonApplet::enterEvent(QEvent* event)
101{
102 QWidget::enterEvent(event);
103 m_launcherClient->beginForceVisible();
104}
105
106void HomeButtonApplet::leaveEvent(QEvent* event)
107{
108 QWidget::leaveEvent(event);
109 m_launcherClient->endForceVisible();
110}
111
112#include "homebuttonapplet.moc"
1130
=== removed file 'panel/applets/homebutton/homebuttonapplet.h'
--- panel/applets/homebutton/homebuttonapplet.h 2011-08-22 09:17:03 +0000
+++ panel/applets/homebutton/homebuttonapplet.h 1970-01-01 00:00:00 +0000
@@ -1,55 +0,0 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2010 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#ifndef HOMEBUTTONAPPLET_H
23#define HOMEBUTTONAPPLET_H
24
25// Local
26#include "homebutton.h"
27
28// Unity-2d
29#include <panelapplet.h>
30
31class QDBusInterface;
32class LauncherClient;
33
34class HomeButtonApplet : public Unity2d::PanelApplet
35{
36Q_OBJECT
37public:
38 HomeButtonApplet(Unity2dPanel* panel);
39
40protected:
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches