svn update: 48958 (latest:48959)
[framework/uifw/ecore.git] / src / lib / ecore_x / xlib / ecore_x_xinerama.c
1 /*
2  * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
3  */
4
5 /*
6  * Xinerama code
7  */
8
9 #ifdef HAVE_CONFIG_H
10 # include <config.h>
11 #endif
12
13 #include "Ecore.h"
14 #include "ecore_x_private.h"
15 #include "Ecore_X.h"
16 #include "Ecore_X_Atoms.h"
17
18 #ifdef ECORE_XINERAMA
19 static XineramaScreenInfo *_xin_info = NULL;
20 static int _xin_scr_num = 0;
21 #endif
22
23 EAPI int
24 ecore_x_xinerama_screen_count_get(void)
25 {
26 #ifdef ECORE_XINERAMA
27    int event_base, error_base;
28
29    LOGFN(__FILE__, __LINE__, __FUNCTION__);
30    if (_xin_info) XFree(_xin_info);
31    _xin_info = NULL;
32    if (XineramaQueryExtension(_ecore_x_disp, &event_base, &error_base))
33      {
34         _xin_info = XineramaQueryScreens(_ecore_x_disp, &_xin_scr_num);
35         if (_xin_info) return _xin_scr_num;
36      }
37 #endif
38    return 0;
39 }
40
41 EAPI int
42 ecore_x_xinerama_screen_geometry_get(int screen, int *x, int *y, int *w, int *h)
43 {
44    LOGFN(__FILE__, __LINE__, __FUNCTION__);
45 #ifdef ECORE_XINERAMA
46    if (_xin_info)
47      {
48         int i;
49         
50         for (i = 0; i < _xin_scr_num; i++)
51           {
52              if (_xin_info[i].screen_number == screen)
53                {
54                   if (x) *x = _xin_info[i].x_org;
55                   if (y) *y = _xin_info[i].y_org;
56                   if (w) *w = _xin_info[i].width;
57                   if (h) *h = _xin_info[i].height;
58                   return 1;
59                }
60           }
61      }
62 #endif
63    if (x) *x = 0;
64    if (y) *y = 0;
65    if (w) *w = DisplayWidth(_ecore_x_disp, 0);
66    if (h) *h = DisplayHeight(_ecore_x_disp, 0);
67    return 0;
68 }