Loading ...
Sorry, an error occurred while loading the content.

Re: [PATCH] Support mouse wheel scrolling of inactive windows in the terminal

Expand Messages
  • Bram Moolenaar
    ... OK. I do think users will be surprised that the behavior changes. But it becomes more consistent with the GUI. ... The Unix version of Vim has one binary
    Message 1 of 6 , Feb 25, 2013
    • 0 Attachment
      Brodie Rao wrote:

      > On Sun, Feb 24, 2013 at 12:40 PM, Bram Moolenaar <Bram@...> wrote:
      > >
      > > Brodie Rao wrote:
      > >
      > >> Support mouse wheel scrolling of inactive windows in the terminal
      > >
      > > Does this actually work for every type of terminal that supports the
      > > mouse wheel? Or only for some of them?
      >
      > Reading check_termcode() in src/term.c, I find the following:
      >
      > - For FEAT_MOUSE_GPM, FEAT_SYSMOUSE, FEAT_MOUSE_XTERM, FEAT_MOUSE_SGR
      > and FEAT_MOUSE_URXVT, all mouse events come with the mouse's position.
      >
      > - For FEAT_MOUSE_DEC, FEAT_MOUSE_JSB, FEAT_MOUSE_NET, and
      > FEAT_MOUSE_PTERM, the mouse wheel is not supported, so mouse wheel
      > events will never be sent.
      >
      > - According to src/os_msdos.c, DOS_MOUSE also doesn't support the mouse wheel.
      >
      > I think that covers everything.

      OK. I do think users will be surprised that the behavior changes.
      But it becomes more consistent with the GUI.

      > It's possible that there are some terminal emulators that don't set
      > the mouse position properly for mouse wheel events, but considering
      > all the protocols consider it a normal button press like any other
      > button, that seems unlikely.
      >
      > I did notice one issue in my patch that I'm not sure about: Is the
      > gui.in_use check necessary? If it's false, does Vim fall back to the
      > terminal, and if so, will it handle mouse events? If that's the case,
      > that check probably shouldn't be there.

      The Unix version of Vim has one binary that can run both in a terminal
      and as a GUI. You can switch from terminal to GUI with the ":gui"
      command. Thus we need a runtime check if it matters whether the GUI is
      running.

      --
      The budget process was invented by an alien race of sadistic beings who
      resemble large cats.
      (Scott Adams - The Dilbert principle)

      /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
      /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
      \\\ an exciting new programming language -- http://www.Zimbu.org ///
      \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

      --
      --
      You received this message from the "vim_dev" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php

      ---
      You received this message because you are subscribed to the Google Groups "vim_dev" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • Brodie Rao
      ... (and in the same check in src/normal.c) I don t think the gui.in_use check should be here. mouse_row and mouse_col will be set properly even if
      Message 2 of 6 , Feb 25, 2013
      • 0 Attachment
        On Mon, Feb 25, 2013 at 3:26 AM, Bram Moolenaar <Bram@...> wrote:
        >
        > Brodie Rao wrote:
        >
        >> On Sun, Feb 24, 2013 at 12:40 PM, Bram Moolenaar <Bram@...> wrote:
        >> >
        >> > Brodie Rao wrote:
        >> >
        >> >> Support mouse wheel scrolling of inactive windows in the terminal
        >> >
        >> > Does this actually work for every type of terminal that supports the
        >> > mouse wheel? Or only for some of them?
        >>
        >> Reading check_termcode() in src/term.c, I find the following:
        >>
        >> - For FEAT_MOUSE_GPM, FEAT_SYSMOUSE, FEAT_MOUSE_XTERM, FEAT_MOUSE_SGR
        >> and FEAT_MOUSE_URXVT, all mouse events come with the mouse's position.
        >>
        >> - For FEAT_MOUSE_DEC, FEAT_MOUSE_JSB, FEAT_MOUSE_NET, and
        >> FEAT_MOUSE_PTERM, the mouse wheel is not supported, so mouse wheel
        >> events will never be sent.
        >>
        >> - According to src/os_msdos.c, DOS_MOUSE also doesn't support the mouse wheel.
        >>
        >> I think that covers everything.
        >
        > OK. I do think users will be surprised that the behavior changes.
        > But it becomes more consistent with the GUI.
        >
        >> It's possible that there are some terminal emulators that don't set
        >> the mouse position properly for mouse wheel events, but considering
        >> all the protocols consider it a normal button press like any other
        >> button, that seems unlikely.
        >>
        >> I did notice one issue in my patch that I'm not sure about: Is the
        >> gui.in_use check necessary? If it's false, does Vim fall back to the
        >> terminal, and if so, will it handle mouse events? If that's the case,
        >> that check probably shouldn't be there.
        >
        > The Unix version of Vim has one binary that can run both in a terminal
        > and as a GUI. You can switch from terminal to GUI with the ":gui"
        > command. Thus we need a runtime check if it matters whether the GUI is
        > running.

        In this bit of code:

        > diff --git a/src/edit.c b/src/edit.c
        > --- a/src/edit.c
        > +++ b/src/edit.c
        > @@ -9139,9 +9139,13 @@ ins_mousescroll(dir)
        >
        > tpos = curwin->w_cursor;
        >
        > -# if defined(FEAT_GUI) && defined(FEAT_WINDOWS)
        > - /* Currently the mouse coordinates are only known in the GUI. */
        > - if (gui.in_use && mouse_row >= 0 && mouse_col >= 0)
        > +# ifdef FEAT_WINDOWS
        > + if (
        > +# ifdef FEAT_GUI
        > + gui.in_use &&
        > +# endif
        > + mouse_row >= 0 && mouse_col >= 0
        > + )
        > {
        > int row, col;

        (and in the same check in src/normal.c)

        I don't think the "gui.in_use" check should be here. mouse_row and
        mouse_col will be set properly even if gui.in_use is false, and
        mouse_find_win() and curwin should both work fine. If we did leave
        that check, you wouldn't be able to scroll inactive windows in the
        terminal with a GUI build that's running in the terminal.

        I'll send an updated patch that drops those two checks.

        --
        --
        You received this message from the "vim_dev" maillist.
        Do not top-post! Type your reply below the text you are replying to.
        For more information, visit http://www.vim.org/maillist.php

        ---
        You received this message because you are subscribed to the Google Groups "vim_dev" group.
        To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
        For more options, visit https://groups.google.com/groups/opt_out.
      • Brodie Rao
        # HG changeset patch # User Brodie Rao # Date 1361818381 28800 # Node ID 5b919bc9b3e89b342efa486d54ee211cbeb4260e # Parent
        Message 3 of 6 , Feb 25, 2013
        • 0 Attachment
          # HG changeset patch
          # User Brodie Rao <brodie@...>
          # Date 1361818381 28800
          # Node ID 5b919bc9b3e89b342efa486d54ee211cbeb4260e
          # Parent 8b86b69546a9ea9309ebf7d05e1d443457cd58d8
          Support mouse wheel scrolling of inactive windows in the terminal

          diff --git a/src/edit.c b/src/edit.c
          --- a/src/edit.c
          +++ b/src/edit.c
          @@ -9139,9 +9139,8 @@ ins_mousescroll(dir)

          tpos = curwin->w_cursor;

          -# if defined(FEAT_GUI) && defined(FEAT_WINDOWS)
          - /* Currently the mouse coordinates are only known in the GUI. */
          - if (gui.in_use && mouse_row >= 0 && mouse_col >= 0)
          +# ifdef FEAT_WINDOWS
          + if (mouse_row >= 0 && mouse_col >= 0)
          {
          int row, col;

          @@ -9191,7 +9190,7 @@ ins_mousescroll(dir)
          # endif
          }

          -# if defined(FEAT_GUI) && defined(FEAT_WINDOWS)
          +# ifdef FEAT_WINDOWS
          curwin->w_redr_status = TRUE;

          curwin = old_curwin;
          diff --git a/src/normal.c b/src/normal.c
          --- a/src/normal.c
          +++ b/src/normal.c
          @@ -4649,11 +4649,10 @@ nv_screengo(oap, dir, dist)
          nv_mousescroll(cap)
          cmdarg_T *cap;
          {
          -# if defined(FEAT_GUI) && defined(FEAT_WINDOWS)
          +# ifdef FEAT_WINDOWS
          win_T *old_curwin = curwin;

          - /* Currently we only get the mouse coordinates in the GUI. */
          - if (gui.in_use && mouse_row >= 0 && mouse_col >= 0)
          + if (mouse_row >= 0 && mouse_col >= 0)
          {
          int row, col;

          @@ -4698,7 +4697,7 @@ nv_mousescroll(cap)
          }
          # endif

          -# if defined(FEAT_GUI) && defined(FEAT_WINDOWS)
          +# ifdef FEAT_WINDOWS
          curwin->w_redr_status = TRUE;

          curwin = old_curwin;

          --
          --
          You received this message from the "vim_dev" maillist.
          Do not top-post! Type your reply below the text you are replying to.
          For more information, visit http://www.vim.org/maillist.php

          ---
          You received this message because you are subscribed to the Google Groups "vim_dev" group.
          To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
          For more options, visit https://groups.google.com/groups/opt_out.
        Your message has been successfully submitted and would be delivered to recipients shortly.