Ejemplo n.º 1
0
wxPaletteRefData::~wxPaletteRefData()
{
    Display *display = (Display*) NULL;

    wxList::compatibility_iterator node, next;

    for (node = m_palettes.GetFirst(); node; node = next) {
        wxXPalette *c = (wxXPalette *)node->GetData();
        unsigned long *pix_array = c->m_pix_array;
        Colormap cmap = (Colormap) c->m_cmap;
        bool destroyable = c->m_destroyable;
        int pix_array_n = c->m_pix_array_n;
        display = (Display*) c->m_display;

        if (pix_array_n > 0)
        {
            //      XFreeColors(display, cmap, pix_array, pix_array_n, 0);
            // Be careful not to free '0' pixels...
            int i, j;
            for(i=j=0; i<pix_array_n; i=j) {
                while(j<pix_array_n && pix_array[j]!=0) j++;
                if(j > i) XFreeColors(display, cmap, &pix_array[i], j-i, 0);
                while(j<pix_array_n && pix_array[j]==0) j++;
            }
            delete [] pix_array;
        }

        if (destroyable)
            XFreeColormap(display, cmap);

        next = node->GetNext();
        m_palettes.Erase(node);
        delete c;
    }
}
Ejemplo n.º 2
0
void
XmuDeleteStandardColormap(Display *dpy, int screen, Atom property)
     /* dpy;		- specifies the X server to connect to
      * screen		- specifies the screen of the display
      * property	- specifies the standard colormap property
      */
{
    XStandardColormap	*stdcmaps, *s;
    int			count = 0;

    if (XGetRGBColormaps(dpy, RootWindow(dpy, screen), &stdcmaps, &count,
			 property))
    {
	for (s=stdcmaps; count > 0; count--, s++) {
	    if ((s->killid == ReleaseByFreeingColormap) &&
		(s->colormap != None) &&
		(s->colormap != DefaultColormap(dpy, screen)))
		XFreeColormap(dpy, s->colormap);
	    else if (s->killid != None)
		XKillClient(dpy, s->killid);
	}
	XDeleteProperty(dpy, RootWindow(dpy, screen), property);
	XFree((char *) stdcmaps);
	XSync(dpy, False);
    }
}
Ejemplo n.º 3
0
MyWindow::~MyWindow() {
#ifdef WIN32
  //
  CURSORINFO cursorInfo;
  cursorInfo.cbSize=sizeof(CURSORINFO);

  if(GetCursorInfo(&cursorInfo) && cursorInfo.flags==0) {
    ShowCursor(TRUE);
  }

  //
  wglMakeCurrent(NULL,NULL);
  wglDeleteContext(hglrc);

  CloseWindow(hWnd);
  HINSTANCE hInstance=GetModuleHandle(0);

#ifdef UNICODE
  UnregisterClass(L"win32app",hInstance);
#else
  UnregisterClass("win32app",hInstance);
#endif
#endif


#ifdef LINUX
  glXMakeCurrent(display,0,0);
  glXDestroyContext(display,ctx);

  XDestroyWindow(display,win);
  XFreeColormap(display,cmap);
  XCloseDisplay(display);
#endif

}
	void OpenGLGraphicDeviceLinux::Close( )
	{
        // Destroy the OpenGL context
        if( m_pRenderOutput && m_DeviceContext )
        {
            // Release the context from this thread
            if( !glXMakeCurrent( XOpenDisplay( NULL ), 0, 0 ) )
            {
                std::cout << "[OpenGLGraphicDeviceLinux::Close] Can release the OpenGL context.\n";
                return;
            }

            glXDestroyContext( XOpenDisplay( NULL ), m_DeviceContext );
            m_DeviceContext = NULL;
        }

        // Free the color map
        if( m_Colormap )
        {
            XFreeColormap( XOpenDisplay( NULL ), m_Colormap );
        }

		m_Open = false;
		m_Version = Version( 0, 0, 0 );
		m_DeviceContext = NULL;
	}
