diff options
-rw-r--r-- | platform/x11/context_gl_x11.cpp | 10 | ||||
-rw-r--r-- | platform/x11/os_x11.cpp | 39 | ||||
-rw-r--r-- | platform/x11/os_x11.h | 1 |
3 files changed, 33 insertions, 17 deletions
diff --git a/platform/x11/context_gl_x11.cpp b/platform/x11/context_gl_x11.cpp index dc0dc063b9..3db1f6da25 100644 --- a/platform/x11/context_gl_x11.cpp +++ b/platform/x11/context_gl_x11.cpp @@ -46,7 +46,6 @@ struct ContextGL_X11_Private { ::GLXContext glx_context; }; - void ContextGL_X11::release_current() { glXMakeCurrent(x11_display, None, NULL); @@ -56,10 +55,12 @@ void ContextGL_X11::make_current() { glXMakeCurrent(x11_display, x11_window, p->glx_context); } + void ContextGL_X11::swap_buffers() { glXSwapBuffers(x11_display,x11_window); } + /* static GLWrapperFuncPtr wrapper_get_proc_address(const char* p_function) { @@ -154,6 +155,9 @@ Error ContextGL_X11::initialize() { */ //glXMakeCurrent(x11_display, None, NULL); + XFree( vi ); + XFree( fbc ); + return OK; } @@ -164,12 +168,12 @@ int ContextGL_X11::get_window_width() { return xwa.width; } + int ContextGL_X11::get_window_height() { XWindowAttributes xwa; XGetWindowAttributes(x11_display,x11_window,&xwa); return xwa.height; - } @@ -189,6 +193,8 @@ ContextGL_X11::ContextGL_X11(::Display *p_x11_display,::Window &p_x11_window,con ContextGL_X11::~ContextGL_X11() { + release_current(); + glXDestroyContext( x11_display, p->glx_context ); memdelete( p ); } diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index 85928f2815..d538b4c7b6 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -153,6 +153,7 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi XFree (xim_styles); } + XFree( imvalret ); } /* @@ -351,6 +352,7 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi for(int i=0;i<CURSOR_MAX;i++) { cursors[i]=None; + img[i]=NULL; } current_cursor=CURSOR_ARROW; @@ -379,16 +381,15 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi "question_arrow" }; - XcursorImage *img = XcursorLibraryLoadImage(cursor_file[i],cursor_theme,cursor_size); - if (img) { - cursors[i]=XcursorImageLoadCursor(x11_display,img); + img[i] = XcursorLibraryLoadImage(cursor_file[i],cursor_theme,cursor_size); + if (img[i]) { + cursors[i]=XcursorImageLoadCursor(x11_display,img[i]); //print_line("found cursor: "+String(cursor_file[i])+" id "+itos(cursors[i])); } else { if (OS::is_stdout_verbose()) print_line("failed cursor: "+String(cursor_file[i])); } } - } @@ -399,9 +400,9 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi XColor col; Cursor cursor; - cursormask = XCreatePixmap(x11_display, RootWindow(x11_display,DefaultScreen(x11_display)), 1, 1, 1); - xgc.function = GXclear; - gc = XCreateGC(x11_display, cursormask, GCFunction, &xgc); + cursormask = XCreatePixmap(x11_display, RootWindow(x11_display,DefaultScreen(x11_display)), 1, 1, 1); + xgc.function = GXclear; + gc = XCreateGC(x11_display, cursormask, GCFunction, &xgc); XFillRectangle(x11_display, cursormask, gc, 0, 0, 1, 1); col.pixel = 0; col.red = 0; @@ -438,13 +439,8 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi _ensure_data_dir(); - net_wm_icon = XInternAtom(x11_display, "_NET_WM_ICON", False); - - - - //printf("got map notify\n"); - } + void OS_X11::finalize() { if(main_loop) @@ -476,14 +472,26 @@ void OS_X11::finalize() { memdelete(input); + XUnmapWindow( x11_display, x11_window ); + XDestroyWindow( x11_display, x11_window ); + #if defined(OPENGL_ENABLED) || defined(LEGACYGL_ENABLED) memdelete(context_gl); #endif - + for(int i=0;i<CURSOR_MAX;i++) { + if( cursors[i] != None ) + XFreeCursor( x11_display, cursors[i] ); + if( img[i] != NULL ) + XcursorImageDestroy( img[i] ); + }; + + XDestroyIC( xic ); + XCloseIM( xim ); XCloseDisplay(x11_display); if (xmbstring) memfree(xmbstring); + args.clear(); } @@ -1861,7 +1869,6 @@ void OS_X11::set_cursor_shape(CursorShape p_shape) { XDefineCursor(x11_display,x11_window,cursors[CURSOR_ARROW]); } - current_cursor=p_shape; } @@ -1894,6 +1901,8 @@ void OS_X11::alert(const String& p_alert,const String& p_title) { } void OS_X11::set_icon(const Image& p_icon) { + net_wm_icon = XInternAtom(x11_display, "_NET_WM_ICON", False); + if (!p_icon.empty()) { Image img=p_icon; img.convert(Image::FORMAT_RGBA); diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h index 1566062b9e..1258dff7a9 100644 --- a/platform/x11/os_x11.h +++ b/platform/x11/os_x11.h @@ -119,6 +119,7 @@ class OS_X11 : public OS_Unix { const char *cursor_theme; int cursor_size; + XcursorImage *img[CURSOR_MAX]; Cursor cursors[CURSOR_MAX]; Cursor null_cursor; CursorShape current_cursor; |