Esempio n. 1
0
	bool UserInputListener::fireMouseButtonReleased( MouseButton p_button )
	{
		bool result = false;

		if ( doHasHandlers() )
		{
			m_mouse.m_buttons[size_t( p_button )] = false;
			m_mouse.m_changed = p_button;
			auto current = doGetMouseTargetableHandler( m_mouse.m_position );

			if ( current )
			{
				current->pushEvent( MouseEvent( MouseEventType::eReleased, m_mouse.m_position, p_button ) );
				result = true;
				m_activeHandler = current;
			}
			else
			{
				auto active = m_activeHandler.lock();

				if ( active )
				{
					active->pushEvent( HandlerEvent( HandlerEventType::eDeactivate, current ) );
				}

				m_activeHandler.reset();
			}
		}

		return result;
	}
OSStatus GHOST_SystemCarbon::handleWindowEvent(EventRef event)
{
	WindowRef windowRef;
	GHOST_WindowCarbon *window;
	OSStatus err = eventNotHandledErr;
	
	// Check if the event was send to a GHOST window
	::GetEventParameter(event, kEventParamDirectObject, typeWindowRef, NULL, sizeof(WindowRef), NULL, &windowRef);
	window = (GHOST_WindowCarbon *) ::GetWRefCon(windowRef);
	if (!validWindow(window)) {
		return err;
	}

	//if (!getFullScreen()) {
	err = noErr;
	switch (::GetEventKind(event))
	{
		case kEventWindowClose:
			pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowClose, window) );
			break;
		case kEventWindowActivated:
			m_windowManager->setActiveWindow(window);
			window->loadCursor(window->getCursorVisibility(), window->getCursorShape());
			pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowActivate, window) );
			break;
		case kEventWindowDeactivated:
			m_windowManager->setWindowInactive(window);
			pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowDeactivate, window) );
			break;
		case kEventWindowUpdate:
			//if (getFullScreen()) GHOST_PRINT("GHOST_SystemCarbon::handleWindowEvent(): full-screen update event\n");
			pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowUpdate, window) );
			break;
		case kEventWindowBoundsChanged:
			if (!m_ignoreWindowSizedMessages)
			{
				window->updateDrawingContext();
				pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowSize, window) );
			}
			break;
		default:
			err = eventNotHandledErr;
			break;
	}
//	}
	//else {
	//window = (GHOST_WindowCarbon*) m_windowManager->getFullScreenWindow();
	//GHOST_PRINT("GHOST_SystemCarbon::handleWindowEvent(): full-screen window event, " << window << "\n");
	//::RemoveEventFromQueue(::GetMainEventQueue(), event);
	//}
	
	return err;
}
	void DInputEventQueue::pushEvent( const DJoyStickEvent& e)
	{
		if (mEventInforQueue.size() < maxEventCount)
		{
			pushEvent(e, mTimer.getMilliseconds());
		}
	}