Ejemplo n.º 5
0
void xf86_dga2_close_display(void)
{
	if(xf86ctx.device)
	{
		XFree(xf86ctx.device);
		xf86ctx.device = 0;
	}
	if(xf86ctx.modes)
	{
		XFree(xf86ctx.modes);
		xf86ctx.modes = 0;
	}
	if(xf86ctx.cmap)
	{
		XFreeColormap(display,xf86ctx.cmap);
		xf86ctx.cmap = 0;
	}
        sysdep_display_effect_close();
	xinput_close();
	if(xf86ctx.current_mode != -1)
	{
		/* HDG: is this really nescesarry ? */
		XDGASync(display,xf86ctx.screen);
#ifdef TDFX_DGA_WORKAROUND
		/* Restore the right video mode before leaving DGA  */
		/* The tdfx driver would have to do it, but it doesn't work ...*/
		XDGASetMode(display, xf86ctx.screen, xf86ctx.current_X11_mode);
#endif
		XDGASetMode(display, xf86ctx.screen, 0);
		xf86ctx.current_mode = -1;
	}
	XSync(display, True);
}
Ejemplo n.º 6
0
/*
 * Class:     jogamp_nativewindow_x11_X11Lib
 * Method:    DestroyWindow
 * Signature: (JJ)V
 */
JNIEXPORT void JNICALL Java_jogamp_nativewindow_x11_X11Lib_DestroyWindow
  (JNIEnv *env, jclass unused, jlong display, jlong window)
{
    Display * dpy = (Display *)(intptr_t)display;
    Window      w = (Window) window;
    XWindowAttributes xwa;

    if(NULL==dpy) {
        NativewindowCommon_throwNewRuntimeException(env, "invalid display connection..");
        return;
    }

    NativewindowCommon_x11ErrorHandlerEnable(env, dpy, 0, 1, errorHandlerQuiet, 0);
    XSync(dpy, False);
    memset(&xwa, 0, sizeof(XWindowAttributes));
    XGetWindowAttributes(dpy, w, &xwa); // prefetch colormap to be destroyed after window destruction
    XSelectInput(dpy, w, 0);
    XUnmapWindow(dpy, w);
    XSync(dpy, False);
    XDestroyWindow(dpy, w);
    if( None != xwa.colormap ) {
        XFreeColormap(dpy, xwa.colormap);
    }
    // NativewindowCommon_x11ErrorHandlerEnable(env, dpy, 0, 0, errorHandlerQuiet, 1);
}
Ejemplo n.º 7
0
	void clean_x() {
		glXMakeCurrent(display, None, NULL);
		glXDestroyContext(display, ctx);
		XDestroyWindow(display, win);
		XFreeColormap(display, cmap);
		XCloseDisplay(display);
	}
Ejemplo n.º 8
0
void GLcleanup()
{
    CleanupTextureStore();                                // bye textures

#ifdef _WINDOWS
    wglMakeCurrent(NULL, NULL);                           // bye context
    if(GLCONTEXT) wglDeleteContext(GLCONTEXT);
    if(!bWindowMode && dcGlobal)
        ReleaseDC(hWWindow,dcGlobal);
#endif

    eglMakeCurrent( display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT );
    eglDestroySurface( display, surface );
    eglDestroyContext( display, context );
    eglTerminate( display );

#if defined(USE_X11)
    if (pandora_driver_mode == MODE_X11)
    {
        if (x11Window) XDestroyWindow(x11Display, x11Window);
        if (x11Colormap) XFreeColormap( x11Display, x11Colormap );
        if (x11Display) XCloseDisplay(x11Display);
    }
#endif
}
Ejemplo n.º 9
0
WindowDevice::~WindowDevice()
{
   numWindowDevice--;
#ifdef _UNIX
    if (winOpen == 0) { // we must close the old window
	XFreeGC(theDisplay, theGC);
	XDestroyWindow(theDisplay, theWindow); 
    }

    if (numWindowDevice == 0) {
	if (colorFlag == 0 ) 
	  XFreeColors(theDisplay, cmap, pixels, 256, 0);
	else if (colorFlag == 1)
	    XFreeColors(theDisplay, cmap, pixels, 192, 0);
	else if (colorFlag == 2)
	    XFreeColors(theDisplay, cmap, pixels, 64, 0);
	
       	XFreeColormap(theDisplay, cmap);
	XCloseDisplay(theDisplay);
    }

#else
    if (winOpen == 0) { // we must close the window
      oglDestroyWindow(title,theWND, theHRC, theHDC);
    }
#endif
}
Ejemplo n.º 10
0
void _glfwPlatformDestroyWindow(_GLFWwindow* window)
{
    if (window->monitor)
        leaveFullscreenMode(window);

    _glfwDestroyContext(window);

    if (window->x11.handle)
    {
        if (window->x11.handle ==
            XGetSelectionOwner(_glfw.x11.display, _glfw.x11.CLIPBOARD))
        {
            _glfwPushSelectionToManager(window);
        }

        XDeleteContext(_glfw.x11.display, window->x11.handle, _glfw.x11.context);
        XUnmapWindow(_glfw.x11.display, window->x11.handle);
        XDestroyWindow(_glfw.x11.display, window->x11.handle);
        window->x11.handle = (Window) 0;
    }

    if (window->x11.colormap)
    {
        XFreeColormap(_glfw.x11.display, window->x11.colormap);
        window->x11.colormap = (Colormap) 0;
    }
}
Ejemplo n.º 11
0
void
wireframeDelete (WireFrame *wireframe)
{
    ScreenInfo *screen_info;

    g_return_if_fail (wireframe != None);
    TRACE ("entering");

    screen_info = wireframe->screen_info;
    XUnmapWindow (myScreenGetXDisplay (screen_info), wireframe->xwindow);
    if (wireframe->cr)
    {
        cairo_destroy (wireframe->cr);
    }
    if (wireframe->surface)
    {
        cairo_surface_destroy (wireframe->surface);
    }
    if (wireframe->xcolormap != screen_info->cmap)
    {
        XFreeColormap (myScreenGetXDisplay (screen_info), wireframe->xcolormap);
    }
    XDestroyWindow (myScreenGetXDisplay (screen_info), wireframe->xwindow);
    g_free (wireframe);
}
Ejemplo n.º 12
0
void printAndReleaseResources(Display *display, GLXFBConfig *fbConfigList,
        XVisualInfo *visualInfo, Window win, GLXContext ctx, Colormap cmap,
        const char *message) {
    if (message != NULL) {
        fprintf(stderr, "%s\n", message);
    }
    if (display == NULL) {
        return;
    }
    glXMakeCurrent(display, None, NULL);
    if (fbConfigList != NULL) {
        XFree(fbConfigList);
    }
    if (visualInfo != NULL) {
        XFree(visualInfo);
    }
    if (ctx != NULL) {
        glXDestroyContext(display, ctx);
    }
    if (win != None) {
        XDestroyWindow(display, win);
    }
    if (cmap != None) {
        XFreeColormap(display, cmap);
    }
}
Ejemplo n.º 13
0
        XWindow::~XWindow()
        {
            this->m_pGraphicsContext.reset();

            XDestroyWindow(display, window);
            XFreeColormap(display, cmap);
            XCloseDisplay(display);
        }
