[gnome-shell/gnome-3-12] screenshot: Scale and unscale the area for HiDpi displays
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/gnome-3-12] screenshot: Scale and unscale the area for HiDpi displays
- Date: Tue, 17 Jun 2014 19:22:22 +0000 (UTC)
commit ba6a2cae9c368da5e5a0ccc0bd6f50cba9c0c2d1
Author: Debarshi Ray <debarshir gnome org>
Date: Mon Jun 16 20:28:17 2014 +0200
screenshot: Scale and unscale the area for HiDpi displays
https://bugzilla.gnome.org/show_bug.cgi?id=731738
js/ui/screenshot.js | 26 +++++++++++++++++++++++---
1 files changed, 23 insertions(+), 3 deletions(-)
---
diff --git a/js/ui/screenshot.js b/js/ui/screenshot.js
index 80c3c1d..1c5812a 100644
--- a/js/ui/screenshot.js
+++ b/js/ui/screenshot.js
@@ -84,8 +84,27 @@ const ScreenshotService = new Lang.Class({
invocation.return_value(retval);
},
+ _scaleArea: function(x, y, width, height) {
+ let scaleFactor = St.ThemeContext.get_for_stage(global.stage).scale_factor;
+ x *= scaleFactor;
+ y *= scaleFactor;
+ width *= scaleFactor;
+ height *= scaleFactor;
+ return [x, y, width, height];
+ },
+
+ _unscaleArea: function(x, y, width, height) {
+ let scaleFactor = St.ThemeContext.get_for_stage(global.stage).scale_factor;
+ x /= scaleFactor;
+ y /= scaleFactor;
+ width /= scaleFactor;
+ height /= scaleFactor;
+ return [x, y, width, height];
+ },
+
ScreenshotAreaAsync : function (params, invocation) {
let [x, y, width, height, flash, filename, callback] = params;
+ [x, y, width, height] = this._scaleArea(x, y, width, height);
if (!this._checkArea(x, y, width, height)) {
invocation.return_error_literal(Gio.IOErrorEnum,
Gio.IOErrorEnum.CANCELLED,
@@ -120,9 +139,9 @@ const ScreenshotService = new Lang.Class({
selectArea.connect('finished', Lang.bind(this,
function(selectArea, areaRectangle) {
if (areaRectangle) {
- let retval = GLib.Variant.new('(iiii)',
- [areaRectangle.x, areaRectangle.y,
- areaRectangle.width, areaRectangle.height]);
+ let retRectangle = this._unscaleArea(areaRectangle.x, areaRectangle.y,
+ areaRectangle.width, areaRectangle.height);
+ let retval = GLib.Variant.new('(iiii)', retRectangle);
invocation.return_value(retval);
} else {
invocation.return_error_literal(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED,
@@ -133,6 +152,7 @@ const ScreenshotService = new Lang.Class({
FlashAreaAsync: function(params, invocation) {
let [x, y, width, height] = params;
+ [x, y, width, height] = this._scaleArea(x, y, width, height);
if (!this._checkArea(x, y, width, height)) {
invocation.return_error_literal(Gio.IOErrorEnum,
Gio.IOErrorEnum.CANCELLED,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]