MCPcopy
hub / github.com/paperwm/PaperWM / toggleMaximizeHorizontally

Function toggleMaximizeHorizontally

tiling.js:4794–4830  ·  view source on GitHub ↗
(metaWindow)

Source from the content-addressed store, hash-verified

4792}
4793
4794export function toggleMaximizeHorizontally(metaWindow) {
4795 metaWindow = metaWindow || display.focus_window;
4796
4797 if (isMaximized(metaWindow)) {
4798 // ASSUMPTION: MaximizeFlags.HORIZONTALLY is not used
4799 unmaximize(metaWindow, Meta.MaximizeFlags.BOTH);
4800 metaWindow.unmaximizedRect = null;
4801 return;
4802 }
4803
4804 let maxWidthPrc = Settings.prefs.maximize_width_percent;
4805 // add some sane limits to width percents: 0.5 <= x <= 1.0
4806 maxWidthPrc = Math.max(0.5, maxWidthPrc);
4807 maxWidthPrc = Math.min(1.0, maxWidthPrc);
4808
4809 let space = spaces.spaceOfWindow(metaWindow);
4810 let workArea = space.workArea();
4811 let frame = metaWindow.get_frame_rect();
4812 let reqWidth = maxWidthPrc * workArea.width - Settings.prefs.horizontal_margin * 2;
4813
4814 // Some windows only resize in increments > 1px so we can't rely on a precise width
4815 // Hopefully this heuristic is good enough
4816 let isFullWidth = (reqWidth - frame.width) < sizeSlack;
4817
4818 if (isFullWidth && metaWindow.unmaximizedRect) {
4819 let unmaximizedRect = metaWindow.unmaximizedRect;
4820 metaWindow.move_resize_frame(
4821 true, unmaximizedRect.x, frame.y,
4822 unmaximizedRect.width, frame.height);
4823
4824 metaWindow.unmaximizedRect = null;
4825 } else {
4826 let x = workArea.x + space.monitor.x + Settings.prefs.horizontal_margin;
4827 metaWindow.unmaximizedRect = frame;
4828 metaWindow.move_resize_frame(true, x, frame.y, reqWidth, frame.height);
4829 }
4830}
4831
4832export function resizeHInc(metaWindow) {
4833 metaWindow = metaWindow || display.focus_window;

Callers 2

registerWindowFunction · 0.85
insertWindowFunction · 0.85

Calls 4

isMaximizedFunction · 0.85
unmaximizeFunction · 0.85
spaceOfWindowMethod · 0.80
workAreaMethod · 0.80

Tested by

no test coverage detected