Exemple #1
0
 void waitForEvent(int type) {
     XEvent event;
     do {
         XWindowEvent(display, window, StructureNotifyMask, &event);
         describeEvent(event);
     } while (event.type != type);
 }
Exemple #2
0
bool
processEvents(void) {
    while (XPending(display) > 0) {
        XEvent event;
        XNextEvent(display, &event);
        describeEvent(event);
    }
    return true;
}
Exemple #3
0
static void waitForEvent(Window window, int type) {
    XFlush(display);
    XEvent event;
    do {
        XNextEvent(display, &event);
        describeEvent(event);
    } while (event.type != type ||
             event.xany.window != window);
}
Exemple #4
0
static void
processEvent(XEvent &event) {
    describeEvent(event);

    switch (event.type) {
    case KeyPress:
        {
            char buffer[32];
            KeySym keysym;
            XLookupString(&event.xkey, buffer, sizeof buffer - 1, &keysym, NULL);
            if (keysym == XK_Escape) {
                exit(0);
            }
        }
        break;
    }
}
Exemple #5
0
// ######################################################################
void XWinManaged::eventHandler(XEvent* event)
{
  if (itsTraceEvents.atomic_get() > 0 || MYLOGVERB >= LOG_DEBUG)
    LINFO("%s in window '%s'...",
          describeEvent(event).c_str(), this->getTitle());

  switch(event->type)
    {

    case ClientMessage:
      {
        if (event->xclient.data.l[0] == (int)deleteAtom)
          {
            // user wants to close window - set the flag
            toBeClosed = true;
          }
      }
      break;

    case Expose:
      {
        while (this->checkMaskEvent(ExposureMask, event))
          { /* empty loop body */ }

        this->redrawImage();
      }
      break;

    case KeyPress:
      {
        GVX_MUTEX_LOCK(&itsEventsMutex);
        itsKeyEvents.push_back(event->xkey);
        if (itsKeyEvents.size() > g_max_queue_len)
          itsKeyEvents.pop_front();
      }
      break;

    case ButtonPress:
      {
        GVX_MUTEX_LOCK(&itsEventsMutex);
        mousePressed = true;

        itsButtonEvents.push_back(event->xbutton);
        if (itsButtonEvents.size() > g_max_queue_len)
          itsButtonEvents.pop_front();

        itsButtonPressedEvents.push_back(event->xbutton);
        if (itsButtonPressedEvents.size() > g_max_queue_len)
          itsButtonPressedEvents.pop_front();
      }
      break;
    case ButtonRelease:
      {
        GVX_MUTEX_LOCK(&itsEventsMutex);
        mousePressed = false;

        itsButtonEvents.push_back(event->xbutton);
        if (itsButtonEvents.size() > g_max_queue_len)
          itsButtonEvents.pop_front();

        itsButtonReleasedEvents.push_back(event->xbutton);
        if (itsButtonReleasedEvents.size() > g_max_queue_len)
          itsButtonReleasedEvents.pop_front();
      }
      break;
    case MotionNotify:
      {
        GVX_MUTEX_LOCK(&itsEventsMutex);

        itsButtonEvents.push_back(event->xbutton);
        if (itsButtonEvents.size() > g_max_queue_len)
          itsButtonEvents.pop_front();

        itsButtonMotionEvents.push_back(event->xbutton);
        if (itsButtonMotionEvents.size() > g_max_queue_len)
          itsButtonMotionEvents.pop_front();
      }
      break;
    }
}