Changeset View
Changeset View
Standalone View
Standalone View
intern/ghost/intern/GHOST_WindowX11.cpp
| Show All 22 Lines | |||||
| /* For standard X11 cursors */ | /* For standard X11 cursors */ | ||||
| #include <X11/cursorfont.h> | #include <X11/cursorfont.h> | ||||
| #include <X11/Xatom.h> | #include <X11/Xatom.h> | ||||
| #include <X11/Xutil.h> | #include <X11/Xutil.h> | ||||
| #ifdef WITH_X11_ALPHA | #ifdef WITH_X11_ALPHA | ||||
| # include <X11/extensions/Xrender.h> | # include <X11/extensions/Xrender.h> | ||||
| #endif | #endif | ||||
| #include <X11/Xmd.h> | |||||
brecht: What is this needed for? This seems to define a bunch of stuff which is available in C99… | |||||
christian.rauchAuthorUnsubmitted Done Inline ActionsIt defines CARD32 which is used in some places. christian.rauch: It defines `CARD32` which is used in some places. | |||||
| #include "GHOST_WindowX11.h" | #include "GHOST_WindowX11.h" | ||||
| #include "GHOST_SystemX11.h" | #include "GHOST_SystemX11.h" | ||||
| #include "GHOST_IconX11.h" | #include "GHOST_IconX11.h" | ||||
| #include "STR_String.h" | #include "STR_String.h" | ||||
| #include "GHOST_Debug.h" | #include "GHOST_Debug.h" | ||||
| #ifdef WITH_XDND | #ifdef WITH_XDND | ||||
| # include "GHOST_DropTargetX11.h" | # include "GHOST_DropTargetX11.h" | ||||
| #endif | #endif | ||||
| #if defined(WITH_GL_EGL) | #if defined(WITH_GL_EGL) | ||||
| # include "GHOST_ContextEGL.h" | # include "GHOST_ContextEGL.h" | ||||
| # include <EGL/eglext.h> | |||||
| #else | #else | ||||
| # include "GHOST_ContextGLX.h" | # include "GHOST_ContextGLX.h" | ||||
| #endif | #endif | ||||
| /* for XIWarpPointer */ | /* for XIWarpPointer */ | ||||
| #ifdef WITH_X11_XINPUT | #ifdef WITH_X11_XINPUT | ||||
| # include <X11/extensions/XInput2.h> | # include <X11/extensions/XInput2.h> | ||||
| #endif | #endif | ||||
| ▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | |||||
| * the work of the window manager. In case, we send | * the work of the window manager. In case, we send | ||||
| * a ClientMessage to the RootWindow with the property | * a ClientMessage to the RootWindow with the property | ||||
| * and the Action (WM-spec define this): | * and the Action (WM-spec define this): | ||||
| */ | */ | ||||
| #define _NET_WM_STATE_REMOVE 0 | #define _NET_WM_STATE_REMOVE 0 | ||||
| #define _NET_WM_STATE_ADD 1 | #define _NET_WM_STATE_ADD 1 | ||||
| // #define _NET_WM_STATE_TOGGLE 2 // UNUSED | // #define _NET_WM_STATE_TOGGLE 2 // UNUSED | ||||
| #if defined(WITH_GL_EGL) | |||||
| static XVisualInfo *x11_visualinfo_from_egl(Display *display) | |||||
| { | |||||
| int numVisuals; | |||||
| XVisualInfo vtempl; | |||||
| vtempl.screen = DefaultScreen(display); | |||||
| return XGetVisualInfo(display, VisualScreenMask, &vtempl, &numVisuals); | |||||
| } | |||||
| #else | |||||
| static XVisualInfo *x11_visualinfo_from_glx(Display *display, | static XVisualInfo *x11_visualinfo_from_glx(Display *display, | ||||
| bool stereoVisual, | bool stereoVisual, | ||||
| bool needAlpha, | bool needAlpha, | ||||
| GLXFBConfig *fbconfig) | GLXFBConfig *fbconfig) | ||||
| { | { | ||||
| int glx_major, glx_minor, glx_version; /* GLX version: major.minor */ | int glx_major, glx_minor, glx_version; /* GLX version: major.minor */ | ||||
| int glx_attribs[64]; | int glx_attribs[64]; | ||||
| ▲ Show 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | #endif | ||||
| fprintf(stderr, | fprintf(stderr, | ||||
| "%s:%d: X11 glXChooseVisual() failed, " | "%s:%d: X11 glXChooseVisual() failed, " | ||||
| "verify working openGL system!\n", | "verify working openGL system!\n", | ||||
| __FILE__, | __FILE__, | ||||
| __LINE__); | __LINE__); | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| #endif // WITH_GL_EGL | |||||
| GHOST_WindowX11::GHOST_WindowX11(GHOST_SystemX11 *system, | GHOST_WindowX11::GHOST_WindowX11(GHOST_SystemX11 *system, | ||||
| Display *display, | Display *display, | ||||
| const STR_String &title, | const STR_String &title, | ||||
| GHOST_TInt32 left, | GHOST_TInt32 left, | ||||
| GHOST_TInt32 top, | GHOST_TInt32 top, | ||||
| GHOST_TUns32 width, | GHOST_TUns32 width, | ||||
| GHOST_TUns32 height, | GHOST_TUns32 height, | ||||
| Show All 21 Lines | |||||
| #endif | #endif | ||||
| #if defined(WITH_X11_XINPUT) && defined(X_HAVE_UTF8_STRING) | #if defined(WITH_X11_XINPUT) && defined(X_HAVE_UTF8_STRING) | ||||
| m_xic(NULL), | m_xic(NULL), | ||||
| #endif | #endif | ||||
| m_valid_setup(false), | m_valid_setup(false), | ||||
| m_is_debug_context(is_debug) | m_is_debug_context(is_debug) | ||||
| { | { | ||||
| if (type == GHOST_kDrawingContextTypeOpenGL) { | if (type == GHOST_kDrawingContextTypeOpenGL) { | ||||
| #if defined(WITH_GL_EGL) | |||||
| m_visualInfo = x11_visualinfo_from_egl(m_display); | |||||
| (void) alphaBackground; | |||||
| #else | |||||
| m_visualInfo = x11_visualinfo_from_glx( | m_visualInfo = x11_visualinfo_from_glx( | ||||
| m_display, stereoVisual, alphaBackground, (GLXFBConfig *)&m_fbconfig); | m_display, stereoVisual, alphaBackground, (GLXFBConfig *)&m_fbconfig); | ||||
| #endif | |||||
| } | } | ||||
| else { | else { | ||||
| XVisualInfo tmp = {0}; | XVisualInfo tmp = {0}; | ||||
| int n; | int n; | ||||
| m_visualInfo = XGetVisualInfo(m_display, 0, &tmp, &n); | m_visualInfo = XGetVisualInfo(m_display, 0, &tmp, &n); | ||||
| } | } | ||||
| /* caller needs to check 'getValid()' */ | /* caller needs to check 'getValid()' */ | ||||
| ▲ Show 20 Lines • Show All 1,070 Lines • ▼ Show 20 Lines | #if defined(WITH_GL_PROFILE_CORE) | ||||
| if (version_major != NULL && version_major[0] == '1') { | if (version_major != NULL && version_major[0] == '1') { | ||||
| fprintf(stderr, "Error: GLEW version 2.0 and above is required.\n"); | fprintf(stderr, "Error: GLEW version 2.0 and above is required.\n"); | ||||
| abort(); | abort(); | ||||
| } | } | ||||
| } | } | ||||
| #endif | #endif | ||||
| const int profile_mask = | const int profile_mask = | ||||
| #ifdef WITH_GL_EGL | |||||
| # if defined(WITH_GL_PROFILE_CORE) | |||||
| EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT; | |||||
| # elif defined(WITH_GL_PROFILE_COMPAT) | |||||
| EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT; | |||||
| # else | |||||
| # error // must specify either core or compat at build time | |||||
| # endif | |||||
| #else | |||||
| #if defined(WITH_GL_PROFILE_CORE) | # if defined(WITH_GL_PROFILE_CORE) | ||||
| GLX_CONTEXT_CORE_PROFILE_BIT_ARB; | GLX_CONTEXT_CORE_PROFILE_BIT_ARB; | ||||
| #elif defined(WITH_GL_PROFILE_COMPAT) | # elif defined(WITH_GL_PROFILE_COMPAT) | ||||
| GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; | GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; | ||||
| #else | # else | ||||
| # error // must specify either core or compat at build time | # error // must specify either core or compat at build time | ||||
| #endif | # endif | ||||
| #endif | |||||
| GHOST_Context *context; | GHOST_Context *context; | ||||
| for (int minor = 5; minor >= 0; --minor) { | for (int minor = 5; minor >= 0; --minor) { | ||||
| #if defined(WITH_GL_EGL) | |||||
| context = new GHOST_ContextEGL(m_wantStereoVisual, | |||||
| EGLNativeWindowType(m_window), | |||||
| EGLNativeDisplayType(m_display), | |||||
| profile_mask, | |||||
| 4, | |||||
| minor, | |||||
| GHOST_OPENGL_EGL_CONTEXT_FLAGS | | |||||
| (m_is_debug_context ? EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR : 0), | |||||
| GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY, | |||||
| EGL_OPENGL_API); | |||||
| #else | |||||
| context = new GHOST_ContextGLX(m_wantStereoVisual, | context = new GHOST_ContextGLX(m_wantStereoVisual, | ||||
| m_window, | m_window, | ||||
| m_display, | m_display, | ||||
| (GLXFBConfig)m_fbconfig, | (GLXFBConfig)m_fbconfig, | ||||
| profile_mask, | profile_mask, | ||||
| 4, | 4, | ||||
| minor, | minor, | ||||
| GHOST_OPENGL_GLX_CONTEXT_FLAGS | | GHOST_OPENGL_GLX_CONTEXT_FLAGS | | ||||
| (m_is_debug_context ? GLX_CONTEXT_DEBUG_BIT_ARB : 0), | (m_is_debug_context ? GLX_CONTEXT_DEBUG_BIT_ARB : 0), | ||||
| GHOST_OPENGL_GLX_RESET_NOTIFICATION_STRATEGY); | GHOST_OPENGL_GLX_RESET_NOTIFICATION_STRATEGY); | ||||
| #endif | |||||
| if (context->initializeDrawingContext()) | if (context->initializeDrawingContext()) | ||||
| return context; | return context; | ||||
| else | else | ||||
| delete context; | delete context; | ||||
| } | } | ||||
| #if defined(WITH_GL_EGL) | |||||
| context = new GHOST_ContextEGL(m_wantStereoVisual, | |||||
| EGLNativeWindowType(m_window), | |||||
| EGLNativeDisplayType(m_display), | |||||
| profile_mask, | |||||
| 3, | |||||
| 3, | |||||
| GHOST_OPENGL_EGL_CONTEXT_FLAGS | | |||||
| (m_is_debug_context ? EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR : 0), | |||||
| GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY, | |||||
| EGL_OPENGL_API); | |||||
| #else | |||||
| context = new GHOST_ContextGLX(m_wantStereoVisual, | context = new GHOST_ContextGLX(m_wantStereoVisual, | ||||
| m_window, | m_window, | ||||
| m_display, | m_display, | ||||
| (GLXFBConfig)m_fbconfig, | (GLXFBConfig)m_fbconfig, | ||||
| profile_mask, | profile_mask, | ||||
| 3, | 3, | ||||
| 3, | 3, | ||||
| GHOST_OPENGL_GLX_CONTEXT_FLAGS | | GHOST_OPENGL_GLX_CONTEXT_FLAGS | | ||||
| (m_is_debug_context ? GLX_CONTEXT_DEBUG_BIT_ARB : 0), | (m_is_debug_context ? GLX_CONTEXT_DEBUG_BIT_ARB : 0), | ||||
| GHOST_OPENGL_GLX_RESET_NOTIFICATION_STRATEGY); | GHOST_OPENGL_GLX_RESET_NOTIFICATION_STRATEGY); | ||||
| #endif | |||||
| if (context->initializeDrawingContext()) | if (context->initializeDrawingContext()) | ||||
| return context; | return context; | ||||
| else | else | ||||
| delete context; | delete context; | ||||
| /* Ugly, but we get crashes unless a whole bunch of systems are patched. */ | /* Ugly, but we get crashes unless a whole bunch of systems are patched. */ | ||||
| fprintf(stderr, "Error! Unsupported graphics card or driver.\n"); | fprintf(stderr, "Error! Unsupported graphics card or driver.\n"); | ||||
| ▲ Show 20 Lines • Show All 352 Lines • Show Last 20 Lines | |||||
What is this needed for? This seems to define a bunch of stuff which is available in C99 already.