From 55a816bdbc40cf1668958c7eac6a118f68f2b52e Mon Sep 17 00:00:00 2001 From: "Torrance, Douglas" Date: Sat, 14 Jan 2023 22:22:39 +0000 Subject: [PATCH] Keep dock on primary head if KeepDockOnPrimaryHead is YES This implements a feature request [1] to allow the possibility of keeping the dock on the primary head on a multi-head system. In particular, if the new KeepDockOnPrimaryHead option is set to YES, the dock will either be on the left- or right-hand side of the primary screen. If it is NO, then we get the current behavior, i.e., the dock will either be on the left-hand side of the leftmost head or the right-hand side of the rightmost head. [1] https://github.com/window-maker/wmaker/issues/24 Closes: #24 --- src/dock.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/dock.c b/src/dock.c index b37cc561..8c777124 100644 --- a/src/dock.c +++ b/src/dock.c @@ -3009,12 +3009,25 @@ static void swapDock(WDock *dock) WAppIcon *btn; int x, i; - if (dock->on_right_side) - x = dock->x_pos = scr->scr_width - ICON_SIZE - DOCK_EXTRA_SPACE; - else - x = dock->x_pos = DOCK_EXTRA_SPACE; + + if (wPreferences.keep_dock_on_primary_head) { + WMRect rect; + + rect = wGetRectForHead(scr, scr->xine_info.primary_head); + x = rect.pos.x; + if (dock->on_right_side) + x += rect.size.width - ICON_SIZE - DOCK_EXTRA_SPACE; + else + x += DOCK_EXTRA_SPACE; + } else { + if (dock->on_right_side) + x = scr->scr_width - ICON_SIZE - DOCK_EXTRA_SPACE; + else + x = DOCK_EXTRA_SPACE; + } swapDrawers(scr, x); + dock->x_pos = x; for (i = 0; i < dock->max_icons; i++) { btn = dock->icon_array[i];