Dear developers,

find attached a set of patches that do the following:

State before patches:
ecore_x_randr_current_output_get was unimplemented.

State after patches:
Patch1: ecore_x_randr_window_outputs_get implements functionality of
ecore_x_randr_current_output_get
Patch2: ecore_x_randr_current_output_get is deprecated and redirects
calls to ecore_x_randr_window_outputs_get

Please review/comment/commit!

BR,

Leif
From f5815eb6446f1bd7d7b5518d15a412cc83bc112c Mon Sep 17 00:00:00 2001
From: Leif Middelschulte <leif.middelschu...@gmail.com>
Date: Thu, 7 Apr 2011 15:49:33 +0200
Subject: [PATCH 1/2] Added ecore_x_randr_window_outputs_get.

It returns an array of outputs that display (parts) of a passed window.
---
 trunk/ecore/src/lib/ecore_x/Ecore_X.h              |    4 +
 .../ecore/src/lib/ecore_x/xlib/ecore_x_randr_12.c  |   63 ++++++++++++++++++++
 2 files changed, 67 insertions(+), 0 deletions(-)

diff --git a/trunk/ecore/src/lib/ecore_x/Ecore_X.h b/trunk/ecore/src/lib/ecore_x/Ecore_X.h
index b7b1dfb..4edefb8 100644
--- a/trunk/ecore/src/lib/ecore_x/Ecore_X.h
+++ b/trunk/ecore/src/lib/ecore_x/Ecore_X.h
@@ -2560,6 +2560,10 @@ EAPI Ecore_X_Randr_Output *ecore_x_randr_outputs_get(
    Ecore_X_Window root,
    int *num);
 EAPI Ecore_X_Randr_Output *
+                           ecore_x_randr_window_outputs_get(
+   Ecore_X_Window window,
+   int *num);
+EAPI Ecore_X_Randr_Output *
                            ecore_x_randr_current_output_get(
    Ecore_X_Window window,
    int *num);
diff --git a/trunk/ecore/src/lib/ecore_x/xlib/ecore_x_randr_12.c b/trunk/ecore/src/lib/ecore_x/xlib/ecore_x_randr_12.c
index 3b0f0a1..6a6898c 100644
--- a/trunk/ecore/src/lib/ecore_x/xlib/ecore_x_randr_12.c
+++ b/trunk/ecore/src/lib/ecore_x/xlib/ecore_x_randr_12.c
@@ -2080,3 +2080,66 @@ ecore_x_randr_output_backlight_level_set(Ecore_X_Window       root,
 #endif
    return EINA_FALSE;
 }
+
+/*
+ * @brief get the outputs, which display a certain window
+ * @param window window the displaying outputs shall be found for
+ * @param num the number of outputs displaying the window
+ * @return array of outputs that display a certain window. NULL if no outputs
+ * was found that displays the specified window.
+ */
+
+EAPI Ecore_X_Randr_Output *
+ecore_x_randr_window_outputs_get(Ecore_X_Window window,
+                                 int *num)
+{
+#ifdef ECORE_XRANDR
+   Ecore_X_Window root;
+   Eina_Rectangle w_geo, c_geo;
+   Ecore_X_Randr_Crtc *crtcs;
+   Ecore_X_Randr_Mode mode;
+   Ecore_X_Randr_Output *outputs, *ret = NULL;
+   int ncrtcs, noutputs, i, j, nret = 0;
+
+   if(_randr_version < RANDR_1_2) goto _ecore_x_randr_current_output_get_fail;
+
+   ecore_x_window_w_geometry_get(window, &w_geo.x, &w_geo.y, &w_geo.w, &w_geo.h);
+
+   root = ecore_x_window_root_get(window);
+
+   crtcs = ecore_x_randr_crtcs_get(root, &ncrtcs);
+   if (!crtcs) goto _ecore_x_randr_current_output_get_fail;
+
+   for (i = 0; i < ncrtcs; i++)
+     {
+        /* if crtc is not enabled, don't bother about it any further */
+        mode = ecore_x_randr_crtc_mode_get(root, crtcs[i]);
+        if (mode == Ecore_X_Randr_None) continue;
+
+        ecore_x_randr_crtc_geometry_get(root, crtcs[i], &c_geo.x, &c_geo.y, &c_geo.w, &c_geo.h);
+        if (eina_rectangles_intersect(&w_geo, &c_geo))
+          {
+             outputs = ecore_x_randr_crtc_outputs_get(root, crtcs[i], &noutputs);
+             /*
+              * The case below should be impossible, but for safety reasons
+              * remains
+              */
+             if (!outputs) continue;
+
+             ret = realloc(ret, ((nret + noutputs) * sizeof(Ecore_X_Randr_Output)));
+             memcpy(&ret[nret], outputs, (noutputs * sizeof(Ecore_X_Randr_Output)));
+             nret += noutputs;
+             free(outputs);
+          }
+     }
+   free(crtcs);
+
+   if (num) *num = nret;
+   return ret;
+
+_ecore_x_randr_current_output_get_fail:
+#endif
+   if (num) *num = 0;
+   return NULL;
+}
+
-- 
1.7.1