Esempio n. 4
0
GHOST_IWindow *
GHOST_SystemSDL::createWindow(const STR_String& title,
                              GHOST_TInt32 left,
                              GHOST_TInt32 top,
                              GHOST_TUns32 width,
                              GHOST_TUns32 height,
                              GHOST_TWindowState state,
                              GHOST_TDrawingContextType type,
                              bool stereoVisual,
                              const GHOST_TUns16 numOfAASamples,
                              const GHOST_TEmbedderWindowID parentWindow
                              )
{
	GHOST_WindowSDL *window= NULL;

	window= new GHOST_WindowSDL (this, title, left, top, width, height, state, parentWindow, type, stereoVisual, 1);

	if (window) {
		if (window->getValid()) {
			m_windowManager->addWindow(window);
			pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowSize, window));
		}
		else {
			delete window;
			window= NULL;
		}
	}
	return window;
}
Esempio n. 5
0
bool
GHOST_SystemSDL::generateWindowExposeEvents()
{
	vector<GHOST_WindowSDL *>::iterator w_start= m_dirty_windows.begin();
	vector<GHOST_WindowSDL *>::const_iterator w_end= m_dirty_windows.end();
	bool anyProcessed= false;

	for (;w_start != w_end; ++w_start) {
		GHOST_Event * g_event= new
			GHOST_Event(
				getMilliSeconds(),
				GHOST_kEventWindowUpdate,
				*w_start
			);

		(*w_start)->validate();

		if (g_event) {
			printf("Expose events pushed\n");
			pushEvent(g_event);
			anyProcessed= true;
		}
	}

	m_dirty_windows.clear();
	return anyProcessed;
}
Esempio n. 6
0
	bool UserInputListener::fireKeyUp( KeyboardKey p_key, bool p_ctrl, bool p_alt, bool p_shift )
	{
		bool result = false;

		if ( doHasHandlers() )
		{
			auto active = m_activeHandler.lock();

			if ( active )
			{
				if ( p_key == KeyboardKey::eControl )
				{
					m_keyboard.m_ctrl = false;
				}

				if ( p_key == KeyboardKey::eAlt )
				{
					m_keyboard.m_alt = false;
				}

				if ( p_key == KeyboardKey::eShift )
				{
					m_keyboard.m_shift = false;
				}

				active->pushEvent( KeyboardEvent( KeyboardEventType::eReleased, p_key, m_keyboard.m_ctrl, m_keyboard.m_alt, m_keyboard.m_shift ) );
				result = true;
			}
		}

		return result;
	}
Esempio n. 7
0
	void EventBuffer::pollEvents(sf::Window& window)
	{
		sf::Event event;

		while (window.pollEvent(event))
			pushEvent(event);
	}
Esempio n. 8
0
void Statistics::endFrame() {
	setValue(frameDurationCounter, frameTimer.getMilliseconds());

	{ // IO
		static Util::Timer ioTimer;
		static size_t lastBytesRead = 0;
		static size_t lastBytesWritten = 0;

		const uint64_t duration = ioTimer.getNanoseconds();
		// Update every second.
		if(duration > 1000000000) {
			const size_t bytesRead = Util::Utils::getIOBytesRead();
			const size_t bytesWritten = Util::Utils::getIOBytesWritten();

			const double MebiPerSecond = 1024.0 * 1024.0 * 1.0e-9 * static_cast<double>(duration);
			const double readRate = static_cast<double>(bytesRead - lastBytesRead) / MebiPerSecond;
			const double writeRate = static_cast<double>(bytesWritten - lastBytesWritten) / MebiPerSecond;

			ioTimer.reset();
			lastBytesRead = bytesRead;
			lastBytesWritten = bytesWritten;

			setValue(ioRateReadCounter, readRate);
			setValue(ioRateWriteCounter, writeRate);
		}
	}

	pushEvent(EVENT_TYPE_FRAME_END, 1);
}
GHOST_IWindow *GHOST_SystemCarbon::createWindow(
		const STR_String& title,
		GHOST_TInt32 left,
		GHOST_TInt32 top,
		GHOST_TUns32 width,
		GHOST_TUns32 height,
		GHOST_TWindowState state,
		GHOST_TDrawingContextType type,
		bool stereoVisual,
		const GHOST_TUns16 numOfAASamples,
		const GHOST_TEmbedderWindowID parentWindow)
{
	GHOST_IWindow *window = 0;

	window = new GHOST_WindowCarbon(title, left, top, width, height, state, type);

	if (window) {
		if (window->getValid()) {
			// Store the pointer to the window
			GHOST_ASSERT(m_windowManager, "m_windowManager not initialized");
			m_windowManager->addWindow(window);
			m_windowManager->setActiveWindow(window);
			pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowSize, window));
		}
		else {
			GHOST_PRINT("GHOST_SystemCarbon::createWindow(): window invalid\n");
			delete window;
			window = 0;
		}
	}
	else {
		GHOST_PRINT("GHOST_SystemCarbon::createWindow(): could not create window\n");
	}
	return window;
}
Esempio n. 10
0
void TetrisAI::execute(vector<int> commands) {
	for (vector<int>::iterator it = commands.begin(); it != commands.end();
			it++) {
		SDL_Delay(AI_DELAY);
		pushEvent(*it);
	}
}
Esempio n. 11
0
void QSFMLCanvas::mouseReleaseEvent(QMouseEvent* event) {
	sf::Event e;
	e.type = sf::Event::MouseButtonReleased;
	e.mouseButton.x = event->x();
	e.mouseButton.y = event->y();
	pushEvent(e);
}
Esempio n. 12
0
void WindowImpl::processSensorEvents()
{
    // First update the sensor states
    SensorManager::getInstance().update();

    for (unsigned int i = 0; i < Sensor::Count; ++i)
    {
        Sensor::Type sensor = static_cast<Sensor::Type>(i);

        // Only process enabled sensors
        if (SensorManager::getInstance().isEnabled(sensor))
        {
            // Copy the previous value of the sensor and get the new one
            Vector3f previousValue = m_sensorValue[i];
            m_sensorValue[i] = SensorManager::getInstance().getValue(sensor);

            // If the value has changed, trigger an event
            if (m_sensorValue[i] != previousValue) // @todo use a threshold?
            {
                Event event;
                event.type = Event::SensorChanged;
                event.sensor.type = sensor;
                event.sensor.x = m_sensorValue[i].x;
                event.sensor.y = m_sensorValue[i].y;
                event.sensor.z = m_sensorValue[i].z;
                pushEvent(event);
            }
        }
    }
}
Esempio n. 13
0
ClientUpdater::ClientUpdater(STI::Pusher::ServerEventHandler_ptr eventHandlerRef, 
							 const ServerEvent& initialState, ORBManager* orb_manager) :
