From 66acfc63ef3326af98a8bf146dcb7e7fd371f614 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20J=C3=B8rgen=20Br=C3=B8nner?= Date: Fri, 17 May 2019 10:08:00 +0200 Subject: [PATCH] Make cycleWindowHeight work for scratch windows --- tiling.js | 48 ++++++++++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/tiling.js b/tiling.js index 07217da..51bb4d0 100644 --- a/tiling.js +++ b/tiling.js @@ -2457,31 +2457,39 @@ function cycleWindowHeight(metaWindow) { } let space = spaces.spaceOfWindow(metaWindow); - if (!space) - return; - let i = space.indexOf(metaWindow); - // Fix `frame` outside `allocate` so the allocation wont change during - // fixpoint calculation. (could move more out, but then we'd have to - // calculate available manually) - let frame = metaWindow.get_frame_rect(); + if (i > -1) { + // Fix `frame` outside `allocate` so the allocation wont change during + // fixpoint calculation. (could move more out, but then we'd have to + // calculate available manually) + let frame = metaWindow.get_frame_rect(); - function allocate(column, available) { - available -= (column.length - 1) * prefs.window_gap; + function allocate(column, available) { + available -= (column.length - 1) * prefs.window_gap; + let r = frame.height / available; + let nextR = ratios[findNext(r)]; + return column.map(mw => { + if (mw === metaWindow) { + return Math.floor(available * nextR); + } else { + return Math.floor(available * (1-nextR)/(column.length-1)); + } + }); + } + + if (space[i].length > 1) { + space.layout(false, {customAllocators: {[i]: allocate}}); + } + } else { + // Not in tiling + let frame = metaWindow.get_frame_rect(); + let workspace = metaWindow.get_workspace(); + let available = workspace.get_work_area_for_monitor().height; let r = frame.height / available; let nextR = ratios[findNext(r)]; - return column.map(mw => { - if (mw === metaWindow) { - return Math.floor(available * nextR); - } else { - return Math.floor(available * (1-nextR)/(column.length-1)); - } - }); - } - - if (space[i].length > 1) { - space.layout(false, {customAllocators: {[i]: allocate}}); + metaWindow.move_resize_frame(true, frame.x, frame.y, + frame.width, Math.floor(available * nextR)); } }