Ejemplo n.º 14
0
X11Win::~X11Win(void) {
	glXDestroyWindow(_d, _glxWin);
	glXMakeCurrent(_d, 0, 0);
	glXDestroyContext(_d, _ctx);
	XDestroyWindow(_d, _w);
	XFreeColormap(_d, _cmap);
	XCloseDisplay(_d);
}
Ejemplo n.º 15
0
void cXInterface::DestroyWindow(void)
{
	XDestroyWindow(GLWin.evdpy, GLWin.win);
	GLWin.win = 0;
	if (GLWin.xEventThread.joinable())
		GLWin.xEventThread.join();
	XFreeColormap(GLWin.evdpy, GLWin.attr.colormap);
}
Ejemplo n.º 16
0
void cX11Window::DestroyXWindow(void)
{
	XUnmapWindow(dpy, win);
	win = 0;
	if (xEventThread.joinable())
		xEventThread.join();
	XFreeColormap(dpy, colormap);
}
Ejemplo n.º 17
0
void x11_colormap_destroy(void)
{
   if (!g_x11_cmap)
      return;

   XFreeColormap(g_x11_dpy, g_x11_cmap);
   g_x11_cmap = None;
}
Ejemplo n.º 18
0
Archivo: window.cpp Proyecto: det/Twil
Window::~Window() noexcept
{
	auto display = application_->display_;
	XDeleteContext(display, id_, application_->context_);
	glXDestroyContext(display, context_);
	XDestroyWindow(display, id_);
	XFreeColormap(display, colormap_);
}
Ejemplo n.º 19
0
static void DestroyContext(GLContext* ctx)
{
	if (NULL != ctx->dpy && NULL != ctx->ctx) glXDestroyContext(ctx->dpy, ctx->ctx);
	if (NULL != ctx->dpy && 0 != ctx->wnd) XDestroyWindow(ctx->dpy, ctx->wnd);
	if (NULL != ctx->dpy && 0 != ctx->cmap) XFreeColormap(ctx->dpy, ctx->cmap);
	if (NULL != ctx->vi) XFree(ctx->vi);
	if (NULL != ctx->dpy) XCloseDisplay(ctx->dpy);
}
Ejemplo n.º 20
0
void cX11Window::DestroyXWindow(void)
{
	XUnmapWindow(GLWin.evdpy, GLWin.win);
	GLWin.win = 0;
	if (GLWin.xEventThread.joinable())
		GLWin.xEventThread.join();
	XFreeColormap(GLWin.evdpy, GLWin.attr.colormap);
}
static void destroyWindow(JNIEnv *env, Display *disp, Window window) {
	if (glx_window != None) {
		lwjgl_glXDestroyWindow(disp, glx_window);
		glx_window = None;
	}
	XDestroyWindow(disp, window);
	XFreeColormap(disp, cmap);
}
Ejemplo n.º 22
0
void deleteGLContext()
{
    glXMakeCurrent(display, 0, 0);
    glXDestroyContext(display, ctx);

    XDestroyWindow(display, win);
    XFreeColormap(display, cmap);
    XCloseDisplay(display);
}
static Window createWindow(JNIEnv* env, Display *disp, int screen, jint window_mode, X11PeerInfo *peer_info, int x, int y, int width, int height, jboolean undecorated, long parent_handle, jboolean resizable) {
	Window parent = (Window)parent_handle;
	Window win;
	XSetWindowAttributes attribs;
	unsigned int attribmask;

    XVisualInfo vis_info;
    if ( !XMatchVisualInfo(disp, screen, DefaultDepth(disp, screen), TrueColor, &vis_info) ) {
        throwException(env, "Failed to acquire X visual.");
        return false;
    }

	cmap = XCreateColormap(disp, parent, vis_info.visual, AllocNone);
	if (!checkXError(env, disp)) {
		return false;
	}
	attribs.colormap = cmap;
	attribs.border_pixel = 0;
	attribs.event_mask = ExposureMask | FocusChangeMask | VisibilityChangeMask | StructureNotifyMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask;
	attribmask = CWColormap | CWEventMask | CWBorderPixel | CWBackPixel;
	if (isLegacyFullscreen(window_mode)) {
		attribmask |= CWOverrideRedirect;
		attribs.override_redirect = True;
	}
	win = XCreateWindow(disp, parent, x, y, width, height, 0, vis_info.depth, InputOutput, vis_info.visual, attribmask, &attribs);

	current_depth = vis_info.depth;
	current_visual = vis_info.visual;

	if (!checkXError(env, disp)) {
		XFreeColormap(disp, cmap);
		return false;
	}
	if (undecorated) {
		// Use Motif decoration hint property and hope the window manager respects them
		setDecorations(disp, win, 0);
	}

	if (RootWindow(disp, screen) == parent_handle) { // only set hints when Display.setParent isn't used
		updateWindowBounds(disp, win, x, y, width, height, JNI_TRUE, resizable);
		updateWindowHints(env, disp, win);
	}

#define NUM_ATOMS 1
	Atom protocol_atoms[NUM_ATOMS] = {XInternAtom(disp, "WM_DELETE_WINDOW", False)/*, XInternAtom(disp, "WM_TAKE_FOCUS", False)*/};
	XSetWMProtocols(disp, win, protocol_atoms, NUM_ATOMS);
	if (window_mode == org_lwjgl_opengl_LinuxDisplay_FULLSCREEN_NETWM) {
		Atom fullscreen_atom = XInternAtom(disp, "_NET_WM_STATE_FULLSCREEN", False);
		XChangeProperty(disp, win, XInternAtom(disp, "_NET_WM_STATE", False),
						XInternAtom(disp, "ATOM", False), 32, PropModeReplace, (const unsigned char*)&fullscreen_atom, 1);
	}
	if (!checkXError(env, disp)) {
		destroyWindow(env, disp, win);
		return 0;
	}
	return win;
}
Ejemplo n.º 24
0
void X11Terminate()
{
    glXMakeCurrent( display, 0, 0 );
    glXDestroyContext( display, ctx );

    XDestroyWindow( display, win );
    XFreeColormap( display, cmap );
    XCloseDisplay( display );
}
Ejemplo n.º 25
0
Archivo: common.c Proyecto: yesj/J5_A8
void deInitX11(void)
{
    if (x11Window)
        XDestroyWindow(x11Display, x11Window);
    if (x11Colormap)
        XFreeColormap(x11Display, x11Colormap);
    if (x11Display)
        XCloseDisplay(x11Display);
}
Ejemplo n.º 26
0
Archivo: glx.c Proyecto: paud/d2x-xl
void OglDestroyWindow(void){
	if (gameStates.ogl.bInitialized){
		glXDestroyContext(dpy,glxcontext);
		XDestroyWindow(dpy,win);
		XFreeColormap(dpy,swa.colormap);
		gameStates.ogl.bInitialized=0;
	}
	return;
}
Ejemplo n.º 27
0
static void gfx_ctx_destroy(void)
{
   if (g_dpy && g_ctx)
   {
      glXMakeContextCurrent(g_dpy, None, None, NULL);
      glXDestroyContext(g_dpy, g_ctx);
      g_ctx = NULL;
   }

   if (g_win)
   {
      glXDestroyWindow(g_dpy, g_glx_win);
      g_glx_win = 0;

      // Save last used monitor for later.
#ifdef HAVE_XINERAMA
      XWindowAttributes target;
      Window child;

      int x = 0, y = 0;
      XGetWindowAttributes(g_dpy, g_win, &target);
      XTranslateCoordinates(g_dpy, g_win, DefaultRootWindow(g_dpy),
            target.x, target.y, &x, &y, &child);

      g_screen = x11_get_xinerama_monitor(g_dpy, x, y,
            target.width, target.height);

      RARCH_LOG("[GLX]: Saved monitor #%u.\n", g_screen);
#endif

      XUnmapWindow(g_dpy, g_win);
      XDestroyWindow(g_dpy, g_win);
      g_win = None;
   }

   if (g_cmap)
   {
      XFreeColormap(g_dpy, g_cmap);
      g_cmap = None;
   }

   if (g_should_reset_mode)
   {
      x11_exit_fullscreen(g_dpy, &g_desktop_mode);
      g_should_reset_mode = false;
   }

   if (g_dpy)
   {
      XCloseDisplay(g_dpy);
      g_dpy = NULL;
   }

   g_inited = false;
   g_pglSwapInterval = NULL;
}
Ejemplo n.º 28
0
/////////////////////////////////////////////////////////
// destroy window
//
/////////////////////////////////////////////////////////
void gemglxwindow :: destroy(void)
{
  /* both glXMakeCurrent() and XCloseDisplay() will crash the application
   * if the handler of the display (m_pimpl->dpy) is invalid, e.g. because
   * somebody closed the Gem-window with xkill or by clicking on the "x" of the window
   */
  if (m_pimpl->dpy) {
    int err=0;

#ifdef HAVE_LIBXXF86VM
    if (m_pimpl->fs) {
      XF86VidModeSwitchToMode(m_pimpl->dpy, m_pimpl->screen, &m_pimpl->deskMode);
      XF86VidModeSetViewPort(m_pimpl->dpy, m_pimpl->screen, 0, 0);
      m_pimpl->fs=0;
    }
#endif

    /* patch by cesare marilungo to prevent the crash "on my laptop" */
    glXMakeCurrent(m_pimpl->dpy, None,
                   NULL); /* this crashes if no window is there! */
    if (m_pimpl->glxcontext) {
      // this crashes sometimes on my laptop:
      glXDestroyContext(m_pimpl->dpy, m_pimpl->glxcontext);
    }

    if (m_pimpl->win) {
      XUnmapWindow      (m_pimpl->dpy, m_pimpl->win);
      err=XDestroyWindow(m_pimpl->dpy, m_pimpl->win);
      if(err) {
        verbose(1, "XDestroyWindow returned %d", err);
      }
    }

    if (m_pimpl->cmap) {
      err=XFreeColormap(m_pimpl->dpy, m_pimpl->cmap);
      if(err) {
        verbose(1, "XFreeColormap returned %d", err);
      }
    }

    XFlush( m_pimpl->dpy );
    err=XCloseDisplay(m_pimpl->dpy); /* this crashes if no window is there */
    if(err) {
      verbose(1, "XCloseDisplay returned %d", err);
    }
  }
  m_pimpl->dpy = NULL;
  m_pimpl->win = 0;
  m_pimpl->cmap = 0;
  m_pimpl->glxcontext = NULL;
  if(m_pimpl->delete_atom) {
    m_pimpl->delete_atom=None;  /* not very sophisticated destruction...*/
  }

  destroyGemWindow();
}
Ejemplo n.º 29
0
void window_destroy() {
  glXMakeCurrent(windowData.display,0,0);
  glXDestroyContext(windowData.display,windowData.ctx);

  //todo destroy blank cursor
  //todo destroy xi
  XDestroyWindow(windowData.display,windowData.win);
  XFreeColormap(windowData.display,windowData.cmap);
  XCloseDisplay(windowData.display);
}
Ejemplo n.º 30
0
void glewDestroyContext ()
{
  if (NULL != dpy && NULL != ctx) glXDestroyContext(dpy, ctx);
  if (NULL != dpy && 0 != wnd) XDestroyWindow(dpy, wnd);
  if (NULL != dpy && 0 != cmap) XFreeColormap(dpy, cmap);
  if (NULL != vis)
    XFree(vis);
  else if (NULL != vi)
    XFree(vi);
  if (NULL != dpy) XCloseDisplay(dpy);
}