handlerRef( STI::Pusher::ServerEventHandler::_duplicate(eventHandlerRef) ), orbManager(orb_manager)
{
	active = true;
	timeoutPeriod = 10 * 60; //10 minutes
	freshEvents = false;

	timeoutLoopMutex = new omni_mutex();
	timeoutLoopCondition = new omni_condition(timeoutLoopMutex);

	FIFOmutex = new omni_mutex();
	FIFOcondition = new omni_condition(FIFOmutex);

	serverCallback = new ServerCallback_i();
	orbManager->registerServant(serverCallback);

	pushLoopRunning = false;
	timeoutLoopRunning = false;

	pushEvent(initialState);

	omni_thread::create(eventPushLoopWrapper, (void*)this, omni_thread::PRIORITY_HIGH);
	omni_thread::create(timeoutLoopWrapper, (void*)this, omni_thread::PRIORITY_LOW);
}
Esempio n. 14
0
// ######################################################################
bool EyeTrackerUDP::checkForData()
{
  int numbytes = 0;
  if (isConnected)
    {
      struct timeval tm;
      tm.tv_sec = 0;
      tm.tv_usec = 0;

      read_fs = master; // copy master
      select(sockfd+1, &read_fs, NULL, NULL, &tm);

      if (FD_ISSET(sockfd, &read_fs))
        {
          //ready to read
          lasthost_addrlen = sizeof lasthost_addr;
          unsigned char msgBuffer[BUFSIZE];

          if ( (numbytes = recvfrom(sockfd, msgBuffer, BUFSIZE-1 , 0,
                                    &lasthost_addr,
                                    &lasthost_addrlen)) <= 0)
            {
              // got error or connection closed by client
              if (numbytes == 0)
                {
                  // connection closed
                  pushEvent("Error::socket closed");
                  LFATAL("The connection closed");
                }
              else
                pushEvent("Error::recieve");
            }
          else
            {
              pushEvent("Received Trigger");
              setEyeFlags(msgBuffer[0]);
            }
        }//end FS_SET == true
    }
  else
    {
      pushEvent("Must be conncted to listen");
      LFATAL("Must be connected to listen");
    }

  return (bool)numbytes;
}
Esempio n. 15
0
      //--------------------------------------------------------------
      /// \brief	            Signal that time event elapsed
      /// \param[in] timeEvent    Time event to signal
      //--------------------------------------------------------------
      void signalTimeEvent(boost::shared_ptr<ITimeEvent> timeEvent)
      {
         BOOST_ASSERT(!!timeEvent);

         boost::shared_ptr<CEventBase> evt(new CEventBase(timeEvent->getId()));
         pushEvent(evt);
         timeEvent->reset();
      }
