2012-12-10 15:26:31 +00:00
|
|
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
2019-01-31 14:07:06 +00:00
|
|
|
/* exported ScreenshotService */
|
2012-12-10 15:26:31 +00:00
|
|
|
|
2019-04-04 14:03:54 +00:00
|
|
|
const { Clutter, Gio, GLib, Meta, Shell, St } = imports.gi;
|
2012-12-10 15:26:31 +00:00
|
|
|
const Signals = imports.signals;
|
|
|
|
|
2014-04-25 16:43:10 +00:00
|
|
|
const GrabHelper = imports.ui.grabHelper;
|
2012-12-10 15:26:31 +00:00
|
|
|
const Lightbox = imports.ui.lightbox;
|
|
|
|
const Main = imports.ui.main;
|
|
|
|
|
2018-09-06 00:55:20 +00:00
|
|
|
const { loadInterfaceXML } = imports.misc.fileUtils;
|
|
|
|
|
|
|
|
const ScreenshotIface = loadInterfaceXML('org.gnome.Shell.Screenshot');
|
2012-12-10 15:26:31 +00:00
|
|
|
|
2017-10-31 01:19:44 +00:00
|
|
|
var ScreenshotService = class {
|
|
|
|
constructor() {
|
2012-12-10 15:26:31 +00:00
|
|
|
this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(ScreenshotIface, this);
|
|
|
|
this._dbusImpl.export(Gio.DBus.session, '/org/gnome/Shell/Screenshot');
|
|
|
|
|
2014-09-27 11:35:22 +00:00
|
|
|
this._screenShooter = new Map();
|
|
|
|
|
2014-10-03 14:33:37 +00:00
|
|
|
this._lockdownSettings = new Gio.Settings({ schema_id: 'org.gnome.desktop.lockdown' });
|
|
|
|
|
2012-12-10 15:26:31 +00:00
|
|
|
Gio.DBus.session.own_name('org.gnome.Shell.Screenshot', Gio.BusNameOwnerFlags.REPLACE, null, null);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-12-10 15:26:31 +00:00
|
|
|
|
2019-01-29 01:27:05 +00:00
|
|
|
_createScreenshot(invocation, needsDisk = true) {
|
2018-07-19 17:23:46 +00:00
|
|
|
let lockedDown = false;
|
|
|
|
if (needsDisk)
|
2019-01-29 01:18:52 +00:00
|
|
|
lockedDown = this._lockdownSettings.get_boolean('disable-save-to-disk');
|
2018-07-19 17:23:46 +00:00
|
|
|
|
2014-09-27 11:35:22 +00:00
|
|
|
let sender = invocation.get_sender();
|
2018-07-19 17:23:46 +00:00
|
|
|
if (this._screenShooter.has(sender) || lockedDown) {
|
2014-09-27 11:35:22 +00:00
|
|
|
invocation.return_value(GLib.Variant.new('(bs)', [false, '']));
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
let shooter = new Shell.Screenshot();
|
|
|
|
shooter._watchNameId =
|
|
|
|
Gio.bus_watch_name(Gio.BusType.SESSION, sender, 0, null,
|
2017-12-02 00:27:35 +00:00
|
|
|
this._onNameVanished.bind(this));
|
2014-09-27 11:35:22 +00:00
|
|
|
|
|
|
|
this._screenShooter.set(sender, shooter);
|
|
|
|
|
|
|
|
return shooter;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2014-09-27 11:35:22 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_onNameVanished(connection, name) {
|
2014-09-27 11:35:22 +00:00
|
|
|
this._removeShooterForSender(name);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2014-09-27 11:35:22 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_removeShooterForSender(sender) {
|
2014-09-27 11:35:22 +00:00
|
|
|
let shooter = this._screenShooter.get(sender);
|
|
|
|
if (!shooter)
|
|
|
|
return;
|
|
|
|
|
|
|
|
Gio.bus_unwatch_name(shooter._watchNameId);
|
|
|
|
this._screenShooter.delete(sender);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2014-09-27 11:35:22 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_checkArea(x, y, width, height) {
|
2014-06-04 14:26:06 +00:00
|
|
|
return x >= 0 && y >= 0 &&
|
|
|
|
width > 0 && height > 0 &&
|
|
|
|
x + width <= global.screen_width &&
|
|
|
|
y + height <= global.screen_height;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2014-06-04 14:26:06 +00:00
|
|
|
|
2018-07-19 13:54:33 +00:00
|
|
|
_onScreenshotComplete(result, area, filenameUsed, flash, invocation) {
|
2014-09-27 11:35:22 +00:00
|
|
|
if (result) {
|
|
|
|
if (flash) {
|
|
|
|
let flashspot = new Flashspot(area);
|
2017-10-31 00:38:18 +00:00
|
|
|
flashspot.fire(() => {
|
2014-09-27 11:35:22 +00:00
|
|
|
this._removeShooterForSender(invocation.get_sender());
|
2017-10-31 00:38:18 +00:00
|
|
|
});
|
2019-01-29 21:02:57 +00:00
|
|
|
} else {
|
2014-09-27 11:35:22 +00:00
|
|
|
this._removeShooterForSender(invocation.get_sender());
|
2019-01-29 21:02:57 +00:00
|
|
|
}
|
2012-12-10 15:26:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
let retval = GLib.Variant.new('(bs)', [result, filenameUsed]);
|
|
|
|
invocation.return_value(retval);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-12-10 15:26:31 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_scaleArea(x, y, width, height) {
|
2014-06-16 18:28:17 +00:00
|
|
|
let scaleFactor = St.ThemeContext.get_for_stage(global.stage).scale_factor;
|
|
|
|
x *= scaleFactor;
|
|
|
|
y *= scaleFactor;
|
|
|
|
width *= scaleFactor;
|
|
|
|
height *= scaleFactor;
|
|
|
|
return [x, y, width, height];
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2014-06-16 18:28:17 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_unscaleArea(x, y, width, height) {
|
2014-06-16 18:28:17 +00:00
|
|
|
let scaleFactor = St.ThemeContext.get_for_stage(global.stage).scale_factor;
|
|
|
|
x /= scaleFactor;
|
|
|
|
y /= scaleFactor;
|
|
|
|
width /= scaleFactor;
|
|
|
|
height /= scaleFactor;
|
|
|
|
return [x, y, width, height];
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2014-06-16 18:28:17 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
ScreenshotAreaAsync(params, invocation) {
|
2019-02-04 10:58:00 +00:00
|
|
|
let [x, y, width, height, flash, filename] = params;
|
2014-06-16 18:28:17 +00:00
|
|
|
[x, y, width, height] = this._scaleArea(x, y, width, height);
|
2014-06-04 14:26:06 +00:00
|
|
|
if (!this._checkArea(x, y, width, height)) {
|
|
|
|
invocation.return_error_literal(Gio.IOErrorEnum,
|
|
|
|
Gio.IOErrorEnum.CANCELLED,
|
|
|
|
"Invalid params");
|
2013-03-02 13:59:05 +00:00
|
|
|
return;
|
|
|
|
}
|
2014-09-27 11:35:22 +00:00
|
|
|
let screenshot = this._createScreenshot(invocation);
|
|
|
|
if (!screenshot)
|
|
|
|
return;
|
2012-12-10 15:26:31 +00:00
|
|
|
screenshot.screenshot_area (x, y, width, height, filename,
|
2018-07-19 13:54:33 +00:00
|
|
|
(o, res) => {
|
|
|
|
try {
|
|
|
|
let [result, area, filenameUsed] =
|
|
|
|
screenshot.screenshot_area_finish(res);
|
2019-09-12 22:41:47 +00:00
|
|
|
this._onScreenshotComplete(
|
|
|
|
result, area, filenameUsed, flash, invocation);
|
2018-07-19 13:54:33 +00:00
|
|
|
} catch (e) {
|
|
|
|
invocation.return_gerror (e);
|
|
|
|
}
|
2017-12-02 00:27:35 +00:00
|
|
|
});
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-12-10 15:26:31 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
ScreenshotWindowAsync(params, invocation) {
|
2019-01-31 13:43:52 +00:00
|
|
|
let [includeFrame, includeCursor, flash, filename] = params;
|
2014-09-27 11:35:22 +00:00
|
|
|
let screenshot = this._createScreenshot(invocation);
|
|
|
|
if (!screenshot)
|
|
|
|
return;
|
2019-01-31 13:43:52 +00:00
|
|
|
screenshot.screenshot_window (includeFrame, includeCursor, filename,
|
2018-07-19 13:54:33 +00:00
|
|
|
(o, res) => {
|
|
|
|
try {
|
|
|
|
let [result, area, filenameUsed] =
|
|
|
|
screenshot.screenshot_window_finish(res);
|
2019-09-12 22:41:47 +00:00
|
|
|
this._onScreenshotComplete(
|
|
|
|
result, area, filenameUsed, flash, invocation);
|
2018-07-19 13:54:33 +00:00
|
|
|
} catch (e) {
|
|
|
|
invocation.return_gerror (e);
|
|
|
|
}
|
2017-12-02 00:27:35 +00:00
|
|
|
});
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-12-10 15:26:31 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
ScreenshotAsync(params, invocation) {
|
2019-01-31 13:43:52 +00:00
|
|
|
let [includeCursor, flash, filename] = params;
|
2014-09-27 11:35:22 +00:00
|
|
|
let screenshot = this._createScreenshot(invocation);
|
|
|
|
if (!screenshot)
|
|
|
|
return;
|
2019-01-31 13:43:52 +00:00
|
|
|
screenshot.screenshot(includeCursor, filename,
|
2018-07-19 13:54:33 +00:00
|
|
|
(o, res) => {
|
|
|
|
try {
|
|
|
|
let [result, area, filenameUsed] =
|
|
|
|
screenshot.screenshot_finish(res);
|
2019-09-12 22:41:47 +00:00
|
|
|
this._onScreenshotComplete(
|
|
|
|
result, area, filenameUsed, flash, invocation);
|
2018-07-19 13:54:33 +00:00
|
|
|
} catch (e) {
|
|
|
|
invocation.return_gerror (e);
|
|
|
|
}
|
2017-12-02 00:27:35 +00:00
|
|
|
});
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-12-10 15:26:31 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
SelectAreaAsync(params, invocation) {
|
2012-12-10 15:26:31 +00:00
|
|
|
let selectArea = new SelectArea();
|
|
|
|
selectArea.show();
|
2017-10-31 00:38:18 +00:00
|
|
|
selectArea.connect('finished', (selectArea, areaRectangle) => {
|
|
|
|
if (areaRectangle) {
|
|
|
|
let retRectangle = this._unscaleArea(areaRectangle.x, areaRectangle.y,
|
2019-01-29 19:36:54 +00:00
|
|
|
areaRectangle.width, areaRectangle.height);
|
2017-10-31 00:38:18 +00:00
|
|
|
let retval = GLib.Variant.new('(iiii)', retRectangle);
|
|
|
|
invocation.return_value(retval);
|
|
|
|
} else {
|
|
|
|
invocation.return_error_literal(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED,
|
2019-01-29 19:36:54 +00:00
|
|
|
"Operation was cancelled");
|
2017-10-31 00:38:18 +00:00
|
|
|
}
|
|
|
|
});
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-12-10 15:26:31 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
FlashAreaAsync(params, invocation) {
|
2014-06-04 14:26:06 +00:00
|
|
|
let [x, y, width, height] = params;
|
2014-06-16 18:28:17 +00:00
|
|
|
[x, y, width, height] = this._scaleArea(x, y, width, height);
|
2014-06-04 14:26:06 +00:00
|
|
|
if (!this._checkArea(x, y, width, height)) {
|
|
|
|
invocation.return_error_literal(Gio.IOErrorEnum,
|
|
|
|
Gio.IOErrorEnum.CANCELLED,
|
|
|
|
"Invalid params");
|
|
|
|
return;
|
|
|
|
}
|
2019-01-29 01:27:05 +00:00
|
|
|
let flashspot = new Flashspot({ x: x, y: y, width: width, height: height });
|
2012-12-10 15:26:31 +00:00
|
|
|
flashspot.fire();
|
2014-06-04 14:26:06 +00:00
|
|
|
invocation.return_value(null);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2018-07-17 23:34:59 +00:00
|
|
|
|
|
|
|
PickColorAsync(params, invocation) {
|
|
|
|
let pickPixel = new PickPixel();
|
|
|
|
pickPixel.show();
|
|
|
|
pickPixel.connect('finished', (pickPixel, coords) => {
|
|
|
|
if (coords) {
|
|
|
|
let screenshot = this._createScreenshot(invocation, false);
|
|
|
|
if (!screenshot)
|
|
|
|
return;
|
|
|
|
screenshot.pick_color(...coords, (o, res) => {
|
2019-01-31 14:08:00 +00:00
|
|
|
let [success_, color] = screenshot.pick_color_finish(res);
|
2018-07-17 23:34:59 +00:00
|
|
|
let { red, green, blue } = color;
|
|
|
|
let retval = GLib.Variant.new('(a{sv})', [{
|
|
|
|
color: GLib.Variant.new('(ddd)', [
|
|
|
|
red / 255.0,
|
|
|
|
green / 255.0,
|
|
|
|
blue / 255.0
|
|
|
|
])
|
|
|
|
}]);
|
|
|
|
this._removeShooterForSender(invocation.get_sender());
|
|
|
|
invocation.return_value(retval);
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
invocation.return_error_literal(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED,
|
2019-01-29 19:36:54 +00:00
|
|
|
"Operation was cancelled");
|
2018-07-17 23:34:59 +00:00
|
|
|
}
|
|
|
|
});
|
2012-12-10 15:26:31 +00:00
|
|
|
}
|
2017-10-31 01:19:44 +00:00
|
|
|
};
|
2012-12-10 15:26:31 +00:00
|
|
|
|
2017-10-31 01:19:44 +00:00
|
|
|
var SelectArea = class {
|
|
|
|
constructor() {
|
2012-12-10 15:26:31 +00:00
|
|
|
this._startX = -1;
|
|
|
|
this._startY = -1;
|
|
|
|
this._lastX = 0;
|
|
|
|
this._lastY = 0;
|
2014-04-25 16:43:10 +00:00
|
|
|
this._result = null;
|
2012-12-10 15:26:31 +00:00
|
|
|
|
|
|
|
this._group = new St.Widget({ visible: false,
|
|
|
|
reactive: true,
|
|
|
|
x: 0,
|
|
|
|
y: 0 });
|
|
|
|
Main.uiGroup.add_actor(this._group);
|
|
|
|
|
2014-04-25 16:43:10 +00:00
|
|
|
this._grabHelper = new GrabHelper.GrabHelper(this._group);
|
|
|
|
|
2012-12-10 15:26:31 +00:00
|
|
|
this._group.connect('button-press-event',
|
2017-12-02 00:27:35 +00:00
|
|
|
this._onButtonPress.bind(this));
|
2012-12-10 15:26:31 +00:00
|
|
|
this._group.connect('button-release-event',
|
2017-12-02 00:27:35 +00:00
|
|
|
this._onButtonRelease.bind(this));
|
2012-12-10 15:26:31 +00:00
|
|
|
this._group.connect('motion-event',
|
2017-12-02 00:27:35 +00:00
|
|
|
this._onMotionEvent.bind(this));
|
2012-12-10 15:26:31 +00:00
|
|
|
|
|
|
|
let constraint = new Clutter.BindConstraint({ source: global.stage,
|
|
|
|
coordinate: Clutter.BindCoordinate.ALL });
|
|
|
|
this._group.add_constraint(constraint);
|
|
|
|
|
2019-04-04 14:03:54 +00:00
|
|
|
this._rubberband = new St.Widget({
|
|
|
|
style_class: 'select-area-rubberband',
|
|
|
|
visible: false
|
|
|
|
});
|
2012-12-10 15:26:31 +00:00
|
|
|
this._group.add_actor(this._rubberband);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-12-10 15:26:31 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
show() {
|
2014-04-25 16:43:10 +00:00
|
|
|
if (!this._grabHelper.grab({ actor: this._group,
|
2017-12-02 00:27:35 +00:00
|
|
|
onUngrab: this._onUngrab.bind(this) }))
|
2012-12-10 15:26:31 +00:00
|
|
|
return;
|
|
|
|
|
2018-01-03 07:55:38 +00:00
|
|
|
global.display.set_cursor(Meta.Cursor.CROSSHAIR);
|
2014-04-25 16:43:10 +00:00
|
|
|
Main.uiGroup.set_child_above_sibling(this._group, null);
|
2012-12-10 15:26:31 +00:00
|
|
|
this._group.visible = true;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-12-10 15:26:31 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_getGeometry() {
|
2012-12-10 15:26:31 +00:00
|
|
|
return { x: Math.min(this._startX, this._lastX),
|
|
|
|
y: Math.min(this._startY, this._lastY),
|
2015-03-14 22:48:41 +00:00
|
|
|
width: Math.abs(this._startX - this._lastX) + 1,
|
|
|
|
height: Math.abs(this._startY - this._lastY) + 1 };
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-12-10 15:26:31 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_onMotionEvent(actor, event) {
|
2019-09-10 06:49:50 +00:00
|
|
|
if (this._startX == -1 || this._startY == -1 || this._result)
|
2013-11-29 18:17:34 +00:00
|
|
|
return Clutter.EVENT_PROPAGATE;
|
2012-12-10 15:26:31 +00:00
|
|
|
|
|
|
|
[this._lastX, this._lastY] = event.get_coords();
|
2015-03-14 22:45:11 +00:00
|
|
|
this._lastX = Math.floor(this._lastX);
|
|
|
|
this._lastY = Math.floor(this._lastY);
|
2012-12-10 15:26:31 +00:00
|
|
|
let geometry = this._getGeometry();
|
|
|
|
|
|
|
|
this._rubberband.set_position(geometry.x, geometry.y);
|
|
|
|
this._rubberband.set_size(geometry.width, geometry.height);
|
2019-04-04 14:03:54 +00:00
|
|
|
this._rubberband.show();
|
2012-12-10 15:26:31 +00:00
|
|
|
|
2013-11-29 18:17:34 +00:00
|
|
|
return Clutter.EVENT_PROPAGATE;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-12-10 15:26:31 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_onButtonPress(actor, event) {
|
2012-12-10 15:26:31 +00:00
|
|
|
[this._startX, this._startY] = event.get_coords();
|
2015-03-14 22:45:11 +00:00
|
|
|
this._startX = Math.floor(this._startX);
|
|
|
|
this._startY = Math.floor(this._startY);
|
2012-12-10 15:26:31 +00:00
|
|
|
this._rubberband.set_position(this._startX, this._startY);
|
|
|
|
|
2013-11-29 18:17:34 +00:00
|
|
|
return Clutter.EVENT_PROPAGATE;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-12-10 15:26:31 +00:00
|
|
|
|
2019-02-04 11:30:53 +00:00
|
|
|
_onButtonRelease() {
|
2014-04-25 16:43:10 +00:00
|
|
|
this._result = this._getGeometry();
|
2018-07-20 19:46:19 +00:00
|
|
|
this._group.ease({
|
|
|
|
opacity: 0,
|
|
|
|
duration: 200,
|
|
|
|
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
|
|
|
|
onComplete: () => this._grabHelper.ungrab()
|
|
|
|
});
|
2014-04-25 16:43:10 +00:00
|
|
|
return Clutter.EVENT_PROPAGATE;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2014-04-25 16:43:10 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_onUngrab() {
|
2018-01-03 07:55:38 +00:00
|
|
|
global.display.set_cursor(Meta.Cursor.DEFAULT);
|
2014-04-25 16:43:10 +00:00
|
|
|
this.emit('finished', this._result);
|
|
|
|
|
2017-10-31 00:38:18 +00:00
|
|
|
GLib.idle_add(GLib.PRIORITY_DEFAULT, () => {
|
|
|
|
this._group.destroy();
|
|
|
|
return GLib.SOURCE_REMOVE;
|
|
|
|
});
|
2012-12-10 15:26:31 +00:00
|
|
|
}
|
2017-10-31 01:19:44 +00:00
|
|
|
};
|
2012-12-10 15:26:31 +00:00
|
|
|
Signals.addSignalMethods(SelectArea.prototype);
|
|
|
|
|
2017-10-31 01:19:44 +00:00
|
|
|
var PickPixel = class {
|
|
|
|
constructor() {
|
2018-07-17 23:34:59 +00:00
|
|
|
this._result = null;
|
|
|
|
|
|
|
|
this._group = new St.Widget({ visible: false,
|
|
|
|
reactive: true });
|
|
|
|
Main.uiGroup.add_actor(this._group);
|
|
|
|
|
|
|
|
this._grabHelper = new GrabHelper.GrabHelper(this._group);
|
|
|
|
|
|
|
|
this._group.connect('button-release-event',
|
|
|
|
this._onButtonRelease.bind(this));
|
|
|
|
|
|
|
|
let constraint = new Clutter.BindConstraint({ source: global.stage,
|
|
|
|
coordinate: Clutter.BindCoordinate.ALL });
|
|
|
|
this._group.add_constraint(constraint);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2018-07-17 23:34:59 +00:00
|
|
|
|
|
|
|
show() {
|
|
|
|
if (!this._grabHelper.grab({ actor: this._group,
|
|
|
|
onUngrab: this._onUngrab.bind(this) }))
|
|
|
|
return;
|
|
|
|
|
|
|
|
global.display.set_cursor(Meta.Cursor.CROSSHAIR);
|
|
|
|
Main.uiGroup.set_child_above_sibling(this._group, null);
|
|
|
|
this._group.visible = true;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2018-07-17 23:34:59 +00:00
|
|
|
|
|
|
|
_onButtonRelease(actor, event) {
|
|
|
|
this._result = event.get_coords();
|
|
|
|
this._grabHelper.ungrab();
|
|
|
|
return Clutter.EVENT_PROPAGATE;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2018-07-17 23:34:59 +00:00
|
|
|
|
|
|
|
_onUngrab() {
|
|
|
|
global.display.set_cursor(Meta.Cursor.DEFAULT);
|
|
|
|
this.emit('finished', this._result);
|
|
|
|
|
|
|
|
GLib.idle_add(GLib.PRIORITY_DEFAULT, () => {
|
|
|
|
this._group.destroy();
|
|
|
|
return GLib.SOURCE_REMOVE;
|
|
|
|
});
|
|
|
|
}
|
2017-10-31 01:19:44 +00:00
|
|
|
};
|
2018-07-17 23:34:59 +00:00
|
|
|
Signals.addSignalMethods(PickPixel.prototype);
|
|
|
|
|
2019-08-01 23:13:10 +00:00
|
|
|
var FLASHSPOT_ANIMATION_OUT_TIME = 500; // milliseconds
|
2012-12-10 15:26:31 +00:00
|
|
|
|
2017-10-31 01:19:44 +00:00
|
|
|
var Flashspot = class extends Lightbox.Lightbox {
|
|
|
|
constructor(area) {
|
|
|
|
super(Main.uiGroup, { inhibitEvents: true,
|
|
|
|
width: area.width,
|
|
|
|
height: area.height });
|
2012-12-10 15:26:31 +00:00
|
|
|
|
|
|
|
this.actor.style_class = 'flashspot';
|
|
|
|
this.actor.set_position(area.x, area.y);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-12-10 15:26:31 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
fire(doneCallback) {
|
2012-12-10 15:26:31 +00:00
|
|
|
this.actor.show();
|
2013-01-14 22:51:36 +00:00
|
|
|
this.actor.opacity = 255;
|
2018-07-20 19:46:19 +00:00
|
|
|
this.actor.ease({
|
|
|
|
opacity: 0,
|
|
|
|
duration: FLASHSPOT_ANIMATION_OUT_TIME,
|
|
|
|
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
|
|
|
|
onComplete: () => {
|
|
|
|
if (doneCallback)
|
|
|
|
doneCallback();
|
|
|
|
this.destroy();
|
|
|
|
}
|
|
|
|
});
|
2012-12-10 15:26:31 +00:00
|
|
|
}
|
2017-10-31 01:19:44 +00:00
|
|
|
};
|