Dear rxvt-unicode,

The attached patch allows the user of urxvt to forbid mouse reporting
even if an application requests it.

This can be useful because some applications (such as aptitude) which
use terminal mouse reporting seem to have no easy way to disable this
in their config file.  After this patch, just echo $'\e[?1062h' and
then run the application, and it will believe that your terminal does
not have mouse reporting.

The patch is starting from the rxvt-unicode-9.07 release.  You may
need to make alldoc after applying the patch.

Ambrus
diff --git a/doc/rxvt.7.pod b/doc/rxvt.7.pod
index 2e48b30..4d43bd0 100644
--- a/doc/rxvt.7.pod
+++ b/doc/rxvt.7.pod
@@ -1991,6 +1991,15 @@ X<Priv66>
 
 =end table
 
+=item B<< C<Pm = 1062> >>
+
+=begin table
+
+	B<< C<h> >>	Forbid enabling mouse reporting modes: trying to turn off mouse reporting private modes will have no effect
+	B<< C<l> >>	Allow enabling mouse reporting modes
+
+=end table
+
 =item B<< C<Pm = 2004> >>
 
 =begin table
@@ -2000,6 +2009,15 @@ X<Priv66>
 
 =end table
 
+=item B<< C<Pm = 2007> >> (X11 xterm) I<unimplemented>
+
+=begin table
+
+	B<< C<h> >>	Report mouse position if mouse dragged off the edge of the window
+	B<< C<l> >>	Report mouse position only inside window
+
+=end table
+
 =back
 
 =back
diff --git a/src/command.C b/src/command.C
index 21062b1..f6ca4df 100644
--- a/src/command.C
+++ b/src/command.C
@@ -3550,8 +3550,8 @@ rxvt_term::process_xterm_seq (int op, char *str, char resp)
 /*{{{ process DEC private mode sequences `ESC [ ? Ps mode' */
 /*
  * mode can only have the following values:
- *      'l' = low
- *      'h' = high
+ *      0   = low
+ *      1   = high
  *      's' = save
  *      'r' = restore
  *      't' = toggle
@@ -3629,7 +3629,9 @@ rxvt_term::process_terminal_mode (int mode, int priv UNUSED, unsigned int nargs,
                  // 1048 save and restore cursor
                   { 1049, PrivMode_Screen }, /* xterm extension, clear screen on ti rather than te */
                  // 1051, 1052, 1060, 1061 keyboard emulation NYI
+                  { 1062, PrivMode_MouseForbid },
                   { 2004, PrivMode_BracketPaste },
+                 // 2007 report mouse drags off edge
                 };
 
   if (nargs == 0)
@@ -3704,6 +3706,8 @@ rxvt_term::process_terminal_mode (int mode, int priv UNUSED, unsigned int nargs,
             case 9:			/* X10 mouse reporting */
               if (state)		/* orthogonal */
                 priv_modes &= ~(PrivMode_MouseX11|PrivMode_MouseBtnEvent|PrivMode_MouseAnyEvent);
+              if (priv_modes & PrivMode_MouseForbid)
+                priv_modes &= ~PrivMode_MouseX10;
               break;
 #ifdef scrollBar_esc
             case scrollBar_esc:
@@ -3727,10 +3731,14 @@ rxvt_term::process_terminal_mode (int mode, int priv UNUSED, unsigned int nargs,
             case 1000:		/* X11 mouse reporting */
               if (state)		/* orthogonal */
                 priv_modes &= ~(PrivMode_MouseX10|PrivMode_MouseBtnEvent|PrivMode_MouseAnyEvent);
+              if (priv_modes & PrivMode_MouseForbid)
+                priv_modes &= ~PrivMode_MouseX11;
               break;
             case 1002:
             case 1003:
-              if (state)
+              if (state && priv_modes & PrivMode_MouseForbid)
+                priv_modes &= ~PrivMode_MouseBtnEvent & ~PrivMode_MouseAnyEvent;
+              else if (state)
                 {
                   priv_modes &= ~(PrivMode_MouseX10|PrivMode_MouseX11);
                   priv_modes &= arg[i] == 1003 ? ~PrivMode_MouseBtnEvent : ~PrivMode_MouseAnyEvent;
diff --git a/src/rxvt.h b/src/rxvt.h
index 0693f1a..5ba97f2 100644
--- a/src/rxvt.h
+++ b/src/rxvt.h
@@ -393,6 +393,7 @@ enum {
   XTerm_konsole30        = 30,      // reserved for konsole
   XTerm_konsole31        = 31,      // reserved for konsole
   XTerm_emacs51          = 51,      // reserved for emacs shell
+  XTerm_Xselection       = 52,      // not implemented, read or write X11 selection
   /*
    * rxvt extensions of XTerm OSCs: ESC ] Ps;Pt (ST|BEL)
    */
@@ -541,6 +542,7 @@ enum {
 #define PrivMode_MouseBtnEvent  (1UL<<20)
 #define PrivMode_MouseAnyEvent  (1UL<<21)
 #define PrivMode_BracketPaste   (1UL<<22)
+#define PrivMode_MouseForbid    (1UL<<23)
 
 #define PrivMode_mouse_report   (PrivMode_MouseX10|PrivMode_MouseX11|PrivMode_MouseBtnEvent|PrivMode_MouseAnyEvent)
 
_______________________________________________
rxvt-unicode mailing list
[email protected]
http://lists.schmorp.de/cgi-bin/mailman/listinfo/rxvt-unicode

Reply via email to