Esempio n. 16
0
void TaskPool::run(Thread* thread, void* userdata)
{

    while (!isStopping && (!tasks.empty() || !isWaiting))
    {
        Task* task;
        tasks.wait_and_pop_front(task);

        if (!task) continue;

        pushEvent(task, TaskState::Started );

        task->run();
        
        pushEvent(task, TaskState::Finished );
    }
}
Esempio n. 17
0
void QSFMLCanvas::keyReleaseEvent(QKeyEvent * event) {
	auto key = keyMap.find(static_cast<Qt::Key>(event->key()));
	if (key != keyMap.end()) {
		sf::Event e;
		e.type = sf::Event::KeyReleased;
		e.key.code = key->second;
		pushEvent(e);
	}
}
	//-----------------------------------------------------------------------
	void ParticleSystem::_pushSystemEvent(EventType eventType)
	{
		// Create the event
		ParticleUniverseEvent evt;
		evt.eventType = eventType;
		evt.componentType = CT_SYSTEM;
		evt.componentName = getName();
		evt.technique = 0;
		evt.emitter = 0;
		pushEvent(evt);
	}
Esempio n. 19
0
void MinerManager::startBlockchainMonitoring() {
  m_contextGroup.spawn([this] () {
    try {
      m_blockchainMonitor.waitBlockchainUpdate();
      pushEvent(BlockchainUpdatedEvent());
    } catch (System::InterruptedException&) {
    } catch (std::exception& e) {
      m_logger(Logging::ERROR) << "BlockchainMonitor context unexpectedly finished: " << e.what();
    }
  });
}
Esempio n. 20
0
void MinerManager::startMining(const CryptoNote::BlockMiningParameters& params) {
  m_contextGroup.spawn([this, params] () {
    try {
      m_minedBlock = m_miner.mine(params, m_config.threadCount);
      pushEvent(BlockMinedEvent());
    } catch (System::InterruptedException&) {
    } catch (std::exception& e) {
      m_logger(Logging::ERROR) << "Miner context unexpectedly finished: " << e.what();
    }
  });
}
	//-----------------------------------------------------------------------
	void ParticleEmitter::_pushEmitterEvent(EventType eventType)
	{
		// Create the event
		ParticleUniverseEvent evt;
		evt.eventType = eventType;
		evt.componentType = CT_EMITTER;
		evt.componentName = getName();
		evt.technique = 0;
		evt.emitter = this;
		pushEvent(evt);
	}
