From f69bdfc68989aeb6d15124a1106154c050067b4b Mon Sep 17 00:00:00 2001 From: Tom Butler Date: Sun, 5 Jan 2020 18:51:57 +0000 Subject: [PATCH] prevent wayland segfault when dragging windows --- contents/code/tile.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/contents/code/tile.js b/contents/code/tile.js index 62a52cc..bab1d1b 100644 --- a/contents/code/tile.js +++ b/contents/code/tile.js @@ -94,6 +94,12 @@ function Tile(firstClient, tileIndex) { */ this._currentScreen = firstClient.screen; + /** + * On wayland, certain actions cause a segfault if they happen + * more than once per frame. Keep track of the last time an + * action was run to stop the crash + */ + this._lastAction = 0; /** * Stores the current desktop as this is needed as a desktopChanged * parameter. @@ -377,6 +383,16 @@ Tile.prototype.onClientStartUserMovedResized = function(client) { }; Tile.prototype.onClientStepUserMovedResized = function(client) { + var ms = (new Date).getTime(); + + // On wayland if this runs twice in the same frame + // it causes a segfault + // Don't allow this to run more than once per frame + // 16.666 for 60fps, but give some additional time. + if (ms <= this._lastAction+25) return; + + this._lastAction = ms; + try { if (client.resize) { this._resizing = true;