emotion: disable direct rendering path if window manager doesn't handle it.
authorcedric <cedric>
Fri, 21 Oct 2011 15:00:41 +0000 (15:00 +0000)
committercedric <cedric@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Fri, 21 Oct 2011 15:00:41 +0000 (15:00 +0000)
git-svn-id: http://svn.enlightenment.org/svn/e/trunk/emotion@64256 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/modules/gstreamer/emotion_gstreamer.c
src/modules/gstreamer/emotion_gstreamer.h
src/modules/gstreamer/emotion_sink.c

index 1e9a40f..b9ba0da 100644 (file)
@@ -7,6 +7,7 @@
 #include "emotion_gstreamer.h"
 #include "Emotion.h"
 
+Eina_Bool window_manager_video = EINA_FALSE;
 int _emotion_gstreamer_log_domain = -1;
 Eina_Bool debug_fps = EINA_FALSE;
 
@@ -1259,6 +1260,11 @@ module_open(Evas_Object           *obj,
             void                 **video,
             Emotion_Module_Options *opt)
 {
+#ifdef HAVE_ECORE_X
+   Ecore_X_Window *roots;
+   int num;
+#endif
+
    if (!module)
      return EINA_FALSE;
 
@@ -1284,6 +1290,54 @@ module_open(Evas_Object           *obj,
 
    eina_threads_init();
 
+#ifdef HAVE_ECORE_X
+   /* Check if the window manager is able to handle our special Xv window. */
+   roots = ecore_x_window_root_list(&num);
+   if (roots && num > 0)
+     {
+        Ecore_X_Window  win, twin;
+        int nwins;
+
+        nwins = ecore_x_window_prop_window_get(roots[0],
+                                               ECORE_X_ATOM_NET_SUPPORTING_WM_CHECK,
+                                               &win, 1);
+        if (nwins > 0)
+          {
+             nwins = ecore_x_window_prop_window_get(win,
+                                                    ECORE_X_ATOM_NET_SUPPORTING_WM_CHECK,
+                                                    &twin, 1);
+             if (nwins > 0 && twin == win)
+               {
+                  Ecore_X_Atom *supported;
+                  int supported_num;
+                  int i;
+
+                  if (ecore_x_netwm_supported_get(roots[0], &supported, &supported_num))
+                    {
+                       Eina_Bool parent = EINA_FALSE;
+                       Eina_Bool video_position = EINA_FALSE;
+
+                       for (i = 0; i < supported_num; ++i)
+                         {
+                            if (supported[i] == ECORE_X_ATOM_E_VIDEO_PARENT)
+                              parent = EINA_TRUE;
+                            else if (supported[i] == ECORE_X_ATOM_E_VIDEO_POSITION)
+                              video_position = EINA_TRUE;
+                            if (parent && video_position)
+                              break;
+                         }
+
+                       if (parent && video_position)
+                         {
+                            window_manager_video = EINA_TRUE;
+                         }
+                    }
+               }
+          }
+     }
+   free(roots);
+#endif
+
    *module = &em_module;
    return EINA_TRUE;
 }
index 51e7281..517ff4f 100644 (file)
@@ -206,6 +206,7 @@ struct _Emotion_Gstreamer_Message
    GstMessage *msg;
 };
 
+extern Eina_Bool window_manager_video;
 extern Eina_Bool debug_fps;
 extern int _emotion_gstreamer_log_domain;
 #define DBG(...) EINA_LOG_DOM_DBG(_emotion_gstreamer_log_domain, __VA_ARGS__)
index 623bb5e..3e71d8f 100644 (file)
@@ -1173,59 +1173,62 @@ gstreamer_video_sink_new(Emotion_Gstreamer_Video *ev,
      }
 
 #if defined HAVE_ECORE_X && defined HAVE_XOVERLAY_H
