From 86b7ec1a58e198469df840372e6cec691c81a699 Mon Sep 17 00:00:00 2001 From: David Maciejak Date: Tue, 14 Mar 2023 18:49:08 +0800 Subject: [PATCH] Restore proper drawer direction when screen was resized Since 48d4820deea3b0053b9840275f1bed5148899006 the dock is positioned dynamically based on the screen midpoint. The side issue using such method is if in case the screen was temporarily resized the dock as a chance to be displayed on the other side making the drawer saved configuration from WMState esp the direction wrong when wm is started again. For example, the dock and drawer are displayed on the right of the screen. Then the screen resolution is downsized temporaily to half or less of the previous size. The position stored in WMState will be updated and the direction of the drawer is still opening on the left. But on next wm start, when reading the conf. The position of the dock and drawer are corresponding to the middle or less of the unresized screen. The dock and drawer will be sticked on the left. But the drawer direction was not updated and still opening on the left (which is out of the screen). --- src/dock.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/dock.c b/src/dock.c index 6eed7101..45282057 100644 --- a/src/dock.c +++ b/src/dock.c @@ -4926,6 +4926,13 @@ static WDock * drawerRestoreState(WScreen *scr, WMPropList *drawer_state) drawer->icon_array[drawer->icon_count] = aicon; if (aicon) { + /* don't trust the stored direction sign as the dock is + * dynamically positioned depending on the screen size + */ + if (drawer->screen_ptr->dock->on_right_side) + aicon->xindex = -abs(aicon->xindex); + else + aicon->xindex = abs(aicon->xindex); aicon->dock = drawer; aicon->x_pos = drawer->x_pos + (aicon->xindex * ICON_SIZE); aicon->y_pos = drawer->y_pos + (aicon->yindex * ICON_SIZE);