From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andreas Politz Newsgroups: gmane.emacs.bugs Subject: bug#5721: Feature request: Function that returns absolute coordinates Date: Fri, 04 Oct 2013 10:28:17 +0200 Message-ID: <874n8xh23i.fsf@hochschule-trier.de> References: <4B9E4521.9030909@yahoo.co.jp> <87fvsoemnj.fsf@hochschule-trier.de> <52480060.7020309@gmx.at> <87mwmvtz26.fsf@hochschule-trier.de> <6CBDC204-ABA9-41D4-BD59-4B66DF82B9D9@swipnet.se> <524875AC.5020104@gmx.at> <87ioxe8dxp.fsf@hochschule-trier.de> <83hacycdan.fsf@gnu.org> <87eh8283jm.fsf@hochschule-trier.de> <83bo35cz1x.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1380875360 23565 80.91.229.3 (4 Oct 2013 08:29:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 4 Oct 2013 08:29:20 +0000 (UTC) Cc: 5721@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Oct 04 10:29:19 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VS0lC-0005o7-Nt for geb-bug-gnu-emacs@m.gmane.org; Fri, 04 Oct 2013 10:29:18 +0200 Original-Received: from localhost ([::1]:46886 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VS0lC-0007F1-9R for geb-bug-gnu-emacs@m.gmane.org; Fri, 04 Oct 2013 04:29:18 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51129) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VS0l3-0007E1-Ud for bug-gnu-emacs@gnu.org; Fri, 04 Oct 2013 04:29:15 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VS0ky-00057g-2p for bug-gnu-emacs@gnu.org; Fri, 04 Oct 2013 04:29:09 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:44854) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VS0kx-00057c-TT for bug-gnu-emacs@gnu.org; Fri, 04 Oct 2013 04:29:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1VS0kw-0007o3-89 for bug-gnu-emacs@gnu.org; Fri, 04 Oct 2013 04:29:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Andreas Politz Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 04 Oct 2013 08:29:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 5721 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 5721-submit@debbugs.gnu.org id=B5721.138087532329976 (code B ref 5721); Fri, 04 Oct 2013 08:29:02 +0000 Original-Received: (at 5721) by debbugs.gnu.org; 4 Oct 2013 08:28:43 +0000 Original-Received: from localhost ([127.0.0.1]:53146 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VS0kc-0007nP-FC for submit@debbugs.gnu.org; Fri, 04 Oct 2013 04:28:42 -0400 Original-Received: from gateway-b.fh-trier.de ([143.93.54.182]:52096) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VS0kZ-0007nG-Pn for 5721@debbugs.gnu.org; Fri, 04 Oct 2013 04:28:40 -0400 X-Virus-Scanned: by Amavisd-new + McAfee uvscan + ClamAV [Rechenzentrum Hochschule Trier] Original-Received: from luca (dslb-146-060-061-089.pools.arcor-ip.net [146.60.61.89]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: politza) by gateway-b.fh-trier.de (Postfix) with ESMTPSA id 7C9DA17B4CB; Fri, 4 Oct 2013 10:28:18 +0200 (CEST) Original-Received: from politza by luca with local (Exim 4.72) (envelope-from ) id 1VS0kD-0002mG-MZ; Fri, 04 Oct 2013 10:28:17 +0200 In-Reply-To: <83bo35cz1x.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 04 Oct 2013 09:47:38 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:78917 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii 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. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=window-absolute-pixel-v2.diff === 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; --=-=-= Content-Type: text/plain -ap --=-=-=--