xgesture
News
What is this?
xgesture is the application to realize "mouse gesture" function for any applications on the X Window System. I am recommend it in the case that you want to operate Mozilla only by a mouse device.
Download
There is the latest source here .
Install
To build xgesture, you need a C++ compiler conforming to ISO C++ after a fashion (i.e. gcc-2.95.x or later), a set of the build suite of X applications, lex and yacc.
Only you need to invoke:
xmkmf -a make sudo make install
after extract the tarball.
fixme: "make install.man" just causes an empty file to install.
Usage
First, start xgesture command suitably.
The gestures of this application is basically derived from "Sleipnir", a tab browser on Windows.
If you move mouse on the target window while pressing the right button of your mouse, the motion history while pressing the button is displayed at the north-west corner of the screen. Each motion is simplified to four directions (u/d/l/r; acronym of up/down/left/right). This motion is called "mouse gesture". If the gesture is matched to one of a registered command, the name of the command is also displayed. If you release the right button at this time, the command is executed on the target winow.
At this time, there are the below target clients supported by xgesture in default. Also, you can add new target clients or the command corresponding to a gesture.
- Mozilla/Phoenix
-
l: Back
r: Forward
u: PageUp
d: PageDown
ud: Reload
rlr: Close a window or a tab
- xterm/kterm
-
u: Shift + PageUp
d: Shift + PageDown
- emacs
-
u: PageUp
d: PageDown
rlr: Exit Emacs(C-x C-c)
Here, I show an example with Mozilla.
First, press the right button on the Mozilla and drag toward bottom. (I use ASTEC-X, a commercial X server on Windows, to capture the screenshots.):

Then, the status window is shown at the north-west corner of the screen.

In English: "[Mozilla] Motion: d(Down)"
release the right button; Page Down key event is raised and the Mozilla window scrolls down.

Next, press the right button and drag toward left:

In this case, another command is displayed:

In English: "[Mozilla] Motion: l(Back)"
release the right button; the Mozilla may back a page.

Finally, right:

left:

In English: "[Mozilla] Motion: r(Next)"
right:

In English: "[Mozilla] Motion: rl"
...Such multi-direction motion is allowed, and release the button:

In English: "[Mozilla] Motion: rlr(Close)"
then the Mozilla window is closed:

