ok. multi-screen (multihead) support with simultaneous display on 2
authorraster <raster@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Thu, 24 Mar 2011 01:45:12 +0000 (01:45 +0000)
committerraster <raster@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Thu, 24 Mar 2011 01:45:12 +0000 (01:45 +0000)
screens with the same gl context is more pain than imagined. revert
attempt to handle it. just use xinerama/twinview if u want the
compositor to not suck.

git-svn-id: http://svn.enlightenment.org/svn/e/trunk/evas@58050 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/modules/engines/gl_x11/evas_x_main.c

index 4316999..e370e75 100644 (file)
@@ -1,26 +1,24 @@
 #include "evas_engine.h"
 
-#define MAXSCRN 16
-
 static Evas_GL_X11_Window *_evas_gl_x11_window = NULL;
 
 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
-static EGLContext  context      [MAXSCRN] = {EGL_NO_CONTEXT};
+static EGLContext context = EGL_NO_CONTEXT;
 #else
 // FIXME: this will only work for 1 display connection (glx land can have > 1)
-static GLXContext  context      [MAXSCRN] = {0};
-static GLXContext  rgba_context [MAXSCRN] = {0};
-static GLXFBConfig fbconf       [MAXSCRN] = {0};
-static GLXFBConfig rgba_fbconf  [MAXSCRN] = {0};
+static GLXContext context = 0;
+static GLXContext rgba_context = 0;
+static GLXFBConfig fbconf = 0;
+static GLXFBConfig rgba_fbconf = 0;
 #endif
 
 // fixme: something is up/wrong here - dont know what tho...
-//#define NEWGL 1
+// #define NEWGL 1
 
-static XVisualInfo *_evas_gl_x11_vi        [MAXSCRN] = {NULL};
-static XVisualInfo *_evas_gl_x11_rgba_vi   [MAXSCRN] = {NULL};
-static Colormap     _evas_gl_x11_cmap      [MAXSCRN] = {0};
-static Colormap     _evas_gl_x11_rgba_cmap [MAXSCRN] = {0};
+static XVisualInfo *_evas_gl_x11_vi = NULL;
+static XVisualInfo *_evas_gl_x11_rgba_vi = NULL;
+static Colormap     _evas_gl_x11_cmap = 0;
+static Colormap     _evas_gl_x11_rgba_cmap = 0;
 
 static int win_count = 0;
 
