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: Sat, 28 Sep 2013 22:06:40 +0200 Message-ID: <87fvsoemnj.fsf@hochschule-trier.de> References: <4B9E4521.9030909@yahoo.co.jp> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1380398839 23853 80.91.229.3 (28 Sep 2013 20:07:19 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 28 Sep 2013 20:07:19 +0000 (UTC) To: 5721@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Sep 28 22:07:21 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 1VQ0nR-0006dc-B5 for geb-bug-gnu-emacs@m.gmane.org; Sat, 28 Sep 2013 22:07:21 +0200 Original-Received: from localhost ([::1]:42487 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VQ0nQ-0004EI-8v for geb-bug-gnu-emacs@m.gmane.org; Sat, 28 Sep 2013 16:07:20 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49701) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VQ0nG-0004EC-9f for bug-gnu-emacs@gnu.org; Sat, 28 Sep 2013 16:07:17 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VQ0n8-0006t5-Up for bug-gnu-emacs@gnu.org; Sat, 28 Sep 2013 16:07:10 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:35319) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VQ0n8-0006sz-RE for bug-gnu-emacs@gnu.org; Sat, 28 Sep 2013 16:07:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1VQ0n8-00057Y-Ej for bug-gnu-emacs@gnu.org; Sat, 28 Sep 2013 16:07:02 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: <4B9E4521.9030909@yahoo.co.jp> Resent-From: Andreas Politz Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 28 Sep 2013 20:07: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.138039882019676 (code B ref 5721); Sat, 28 Sep 2013 20:07:02 +0000 Original-Received: (at 5721) by debbugs.gnu.org; 28 Sep 2013 20:07:00 +0000 Original-Received: from localhost ([127.0.0.1]:43612 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VQ0n5-00057H-Dt for submit@debbugs.gnu.org; Sat, 28 Sep 2013 16:06:59 -0400 Original-Received: from gateway-a.fh-trier.de ([143.93.54.181]:59141) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VQ0n3-000579-HI for 5721@debbugs.gnu.org; Sat, 28 Sep 2013 16:06:58 -0400 X-Virus-Scanned: by Amavisd-new + McAfee uvscan + ClamAV [Rechenzentrum Hochschule Trier] Original-Received: from luca (dslb-178-004-164-059.pools.arcor-ip.net [178.4.164.59]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: politza) by gateway-a.fh-trier.de (Postfix) with ESMTPSA id 363B41761162 for <5721@debbugs.gnu.org>; Sat, 28 Sep 2013 22:06:41 +0200 (CEST) Original-Received: from politza by luca with local (Exim 4.72) (envelope-from ) id 1VQ0mm-0004FY-Go for 5721@debbugs.gnu.org; Sat, 28 Sep 2013 22:06:40 +0200 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:78784 Archived-At: --=-=-= Content-Type: text/plain I'd like the request to be reopened, because the current function `window-inside-absolute-pixel-edges' does not provide the requested behaviour. Suppose no fringes, and header-line. All considerations for a GTK build. 0--------------------------------------* | display | | A----------------------------+ | | | emacs@foo.bar + | | |-B------------------------+ + | | | | toolbar | | | | | +------------------------+ | | | | | menubar | | | | | C------------------------+ | | | | | | | | | | | window | | | | | | D---------+ | | | | | | | tooltip | | | | | | | +---------+ | | | | | +------------------------+ | | | *----------------------------* | | | *--------------------------------------* 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. 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. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=winabs.diff === modified file 'src/window.c' *** src/window.c 2013-09-20 15:34:36 +0000 --- src/window.c 2013-09-28 19:53:08 +0000 *************** *** 939,945 **** 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 --- 939,946 ---- calc_absolute_offset (struct window *w, int *add_x, int *add_y) { struct frame *f = XFRAME (w->frame); ! *add_y = f->top_pos + f->y_pixels_diff; ! #ifndef USE_GTK #ifdef FRAME_MENUBAR_HEIGHT *add_y += FRAME_MENUBAR_HEIGHT (f); #endif *************** *** 951,960 **** #ifdef FRAME_NS_TITLEBAR_HEIGHT *add_y += FRAME_NS_TITLEBAR_HEIGHT (f); #endif ! *add_x = f->left_pos; #ifdef FRAME_TOOLBAR_LEFT_WIDTH *add_x += FRAME_TOOLBAR_LEFT_WIDTH (f); #endif } DEFUN ("window-absolute-pixel-edges", Fwindow_absolute_pixel_edges, --- 952,965 ---- #ifdef FRAME_NS_TITLEBAR_HEIGHT *add_y += FRAME_NS_TITLEBAR_HEIGHT (f); #endif ! #endif ! ! *add_x = f->left_pos + f->x_pixels_diff; ! #ifndef USE_GTK #ifdef FRAME_TOOLBAR_LEFT_WIDTH *add_x += FRAME_TOOLBAR_LEFT_WIDTH (f); #endif + #endif } DEFUN ("window-absolute-pixel-edges", Fwindow_absolute_pixel_edges, --=-=-= Content-Type: text/plain After applying the patch, the following function displays a tool-tip below the cursor in the current buffer, which is something that is not possible at the moment (without referring to e.g. xwininfo as the OP explained). (defun tooltip-below-point (msg) (let* ((win-pos (posn-x-y (posn-at-point))) (offset (let ((e (window-inside-absolute-pixel-edges))) (cons (car e) (cadr e)))) (char-y-offset (cdr (posn-object-width-height (posn-at-point)))) (abs-pos (cons (+ (car win-pos) (car offset)) (+ (cdr win-pos) (cdr offset) char-y-offset))) (tooltip-frame-parameters `((left . ,(car abs-pos)) (top . ,(cdr abs-pos))))) (tooltip-show msg))) -ap --=-=-=--