Merge ~3v1n0/ubuntu/+source/gnome-shell:ubuntu/master into ~ubuntu-desktop/ubuntu/+source/gnome-shell:ubuntu/master

Proposed by Marco Trevisan (Treviño) on 2019-03-27
Status: Merged
Approved by: Didier Roche on 2019-03-27
Approved revision: 721e4f41de1e11f42d853238694fabf459958c3b
Merged at revision: 721e4f41de1e11f42d853238694fabf459958c3b
Proposed branch: ~3v1n0/ubuntu/+source/gnome-shell:ubuntu/master
Merge into: ~ubuntu-desktop/ubuntu/+source/gnome-shell:ubuntu/master
Diff against target: 249 lines (+225/-0)
3 files modified
debian/changelog (+8/-0)
debian/patches/magnifier-Show-cursor-when-magnifier-is-enabled-and-scale.patch (+216/-0)
debian/patches/series (+1/-0)
Reviewer Review Type Date Requested Status
Didier Roche 2019-03-27 Approve on 2019-03-27
Review via email: mp+365180@code.launchpad.net

Commit message

magnifier: Show cursor when magnifier is enabled and scale it properly

To post a comment you must log in.
Didier Roche (didrocks) wrote :

I didn't spot anything bad. Let's merge it to master, thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index 027f211..aa59db3 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,11 @@
6+gnome-shell (3.32.0-1ubuntu2) UNRELEASED; urgency=medium
7+
8+ * d/p/magnifier-Show-cursor-when-magnifier-is-enabled-and-scale.patch:
9+ - magnifier: Show cursor when magnifier is enabled and scale it to
10+ match monitor scaling (LP: #1818790)
11+
12+ -- Marco Trevisan (Treviño) <marco@ubuntu.com> Wed, 27 Mar 2019 16:51:27 +0100
13+
14 gnome-shell (3.32.0-1ubuntu1) disco; urgency=medium
15
16 * Merge with debian, remaining changes:
17diff --git a/debian/patches/magnifier-Show-cursor-when-magnifier-is-enabled-and-scale.patch b/debian/patches/magnifier-Show-cursor-when-magnifier-is-enabled-and-scale.patch
18new file mode 100644
19index 0000000..0bb6c71
20--- /dev/null
21+++ b/debian/patches/magnifier-Show-cursor-when-magnifier-is-enabled-and-scale.patch
22@@ -0,0 +1,216 @@
23+From: =?utf-8?b?Ik1hcmNvIFRyZXZpc2FuIChUcmV2acOxbyki?= <mail@3v1n0.net>
24+Date: Wed, 27 Mar 2019 16:14:39 +0100
25+Subject: magnifier: Show cursor when magnifier is enabled and scale it
26+ properly
27+
28+Show the cursor when using the magnifier and apply the proper monitor scaling
29+to it.
30+
31+GNOME-Bug: https://gitlab.gnome.org/GNOME/gnome-shell/issues/1020
32+Ubuntu-Bug: https://bugs.launchpad.net/bugs/1818790
33+Origin: https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/454
34+Applied-Upstream: no
35+Forwarded: yes
36+---
37+ js/ui/layout.js | 24 ++++++++++++++---
38+ js/ui/magnifier.js | 76 +++++++++++++++++++++++++++++++++++++++++++++++-------
39+ 2 files changed, 87 insertions(+), 13 deletions(-)
40+
41+diff --git a/js/ui/layout.js b/js/ui/layout.js
42+index 27a3099..376a585 100644
43+--- a/js/ui/layout.js
44++++ b/js/ui/layout.js
45+@@ -930,22 +930,38 @@ var LayoutManager = GObject.registerClass({
46+ return ws.get_work_area_for_monitor(monitorIndex);
47+ }
48+
49++ _findIndexForRect(x, y, width, height) {
50++ let rect = new Meta.Rectangle({
51++ x: Math.floor(x),
52++ y: Math.floor(y),
53++ width: Math.ceil(x + width) - Math.floor(x),
54++ height: Math.ceil(y + height) - Math.floor(y)
55++ });
56++ return global.display.get_monitor_index_for_rect(rect);
57++ }
58++
59+ // This call guarantees that we return some monitor to simplify usage of it
60+ // In practice all tracked actors should be visible on some monitor anyway
61+ findIndexForActor(actor) {
62+ let [x, y] = actor.get_transformed_position();
63+ let [w, h] = actor.get_transformed_size();
64+- let rect = new Meta.Rectangle({ x: x, y: y, width: w, height: h });
65+- return global.display.get_monitor_index_for_rect(rect);
66++ return this._findIndexForRect(x, y, w, h);
67+ }
68+
69+- findMonitorForActor(actor) {
70+- let index = this.findIndexForActor(actor);
71++ _findMonitorForIndex(index) {
72+ if (index >= 0 && index < this.monitors.length)
73+ return this.monitors[index];
74+ return null;
75+ }
76+
77++ findMonitorForActor(actor) {
78++ return this._findMonitorForIndex(this.findIndexForActor(actor));
79++ }
80++
81++ findMonitorForPoint(x, y) {
82++ return this._findMonitorForIndex(this._findIndexForRect(x, y, 1, 1));
83++ }
84++
85+ _queueUpdateRegions() {
86+ if (this._startingUp)
87+ return;
88+diff --git a/js/ui/magnifier.js b/js/ui/magnifier.js
89+index 546ab1d..c77e47f 100644
90+--- a/js/ui/magnifier.js
91++++ b/js/ui/magnifier.js
92+@@ -51,31 +51,58 @@ var MouseSpriteContent = GObject.registerClass({
93+ }, class MouseSpriteContent extends GObject.Object {
94+ _init() {
95+ super._init();
96++ this._scale = 1.0;
97++ this._monitorScale = 1.0;
98+ this._texture = null;
99+ }
100+
101+ vfunc_get_preferred_size() {
102+ if (!this._texture)
103+- return [0, 0];
104++ return [false, 0, 0];
105+
106+- return [this._texture.get_width(), this._texture.get_height()];
107++ let width = this._texture.get_width() / this._scale;
108++ let height = this._texture.get_height() / this._scale;
109++
110++ return [true, width, height];
111+ }
112+
113+ vfunc_paint_content(actor, node) {
114+ if (!this._texture)
115+ return;
116+
117+- let color = new Clutter.Color();
118++ let color = Clutter.Color.get_static(Clutter.StaticColor.WHITE);
119++ let [min_filter, mag_filter] = actor.get_content_scaling_filters();
120+ let textureNode = new Clutter.TextureNode(this._texture,
121+- color,
122+- Clutter.ScalingFilter.NEAREST,
123+- Clutter.ScalingFilter.NEAREST);
124++ color, min_filter, mag_filter);
125+ textureNode.set_name('MouseSpriteContent');
126+ node.add_child(textureNode);
127+
128+ textureNode.add_rectangle(actor.get_content_box());
129+ }
130+
131++ _textureScale() {
132++ if (!this._texture)
133++ return 1;
134++
135++ /* This is a workaround to guess the sprite scale; while it works file
136++ * in normal scenarios, it's not guaranteed to work in all the cases,
137++ * and so we should actually add an API to mutter that will allow us
138++ * to know the real spirte texture scaling in order to adapt it to the
139++ * wanted one. */
140++ let avgSize = (this._texture.get_width() + this._texture.get_height()) / 2;
141++ return Math.max (1, Math.floor (avgSize / Meta.prefs_get_cursor_size() + .1));
142++ }
143++
144++ _recomputeScale() {
145++ let scale = this._textureScale() / this._monitorScale;
146++
147++ if (this._scale != scale) {
148++ this._scale = scale;
149++ return true;
150++ }
151++ return false;
152++ }
153++
154+ get texture() {
155+ return this._texture;
156+ }
157+@@ -84,8 +111,26 @@ var MouseSpriteContent = GObject.registerClass({
158+ if (this._texture == coglTexture)
159+ return;
160+
161++ let oldTexture = this._texture;
162+ this._texture = coglTexture;
163+- this.invalidate();
164++
165++ if (!oldTexture || !coglTexture ||
166++ oldTexture.get_width() != coglTexture.get_width() ||
167++ oldTexture.get_height() != coglTexture.get_height()) {
168++ this._recomputeScale();
169++ this.invalidate_size();
170++ } else
171++ this.invalidate();
172++ }
173++
174++ get scale() {
175++ return this._scale;
176++ }
177++
178++ set monitorScale(monitorScale) {
179++ this._monitorScale = monitorScale;
180++ if (this._recomputeScale())
181++ this.invalidate_size();
182+ }
183+ });
184+
185+@@ -100,7 +145,6 @@ var Magnifier = class Magnifier {
186+
187+ this._mouseSprite = new Clutter.Actor({ request_mode: Clutter.RequestMode.CONTENT_SIZE });
188+ this._mouseSprite.content = new MouseSpriteContent();
189+- this._updateSpriteTexture();
190+
191+ this._cursorRoot = new Clutter.Actor();
192+ this._cursorRoot.add_actor(this._mouseSprite);
193+@@ -116,13 +160,19 @@ var Magnifier = class Magnifier {
194+ let showAtLaunch = this._settingsInit(aZoomRegion);
195+ aZoomRegion.scrollContentsTo(this.xMouse, this.yMouse);
196+
197+- cursorTracker.connect('cursor-changed', this._updateMouseSprite.bind(this));
198++ this._updateContentScale();
199+
200+ // Export to dbus.
201+ magDBusService = new MagnifierDBus.ShellMagnifier();
202+ this.setActive(showAtLaunch);
203+ }
204+
205++ _updateContentScale() {
206++ let monitor = Main.layoutManager.findMonitorForPoint(this.xMouse,
207++ this.yMouse);
208++ this._mouseSprite.content.monitorScale = monitor.geometry_scale;
209++ }
210++
211+ /**
212+ * showSystemCursor:
213+ * Show the system mouse pointer.
214+@@ -153,9 +203,15 @@ var Magnifier = class Magnifier {
215+
216+ if (isActive != activate) {
217+ if (activate) {
218++ this._updateMouseSprite();
219++ this._cursorSpriteChangedId =
220++ this._cursorTracker.connect('cursor-changed',
221++ this._updateMouseSprite.bind(this));
222+ Meta.disable_unredirect_for_display(global.display);
223+ this.startTrackingMouse();
224+ } else {
225++ this._cursorTracker.disconnect(this._cursorSpriteChangedId);
226++ this._mouseSprite.content.texture = null;
227+ Meta.enable_unredirect_for_display(global.display);
228+ this.stopTrackingMouse();
229+ }
230+@@ -226,6 +282,8 @@ var Magnifier = class Magnifier {
231+ this.xMouse = xMouse;
232+ this.yMouse = yMouse;
233+
234++ this._updateContentScale();
235++
236+ let sysMouseOverAny = false;
237+ this._zoomRegions.forEach((zoomRegion, index, array) => {
238+ if (zoomRegion.scrollToMousePos())
239diff --git a/debian/patches/series b/debian/patches/series
240index db59749..4b657f0 100644
241--- a/debian/patches/series
242+++ b/debian/patches/series
243@@ -21,5 +21,6 @@ main-add-backtrace-crashes-all-and-backtrace-all.patch
244 sessionMode-add-support-for-debugFlags-parameter.patch
245 st-scroll-view-Handle-the-case-where-scrollbars-are-NULL.patch
246 st-scroll-view-Remove-scrollbars-references-on-dispose.patch
247+magnifier-Show-cursor-when-magnifier-is-enabled-and-scale.patch
248 ubuntu/search-call-XUbuntuCancel-method-on-providers-when-no-dat.patch
249 ubuntu/resolve_alternate_theme_path.patch

Subscribers

People subscribed via source and target branches