vrj::PfInputHandler Class Reference

Performer input handler. More...

#include <vrj/Draw/Pf/PfInputHandler.h>

List of all members.

Public Member Functions

 PfInputHandler (pfPipeWindow *pipeWindow, const std::string &displayName)
 Creates an adaptor which will route events from Performer into platform-specific events.
void config (jccl::ConfigElementPtr e, vrj::Display *disp)
 Configures the adaptor.
void checkEvents ()
void handleEvents ()
 Grab events from Performer window and sends them to InputAreaXWin::handleEvent() or InputAreaWin32::handleEvent().

Static Public Member Functions

static int errorHandler (::Display *display, XErrorEvent *e)
 Handles error output from X services Traps X errors instead of killing the application.


Detailed Description

Performer input handler.

Definition at line 82 of file PfInputHandler.h.


Constructor & Destructor Documentation

vrj::PfInputHandler::PfInputHandler ( pfPipeWindow *  pipeWindow,
const std::string &  displayName 
)

Creates an adaptor which will route events from Performer into platform-specific events.

Parameters:
pipeWindow Performer window to grab events from.
displayName The name of the display.

Definition at line 53 of file PfInputHandler.cpp.

00055 {
00056    mName = displayName;
00057    mPipeWindow = pipeWindow;
00058    mPipe = pfGetPWinPipe(mPipeWindow);
00059    mBlocking = false;
00060 #ifdef VPR_OS_Windows
00061    mWinHandle = pipeWindow->getWSWindow();
00062 #else
00063    // Get the XWindow from that we are going to recieve events from.
00064    mXWindow = pfGetPWinWSWindow(mPipeWindow);
00065    openConnection();
00066 #endif
00067 }


Member Function Documentation

void vrj::PfInputHandler::config ( jccl::ConfigElementPtr  e,
vrj::Display disp 
) [inline]

Configures the adaptor.

Parameters:
e ConfigElement that contains all configuration information to configure an InputArea.
disp VR Juggler display which contains size info.

Definition at line 106 of file PfInputHandler.h.

References vrj::Display::getOriginAndSize().

Referenced by vrj::PfDrawManager::addDisplay().

00107    {
00108       gadget::InputArea::config(e);
00109       int originX, originY, width, height;
00110       disp->getOriginAndSize(originX, originY, width, height);
00111       mWidth = (unsigned int)width;
00112       mHeight = (unsigned int)height;
00113    }

void vrj::PfInputHandler::checkEvents (  ) 

Definition at line 124 of file PfInputHandler.cpp.

References handleEvents().

00125 {
00126    handleEvents();
00127 }

void vrj::PfInputHandler::handleEvents (  ) 

Grab events from Performer window and sends them to InputAreaXWin::handleEvent() or InputAreaWin32::handleEvent().

Precondition:
openConnection has been called.

Definition at line 157 of file PfInputHandler.cpp.

Referenced by checkEvents().

00158 {
00159    XEvent      event;
00160 
00161    /*
00162    // In Linux, XEventsQueued with QueuedAlready results in an
00163    // extreme amount of latency in SP mode since the event queue
00164    // only ever reports one event per call.  It's necessary to
00165    // change this to re-query the X server for more events after
00166    // the first one is pulled from the queue.  However this results
00167    // in a server roundtrip (in Linux) and probably causes a performance
00168    // hit.  So only being defined for LINUX
00169    */
00170 
00171    while (XPending(mXDisplay)) 
00172    {
00173       XNextEvent(mXDisplay, &event);
00174       
00175       switch (event.type) 
00176       {
00177       case ClientMessage:
00178          //if ((event.xclient.message_type == wm_protocols) &&
00179          //    (event.xclient.data.l[0] == wm_delete_window))
00180          {
00181             //events->devQ[events->numDevs] = PFUDEV_WINQUIT;
00182             //events->devVal[events->numDevs] = 1;
00183             //events->devCount[PFUDEV_WINQUIT] += 1;
00184             //events->numDevs++;
00185          } 
00186          break;
00187       default:
00188          // If we have a valid KeyboardMouseDevice, process
00189          // all keyboard/mouse events
00190          if ( NULL != mKeyboardMouseDevice )
00191          {
00192             // Forward events on to subclass. The magic of inheritance :)
00193             handleEvent(event);
00194          }
00195          break;
00196       }
00197    }
00198 }

int vrj::PfInputHandler::errorHandler ( ::Display display,
XErrorEvent *  e 
) [static]

Handles error output from X services Traps X errors instead of killing the application.

Definition at line 200 of file PfInputHandler.cpp.

00201 {
00202    char* errorOutput = new char[512];
00203    XGetErrorText(e->display, (int) e->error_code, errorOutput, 512);
00204    vprDEBUG(vprDBG_ERROR, vprDBG_CRITICAL_LVL)
00205          << clrOutNORM(clrRED, "ERROR:")
00206          << "PfInputHandler::errorHandler Caught X Error '\n" << errorOutput
00207          << "'\n" << vprDEBUG_FLUSH;
00208    delete [] errorOutput;
00209    return 0;
00210 }


The documentation for this class was generated from the following files:
Generated on Thu Jan 4 10:58:28 2007 for VR Juggler by  doxygen 1.5.1