Merge lp:~albertomilone/unity/unity-dconf-for-gestures into lp:unity

Proposed by Alberto Milone on 2016-06-06
Status: Merged
Approved by: Marco Trevisan (Treviño) on 2016-06-06
Approved revision: 4128
Merged at revision: 4129
Proposed branch: lp:~albertomilone/unity/unity-dconf-for-gestures
Merge into: lp:unity
Diff against target: 176 lines (+55/-4)
5 files modified
com.canonical.Unity.gschema.xml (+19/-0)
plugins/unityshell/src/unityshell.cpp (+11/-4)
plugins/unityshell/src/unityshell.h (+1/-0)
unity-shared/UnitySettings.cpp (+20/-0)
unity-shared/UnitySettings.h (+4/-0)
To merge this branch: bzr merge lp:~albertomilone/unity/unity-dconf-for-gestures
Reviewer Review Type Date Requested Status
Marco Trevisan (Treviño) 2016-06-06 Approve on 2016-06-06
Review via email: mp+296559@code.launchpad.net

Commit message

UnitySettings: Add dconf keys for disabling multitouch gestures

Description of the change

While not an actual solution to LP: #1264795, it provide a rather easy way for users to disable gestures in dconf (as per LP: #1589520).

To post a comment you must log in.
4128. By Alberto Milone on 2016-06-06

Drop the Activate()s in InitGesturesSupport() and add a newline.

