Bug 13589 - coordinates from XMoveWindow() treated incorrectly
Summary: coordinates from XMoveWindow() treated incorrectly
Status: RESOLVED FIXED
Alias: None
Product: xorg
Classification: Unclassified
Component: App/compiz (show other bugs)
Version: 7.2 (2007.02)
Hardware: Other Linux (All)
: medium normal
Assignee: David Reveman
QA Contact: Xorg Project Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-12-10 08:13 UTC by Oleg Sukhodolsky
Modified: 2008-03-17 07:15 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
Possible fix (911 bytes, patch)
2008-03-08 21:51 UTC, Erkin Bahceci
no flags Details | Splinter Review
Better fix (1.03 KB, patch)
2008-03-16 23:51 UTC, Danny Baumann
no flags Details | Splinter Review
Better fix, take 2 (1.11 KB, patch)
2008-03-17 00:02 UTC, Danny Baumann
no flags Details | Splinter Review

Description Oleg Sukhodolsky 2007-12-10 08:13:48 UTC
Here is a simple test which creates/maps a windows at location (100,100) and on 
mouse press move the window at the same location.
Under Metacity everything works fine (second move does nothing), however under Compiz we have a different story :(
initially it places so decoration would placed at (100,100) and the window itself has different coordinates ((104, 124) in my case.
But after XMoveWindow() it moves the window at (100,100), so decorations are
at (96, 76).

I may be wrong, but my interpretation of ICCM (http://tronche.com/gui/x/icccm/sec-4.html#s-4.1.5) is that WM should treat
coordinates from XMoveWindow() the same way as from hints for initial showing. 

#include <X11/Xlib.h>
#include <X11/Xutil.h>

#include <stdio.h>

Display *display;
Window root, w1;

Window create_window(char *name, Window parent, int x, int y, int width, int height)
{
    Window win = XCreateSimpleWindow(display, parent, x, y, width, height,
                                     2,
                                     BlackPixel(display, 0),
                                     WhitePixel(display, 0));

    XStoreName(display, win, name);

    XSizeHints *hints = XAllocSizeHints();
    hints->width = width;
    hints->height = height;
    hints->x = x;
    hints->y = y;
    hints->win_gravity = 1 /*NorthWest*/;

    hints->flags = PPosition | USPosition | PSize | PWinGravity;

    XSetWMNormalHints(display, win, hints);
    XFree(hints);

    return win;
}

int main(int argc, char **argv)
{
    XEvent ev;
    char *display_name = NULL;
    if ((display = XOpenDisplay(display_name)) == NULL)
    {
        fprintf(stderr, "Couldn't open %s\n", XDisplayName(display_name));
        return -1;
    }

    root = RootWindow(display, 0);

    w1 = create_window("Window", root, 100, 100, 100, 100);
    XSelectInput(display, w1, StructureNotifyMask | ExposureMask | ButtonPressMask);

    XMapWindow(display, w1);

    XFlush(display);

    while (1)
    {
        XNextEvent(display, &ev);
        if (ConfigureNotify == ev.type) {
            XConfigureEvent e = ev.xconfigure;
            fprintf(stderr, "ConfigureNotify: w=%x, x=%d, y=%d, send=%d\n", e.window, e.x, e.y, e.send_event);
        } else if (ButtonPress == ev.type) {
            XMoveWindow(display, w1, 100, 100);
            fprintf(stderr, "button pressed\n");
        }

    }

    return 0;
}
Comment 1 Erkin Bahceci 2008-03-08 21:51:43 UTC
Created attachment 14964 [details] [review]
Possible fix

Here is a patch that seems to fix this problem. I didn't spot any bad side effects. It doesn't fix Java bug 6632124 though.
Comment 2 Danny Baumann 2008-03-16 23:51:37 UTC
Created attachment 15219 [details] [review]
Better fix

Better fix attempt. The patch in comment #1 only works for windows with NorthWestGravity. This fix should work for all kinds of gravity - please test.
Comment 3 Danny Baumann 2008-03-17 00:02:52 UTC
Created attachment 15220 [details] [review]
Better fix, take 2

I just noticed that my first fix attempt didn't work correctly for e.g. SouthEastGravity. Inspection showed that seemingly just the north / west adjustments were missing from the moveResizeWindow function.
Please test this one, it should work fine.
Comment 4 Danny Baumann 2008-03-17 02:44:01 UTC
(In reply to comment #3)
> Created an attachment (id=15220) [details]
> Better fix, take 2
> 
> I just noticed that my first fix attempt didn't work correctly for e.g.
> SouthEastGravity. Inspection showed that seemingly just the north / west
> adjustments were missing from the moveResizeWindow function.
> Please test this one, it should work fine.

After thinking a bit more about that, I decided that this fix is the correct one and thus pushed it.
Should be fixed in commit 61f8473ed79d679f0c9dd068340b14ad964dda12.

Comment 5 Erkin Bahceci 2008-03-17 07:15:36 UTC
I tested the latest git version with your commits, and it works fine for all gravities.
Thanks.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.