}
}
-int process_event(Compositor *compositor)
+void process_events(Compositor *compositor)
{
+ int pending;
XEvent event;
- if(compositor->dirty)
+
+ pending = 0;
+ while((pending || !compositor->dirty) && !terminate_requested)
{
- if(!XCheckMaskEvent(compositor->display, -1, &event))
- return 0;
- }
- else
+ if(!pending)
+ pending = XPending(compositor->display);
+
XNextEvent(compositor->display, &event);
+ if(pending)
+ --pending;
- switch(event.type)
- {
- case CreateNotify:
- process_create_window_event(compositor, &event.xcreatewindow);
- break;
- case DestroyNotify:
- process_destroy_window_event(compositor, &event.xdestroywindow);
- break;
- case MapNotify:
- process_map_event(compositor, &event.xmap);
- break;
- case UnmapNotify:
- process_unmap_event(compositor, &event.xunmap);
- break;
- case ReparentNotify:
- process_reparent_event(compositor, &event.xreparent);
- break;
- case ConfigureNotify:
- process_configure_event(compositor, &event.xconfigure);
- break;
- case PropertyNotify:
- process_property_event(compositor, &event.xproperty);
- break;
- default:
- if(event.type==compositor->damage_event+XDamageNotify)
- process_damage_event(compositor, (XDamageNotifyEvent *)&event);
- else if(event.type==compositor->shape_event+ShapeNotify)
- process_shape_event(compositor, (XShapeEvent *)&event);
- else
- printf("Event %d\n", event.type);
+ switch(event.type)
+ {
+ case CreateNotify:
+ process_create_window_event(compositor, &event.xcreatewindow);
+ break;
+ case DestroyNotify:
+ process_destroy_window_event(compositor, &event.xdestroywindow);
+ break;
+ case MapNotify:
+ process_map_event(compositor, &event.xmap);
+ break;
+ case UnmapNotify:
+ process_unmap_event(compositor, &event.xunmap);
+ break;
+ case ReparentNotify:
+ process_reparent_event(compositor, &event.xreparent);
+ break;
+ case ConfigureNotify:
+ process_configure_event(compositor, &event.xconfigure);
+ break;
+ case PropertyNotify:
+ process_property_event(compositor, &event.xproperty);
+ break;
+ default:
+ if(event.type==compositor->damage_event+XDamageNotify)
+ process_damage_event(compositor, (XDamageNotifyEvent *)&event);
+ else if(event.type==compositor->shape_event+ShapeNotify)
+ process_shape_event(compositor, (XShapeEvent *)&event);
+ else
+ printf("Event %d\n", event.type);
+ }
}
-
- return 1;
}
void refresh_screen(Compositor *compositor, CompositedScreen *screen)
while(!terminate_requested)
{
- if(!process_event(&compositor))
+ process_events(&compositor);
+ if(compositor.dirty && !terminate_requested)
refresh_all_screens(&compositor);
}