Esempio n. 22
0
void gSDLDC::exec(const gOpcode *o)
{
	switch (o->opcode) {
	case gOpcode::flush:
		pushEvent(EV_FLIP);
		eDebug("FLUSH");
		break;
	default:
		gDC::exec(o);
		break;
	}
}
Esempio n. 23
0
void QtBackend::keyEvent(QKeyEvent *k, bool pressed) {
	int translatedkey = translateQtKey(k->key());
	int key = translatedkey;
	if (key == -1) {
		if (k->key() >= Qt::Key_0 && k->key() <= Qt::Key_9) {
			key = k->key();
		} else if (k->key() >= Qt::Key_A && k->key() <= Qt::Key_Z) {
			key = k->key();
		}
	}
	if (key != -1) {
		SomeEvent e;
		if (pressed)
			e.type = eventspecialkeydown;
		else
			e.type = eventspecialkeyup;
		e.key = key;
		pushEvent(e);
		downkeys[key] = pressed;
		if (translatedkey != -1) return;
	}

	for (int i = 0; i < k->text().size(); i++) {
		// TODO: openc2e probably doesn't like latin1
		unsigned char x = k->text().at(i).toLatin1();
		if (x > 31) { // Qt helpfully hands us non-text chars for some crazy reason
			// We have a Latin-1 key which we can process.
			SomeEvent e;
			
			// the engine only handles eventkeydown at present
			if (pressed) {
				e.type = eventkeydown;
				e.key = x;
				pushEvent(e);
			}
		}
	}
}
Esempio n. 24
0
void Anchor::endProcess() {
  if(!detached) {
    // Tell the process to die
    Event *ev = new Event();
    ev->set_type(Event_EventType_ET_SUICIDE);
    pushEvent(ev);

    // Wait for it to die
    waitpid(pid, NULL, 0);

    // Stop the own event queue
    Process::stop();
    detached = true;
  }
}
Esempio n. 25
0
// ######################################################################
void EyeTrackerUDP::sendMessage(const char* msg)
{
  //send some packets
    if (isConnected)
    {
      //return a status code to sender
      int check = 0;
      (hostInfo != NULL)?
        check = sendto(sockfd, msg, strlen(msg), 0,
                       hostInfo->ai_addr, hostInfo->ai_addrlen)
        :check = sendto(sockfd, msg, strlen(msg), 0,
                        &lasthost_addr, lasthost_addrlen);

      (check < 0)?
        pushEvent("Error::Sending"):
        pushEvent( std::string("Listener::Sent '" +
                               std::string(msg) + "'"));
    }
  else
    {
      pushEvent("Must be Connected to send a message");
      LFATAL("Must be conncted to send a message");
    }
}
Esempio n. 26
0
	bool UserInputListener::fireMouseMove( Position const & p_position )
	{
		bool result = false;

		if ( doHasHandlers() )
		{
			m_mouse.m_position = p_position;
			auto current = doGetMouseTargetableHandler( p_position );
			auto last = m_lastMouseTarget.lock();

			if ( current != last )
			{
				if ( last )
				{
					castor::Logger::logDebug( castor::StringStream() << p_position.x() << "x" << p_position.y() );
					last->pushEvent( MouseEvent( MouseEventType::eLeave, p_position ) );
					last.reset();
					m_lastMouseTarget.reset();
				}
			}

			if ( current )
			{
				if ( current != last )
				{
					current->pushEvent( MouseEvent( MouseEventType::eEnter, p_position ) );
				}

				current->pushEvent( MouseEvent( MouseEventType::eMove, p_position ) );
				result = true;
				m_lastMouseTarget = current;
			}
		}

		return result;
	}
