Marco Trevisan (Treviño) has proposed merging ~3v1n0/ubuntu/+source/gnome-shell:ubuntu/master into ~ubuntu-desktop/ubuntu/+source/gnome-shell:ubuntu/master.
Commit message: magnifier: Show cursor when magnifier is enabled and scale it properly Requested reviews: Ubuntu Desktop (ubuntu-desktop) Related bugs: Bug #1818790 in gnome-shell (Ubuntu): "[regression] Desktop zoom is missing the mouse pointer" https://bugs.launchpad.net/ubuntu/+source/gnome-shell/+bug/1818790 For more details, see: https://code.launchpad.net/~3v1n0/ubuntu/+source/gnome-shell/+git/gnome-shell/+merge/365180 -- Your team Ubuntu Desktop is requested to review the proposed merge of ~3v1n0/ubuntu/+source/gnome-shell:ubuntu/master into ~ubuntu-desktop/ubuntu/+source/gnome-shell:ubuntu/master.
diff --git a/debian/changelog b/debian/changelog index 027f211..aa59db3 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +gnome-shell (3.32.0-1ubuntu2) UNRELEASED; urgency=medium + + * d/p/magnifier-Show-cursor-when-magnifier-is-enabled-and-scale.patch: + - magnifier: Show cursor when magnifier is enabled and scale it to + match monitor scaling (LP: #1818790) + + -- Marco Trevisan (Treviño) <ma...@ubuntu.com> Wed, 27 Mar 2019 16:51:27 +0100 + gnome-shell (3.32.0-1ubuntu1) disco; urgency=medium * Merge with debian, remaining changes: diff --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 new file mode 100644 index 0000000..0bb6c71 --- /dev/null +++ b/debian/patches/magnifier-Show-cursor-when-magnifier-is-enabled-and-scale.patch @@ -0,0 +1,216 @@ +From: =?utf-8?b?Ik1hcmNvIFRyZXZpc2FuIChUcmV2acOxbyki?= <m...@3v1n0.net> +Date: Wed, 27 Mar 2019 16:14:39 +0100 +Subject: magnifier: Show cursor when magnifier is enabled and scale it + properly + +Show the cursor when using the magnifier and apply the proper monitor scaling +to it. + +GNOME-Bug: https://gitlab.gnome.org/GNOME/gnome-shell/issues/1020 +Ubuntu-Bug: https://bugs.launchpad.net/bugs/1818790 +Origin: https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/454 +Applied-Upstream: no +Forwarded: yes +--- + js/ui/layout.js | 24 ++++++++++++++--- + js/ui/magnifier.js | 76 +++++++++++++++++++++++++++++++++++++++++++++++------- + 2 files changed, 87 insertions(+), 13 deletions(-) + +diff --git a/js/ui/layout.js b/js/ui/layout.js +index 27a3099..376a585 100644 +--- a/js/ui/layout.js ++++ b/js/ui/layout.js +@@ -930,22 +930,38 @@ var LayoutManager = GObject.registerClass({ + return ws.get_work_area_for_monitor(monitorIndex); + } + ++ _findIndexForRect(x, y, width, height) { ++ let rect = new Meta.Rectangle({ ++ x: Math.floor(x), ++ y: Math.floor(y), ++ width: Math.ceil(x + width) - Math.floor(x), ++ height: Math.ceil(y + height) - Math.floor(y) ++ }); ++ return global.display.get_monitor_index_for_rect(rect); ++ } ++ + // This call guarantees that we return some monitor to simplify usage of it + // In practice all tracked actors should be visible on some monitor anyway + findIndexForActor(actor) { + let [x, y] = actor.get_transformed_position(); + let [w, h] = actor.get_transformed_size(); +- let rect = new Meta.Rectangle({ x: x, y: y, width: w, height: h }); +- return global.display.get_monitor_index_for_rect(rect); ++ return this._findIndexForRect(x, y, w, h); + } + +- findMonitorForActor(actor) { +- let index = this.findIndexForActor(actor); ++ _findMonitorForIndex(index) { + if (index >= 0 && index < this.monitors.length) + return this.monitors[index]; + return null; + } + ++ findMonitorForActor(actor) { ++ return this._findMonitorForIndex(this.findIndexForActor(actor)); ++ } ++ ++ findMonitorForPoint(x, y) { ++ return this._findMonitorForIndex(this._findIndexForRect(x, y, 1, 1)); ++ } ++ + _queueUpdateRegions() { + if (this._startingUp) + return; +diff --git a/js/ui/magnifier.js b/js/ui/magnifier.js +index 546ab1d..c77e47f 100644 +--- a/js/ui/magnifier.js ++++ b/js/ui/magnifier.js +@@ -51,31 +51,58 @@ var MouseSpriteContent = GObject.registerClass({ + }, class MouseSpriteContent extends GObject.Object { + _init() { + super._init(); ++ this._scale = 1.0; ++ this._monitorScale = 1.0; + this._texture = null; + } + + vfunc_get_preferred_size() { + if (!this._texture) +- return [0, 0]; ++ return [false, 0, 0]; + +- return [this._texture.get_width(), this._texture.get_height()]; ++ let width = this._texture.get_width() / this._scale; ++ let height = this._texture.get_height() / this._scale; ++ ++ return [true, width, height]; + } + + vfunc_paint_content(actor, node) { + if (!this._texture) + return; + +- let color = new Clutter.Color(); ++ let color = Clutter.Color.get_static(Clutter.StaticColor.WHITE); ++ let [min_filter, mag_filter] = actor.get_content_scaling_filters(); + let textureNode = new Clutter.TextureNode(this._texture, +- color, +- Clutter.ScalingFilter.NEAREST, +- Clutter.ScalingFilter.NEAREST); ++ color, min_filter, mag_filter); + textureNode.set_name('MouseSpriteContent'); + node.add_child(textureNode); + + textureNode.add_rectangle(actor.get_content_box()); + } + ++ _textureScale() { ++ if (!this._texture) ++ return 1; ++ ++ /* This is a workaround to guess the sprite scale; while it works file ++ * in normal scenarios, it's not guaranteed to work in all the cases, ++ * and so we should actually add an API to mutter that will allow us ++ * to know the real spirte texture scaling in order to adapt it to the ++ * wanted one. */ ++ let avgSize = (this._texture.get_width() + this._texture.get_height()) / 2; ++ return Math.max (1, Math.floor (avgSize / Meta.prefs_get_cursor_size() + .1)); ++ } ++ ++ _recomputeScale() { ++ let scale = this._textureScale() / this._monitorScale; ++ ++ if (this._scale != scale) { ++ this._scale = scale; ++ return true; ++ } ++ return false; ++ } ++ + get texture() { + return this._texture; + } +@@ -84,8 +111,26 @@ var MouseSpriteContent = GObject.registerClass({ + if (this._texture == coglTexture) + return; + ++ let oldTexture = this._texture; + this._texture = coglTexture; +- this.invalidate(); ++ ++ if (!oldTexture || !coglTexture || ++ oldTexture.get_width() != coglTexture.get_width() || ++ oldTexture.get_height() != coglTexture.get_height()) { ++ this._recomputeScale(); ++ this.invalidate_size(); ++ } else ++ this.invalidate(); ++ } ++ ++ get scale() { ++ return this._scale; ++ } ++ ++ set monitorScale(monitorScale) { ++ this._monitorScale = monitorScale; ++ if (this._recomputeScale()) ++ this.invalidate_size(); + } + }); + +@@ -100,7 +145,6 @@ var Magnifier = class Magnifier { + + this._mouseSprite = new Clutter.Actor({ request_mode: Clutter.RequestMode.CONTENT_SIZE }); + this._mouseSprite.content = new MouseSpriteContent(); +- this._updateSpriteTexture(); + + this._cursorRoot = new Clutter.Actor(); + this._cursorRoot.add_actor(this._mouseSprite); +@@ -116,13 +160,19 @@ var Magnifier = class Magnifier { + let showAtLaunch = this._settingsInit(aZoomRegion); + aZoomRegion.scrollContentsTo(this.xMouse, this.yMouse); + +- cursorTracker.connect('cursor-changed', this._updateMouseSprite.bind(this)); ++ this._updateContentScale(); + + // Export to dbus. + magDBusService = new MagnifierDBus.ShellMagnifier(); + this.setActive(showAtLaunch); + } + ++ _updateContentScale() { ++ let monitor = Main.layoutManager.findMonitorForPoint(this.xMouse, ++ this.yMouse); ++ this._mouseSprite.content.monitorScale = monitor.geometry_scale; ++ } ++ + /** + * showSystemCursor: + * Show the system mouse pointer. +@@ -153,9 +203,15 @@ var Magnifier = class Magnifier { + + if (isActive != activate) { + if (activate) { ++ this._updateMouseSprite(); ++ this._cursorSpriteChangedId = ++ this._cursorTracker.connect('cursor-changed', ++ this._updateMouseSprite.bind(this)); + Meta.disable_unredirect_for_display(global.display); + this.startTrackingMouse(); + } else { ++ this._cursorTracker.disconnect(this._cursorSpriteChangedId); ++ this._mouseSprite.content.texture = null; + Meta.enable_unredirect_for_display(global.display); + this.stopTrackingMouse(); + } +@@ -226,6 +282,8 @@ var Magnifier = class Magnifier { + this.xMouse = xMouse; + this.yMouse = yMouse; + ++ this._updateContentScale(); ++ + let sysMouseOverAny = false; + this._zoomRegions.forEach((zoomRegion, index, array) => { + if (zoomRegion.scrollToMousePos()) diff --git a/debian/patches/series b/debian/patches/series index db59749..4b657f0 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -21,5 +21,6 @@ main-add-backtrace-crashes-all-and-backtrace-all.patch sessionMode-add-support-for-debugFlags-parameter.patch st-scroll-view-Handle-the-case-where-scrollbars-are-NULL.patch st-scroll-view-Remove-scrollbars-references-on-dispose.patch +magnifier-Show-cursor-when-magnifier-is-enabled-and-scale.patch ubuntu/search-call-XUbuntuCancel-method-on-providers-when-no-dat.patch ubuntu/resolve_alternate_theme_path.patch
-- ubuntu-desktop mailing list ubuntu-desktop@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/ubuntu-desktop