Marco Trevisan (Treviño) (3v1n0) wrote :

Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'com.canonical.Unity.gschema.xml'
2--- com.canonical.Unity.gschema.xml 2016-05-30 18:05:51 +0000
3+++ com.canonical.Unity.gschema.xml 2016-06-06 14:22:43 +0000
4@@ -220,4 +220,23 @@
5 when clicking over unfocused menu entries</description>
6 </key>
7 </schema>
8+ <schema path="/com/canonical/unity/gestures/" id="com.canonical.Unity.Gestures" gettext-domain="unity">
9+ <key type="b" name="launcher-drag">
10+ <default>true</default>
11+ <summary>Multi-touch gesture to reveal the launcher.</summary>
12+ <description>When this is enabled, a 4 finger swipe from left to right will reveal launcher,
13+ provided that the launcher is set to auto-hide.</description>
14+ </key>
15+ <key type="b" name="dash-tap">
16+ <default>true</default>
17+ <summary>Multi-touch gesture to open the dash.</summary>
18+ <description>When this is enabled, a 4 finger tap will open the dash.</description>
19+ </key>
20+ <key type="b" name="windows-drag-pinch">
21+ <default>true</default>
22+ <summary>Multi-touch gestures to manage the windows.</summary>
23+ <description>When this is enabled, 3 finger gestures such as drag, and pinch, will
24+ help manage the windows.</description>
25+ </key>
26+ </schema>
27 </schemalist>
28
29=== modified file 'plugins/unityshell/src/unityshell.cpp'
30--- plugins/unityshell/src/unityshell.cpp 2016-05-31 11:54:01 +0000
31+++ plugins/unityshell/src/unityshell.cpp 2016-06-06 14:22:43 +0000
32@@ -446,6 +446,7 @@
33 auto init_plugins_cb = sigc::mem_fun(this, &UnityScreen::InitPluginActions);
34 sources_.Add(std::make_shared<glib::Idle>(init_plugins_cb, glib::Source::Priority::DEFAULT));
35
36+ Settings::Instance().gestures_changed.connect(sigc::mem_fun(this, &UnityScreen::UpdateGesturesSupport));
37 InitGesturesSupport();
38
39 LoadPanelShadowTexture();
40@@ -4189,22 +4190,26 @@
41 return lockscreen_controller_;
42 }
43
44+void UnityScreen::UpdateGesturesSupport()
45+{
46+ Settings::Instance().gestures_launcher_drag() ? gestures_sub_launcher_->Activate() : gestures_sub_launcher_->Deactivate();
47+ Settings::Instance().gestures_dash_tap() ? gestures_sub_dash_->Activate() : gestures_sub_dash_->Deactivate();
48+ Settings::Instance().gestures_windows_drag_pinch() ? gestures_sub_windows_->Activate() : gestures_sub_windows_->Deactivate();
49+}
50+
51 void UnityScreen::InitGesturesSupport()
52 {
53 std::unique_ptr<nux::GestureBroker> gesture_broker(new UnityGestureBroker);
54 wt->GetWindowCompositor().SetGestureBroker(std::move(gesture_broker));
55-
56 gestures_sub_launcher_.reset(new nux::GesturesSubscription);
57 gestures_sub_launcher_->SetGestureClasses(nux::DRAG_GESTURE);
58 gestures_sub_launcher_->SetNumTouches(4);
59 gestures_sub_launcher_->SetWindowId(GDK_ROOT_WINDOW());
60- gestures_sub_launcher_->Activate();
61
62 gestures_sub_dash_.reset(new nux::GesturesSubscription);
63 gestures_sub_dash_->SetGestureClasses(nux::TAP_GESTURE);
64 gestures_sub_dash_->SetNumTouches(4);
65 gestures_sub_dash_->SetWindowId(GDK_ROOT_WINDOW());
66- gestures_sub_dash_->Activate();
67
68 gestures_sub_windows_.reset(new nux::GesturesSubscription);
69 gestures_sub_windows_->SetGestureClasses(nux::TOUCH_GESTURE
70@@ -4212,7 +4217,9 @@
71 | nux::PINCH_GESTURE);
72 gestures_sub_windows_->SetNumTouches(3);
73 gestures_sub_windows_->SetWindowId(GDK_ROOT_WINDOW());
74- gestures_sub_windows_->Activate();
75+
76+ // Apply the user's settings
77+ UpdateGesturesSupport();
78 }
79
80 CompAction::Vector& UnityScreen::getActions()
81
82=== modified file 'plugins/unityshell/src/unityshell.h'
83--- plugins/unityshell/src/unityshell.h 2016-05-31 11:54:01 +0000
84+++ plugins/unityshell/src/unityshell.h 2016-06-06 14:22:43 +0000
85@@ -282,6 +282,7 @@
86 void OnDecorationStyleChanged();
87
88 void InitGesturesSupport();
89+ void UpdateGesturesSupport();
90
91 void DrawPanelUnderDash();
92
93
94=== modified file 'unity-shared/UnitySettings.cpp'
95--- unity-shared/UnitySettings.cpp 2016-03-18 01:47:08 +0000
96+++ unity-shared/UnitySettings.cpp 2016-06-06 14:22:43 +0000
97@@ -66,6 +66,11 @@
98 const std::string REMOTE_CONTENT_SETTINGS = "com.canonical.Unity.Lenses";
99 const std::string REMOTE_CONTENT_KEY = "remote-content-search";
100
101+const std::string GESTURES_SETTINGS = "com.canonical.Unity.Gestures";
102+const std::string LAUNCHER_DRAG = "launcher-drag";
103+const std::string DASH_TAP = "dash-tap";
104+const std::string WINDOWS_DRAG_PINCH = "windows-drag-pinch";
105+
106 const int DEFAULT_LAUNCHER_SIZE = 64;
107 const int MINIMUM_DESKTOP_HEIGHT = 800;
108 const int GNOME_SETTINGS_CHANGED_WAIT_SECONDS = 1;
109@@ -83,6 +88,7 @@
110 , usettings_(g_settings_new(SETTINGS_NAME.c_str()))
111 , launcher_settings_(g_settings_new(LAUNCHER_SETTINGS.c_str()))
112 , lim_settings_(g_settings_new(LIM_SETTINGS.c_str()))
113+ , gestures_settings_(g_settings_new(GESTURES_SETTINGS.c_str()))
114 , ui_settings_(g_settings_new(UI_SETTINGS.c_str()))
115 , ubuntu_ui_settings_(g_settings_new(UBUNTU_UI_SETTINGS.c_str()))
116 , gnome_ui_settings_(g_settings_new(GNOME_UI_SETTINGS.c_str()))
117@@ -160,6 +166,10 @@
118 UpdateLimSetting();
119 });
120
121+ signals_.Add<void, GSettings*, const gchar*>(gestures_settings_, "changed", [this] (GSettings*, const gchar*) {
122+ UpdateGesturesSetting();
123+ });
124+
125 signals_.Add<void, GSettings*, const gchar*>(remote_content_settings_, "changed::" + REMOTE_CONTENT_KEY, [this] (GSettings*, const gchar* t) {
126 UpdateRemoteContentSearch();
127 });
128@@ -168,6 +178,7 @@
129
130 // The order is important here, DPI is the last thing to be updated
131 UpdateLimSetting();
132+ UpdateGesturesSetting();
133 UpdateTextScaleFactor();
134 UpdateCursorScaleFactor();
135 UpdateFontSize();
136@@ -222,6 +233,14 @@
137 parent_->lim_unfocused_popup = g_settings_get_boolean(lim_settings_, UNFOCUSED_MENU_POPUP.c_str());
138 }
139
140+ void UpdateGesturesSetting()
141+ {
142+ parent_->gestures_launcher_drag = g_settings_get_boolean(gestures_settings_, LAUNCHER_DRAG.c_str());
143+ parent_->gestures_dash_tap = g_settings_get_boolean(gestures_settings_, DASH_TAP.c_str());
144+ parent_->gestures_windows_drag_pinch = g_settings_get_boolean(gestures_settings_, WINDOWS_DRAG_PINCH.c_str());
145+ parent_->gestures_changed.emit();
146+ }
147+
148 FormFactor GetFormFactor() const
149 {
150 return cached_form_factor_;
151@@ -384,6 +403,7 @@
152 glib::Object<GSettings> usettings_;
153 glib::Object<GSettings> launcher_settings_;
154 glib::Object<GSettings> lim_settings_;
155+ glib::Object<GSettings> gestures_settings_;
156 glib::Object<GSettings> ui_settings_;
157 glib::Object<GSettings> ubuntu_ui_settings_;
158 glib::Object<GSettings> gnome_ui_settings_;
159
160=== modified file 'unity-shared/UnitySettings.h'
161--- unity-shared/UnitySettings.h 2016-03-18 01:47:08 +0000
162+++ unity-shared/UnitySettings.h 2016-06-06 14:22:43 +0000
163@@ -71,9 +71,13 @@
164 nux::Property<double> font_scaling;
165 nux::ROProperty<bool> remote_content;
166 nux::RWProperty<LauncherPosition> launcher_position;
167+ nux::Property<bool> gestures_launcher_drag;
168+ nux::Property<bool> gestures_dash_tap;
169+ nux::Property<bool> gestures_windows_drag_pinch;
170
171 sigc::signal<void> dpi_changed;
172 sigc::signal<void> low_gfx_changed;
173+ sigc::signal<void> gestures_changed;
174
175 private:
176 class Impl;