MCPcopy Index your code
hub / github.com/paperwm/PaperWM / triggerPreview

Method triggerPreview

stackoverlay.js:270–340  ·  view source on GitHub ↗

* Triggers edge window preview. * @param {Boolean} postActivatePreview: true if an auto preview after previous activation * @returns

(postActivatePreview = false)

Source from the content-addressed store, hash-verified

268 * @returns
269 */
270 triggerPreview(postActivatePreview = false) {
271 if (!Settings.prefs.edge_preview_enable) {
272 return;
273 }
274
275 if (this.showPreviewTimeout) {
276 return;
277 }
278
279 if (!this.target) {
280 return;
281 }
282
283 // create pointerwatcher to ensure preview is removed
284 previewPointerWatcher?.remove();
285 previewPointerWatcher = PointerWatcher.getPointerWatcher().addWatch(200, () => {
286 if (!this._pointerIsAtEdge()) {
287 this.removePreview();
288 previewPointerWatcher?.remove();
289 previewPointerWatcher = null;
290 }
291 });
292
293 this.showPreviewTimeout = GLib.timeout_add(GLib.PRIORITY_DEFAULT, this.SHOW_DELAY, () => {
294 this.removePreview();
295 this.showPreview();
296 this.showPreviewTimeout = null;
297
298 // activate preview on timeout
299 if (Settings.prefs.edge_preview_timeout_enable) {
300 // if no continual activation
301 if (postActivatePreview &&
302 !Settings.prefs.edge_preview_timeout_continual) {
303 // check have a target
304 if (!this.target) {
305 return;
306 }
307
308 // push pointer back
309 let [, py] = global.get_pointer();
310 const offset = 3;
311 let x;
312 switch (this._direction) {
313 case Meta.MotionDirection.LEFT:
314 x = this.monitor.x + offset;
315 break;
316 case Meta.MotionDirection.RIGHT:
317 x = this.monitor.x + this.monitor.width - offset;
318 break;
319 }
320 Utils.warpPointer(
321 x,
322 py,
323 false
324 );
325 return;
326 }
327

Callers 2

constructorMethod · 0.95
_activateTargetMethod · 0.95

Calls 5

_pointerIsAtEdgeMethod · 0.95
removePreviewMethod · 0.95
showPreviewMethod · 0.95
_activateTargetMethod · 0.95
removeMethod · 0.80

Tested by

no test coverage detected