Button Bindings - bakkeby/dusk GitHub Wiki

Button bindings are similar to key bindings just that they are specific for binding mouse button clicks to trigger designated function calls.

These are defined in the buttons array in config.h. Refer to that for practical examples.

Each button binding have five values as defined by the Button struct:

typedef struct {
	unsigned int click;
	unsigned int mask;
	unsigned int button;
	void (*func)(const Arg *arg);
	const Arg arg;
} Button;

The first three are filters and the function and argument is what will be evaluated if the conditions matches the filters.

click

The click value is an indication of the context in which a button binding applies. For example ClkClientWin means that the button binding applies when the user clicks on a client window while ClkWorkspaceBar means that the binding applies when the user clicks on the workspace icons in the bar.

The available click filters are ClkWorkspaceBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, and ClkRootWin.

Should you need to introduce additional click types then refer to the clicks enum in dusk.c (search for ClkLtSymbol).

mask

The event mask is used to differentiate between a plain mouse click and when a modifier key is held down when the click occurs. An example modifier key would be Shift or Alt.

You can also combine modifiers for the event mask, e.g. Shift|Ctrl.

button

Button bindings are typically bound as Button1, Button2, Button3, etc. These are actually just macros that set the corresponding integer values of 1, 2, 3, etc.

X11 defines macros up to Button5 whereas Button6 through Button9 are defined in dusk.c. Should you need more buttons then you can add further macros there, but you can also just add the numbers directly in the key bindings.

How many buttons are available depends on your mouse peripheral. Some gaming mice can have a ridiculous amount of buttons.

Which button does what can depend on setup, but typically you will have something like this:

Button Description
Button1 Left click
Button2 Middle click
Button3 Right click
Button4 Scroll up
Button5 Scroll down
Button6 Scroll left
Button7 Scroll right
Button8 Back button
Button9 Forward button

function

This is the function that will be called if the click conditions matches all the button filters for the binding.

The signature of the function is that it needs to take a constant Arg argument and not return anything:

void (*func)(const Arg *arg);

argument

If the argument has a value then that argument will be passed to the function when it is evaluated.

If the argument is {0} then the argument may be set behind the scenes by the window manager.

As an example the argument is set to be a client reference if you click on a client window or a window title in the bar. Likewise the argument is set to a workspace reference if you click on a workspace icon in the bar.


Back to Configuration.

⚠️ **GitHub.com Fallback** ⚠️