Subject: Re: bug#5721: Feature request: Function that returns absolute coordinates

From: Jan Djärv <[email-masked]>
Date: Sun, 29 Sep 2013 17:59:04 +0200

29 sep 2013 kl. 12:26 skrev martin rudalics <[email-masked]>:

> > I'd like the request to be reopened, because the current function
> > `window-inside-absolute-pixel-edges' does not provide the requested
> > behaviour.
> 
> I think your analysis is correct but will leave it to Jan to decide how
> to proceed.
> 

I gave no opinion in the matter.  I think it is a mistake to let users access pixels.  It worked fine with X and no toolkit or Lucid/Motif.  But nowdays, window manager do strange things and so does toolkits (Gtk+ don't create separate windows for its widgets for example), so it is almost impossible to get right. 

	Jan D.

> > Suppose no fringes, and header-line.  All considerations for a GTK build.
> >
> > 0--------------------------------------*
> > |           display                    |
> > | A----------------------------+       |
> > | |      [email-masked]         +       |
> > | |-B------------------------+ +       |
> > | | |       toolbar          | |       |
> > | | +------------------------+ |       |
> > | | |       menubar          | |       |
> > | | C------------------------+ |       |
> > | | |                        | |       |
> > | | |       window           | |       |
> > | | |   D---------+          | |       |
> > | | |   | tooltip |          | |       |
> > | | |   +---------+          | |       |
> > | | +------------------------+ |       |
> > | *----------------------------*       |
> > |                                      |
> > *--------------------------------------*
> 
> Where did/do we put the internal borders of the frame?
> 
> > We have a buffer position D =
> > (D.x, D.y) in some window and want to display a tool-tip there. At the
> > moment,
> >
> >        (posn-x-y (posn-at-point))
> >
> > gives us a position relative to C, so we would need it's absolute
> > position.
> >
> > But `window-absolute-pixel-edges' gives the absolute position of
> >
> >     (C.x - (B.x - A.x), C.y - (B.y - A.y))
> >   = (A.x , C.y - (B.y - A.y)) ,
> >
> > that is, it does not account for the width and height (B - A) of the
> > window managers decorations.  Furthermore these sizes are unknown to the
> > lisp side, making it impossible to complete the desired task.
> 
> I'm not sure whether we can correctly retrieve the decorations always
> and everywhere.  But note that for maximized and full-screen frames
> there usually are no outer borders and with full-screen frames there's
> no titlebar either.  How does your patch handle these?
> 
> > So it seems to me that `window-absolute-pixel-edges' should return the
> > absolute position of C, such that the tool-tip (or other frame) may be
> > positioned at C + D.
> >
> > I noticed, that the frame struct already has members x_pixels_diff and
> > y_pixels_diff, such that
> >
> >     (x_pixels_diff, y_pixels_diff) = (B.x - A.x, B.y - A.y) ,
> >
> > such that we may compute C with this values.  So I propose extending
> > `calc_absolute_offset' by adding these pixel_diff values.  For GTK this
> > appears to be especially easy, since these diff values already account
> > for the tool-bar and menu-bar sizes.
> 
> martin
> 
>