コード例 #1
0
ファイル: MSWidget.C プロジェクト: PlanetAPL/a-plus
void MSWidget::event(const XEvent *pEvent_)
{
 if (!_eventOverride||!(*_eventOverride)(pEvent_->type))
  switch (pEvent_->type)
   {
   case Expose:           expose(pEvent_);             break;
   case NoExpose:         noExpose(pEvent_);           break;
   case GraphicsExpose:   graphicsExpose(pEvent_);     break;
   case VisibilityNotify: visibilityNotify(pEvent_);   break;
   case EnterNotify:      if (_server->eventGrabbed(pEvent_,this)==MSTrue) enterNotify(pEvent_);  break;
   case LeaveNotify:      leaveNotify(pEvent_);        break;
   case ConfigureNotify:  configureNotify(pEvent_);    break;
   case CreateNotify:     createNotify(pEvent_);       break;
   case DestroyNotify:    destroyNotify(pEvent_);      break;
   case ReparentNotify:   reparentNotify(pEvent_);     break;
   case MapNotify:        mapNotify(pEvent_);          break;
   case UnmapNotify:      unmapNotify(pEvent_);        break;
   case PropertyNotify:   propertyNotify(pEvent_);     break;
   case SelectionNotify:  selectionNotify(pEvent_);    break;
   case SelectionClear:   selectionClear(pEvent_);     break;
   case SelectionRequest: selectionRequest(pEvent_);   break;
   case ClientMessage:    clientMessage(pEvent_);      break;
   case MotionNotify:     if (_server->eventGrabbed(pEvent_,this)==MSTrue) motionNotify(pEvent_);  break;   
   case ButtonRelease:    if (_server->eventGrabbed(pEvent_,this)==MSTrue) buttonRelease(pEvent_); break;
   case ButtonPress:      if (_server->eventGrabbed(pEvent_,this)==MSTrue) buttonPress(pEvent_);
                          else _server->bell();                                                    break;
   case KeyRelease:       if (_server->eventGrabbed(pEvent_,this)==MSTrue) keyRelease(pEvent_);    break;  
   case KeyPress:         if (_server->eventGrabbed(pEvent_,this)==MSTrue) keyPressEvent(pEvent_);      
                          else _server->bell();                                                    break;
   case FocusIn:          focusInEventNotify(pEvent_);  break;
   case FocusOut:         focusOutEventNotify(pEvent_); break;
   default:                                                                                         break;
   }
  // this event handler is intended to support the mstk builder
  // i.e. it is easier to get events this way rather than
  // subclass every widget and override the event methods
  if (_eventHandler!=0)	(*_eventHandler)(this,pEvent_,_eventHandlerData);
}
コード例 #2
0
ファイル: Dock.c プロジェクト: do4u-chenyu/jdic
/*
 * Class:     org_jdesktop_jdic_dock_internal_impl_UnixDockService
 * Method:    eventLoop
 * Signature: ()V
 */
JNIEXPORT void JNICALL Java_org_jdesktop_jdic_dock_internal_impl_UnixDockService_eventLoop(JNIEnv *env, jclass klass)
{
    XEvent        report;
    /*  Enter event loop  */
    static struct pollfd pollFds[2];
    int timeout = 100;
    int result;
    int fdX =  ConnectionNumber(display) ;
    pollFds[0].fd = fdX;
    pollFds[0].events = POLLRDNORM;
    pollFds[0].revents = 0;

   dprintf("Starting event loop ...\n");

    while ( 1 ) {

        (*LockIt)(env);
        while ((XEventsQueued(display, QueuedAfterReading) == 0) &&
                (XEventsQueued(display, QueuedAfterFlush) == 0)) {

            XFlush(display);
            (*UnLockIt)(env);
            ThreadYield(env);
            result = poll( pollFds, 1, (int32_t) timeout );
            (*LockIt)(env);

        }
        XNextEvent(display, &report);
        (*UnLockIt)(env);

        switch ( report.type ) {

            case Expose:
                dprintf("Expose\n");
                break;
            case PropertyNotify:
                dprintf("PropertyNotify\n");
                break;
            case ClientMessage:
                dprintf("ClientMessage\n");
                break;
            case ReparentNotify:
                dprintf("ReparentNotify\n");
                dprintf("window = %x parent = %x\n", report.xreparent.window,report.xreparent.parent);

                break;
            case ConfigureNotify:
                dprintf("ConfigureNotify win = %x x = %d y=%d w=%d h=%d\n",report.xconfigure.window, report.xconfigure.x,report.xconfigure.y, report.xconfigure.width, report.xconfigure.height);
                configureNotify(env,report.xconfigure.window,report.xconfigure.x,report.xconfigure.y, report.xconfigure.width, report.xconfigure.height);

                break;
            case ButtonPress:
                dprintf("ButtonPress\n");
                break;
	    case MapRequest:
		dprintf("MapRequest\n");
		break;
	    case MapNotify:
                dprintf("MapNotify %x\n", report.xconfigure.window);
                break;
	    case UnmapNotify:
                dprintf("UnmapNotify\n");
                break;




        }
    }
}