joewing / jwm

Joe's Window Manager
http://joewing.net/projects/jwm
MIT License
520 stars 84 forks source link

A maximized window created by dragging the window to a border doesn’t store its location correctly. #605

Open pmarin opened 9 months ago

pmarin commented 9 months ago

Looks like after the window is maximized, the EventLoop calls HandleButtonEvent and MoveClient overwrite np->x and np->y.

Example: jwm

I don’t know the event handling code enough to fix the bug so I just get the location from its window attributes:

--- src/resize.c    2023-12-02 17:33:32.000000000 +0100
+++ ../jwm-old/src/resize.c 2023-12-10 09:33:23.164949556 +0100
@@ -138,10 +138,18 @@
       return;
    }
    if(np->state.maxFlags) {
+      XWindowAttributes parent;
+      XWindowAttributes window;
+      if(JXGetWindowAttributes(display, np->parent, &parent))
+         if(JXGetWindowAttributes(display, np->window, &window)) {
+             np->x = parent.x+window.x;
+             np->y = parent.y+window.y;
+         }
       np->state.maxFlags = MAX_NONE;
       WriteState(np);
       ResetBorder(np);
    }
+
    if(JUNLIKELY(!GrabMouseForResize(context))) {
       return;
    }

The result: jwm_patched

It doesn’t fix the bug (the location overwrite) but at least the resize works correctly.