bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Eli Zaretskii
Subject: bug#5721: Feature request: Function that returns absolute coordinates
Date: Fri, 04 Oct 2013 11:55:23 +0300

> From: Andreas Politz <politza@hochschule-trier.de>
> Cc: jan.h.d@swipnet.se,  5721@debbugs.gnu.org
> Date: Fri, 04 Oct 2013 10:28:17 +0200
> 
> >> Should these functions (`window-absolute-pixel-edges' and
> >> `window-inside-absolute-pixel-edges') return nil in a terminal ?
> >
> > I see no reason to do that.  We do support pixel coordinates on a text
> > terminal, counting each column and row as one pixel.
> 
> Then they should probably return the same values as the non-absolute
> counterparts.

Yes, this sounds correct, thanks.

One more nit, about these fragments:

> + #ifdef HAVE_WINDOW_SYSTEM
>   static void
> ! calc_absolute_offset (struct frame *f, int *add_x, int *add_y)
>   {
> !   eassert (FRAME_WINDOW_P (f));
> ! 
>     *add_y = f->top_pos;
> + #ifdef HAVE_X_WINDOWS
> +   *add_y += FRAME_X_OUTPUT (f)->y_pixels_outer_diff;
> + #elif defined (HAVE_NTGUI)
> +   *add_y += f->y_pixels_diff;
> + #endif
>   #ifdef FRAME_MENUBAR_HEIGHT
>     *add_y += FRAME_MENUBAR_HEIGHT (f);
>   #endif
> ***************
> *** 951,961 ****
> --- 958,975 ----
>   #ifdef FRAME_NS_TITLEBAR_HEIGHT
>     *add_y += FRAME_NS_TITLEBAR_HEIGHT (f);
>   #endif
> + 
>     *add_x = f->left_pos;
> + #ifdef HAVE_X_WINDOWS
> +   *add_x += FRAME_X_OUTPUT (f)->x_pixels_outer_diff;
> + #elif defined (HAVE_NTGUI)
> +   *add_x += f->x_pixels_diff;
> + #endif
>   #ifdef FRAME_TOOLBAR_LEFT_WIDTH
>     *add_x += FRAME_TOOLBAR_LEFT_WIDTH (f);
>   #endif
>   }
> + #endif  /* HAVE_WINDOW_SYSTEM */

For the possibility that the same Emacs session can support several
different types of frames, it is better to check the frame type
at run time, not just rely on compile-time conditional.  Like this:

 #ifdef HAVE_X_WINDOWS
   if (FRAME_X_P (f))
     *add_y += FRAME_X_OUTPUT (f)->y_pixels_outer_diff;
   else
 #elif defined (HAVE_NTGUI)
   if (FRAME_W32_P (f))
     *add_y += f->y_pixels_diff;
 #endif

etc., you get the idea.  The above will work if the same session can
have both X and w32 frames, something that is currently impossible
(AFAIK), but is not unimaginable in principle.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]