コード例 #1
0
ファイル: main.c プロジェクト: Remmy/afterstep
static gboolean
x11_fd_check (GSource *source)
{

//	SHOW_CHECKPOINT;
/* for some reason if events are handled in dispatch - it messes up the timeout events */
//	show_debug (__FILE__,__FUNCTION__,__LINE__,"XQLength = %d, x_fd = %d", XQLength(dpy), x_fd);
	HandleXEvent();
//	XSync (dpy, True);
//	show_debug (__FILE__,__FUNCTION__,__LINE__,"XQLength = %d", XQLength(dpy));
	return FALSE;
}
コード例 #2
0
int 
DispatchLoop()
{
  SPW_InputDispatchStruct dispatch_data;
  XEvent                  xevent;
  SPW_InputEvent          spwevent;
  int done = FALSE;

  /*
   *  Set up the callback struct
   */

  SPW_InputInitDispatchStruct(&dispatch_data);
  dispatch_data.display = Spw_Dpy;
  dispatch_data.spwbw   = Spw_ButtonWindow;
  dispatch_data.xevent  = &xevent;
  dispatch_data.spwevent  = &spwevent;
  dispatch_data.handle_motion = SpwMotionEvent;
  dispatch_data.handle_bpress = SpwButtonPressEvent;
  dispatch_data.handle_brelease = SpwButtonReleaseEvent;
  dispatch_data.delay = 1;
  
  /*
   *  Loop, process events as possible Button Window, Spaceball, or app
   */

  while(!done)
    {
      if(!XPending(Spw_Dpy) && Spw_Redraw)
        {
          Spw_Redraw=FALSE;
          UpdateScreen();
        }
      XNextEvent(Spw_Dpy, &xevent);
      
      SPW_BwHandleEvent(Spw_ButtonWindow, &xevent);
      
      if(SPW_InputIsSpaceballEvent(Spw_Dpy, &xevent, &spwevent))
        {
          SPW_InputDispatch(&dispatch_data); 
        }
      else
        {
          Spw_Redraw|=HandleXEvent(&xevent, &done);
        }
    }  

  return done;

} /* end of DispatchLoop */
コード例 #3
0
ファイル: main.c プロジェクト: Remmy/afterstep
void mainLoop ()
{
  GPollFD dpy_pollfd = {x_fd, G_IO_IN, 0};// | G_IO_HUP | G_IO_ERR
	GSourceFuncs x11_source_funcs = {
    x11_fd_prepare,
    x11_fd_check,    x11_fd_dispatch,
    NULL, /* finalize */
    NULL, /* closure_callback */
    NULL /* closure_marshal */
      };

	GSource *x11_source = g_source_new(&x11_source_funcs, sizeof(x11_source_t));

	((x11_source_t*)x11_source)->dpy = dpy;
	((x11_source_t*)x11_source)->pending_events = 0;
	g_source_add_poll(x11_source, &dpy_pollfd);
	g_source_attach(x11_source,NULL); /* must use default context so that DBus signal handling is not impeded */
	{
#if 0
		GMainLoop *mainloop = g_main_loop_new(NULL,FALSE);
		g_main_loop_run(mainloop);
#else
		GMainContext *ctx = g_main_context_default ();
		GPollFD qfd_a[10];
		do {
	    gint timeout;
			int priority = 0;
			int i;
    	g_main_context_prepare (ctx, &priority);		
    	gint recordCount = g_main_context_query(ctx, 2, &timeout, qfd_a, 10);
			/* we need to specify the timeout, in order for glib signals to propagate properly
			   Ain't that stupid!!!!!! */
			g_poll (qfd_a, recordCount, 200);
			/* don't want to trust glib's main loop with our X event handling - it gets all screwed up */
#if 1
			for (i = 0 ; i < recordCount ; ++i)
				if (qfd_a[i].revents) {
/*					show_progress ( "%d: fd = %d, events = 0x%X, revents = 0x%X", time(NULL), qfd_a[i].fd, qfd_a[i].events, qfd_a[i].revents); */
					if (qfd_a[i].fd == x_fd) {
						HandleXEvent();
						qfd_a[i].revents = 0;
					}
				}
#endif  	 
		  g_main_context_check(ctx, -1, qfd_a, recordCount);
			g_main_context_dispatch (ctx);
		}while (1);
#endif		
	}
}