unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* Swapping mouse buttons under X11
@ 2006-09-04 20:37 Christopher J. Madsen
  2006-09-10 13:47 ` Reiner Steib
  0 siblings, 1 reply; 2+ messages in thread
From: Christopher J. Madsen @ 2006-09-04 20:37 UTC (permalink / raw)


[-- Attachment #1: message body and .signature --]
[-- Type: text/plain, Size: 1083 bytes --]

I got used to using Emacs on Microsoft Windows with w32-swap-mouse-buttons
set to 't (which swaps mouse buttons 2 & 3).  I want to be able to get the
same behavior on GNU/Linux & X11.

I have attached a patch to illustrate what I'm trying to do.  The patch
works great (I've been using it on my system for years), but the problem
is that it has no UI.  It always swaps buttons 2 & 3.  Obviously, it needs
a UI before it can be merged.

The question is what kind of UI it should have.  I'm aware of two
variables that have similar behavior: mac-wheel-button-is-mouse-2 and
w32-swap-mouse-buttons.  They do the same thing, except the sense is
reversed.

I see several possibilities:

1. Add x-swap-mouse-buttons (acts like w32-swap-mouse-buttons).

2. Add x-mouse-button-array (lets you remap buttons in any way you choose).

3. Replace existing vars with swap-mouse-buttons.

4. Replace existing vars with mouse-button-array.

Any comments?

-- 
Chris Madsen                                            cjm@pobox.com
  ------------------  http://www.pobox.com/~cjm  ------------------

[-- Attachment #2: Patch to xterm.c --]
[-- Type: text/plain, Size: 1888 bytes --]

*** xterm.c	Sat Jan  3 11:51:04 2004
--- xterm.c	Sat Jan  3 11:57:41 2004
***************
*** 371,376 ****
--- 371,391 ----
                                    int *));
  
  
+ /* CJM added x_get_button_num 9/18/02 */
+ static int x_button_numbers[] = { 0, 2, 1 };
+ 
+ static int
+ x_get_button_num (button)
+   int button;
+ {
+   button -= Button1;
+   if ((button >= 0) && (button < sizeof(x_button_numbers)/sizeof(x_button_numbers[0])))
+     return x_button_numbers[button];
+   else
+     return button;
+ }
+ 
+ 
  /* Flush display of frame F, or of all frames if F is null.  */
  
  static void
***************
*** 3498,3504 ****
    /* Make the event type NO_EVENT; we'll change that when we decide
       otherwise.  */
    result->kind = MOUSE_CLICK_EVENT;
!   result->code = event->button - Button1;
    result->timestamp = event->time;
    result->modifiers = (x_x_to_emacs_modifiers (FRAME_X_DISPLAY_INFO (f),
  					       event->state)
--- 3513,3519 ----
    /* Make the event type NO_EVENT; we'll change that when we decide
       otherwise.  */
    result->kind = MOUSE_CLICK_EVENT;
!   result->code = x_get_button_num(event->button);
    result->timestamp = event->time;
    result->modifiers = (x_x_to_emacs_modifiers (FRAME_X_DISPLAY_INFO (f),
  					       event->state)
***************
*** 5301,5307 ****
      abort ();
  
    emacs_event->kind = SCROLL_BAR_CLICK_EVENT;
!   emacs_event->code = event->xbutton.button - Button1;
    emacs_event->modifiers
      = (x_x_to_emacs_modifiers (FRAME_X_DISPLAY_INFO
  			       (XFRAME (WINDOW_FRAME (XWINDOW (bar->window)))),
--- 5316,5322 ----
      abort ();
  
    emacs_event->kind = SCROLL_BAR_CLICK_EVENT;
!   emacs_event->code = x_get_button_num(event->xbutton.button);
    emacs_event->modifiers
      = (x_x_to_emacs_modifiers (FRAME_X_DISPLAY_INFO
  			       (XFRAME (WINDOW_FRAME (XWINDOW (bar->window)))),

[-- Attachment #3: Type: text/plain, Size: 149 bytes --]

_______________________________________________
bug-gnu-emacs mailing list
bug-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-gnu-emacs

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

* Re: Swapping mouse buttons under X11
  2006-09-04 20:37 Swapping mouse buttons under X11 Christopher J. Madsen
@ 2006-09-10 13:47 ` Reiner Steib
  0 siblings, 0 replies; 2+ messages in thread
From: Reiner Steib @ 2006-09-10 13:47 UTC (permalink / raw)
  Cc: GNU Emacs Bug Reports

On Mon, Sep 04 2006, Christopher J. Madsen wrote:

> I got used to using Emacs on Microsoft Windows with w32-swap-mouse-buttons
> set to 't (which swaps mouse buttons 2 & 3).  I want to be able to get the
> same behavior on GNU/Linux & X11.

I wonder if you'd like to swap button 2 and 3 for the whole session
rather than only for Emacs.  I do this on my notebook (only two mouse
buttons) using xmodmap:

Xmodmap_mouse_132 ()
{
  local buttons
  buttons=`xmodmap -pp | sed -ne "s/.*There are \(.*\) pointer buttons.*/\1/p"`
  # useful e.g. for notebook with 2-button mouse:
  # let left button act as middle button and left+right as right button
  if [ "$buttons" -ge 4 ]; then
    xmodmap -e "pointer = 1 3 2 `seq 4 $buttons`"
  else
    xmodmap -e "pointer = 1 3 2"
  fi
}

Also note that in Emacs 22 (CVS) you can follow links with mouse-1
instead of mouse-2:

,----[ etc/NEWS in Emacs 22 ]
| *** You can now follow links by clicking Mouse-1 on the link.
| 
| Traditionally, Emacs uses a Mouse-1 click to set point and a Mouse-2
| click to follow a link, whereas most other applications use a Mouse-1
| click for both purposes, depending on whether you click outside or
| inside a link.  Now the behavior of a Mouse-1 click has been changed
| to match this context-sentitive dual behavior.  (If you prefer the old
| behavior, set the user option `mouse-1-click-follows-link' to nil.)
`----

Bye, Reiner.
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo---  |  PGP key available  |  http://rsteib.home.pages.de/

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

end of thread, other threads:[~2006-09-10 13:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-04 20:37 Swapping mouse buttons under X11 Christopher J. Madsen
2006-09-10 13:47 ` Reiner Steib

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).