]>
Commit | Line | Data |
---|---|---|
83df96d6 JS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: windows.cpp | |
3 | // Purpose: wxWindow | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 17/09/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | // ============================================================================ | |
13 | // declarations | |
14 | // ============================================================================ | |
15 | ||
16 | // ---------------------------------------------------------------------------- | |
17 | // headers | |
18 | // ---------------------------------------------------------------------------- | |
19 | ||
20 | #ifdef __GNUG__ | |
21 | #pragma implementation "window.h" | |
22 | #endif | |
23 | ||
83df96d6 JS |
24 | #include "wx/setup.h" |
25 | #include "wx/menu.h" | |
26 | #include "wx/dc.h" | |
27 | #include "wx/dcclient.h" | |
28 | #include "wx/utils.h" | |
29 | #include "wx/app.h" | |
30 | #include "wx/panel.h" | |
31 | #include "wx/layout.h" | |
32 | #include "wx/dialog.h" | |
33 | #include "wx/listbox.h" | |
34 | #include "wx/button.h" | |
35 | #include "wx/settings.h" | |
36 | #include "wx/msgdlg.h" | |
37 | #include "wx/frame.h" | |
38 | #include "wx/scrolwin.h" | |
ab6b6b15 | 39 | #include "wx/scrolbar.h" |
83df96d6 JS |
40 | #include "wx/module.h" |
41 | #include "wx/menuitem.h" | |
42 | #include "wx/log.h" | |
43 | ||
44 | #if wxUSE_DRAG_AND_DROP | |
45 | #include "wx/dnd.h" | |
46 | #endif | |
47 | ||
bc797f4c | 48 | #include "wx/x11/private.h" |
7266b672 | 49 | #include "X11/Xutil.h" |
83df96d6 | 50 | |
461e93f9 JS |
51 | #if wxUSE_NANOX |
52 | // For wxGetLocalTime, used by XButtonEventGetTime | |
53 | #include "wx/timer.h" | |
54 | #endif | |
55 | ||
83df96d6 JS |
56 | #include <string.h> |
57 | ||
83df96d6 JS |
58 | // ---------------------------------------------------------------------------- |
59 | // global variables for this module | |
60 | // ---------------------------------------------------------------------------- | |
61 | ||
62 | extern wxHashTable *wxWidgetHashTable; | |
ab6b6b15 | 63 | extern wxHashTable *wxClientWidgetHashTable; |
83df96d6 | 64 | static wxWindow* g_captureWindow = NULL; |
c2c0dabf | 65 | static GC g_eraseGC; |
83df96d6 | 66 | |
83df96d6 JS |
67 | // ---------------------------------------------------------------------------- |
68 | // macros | |
69 | // ---------------------------------------------------------------------------- | |
70 | ||
71 | #define event_left_is_down(x) ((x)->xbutton.state & Button1Mask) | |
72 | #define event_middle_is_down(x) ((x)->xbutton.state & Button2Mask) | |
73 | #define event_right_is_down(x) ((x)->xbutton.state & Button3Mask) | |
74 | ||
75 | // ---------------------------------------------------------------------------- | |
76 | // event tables | |
77 | // ---------------------------------------------------------------------------- | |
78 | ||
8354aa92 | 79 | IMPLEMENT_ABSTRACT_CLASS(wxWindowX11, wxWindowBase) |
83df96d6 | 80 | |
bc797f4c JS |
81 | BEGIN_EVENT_TABLE(wxWindowX11, wxWindowBase) |
82 | EVT_SYS_COLOUR_CHANGED(wxWindowX11::OnSysColourChanged) | |
bc797f4c | 83 | END_EVENT_TABLE() |
83df96d6 JS |
84 | |
85 | // ============================================================================ | |
86 | // implementation | |
87 | // ============================================================================ | |
88 | ||
89 | // ---------------------------------------------------------------------------- | |
90 | // helper functions | |
91 | // ---------------------------------------------------------------------------- | |
92 | ||
83df96d6 JS |
93 | // ---------------------------------------------------------------------------- |
94 | // constructors | |
95 | // ---------------------------------------------------------------------------- | |
96 | ||
bc797f4c | 97 | void wxWindowX11::Init() |
83df96d6 JS |
98 | { |
99 | // generic initializations first | |
100 | InitBase(); | |
101 | ||
7266b672 | 102 | // X11-specific |
ab6b6b15 RR |
103 | m_mainWindow = (WXWindow) 0; |
104 | m_clientWindow = (WXWindow) 0; | |
105 | m_insertIntoMain = FALSE; | |
065722d7 | 106 | m_updateNcArea = FALSE; |
ab6b6b15 | 107 | |
83df96d6 | 108 | m_winCaptured = FALSE; |
3a0b23eb | 109 | m_needsInputFocus = FALSE; |
83df96d6 JS |
110 | m_isShown = TRUE; |
111 | m_isBeingDeleted = FALSE; | |
83df96d6 JS |
112 | m_lastTS = 0; |
113 | m_lastButton = 0; | |
83df96d6 JS |
114 | } |
115 | ||
116 | // real construction (Init() must have been called before!) | |
bc797f4c | 117 | bool wxWindowX11::Create(wxWindow *parent, wxWindowID id, |
83df96d6 JS |
118 | const wxPoint& pos, |
119 | const wxSize& size, | |
120 | long style, | |
121 | const wxString& name) | |
122 | { | |
123 | wxCHECK_MSG( parent, FALSE, "can't create wxWindow without parent" ); | |
124 | ||
125 | CreateBase(parent, id, pos, size, style, wxDefaultValidator, name); | |
126 | ||
3cd0b8c5 | 127 | parent->AddChild(this); |
83df96d6 | 128 | |
b513212d JS |
129 | int w = size.GetWidth(); |
130 | int h = size.GetHeight(); | |
131 | int x = size.GetX(); | |
132 | int y = size.GetY(); | |
178572bb RR |
133 | if (w == -1) w = 20; |
134 | if (h == -1) h = 20; | |
b513212d JS |
135 | if (x == -1) x = 0; |
136 | if (y == -1) y = 0; | |
83df96d6 | 137 | |
3cd0b8c5 RR |
138 | Display *xdisplay = (Display*) wxGlobalDisplay(); |
139 | int xscreen = DefaultScreen( xdisplay ); | |
7e4501ee | 140 | Visual *xvisual = DefaultVisual( xdisplay, xscreen ); |
3cd0b8c5 | 141 | Colormap cm = DefaultColormap( xdisplay, xscreen ); |
b513212d | 142 | |
3cd0b8c5 RR |
143 | m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE); |
144 | m_backgroundColour.CalcPixel( (WXColormap) cm ); | |
145 | ||
146 | m_foregroundColour = *wxBLACK; | |
147 | m_foregroundColour.CalcPixel( (WXColormap) cm ); | |
3cd0b8c5 | 148 | |
ab6b6b15 RR |
149 | Window xparent = (Window) parent->GetClientWindow(); |
150 | ||
151 | // Add window's own scrollbars to main window, not to client window | |
152 | if (parent->GetInsertIntoMain()) | |
153 | { | |
154 | // wxLogDebug( "Inserted into main: %s", GetName().c_str() ); | |
155 | xparent = (Window) parent->GetMainWindow(); | |
156 | } | |
2f12683e RR |
157 | |
158 | wxSize size2(size); | |
159 | if (size2.x == -1) | |
160 | size2.x = 20; | |
161 | if (size2.y == -1) | |
162 | size2.y = 20; | |
b513212d | 163 | |
2f12683e RR |
164 | wxPoint pos2(pos); |
165 | if (pos2.x == -1) | |
166 | pos2.x = 0; | |
167 | if (pos2.y == -1) | |
168 | pos2.y = 0; | |
169 | ||
461e93f9 | 170 | #if !wxUSE_NANOX |
ab6b6b15 RR |
171 | |
172 | #if wxUSE_TWO_WINDOWS | |
173 | bool need_two_windows = | |
174 | ((( wxSUNKEN_BORDER | wxRAISED_BORDER | wxSIMPLE_BORDER | wxHSCROLL | wxVSCROLL ) & m_windowStyle) != 0); | |
175 | #else | |
176 | bool need_two_windows = FALSE; | |
177 | #endif | |
178 | ||
7e4501ee | 179 | XSetWindowAttributes xattributes; |
ab6b6b15 | 180 | long xattributes_mask = 0; |
7e4501ee | 181 | |
ab6b6b15 | 182 | xattributes_mask |= CWBackPixel; |
7e4501ee | 183 | xattributes.background_pixel = m_backgroundColour.GetPixel(); |
ab6b6b15 RR |
184 | |
185 | xattributes_mask |= CWBorderPixel; | |
7e4501ee RR |
186 | xattributes.border_pixel = BlackPixel( xdisplay, xscreen ); |
187 | ||
2f12683e | 188 | xattributes_mask |= CWEventMask; |
ab6b6b15 RR |
189 | |
190 | if (need_two_windows) | |
2f12683e | 191 | { |
ab6b6b15 RR |
192 | xattributes.event_mask = |
193 | ExposureMask | StructureNotifyMask | ColormapChangeMask; | |
194 | ||
195 | Window xwindow = XCreateWindow( xdisplay, xparent, pos2.x, pos2.y, size2.x, size2.y, | |
196 | 0, DefaultDepth(xdisplay,xscreen), InputOutput, xvisual, xattributes_mask, &xattributes ); | |
197 | ||
198 | XSetWindowBackgroundPixmap( xdisplay, xwindow, None ); | |
199 | ||
200 | m_mainWindow = (WXWindow) xwindow; | |
201 | wxAddWindowToTable( xwindow, (wxWindow*) this ); | |
202 | ||
203 | XMapWindow( xdisplay, xwindow ); | |
204 | ||
205 | xattributes.event_mask = | |
206 | ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | | |
207 | ButtonMotionMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask | | |
208 | KeymapStateMask | FocusChangeMask | ColormapChangeMask | StructureNotifyMask | | |
209 | PropertyChangeMask | VisibilityChangeMask ; | |
210 | ||
211 | if (HasFlag( wxNO_FULL_REPAINT_ON_RESIZE )) | |
212 | { | |
213 | xattributes_mask |= CWBitGravity; | |
214 | xattributes.bit_gravity = StaticGravity; | |
215 | } | |
216 | ||
065722d7 RR |
217 | if (HasFlag( wxSUNKEN_BORDER) || HasFlag( wxRAISED_BORDER)) |
218 | { | |
219 | pos2.x = 2; | |
220 | pos2.y = 2; | |
221 | size2.x -= 4; | |
222 | size2.y -= 4; | |
223 | } else | |
224 | if (HasFlag( wxSIMPLE_BORDER )) | |
225 | { | |
226 | pos2.x = 1; | |
227 | pos2.y = 1; | |
228 | size2.x -= 2; | |
229 | size2.y -= 2; | |
230 | } else | |
231 | { | |
232 | pos2.x = 0; | |
233 | pos2.y = 0; | |
234 | } | |
235 | ||
236 | xwindow = XCreateWindow( xdisplay, xwindow, pos2.x, pos2.y, size2.x, size2.y, | |
ab6b6b15 RR |
237 | 0, DefaultDepth(xdisplay,xscreen), InputOutput, xvisual, xattributes_mask, &xattributes ); |
238 | ||
239 | XSetWindowBackgroundPixmap( xdisplay, xwindow, None ); | |
240 | ||
241 | m_clientWindow = (WXWindow) xwindow; | |
242 | wxAddClientWindowToTable( xwindow, (wxWindow*) this ); | |
243 | ||
244 | XMapWindow( xdisplay, xwindow ); | |
2f12683e | 245 | } |
ab6b6b15 RR |
246 | else |
247 | { | |
248 | // wxLogDebug( "No two windows needed %s", GetName().c_str() ); | |
249 | ||
250 | xattributes.event_mask = | |
251 | ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | | |
252 | ButtonMotionMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask | | |
253 | KeymapStateMask | FocusChangeMask | ColormapChangeMask | StructureNotifyMask | | |
254 | PropertyChangeMask | VisibilityChangeMask ; | |
2f12683e | 255 | |
ab6b6b15 RR |
256 | if (HasFlag( wxNO_FULL_REPAINT_ON_RESIZE )) |
257 | { | |
258 | xattributes_mask |= CWBitGravity; | |
065722d7 | 259 | xattributes.bit_gravity = NorthWestGravity; |
ab6b6b15 RR |
260 | } |
261 | ||
262 | Window xwindow = XCreateWindow( xdisplay, xparent, pos2.x, pos2.y, size2.x, size2.y, | |
263 | 0, DefaultDepth(xdisplay,xscreen), InputOutput, xvisual, xattributes_mask, &xattributes ); | |
264 | ||
265 | XSetWindowBackgroundPixmap( xdisplay, xwindow, None ); | |
266 | ||
267 | m_mainWindow = (WXWindow) xwindow; | |
268 | m_clientWindow = m_mainWindow; | |
269 | wxAddWindowToTable( xwindow, (wxWindow*) this ); | |
270 | ||
271 | XMapWindow( xdisplay, xwindow ); | |
272 | } | |
2f12683e | 273 | #else |
15c69343 | 274 | |
461e93f9 JS |
275 | int extraFlags = GR_EVENT_MASK_CLOSE_REQ; |
276 | ||
277 | long backColor, foreColor; | |
278 | backColor = GR_RGB(m_backgroundColour.Red(), m_backgroundColour.Green(), m_backgroundColour.Blue()); | |
279 | foreColor = GR_RGB(m_foregroundColour.Red(), m_foregroundColour.Green(), m_foregroundColour.Blue()); | |
280 | ||
281 | Window xwindow = XCreateWindowWithColor( xdisplay, xparent, pos2.x, pos2.y, size2.x, size2.y, | |
282 | 0, 0, InputOutput, xvisual, backColor, foreColor); | |
283 | XSelectInput( xdisplay, xwindow, | |
284 | extraFlags | ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | | |
285 | ButtonMotionMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask | | |
286 | KeymapStateMask | FocusChangeMask | ColormapChangeMask | StructureNotifyMask | | |
287 | PropertyChangeMask ); | |
461e93f9 | 288 | |
ab6b6b15 RR |
289 | XSetWindowBackgroundPixmap( xdisplay, xwindow, None ); |
290 | ||
291 | m_mainWindow = (WXWindow) xwindow; | |
ba696cfa | 292 | wxAddWindowToTable( xwindow, (wxWindow*) this ); |
ab6b6b15 RR |
293 | |
294 | XMapWindow( xdisplay, xwindow ); | |
295 | #endif | |
b513212d | 296 | |
b28d3abf JS |
297 | // Is a subwindow, so map immediately |
298 | m_isShown = TRUE; | |
83df96d6 JS |
299 | |
300 | // Without this, the cursor may not be restored properly (e.g. in splitter | |
301 | // sample). | |
302 | SetCursor(*wxSTANDARD_CURSOR); | |
303 | SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); | |
15c69343 JS |
304 | |
305 | // Don't call this, it can have nasty repercussions for composite controls, | |
306 | // for example | |
307 | // SetSize(pos.x, pos.y, size.x, size.y); | |
83df96d6 JS |
308 | |
309 | return TRUE; | |
310 | } | |
311 | ||
312 | // Destructor | |
7266b672 | 313 | wxWindowX11::~wxWindowX11() |
83df96d6 JS |
314 | { |
315 | if (g_captureWindow == this) | |
316 | g_captureWindow = NULL; | |
317 | ||
318 | m_isBeingDeleted = TRUE; | |
319 | ||
d02cb44e | 320 | if (m_parent) |
83df96d6 JS |
321 | m_parent->RemoveChild( this ); |
322 | ||
d02cb44e | 323 | DestroyChildren(); |
83df96d6 | 324 | |
ab6b6b15 | 325 | if (m_clientWindow != m_mainWindow) |
83df96d6 | 326 | { |
ab6b6b15 RR |
327 | // Destroy the cleint window |
328 | Window xwindow = (Window) m_clientWindow; | |
329 | wxDeleteClientWindowFromTable( xwindow ); | |
7e4501ee | 330 | XDestroyWindow( wxGlobalDisplay(), xwindow ); |
ab6b6b15 | 331 | m_clientWindow = NULL; |
83df96d6 | 332 | } |
ab6b6b15 RR |
333 | |
334 | // Destroy the window | |
335 | Window xwindow = (Window) m_mainWindow; | |
336 | wxDeleteWindowFromTable( xwindow ); | |
337 | XDestroyWindow( wxGlobalDisplay(), xwindow ); | |
338 | m_mainWindow = NULL; | |
83df96d6 JS |
339 | } |
340 | ||
341 | // --------------------------------------------------------------------------- | |
342 | // basic operations | |
343 | // --------------------------------------------------------------------------- | |
344 | ||
bc797f4c | 345 | void wxWindowX11::SetFocus() |
83df96d6 | 346 | { |
ab6b6b15 | 347 | Window xwindow = (Window) m_clientWindow; |
86fd8bda RR |
348 | |
349 | wxCHECK_RET( xwindow, wxT("invalid window") ); | |
9b8270da RR |
350 | |
351 | wxCHECK_RET( AcceptsFocus(), wxT("set focus on window that doesn't accept the focus") ); | |
352 | ||
353 | #if 0 | |
354 | if (GetName() == "scrollBar") | |
355 | { | |
356 | char *crash = NULL; | |
357 | *crash = 0; | |
358 | } | |
359 | #endif | |
360 | ||
3a0b23eb JS |
361 | if (wxWindowIsVisible(xwindow)) |
362 | { | |
79ad56d0 | 363 | XSetInputFocus( wxGlobalDisplay(), xwindow, RevertToParent, CurrentTime ); |
ba696cfa | 364 | m_needsInputFocus = FALSE; |
3a0b23eb JS |
365 | } |
366 | else | |
367 | { | |
ba696cfa | 368 | m_needsInputFocus = TRUE; |
3a0b23eb | 369 | } |
83df96d6 JS |
370 | } |
371 | ||
372 | // Get the window with the focus | |
373 | wxWindow *wxWindowBase::FindFocus() | |
374 | { | |
86fd8bda | 375 | Window xfocus = (Window) 0; |
b513212d | 376 | int revert = 0; |
bc797f4c | 377 | |
86fd8bda RR |
378 | XGetInputFocus( wxGlobalDisplay(), &xfocus, &revert); |
379 | if (xfocus) | |
83df96d6 | 380 | { |
86fd8bda | 381 | wxWindow *win = wxGetWindowFromTable( xfocus ); |
b513212d JS |
382 | |
383 | return win; | |
83df96d6 JS |
384 | } |
385 | ||
b513212d | 386 | return NULL; |
83df96d6 JS |
387 | } |
388 | ||
b513212d JS |
389 | // Enabling/disabling handled by event loop, and not sending events |
390 | // if disabled. | |
bc797f4c | 391 | bool wxWindowX11::Enable(bool enable) |
83df96d6 JS |
392 | { |
393 | if ( !wxWindowBase::Enable(enable) ) | |
394 | return FALSE; | |
b513212d | 395 | |
83df96d6 JS |
396 | return TRUE; |
397 | } | |
398 | ||
bc797f4c | 399 | bool wxWindowX11::Show(bool show) |
83df96d6 | 400 | { |
7edcafa4 | 401 | wxWindowBase::Show(show); |
83df96d6 | 402 | |
ab6b6b15 RR |
403 | Window xwindow = (Window) m_mainWindow; |
404 | Display *xdisp = wxGlobalDisplay(); | |
83df96d6 | 405 | if (show) |
b513212d | 406 | { |
7e4501ee | 407 | // wxLogDebug( "Mapping window of type %s", GetName().c_str() ); |
ab6b6b15 | 408 | XMapWindow(xdisp, xwindow); |
b513212d | 409 | } |
83df96d6 | 410 | else |
b513212d | 411 | { |
7e4501ee | 412 | // wxLogDebug( "Unmapping window of type %s", GetName().c_str() ); |
ab6b6b15 | 413 | XUnmapWindow(xdisp, xwindow); |
b513212d | 414 | } |
83df96d6 JS |
415 | |
416 | return TRUE; | |
417 | } | |
418 | ||
419 | // Raise the window to the top of the Z order | |
bc797f4c | 420 | void wxWindowX11::Raise() |
83df96d6 | 421 | { |
ab6b6b15 RR |
422 | if (m_mainWindow) |
423 | XRaiseWindow( wxGlobalDisplay(), (Window) m_mainWindow ); | |
83df96d6 JS |
424 | } |
425 | ||
426 | // Lower the window to the bottom of the Z order | |
bc797f4c | 427 | void wxWindowX11::Lower() |
83df96d6 | 428 | { |
ab6b6b15 RR |
429 | if (m_mainWindow) |
430 | XLowerWindow( wxGlobalDisplay(), (Window) m_mainWindow ); | |
83df96d6 JS |
431 | } |
432 | ||
bc797f4c | 433 | void wxWindowX11::DoCaptureMouse() |
83df96d6 | 434 | { |
7edcafa4 JS |
435 | if ((g_captureWindow != NULL) && (g_captureWindow != this)) |
436 | { | |
346d4fcd | 437 | wxASSERT_MSG(FALSE, "Trying to capture before mouse released."); |
7edcafa4 | 438 | |
346d4fcd RR |
439 | // Core dump now |
440 | int *tmp = NULL; | |
441 | (*tmp) = 1; | |
442 | return; | |
7edcafa4 JS |
443 | } |
444 | ||
346d4fcd | 445 | if (m_winCaptured) |
83df96d6 JS |
446 | return; |
447 | ||
ab6b6b15 | 448 | Window xwindow = (Window) m_clientWindow; |
346d4fcd | 449 | |
86fd8bda RR |
450 | wxCHECK_RET( xwindow, wxT("invalid window") ); |
451 | ||
7edcafa4 JS |
452 | g_captureWindow = (wxWindow*) this; |
453 | ||
346d4fcd | 454 | if (xwindow) |
b513212d | 455 | { |
346d4fcd | 456 | int res = XGrabPointer(wxGlobalDisplay(), xwindow, |
b513212d JS |
457 | FALSE, |
458 | ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, | |
459 | GrabModeAsync, | |
460 | GrabModeAsync, | |
461 | None, | |
462 | None, /* cursor */ // TODO: This may need to be set to the cursor of this window | |
346d4fcd | 463 | CurrentTime ); |
b513212d | 464 | |
b28d3abf | 465 | if (res != GrabSuccess) |
b513212d | 466 | { |
346d4fcd RR |
467 | wxString msg; |
468 | msg.Printf("Failed to grab pointer for window %s", this->GetClassInfo()->GetClassName()); | |
469 | wxLogDebug(msg); | |
470 | if (res == GrabNotViewable) | |
471 | { | |
472 | wxLogDebug("This is not a viewable window - perhaps not shown yet?"); | |
473 | } | |
474 | g_captureWindow = NULL; | |
b28d3abf | 475 | return; |
b513212d | 476 | } |
346d4fcd | 477 | |
b28d3abf | 478 | m_winCaptured = TRUE; |
b513212d | 479 | } |
83df96d6 JS |
480 | } |
481 | ||
bc797f4c | 482 | void wxWindowX11::DoReleaseMouse() |
83df96d6 JS |
483 | { |
484 | g_captureWindow = NULL; | |
346d4fcd | 485 | |
83df96d6 JS |
486 | if ( !m_winCaptured ) |
487 | return; | |
488 | ||
ab6b6b15 | 489 | Window xwindow = (Window) m_clientWindow; |
b513212d | 490 | |
346d4fcd | 491 | if (xwindow) |
b28d3abf | 492 | { |
346d4fcd | 493 | XUngrabPointer( wxGlobalDisplay(), CurrentTime ); |
b28d3abf | 494 | } |
887dd52f | 495 | |
9691c806 | 496 | // wxLogDebug( "Ungrabbed pointer in %s", GetName().c_str() ); |
83df96d6 JS |
497 | |
498 | m_winCaptured = FALSE; | |
499 | } | |
500 | ||
bc797f4c | 501 | bool wxWindowX11::SetFont(const wxFont& font) |
83df96d6 JS |
502 | { |
503 | if ( !wxWindowBase::SetFont(font) ) | |
504 | { | |
505 | // nothing to do | |
506 | return FALSE; | |
507 | } | |
508 | ||
83df96d6 JS |
509 | return TRUE; |
510 | } | |
511 | ||
bc797f4c | 512 | bool wxWindowX11::SetCursor(const wxCursor& cursor) |
83df96d6 JS |
513 | { |
514 | if ( !wxWindowBase::SetCursor(cursor) ) | |
515 | { | |
516 | // no change | |
517 | return FALSE; | |
518 | } | |
519 | ||
ab6b6b15 | 520 | Window xwindow = (Window) m_clientWindow; |
86fd8bda RR |
521 | |
522 | wxCHECK_MSG( xwindow, FALSE, wxT("invalid window") ); | |
523 | ||
524 | wxCursor cursorToUse; | |
83df96d6 | 525 | if (m_cursor.Ok()) |
86fd8bda | 526 | cursorToUse = m_cursor; |
83df96d6 | 527 | else |
86fd8bda | 528 | cursorToUse = *wxSTANDARD_CURSOR; |
83df96d6 | 529 | |
86fd8bda | 530 | Cursor xcursor = (Cursor) cursorToUse.GetCursor(); |
83df96d6 | 531 | |
e88be8c9 | 532 | XDefineCursor( wxGlobalDisplay(), xwindow, xcursor ); |
83df96d6 JS |
533 | |
534 | return TRUE; | |
535 | } | |
536 | ||
537 | // Coordinates relative to the window | |
bc797f4c | 538 | void wxWindowX11::WarpPointer (int x, int y) |
83df96d6 | 539 | { |
ab6b6b15 | 540 | Window xwindow = (Window) m_clientWindow; |
86fd8bda RR |
541 | |
542 | wxCHECK_RET( xwindow, wxT("invalid window") ); | |
543 | ||
544 | XWarpPointer( wxGlobalDisplay(), None, xwindow, 0, 0, 0, 0, x, y); | |
83df96d6 JS |
545 | } |
546 | ||
83df96d6 | 547 | // Does a physical scroll |
bc797f4c | 548 | void wxWindowX11::ScrollWindow(int dx, int dy, const wxRect *rect) |
83df96d6 | 549 | { |
fc9be1cf RR |
550 | // No scrolling requested. |
551 | if ((dx == 0) && (dy == 0)) return; | |
552 | ||
553 | if (!m_updateRegion.IsEmpty()) | |
554 | { | |
555 | m_updateRegion.Offset( dx, dy ); | |
556 | ||
557 | int cw = 0; | |
558 | int ch = 0; | |
559 | GetSize( &cw, &ch ); // GetClientSize() ?? | |
560 | m_updateRegion.Intersect( 0, 0, cw, ch ); | |
561 | } | |
562 | ||
563 | if (!m_clearRegion.IsEmpty()) | |
564 | { | |
565 | m_clearRegion.Offset( dx, dy ); | |
566 | ||
567 | int cw = 0; | |
568 | int ch = 0; | |
569 | GetSize( &cw, &ch ); // GetClientSize() ?? | |
570 | m_clearRegion.Intersect( 0, 0, cw, ch ); | |
571 | } | |
572 | ||
ab6b6b15 | 573 | Window xwindow = (Window) GetClientWindow(); |
7e085304 RR |
574 | |
575 | wxCHECK_RET( xwindow, wxT("invalid window") ); | |
576 | ||
577 | Display *xdisplay = wxGlobalDisplay(); | |
578 | ||
579 | GC xgc = XCreateGC( xdisplay, xwindow, 0, NULL ); | |
580 | XSetGraphicsExposures( xdisplay, xgc, True ); | |
581 | ||
e88be8c9 RR |
582 | int s_x = 0; |
583 | int s_y = 0; | |
4125131b RR |
584 | int cw; |
585 | int ch; | |
586 | if (rect) | |
587 | { | |
588 | s_x = rect->x; | |
589 | s_y = rect->y; | |
e88be8c9 | 590 | |
4125131b RR |
591 | cw = rect->width; |
592 | ch = rect->height; | |
593 | } | |
594 | else | |
595 | { | |
596 | s_x = 0; | |
597 | s_y = 0; | |
598 | GetClientSize( &cw, &ch ); | |
599 | } | |
600 | ||
ab6b6b15 RR |
601 | #if wxUSE_TWO_WINDOWS |
602 | wxPoint offset( 0,0 ); | |
603 | #else | |
4125131b RR |
604 | wxPoint offset = GetClientAreaOrigin(); |
605 | s_x += offset.x; | |
606 | s_y += offset.y; | |
ab6b6b15 | 607 | #endif |
e88be8c9 | 608 | |
7e085304 RR |
609 | int w = cw - abs(dx); |
610 | int h = ch - abs(dy); | |
4125131b | 611 | |
7e085304 | 612 | if ((h < 0) || (w < 0)) |
83df96d6 | 613 | { |
7e085304 | 614 | Refresh(); |
83df96d6 JS |
615 | } |
616 | else | |
617 | { | |
4125131b | 618 | wxRect rect; |
f809133f RR |
619 | if (dx < 0) rect.x = cw+dx + offset.x; else rect.x = s_x; |
620 | if (dy < 0) rect.y = ch+dy + offset.y; else rect.y = s_y; | |
4125131b RR |
621 | if (dy != 0) rect.width = cw; else rect.width = abs(dx); |
622 | if (dx != 0) rect.height = ch; else rect.height = abs(dy); | |
623 | ||
624 | int d_x = s_x; | |
625 | int d_y = s_y; | |
e88be8c9 | 626 | |
4125131b RR |
627 | if (dx < 0) s_x += -dx; |
628 | if (dy < 0) s_y += -dy; | |
e88be8c9 RR |
629 | if (dx > 0) d_x = dx + offset.x; |
630 | if (dy > 0) d_y = dy + offset.y; | |
7e085304 RR |
631 | |
632 | XCopyArea( xdisplay, xwindow, xwindow, xgc, s_x, s_y, w, h, d_x, d_y ); | |
4125131b | 633 | |
e88be8c9 | 634 | // wxLogDebug( "Copy: s_x %d s_y %d w %d h %d d_x %d d_y %d", s_x, s_y, w, h, d_x, d_y ); |
7e085304 | 635 | |
e88be8c9 | 636 | // wxLogDebug( "Update: %d %d %d %d", rect.x, rect.y, rect.width, rect.height ); |
7e085304 RR |
637 | |
638 | m_updateRegion.Union( rect ); | |
639 | m_clearRegion.Union( rect ); | |
83df96d6 | 640 | } |
bc797f4c | 641 | |
7e085304 | 642 | XFreeGC( xdisplay, xgc ); |
83df96d6 JS |
643 | } |
644 | ||
645 | // --------------------------------------------------------------------------- | |
646 | // drag and drop | |
647 | // --------------------------------------------------------------------------- | |
648 | ||
649 | #if wxUSE_DRAG_AND_DROP | |
650 | ||
bc797f4c | 651 | void wxWindowX11::SetDropTarget(wxDropTarget * WXUNUSED(pDropTarget)) |
83df96d6 JS |
652 | { |
653 | // TODO | |
654 | } | |
655 | ||
656 | #endif | |
657 | ||
658 | // Old style file-manager drag&drop | |
bc797f4c | 659 | void wxWindowX11::DragAcceptFiles(bool WXUNUSED(accept)) |
83df96d6 JS |
660 | { |
661 | // TODO | |
662 | } | |
663 | ||
664 | // ---------------------------------------------------------------------------- | |
665 | // tooltips | |
666 | // ---------------------------------------------------------------------------- | |
667 | ||
668 | #if wxUSE_TOOLTIPS | |
669 | ||
bc797f4c | 670 | void wxWindowX11::DoSetToolTip(wxToolTip * WXUNUSED(tooltip)) |
83df96d6 JS |
671 | { |
672 | // TODO | |
673 | } | |
674 | ||
675 | #endif // wxUSE_TOOLTIPS | |
676 | ||
83df96d6 JS |
677 | // --------------------------------------------------------------------------- |
678 | // moving and resizing | |
679 | // --------------------------------------------------------------------------- | |
680 | ||
bc797f4c | 681 | bool wxWindowX11::PreResize() |
83df96d6 JS |
682 | { |
683 | return TRUE; | |
684 | } | |
685 | ||
686 | // Get total size | |
bc797f4c | 687 | void wxWindowX11::DoGetSize(int *x, int *y) const |
83df96d6 | 688 | { |
ab6b6b15 | 689 | Window xwindow = (Window) m_mainWindow; |
86fd8bda RR |
690 | |
691 | wxCHECK_RET( xwindow, wxT("invalid window") ); | |
692 | ||
59db9cfa | 693 | //XSync(wxGlobalDisplay(), False); |
e941874b | 694 | |
86fd8bda RR |
695 | XWindowAttributes attr; |
696 | Status status = XGetWindowAttributes( wxGlobalDisplay(), xwindow, &attr ); | |
697 | wxASSERT(status); | |
b513212d | 698 | |
86fd8bda RR |
699 | if (status) |
700 | { | |
701 | *x = attr.width /* + 2*m_borderSize */ ; | |
702 | *y = attr.height /* + 2*m_borderSize */ ; | |
83df96d6 | 703 | } |
83df96d6 JS |
704 | } |
705 | ||
bc797f4c | 706 | void wxWindowX11::DoGetPosition(int *x, int *y) const |
83df96d6 | 707 | { |
ab6b6b15 | 708 | Window window = (Window) m_mainWindow; |
b513212d | 709 | if (window) |
83df96d6 | 710 | { |
59db9cfa | 711 | //XSync(wxGlobalDisplay(), False); |
b513212d JS |
712 | XWindowAttributes attr; |
713 | Status status = XGetWindowAttributes(wxGlobalDisplay(), window, & attr); | |
714 | wxASSERT(status); | |
715 | ||
716 | if (status) | |
717 | { | |
718 | *x = attr.x; | |
719 | *y = attr.y; | |
720 | ||
721 | // We may be faking the client origin. So a window that's really at (0, 30) | |
722 | // may appear (to wxWin apps) to be at (0, 0). | |
723 | if (GetParent()) | |
724 | { | |
725 | wxPoint pt(GetParent()->GetClientAreaOrigin()); | |
726 | *x -= pt.x; | |
727 | *y -= pt.y; | |
728 | } | |
729 | } | |
83df96d6 | 730 | } |
83df96d6 JS |
731 | } |
732 | ||
bc797f4c | 733 | void wxWindowX11::DoScreenToClient(int *x, int *y) const |
83df96d6 | 734 | { |
b513212d | 735 | Display *display = wxGlobalDisplay(); |
bc797f4c | 736 | Window rootWindow = RootWindowOfScreen(DefaultScreenOfDisplay(display)); |
ab6b6b15 | 737 | Window thisWindow = (Window) m_clientWindow; |
83df96d6 JS |
738 | |
739 | Window childWindow; | |
740 | int xx = *x; | |
741 | int yy = *y; | |
742 | XTranslateCoordinates(display, rootWindow, thisWindow, xx, yy, x, y, &childWindow); | |
743 | } | |
744 | ||
bc797f4c | 745 | void wxWindowX11::DoClientToScreen(int *x, int *y) const |
83df96d6 | 746 | { |
b513212d | 747 | Display *display = wxGlobalDisplay(); |
bc797f4c | 748 | Window rootWindow = RootWindowOfScreen(DefaultScreenOfDisplay(display)); |
ab6b6b15 | 749 | Window thisWindow = (Window) m_clientWindow; |
83df96d6 JS |
750 | |
751 | Window childWindow; | |
752 | int xx = *x; | |
753 | int yy = *y; | |
754 | XTranslateCoordinates(display, thisWindow, rootWindow, xx, yy, x, y, &childWindow); | |
755 | } | |
756 | ||
757 | ||
758 | // Get size *available for subwindows* i.e. excluding menu bar etc. | |
bc797f4c | 759 | void wxWindowX11::DoGetClientSize(int *x, int *y) const |
83df96d6 | 760 | { |
ab6b6b15 | 761 | Window window = (Window) m_mainWindow; |
b513212d JS |
762 | |
763 | if (window) | |
764 | { | |
765 | XWindowAttributes attr; | |
3cd0b8c5 | 766 | Status status = XGetWindowAttributes( wxGlobalDisplay(), window, &attr ); |
b513212d JS |
767 | wxASSERT(status); |
768 | ||
769 | if (status) | |
770 | { | |
771 | *x = attr.width ; | |
772 | *y = attr.height ; | |
773 | } | |
774 | } | |
83df96d6 JS |
775 | } |
776 | ||
bc797f4c | 777 | void wxWindowX11::DoSetSize(int x, int y, int width, int height, int sizeFlags) |
83df96d6 | 778 | { |
df0e1b64 | 779 | // wxLogDebug("DoSetSize: %s (%ld) %d, %d %dx%d", GetClassInfo()->GetClassName(), GetId(), x, y, width, height); |
ab6b6b15 RR |
780 | |
781 | Window xwindow = (Window) m_mainWindow; | |
83df96d6 | 782 | |
27398643 RR |
783 | wxCHECK_RET( xwindow, wxT("invalid window") ); |
784 | ||
785 | XWindowAttributes attr; | |
786 | Status status = XGetWindowAttributes( wxGlobalDisplay(), xwindow, &attr ); | |
787 | wxCHECK_RET( status, wxT("invalid window attributes") ); | |
788 | ||
789 | int new_x = attr.x; | |
790 | int new_y = attr.y; | |
791 | int new_w = attr.width; | |
792 | int new_h = attr.height; | |
ab6b6b15 | 793 | |
b513212d | 794 | if (x != -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) |
83df96d6 | 795 | { |
27398643 | 796 | int yy = 0; |
e5053ade | 797 | AdjustForParentClientOrigin( x, yy, sizeFlags); |
27398643 | 798 | new_x = x; |
83df96d6 | 799 | } |
b513212d | 800 | if (y != -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) |
83df96d6 | 801 | { |
27398643 | 802 | int xx = 0; |
e5053ade | 803 | AdjustForParentClientOrigin( xx, y, sizeFlags); |
27398643 | 804 | new_y = y; |
83df96d6 | 805 | } |
27398643 | 806 | if (width != -1) |
83df96d6 | 807 | { |
27398643 RR |
808 | new_w = width; |
809 | if (new_w <= 0) | |
810 | new_w = 20; | |
83df96d6 | 811 | } |
27398643 | 812 | if (height != -1) |
b513212d | 813 | { |
27398643 RR |
814 | new_h = height; |
815 | if (new_h <= 0) | |
816 | new_h = 20; | |
b513212d | 817 | } |
27398643 RR |
818 | |
819 | DoMoveWindow( new_x, new_y, new_w, new_h ); | |
83df96d6 JS |
820 | } |
821 | ||
bc797f4c | 822 | void wxWindowX11::DoSetClientSize(int width, int height) |
83df96d6 | 823 | { |
df0e1b64 | 824 | // wxLogDebug("DoSetClientSize: %s (%ld) %dx%d", GetClassInfo()->GetClassName(), GetId(), width, height); |
ab6b6b15 RR |
825 | |
826 | Window xwindow = (Window) m_mainWindow; | |
83df96d6 | 827 | |
27398643 | 828 | wxCHECK_RET( xwindow, wxT("invalid window") ); |
83df96d6 | 829 | |
2f12683e | 830 | XResizeWindow( wxGlobalDisplay(), xwindow, width, height ); |
df0e1b64 | 831 | |
ab6b6b15 RR |
832 | if (m_mainWindow != m_clientWindow) |
833 | { | |
834 | xwindow = (Window) m_clientWindow; | |
27398643 | 835 | |
ab6b6b15 RR |
836 | if (HasFlag( wxSUNKEN_BORDER) || HasFlag( wxRAISED_BORDER)) |
837 | { | |
838 | width -= 4; | |
839 | height -= 4; | |
840 | } else | |
841 | if (HasFlag( wxSIMPLE_BORDER )) | |
842 | { | |
843 | width -= 2; | |
844 | height -= 2; | |
845 | } | |
27398643 | 846 | |
ab6b6b15 RR |
847 | XResizeWindow( wxGlobalDisplay(), xwindow, width, height ); |
848 | } | |
83df96d6 JS |
849 | } |
850 | ||
851 | // For implementation purposes - sometimes decorations make the client area | |
852 | // smaller | |
bc797f4c | 853 | wxPoint wxWindowX11::GetClientAreaOrigin() const |
83df96d6 JS |
854 | { |
855 | return wxPoint(0, 0); | |
856 | } | |
857 | ||
ab6b6b15 RR |
858 | void wxWindowX11::DoMoveWindow(int x, int y, int width, int height) |
859 | { | |
860 | Window xwindow = (Window) m_mainWindow; | |
861 | ||
862 | wxCHECK_RET( xwindow, wxT("invalid window") ); | |
863 | ||
864 | #if !wxUSE_NANOX | |
865 | ||
866 | XMoveResizeWindow( wxGlobalDisplay(), xwindow, x, y, width, height ); | |
867 | if (m_mainWindow != m_clientWindow) | |
868 | { | |
869 | xwindow = (Window) m_clientWindow; | |
870 | ||
871 | if (HasFlag( wxSUNKEN_BORDER) || HasFlag( wxRAISED_BORDER)) | |
872 | { | |
873 | x = 2; | |
874 | y = 2; | |
875 | width -= 4; | |
876 | height -= 4; | |
877 | } else | |
878 | if (HasFlag( wxSIMPLE_BORDER )) | |
879 | { | |
880 | x = 1; | |
881 | y = 1; | |
882 | width -= 2; | |
883 | height -= 2; | |
884 | } else | |
885 | { | |
886 | x = 0; | |
887 | y = 0; | |
888 | } | |
889 | ||
890 | wxWindow *window = (wxWindow*) this; | |
891 | wxScrollBar *sb = window->GetScrollbar( wxHORIZONTAL ); | |
892 | if (sb && sb->IsShown()) | |
893 | { | |
894 | wxSize size = sb->GetSize(); | |
895 | height -= size.y; | |
896 | } | |
897 | sb = window->GetScrollbar( wxVERTICAL ); | |
898 | if (sb && sb->IsShown()) | |
899 | { | |
900 | wxSize size = sb->GetSize(); | |
901 | width -= size.x; | |
902 | } | |
903 | ||
904 | XMoveResizeWindow( wxGlobalDisplay(), xwindow, x, y, width, height ); | |
905 | } | |
906 | ||
907 | #else | |
908 | ||
909 | XWindowChanges windowChanges; | |
910 | windowChanges.x = x; | |
911 | windowChanges.y = y; | |
912 | windowChanges.width = width; | |
913 | windowChanges.height = height; | |
914 | windowChanges.stack_mode = 0; | |
915 | int valueMask = CWX | CWY | CWWidth | CWHeight; | |
916 | ||
917 | XConfigureWindow( wxGlobalDisplay(), xwindow, valueMask, &windowChanges ); | |
918 | ||
919 | #endif | |
920 | } | |
921 | ||
bc797f4c | 922 | void wxWindowX11::SetSizeHints(int minW, int minH, int maxW, int maxH, int incW, int incH) |
83df96d6 JS |
923 | { |
924 | m_minWidth = minW; | |
925 | m_minHeight = minH; | |
926 | m_maxWidth = maxW; | |
927 | m_maxHeight = maxH; | |
928 | ||
461e93f9 | 929 | #if !wxUSE_NANOX |
b513212d JS |
930 | XSizeHints sizeHints; |
931 | sizeHints.flags = 0; | |
932 | ||
933 | if (minW > -1 && minH > -1) | |
83df96d6 | 934 | { |
b513212d JS |
935 | sizeHints.flags |= PMinSize; |
936 | sizeHints.min_width = minW; | |
937 | sizeHints.min_height = minH; | |
938 | } | |
939 | if (maxW > -1 && maxH > -1) | |
940 | { | |
941 | sizeHints.flags |= PMaxSize; | |
942 | sizeHints.max_width = maxW; | |
943 | sizeHints.max_height = maxH; | |
944 | } | |
945 | if (incW > -1 && incH > -1) | |
946 | { | |
947 | sizeHints.flags |= PResizeInc; | |
948 | sizeHints.width_inc = incW; | |
949 | sizeHints.height_inc = incH; | |
83df96d6 JS |
950 | } |
951 | ||
ab6b6b15 | 952 | XSetWMNormalHints(wxGlobalDisplay(), (Window) m_mainWindow, &sizeHints ); |
2f12683e | 953 | #endif |
83df96d6 JS |
954 | } |
955 | ||
956 | // --------------------------------------------------------------------------- | |
957 | // text metrics | |
958 | // --------------------------------------------------------------------------- | |
959 | ||
bc797f4c | 960 | int wxWindowX11::GetCharHeight() const |
83df96d6 JS |
961 | { |
962 | wxCHECK_MSG( m_font.Ok(), 0, "valid window font needed" ); | |
963 | ||
ab6b6b15 | 964 | WXFontStructPtr pFontStruct = m_font.GetFontStruct(1.0, wxGlobalDisplay()); |
83df96d6 JS |
965 | |
966 | int direction, ascent, descent; | |
967 | XCharStruct overall; | |
968 | XTextExtents ((XFontStruct*) pFontStruct, "x", 1, &direction, &ascent, | |
969 | &descent, &overall); | |
970 | ||
971 | // return (overall.ascent + overall.descent); | |
972 | return (ascent + descent); | |
973 | } | |
974 | ||
bc797f4c | 975 | int wxWindowX11::GetCharWidth() const |
83df96d6 JS |
976 | { |
977 | wxCHECK_MSG( m_font.Ok(), 0, "valid window font needed" ); | |
978 | ||
ab6b6b15 | 979 | WXFontStructPtr pFontStruct = m_font.GetFontStruct(1.0, wxGlobalDisplay()); |
83df96d6 JS |
980 | |
981 | int direction, ascent, descent; | |
982 | XCharStruct overall; | |
983 | XTextExtents ((XFontStruct*) pFontStruct, "x", 1, &direction, &ascent, | |
984 | &descent, &overall); | |
985 | ||
986 | return overall.width; | |
987 | } | |
988 | ||
bc797f4c | 989 | void wxWindowX11::GetTextExtent(const wxString& string, |
83df96d6 JS |
990 | int *x, int *y, |
991 | int *descent, int *externalLeading, | |
992 | const wxFont *theFont) const | |
993 | { | |
0d1dff01 RR |
994 | wxFont fontToUse = m_font; |
995 | if (theFont) fontToUse = *theFont; | |
83df96d6 | 996 | |
0d1dff01 RR |
997 | wxCHECK_RET( fontToUse.Ok(), wxT("invalid font") ); |
998 | ||
ab6b6b15 | 999 | WXFontStructPtr pFontStruct = fontToUse.GetFontStruct(1.0, wxGlobalDisplay()); |
83df96d6 JS |
1000 | |
1001 | int direction, ascent, descent2; | |
1002 | XCharStruct overall; | |
1003 | int slen = string.Len(); | |
1004 | ||
1005 | #if 0 | |
1006 | if (use16) | |
1007 | XTextExtents16((XFontStruct*) pFontStruct, (XChar2b *) (char*) (const char*) string, slen, &direction, | |
1008 | &ascent, &descent2, &overall); | |
1009 | #endif | |
1010 | ||
461e93f9 | 1011 | XTextExtents((XFontStruct*) pFontStruct, (char*) string.c_str(), slen, |
83df96d6 JS |
1012 | &direction, &ascent, &descent2, &overall); |
1013 | ||
1014 | if ( x ) | |
1015 | *x = (overall.width); | |
1016 | if ( y ) | |
1017 | *y = (ascent + descent2); | |
1018 | if (descent) | |
1019 | *descent = descent2; | |
1020 | if (externalLeading) | |
1021 | *externalLeading = 0; | |
1022 | ||
1023 | } | |
1024 | ||
1025 | // ---------------------------------------------------------------------------- | |
1026 | // painting | |
1027 | // ---------------------------------------------------------------------------- | |
1028 | ||
bc797f4c | 1029 | void wxWindowX11::Refresh(bool eraseBack, const wxRect *rect) |
83df96d6 | 1030 | { |
d02cb44e RR |
1031 | if (eraseBack) |
1032 | { | |
1033 | if (rect) | |
1034 | { | |
1035 | // Schedule for later Updating in ::Update() or ::OnInternalIdle(). | |
1036 | m_clearRegion.Union( rect->x, rect->y, rect->width, rect->height ); | |
1037 | } | |
1038 | else | |
1039 | { | |
1040 | int height,width; | |
1041 | GetSize( &width, &height ); | |
1042 | ||
1043 | // Schedule for later Updating in ::Update() or ::OnInternalIdle(). | |
1044 | m_clearRegion.Clear(); | |
1045 | m_clearRegion.Union( 0, 0, width, height ); | |
1046 | } | |
1047 | } | |
83df96d6 | 1048 | |
83df96d6 JS |
1049 | if (rect) |
1050 | { | |
d02cb44e RR |
1051 | // Schedule for later Updating in ::Update() or ::OnInternalIdle(). |
1052 | m_updateRegion.Union( rect->x, rect->y, rect->width, rect->height ); | |
83df96d6 JS |
1053 | } |
1054 | else | |
1055 | { | |
0d1dff01 RR |
1056 | int height,width; |
1057 | GetSize( &width, &height ); | |
d02cb44e RR |
1058 | |
1059 | // Schedule for later Updating in ::Update() or ::OnInternalIdle(). | |
1060 | m_updateRegion.Clear(); | |
1061 | m_updateRegion.Union( 0, 0, width, height ); | |
83df96d6 | 1062 | } |
d02cb44e | 1063 | } |
83df96d6 | 1064 | |
d02cb44e RR |
1065 | void wxWindowX11::Update() |
1066 | { | |
ab6b6b15 RR |
1067 | if (m_updateNcArea) |
1068 | { | |
065722d7 | 1069 | // wxLogDebug("wxWindowX11::UpdateNC: %s", GetClassInfo()->GetClassName()); |
ab6b6b15 RR |
1070 | // Send nc paint events. |
1071 | SendNcPaintEvents(); | |
1072 | } | |
1073 | ||
d02cb44e | 1074 | if (!m_updateRegion.IsEmpty()) |
83df96d6 | 1075 | { |
ab6b6b15 | 1076 | // wxLogDebug("wxWindowX11::Update: %s", GetClassInfo()->GetClassName()); |
887dd52f RR |
1077 | // Actually send erase events. |
1078 | SendEraseEvents(); | |
1079 | ||
1080 | // Actually send paint events. | |
1081 | SendPaintEvents(); | |
83df96d6 | 1082 | } |
83df96d6 JS |
1083 | } |
1084 | ||
bc797f4c | 1085 | void wxWindowX11::Clear() |
83df96d6 | 1086 | { |
ab6b6b15 RR |
1087 | // wxClientDC dc((wxWindow*) this); |
1088 | // wxBrush brush(GetBackgroundColour(), wxSOLID); | |
1089 | // dc.SetBackground(brush); | |
1090 | // dc.Clear(); | |
83df96d6 JS |
1091 | } |
1092 | ||
887dd52f | 1093 | void wxWindowX11::SendEraseEvents() |
83df96d6 | 1094 | { |
2f12683e RR |
1095 | if (m_clearRegion.IsEmpty()) return; |
1096 | ||
ab6b6b15 | 1097 | wxClientDC dc( (wxWindow*)this ); |
2f12683e RR |
1098 | dc.SetClippingRegion( m_clearRegion ); |
1099 | ||
1100 | wxEraseEvent erase_event( GetId(), &dc ); | |
1101 | erase_event.SetEventObject( this ); | |
0b5c0e1a | 1102 | |
c2c0dabf | 1103 | if (!GetEventHandler()->ProcessEvent(erase_event) ) |
2f12683e | 1104 | { |
2f12683e | 1105 | Display *xdisplay = wxGlobalDisplay(); |
c2c0dabf RR |
1106 | Window xwindow = (Window) GetClientWindow(); |
1107 | XSetForeground( xdisplay, g_eraseGC, m_backgroundColour.GetPixel() ); | |
1108 | ||
2f12683e RR |
1109 | wxRegionIterator upd( m_clearRegion ); |
1110 | while (upd) | |
1934d291 | 1111 | { |
c2c0dabf | 1112 | XFillRectangle( xdisplay, xwindow, g_eraseGC, |
2f12683e RR |
1113 | upd.GetX(), upd.GetY(), upd.GetWidth(), upd.GetHeight() ); |
1114 | upd ++; | |
1934d291 | 1115 | } |
83df96d6 | 1116 | } |
2f12683e RR |
1117 | |
1118 | m_clearRegion.Clear(); | |
887dd52f RR |
1119 | } |
1120 | ||
887dd52f RR |
1121 | void wxWindowX11::SendPaintEvents() |
1122 | { | |
df0e1b64 JS |
1123 | // wxLogDebug("SendPaintEvents: %s (%ld)", GetClassInfo()->GetClassName(), GetId()); |
1124 | ||
887dd52f | 1125 | m_clipPaintRegion = TRUE; |
aae73669 | 1126 | |
1934d291 RR |
1127 | wxPaintEvent paint_event( GetId() ); |
1128 | paint_event.SetEventObject( this ); | |
1129 | GetEventHandler()->ProcessEvent( paint_event ); | |
0d1dff01 | 1130 | |
0b5c0e1a | 1131 | m_updateRegion.Clear(); |
2f12683e | 1132 | |
1934d291 | 1133 | m_clipPaintRegion = FALSE; |
83df96d6 JS |
1134 | } |
1135 | ||
ab6b6b15 RR |
1136 | void wxWindowX11::SendNcPaintEvents() |
1137 | { | |
1138 | wxNcPaintEvent nc_paint_event( GetId() ); | |
1139 | nc_paint_event.SetEventObject( this ); | |
1140 | GetEventHandler()->ProcessEvent( nc_paint_event ); | |
065722d7 RR |
1141 | |
1142 | m_updateNcArea = FALSE; | |
ab6b6b15 RR |
1143 | } |
1144 | ||
83df96d6 JS |
1145 | // ---------------------------------------------------------------------------- |
1146 | // event handlers | |
1147 | // ---------------------------------------------------------------------------- | |
1148 | ||
1149 | // Responds to colour changes: passes event on to children. | |
bc797f4c | 1150 | void wxWindowX11::OnSysColourChanged(wxSysColourChangedEvent& event) |
83df96d6 JS |
1151 | { |
1152 | wxWindowList::Node *node = GetChildren().GetFirst(); | |
1153 | while ( node ) | |
1154 | { | |
1155 | // Only propagate to non-top-level windows | |
1156 | wxWindow *win = node->GetData(); | |
1157 | if ( win->GetParent() ) | |
1158 | { | |
1159 | wxSysColourChangedEvent event2; | |
1160 | event.m_eventObject = win; | |
1161 | win->GetEventHandler()->ProcessEvent(event2); | |
1162 | } | |
1163 | ||
1164 | node = node->GetNext(); | |
1165 | } | |
1166 | } | |
1167 | ||
0d1dff01 | 1168 | void wxWindowX11::OnInternalIdle() |
83df96d6 | 1169 | { |
0d1dff01 RR |
1170 | // Update invalidated regions. |
1171 | Update(); | |
1172 | ||
83df96d6 JS |
1173 | // This calls the UI-update mechanism (querying windows for |
1174 | // menu/toolbar/control state information) | |
1175 | UpdateWindowUI(); | |
3a0b23eb JS |
1176 | |
1177 | // Set the input focus if couldn't do it before | |
1178 | if (m_needsInputFocus) | |
ff6b424a | 1179 | { |
3a0b23eb | 1180 | SetFocus(); |
ff6b424a | 1181 | } |
83df96d6 JS |
1182 | } |
1183 | ||
83df96d6 JS |
1184 | // ---------------------------------------------------------------------------- |
1185 | // function which maintain the global hash table mapping Widgets to wxWindows | |
1186 | // ---------------------------------------------------------------------------- | |
1187 | ||
bc797f4c | 1188 | bool wxAddWindowToTable(Window w, wxWindow *win) |
83df96d6 JS |
1189 | { |
1190 | wxWindow *oldItem = NULL; | |
1191 | if ((oldItem = (wxWindow *)wxWidgetHashTable->Get ((long) w))) | |
1192 | { | |
1193 | wxLogDebug("Widget table clash: new widget is %ld, %s", | |
1194 | (long)w, win->GetClassInfo()->GetClassName()); | |
1195 | return FALSE; | |
1196 | } | |
1197 | ||
1198 | wxWidgetHashTable->Put((long) w, win); | |
1199 | ||
bc797f4c | 1200 | wxLogTrace("widget", "XWindow 0x%08x <-> window %p (%s)", |
83df96d6 JS |
1201 | w, win, win->GetClassInfo()->GetClassName()); |
1202 | ||
1203 | return TRUE; | |
1204 | } | |
1205 | ||
bc797f4c | 1206 | wxWindow *wxGetWindowFromTable(Window w) |
83df96d6 JS |
1207 | { |
1208 | return (wxWindow *)wxWidgetHashTable->Get((long) w); | |
1209 | } | |
1210 | ||
bc797f4c | 1211 | void wxDeleteWindowFromTable(Window w) |
83df96d6 JS |
1212 | { |
1213 | wxWidgetHashTable->Delete((long)w); | |
1214 | } | |
1215 | ||
1216 | // ---------------------------------------------------------------------------- | |
ab6b6b15 | 1217 | // function which maintain the global hash table mapping client widgets |
83df96d6 JS |
1218 | // ---------------------------------------------------------------------------- |
1219 | ||
ab6b6b15 RR |
1220 | bool wxAddClientWindowToTable(Window w, wxWindow *win) |
1221 | { | |
1222 | wxWindow *oldItem = NULL; | |
1223 | if ((oldItem = (wxWindow *)wxClientWidgetHashTable->Get ((long) w))) | |
1224 | { | |
1225 | wxLogDebug("Client window table clash: new window is %ld, %s", | |
1226 | (long)w, win->GetClassInfo()->GetClassName()); | |
1227 | return FALSE; | |
1228 | } | |
1229 | ||
1230 | wxClientWidgetHashTable->Put((long) w, win); | |
1231 | ||
1232 | wxLogTrace("widget", "XWindow 0x%08x <-> window %p (%s)", | |
1233 | w, win, win->GetClassInfo()->GetClassName()); | |
83df96d6 | 1234 | |
ab6b6b15 RR |
1235 | return TRUE; |
1236 | } | |
1237 | ||
1238 | wxWindow *wxGetClientWindowFromTable(Window w) | |
83df96d6 | 1239 | { |
ab6b6b15 | 1240 | return (wxWindow *)wxClientWidgetHashTable->Get((long) w); |
83df96d6 JS |
1241 | } |
1242 | ||
ab6b6b15 | 1243 | void wxDeleteClientWindowFromTable(Window w) |
83df96d6 | 1244 | { |
ab6b6b15 | 1245 | wxClientWidgetHashTable->Delete((long)w); |
83df96d6 JS |
1246 | } |
1247 | ||
ab6b6b15 RR |
1248 | // ---------------------------------------------------------------------------- |
1249 | // add/remove window from the table | |
1250 | // ---------------------------------------------------------------------------- | |
1251 | ||
1252 | // ---------------------------------------------------------------------------- | |
1253 | // X11-specific accessors | |
1254 | // ---------------------------------------------------------------------------- | |
1255 | ||
bc797f4c | 1256 | WXWindow wxWindowX11::GetMainWindow() const |
83df96d6 | 1257 | { |
ab6b6b15 RR |
1258 | return m_mainWindow; |
1259 | } | |
1260 | ||
1261 | WXWindow wxWindowX11::GetClientWindow() const | |
1262 | { | |
1263 | return m_clientWindow; | |
83df96d6 JS |
1264 | } |
1265 | ||
83df96d6 JS |
1266 | // ---------------------------------------------------------------------------- |
1267 | // TranslateXXXEvent() functions | |
1268 | // ---------------------------------------------------------------------------- | |
1269 | ||
1b0fb34b | 1270 | bool wxTranslateMouseEvent(wxMouseEvent& wxevent, wxWindow *win, Window window, XEvent *xevent) |
83df96d6 | 1271 | { |
461e93f9 | 1272 | switch (XEventGetType(xevent)) |
83df96d6 | 1273 | { |
1b0fb34b JS |
1274 | case EnterNotify: |
1275 | case LeaveNotify: | |
83df96d6 JS |
1276 | case ButtonPress: |
1277 | case ButtonRelease: | |
1278 | case MotionNotify: | |
1279 | { | |
1280 | wxEventType eventType = wxEVT_NULL; | |
1281 | ||
461e93f9 | 1282 | if (XEventGetType(xevent) == EnterNotify) |
83df96d6 | 1283 | { |
1b0fb34b JS |
1284 | //if (local_event.xcrossing.mode!=NotifyNormal) |
1285 | // return ; // Ignore grab events | |
1286 | eventType = wxEVT_ENTER_WINDOW; | |
1287 | // canvas->GetEventHandler()->OnSetFocus(); | |
1288 | } | |
461e93f9 | 1289 | else if (XEventGetType(xevent) == LeaveNotify) |
1b0fb34b JS |
1290 | { |
1291 | //if (local_event.xcrossingr.mode!=NotifyNormal) | |
1292 | // return ; // Ignore grab events | |
1293 | eventType = wxEVT_LEAVE_WINDOW; | |
1294 | // canvas->GetEventHandler()->OnKillFocus(); | |
83df96d6 | 1295 | } |
461e93f9 | 1296 | else if (XEventGetType(xevent) == MotionNotify) |
83df96d6 JS |
1297 | { |
1298 | eventType = wxEVT_MOTION; | |
1299 | } | |
461e93f9 | 1300 | else if (XEventGetType(xevent) == ButtonPress) |
83df96d6 | 1301 | { |
461e93f9 | 1302 | wxevent.SetTimestamp(XButtonEventGetTime(xevent)); |
83df96d6 | 1303 | int button = 0; |
461e93f9 | 1304 | if (XButtonEventLChanged(xevent)) |
83df96d6 JS |
1305 | { |
1306 | eventType = wxEVT_LEFT_DOWN; | |
83df96d6 JS |
1307 | button = 1; |
1308 | } | |
461e93f9 | 1309 | else if (XButtonEventMChanged(xevent)) |
83df96d6 JS |
1310 | { |
1311 | eventType = wxEVT_MIDDLE_DOWN; | |
83df96d6 JS |
1312 | button = 2; |
1313 | } | |
461e93f9 | 1314 | else if (XButtonEventRChanged(xevent)) |
83df96d6 JS |
1315 | { |
1316 | eventType = wxEVT_RIGHT_DOWN; | |
83df96d6 JS |
1317 | button = 3; |
1318 | } | |
1319 | ||
1320 | // check for a double click | |
1b0fb34b | 1321 | // TODO: where can we get this value from? |
b513212d | 1322 | //long dclickTime = XtGetMultiClickTime(wxGlobalDisplay()); |
7266b672 | 1323 | long dclickTime = 200; |
83df96d6 JS |
1324 | long ts = wxevent.GetTimestamp(); |
1325 | ||
1326 | int buttonLast = win->GetLastClickedButton(); | |
1327 | long lastTS = win->GetLastClickTime(); | |
1328 | if ( buttonLast && buttonLast == button && (ts - lastTS) < dclickTime ) | |
1329 | { | |
1330 | // I have a dclick | |
1331 | win->SetLastClick(0, ts); | |
1332 | if ( eventType == wxEVT_LEFT_DOWN ) | |
1333 | eventType = wxEVT_LEFT_DCLICK; | |
1334 | else if ( eventType == wxEVT_MIDDLE_DOWN ) | |
1335 | eventType = wxEVT_MIDDLE_DCLICK; | |
1336 | else if ( eventType == wxEVT_RIGHT_DOWN ) | |
1337 | eventType = wxEVT_RIGHT_DCLICK; | |
1338 | } | |
1339 | else | |
1340 | { | |
1341 | // not fast enough or different button | |
1342 | win->SetLastClick(button, ts); | |
1343 | } | |
1344 | } | |
461e93f9 | 1345 | else if (XEventGetType(xevent) == ButtonRelease) |
83df96d6 | 1346 | { |
461e93f9 | 1347 | if (XButtonEventLChanged(xevent)) |
83df96d6 JS |
1348 | { |
1349 | eventType = wxEVT_LEFT_UP; | |
83df96d6 | 1350 | } |
461e93f9 | 1351 | else if (XButtonEventMChanged(xevent)) |
83df96d6 JS |
1352 | { |
1353 | eventType = wxEVT_MIDDLE_UP; | |
83df96d6 | 1354 | } |
461e93f9 | 1355 | else if (XButtonEventRChanged(xevent)) |
83df96d6 JS |
1356 | { |
1357 | eventType = wxEVT_RIGHT_UP; | |
83df96d6 JS |
1358 | } |
1359 | else return FALSE; | |
1360 | } | |
1361 | else | |
1362 | { | |
1363 | return FALSE; | |
1364 | } | |
1365 | ||
1366 | wxevent.SetEventType(eventType); | |
1367 | ||
461e93f9 JS |
1368 | wxevent.m_x = XButtonEventGetX(xevent); |
1369 | wxevent.m_y = XButtonEventGetY(xevent); | |
83df96d6 JS |
1370 | |
1371 | wxevent.m_leftDown = ((eventType == wxEVT_LEFT_DOWN) | |
461e93f9 | 1372 | || (XButtonEventLIsDown(xevent) |
83df96d6 JS |
1373 | && (eventType != wxEVT_LEFT_UP))); |
1374 | wxevent.m_middleDown = ((eventType == wxEVT_MIDDLE_DOWN) | |
461e93f9 | 1375 | || (XButtonEventMIsDown(xevent) |
83df96d6 JS |
1376 | && (eventType != wxEVT_MIDDLE_UP))); |
1377 | wxevent.m_rightDown = ((eventType == wxEVT_RIGHT_DOWN) | |
461e93f9 | 1378 | || (XButtonEventRIsDown (xevent) |
83df96d6 JS |
1379 | && (eventType != wxEVT_RIGHT_UP))); |
1380 | ||
461e93f9 JS |
1381 | wxevent.m_shiftDown = XButtonEventShiftIsDown(xevent); |
1382 | wxevent.m_controlDown = XButtonEventCtrlIsDown(xevent); | |
1383 | wxevent.m_altDown = XButtonEventAltIsDown(xevent); | |
1384 | wxevent.m_metaDown = XButtonEventMetaIsDown(xevent); | |
83df96d6 JS |
1385 | |
1386 | wxevent.SetId(win->GetId()); | |
1387 | wxevent.SetEventObject(win); | |
1388 | ||
1389 | return TRUE; | |
1390 | } | |
1391 | } | |
1392 | return FALSE; | |
1393 | } | |
1394 | ||
7eaac9f5 | 1395 | bool wxTranslateKeyEvent(wxKeyEvent& wxevent, wxWindow *win, Window WXUNUSED(win), XEvent *xevent) |
83df96d6 | 1396 | { |
461e93f9 | 1397 | switch (XEventGetType(xevent)) |
83df96d6 JS |
1398 | { |
1399 | case KeyPress: | |
1400 | case KeyRelease: | |
1401 | { | |
1402 | char buf[20]; | |
1403 | ||
1404 | KeySym keySym; | |
83df96d6 JS |
1405 | (void) XLookupString ((XKeyEvent *) xevent, buf, 20, &keySym, NULL); |
1406 | int id = wxCharCodeXToWX (keySym); | |
1407 | ||
461e93f9 JS |
1408 | wxevent.m_shiftDown = XKeyEventShiftIsDown(xevent); |
1409 | wxevent.m_controlDown = XKeyEventCtrlIsDown(xevent); | |
1410 | wxevent.m_altDown = XKeyEventAltIsDown(xevent); | |
1411 | wxevent.m_metaDown = XKeyEventMetaIsDown(xevent); | |
83df96d6 JS |
1412 | wxevent.SetEventObject(win); |
1413 | wxevent.m_keyCode = id; | |
461e93f9 | 1414 | wxevent.SetTimestamp(XKeyEventGetTime(xevent)); |
83df96d6 | 1415 | |
461e93f9 JS |
1416 | wxevent.m_x = XKeyEventGetX(xevent); |
1417 | wxevent.m_y = XKeyEventGetY(xevent); | |
83df96d6 JS |
1418 | |
1419 | if (id > -1) | |
1420 | return TRUE; | |
1421 | else | |
1422 | return FALSE; | |
1423 | break; | |
1424 | } | |
1425 | default: | |
1426 | break; | |
1427 | } | |
1428 | return FALSE; | |
1429 | } | |
1430 | ||
1431 | // ---------------------------------------------------------------------------- | |
1432 | // Colour stuff | |
1433 | // ---------------------------------------------------------------------------- | |
1434 | ||
bc797f4c | 1435 | bool wxWindowX11::SetBackgroundColour(const wxColour& col) |
83df96d6 | 1436 | { |
56cb684a | 1437 | wxWindowBase::SetBackgroundColour(col); |
83df96d6 | 1438 | |
3cd0b8c5 RR |
1439 | Display *xdisplay = (Display*) wxGlobalDisplay(); |
1440 | int xscreen = DefaultScreen( xdisplay ); | |
1441 | Colormap cm = DefaultColormap( xdisplay, xscreen ); | |
1442 | ||
ba696cfa | 1443 | m_backgroundColour.CalcPixel( (WXColormap) cm ); |
3cd0b8c5 | 1444 | |
c2c0dabf RR |
1445 | // We don't set the background colour as we paint |
1446 | // the background ourselves. | |
1447 | // XSetWindowBackground( xdisplay, (Window) m_clientWindow, m_backgroundColour.GetPixel() ); | |
1448 | ||
83df96d6 JS |
1449 | return TRUE; |
1450 | } | |
1451 | ||
bc797f4c | 1452 | bool wxWindowX11::SetForegroundColour(const wxColour& col) |
83df96d6 JS |
1453 | { |
1454 | if ( !wxWindowBase::SetForegroundColour(col) ) | |
1455 | return FALSE; | |
1456 | ||
83df96d6 JS |
1457 | return TRUE; |
1458 | } | |
1459 | ||
83df96d6 JS |
1460 | // ---------------------------------------------------------------------------- |
1461 | // global functions | |
1462 | // ---------------------------------------------------------------------------- | |
1463 | ||
1464 | wxWindow *wxGetActiveWindow() | |
1465 | { | |
1466 | // TODO | |
1467 | wxFAIL_MSG("Not implemented"); | |
1468 | return NULL; | |
1469 | } | |
1470 | ||
1471 | /* static */ | |
1472 | wxWindow *wxWindowBase::GetCapture() | |
1473 | { | |
1474 | return (wxWindow *)g_captureWindow; | |
1475 | } | |
1476 | ||
1477 | ||
1478 | // Find the wxWindow at the current mouse position, returning the mouse | |
1479 | // position. | |
1480 | wxWindow* wxFindWindowAtPointer(wxPoint& pt) | |
1481 | { | |
1482 | return wxFindWindowAtPoint(wxGetMousePosition()); | |
1483 | } | |
1484 | ||
1485 | // Get the current mouse position. | |
1486 | wxPoint wxGetMousePosition() | |
1487 | { | |
461e93f9 JS |
1488 | #if wxUSE_NANOX |
1489 | /* TODO */ | |
1490 | return wxPoint(0, 0); | |
1491 | #else | |
b513212d | 1492 | Display *display = wxGlobalDisplay(); |
83df96d6 JS |
1493 | Window rootWindow = RootWindowOfScreen (DefaultScreenOfDisplay(display)); |
1494 | Window rootReturn, childReturn; | |
1495 | int rootX, rootY, winX, winY; | |
1496 | unsigned int maskReturn; | |
1497 | ||
1498 | XQueryPointer (display, | |
1499 | rootWindow, | |
1500 | &rootReturn, | |
1501 | &childReturn, | |
1502 | &rootX, &rootY, &winX, &winY, &maskReturn); | |
1503 | return wxPoint(rootX, rootY); | |
461e93f9 | 1504 | #endif |
83df96d6 JS |
1505 | } |
1506 | ||
1507 | ||
1508 | // ---------------------------------------------------------------------------- | |
1509 | // wxNoOptimize: switch off size optimization | |
1510 | // ---------------------------------------------------------------------------- | |
1511 | ||
1512 | int wxNoOptimize::ms_count = 0; | |
1513 | ||
c2c0dabf RR |
1514 | |
1515 | // ---------------------------------------------------------------------------- | |
1516 | // wxDCModule | |
1517 | // ---------------------------------------------------------------------------- | |
1518 | ||
1519 | class wxWinModule : public wxModule | |
1520 | { | |
1521 | public: | |
1522 | bool OnInit(); | |
1523 | void OnExit(); | |
1524 | ||
1525 | private: | |
1526 | DECLARE_DYNAMIC_CLASS(wxWinModule) | |
1527 | }; | |
1528 | ||
1529 | IMPLEMENT_DYNAMIC_CLASS(wxWinModule, wxModule) | |
1530 | ||
1531 | bool wxWinModule::OnInit() | |
1532 | { | |
1533 | Display *xdisplay = wxGlobalDisplay(); | |
1534 | int xscreen = DefaultScreen( xdisplay ); | |
1535 | Window xroot = RootWindow( xdisplay, xscreen ); | |
1536 | g_eraseGC = XCreateGC( xdisplay, xroot, 0, NULL ); | |
1537 | XSetFillStyle( xdisplay, g_eraseGC, FillSolid ); | |
1538 | ||
1539 | return TRUE; | |
1540 | } | |
1541 | ||
1542 | void wxWinModule::OnExit() | |
1543 | { | |
1544 | Display *xdisplay = wxGlobalDisplay(); | |
1545 | XFreeGC( xdisplay, g_eraseGC ); | |
1546 | } | |
1547 | ||
1548 |