Mercurial > MadButterfly
comparison src/X_supp.c @ 350:892f4efe2e48
Prevent applications from hanging by massive mouse motion events.
- When massive motion events are send by mouse, the application will
busy for processing events.
- The motion events are aggregated to prevent applicatin from hanging for
massive mouse motion events.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Sun, 08 Mar 2009 23:08:51 +0800 |
parents | b391722bf20e |
children | 16116d84bc5e |
comparison
equal
deleted
inserted
replaced
349:700954870cee | 350:892f4efe2e48 |
---|---|
175 /*! \brief Dispatch all X events in the queue. | 175 /*! \brief Dispatch all X events in the queue. |
176 */ | 176 */ |
177 static void handle_x_event(X_MB_runtime_t *rt) { | 177 static void handle_x_event(X_MB_runtime_t *rt) { |
178 Display *display = rt->display; | 178 Display *display = rt->display; |
179 redraw_man_t *rdman = rt->rdman; | 179 redraw_man_t *rdman = rt->rdman; |
180 XEvent evt; | 180 XEvent evt, peek_evt; |
181 XMotionEvent *mevt; | 181 XMotionEvent *mevt; |
182 XButtonEvent *bevt; | 182 XButtonEvent *bevt; |
183 XExposeEvent *eevt; | 183 XExposeEvent *eevt; |
184 XKeyEvent *xkey; | 184 XKeyEvent *xkey; |
185 co_aix x, y, w, h; | 185 co_aix x, y, w, h; |
229 x, y, EVT_MOUSE_BUT_RELEASE, | 229 x, y, EVT_MOUSE_BUT_RELEASE, |
230 state, button); | 230 state, button); |
231 break; | 231 break; |
232 | 232 |
233 case MotionNotify: | 233 case MotionNotify: |
234 while(XEventsQueued(display, QueuedAfterReading) > 0) { | |
235 r = XPeekEvent(display, &peek_evt); | |
236 if(r == -1) | |
237 break; | |
238 if(peek_evt.type != MotionNotify) | |
239 break; | |
240 XNextEvent(display, &evt); | |
241 } | |
242 if(r == -1) | |
243 break; | |
244 | |
234 mevt = (XMotionEvent *)&evt; | 245 mevt = (XMotionEvent *)&evt; |
235 x = mevt->x; | 246 x = mevt->x; |
236 y = mevt->y; | 247 y = mevt->y; |
237 state = get_button_state(mevt->state); | 248 state = get_button_state(mevt->state); |
238 | 249 |