Subject: bug#73838: 31.0.50; Problems in note_mouse_highlight if -nw

From: Eli Zaretskii <[email-masked]>
Date: Wed, 16 Oct 2024 18:38:05 +0300

> From: Gerd Möllmann <[email-masked]>
> Date: Wed, 16 Oct 2024 16:19:53 +0200
> 
> I'd like to propose a change like in the attached patch (from my tty
> child frames branch). It fixes the case I mentioned above.

I'd like to understand why these changes are needed.  Could you please
elaborate on each and every change?

>    if (EQ (window, f->menu_bar_window))
>      {
> -      cursor = FRAME_OUTPUT_DATA (f)->nontext_cursor;
> +      if (FRAME_WINDOW_P (f))
> +	cursor = FRAME_OUTPUT_DATA (f)->nontext_cursor;

Can a TTY frame have a menu-bar window?  AFAIK, a menu bar is just a
frame glyph row on TTY frames, it is not a window.

>    if (EQ (window, f->tab_bar_window))
>      {
>        note_tab_bar_highlight (f, x, y);
> -      if (tab_bar__dragging_in_progress)
> -	  cursor = FRAME_OUTPUT_DATA (f)->hand_cursor;
> -      else
> -	cursor = FRAME_OUTPUT_DATA (f)->nontext_cursor;
> +      if (FRAME_WINDOW_P (f))
> +	{
> +	  if (tab_bar__dragging_in_progress)
> +	    cursor = FRAME_OUTPUT_DATA (f)->hand_cursor;
> +	  else
> +	    cursor = FRAME_OUTPUT_DATA (f)->nontext_cursor;
> +	}

Same question here about tab-bar window.

>    if (EQ (window, f->tool_bar_window))
>      {
>        note_tool_bar_highlight (f, x, y);
> -      cursor = FRAME_OUTPUT_DATA (f)->nontext_cursor;
> +      if (FRAME_WINDOW_P (f))
> +	cursor = FRAME_OUTPUT_DATA (f)->nontext_cursor;
>        goto set_cursor;

Same question here about tool-bar window.

>  #ifdef HAVE_WINDOW_SYSTEM
>        if (part == ON_LEFT_MARGIN || part == ON_RIGHT_MARGIN)
>  	{
> -	  cursor = FRAME_OUTPUT_DATA (f)->nontext_cursor;
> +	  if (FRAME_WINDOW_P (f))
> +	    cursor = FRAME_OUTPUT_DATA (f)->nontext_cursor;

This part I could understand.

>  #ifdef HAVE_WINDOW_SYSTEM
>    if (part == ON_VERTICAL_BORDER)
>      {
> -      cursor = FRAME_OUTPUT_DATA (f)->horizontal_drag_cursor;
> +      if (FRAME_WINDOW_P (f))
> +	cursor = FRAME_OUTPUT_DATA (f)->horizontal_drag_cursor;

Do we have vertical borders on TTY frames?  If yes, this is also
understood.

>    else if (part == ON_RIGHT_DIVIDER)
>      {
> -      cursor = FRAME_OUTPUT_DATA (f)->horizontal_drag_cursor;
> +      if (FRAME_WINDOW_P (f))
> +	cursor = FRAME_OUTPUT_DATA (f)->horizontal_drag_cursor;
>        help_echo_string = build_string ("drag-mouse-1: resize");
>        goto set_cursor;

Do we have right dividers on TTY frames?

> @@ -36244,7 +36253,8 @@ note_mouse_highlight (struct frame *f, int x, int y)
>  	|| minibuf_level
>  	|| NILP (Vresize_mini_windows))
>        {
> -	cursor = FRAME_OUTPUT_DATA (f)->vertical_drag_cursor;
> +	if (FRAME_WINDOW_P (f))
> +	  cursor = FRAME_OUTPUT_DATA (f)->vertical_drag_cursor;
>  	help_echo_string = build_string ("drag-mouse-1: resize");

Same question about bottom dividers as above about right dividers.

>    else if (part == ON_LEFT_FRINGE || part == ON_RIGHT_FRINGE)
>      {
> -      cursor = FRAME_OUTPUT_DATA (f)->nontext_cursor;
> +      if (FRAME_WINDOW_P (f))
> +	cursor = FRAME_OUTPUT_DATA (f)->nontext_cursor;

How can fringes happen on a TTY frame?

>    else if (part == ON_VERTICAL_SCROLL_BAR
>  	   || part == ON_HORIZONTAL_SCROLL_BAR)
> -    cursor = FRAME_OUTPUT_DATA (f)->nontext_cursor;
> -  else
> +    {
> +      if (FRAME_WINDOW_P (f))
> +	cursor = FRAME_OUTPUT_DATA (f)->nontext_cursor;
> +    }
> +  else if (FRAME_WINDOW_P (f))
>      cursor = FRAME_OUTPUT_DATA (f)->text_cursor;
>  #endif

How can scroll bars happen on TTY frames?