473,382 Members | 1,480 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

xlib and mouse button

19
Hi,

I'm trying to use the Xlib library to detect a mouse button event in C. I'm using linux. I want to run a loop and exit this loop when a mouse button is pressed. It seems possible to me to wait for an event to happen but it it possible to compute something else while we're waiting?

I thought of something like :

do {
...
} while !(buttonstate1==pressed)

So my question is: is there a command to read the state (pressed or not) of the mouse button?

Regards
Jan 13 '08 #1
1 4487
RRick
463 Expert 256MB
X windows is based on an event structure and mechanism. Somewhere in your program you turn on X and let it run. All this does is loop over events. Unfortunately, it doesn't allow for other tasks to happen. To get around this limitation, everything that needs to be done is through the X events. This has some draw backs but works reasonably well.

If you want to intercept the events directly, you can modify the X main loop, but this can be pretty messy. Take a look at http://www.everything2.com/index.pl?node_id=39055 for more info.

Usually, you work with X through the widgets. The widgets control the events via callbacks and actions. This is really the way you want to go. For example, to read the mouse from a display widget, you would set a callback for mouse events. Now, the widget will call your routine whenever a mouse event happens.
Jan 14 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: John Champaign | last post by:
Hi all, I'm working on an educational applet for a child with special needs. He's got a bit of a trick to make my life more difficult... To interact with the applet he needs to click on...
0
by: Ed Suominen | last post by:
I am a fairly experienced TCL programmer considering a move to Python for my next project. The project will receive text via TCP from a Windows box running speech recognition software and send...
2
by: Artificial Life | last post by:
All I really want is to write a few strings to the background of my X display. XDrawString() is what I need. The Xlib for Python shows it's out dated. Is there any alternative?
7
by: Tyron | last post by:
I need to know if the Left Button of the Mouse is clicked in the WM_NCMOUSEMOVE Notification but this Message doesnt contain the Mouse Button States as WM_MOUSEMOVE does. So how can I get them? ...
13
by: James Bond | last post by:
Hello. My 80+ year old father has recently decided to get his first computer. Due to his age (and I suspect lack of playing pong as a child like I did) he lacks the manual dexterity to use a mouse...
0
by: Ferry Boender | last post by:
Hi, I'm relatively new to Xlib programming, and I ran into a little problem. I'm trying to insert keypress events into a X window. The following code works: ...
8
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I disable the right mouse button? -----------------------------------------------------------------------...
1
by: giovanni.iovino | last post by:
Hi, sorry for my English. I'm writing my first python script for Linux for a remote bluetooth application. I'm using python-xlib library to send keyboard and mouse events and at the moment I...
2
by: Dariusz.Donimirski | last post by:
I must rotate bmp using Xlib without change bmp's memory. If someone knows how I can do this, please help me. dariusz sorry about my english, I'm still learning
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.