all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Mouse information in xterm.
       [not found] <20200914113816.562wa5cwqxdtwnmy.ref@Ergus>
@ 2020-09-14 11:38 ` Ergus
  2020-09-14 15:23   ` Eli Zaretskii
  0 siblings, 1 reply; 9+ messages in thread
From: Ergus @ 2020-09-14 11:38 UTC (permalink / raw)
  To: emacs-devel

Hi I have a question that I am not sure if this is a bug or a feature.

I have been playing with x-popup-menu today and I noticed that in
terminal, when we pass t as the first parameter the popup appears in
position (0, 0) which is wrong.

I debugged the C code and it seems that this position is expected to be
computed in x_popup_menu_1 calling:

mouse_position_hook which is a pointer to term_mouse_position and the
vales are taken there from last_mouse_x and last_mouse_y.

The issue is that those values are updated only in term_mouse_movement
which is called in handle_one_term_event but that function never
triggers my gdb.

Is this somehow intended and a limitation of the terminal interface??




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Mouse information in xterm.
  2020-09-14 11:38 ` Mouse information in xterm Ergus
@ 2020-09-14 15:23   ` Eli Zaretskii
  2020-09-14 16:27     ` Ergus
  0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2020-09-14 15:23 UTC (permalink / raw)
  To: Ergus; +Cc: emacs-devel

> Date: Mon, 14 Sep 2020 13:38:16 +0200
> From: Ergus <spacibba@aol.com>
> 
> I have been playing with x-popup-menu today and I noticed that in
> terminal, when we pass t as the first parameter the popup appears in
> position (0, 0) which is wrong.
> 
> I debugged the C code and it seems that this position is expected to be
> computed in x_popup_menu_1 calling:
> 
> mouse_position_hook which is a pointer to term_mouse_position and the
> vales are taken there from last_mouse_x and last_mouse_y.
> 
> The issue is that those values are updated only in term_mouse_movement
> which is called in handle_one_term_event but that function never
> triggers my gdb.
> 
> Is this somehow intended and a limitation of the terminal interface??

It's hard to answer your questions, because you didn't describe what
you tried to do.  For starters, did you invoke and navigate the menus
with a mouse or with a keyboard?



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Mouse information in xterm.
  2020-09-14 15:23   ` Eli Zaretskii
@ 2020-09-14 16:27     ` Ergus
  2020-09-14 17:34       ` Eli Zaretskii
  0 siblings, 1 reply; 9+ messages in thread
From: Ergus @ 2020-09-14 16:27 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

On Mon, Sep 14, 2020 at 06:23:25PM +0300, Eli Zaretskii wrote:
>> Date: Mon, 14 Sep 2020 13:38:16 +0200
>> From: Ergus <spacibba@aol.com>
>>
>> I have been playing with x-popup-menu today and I noticed that in
>> terminal, when we pass t as the first parameter the popup appears in
>> position (0, 0) which is wrong.
>>
>> I debugged the C code and it seems that this position is expected to be
>> computed in x_popup_menu_1 calling:
>>
>> mouse_position_hook which is a pointer to term_mouse_position and the
>> vales are taken there from last_mouse_x and last_mouse_y.
>>
>> The issue is that those values are updated only in term_mouse_movement
>> which is called in handle_one_term_event but that function never
>> triggers my gdb.
>>
>> Is this somehow intended and a limitation of the terminal interface??
>
>It's hard to answer your questions, because you didn't describe what
>you tried to do.  For starters, did you invoke and navigate the menus
>with a mouse or with a keyboard?
>
Hi Eli:

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.

Best,
Ergus



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Mouse information in xterm.
  2020-09-14 16:27     ` Ergus
@ 2020-09-14 17:34       ` Eli Zaretskii
  2020-09-14 18:13         ` Ergus
  0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2020-09-14 17:34 UTC (permalink / raw)
  To: Ergus; +Cc: emacs-devel

> Date: Mon, 14 Sep 2020 18:27:10 +0200
> From: Ergus <spacibba@aol.com>
> 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?



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Mouse information in xterm.
  2020-09-14 17:34       ` Eli Zaretskii
