coords of a window under sdl - Xwindows

This is a discussion on coords of a window under sdl - Xwindows ; i'm using the following piece of code to know the windows coordinates : --- if (hSurface) { SDL_SysWMinfo info; Window window, dummy; int x, y; XWindowAttributes attributes; Display *display; SDL_VERSION(&info.version); if (!SDL_GetWMInfo(&info)) return (hY); info.info.x11.lock_func(); display = info.info.x11.display; window = ...

+ Reply to Thread
Results 1 to 6 of 6

Thread: coords of a window under sdl

  1. coords of a window under sdl

    i'm using the following piece of code to know the windows coordinates :

    ---
    if (hSurface)
    {
    SDL_SysWMinfo info;
    Window window, dummy;
    int x, y;
    XWindowAttributes attributes;
    Display *display;
    SDL_VERSION(&info.version);

    if (!SDL_GetWMInfo(&info))
    return (hY);

    info.info.x11.lock_func();
    display = info.info.x11.display;
    window = info.info.x11.window;
    XSync(display, false);
    XGetWindowAttributes(display, window, &attributes);
    XTranslateCoordinates (display, window, attributes.root, 0, 0, &x, &y,
    &dummy);
    info.info.x11.unlock_func();
    hY = y;
    }

    ---

    But when the window is at 0,0 i get x = 5 and y = 22 (under kde) ! How can i
    have real coordinates ? am i doing something wrong ?

    Thx


  2. Re: coords of a window under sdl

    Laurent Carlier wrote:
    > i'm using the following piece of code to know the windows coordinates :
    >
    > ---
    > if (hSurface)
    > {
    > SDL_SysWMinfo info;
    > Window window, dummy;
    > int x, y;
    > XWindowAttributes attributes;
    > Display *display;
    > SDL_VERSION(&info.version);
    >
    > if (!SDL_GetWMInfo(&info))
    > return (hY);
    >
    > info.info.x11.lock_func();
    > display = info.info.x11.display;
    > window = info.info.x11.window;
    > XSync(display, false);
    > XGetWindowAttributes(display, window, &attributes);
    > XTranslateCoordinates (display, window, attributes.root, 0, 0, &x, &y,
    > &dummy);
    > info.info.x11.unlock_func();
    > hY = y;
    > }
    >
    > ---
    >
    > But when the window is at 0,0 i get x = 5 and y = 22 (under kde) ! How can i
    > have real coordinates ? am i doing something wrong ?
    >
    > Thx
    >

    x=5 y=22 look very much like the coordinates on screen of the top left
    *inside* the window frame. And yes, getting the physical position and
    thicknesses *of* the window *frame* is often needed, often asked on the
    net, and practically impossible to do in a way that does not depend a
    lot on the window manager.

    If it's OK for you to be limited to your favorite current wm, then try
    xprop and xwininfo on the window; *maybe* kdm will be kind enough to
    have the answer. But I wouldnt recommend going that way.

    What exactly are you trying to accomplish?

    --
    Michel Bardiaux
    R&D Director
    T +32 [0] 2 790 29 41
    F +32 [0] 2 790 29 02
    E mailto:mbardiaux@mediaxim.be

    Mediaxim NV/SA
    Vorstlaan 191 Boulevard du Souverain
    Brussel 1160 Bruxelles
    http://www.mediaxim.com/

  3. Re: coords of a window under sdl

    Michel Bardiaux wrote:

    > Laurent Carlier wrote:
    >> i'm using the following piece of code to know the windows coordinates :
    >>
    >> ---
    >> ---
    >>
    >> But when the window is at 0,0 i get x = 5 and y = 22 (under kde) ! How
    >> can i have real coordinates ? am i doing something wrong ?
    >>
    >> Thx
    >>

    > x=5 y=22 look very much like the coordinates on screen of the top left
    > *inside* the window frame. And yes, getting the physical position and
    > thicknesses *of* the window *frame* is often needed, often asked on the
    > net, and practically impossible to do in a way that does not depend a
    > lot on the window manager.
    >
    > If it's OK for you to be limited to your favorite current wm, then try
    > xprop and xwininfo on the window; *maybe* kdm will be kind enough to
    > have the answer. But I wouldnt recommend going that way.
    >
    > What exactly are you trying to accomplish?
    >


    I'm trying to let the user of my app to change and get coords of an sdl
    window. I've just found the _NET_FRAME_EXTENTS atom that seem to return
    size of borders
    ( http://standards.freedesktop.org/wm-...html#id2523626 )

    Now i must learn how to use atoms :-)

    Thx


  4. Re: coords of a window under sdl

    Laurent Carlier wrote:
    > Michel Bardiaux wrote:
    >
    >> Laurent Carlier wrote:
    >>> i'm using the following piece of code to know the windows coordinates :
    >>>
    >>> ---
    >>> ---
    >>>
    >>> But when the window is at 0,0 i get x = 5 and y = 22 (under kde) ! How
    >>> can i have real coordinates ? am i doing something wrong ?
    >>>
    >>> Thx
    >>>

    >> x=5 y=22 look very much like the coordinates on screen of the top left
    >> *inside* the window frame. And yes, getting the physical position and
    >> thicknesses *of* the window *frame* is often needed, often asked on the
    >> net, and practically impossible to do in a way that does not depend a
    >> lot on the window manager.
    >>
    >> If it's OK for you to be limited to your favorite current wm, then try
    >> xprop and xwininfo on the window; *maybe* kdm will be kind enough to
    >> have the answer. But I wouldnt recommend going that way.
    >>
    >> What exactly are you trying to accomplish?
    >>

    >
    > I'm trying to let the user of my app to change and get coords of an sdl
    > window.


    Still not clear because still the idea that the borders belong to the
    window. They dont, they belong to the WM. An app should not be concerned
    with that, unless it uses full-screen.

    > I've just found the _NET_FRAME_EXTENTS atom that seem to return
    > size of borders
    > ( http://standards.freedesktop.org/wm-...html#id2523626 )
    >
    > Now i must learn how to use atoms :-)


    Look in the source of xprop.

    >
    > Thx
    >



    --
    Michel Bardiaux
    R&D Director
    T +32 [0] 2 790 29 41
    F +32 [0] 2 790 29 02
    E mailto:mbardiaux@mediaxim.be

    Mediaxim NV/SA
    Vorstlaan 191 Boulevard du Souverain
    Brussel 1160 Bruxelles
    http://www.mediaxim.com/

  5. Re: coords of a window under sdl

    Michel Bardiaux wrote:

    > Laurent Carlier wrote:
    >> Michel Bardiaux wrote:
    >>
    >>> Laurent Carlier wrote:
    >>>> i'm using the following piece of code to know the windows coordinates :
    >>>>
    >>>> ---
    >>>> ---
    >>>>
    >>>> But when the window is at 0,0 i get x = 5 and y = 22 (under kde) ! How
    >>>> can i have real coordinates ? am i doing something wrong ?
    >>>>
    >>>> Thx
    >>>>
    >>> x=5 y=22 look very much like the coordinates on screen of the top left
    >>> *inside* the window frame. And yes, getting the physical position and
    >>> thicknesses *of* the window *frame* is often needed, often asked on the
    >>> net, and practically impossible to do in a way that does not depend a
    >>> lot on the window manager.
    >>>
    >>> If it's OK for you to be limited to your favorite current wm, then try
    >>> xprop and xwininfo on the window; *maybe* kdm will be kind enough to
    >>> have the answer. But I wouldnt recommend going that way.
    >>>
    >>> What exactly are you trying to accomplish?
    >>>

    >>
    >> I'm trying to let the user of my app to change and get coords of an sdl
    >> window.

    >
    > Still not clear because still the idea that the borders belong to the
    > window. They dont, they belong to the WM. An app should not be concerned
    > with that, unless it uses full-screen.
    >


    Yes of course, not the app, but the user of the app :-)
    I want to give to the user the ability to move the window (done with
    XMoveWindow, which working great) and the ability to get the window coords.

    If i move the window to 100,100 , if i read them i get 104, 122 :-/

    >> I've just found the _NET_FRAME_EXTENTS atom that seem to return
    >> size of borders
    >> ( http://standards.freedesktop.org/wm-...html#id2523626 )
    >>
    >> Now i must learn how to use atoms :-)

    >
    > Look in the source of xprop.
    >


    Yes, i've grab xprop sources, thanks



  6. Re: coords of a window under sdl

    Laurent Carlier wrote:
    > Michel Bardiaux wrote:
    >
    >> Laurent Carlier wrote:
    >>> Michel Bardiaux wrote:
    >>>
    >>>> Laurent Carlier wrote:
    >>>>> i'm using the following piece of code to know the windows coordinates :
    >>>>>
    >>>>> ---
    >>>>> ---
    >>>>>
    >>>>> But when the window is at 0,0 i get x = 5 and y = 22 (under kde) ! How
    >>>>> can i have real coordinates ? am i doing something wrong ?
    >>>>>
    >>>>> Thx
    >>>>>
    >>>> x=5 y=22 look very much like the coordinates on screen of the top left
    >>>> *inside* the window frame. And yes, getting the physical position and
    >>>> thicknesses *of* the window *frame* is often needed, often asked on the
    >>>> net, and practically impossible to do in a way that does not depend a
    >>>> lot on the window manager.
    >>>>
    >>>> If it's OK for you to be limited to your favorite current wm, then try
    >>>> xprop and xwininfo on the window; *maybe* kdm will be kind enough to
    >>>> have the answer. But I wouldnt recommend going that way.
    >>>>
    >>>> What exactly are you trying to accomplish?
    >>>>
    >>> I'm trying to let the user of my app to change and get coords of an sdl
    >>> window.

    >> Still not clear because still the idea that the borders belong to the
    >> window. They dont, they belong to the WM. An app should not be concerned
    >> with that, unless it uses full-screen.
    >>

    >
    > Yes of course, not the app, but the user of the app :-)
    > I want to give to the user the ability to move the window (done with
    > XMoveWindow, which working great) and the ability to get the window coords.
    >
    > If i move the window to 100,100 , if i read them i get 104, 122 :-/


    You're just lucky XMoveWindow works; the WM is allowed to do whatever it
    wants, including not moving the window at all! It is generally not a
    good idea to engage in a p***ing contest with the WM...

    >
    >>> I've just found the _NET_FRAME_EXTENTS atom that seem to return
    >>> size of borders
    >>> ( http://standards.freedesktop.org/wm-...html#id2523626 )
    >>>
    >>> Now i must learn how to use atoms :-)

    >> Look in the source of xprop.
    >>

    >
    > Yes, i've grab xprop sources, thanks
    >
    >



    --
    Michel Bardiaux
    R&D Director
    T +32 [0] 2 790 29 41
    F +32 [0] 2 790 29 02
    E mailto:mbardiaux@mediaxim.be

    Mediaxim NV/SA
    Vorstlaan 191 Boulevard du Souverain
    Brussel 1160 Bruxelles
    http://www.mediaxim.com/

+ Reply to Thread