From 48d4820deea3b0053b9840275f1bed5148899006 Mon Sep 17 00:00:00 2001 From: "Torrance, Douglas" Date: Wed, 18 Jan 2023 11:42:57 +0000 Subject: [PATCH] Support "KeepDockOnPrimaryHead" when restoring state We use the new helper function getDockXPosition to determine where to put the dock. If WMState gives an x-coordinate less than the center of the screen, we put it on the left, and otherwise we put it on the right. --- src/dock.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/dock.c b/src/dock.c index d06cac05..1a3e25b8 100644 --- a/src/dock.c +++ b/src/dock.c @@ -1846,11 +1846,17 @@ WDock *wDockRestoreState(WScreen *scr, WMPropList *dock_state, int type) dock->x_pos = scr->scr_width - ICON_SIZE; } } else { - if (dock->x_pos >= 0) { - dock->x_pos = DOCK_EXTRA_SPACE; + int left, right, midpoint; + + left = getDockXPosition(scr, False); + right = getDockXPosition(scr, True); + midpoint = (left + right) / 2; + + if (dock->x_pos < midpoint) { + dock->x_pos = left; dock->on_right_side = 0; } else { - dock->x_pos = scr->scr_width - DOCK_EXTRA_SPACE - ICON_SIZE; + dock->x_pos = right; dock->on_right_side = 1; } }