Esempio n. 27
0
GHOST_IWindow *GHOST_SystemSDL::createWindow(const STR_String &title,
                                             GHOST_TInt32 left,
                                             GHOST_TInt32 top,
                                             GHOST_TUns32 width,
                                             GHOST_TUns32 height,
                                             GHOST_TWindowState state,
                                             GHOST_TDrawingContextType type,
                                             GHOST_GLSettings glSettings,
                                             const bool exclusive,
                                             const GHOST_TEmbedderWindowID parentWindow)
{
  GHOST_WindowSDL *window = NULL;

  window = new GHOST_WindowSDL(this,
                               title,
                               left,
                               top,
                               width,
                               height,
                               state,
                               parentWindow,
                               type,
                               ((glSettings.flags & GHOST_glStereoVisual) != 0),
                               exclusive);

  if (window) {
    if (GHOST_kWindowStateFullScreen == state) {
      SDL_Window *sdl_win = window->getSDLWindow();
      SDL_DisplayMode mode;

      static_cast<GHOST_DisplayManagerSDL *>(m_displayManager)->getCurrentDisplayModeSDL(mode);

      SDL_SetWindowDisplayMode(sdl_win, &mode);
      SDL_ShowWindow(sdl_win);
      SDL_SetWindowFullscreen(sdl_win, SDL_TRUE);
    }

    if (window->getValid()) {
      m_windowManager->addWindow(window);
      pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowSize, window));
    }
    else {
      delete window;
      window = NULL;
    }
  }
  return window;
}
Esempio n. 28
0
	bool UserInputListener::fireChar( KeyboardKey p_key, String const & p_char )
	{
		bool result = false;

		if ( doHasHandlers() )
		{
			auto active = m_activeHandler.lock();

			if ( active )
			{
				active->pushEvent( KeyboardEvent( KeyboardEventType::eChar, p_key, p_char, m_keyboard.m_ctrl, m_keyboard.m_alt, m_keyboard.m_shift ) );
				result = true;
			}
		}

		return result;
	}
Esempio n. 29
0
	bool UserInputListener::fireMouseWheel( Position const & p_offsets )
	{
		bool result = false;

		if ( doHasHandlers() )
		{
			m_mouse.m_wheel += p_offsets;
			auto current = doGetMouseTargetableHandler( m_mouse.m_position );

			if ( current )
			{
				current->pushEvent( MouseEvent( MouseEventType::eWheel, p_offsets ) );
				result = true;
			}
		}

		return result;
	}
