use timestamps instead of Math.random in elementGrabber

This commit is contained in:
abakkk 2020-08-31 14:03:24 +02:00
parent 89067a8dd9
commit 6a8afcc20a
1 changed files with 3 additions and 1 deletions

View File

@ -45,6 +45,7 @@ const _ = imports.gettext.domain(Me.metadata['gettext-domain']).gettext;
const CAIRO_DEBUG_EXTENDS = false;
const SVG_DEBUG_EXTENDS = false;
const TEXT_CURSOR_TIME = 600; // ms
const ELEMENT_GRABBER_TIME = 80; // ms, default is about 16 ms
const GRID_TILES_HORIZONTAL_NUMBER = 30;
const { Shapes, ShapeNames, Transformations, LineCapNames, LineJoinNames, FillRuleNames, FontWeightNames, FontStyleNames } = Elements;
@ -434,8 +435,9 @@ var DrawingArea = new Lang.Class({
}
// Reduce computing without notable effect.
if (Math.random() <= 0.75)
if (event.get_time() - (this.elementGrabberTimestamp || 0) < ELEMENT_GRABBER_TIME)
return;
this.elementGrabberTimestamp = event.get_time();
let coords = event.get_coords();
let [s, x, y] = this.transform_stage_point(coords[0], coords[1]);