]>
Commit | Line | Data |
---|---|---|
b1b3ddd8 JS |
1 | /////////////////////////////////////////////////////////////////////////// |
2 | // Name: displayx11.cpp | |
3 | // Purpose: Unix/X11 implementation of wxDisplay class | |
4 | // Author: Brian Victor | |
5 | // Modified by: | |
6 | // Created: 12/05/02 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) wxWindows team | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
14f355c2 | 12 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) |
b1b3ddd8 JS |
13 | #pragma implementation "display.h" |
14 | #endif | |
15 | ||
16 | // For compilers that support precompilation, includes "wx.h". | |
17 | #include "wx/wxprec.h" | |
18 | ||
19 | #ifdef __BORLANDC__ | |
20 | #pragma hdrstop | |
21 | #endif | |
22 | ||
23 | #include "wx/display.h" | |
24 | ||
25 | #ifndef WX_PRECOMP | |
26 | #include "wx/dynarray.h" | |
27 | #include "wx/gdicmn.h" | |
28 | #include "wx/string.h" | |
29 | #include "wx/utils.h" | |
30 | #endif /* WX_PRECOMP */ | |
31 | ||
32 | #if wxUSE_DISPLAY | |
33 | ||
34 | /* These must be included after the wx files. Otherwise the Data macro in | |
35 | * Xlibint.h conflicts with a function declaration in wx/list.h. */ | |
36 | extern "C" { | |
37 | #include <X11/Xlib.h> | |
38 | #include <X11/Xlibint.h> | |
39 | #include <X11/extensions/Xinerama.h> | |
40 | } | |
41 | ||
42 | class wxDisplayUnixPriv | |
43 | { | |
44 | public: | |
45 | wxRect m_rect; | |
46 | int m_depth; | |
47 | }; | |
48 | ||
49 | size_t wxDisplayBase::GetCount() | |
50 | { | |
51 | Display *disp = (Display*)wxGetDisplay(); | |
52 | ||
53 | if ( XineramaIsActive(disp) ) | |
54 | { | |
55 | XineramaScreenInfo *screenarr; | |
56 | int numscreens; | |
57 | screenarr = XineramaQueryScreens(disp, &numscreens); | |
58 | XFree(screenarr); | |
59 | return numscreens; | |
60 | } | |
61 | else | |
62 | { | |
63 | return 1; | |
64 | } | |
65 | } | |
66 | ||
67 | int wxDisplayBase::GetFromPoint(const wxPoint &p) | |
68 | { | |
69 | Display *disp = (Display*)wxGetDisplay(); | |
70 | ||
71 | if ( XineramaIsActive(disp) ) | |
72 | { | |
73 | int which_screen = -1; | |
74 | XineramaScreenInfo *screenarr; | |
75 | int numscreens; | |
76 | screenarr = XineramaQueryScreens(disp, &numscreens); | |
77 | ||
78 | int i; | |
79 | for (i = 0; i < numscreens; ++i) | |
80 | { | |
81 | if (p.x >= screenarr[i].x_org && | |
82 | p.x <= screenarr[i].x_org + screenarr[i].width && | |
83 | p.y >= screenarr[i].y_org && | |
84 | p.y <= screenarr[i].y_org + screenarr[i].height) | |
85 | { | |
86 | which_screen = i; | |
87 | } | |
88 | } | |
89 | ||
90 | XFree(screenarr); | |
91 | return which_screen; | |
92 | } | |
93 | else | |
94 | { | |
3cb98121 VZ |
95 | wxSize size = wxGetDisplaySize(); |
96 | if (p.x >= 0 && | |
97 | p.x <= size.GetWidth() && | |
98 | p.y > 0 && | |
99 | p.y <= size.GetHeight()) | |
100 | { | |
101 | return 0; | |
102 | } | |
103 | ||
104 | return -1 | |
b1b3ddd8 JS |
105 | } |
106 | } | |
107 | ||
108 | wxDisplay::wxDisplay(size_t index) : wxDisplayBase ( index ), m_priv( new wxDisplayUnixPriv ) | |
109 | { | |
110 | Display *disp = (Display*)wxGetDisplay(); | |
111 | ||
112 | if ( XineramaIsActive(disp) ) | |
113 | { | |
114 | XineramaScreenInfo *screenarr; | |
115 | int numscreens; | |
116 | screenarr = XineramaQueryScreens(disp, &numscreens); | |
117 | m_priv->m_rect = wxRect(screenarr[index].x_org, screenarr[index].y_org, | |
118 | screenarr[index].width, screenarr[index].height); | |
119 | m_priv->m_depth = DefaultDepth(disp, DefaultScreen(disp)); | |
120 | XFree(screenarr); | |
121 | } | |
122 | else | |
123 | { | |
124 | wxSize size = wxGetDisplaySize(); | |
125 | m_priv->m_rect = wxRect(0, 0, size.GetWidth(), size.GetHeight()); | |
126 | m_priv->m_depth = wxDisplayDepth(); | |
127 | } | |
128 | } | |
129 | ||
130 | wxDisplay::~wxDisplay() | |
131 | { | |
132 | delete m_priv; | |
133 | } | |
134 | ||
135 | wxRect wxDisplay::GetGeometry() const | |
136 | { | |
137 | return m_priv->m_rect; | |
138 | } | |
139 | ||
140 | int wxDisplay::GetDepth() const | |
141 | { | |
142 | return m_priv->m_depth; | |
143 | } | |
144 | ||
145 | wxString wxDisplay::GetName() const | |
146 | { | |
32e2c761 | 147 | return wxEmptyString; |
b1b3ddd8 JS |
148 | } |
149 | ||
150 | #endif /* wxUSE_DISPLAY */ | |
151 |