[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Any experts how to useknow Xlib: MotionNotify ....help!!!!

Posted on 1998-10-01
1
Medium Priority
?
581 Views
Last Modified: 2012-05-04
Any body know how to get the coordinate of a mouse in a xwindow??  I try doing this by writing a program below but only a window display and no motiondetect when i move my mouse inside the window... pls help me...

#include <X11/Xlib.h>

#define BUF_SIZE 2000
Display *display;
Window window;
XEvent report;

int xpositions[BUF_SIZE], ypositions[BUF_SIZE];

int count=0;


void main()
{
display=XOpenDisplay(NULL);
window=XCreateSimpleWindow(display,XDefaultRootWindow(display),100,100,200,200,4,0,0);
XMapWindow(display,window);
XSelectInput(display,window,Button1MotionMask|ExposureMask);


   while (1)  {
      XNextEvent(display, &report);
if (report.type==MotionNotify)
       
        printf("got a motion event\n");          
xpositions[count] = report.xmotion.x;
        ypositions[count] = report.xmotion.y;
printf("%d\n",xpositions[count]);
       
          /* The following implements a fast ring buffer when count reaches buffer size */
          if (count <= BUF_SIZE)
             count++;
          else {
             count = 0;
              }
         
   
   } /* End while */
}
0
Comment
Question by:yueweng5
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 4

Accepted Solution

by:
feenix earned 400 total points
ID: 1174146
Use are using Button1MotionMask, so you get the movement events only when you press the mouse button and move. You should use PointerMotionMask instead.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question