If you cancel the motion, you only release the button when no command is displayed.
Well, press the right button and drag as you pleases, then you should get used to it soon.
Configuration
All configuration is done via the resource mechanism of the X window system. The following resources are allowed:
- upChar
-
The motion symbol when the mouse is dragged toward top.
Class: UpChar
Type: String
Default: u
- downChar
-
The motion symbol when the mouse is dragged toward bottom.
Class: DownChar
Type: String
Default: d
- leftChar
-
The motion symbol when the mouse is dragged toward left.
Class: LeftChar
Type: String
Default: l
- rightChar
-
The motion symbol when the mouse is dragged toward right.
Class: RightChar
Type: String
Default: r
- unitDistance
-
The unit distance to recognize moving the mouse.
Class: RightChar
Type: Int
Default: 10
- maxMotions
-
The maximum number of the directions of motion.
Class: MaxMotions
Type: Int
Default: 10
- button
-
The grab condition of mouse button.
Class: Button
Type: Int
Default: 3
fixme: In the future, this parameter should be specified in a symbol (such as "Button3").
- modifier
-
The grab condition of modifier.
Class: Modifier
Type: Int
Default: 0
fixme: In the future, this parameter should be specified in a symbol (such as "Ctrl").
- warpBack
-
Whether the pointer is return to the point that the button pressed when the button is released.
Class: WarpBack
Type: Boolean
Default: True
- gestures
-
The definisions of the mouse gestures (see below).
Class: Gesture
Type: String
Default: an empty string
- commandLeft
-
The left parenthesis around the command title.
Class: CommandLeft
Type: String
Default: (
- commandRight
-
The right parenthesis around the command title.
Class: CommandRight
Type: String
Default: )
- targetLeft
-
The left square bracket around the target title.
Class: TargetLeft
Type: String
Default: [
- targetRight
-
The right square bracket around the target title.
Class: TargetRight
Type: String
Default: ]
The definision of the mouse gestures contains 0 or more sentences as the following:
DEFM motion-list-name { motion-list } ; TARGET "target-application-name" { motion-list } ; TARGET "target-application-name" motion-list-name ;
these mean:
- DEFM motion-list-name { motion-list };
-
This names the motion-list. This name can be referred from a motion-list-name specifier in TARGET or an import sentence in motion-list.
- TARGET "target-application-name" { motion-list };
-
This defines a motion on the window matching to target-application-name. target-application-name is matched to the resource class name, resource instance name or window name. The matching is case-insensitive and you can use * and ? like as filename globbing of shell.
- TARGET "target-application-name" motion-list-name;
-
Same as above, motion-list-name is applied instead of direct description of motion list.
motion-list contains zero or more sentences as the following:
motion-syms "command-name" [ key-strokes ] ; <motion-list-name> ;
these means:
- motion-syms "command-name" [ key-strokes ] ;
-
This specifies the key-strokes corresponding to motion-syms. motion-syms contains any number of u, d, l and r.
command-name is the string shown in the status window if the motion-syms is matched to the motion.
key-strokes is the KeySym list to be raised. If the multiple KeySyms are specified continuously, these are raised corresponding KeyPress events in the order. If ';' is placed or the list terminated by ']', then the KeyRelease events in the reverse order.
The examples of key-strokes:
a # equivalent to typing 'a' Control_L a # equivalent to typing 'C-a' Control_L x ; Control_L c # equivalent to typing 'C-x''C-c'
- <motion-list-name> ;
-
This imports the motion-list defined by DEFM here.
If the same motion specifications is multiply defined, the last one is valid.
another general note; When the mouse gesture definision is described in the resource file, each of lines need to be appended '\' the line to be continued. The mouse gesture definision described in the XGesture.ad is quoted below:
! ! sample ! xgesture*gestures: \n\ Target "Mozilla" { \n\ l "Back" [ Alt_L Left ]; \n\ r "Forward" [ Alt_L Right ]; \n\ u "Up" [ Prior ]; \n\ d "Down" [ Next ]; \n\ ud "Reload" [ Control_L Shift_L r ]; \n\ rlr "Close" [ Control_L w ]; \n\ }; \n\ DefM XTERM_FAMILY { \n\ u "Up" [ Shift_L Prior ]; \n\ d "Down" [ Shift_L Next ]; \n\ }; \n\ Target "XTerm" XTERM_FAMILY; \n\ Target "KTerm" XTERM_FAMILY; \n\ DefM EMACS_FAMILY { \n\ u "Up" [ Prior ]; \n\ d "Down" [ Next ]; \n\ rlr "Close" [ Control_L x; Control_L c ]; \n\ }; \n\ Target "Emacs" EMACS_FAMILY; \n\ Target "XEmacs" EMACS_FAMILY; \n\ Target "Mule" EMACS_FAMILY;
Mechanism
In the current xgesture, it sets the passive grab on the root window to capture the right button down and raises Fake Key events with using XTest extension. Thus, there are the notices below:
-
xgesture conflicts other applications that want to set the passive grab under the same conditions.
In this case, the applications stared later catch an asynchronus error of X protocol. xgesture just fails because it does not handle such error.
Because passive grab for ancestor has priority over ones for any descendants, if someone takes the passive grab of the root window, others cannot set the passive grab in the same condition.
-
In the case that the right button is clicked on a non-target window, xgesture cannot deal the click exactly same as normal right click.
In the current xgesture, 'Press' and 'Release' fake button events are sent at same time when the real right button is released.
In ideal, xgesture immediately release the (active) grab and sends the Fake Button event with using XTest extension when the real right button is pressed on a non-target window, but this is failed because it seems to conflict to auto-grab of X server. Unfortunately, if the fake button event is raised in this timing, the passive-grab is never valid because X server seems to have a bug.
To eliminate these problems, xgesture needs to track the focus transition and sets the passive grab in the sufficient cases, but such process is difficult; window managers only can do it.
ToDo: For example in Fvwm, this is realized by creating a module.
Internationalization
xgesture is basically i18n-ed because it is obedient Xaw application. However, xgesture is restricted by lex and yacc if you use non-ASCII string in the definision of mouse gesture. At least, EUC and UTF-8 are valid with the combination of flex and BSD yacc or GNU bison.
License
xgesture is distributed under 2-clause BSD license:
Copyright (c)2003 Takuya SHIOZAKI, All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.