Merge branch 'master' into blender2.8
authorCampbell Barton <ideasman42@gmail.com>
Sat, 9 Jun 2018 10:06:33 +0000 (12:06 +0200)
committerCampbell Barton <ideasman42@gmail.com>
Sat, 9 Jun 2018 10:06:33 +0000 (12:06 +0200)
1  2 
intern/ghost/intern/GHOST_SystemX11.cpp

index e50df358cb299f451b0dc83b846fa37e8e406d6c,b8069e81eab9471ad66cf4767ba26ced3ed2482b..ce89b5c8758ed60c204a2bab78d75fa8636ef7c6
  
  #include "GHOST_Debug.h"
  
 +#if defined(WITH_GL_EGL)
 +#  include "GHOST_ContextEGL.h"
 +#else
 +#  include "GHOST_ContextGLX.h"
 +#endif
 +
  #ifdef WITH_XF86KEYSYM
  #include <X11/XF86keysym.h>
  #endif
@@@ -125,7 -119,6 +125,7 @@@ GHOST_SystemX11
        m_xkb_descr(NULL),
        m_start_time(0)
  {
 +      XInitThreads();
        m_display = XOpenDisplay(NULL);
  
        if (!m_display) {
@@@ -406,97 -399,6 +406,97 @@@ bool GHOST_SystemX11::supportsNativeDia
        return false;
  }
  
 +/**
 + * Create a new offscreen context.
 + * Never explicitly delete the context, use disposeContext() instead.
 + * \return  The new context (or 0 if creation failed).
 + */
 +GHOST_IContext *
 +GHOST_SystemX11::
 +createOffscreenContext()
 +{
 +      // During development:
 +      //   try 4.x compatibility profile
 +      //   try 3.3 compatibility profile
 +      //   fall back to 3.0 if needed
 +      //
 +      // Final Blender 2.8:
 +      //   try 4.x core profile
 +      //   try 3.3 core profile
 +      //   no fallbacks
 +
 +#if defined(WITH_GL_PROFILE_CORE)
 +      {
 +              const char *version_major = (char*)glewGetString(GLEW_VERSION_MAJOR);
 +              if (version_major != NULL && version_major[0] == '1') {
 +                      fprintf(stderr, "Error: GLEW version 2.0 and above is required.\n");
 +                      abort();
 +              }
 +      }
 +#endif
 +
 +      const int profile_mask =
 +#if defined(WITH_GL_PROFILE_CORE)
 +              GLX_CONTEXT_CORE_PROFILE_BIT_ARB;
 +#elif defined(WITH_GL_PROFILE_COMPAT)
 +              GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
 +#else
 +#  error // must specify either core or compat at build time
 +#endif
 +
 +      GHOST_Context *context;
 +
 +      for (int minor = 5; minor >= 0; --minor) {
 +              context = new GHOST_ContextGLX(
 +                      false,
 +                      0,
 +                      (Window)NULL,
 +                      m_display,
 +                      (GLXFBConfig)NULL,
 +                      profile_mask,
 +                      4, minor,
 +                      GHOST_OPENGL_GLX_CONTEXT_FLAGS | (false ? GLX_CONTEXT_DEBUG_BIT_ARB : 0),
 +                      GHOST_OPENGL_GLX_RESET_NOTIFICATION_STRATEGY);
 +
 +              if (context->initializeDrawingContext())
 +                      return context;
 +              else
 +                      delete context;
 +      }
 +
 +      context = new GHOST_ContextGLX(
 +              false,
 +              0,
 +              (Window)NULL,
 +              m_display,
 +              (GLXFBConfig)NULL,
 +              profile_mask,
 +              3, 3,
 +              GHOST_OPENGL_GLX_CONTEXT_FLAGS | (false ? GLX_CONTEXT_DEBUG_BIT_ARB : 0),
 +              GHOST_OPENGL_GLX_RESET_NOTIFICATION_STRATEGY);
 +
 +      if (context->initializeDrawingContext())
 +              return context;
 +      else
 +              delete context;
 +
 +      return NULL;
 +}
 +
 +/**
 + * Dispose of a context.
 + * \param   context Pointer to the context to be disposed.
 + * \return  Indication of success.
 + */
 +GHOST_TSuccess
 +GHOST_SystemX11::
 +disposeContext(GHOST_IContext *context)
 +{
 +      delete context;
 +
 +      return GHOST_kSuccess;
 +}
 +
  #if defined(WITH_X11_XINPUT) && defined(X_HAVE_UTF8_STRING)
  static void destroyIMCallback(XIM /*xim*/, XPointer ptr, XPointer /*data*/)
  {
@@@ -969,7 -871,6 +969,6 @@@ GHOST_SystemX11::processEvent(XEvent *x
                {
                        XKeyEvent *xke = &(xe->xkey);
                        KeySym key_sym;
-                       KeySym key_sym_str;
                        char ascii;
  #if defined(WITH_X11_XINPUT) && defined(X_HAVE_UTF8_STRING)
                        /* utf8_array[] is initial buffer used for Xutf8LookupString().
                         *
                         * [1] http://cgit.freedesktop.org/xorg/lib/libX11/tree/src/KeyBind.c
                         */
+                       KeySym key_sym_str;
                        /* Mode_switch 'modifier' is AltGr - when this one or Shift are enabled, we do not want to apply
                         * that 'forced number' hack. */
                        const unsigned int mode_switch_mask = XkbKeysymToModifiers(xke->display, XK_Mode_switch);
                                key_sym = XLookupKeysym(xke, 0);
                        }
  
-                       gkey = ghost_key_from_keysym(key_sym);
+                       gkey = ghost_key_from_keysym_or_keycode(key_sym, m_xkb_descr, xke->keycode);
  
                        if (!XLookupString(xke, &ascii, 1, NULL, NULL)) {
                                ascii = '\0';