@ 2020-09-14 18:13         ` Ergus
  2020-09-14 18:56           ` Eli Zaretskii
  0 siblings, 1 reply; 9+ messages in thread
From: Ergus @ 2020-09-14 18:13 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

On Mon, Sep 14, 2020 at 08:34:43PM +0300, Eli Zaretskii wrote:
>> Date: Mon, 14 Sep 2020 18:27:10 +0200
>> From: Ergus <spacibba@aol.com>
>> 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.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Mouse information in xterm.
  2020-09-14 18:13         ` Ergus
@ 2020-09-14 18:56           ` Eli Zaretskii
  2020-09-14 19:04             ` Ergus
  0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2020-09-14 18:56 UTC (permalink / raw)
  To: Ergus; +Cc: emacs-devel

> Date: Mon, 14 Sep 2020 20:13:11 +0200
> From: Ergus <spacibba@aol.com>
> Cc: emacs-devel@gnu.org
> 
> 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.

last_mouse_x and last_mouse_y will change only if you use GPM mouse on
the terminal.  Otherwise, these variables will remain zero on
GNU/Linux.  So what you see is expected unless you use GPM (do you?).

The doc string of x-popup-dialog says that if POSITION is t, then the
dialog appears at the center of the selected frame.  So what you see
is exactly what the documentation says, and I don't understand what is
the problem you are trying to solve, or why POSITION being t is
important to you, or where you expected or wanted the dialog to pop up
or why there.  Please elaborate, as I feel we are talking past each
other.

I see the same on a GUI frame, btw, so I also don't understand what
"works as expected in gui" for you.

What am I missing?



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Mouse information in xterm.
  2020-09-14 18:56           ` Eli Zaretskii
@ 2020-09-14 19:04             ` Ergus
  2020-09-14 19:14               ` Eli Zaretskii
  0 siblings, 1 reply; 9+ messages in thread
From: Ergus @ 2020-09-14 19:04 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

On Mon, Sep 14, 2020 at 09:56:37PM +0300, Eli Zaretskii wrote:
>> Date: Mon, 14 Sep 2020 20:13:11 +0200
>> From: Ergus <spacibba@aol.com>
>> Cc: emacs-devel@gnu.org
>>
>> 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.
>
>last_mouse_x and last_mouse_y will change only if you use GPM mouse on
>the terminal.  Otherwise, these variables will remain zero on
>GNU/Linux.  So what you see is expected unless you use GPM (do you?).
>
>The doc string of x-popup-dialog says that if POSITION is t, then the
>dialog appears at the center of the selected frame.  So what you see
>is exactly what the documentation says, and I don't understand what is
>the problem you are trying to solve, or why POSITION being t is
>important to you, or where you expected or wanted the dialog to pop up
>or why there.  Please elaborate, as I feel we are talking past each
>other.
>
>I see the same on a GUI frame, btw, so I also don't understand what
>"works as expected in gui" for you.
>
>What am I missing?
>
x-popup-menu manual says:

If position is t, it means to use the current mouse position (or the
top-left corner of the frame if the mouse is not available on a text
terminal)

