home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright 1993, 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- */
-
-
- #include <aux.h>
- #include <auxPrivate.h>
-
- /**************************************************************************
- * auxEventPending() - Check to see if there's an event on the queue
- **************************************************************************/
-
- GLboolean
- auxEventPending( GLvoid )
- {
- if ( XPending( auxState.display ) > ZERO )
- return GL_TRUE;
- else
- return GL_FALSE;
- }
-
-
- /**************************************************************************
- * GetWindow() - Match an X window to an auxWindow id ( STATIC )
- **************************************************************************/
-
- static auxWindow *
- GetWindow( Window window )
- {
- auxWindow *tmp;
-
- for ( tmp = auxState.head; tmp; tmp = tmp->next )
- if ( tmp->glxWindow == window )
- return tmp;
-
- auxFatalError( "Unable to find window" );
- }
-
-
- /**************************************************************************
- * auxReadEvent() - Check to see if there's an event on the queue
- **************************************************************************/
-
- GLint
- auxReadEvent( GLint *value, GLint *mousex, GLint *mousey )
- {
- GLint windowId;
- auxWindow *tmp;
- KeySym keysym;
- XEvent event, ahead;
-
-
- static GLint auxButtonList[] = {
- None, AUX_LEFTBUTTON, AUX_MIDDLEBUTTON, AUX_RIGHTBUTTON
- };
-
- auxMouseX = MINUS_ONE;
- auxMouseY = MINUS_ONE;
-
- XNextEvent( auxState.display, &event );
-
- #ifdef DEBUG3
- printf(" Reveivced %s Event\n", eventName[event.type] );
- #endif
-
- switch( event.type ) {
-
- case ConfigureNotify :
- tmp = GetWindow( event.xconfigure.window );
- tmp->x = event.xconfigure.x;
- tmp->y = event.xconfigure.y;
- tmp->width = event.xconfigure.width;
- tmp->height = event.xconfigure.height;
- auxValue = tmp->id;
- auxDevice = AUX_CONFIG;
- #ifdef DEBUG3
- printf("\tauxWindow : %d X Window : 0x%x\n", tmp->id, tmp->glxWindow );
- printf("\torigin : ( %d, %d ) size : ( %d, %d )\n", tmp->x, tmp->y,
- tmp->width, tmp->height );
- #endif
- break;
-
- case Expose :
- while( XPending( auxState.display ) > ZERO ){
- XPeekEvent( auxState.display, &ahead );
- if ( ahead.type != Expose )
- break;
- if ( ahead.xexpose.window != event.xexpose.window )
- break;
- XNextEvent( auxState.display, &event );
- }
- tmp = GetWindow( event.xexpose.window );
- auxValue = tmp->id;
- auxDevice = AUX_EXPOSE;
- #ifdef DEBUG3
- printf("\tauxWindow : %d X Window : 0x%x\n", tmp->id, tmp->glxWindow );
- printf("\torigin : ( %d, %d ) size : ( %d, %d )\n", event.xexpose.x,
- event.xexpose.y, event.xexpose.width, event.xexpose.height );
- #endif
- break;
-
- case KeyPress :
- case KeyRelease : {
- const GLint bufSize = 8;
- char buf[bufSize];
-
- XLookupString( (XKeyEvent *) &event, buf, bufSize, &keysym, ZERO );
- #ifdef DEBUG3
- printf(" Keysym = 0x%3x buf = '%s'\n", keysym, buf );
- #endif
- }
-
- auxMouseX = event.xkey.x;
- auxMouseY = event.xkey.y;
-
- auxValue = ( event.type == KeyPress ? ONE : ZERO );
- auxDevice = keysym;
- break;
-
- case ButtonPress :
- case ButtonRelease :
- auxValue = ( event.type == ButtonPress ? ONE : ZERO );
- auxMouseX = event.xbutton.x;
- auxMouseY = event.xbutton.y;
- #ifdef DEBUG3
- { static char *auxButtonNames[] = {
- "None",
- "AUX_LEFTBUTTON",
- "AUX_MIDDLEBUTTON",
- "AUX_RIGHTBUTTON"
- };
-
- printf(" Button = %s value = %d ( %d, %d )\n",
- auxButtonNames[event.xbutton.button], *value, *mousex, *mousey );
- }
- #endif
- auxDevice = auxButtonList[event.xbutton.button];
- break;
-
- case FocusIn :
- tmp = GetWindow( event.xfocus.window );
- auxValue = tmp->id;
- auxDevice = AUX_INPUTCHANGE;
- break;
-
- case FocusOut :
- auxValue = ZERO;
- auxDevice = AUX_INPUTCHANGE;
- break;
-
- case MotionNotify :
- auxValue = ZERO;
- auxMouseX = event.xmotion.x;
- auxMouseY = event.xmotion.y;
- auxDevice = AUX_MOUSELOC;
- break;
-
- case EnterNotify :
- case LeaveNotify :
- case KeymapNotify :
- case GraphicsExpose :
- case NoExpose :
- case VisibilityNotify :
- case CreateNotify :
- case DestroyNotify :
- case UnmapNotify :
- case MapNotify :
- case ReparentNotify :
- case GravityNotify :
- case CirculateNotify :
- case PropertyNotify :
- case SelectionClear :
- case SelectionNotify :
- case ColormapNotify :
- case ClientMessage :
- case MappingNotify :
- case MapRequest :
- case ConfigureRequest :
- case ResizeRequest :
- case CirculateRequest :
- case SelectionRequest :
- auxDevice = AUX_NOEVENT;
- break;
- }
-
- *value = auxValue;
- *mousex = auxMouseX;
- *mousey = auxMouseY;
-
- return auxDevice;
- }
-