[gnome-shell] Improve the algorithm for proportional mouse tracking
- From: Owen Taylor <otaylor src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] Improve the algorithm for proportional mouse tracking
- Date: Fri, 3 Dec 2010 19:26:43 +0000 (UTC)
commit 96fb6d8f164621a933354d64ccd661a660acc163
Author: Owen W. Taylor <otaylor fishsoup net>
Date: Sun Nov 14 17:21:43 2010 -0500
Improve the algorithm for proportional mouse tracking
Change the proportional algorithm so stop moving the zoom region
when cursor is in a "padding region" at the edge of the screen.
(The padding region is a 10th of the screen at 2x zoom, and smaller
for higher zooms.)
Based on earlier versions from Jon McCann and Florian Muellner.
https://bugzilla.gnome.org/show_bug.cgi?id=629950
js/ui/magnifier.js | 13 +++++++++----
1 files changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/js/ui/magnifier.js b/js/ui/magnifier.js
index 86a3f29..edc3d00 100644
--- a/js/ui/magnifier.js
+++ b/js/ui/magnifier.js
@@ -1093,10 +1093,15 @@ ZoomRegion.prototype = {
let [xRoi, yRoi, widthRoi, heightRoi] = this.getROI();
let halfScreenWidth = global.screen_width / 2;
let halfScreenHeight = global.screen_height / 2;
- let xProportion = (halfScreenWidth - xMouse) / halfScreenWidth;
- let yProportion = (halfScreenHeight - yMouse) / halfScreenHeight;
- let xPos = xMouse + xProportion * widthRoi / 2;
- let yPos = yMouse + yProportion * heightRoi / 2;
+ // We want to pad with a constant distance after zooming, so divide
+ // by the magnification factor.
+ let unscaledPadding = Math.min(this._viewPortWidth, this._viewPortHeight) / 5;
+ let xPadding = unscaledPadding / this._xMagFactor;
+ let yPadding = unscaledPadding / this._yMagFactor;
+ let xProportion = (xMouse - halfScreenWidth) / halfScreenWidth; // -1 ... 1
+ let yProportion = (yMouse - halfScreenHeight) / halfScreenHeight; // -1 ... 1
+ let xPos = xMouse - xProportion * (widthRoi / 2 - xPadding);
+ let yPos = yMouse - yProportion * (heightRoi /2 - yPadding);
return [xPos, yPos];
},
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]