@@ -47,14 +45,7 @@ eng_window_new(Display *disp,
    XVisualInfo *vi_use;
    const GLubyte *vendor, *renderer, *version;
    
-   if (screen >= MAXSCRN)
-     {
-        ERR("Screen #%i beyond the maximum # of supported screens (%i)",
-            screen, MAXSCRN);
-        return NULL;
-     }
-   
-   if (!_evas_gl_x11_vi[screen]) return NULL;
+   if (!_evas_gl_x11_vi) return NULL;
    
    gw = calloc(1, sizeof(Evas_GL_X11_Window));
    if (!gw) return NULL;
@@ -71,7 +62,7 @@ eng_window_new(Display *disp,
    gw->h = h;
    gw->rot = rot;
 
-   vi_use = _evas_gl_x11_vi[gw->screen];
+   vi_use = _evas_gl_x11_vi;
    if (gw->alpha)
      {
 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
@@ -81,19 +72,17 @@ eng_window_new(Display *disp,
           }
 #else
 #ifdef NEWGL
-/*        
         if (_evas_gl_x11_rgba_vi)
           {
              vi_use = _evas_gl_x11_rgba_vi;
           }
- */
 #endif        
 #endif        
      }
    gw->visualinfo = vi_use;
    
-#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
 // EGL / GLES
+#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
    context_attrs[0] = EGL_CONTEXT_CLIENT_VERSION;
    context_attrs[1] = 2;
    context_attrs[2] = EGL_NONE;
@@ -206,10 +195,10 @@ eng_window_new(Display *disp,
        eng_window_free(gw);
         return NULL;
      }
-   if (context[gw->screen] == EGL_NO_CONTEXT)
-      context[gw->screen] = eglCreateContext(gw->egl_disp, gw->egl_config,
-                                             NULL, context_attrs);
-   gw->egl_context[0] = context[gw->screen];
+   if (context == EGL_NO_CONTEXT)
+     context = eglCreateContext(gw->egl_disp, gw->egl_config, NULL, 
+                                context_attrs);
+   gw->egl_context[0] = context;
    if (gw->egl_context[0] == EGL_NO_CONTEXT)
      {
         ERR("eglCreateContext() fail. code=%#x", eglGetError());
@@ -239,56 +228,52 @@ eng_window_new(Display *disp,
         fprintf(stderr, "renderer: %s\n", renderer);
         fprintf(stderr, "version: %s\n", version);
      }
+// GLX   
 #else
-// GLX
-   if (!context[gw->screen])
+   if (!context)
      {
 #ifdef NEWGL        
-/*
         if (indirect)
-          context[gw->screen] = glXCreateNewContext(gw->disp, fbconf[gw->screen]
+          context = glXCreateNewContext(gw->disp, fbconf
                                         GLX_RGBA_TYPE, NULL, 
                                         GL_TRUE);
         else
-          context[gw->screen] = glXCreateNewContext(gw->disp, fbconf[gw->screen]
+          context = glXCreateNewContext(gw->disp, fbconf
                                         GLX_RGBA_TYPE, NULL, 
                                         GL_FALSE);
- */
 #else
         if (indirect)
-          context[gw->screen] = glXCreateContext(gw->disp, gw->visualinfo, NULL, GL_FALSE);
+          context = glXCreateContext(gw->disp, gw->visualinfo, NULL, GL_FALSE);
         else
-          context[gw->screen] = glXCreateContext(gw->disp, gw->visualinfo, NULL, GL_TRUE);
+          context = glXCreateContext(gw->disp, gw->visualinfo, NULL, GL_TRUE);
 #endif
      }
 #ifdef NEWGL
-/*
-   if ((gw->alpha) && (!rgba_context[gw->screen]))
+   if ((gw->alpha) && (!rgba_context))
      {
         if (indirect)
-          rgba_context[gw->screen] = glXCreateNewContext(gw->disp, rgba_fbconf[gw->screen]
-                                             GLX_RGBA_TYPE, context[gw->screen]
+          rgba_context = glXCreateNewContext(gw->disp, rgba_fbconf
+                                             GLX_RGBA_TYPE, context, 
                                              GL_TRUE);
         else
-          rgba_context[gw->screen] = glXCreateNewContext(gw->disp, rgba_fbconf[gw->screen]
-                                             GLX_RGBA_TYPE, context[gw->screen]
+          rgba_context = glXCreateNewContext(gw->disp, rgba_fbconf
+                                             GLX_RGBA_TYPE, context, 
                                              GL_FALSE);
      }
    if (gw->alpha)
-     gw->glxwin = glXCreateWindow(gw->disp, rgba_fbconf[gw->screen], gw->win, NULL);
+     gw->glxwin = glXCreateWindow(gw->disp, rgba_fbconf, gw->win, NULL);
    else
-     gw->glxwin = glXCreateWindow(gw->disp, fbconf[gw->screen], gw->win, NULL);
+     gw->glxwin = glXCreateWindow(gw->disp, fbconf, gw->win, NULL);
    if (!gw->glxwin)
      {
        eng_window_free(gw);
         return NULL;
      }
    
-   if (gw->alpha) gw->context = rgba_context[gw->screen];
-   else gw->context = context[gw->screen];
- */
+   if (gw->alpha) gw->context = rgba_context;
+   else gw->context = context;
 #else   
-   gw->context = context[gw->screen];
+   gw->context = context;
 #endif
 
    if (!gw->context)
@@ -549,21 +534,21 @@ eng_window_free(Evas_GL_X11_Window *gw)
      eglDestroySurface(gw->egl_disp, gw->egl_surface[0]);
    if (ref == 0)
      {
-        if (context[gw->screen]) eglDestroyContext(gw->egl_disp, context[gw->screen]);
+        if (context) eglDestroyContext(gw->egl_disp, context);
         eglTerminate(gw->egl_disp);
-        context[gw->screen] = EGL_NO_CONTEXT;
+        context = EGL_NO_CONTEXT;
      }
    eglMakeCurrent(gw->egl_disp, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
 #else
    if (gw->glxwin) glXDestroyWindow(gw->disp, gw->glxwin);
    if (ref == 0)
      {
-        if (context[gw->screen]) glXDestroyContext(gw->disp, context[gw->screen]);
-        if (rgba_context[gw->screen]) glXDestroyContext(gw->disp, rgba_context[gw->screen]);
-        context[gw->screen] = 0;
-        rgba_context[gw->screen] = 0;
-        fbconf[gw->screen] = 0;
-        rgba_fbconf[gw->screen] = 0;
+        if (context) glXDestroyContext(gw->disp, context);
+        if (rgba_context) glXDestroyContext(gw->disp, rgba_context);
+        context = 0;
+        rgba_context = 0;
+        fbconf = 0;
+        rgba_fbconf = 0;
      }
 #endif
    free(gw);
@@ -708,7 +693,7 @@ eng_best_visual_get(Evas_Engine_Info_GL_X11 *einfo)
 {
    if (!einfo) return NULL;
    if (!einfo->info.display) return NULL;
-   if (!_evas_gl_x11_vi[einfo->info.screen])
+   if (!_evas_gl_x11_vi)
      {
         int alpha;
         
@@ -753,10 +738,10 @@ eng_best_visual_get(Evas_Engine_Info_GL_X11 *einfo)
                }
              else
                {
-                  _evas_gl_x11_vi[einfo->info.screen] = calloc(1, sizeof(XVisualInfo));
+                  _evas_gl_x11_vi = calloc(1, sizeof(XVisualInfo));
                   XMatchVisualInfo(einfo->info.display,
                                    einfo->info.screen, depth, TrueColor,
-                                   _evas_gl_x11_vi[einfo->info.screen]);
+                                   _evas_gl_x11_vi);
                }
           }
 // GLX
@@ -821,9 +806,9 @@ eng_best_visual_get(Evas_Engine_Info_GL_X11 *einfo)
                   if (!alpha)
                     {
                        config = configs[i];
-                       _evas_gl_x11_vi[einfo->info.screen] = malloc(sizeof(XVisualInfo));
-                       memcpy(_evas_gl_x11_vi[einfo->info.screen], visinfo, sizeof(XVisualInfo));
-                       fbconf[einfo->info.screen] = config;
+                       _evas_gl_x11_vi = malloc(sizeof(XVisualInfo));
+                       memcpy(_evas_gl_x11_vi, visinfo, sizeof(XVisualInfo));
+                       fbconf = config;
                        XFree(visinfo);
                        break;
                     }
@@ -839,9 +824,9 @@ eng_best_visual_get(Evas_Engine_Info_GL_X11 *einfo)
                        if (format->direct.alphaMask > 0)
                          {
                             config = configs[i];
-                            _evas_gl_x11_rgba_vi[einfo->info.screen] = malloc(sizeof(XVisualInfo));
-                            memcpy(_evas_gl_x11_rgba_vi[einfo->info.screen], visinfo, sizeof(XVisualInfo));
-                            rgba_fbconf[einfo->info.screen] = config;
+                            _evas_gl_x11_rgba_vi = malloc(sizeof(XVisualInfo));
+                            memcpy(_evas_gl_x11_rgba_vi, visinfo, sizeof(XVisualInfo));
+                            rgba_fbconf = config;
                             XFree(visinfo);
                             break;
                          }
@@ -851,21 +836,19 @@ eng_best_visual_get(Evas_Engine_Info_GL_X11 *einfo)
           }
 #endif
      }
-   if (!_evas_gl_x11_vi[einfo->info.screen]) return NULL;
+   if (!_evas_gl_x11_vi) return NULL;
    if (einfo->info.destination_alpha)
      {
 // EGL / GLES
 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
-        if (_evas_gl_x11_rgba_vi[einfo->info.screen])
-           return _evas_gl_x11_rgba_vi[einfo->info.screen]->visual;
+        if (_evas_gl_x11_rgba_vi) return _evas_gl_x11_rgba_vi->visual;
 #else        
 # ifdef NEWGL
-        if (_evas_gl_x11_rgba_vi[einfo->info.screen])
-           return _evas_gl_x11_rgba_vi[einfo->info.screen]->visual;
+        if (_evas_gl_x11_rgba_vi) return _evas_gl_x11_rgba_vi->visual;
 # endif
 #endif        
      }
-   return _evas_gl_x11_vi[einfo->info.screen]->visual;
+   return _evas_gl_x11_vi->visual;
 }
 
 Colormap
