Exemplo n.º 1
0
static void
OpenGLEventProc(ClientData clientData, XEvent *eventPtr)
{

  OpenGLClientData *OpenGLPtr = (OpenGLClientData *) clientData;
  if (eventPtr->type == DestroyNotify) 
  {
#ifndef _WIN32
    glXMakeContextCurrent(OpenGLPtr->display, None, None, 0);
#else
    wglMakeCurrent(OpenGLPtr->hDC,0);
#endif
    XSync(OpenGLPtr->display, False);
    //      glXDestroyWindow(OpenGLPtr->display, OpenGLPtr->glx_win);
#ifndef _WIN32
    glXDestroyContext(OpenGLPtr->display, OpenGLPtr->cx);
#else
    wglDeleteContext( OpenGLPtr->cx ); 
#endif
    XSync(OpenGLPtr->display, False);

    Tcl_DeleteCommand(OpenGLPtr->interp, Tk_PathName(OpenGLPtr->tkwin));
    OpenGLPtr->tkwin = NULL;
    Tk_EventuallyFree((ClientData) OpenGLPtr, (Tcl_FreeProc*)OpenGLDestroy);
  }
}
Exemplo n.º 2
0
static void
PaxWidgetEventProc(ClientData clientData, XEvent *event)
{
    PaxWidget *paxwidget = (PaxWidget *) clientData;

    if (event->type == Expose || event->type == GraphicsExpose)
    {
	handle_expose_event(paxwidget, event);
    }
    else if (event->type == ConfigureNotify)
    {
	paxWidget_CallMethodArgs(paxwidget->obj, ResizedMethodIdx,
				 Py_BuildValue("ii", event->xconfigure.width,
					       event->xconfigure.height));
    }
    else if (event->type == MapNotify)
    {
	paxWidget_CallMethod(paxwidget->obj, MapMethodIdx);
    }
    else if (event->type == DestroyNotify)
    {
	paxWidget_CallMethod(paxwidget->obj, DestroyMethodIdx);

	if (paxwidget->tkwin != NULL)
	{
	    paxwidget->tkwin = NULL;
	    Tcl_DeleteCommand(paxwidget->interp,
			      Tcl_GetCommandName(paxwidget->interp,
						 paxwidget->widget_cmd));
	}
	if (paxwidget->update_pending)
	{
	    Tk_CancelIdleCall(PaxWidgetDisplay, (ClientData) paxwidget);
	}
	Tk_EventuallyFree((ClientData) paxwidget, PaxWidgetDestroy);
    }
    else if (event->type > LASTEvent)
    {
	paxWidget_CallMethodArgs(paxwidget->obj, ExtensionEventIdx,
				 Py_BuildValue("(i)", event->type));
    }
}
Exemplo n.º 3
0
void
SimGraphEventProc(ClientData clientData, XEvent *eventPtr)
{
  SimGraph *graph = (SimGraph *) clientData;

  if ((eventPtr->type == Expose) && (eventPtr->xexpose.count == 0)) {
    graph->visible = 1;
    EventuallyRedrawGraph(graph);
  } else if (eventPtr->type == MapNotify) {
    graph->visible = 1;
  } else if (eventPtr->type == UnmapNotify) {
    graph->visible = 0;
  } else if (eventPtr->type == VisibilityNotify) {
    if (eventPtr->xvisibility.state == VisibilityFullyObscured)
      graph->visible = 0;
    else
      graph->visible = 1;
  } else if (eventPtr->type == ConfigureNotify) {
    DoResizeGraph(graph,
		  eventPtr->xconfigure.width,
		  eventPtr->xconfigure.height);
    EventuallyRedrawGraph(graph);
  } else if (eventPtr->type == DestroyNotify) {
    Tcl_DeleteCommand(graph->interp, Tk_PathName(graph->tkwin));
    graph->tkwin = NULL;
    if (graph->flags & VIEW_REDRAW_PENDING) {
//fprintf(stderr, "SimGraphEventProc Destroy token %d\n", graph->draw_graph_token);
      assert(graph->draw_graph_token != 0);
      if (graph->draw_graph_token != 0) {
	Tk_DeleteTimerHandler(graph->draw_graph_token);
	graph->draw_graph_token = 0;
      }
      graph->flags &= ~VIEW_REDRAW_PENDING;
    }
   Tk_EventuallyFree((ClientData) graph, DestroySimGraph);
  }
}