-   engines = evas_render_method_list();
+   if (window_manager_video)
+     {
+       engines = evas_render_method_list();
 
-   engine = eina_list_nth(engines, evas_output_method_get(evas_object_evas_get(obj)) - 1);
+       engine = eina_list_nth(engines, evas_output_method_get(evas_object_evas_get(obj)) - 1);
 
-   if (ev->priority && engine && strstr(engine, "_x11") != NULL)
-     {
-        Ecore_Evas *ee;
-        Evas_Coord x, y, w, h;
-       Ecore_X_Window win;
-        Ecore_X_Window parent;
+       if (ev->priority && engine && strstr(engine, "_x11") != NULL)
+        {
+          Ecore_Evas *ee;
+          Evas_Coord x, y, w, h;
+          Ecore_X_Window win;
+          Ecore_X_Window parent;
 
-       evas_object_geometry_get(obj, &x, &y, &w, &h);
+          evas_object_geometry_get(obj, &x, &y, &w, &h);
 
-        ee = ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
+          ee = ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
 
-        if (w < 4) w = 4;
-        if (h < 2) h = 2;
+          if (w < 4) w = 4;
+          if (h < 2) h = 2;
 
-        /* Here we really need to have the help of the window manager, this code will change when we update E17. */
-        parent = (Ecore_X_Window) ecore_evas_window_get(ee);
-        fprintf(stderr, "parent: %x\n", parent);
+          /* Here we really need to have the help of the window manager, this code will change when we update E17. */
+          parent = (Ecore_X_Window) ecore_evas_window_get(ee);
+          fprintf(stderr, "parent: %x\n", parent);
 
-       win = ecore_x_window_new(0, x, y, w, h);
-        fprintf(stderr, "creating window: %x [%i, %i, %i, %i]\n", win, x, y, w, h);
-       if (win)
-         {
-             ecore_x_mwm_borderless_set(win, EINA_TRUE);
-             ecore_x_window_show(win);
-             xvsink = gst_element_factory_make("xvimagesink", NULL);
-            if (xvsink)
-              {
-                 unsigned int pos[2];
+          win = ecore_x_window_new(0, x, y, w, h);
+          fprintf(stderr, "creating window: %x [%i, %i, %i, %i]\n", win, x, y, w, h);
+          if (win)
+            {
+              /* ecore_x_mwm_borderless_set(win, EINA_TRUE); */
+              ecore_x_window_hide(win);
+              xvsink = gst_element_factory_make("xvimagesink", NULL);
+              if (xvsink)
+                {
+                  unsigned int pos[2];
 
 #ifdef HAVE_X_OVERLAY_SET
-                 gst_x_overlay_set_window_handle(GST_X_OVERLAY(xvsink), win);
+                  gst_x_overlay_set_window_handle(GST_X_OVERLAY(xvsink), win);
 #else
-                 gst_x_overlay_set_xwindow_id(GST_X_OVERLAY(xvsink), win);
+                  gst_x_overlay_set_xwindow_id(GST_X_OVERLAY(xvsink), win);
 #endif
-                 ev->win = win;
-
-                 ecore_x_window_prop_card32_set(win, ECORE_X_ATOM_E_VIDEO_PARENT, &parent, 1);
-
-                 pos[0] = x; pos[1] = y;
-                 ecore_x_window_prop_card32_set(win, ECORE_X_ATOM_E_VIDEO_POSITION, pos, 2);
-              }
-            else
-              {
-                  fprintf(stderr, "destroying win: %x\n", win);
-                 ecore_x_window_free(win);
-              }
-         }
+                  ev->win = win;
+
+                  ecore_x_window_prop_card32_set(win, ECORE_X_ATOM_E_VIDEO_PARENT, &parent, 1);
+
+                  pos[0] = x; pos[1] = y;
+                  ecore_x_window_prop_card32_set(win, ECORE_X_ATOM_E_VIDEO_POSITION, pos, 2);
+                }
+              else
+                {
+                  fprintf(stderr, "destroying win: %x\n", win);
+                  ecore_x_window_free(win);
+                }
+            }
+        }
+       evas_render_method_list_free(engines);
      }
-   evas_render_method_list_free(engines);
 #else
 # warning "no ecore_x or xoverlay"
 #endif