Esempio n. 30
0
void X11Window::processEvent(const XEvent &xEvent)
{
    // TODO(cwallez) text events
    switch (xEvent.type)
    {
      case ButtonPress:
        {
            Event event;
            MouseButton button = MOUSEBUTTON_UNKNOWN;
            int wheelX = 0;
            int wheelY = 0;

            // The mouse wheel updates are sent via button events.
            switch (xEvent.xbutton.button)
            {
              case Button4:
                wheelY = 1;
                break;
              case Button5:
                wheelY = -1;
                break;
              case 6:
                wheelX = 1;
                break;
              case 7:
                wheelX = -1;
                break;

              case Button1:
                button = MOUSEBUTTON_LEFT;
                break;
              case Button2:
                button = MOUSEBUTTON_MIDDLE;
                break;
              case Button3:
                button = MOUSEBUTTON_RIGHT;
                break;
              case 8:
                button = MOUSEBUTTON_BUTTON4;
                break;
              case 9:
                button = MOUSEBUTTON_BUTTON5;
                break;

              default:
                break;
            }

            if (wheelY != 0)
            {
                event.Type = Event::EVENT_MOUSE_WHEEL_MOVED;
                event.MouseWheel.Delta = wheelY;
                pushEvent(event);
            }

            if (button != MOUSEBUTTON_UNKNOWN)
            {
                event.Type = Event::EVENT_MOUSE_BUTTON_RELEASED;
                event.MouseButton.Button = button;
                event.MouseButton.X = xEvent.xbutton.x;
                event.MouseButton.Y = xEvent.xbutton.y;
                pushEvent(event);
            }
        }
        break;

      case ButtonRelease:
        {
            Event event;
            MouseButton button = MOUSEBUTTON_UNKNOWN;

            switch (xEvent.xbutton.button)
            {
              case Button1:
                button = MOUSEBUTTON_LEFT;
                break;
              case Button2:
                button = MOUSEBUTTON_MIDDLE;
                break;
              case Button3:
                button = MOUSEBUTTON_RIGHT;
                break;
              case 8:
                button = MOUSEBUTTON_BUTTON4;
                break;
              case 9:
                button = MOUSEBUTTON_BUTTON5;
                break;

              default:
                break;
            }

            if (button != MOUSEBUTTON_UNKNOWN)
            {
                event.Type = Event::EVENT_MOUSE_BUTTON_RELEASED;
                event.MouseButton.Button = button;
                event.MouseButton.X = xEvent.xbutton.x;
                event.MouseButton.Y = xEvent.xbutton.y;
                pushEvent(event);
            }
        }
        break;

      case KeyPress:
        {
            Event event;
            event.Type = Event::EVENT_KEY_PRESSED;
            event.Key.Code = X11CodeToKey(mDisplay, xEvent.xkey.keycode);
            AddX11KeyStateToEvent(&event, xEvent.xkey.state);
            pushEvent(event);
        }
        break;

      case KeyRelease:
        {
            Event event;
            event.Type = Event::EVENT_KEY_RELEASED;
            event.Key.Code = X11CodeToKey(mDisplay, xEvent.xkey.keycode);
            AddX11KeyStateToEvent(&event, xEvent.xkey.state);
            pushEvent(event);
        }
        break;

      case EnterNotify:
        {
            Event event;
            event.Type = Event::EVENT_MOUSE_ENTERED;
            pushEvent(event);
        }
        break;

      case LeaveNotify:
        {
            Event event;
            event.Type = Event::EVENT_MOUSE_LEFT;
            pushEvent(event);
        }
        break;

      case MotionNotify:
        {
            Event event;
            event.Type = Event::EVENT_MOUSE_MOVED;
            event.MouseMove.X = xEvent.xmotion.x;
            event.MouseMove.Y = xEvent.xmotion.y;
            pushEvent(event);
        }
        break;

      case ConfigureNotify:
        {
            if (xEvent.xconfigure.width != mWidth || xEvent.xconfigure.height != mHeight)
            {
                Event event;
                event.Type = Event::EVENT_RESIZED;
                event.Size.Width = xEvent.xconfigure.width;
                event.Size.Height = xEvent.xconfigure.height;
                pushEvent(event);
            }
            if (xEvent.xconfigure.x != mX || xEvent.xconfigure.y != mY)
            {
                // Sometimes, the window manager reparents our window (for example
                // when resizing) then the X and Y coordinates will be with respect to
                // the new parent and not what the user wants to know. Use
                // XTranslateCoordinates to get the coordinates on the screen.
                int screen = DefaultScreen(mDisplay);
                Window root = RootWindow(mDisplay, screen);

                int x, y;
                Window child;
                XTranslateCoordinates(mDisplay, mWindow, root, 0, 0, &x, &y, &child);

                if (x != mX || y != mY)
                {
                    Event event;
                    event.Type = Event::EVENT_MOVED;
                    event.Move.X = x;
                    event.Move.Y = y;
                    pushEvent(event);
                }
            }
        }
        break;

      case FocusIn:
        if (xEvent.xfocus.mode == NotifyNormal || xEvent.xfocus.mode == NotifyWhileGrabbed)
        {
            Event event;
            event.Type = Event::EVENT_GAINED_FOCUS;
            pushEvent(event);
        }
        break;

      case FocusOut:
        if (xEvent.xfocus.mode == NotifyNormal || xEvent.xfocus.mode == NotifyWhileGrabbed)
        {
            Event event;
            event.Type = Event::EVENT_LOST_FOCUS;
            pushEvent(event);
        }
        break;

      case DestroyNotify:
        // We already received WM_DELETE_WINDOW
        break;

      case ClientMessage:
        if (xEvent.xclient.message_type == WM_PROTOCOLS &&
            static_cast<Atom>(xEvent.xclient.data.l[0]) == WM_DELETE_WINDOW)
        {
            Event event;
            event.Type = Event::EVENT_CLOSED;
            pushEvent(event);
        }
        else if (xEvent.xclient.message_type == TEST_EVENT)
        {
            Event event;
            event.Type = Event::EVENT_TEST;
            pushEvent(event);
        }
        break;
    }
}