4a591f9753fc818659d83d40f8f2102ab85d7c33
[platform/upstream/efl.git] / src / lib / ecore_x / xlib / ecore_x_xinerama.c
1 /*
2  * Xinerama code
3  */
4
5 #ifdef HAVE_CONFIG_H
6 # include <config.h>
7 #endif /* ifdef HAVE_CONFIG_H */
8
9 #include "Ecore.h"
10 #include "ecore_x_private.h"
11 #include "Ecore_X.h"
12 #include "Ecore_X_Atoms.h"
13
14 #ifdef ECORE_XINERAMA
15 static XineramaScreenInfo *_xin_info = NULL;
16 static int _xin_scr_num = 0;
17 #endif /* ifdef ECORE_XINERAMA */
18
19 EAPI int
20 ecore_x_xinerama_screen_count_get(void)
21 {
22 #ifdef ECORE_XINERAMA
23    int event_base, error_base;
24
25    LOGFN(__FILE__, __LINE__, __FUNCTION__);
26    if (_xin_info)
27      XFree(_xin_info);
28
29    _xin_info = NULL;
30    if (XineramaQueryExtension(_ecore_x_disp, &event_base, &error_base))
31      {
32         if (_ecore_xlib_sync) ecore_x_sync();
33         _xin_info = XineramaQueryScreens(_ecore_x_disp, &_xin_scr_num);
34         if (_ecore_xlib_sync) ecore_x_sync();
35         if (_xin_info)
36           return _xin_scr_num;
37      }
38    if (_ecore_xlib_sync) ecore_x_sync();
39
40 #endif /* ifdef ECORE_XINERAMA */
41    return 0;
42 }
43
44 EAPI Eina_Bool
45 ecore_x_xinerama_screen_geometry_get(int screen,
46                                      int *x,
47                                      int *y,
48                                      int *w,
49                                      int *h)
50 {
51    LOGFN(__FILE__, __LINE__, __FUNCTION__);
52 #ifdef ECORE_XINERAMA
53    if (_xin_info)
54      {
55         int i;
56
57         for (i = 0; i < _xin_scr_num; i++)
58           {
59              if (_xin_info[i].screen_number == screen)
60                {
61                   if (x)
62                     *x = _xin_info[i].x_org;
63
64                   if (y)
65                     *y = _xin_info[i].y_org;
66
67                   if (w)
68                     *w = _xin_info[i].width;
69
70                   if (h)
71                     *h = _xin_info[i].height;
72
73                   return EINA_TRUE;
74                }
75           }
76      }
77
78 #endif /* ifdef ECORE_XINERAMA */
79    if (x)
80      *x = 0;
81
82    if (y)
83      *y = 0;
84
85    if (w)
86      *w = DisplayWidth(_ecore_x_disp, 0);
87
88    if (h)
89      *h = DisplayHeight(_ecore_x_disp, 0);
90
91    return EINA_FALSE;
92    screen = 0;
93 }
94