rajat
rajat

Reputation: 3553

How to read mouse up and mouse down events in linux?

I used to work in windows and if in my C# wpf application I wanted to detect mouse up and mouse down , I did it using mouseup event.

Now I want to develop a simple application in C++ which detects mouse up and mouse down events in Linux . I have no idea about how to proceed , which is the best way and what libraries to use . Please guide me about how to go ahead .

Upvotes: 0

Views: 819

Answers (2)

user529758
user529758

Reputation:

A really simple and quick solution may be libxdo.

Upvotes: 1

rodrigo
rodrigo

Reputation: 98328

Your question is just too broad... but I'll try anyway.

You can go with the device access level:

  1. You can read input events directly from /dev/input/*. It is not difficult, but your application will need root access, or else you'll have to change the permissions of the devices. The main advantage is that you can read the mouse without even create a connection with the X server.

  2. You can work as an X client:

    a. You can use the X access directly, Xlib (not really recommended).

    b. You can use a toolkit library, such as GTK+, Qt or WxWidgets, to name a few.

With option 2. you may have a hard time if you want to get the events that happen in windows from other applications. YMMV.

Upvotes: 3

Related Questions