From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ergus Newsgroups: gmane.emacs.devel Subject: Re: Mouse information in xterm. Date: Mon, 14 Sep 2020 20:13:11 +0200 Message-ID: <20200914181311.fd56gqwn4ntytkqn@Ergus> References: <20200914113816.562wa5cwqxdtwnmy.ref@Ergus> <20200914113816.562wa5cwqxdtwnmy@Ergus> <83r1r49yc2.fsf@gnu.org> <20200914162710.c2ic5szp34tvwtib@Ergus> <83h7s09s98.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12056"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Sep 14 20:14:36 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kHszs-00033S-M8 for ged-emacs-devel@m.gmane-mx.org; Mon, 14 Sep 2020 20:14:36 +0200 Original-Received: from localhost ([::1]:58288 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kHszr-0005YP-Kv for ged-emacs-devel@m.gmane-mx.org; Mon, 14 Sep 2020 14:14:35 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58234) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kHsyj-00057J-SW for emacs-devel@gnu.org; Mon, 14 Sep 2020 14:13:25 -0400 Original-Received: from sonic308-2.consmr.mail.bf2.yahoo.com ([74.6.130.41]:39547) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kHsyg-0004ch-3Q for emacs-devel@gnu.org; Mon, 14 Sep 2020 14:13:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1600107201; bh=LvUOLbpO+h4NIsqSA/KOQcUD39O3VkWamMAYHsXpIpY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From:Subject; b=WwIguLInw4z6ILx3clI5R2Hg7f7oKaribPbIdywfFgNxc6zXzlMBPnDde3LUBs8bS9fuGFDy0PMGBynCfx3gtYld9QZEBPwBSQVSpPQQl/gpxW652roARSvIcd/cbFd4KtoX4SjLv+PhqiT6awC86fgbVQATTEI3c9cR8Qh/hXd7dPfgAEeokRhxt7gl7FB3w7cNSpspfoXCdKXCOdNsvOsJN/GSck7aEGI1mhv8BuVSMULplaIQircApItn6EoOB7tVYUpEHM0Z2JtZ4NG3GJ4waxEoiOpz0Ncryly84BoeAsjTs6MJyrK4ZABqQUdTt/fyilJ8ZctbCSVY7EnVYg== X-YMail-OSG: Vsxhw.sVM1n0RzqvbA38G6DJQ2bZO_ATvsIZjJJsbACtJIn5X.EVzlB3L1fNQQY aKAsTd0MR6OHuhRW3BcycJmDoWd4tIPPA9s6XeiGU85UUUEFPuKMG8OsGcXHSzKsiitINnMNG58O Id9cHAsuMVq2z8bvUHE_zTjmEJbyth.v57luFXO7_q1IJP6wPQP7z8943UEJjnQ2b.ya6W8jMI_c ROYcxq75np1S74RHriC5kFsUHh5p3ZKoGCWhbe1LTuiT4Xssj1AN5SfxFphH1PM6u8ncePloyzE4 EuBoVQontPn99sWkyzIsCce7G2Xv8rqTNmm0t8r8c0JRej5NwOFQvq3ZvIFrpGIVeHWrYdrVvNma 5BDDaAL68y0m1wGjZlVIbC3xsq45ZVdvrOSPAmjuEXTwYCVw5TsaCd.885dlsz6atBQr9raTPskn R9dtd2m59zjn27BSPHewIgaTF0DFVARHt9Rsh6f_.M1N6bAGWEKKJ1TGpEwnbWs75RnPugoWuSOa Zpu5VFNtmv9_tXMiMrtcxNjSidYpzwwqQ8I5O5HciqUjz1ehmB2pb2NIjkRKXbEPqMpu5KxMaoUJ Ts_u8MazROPlJdU3VLhFbCrHZouZE.Qhlqa._WK_cMA_ZUSXgnD5Zd8OXK9rxkIW.IgtU.kM2wXY 9.bAvzz.w4Pc9MYLP8F6IzgUrBJnR.bx.pzqtfIT_HnztvXWIsb1VMyNp0PSVJlIykQWP6aDuwQ4 mB1yRZnWakcS8yCHptGj8ExmbmKVR4wxuFOunkrdJLmwEqCQ0XtZMCaAyNoZPIcmxbkm6VGWGQ5q qZyj4ymRhI359VhjnBIUuKU5nWC6O2WwfiXmkL8aox Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic308.consmr.mail.bf2.yahoo.com with HTTP; Mon, 14 Sep 2020 18:13:21 +0000 Original-Received: by smtp414.mail.ir2.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID 0d0e00aec3ea58bfe00b67c0a981de9f; Mon, 14 Sep 2020 18:13:17 +0000 (UTC) Content-Disposition: inline In-Reply-To: <83h7s09s98.fsf@gnu.org> X-Mailer: WebService/1.1.16583 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.aol Apache-HttpAsyncClient/4.1.4 (Java/11.0.7) Received-SPF: pass client-ip=74.6.130.41; envelope-from=spacibba@aol.com; helo=sonic308-2.consmr.mail.bf2.yahoo.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/14 12:27:22 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:255682 Archived-At: On Mon, Sep 14, 2020 at 08:34:43PM +0300, Eli Zaretskii wrote: >> Date: Mon, 14 Sep 2020 18:27:10 +0200 >> From: Ergus >> Cc: emacs-devel@gnu.org >> >> The menu part is just how I observed the issue. The problem is somewhere >> else; handle_one_term_event is never called (at least for me) either >> when moving the cursor, or the mouse or clicking here and there. So the >> variables last_mouse_x and last_mouse_y are not updated. >> >> So far I observe that handle_one_term_event is called in a single place >> in the code, but the condition to enter the "if" around is never true at >> least for me. >> >> I tried to create the x-dialog from the scratch buffer. The code works >> as expected in gui, but in xterm I see this problem. >> >> I just tried this in xterm: >> >> (x-popup-dialog t '("Dialog" "Value1" "Value")) >> >> And the dialog appears either in (0,0) or in the center of the screen, >> but not related with the mouse or cursor positions. >> >> There is another function that updated last_mouse_x and last_mouse_y, >> but all it's code is commented. > >I'm sorry, I still don't understand what are the issues that bother >you. Are you trying to pop up a menu from the minibuffer, as in the >above x-popup-dialog call? And all the rest of your questions are >just your attempt to understand why x-popup-dialog doesn't work as you >expected? Or are you after something else? > >IOW, let me be blunt and ask why do you care what are last_mouse_x and >last_mouse_y, and which code sets them? Hi Eli: When we call x-popup-dialog with t as the first parameter. The function x_popup_menu_1 tries to get the cursor/mouse position calling term_mouse_position. (As the documentation says) The issue is that term_mouse_position always report (0,0) as the current position independently of the cursor and mouse actual positions because it just copies the values in last_mouse_x and last_mouse_y which are zero because nobody updated them, see. ``` static void term_mouse_position (struct frame **fp, int insist, Lisp_Object *bar_window, enum scroll_bar_part *part, Lisp_Object *x, Lisp_Object *y, Time *timeptr) { *fp = SELECTED_FRAME (); (*fp)->mouse_moved = 0; *bar_window = Qnil; *part = scroll_bar_above_handle; XSETINT (*x, last_mouse_x); XSETINT (*y, last_mouse_y); *timeptr = current_Time (); } ``` I tried the code I sent you before in a normal buffer with C-x C-e and it works as expected in gui. The problem is terminal specific because of what I explain. The only function that modifies those variable is: ``` static bool term_mouse_movement (struct frame *frame, Gpm_Event *event) { /* Has the mouse moved off the glyph it was on at the last sighting? */ if (event->x != last_mouse_x || event->y != last_mouse_y) { frame->mouse_moved = 1; note_mouse_highlight (frame, event->x, event->y); /* Remember which glyph we're now on. */ last_mouse_x = event->x; last_mouse_y = event->y; return 1; } return 0; } ``` which is called in this stack: term_mouse_movement handle_one_term_event tty_read_avail_input tty_read_avail_input has a condition if (gpm_tty == tty) that in my case always prevent to call handle_one_term_event. I tried typing, moving the mouse, clicking, with all the buttons and the break point never crosses the it. So I am not sure when is supposed to be called handle_one_term_event to update the position values. The other function touching those variables should be term_mouse_moveto in term.c but all it's internal code is commented. It is called in set-mouse-position.