From 0786160ca3f65b0e3481a1d9c7932fbe85a52e10 Mon Sep 17 00:00:00 2001
From: Leif Middelschulte <leif.middelschu...@gmail.com>
Date: Thu, 7 Apr 2011 16:09:38 +0200
Subject: [PATCH 2/2] Implemented/Deprecated ecore_x_randr_output_current_get.

Marked this function as deprecated because of the bad naming.
Use ecore_x_randr_window_outputs_get instead.
---
 trunk/ecore/src/lib/ecore_x/Ecore_X.h              |    2 +-
 .../ecore/src/lib/ecore_x/xlib/ecore_x_randr_12.c  |   15 +++++++++++++++
 2 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/trunk/ecore/src/lib/ecore_x/Ecore_X.h b/trunk/ecore/src/lib/ecore_x/Ecore_X.h
index 4edefb8..6355d9a 100644
--- a/trunk/ecore/src/lib/ecore_x/Ecore_X.h
+++ b/trunk/ecore/src/lib/ecore_x/Ecore_X.h
@@ -2563,7 +2563,7 @@ EAPI Ecore_X_Randr_Output *
                            ecore_x_randr_window_outputs_get(
    Ecore_X_Window window,
    int *num);
-EAPI Ecore_X_Randr_Output *
+EINA_DEPRECATED EAPI Ecore_X_Randr_Output *
                            ecore_x_randr_current_output_get(
    Ecore_X_Window window,
    int *num);
diff --git a/trunk/ecore/src/lib/ecore_x/xlib/ecore_x_randr_12.c b/trunk/ecore/src/lib/ecore_x/xlib/ecore_x_randr_12.c
index 6a6898c..798fe5e 100644
--- a/trunk/ecore/src/lib/ecore_x/xlib/ecore_x_randr_12.c
+++ b/trunk/ecore/src/lib/ecore_x/xlib/ecore_x_randr_12.c
@@ -2143,3 +2143,18 @@ _ecore_x_randr_current_output_get_fail:
    return NULL;
 }
 
+/*
+ * @depricated bad naming. Use ecore_x_randr_window_outputs_get instead.
+ * @brief get the outputs, which display a certain window
+ * @param window window the displaying outputs shall be found for
+ * @param num the number of outputs displaying the window
+ * @return array of outputs that display a certain window. NULL if no outputs
+ * was found that displays the specified window.
+ */
+
+EINA_DEPRECATED EAPI Ecore_X_Randr_Output *
+ecore_x_randr_current_output_get(Ecore_X_Window window,
+                                 int *num)
+{
+   return ecore_x_randr_window_outputs_get(window, num);
+}
-- 
1.7.1

------------------------------------------------------------------------------
Xperia(TM) PLAY
It's a major breakthrough. An authentic gaming
smartphone on the nation's most reliable network.
And it wants your games.
http://p.sf.net/sfu/verizon-sfdev
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to