Sign in to follow this  
kimryo

About cursor and mouse under linux

Recommended Posts

Can cursor been cliped(refined) and mouse message been captured under linux just as Windows does(ClipCursor and SetCapture)? New to linux, any help is appreciate. Thx in advance. [Edited by - kimryo on July 3, 2008 1:53:40 AM]

Share this post


Link to post
Share on other sites
When most people want to use a manual pointer input (mouse, trackball, etc) or graphical output display device of some description (CRT, vector display) when running software on an OS such as Lunx or Unix they resort to a program called an "X Window server." There are a number of such programs available from various vendors but they all implement a de facto standard wire protocol for communication with your application. Your best bet for how to use an X Window server is to consult the Xlib documentation.

There are am astounding number of competing toolkit libraries available to make your job of communicating with an X Window server easier. Popular toolkit libraries include Qr and Gtk, as well as WvWidgets, FLTK, SDL, and many may others. You would be wise to choose such a toolkit and consult the relevant documentation to find the answer to your question.

Linux itself has no concept of a mouse or a cursor, although both of thise concepts are eventually implemented via device drivers, so conceptually it would be possible to write software for Linux as a kernel module to intercept data going through the device driver stack. Unless you're trying to whip up a keylogger for inclusion in a rootkit, you're better off choosing a toolkit library and lerning how to use it.

Share this post


Link to post
Share on other sites
Quote:
Original post by kimryo
Can cursor been cliped(refined) and mouse message been captured under linux just as Windows does(ClipCursor and SetCapture)?

Yep, there are similar functions under Linux. Use XGrabPointer and XUngrabPointer as replacements for SetCapture. I'm not aware of any direct equivalent of ClipCursor, but you can probably use a combination of XQueryPointer and XWarpPointer.

Mouse messages can be processed in a very similar way to Windows. The equivalent of WM_MOUSEMOVE is MotionNotify, WM_xBUTTONDOWN is ButtonPress, and WM_xBUTTONUP would be ButtonRelease.

It's pretty straightforward actually.

Share this post


Link to post
Share on other sites
Sign in to follow this