@@ -873,27 +856,27 @@ eng_best_colormap_get(Evas_Engine_Info_GL_X11 *einfo)
 {
    if (!einfo) return 0;
    if (!einfo->info.display) return 0;
-   if (!_evas_gl_x11_vi[einfo->info.screen]) eng_best_visual_get(einfo);
-   if (!_evas_gl_x11_vi[einfo->info.screen]) return 0;
+   if (!_evas_gl_x11_vi) eng_best_visual_get(einfo);
+   if (!_evas_gl_x11_vi) return 0;
    if (einfo->info.destination_alpha)
      {
-        if (!_evas_gl_x11_rgba_cmap[einfo->info.screen])
-          _evas_gl_x11_rgba_cmap[einfo->info.screen] = 
+        if (!_evas_gl_x11_rgba_cmap)
+          _evas_gl_x11_rgba_cmap = 
           XCreateColormap(einfo->info.display,
                           RootWindow(einfo->info.display,
                                      einfo->info.screen),
-                          _evas_gl_x11_rgba_vi[einfo->info.screen]->visual, 
+                          _evas_gl_x11_rgba_vi->visual, 
                           0);
-        return _evas_gl_x11_rgba_cmap[einfo->info.screen];
+        return _evas_gl_x11_rgba_cmap;
      }
-   if (!_evas_gl_x11_cmap[einfo->info.screen])
-     _evas_gl_x11_cmap[einfo->info.screen] = 
+   if (!_evas_gl_x11_cmap)
+     _evas_gl_x11_cmap = 
      XCreateColormap(einfo->info.display,
                      RootWindow(einfo->info.display,
                                 einfo->info.screen),
-                     _evas_gl_x11_vi[einfo->info.screen]->visual, 
+                     _evas_gl_x11_vi->visual, 
                      0);
-   return _evas_gl_x11_cmap[einfo->info.screen];
+   return _evas_gl_x11_cmap;
 }
                                  
 int
@@ -901,12 +884,11 @@ eng_best_depth_get(Evas_Engine_Info_GL_X11 *einfo)
 {
    if (!einfo) return 0;
    if (!einfo->info.display) return 0;
-   if (!_evas_gl_x11_vi[einfo->info.screen]) eng_best_visual_get(einfo);
-   if (!_evas_gl_x11_vi[einfo->info.screen]) return 0;
+   if (!_evas_gl_x11_vi) eng_best_visual_get(einfo);
+   if (!_evas_gl_x11_vi) return 0;
    if (einfo->info.destination_alpha)
      {
-        if (_evas_gl_x11_rgba_vi[einfo->info.screen])
-           return _evas_gl_x11_rgba_vi[einfo->info.screen]->depth;
+        if (_evas_gl_x11_rgba_vi) return _evas_gl_x11_rgba_vi->depth;
      }
-   return _evas_gl_x11_vi[einfo->info.screen]->depth;
+   return _evas_gl_x11_vi->depth;
 }