You are not logged in.

#1 2013-11-03 11:10:40

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

[SOLVED] Mouse Button6 and upwards in Xlib?

Hey,

I'm working on DWM again and wanted to add some command using mouse Button6 and Button7. I found out Xlib's headers (not sure which at the moment) have no support for mouse buttons higher than Button5. You have to manually define them like so:

#ifndef Button6
#define Button6 6
#endif

#ifndef Button7
#define Button7 7
#endif

I'm curious as to why these aren't "supported" through the official header files, as they do work?

Last edited by Unia (2013-11-03 12:19:32)


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

#2 2013-11-03 12:10:43

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,332
Website

Re: [SOLVED] Mouse Button6 and upwards in Xlib?

You don't need to define them at all.  Just use the number.  I've never used those button definitions - don't they strike you as a little silly: putting "Button1" instead of just "1"*.  And how many buttons do you think should have such silly definitions in the header files?  One could argue that 3 are the only really globally used buttons.  5 buttons are common, 7 slightly less so, but mice can have a ridiculous number of buttons.


(*) I'd actually argue that the following code makes more sense as it adds just as much value but saves characters:

#ifndef 7
#define 7 7
#endif

Of course the compiler doesn't allow this one.

Last edited by Trilby (2013-11-03 12:13:01)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#3 2013-11-03 12:11:29

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

Re: [SOLVED] Mouse Button6 and upwards in Xlib?

True, but then why are button one to five defined?


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

#4 2013-11-03 12:15:56

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,332
Website

Re: [SOLVED] Mouse Button6 and upwards in Xlib?

No idea.  I'd not necessarily advocate for things like "#define ButtonLeft 1" but at least that would serve a purpose.  The Button# defintiions are just silly.  The x server can handle button numbers up to (at least) 12.

Last edited by Trilby (2013-11-03 12:16:49)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#5 2013-11-03 12:19:14

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

Re: [SOLVED] Mouse Button6 and upwards in Xlib?

Conclusion: X is silly tongue Oke, we're done here! I'll mark this as solved.


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

Board footer

Powered by FluxBB