The part of "if the mouse is not available on a text terminal" then
doesn't apply to xterm with xterm-mouse-mode? 



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Mouse information in xterm.
  2020-09-14 19:04             ` Ergus
@ 2020-09-14 19:14               ` Eli Zaretskii
  2020-09-14 19:45                 ` Ergus
  0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2020-09-14 19:14 UTC (permalink / raw)
  To: Ergus; +Cc: emacs-devel

> Date: Mon, 14 Sep 2020 21:04:53 +0200
> From: Ergus <spacibba@aol.com>
> Cc: emacs-devel@gnu.org
> 
> On Mon, Sep 14, 2020 at 09:56:37PM +0300, Eli Zaretskii wrote:
> >> Date: Mon, 14 Sep 2020 20:13:11 +0200
> >> From: Ergus <spacibba@aol.com>
> >> Cc: emacs-devel@gnu.org
> >>
> >> 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.
> >
> >last_mouse_x and last_mouse_y will change only if you use GPM mouse on
> >the terminal.  Otherwise, these variables will remain zero on
> >GNU/Linux.  So what you see is expected unless you use GPM (do you?).
> >
> >The doc string of x-popup-dialog says that if POSITION is t, then the
> >dialog appears at the center of the selected frame.  So what you see
> >is exactly what the documentation says, and I don't understand what is
> >the problem you are trying to solve, or why POSITION being t is
> >important to you, or where you expected or wanted the dialog to pop up
> >or why there.  Please elaborate, as I feel we are talking past each
> >other.
> >
> >I see the same on a GUI frame, btw, so I also don't understand what
> >"works as expected in gui" for you.
> >
> >What am I missing?
> >
> x-popup-menu manual says:

Are we talking about x-popup-menu or x-popup-dialog?  You talked about
the latter in all your messages.

So I'm still confused...

> The part of "if the mouse is not available on a text terminal" then
> doesn't apply to xterm with xterm-mouse-mode? 

Indeed, it doesn't.  Because AFAIK no one has yet adapted the TTY
menus and dialogs to xterm-mouse-mode.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Mouse information in xterm.
  2020-09-14 19:14               ` Eli Zaretskii
@ 2020-09-14 19:45                 ` Ergus
  0 siblings, 0 replies; 9+ messages in thread
From: Ergus @ 2020-09-14 19:45 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel



On September 14, 2020 9:14:15 PM GMT+02:00, Eli Zaretskii <eliz@gnu.org> wrote:
>> Date: Mon, 14 Sep 2020 21:04:53 +0200
>> From: Ergus <spacibba@aol.com>
>> Cc: emacs-devel@gnu.org
>> 
>> On Mon, Sep 14, 2020 at 09:56:37PM +0300, Eli Zaretskii wrote:
>> >> Date: Mon, 14 Sep 2020 20:13:11 +0200
>> >> From: Ergus <spacibba@aol.com>
>> >> Cc: emacs-devel@gnu.org
>> >>
>> >> 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.
>> >
>> >last_mouse_x and last_mouse_y will change only if you use GPM mouse
>on
>> >the terminal.  Otherwise, these variables will remain zero on
>> >GNU/Linux.  So what you see is expected unless you use GPM (do
>you?).
>> >
>> >The doc string of x-popup-dialog says that if POSITION is t, then
>the
>> >dialog appears at the center of the selected frame.  So what you see
>> >is exactly what the documentation says, and I don't understand what
>is
>> >the problem you are trying to solve, or why POSITION being t is
>> >important to you, or where you expected or wanted the dialog to pop
>up
>> >or why there.  Please elaborate, as I feel we are talking past each
>> >other.
>> >
>> >I see the same on a GUI frame, btw, so I also don't understand what
>> >"works as expected in gui" for you.
>> >
>> >What am I missing?
>> >
>> x-popup-menu manual says:
>
>Are we talking about x-popup-menu or x-popup-dialog?  You talked about
>the latter in all your messages.
>
>So I'm still confused...
>
Sorry I confused them in the mail because in the backend is the same code. The issue is also the same. But its my fault.

>> The part of "if the mouse is not available on a text terminal" then
>> doesn't apply to xterm with xterm-mouse-mode? 
>
>Indeed, it doesn't.  Because AFAIK no one has yet adapted the TTY
>menus and dialogs to xterm-mouse-mode.

Ohh, bad news. 

-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-09-14 19:45 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20200914113816.562wa5cwqxdtwnmy.ref@Ergus>
2020-09-14 11:38 ` Mouse information in xterm Ergus
2020-09-14 15:23   ` Eli Zaretskii
2020-09-14 16:27     ` Ergus
2020-09-14 17:34       ` Eli Zaretskii
2020-09-14 18:13         ` Ergus
2020-09-14 18:56           ` Eli Zaretskii
2020-09-14 19:04             ` Ergus
2020-09-14 19:14               ` Eli Zaretskii
2020-09-14 19:45                 ` Ergus

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.