eventHandler.cpp

00001 
00002 /* Copyright (c) 2006-2009, Stefan Eilemann <eile@equalizergraphics.com> 
00003  *
00004  * This library is free software; you can redistribute it and/or modify it under
00005  * the terms of the GNU Lesser General Public License version 2.1 as published
00006  * by the Free Software Foundation.
00007  *  
00008  * This library is distributed in the hope that it will be useful, but WITHOUT
00009  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00010  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00011  * details.
00012  * 
00013  * You should have received a copy of the GNU Lesser General Public License
00014  * along with this library; if not, write to the Free Software Foundation, Inc.,
00015  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00016  */
00017 
00018 #include "eventHandler.h"
00019 
00020 #ifdef GLX
00021 #  include "glXEventHandler.h"
00022 #endif
00023 
00024 #include "pipe.h"
00025 #include "window.h"
00026 
00027 #include <eq/base/lock.h>
00028 #include <eq/base/debug.h>
00029 
00030 using namespace eq::base;
00031 using namespace std;
00032 
00033 namespace eq
00034 {
00035 
00036 void EventHandler::_computePointerDelta( const Window* window, Event &event )
00037 {
00038     if( _lastEventWindow != window )
00039     {
00040         event.pointer.dx  = 0;
00041         event.pointer.dy  = 0;
00042         _lastPointerEvent = event;
00043         _lastEventWindow  = window;
00044         return;
00045     }
00046 
00047     switch( event.type )
00048     {
00049         case Event::POINTER_BUTTON_PRESS:
00050         case Event::POINTER_BUTTON_RELEASE:
00051             if( _lastPointerEvent.type == Event::POINTER_MOTION )
00052             {
00053                 event.pointer.dx = _lastPointerEvent.pointer.dx;
00054                 event.pointer.dy = _lastPointerEvent.pointer.dy;
00055                 break;
00056             }
00057             // fall through
00058 
00059         default:
00060             event.pointer.dx = event.pointer.x - _lastPointerEvent.pointer.x;
00061             event.pointer.dy = event.pointer.y - _lastPointerEvent.pointer.y;
00062     }
00063     _lastPointerEvent = event;
00064 }
00065 
00066 void EventHandler::_getRenderContext( const Window* window, Event& event )
00067 {
00068     const int32_t x = event.pointer.x;
00069     const int32_t y = event.pointer.y;
00070 
00071     if( !window->getRenderContext( x, y, event.context ))
00072         EQINFO << "No rendering context for pointer event at " << x << ", " 
00073                << y << endl;
00074 }
00075 
00076 }
Generated on Mon Aug 10 18:58:32 2009 for Equalizer 0.9 by  doxygen 1.5.8