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: Andreas Politz
Subject: bug#5721: Feature request: Function that returns absolute coordinates
Date: Fri, 04 Oct 2013 10:28:17 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

Eli Zaretskii <eliz@gnu.org> writes:

>> 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.

=== modified file 'src/window.c'
*** src/window.c        2013-10-02 12:08:27 +0000
--- src/window.c        2013-10-04 08:05:28 +0000
***************
*** 935,945 ****
                 WINDOW_RIGHT_EDGE_X (w), WINDOW_BOTTOM_EDGE_Y (w));
  }
  
  static void
! calc_absolute_offset (struct window *w, int *add_x, int *add_y)
  {
!   struct frame *f = XFRAME (w->frame);
    *add_y = f->top_pos;
  #ifdef FRAME_MENUBAR_HEIGHT
    *add_y += FRAME_MENUBAR_HEIGHT (f);
  #endif
--- 935,952 ----
                 WINDOW_RIGHT_EDGE_X (w), WINDOW_BOTTOM_EDGE_Y (w));
  }
  
+ #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 */
  
  DEFUN ("window-absolute-pixel-edges", Fwindow_absolute_pixel_edges,
         Swindow_absolute_pixel_edges, 0, 1, 0,
***************
*** 972,987 ****
  of just the text area, use `window-inside-absolute-pixel-edges'.  */)
    (Lisp_Object window)
  {
    register struct window *w = decode_valid_window (window);
    int add_x, add_y;
  
!   calc_absolute_offset (w, &add_x, &add_y);
  
    return list4i (WINDOW_LEFT_EDGE_X (w) + add_x,
                 WINDOW_TOP_EDGE_Y (w) + add_y,
                 WINDOW_RIGHT_EDGE_X (w) + add_x,
                 WINDOW_BOTTOM_EDGE_Y (w) + add_y);
  }
  
  DEFUN ("window-inside-edges", Fwindow_inside_edges, Swindow_inside_edges, 0, 
1, 0,
         doc: /* Return a list of the edge coordinates of WINDOW.
--- 986,1009 ----
  of just the text area, use `window-inside-absolute-pixel-edges'.  */)
    (Lisp_Object window)
  {
+ #if HAVE_WINDOW_SYSTEM
    register struct window *w = decode_valid_window (window);
+   struct frame *f = XFRAME (w->frame);
    int add_x, add_y;
  
!   if (FRAME_WINDOW_P (f))
!     {
!       calc_absolute_offset (f, &add_x, &add_y);
  
        return list4i (WINDOW_LEFT_EDGE_X (w) + add_x,
                       WINDOW_TOP_EDGE_Y (w) + add_y,
                       WINDOW_RIGHT_EDGE_X (w) + add_x,
                       WINDOW_BOTTOM_EDGE_Y (w) + add_y);
      }
+   else
+ #endif
+     return Fwindow_pixel_edges (window);
+ }
  
  DEFUN ("window-inside-edges", Fwindow_inside_edges, Swindow_inside_edges, 0, 
1, 0,
         doc: /* Return a list of the edge coordinates of WINDOW.
***************
*** 1053,1062 ****
  display margins, fringes, header line, and/or mode line.  */)
    (Lisp_Object window)
  {
!   register struct window *w = decode_live_window (window);
    int add_x, add_y;
  
!   calc_absolute_offset (w, &add_x, &add_y);
  
    return list4i ((WINDOW_BOX_LEFT_EDGE_X (w)
                  + WINDOW_LEFT_MARGIN_WIDTH (w)
--- 1075,1088 ----
  display margins, fringes, header line, and/or mode line.  */)
    (Lisp_Object window)
  {
! #if HAVE_WINDOW_SYSTEM
!   register struct window *w = decode_valid_window (window);
!   struct frame *f = XFRAME (w->frame);
    int add_x, add_y;
  
!   if (FRAME_WINDOW_P (f))
!     {
!       calc_absolute_offset (f, &add_x, &add_y);
  
        return list4i ((WINDOW_BOX_LEFT_EDGE_X (w)
                        + WINDOW_LEFT_MARGIN_WIDTH (w)
***************
*** 1069,1074 ****
--- 1095,1104 ----
                       (WINDOW_BOTTOM_EDGE_Y (w)
                        - WINDOW_MODE_LINE_HEIGHT (w) + add_y));
      }
+   else
+ #endif
+     return Fwindow_inside_pixel_edges (window);
+ }
  
  /* Test if the character at column X, row Y is within window W.
     If it is not, return ON_NOTHING;

-ap

reply via email to

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