1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
23 #include "wx/dcclient.h"
27 #include "wx/layout.h"
28 #include "wx/dialog.h"
29 #include "wx/listbox.h"
30 #include "wx/button.h"
31 #include "wx/settings.h"
32 #include "wx/msgdlg.h"
34 #include "wx/scrolwin.h"
35 #include "wx/scrolbar.h"
36 #include "wx/module.h"
37 #include "wx/menuitem.h"
39 #include "wx/fontutil.h"
40 #include "wx/univ/renderer.h"
43 #if wxUSE_DRAG_AND_DROP
47 #include "wx/x11/private.h"
48 #include "X11/Xutil.h"
51 // For wxGetLocalTime, used by XButtonEventGetTime
57 // ----------------------------------------------------------------------------
58 // global variables for this module
59 // ----------------------------------------------------------------------------
61 static wxWindow
* g_captureWindow
= NULL
;
64 // ----------------------------------------------------------------------------
66 // ----------------------------------------------------------------------------
68 #define event_left_is_down(x) ((x)->xbutton.state & Button1Mask)
69 #define event_middle_is_down(x) ((x)->xbutton.state & Button2Mask)
70 #define event_right_is_down(x) ((x)->xbutton.state & Button3Mask)
72 // ----------------------------------------------------------------------------
74 // ----------------------------------------------------------------------------
76 IMPLEMENT_ABSTRACT_CLASS(wxWindowX11
, wxWindowBase
)
78 BEGIN_EVENT_TABLE(wxWindowX11
, wxWindowBase
)
79 EVT_SYS_COLOUR_CHANGED(wxWindowX11::OnSysColourChanged
)
82 // ============================================================================
84 // ============================================================================
86 // ----------------------------------------------------------------------------
88 // ----------------------------------------------------------------------------
90 // ----------------------------------------------------------------------------
92 // ----------------------------------------------------------------------------
94 void wxWindowX11::Init()
97 m_mainWindow
= (WXWindow
) 0;
98 m_clientWindow
= (WXWindow
) 0;
99 m_insertIntoMain
= FALSE
;
100 m_updateNcArea
= FALSE
;
102 m_winCaptured
= FALSE
;
103 m_needsInputFocus
= FALSE
;
109 // real construction (Init() must have been called before!)
110 bool wxWindowX11::Create(wxWindow
*parent
, wxWindowID id
,
114 const wxString
& name
)
116 wxCHECK_MSG( parent
, FALSE
, wxT("can't create wxWindow without parent") );
118 CreateBase(parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
);
120 parent
->AddChild(this);
122 Display
*xdisplay
= (Display
*) wxGlobalDisplay();
123 int xscreen
= DefaultScreen( xdisplay
);
124 Visual
*xvisual
= DefaultVisual( xdisplay
, xscreen
);
125 Colormap cm
= DefaultColormap( xdisplay
, xscreen
);
127 m_backgroundColour
= wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE
);
128 m_backgroundColour
.CalcPixel( (WXColormap
) cm
);
130 m_foregroundColour
= *wxBLACK
;
131 m_foregroundColour
.CalcPixel( (WXColormap
) cm
);
133 Window xparent
= (Window
) parent
->GetClientAreaWindow();
135 // Add window's own scrollbars to main window, not to client window
136 if (parent
->GetInsertIntoMain())
138 // wxLogDebug( "Inserted into main: %s", GetName().c_str() );
139 xparent
= (Window
) parent
->GetMainWindow();
142 // Size (not including the border) must be nonzero (or a Value error results)!
143 // Note: The Xlib manual doesn't mention this restriction of XCreateWindow.
156 #if wxUSE_TWO_WINDOWS
157 bool need_two_windows
=
158 ((( wxSUNKEN_BORDER
| wxRAISED_BORDER
| wxSIMPLE_BORDER
| wxHSCROLL
| wxVSCROLL
) & m_windowStyle
) != 0);
160 bool need_two_windows
= FALSE
;
164 long xattributes
= 0;
166 XSetWindowAttributes xattributes
;
167 long xattributes_mask
= 0;
169 xattributes_mask
|= CWBackPixel
;
170 xattributes
.background_pixel
= m_backgroundColour
.GetPixel();
172 xattributes_mask
|= CWBorderPixel
;
173 xattributes
.border_pixel
= BlackPixel( xdisplay
, xscreen
);
175 xattributes_mask
|= CWEventMask
;
178 if (need_two_windows
)
181 long backColor
, foreColor
;
182 backColor
= GR_RGB(m_backgroundColour
.Red(), m_backgroundColour
.Green(), m_backgroundColour
.Blue());
183 foreColor
= GR_RGB(m_foregroundColour
.Red(), m_foregroundColour
.Green(), m_foregroundColour
.Blue());
185 Window xwindow
= XCreateWindowWithColor( xdisplay
, xparent
, pos2
.x
, pos2
.y
, size2
.x
, size2
.y
,
186 0, 0, InputOutput
, xvisual
, backColor
, foreColor
);
187 XSelectInput( xdisplay
, xwindow
,
188 GR_EVENT_MASK_CLOSE_REQ
| ExposureMask
| KeyPressMask
| KeyReleaseMask
| ButtonPressMask
| ButtonReleaseMask
|
189 ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
|
190 KeymapStateMask
| FocusChangeMask
| ColormapChangeMask
| StructureNotifyMask
|
191 PropertyChangeMask
);
195 xattributes
.event_mask
=
196 ExposureMask
| StructureNotifyMask
| ColormapChangeMask
;
198 Window xwindow
= XCreateWindow( xdisplay
, xparent
, pos2
.x
, pos2
.y
, size2
.x
, size2
.y
,
199 0, DefaultDepth(xdisplay
,xscreen
), InputOutput
, xvisual
, xattributes_mask
, &xattributes
);
203 XSetWindowBackgroundPixmap( xdisplay
, xwindow
, None
);
205 m_mainWindow
= (WXWindow
) xwindow
;
206 wxAddWindowToTable( xwindow
, (wxWindow
*) this );
208 XMapWindow( xdisplay
, xwindow
);
211 xattributes
.event_mask
=
212 ExposureMask
| KeyPressMask
| KeyReleaseMask
| ButtonPressMask
| ButtonReleaseMask
|
213 ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
|
214 KeymapStateMask
| FocusChangeMask
| ColormapChangeMask
| StructureNotifyMask
|
215 PropertyChangeMask
| VisibilityChangeMask
;
217 if (!HasFlag( wxFULL_REPAINT_ON_RESIZE
))
219 xattributes_mask
|= CWBitGravity
;
220 xattributes
.bit_gravity
= StaticGravity
;
224 if (HasFlag( wxSUNKEN_BORDER
) || HasFlag( wxRAISED_BORDER
))
231 else if (HasFlag( wxSIMPLE_BORDER
))
244 // Make again sure the size is nonzero.
251 backColor
= GR_RGB(m_backgroundColour
.Red(), m_backgroundColour
.Green(), m_backgroundColour
.Blue());
252 foreColor
= GR_RGB(m_foregroundColour
.Red(), m_foregroundColour
.Green(), m_foregroundColour
.Blue());
254 xwindow
= XCreateWindowWithColor( xdisplay
, xwindow
, pos2
.x
, pos2
.y
, size2
.x
, size2
.y
,
255 0, 0, InputOutput
, xvisual
, backColor
, foreColor
);
256 XSelectInput( xdisplay
, xwindow
,
257 GR_EVENT_MASK_CLOSE_REQ
| ExposureMask
| KeyPressMask
| KeyReleaseMask
| ButtonPressMask
| ButtonReleaseMask
|
258 ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
|
259 KeymapStateMask
| FocusChangeMask
| ColormapChangeMask
| StructureNotifyMask
|
260 PropertyChangeMask
);
263 xwindow
= XCreateWindow( xdisplay
, xwindow
, pos2
.x
, pos2
.y
, size2
.x
, size2
.y
,
264 0, DefaultDepth(xdisplay
,xscreen
), InputOutput
, xvisual
, xattributes_mask
, &xattributes
);
267 XSetWindowBackgroundPixmap( xdisplay
, xwindow
, None
);
269 m_clientWindow
= (WXWindow
) xwindow
;
270 wxAddClientWindowToTable( xwindow
, (wxWindow
*) this );
272 XMapWindow( xdisplay
, xwindow
);
276 // wxLogDebug( "No two windows needed %s", GetName().c_str() );
278 long backColor
, foreColor
;
279 backColor
= GR_RGB(m_backgroundColour
.Red(), m_backgroundColour
.Green(), m_backgroundColour
.Blue());
280 foreColor
= GR_RGB(m_foregroundColour
.Red(), m_foregroundColour
.Green(), m_foregroundColour
.Blue());
282 Window xwindow
= XCreateWindowWithColor( xdisplay
, xparent
, pos2
.x
, pos2
.y
, size2
.x
, size2
.y
,
283 0, 0, InputOutput
, xvisual
, backColor
, foreColor
);
284 XSelectInput( xdisplay
, xwindow
,
285 GR_EVENT_MASK_CLOSE_REQ
| ExposureMask
| KeyPressMask
| KeyReleaseMask
| ButtonPressMask
| ButtonReleaseMask
|
286 ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
|
287 KeymapStateMask
| FocusChangeMask
| ColormapChangeMask
| StructureNotifyMask
|
288 PropertyChangeMask
);
291 xattributes
.event_mask
=
292 ExposureMask
| KeyPressMask
| KeyReleaseMask
| ButtonPressMask
| ButtonReleaseMask
|
293 ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
|
294 KeymapStateMask
| FocusChangeMask
| ColormapChangeMask
| StructureNotifyMask
|
295 PropertyChangeMask
| VisibilityChangeMask
;
297 if (!HasFlag( wxFULL_REPAINT_ON_RESIZE
))
299 xattributes_mask
|= CWBitGravity
;
300 xattributes
.bit_gravity
= NorthWestGravity
;
303 Window xwindow
= XCreateWindow( xdisplay
, xparent
, pos2
.x
, pos2
.y
, size2
.x
, size2
.y
,
304 0, DefaultDepth(xdisplay
,xscreen
), InputOutput
, xvisual
, xattributes_mask
, &xattributes
);
307 XSetWindowBackgroundPixmap( xdisplay
, xwindow
, None
);
309 m_mainWindow
= (WXWindow
) xwindow
;
310 m_clientWindow
= m_mainWindow
;
311 wxAddWindowToTable( xwindow
, (wxWindow
*) this );
313 XMapWindow( xdisplay
, xwindow
);
316 // Is a subwindow, so map immediately
319 // Without this, the cursor may not be restored properly (e.g. in splitter
321 SetCursor(*wxSTANDARD_CURSOR
);
322 SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
));
324 // Don't call this, it can have nasty repercussions for composite controls,
326 // SetSize(pos.x, pos.y, size.x, size.y);
332 wxWindowX11::~wxWindowX11()
336 if (g_captureWindow
== this)
337 g_captureWindow
= NULL
;
339 m_isBeingDeleted
= TRUE
;
343 if (m_clientWindow
!= m_mainWindow
)
345 // Destroy the cleint window
346 Window xwindow
= (Window
) m_clientWindow
;
347 wxDeleteClientWindowFromTable( xwindow
);
348 XDestroyWindow( wxGlobalDisplay(), xwindow
);
349 m_clientWindow
= NULL
;
352 // Destroy the window
353 Window xwindow
= (Window
) m_mainWindow
;
354 wxDeleteWindowFromTable( xwindow
);
355 XDestroyWindow( wxGlobalDisplay(), xwindow
);
359 // ---------------------------------------------------------------------------
361 // ---------------------------------------------------------------------------
363 void wxWindowX11::SetFocus()
365 Window xwindow
= (Window
) m_clientWindow
;
367 wxCHECK_RET( xwindow
, wxT("invalid window") );
369 // Don't assert; we might be trying to set the focus for a panel
370 // with only static controls, so the panel returns false from AcceptsFocus.
371 // The app should be not be expected to deal with this.
376 if (GetName() == "scrollBar")
383 if (wxWindowIsVisible(xwindow
))
385 wxLogTrace( _T("focus"), _T("wxWindowX11::SetFocus: %s"), GetClassInfo()->GetClassName());
386 // XSetInputFocus( wxGlobalDisplay(), xwindow, RevertToParent, CurrentTime );
387 XSetInputFocus( wxGlobalDisplay(), xwindow
, RevertToNone
, CurrentTime
);
388 m_needsInputFocus
= FALSE
;
392 m_needsInputFocus
= TRUE
;
396 // Get the window with the focus
397 wxWindow
*wxWindowBase::DoFindFocus()
399 Window xfocus
= (Window
) 0;
402 XGetInputFocus( wxGlobalDisplay(), &xfocus
, &revert
);
405 wxWindow
*win
= wxGetWindowFromTable( xfocus
);
408 win
= wxGetClientWindowFromTable( xfocus
);
417 // Enabling/disabling handled by event loop, and not sending events
419 bool wxWindowX11::Enable(bool enable
)
421 if ( !wxWindowBase::Enable(enable
) )
427 bool wxWindowX11::Show(bool show
)
429 wxWindowBase::Show(show
);
431 Window xwindow
= (Window
) m_mainWindow
;
432 Display
*xdisp
= wxGlobalDisplay();
435 // wxLogDebug( "Mapping window of type %s", GetName().c_str() );
436 XMapWindow(xdisp
, xwindow
);
440 // wxLogDebug( "Unmapping window of type %s", GetName().c_str() );
441 XUnmapWindow(xdisp
, xwindow
);
447 // Raise the window to the top of the Z order
448 void wxWindowX11::Raise()
451 XRaiseWindow( wxGlobalDisplay(), (Window
) m_mainWindow
);
454 // Lower the window to the bottom of the Z order
455 void wxWindowX11::Lower()
458 XLowerWindow( wxGlobalDisplay(), (Window
) m_mainWindow
);
461 void wxWindowX11::DoCaptureMouse()
463 if ((g_captureWindow
!= NULL
) && (g_captureWindow
!= this))
465 wxASSERT_MSG(FALSE
, wxT("Trying to capture before mouse released."));
476 Window xwindow
= (Window
) m_clientWindow
;
478 wxCHECK_RET( xwindow
, wxT("invalid window") );
480 g_captureWindow
= (wxWindow
*) this;
484 int res
= XGrabPointer(wxGlobalDisplay(), xwindow
,
486 ButtonPressMask
| ButtonReleaseMask
| ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
,
490 None
, /* cursor */ // TODO: This may need to be set to the cursor of this window
493 if (res
!= GrabSuccess
)
496 msg
.Printf(wxT("Failed to grab pointer for window %s"), this->GetClassInfo()->GetClassName());
498 if (res
== GrabNotViewable
)
499 wxLogDebug( wxT("This is not a viewable window - perhaps not shown yet?") );
501 g_captureWindow
= NULL
;
505 m_winCaptured
= TRUE
;
509 void wxWindowX11::DoReleaseMouse()
511 g_captureWindow
= NULL
;
513 if ( !m_winCaptured
)
516 Window xwindow
= (Window
) m_clientWindow
;
520 XUngrabPointer( wxGlobalDisplay(), CurrentTime
);
523 // wxLogDebug( "Ungrabbed pointer in %s", GetName().c_str() );
525 m_winCaptured
= FALSE
;
528 bool wxWindowX11::SetFont(const wxFont
& font
)
530 if ( !wxWindowBase::SetFont(font
) )
539 bool wxWindowX11::SetCursor(const wxCursor
& cursor
)
541 if ( !wxWindowBase::SetCursor(cursor
) )
547 Window xwindow
= (Window
) m_clientWindow
;
549 wxCHECK_MSG( xwindow
, FALSE
, wxT("invalid window") );
551 wxCursor cursorToUse
;
553 cursorToUse
= m_cursor
;
555 cursorToUse
= *wxSTANDARD_CURSOR
;
557 Cursor xcursor
= (Cursor
) cursorToUse
.GetCursor();
559 XDefineCursor( wxGlobalDisplay(), xwindow
, xcursor
);
564 // Coordinates relative to the window
565 void wxWindowX11::WarpPointer (int x
, int y
)
567 Window xwindow
= (Window
) m_clientWindow
;
569 wxCHECK_RET( xwindow
, wxT("invalid window") );
571 XWarpPointer( wxGlobalDisplay(), None
, xwindow
, 0, 0, 0, 0, x
, y
);
574 // Does a physical scroll
575 void wxWindowX11::ScrollWindow(int dx
, int dy
, const wxRect
*rect
)
577 // No scrolling requested.
578 if ((dx
== 0) && (dy
== 0)) return;
580 if (!m_updateRegion
.IsEmpty())
582 m_updateRegion
.Offset( dx
, dy
);
586 GetSize( &cw
, &ch
); // GetClientSize() ??
587 m_updateRegion
.Intersect( 0, 0, cw
, ch
);
590 if (!m_clearRegion
.IsEmpty())
592 m_clearRegion
.Offset( dx
, dy
);
596 GetSize( &cw
, &ch
); // GetClientSize() ??
597 m_clearRegion
.Intersect( 0, 0, cw
, ch
);
600 Window xwindow
= (Window
) GetClientAreaWindow();
602 wxCHECK_RET( xwindow
, wxT("invalid window") );
604 Display
*xdisplay
= wxGlobalDisplay();
606 GC xgc
= XCreateGC( xdisplay
, xwindow
, 0, NULL
);
607 XSetGraphicsExposures( xdisplay
, xgc
, True
);
625 GetClientSize( &cw
, &ch
);
628 #if wxUSE_TWO_WINDOWS
629 wxPoint
offset( 0,0 );
631 wxPoint offset
= GetClientAreaOrigin();
636 int w
= cw
- abs(dx
);
637 int h
= ch
- abs(dy
);
639 if ((h
< 0) || (w
< 0))
646 if (dx
< 0) rect
.x
= cw
+dx
+ offset
.x
; else rect
.x
= s_x
;
647 if (dy
< 0) rect
.y
= ch
+dy
+ offset
.y
; else rect
.y
= s_y
;
648 if (dy
!= 0) rect
.width
= cw
; else rect
.width
= abs(dx
);
649 if (dx
!= 0) rect
.height
= ch
; else rect
.height
= abs(dy
);
654 if (dx
< 0) s_x
+= -dx
;
655 if (dy
< 0) s_y
+= -dy
;
656 if (dx
> 0) d_x
= dx
+ offset
.x
;
657 if (dy
> 0) d_y
= dy
+ offset
.y
;
659 XCopyArea( xdisplay
, xwindow
, xwindow
, xgc
, s_x
, s_y
, w
, h
, d_x
, d_y
);
661 // 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 );
663 // wxLogDebug( "Update: %d %d %d %d", rect.x, rect.y, rect.width, rect.height );
665 m_updateRegion
.Union( rect
);
666 m_clearRegion
.Union( rect
);
669 XFreeGC( xdisplay
, xgc
);
671 // Move Clients, but not the scrollbars
672 // FIXME: There may be a better method to move a lot of Windows within X11
673 wxScrollBar
*sbH
= ((wxWindow
*) this)->GetScrollbar( wxHORIZONTAL
);
674 wxScrollBar
*sbV
= ((wxWindow
*) this)->GetScrollbar( wxVERTICAL
);
675 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
678 // Only propagate to non-top-level windows
679 wxWindow
*win
= node
->GetData();
680 if ( win
->GetParent() && win
!= sbH
&& win
!= sbV
)
682 wxPoint pos
= win
->GetPosition();
683 // Add the delta to the old Position
686 win
->SetPosition(pos
);
688 node
= node
->GetNext();
692 // ---------------------------------------------------------------------------
694 // ---------------------------------------------------------------------------
696 #if wxUSE_DRAG_AND_DROP
698 void wxWindowX11::SetDropTarget(wxDropTarget
* WXUNUSED(pDropTarget
))
705 // Old style file-manager drag&drop
706 void wxWindowX11::DragAcceptFiles(bool WXUNUSED(accept
))
711 // ----------------------------------------------------------------------------
713 // ----------------------------------------------------------------------------
717 void wxWindowX11::DoSetToolTip(wxToolTip
* WXUNUSED(tooltip
))
722 #endif // wxUSE_TOOLTIPS
724 // ---------------------------------------------------------------------------
725 // moving and resizing
726 // ---------------------------------------------------------------------------
728 bool wxWindowX11::PreResize()
734 void wxWindowX11::DoGetSize(int *x
, int *y
) const
736 Window xwindow
= (Window
) m_mainWindow
;
738 wxCHECK_RET( xwindow
, wxT("invalid window") );
740 //XSync(wxGlobalDisplay(), False);
742 XWindowAttributes attr
;
743 Status status
= XGetWindowAttributes( wxGlobalDisplay(), xwindow
, &attr
);
748 *x
= attr
.width
/* + 2*m_borderSize */ ;
749 *y
= attr
.height
/* + 2*m_borderSize */ ;
753 void wxWindowX11::DoGetPosition(int *x
, int *y
) const
755 Window window
= (Window
) m_mainWindow
;
758 //XSync(wxGlobalDisplay(), False);
759 XWindowAttributes attr
;
760 Status status
= XGetWindowAttributes(wxGlobalDisplay(), window
, & attr
);
768 // We may be faking the client origin. So a window that's really at (0, 30)
769 // may appear (to wxWin apps) to be at (0, 0).
772 wxPoint
pt(GetParent()->GetClientAreaOrigin());
780 void wxWindowX11::DoScreenToClient(int *x
, int *y
) const
782 Display
*display
= wxGlobalDisplay();
783 Window rootWindow
= RootWindowOfScreen(DefaultScreenOfDisplay(display
));
784 Window thisWindow
= (Window
) m_clientWindow
;
789 XTranslateCoordinates(display
, rootWindow
, thisWindow
, xx
, yy
, x
, y
, &childWindow
);
792 void wxWindowX11::DoClientToScreen(int *x
, int *y
) const
794 Display
*display
= wxGlobalDisplay();
795 Window rootWindow
= RootWindowOfScreen(DefaultScreenOfDisplay(display
));
796 Window thisWindow
= (Window
) m_clientWindow
;
801 XTranslateCoordinates(display
, thisWindow
, rootWindow
, xx
, yy
, x
, y
, &childWindow
);
805 // Get size *available for subwindows* i.e. excluding menu bar etc.
806 void wxWindowX11::DoGetClientSize(int *x
, int *y
) const
808 Window window
= (Window
) m_mainWindow
;
812 XWindowAttributes attr
;
813 Status status
= XGetWindowAttributes( wxGlobalDisplay(), window
, &attr
);
824 void wxWindowX11::DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
826 // wxLogDebug("DoSetSize: %s (%ld) %d, %d %dx%d", GetClassInfo()->GetClassName(), GetId(), x, y, width, height);
828 Window xwindow
= (Window
) m_mainWindow
;
830 wxCHECK_RET( xwindow
, wxT("invalid window") );
832 XWindowAttributes attr
;
833 Status status
= XGetWindowAttributes( wxGlobalDisplay(), xwindow
, &attr
);
834 wxCHECK_RET( status
, wxT("invalid window attributes") );
838 int new_w
= attr
.width
;
839 int new_h
= attr
.height
;
841 if (x
!= -1 || (sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
844 AdjustForParentClientOrigin( x
, yy
, sizeFlags
);
847 if (y
!= -1 || (sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
850 AdjustForParentClientOrigin( xx
, y
, sizeFlags
);
866 DoMoveWindow( new_x
, new_y
, new_w
, new_h
);
869 void wxWindowX11::DoSetClientSize(int width
, int height
)
871 // wxLogDebug("DoSetClientSize: %s (%ld) %dx%d", GetClassInfo()->GetClassName(), GetId(), width, height);
873 Window xwindow
= (Window
) m_mainWindow
;
875 wxCHECK_RET( xwindow
, wxT("invalid window") );
877 XResizeWindow( wxGlobalDisplay(), xwindow
, width
, height
);
879 if (m_mainWindow
!= m_clientWindow
)
881 xwindow
= (Window
) m_clientWindow
;
883 wxWindow
*window
= (wxWindow
*) this;
884 wxRenderer
*renderer
= window
->GetRenderer();
887 wxRect border
= renderer
->GetBorderDimensions( (wxBorder
)(m_windowStyle
& wxBORDER_MASK
) );
888 width
-= border
.x
+ border
.width
;
889 height
-= border
.y
+ border
.height
;
892 XResizeWindow( wxGlobalDisplay(), xwindow
, width
, height
);
896 void wxWindowX11::DoMoveWindow(int x
, int y
, int width
, int height
)
898 Window xwindow
= (Window
) m_mainWindow
;
900 wxCHECK_RET( xwindow
, wxT("invalid window") );
904 XMoveResizeWindow( wxGlobalDisplay(), xwindow
, x
, y
, width
, height
);
905 if (m_mainWindow
!= m_clientWindow
)
907 xwindow
= (Window
) m_clientWindow
;
909 wxWindow
*window
= (wxWindow
*) this;
910 wxRenderer
*renderer
= window
->GetRenderer();
913 wxRect border
= renderer
->GetBorderDimensions( (wxBorder
)(m_windowStyle
& wxBORDER_MASK
) );
916 width
-= border
.x
+ border
.width
;
917 height
-= border
.y
+ border
.height
;
925 wxScrollBar
*sb
= window
->GetScrollbar( wxHORIZONTAL
);
926 if (sb
&& sb
->IsShown())
928 wxSize size
= sb
->GetSize();
931 sb
= window
->GetScrollbar( wxVERTICAL
);
932 if (sb
&& sb
->IsShown())
934 wxSize size
= sb
->GetSize();
938 XMoveResizeWindow( wxGlobalDisplay(), xwindow
, x
, y
, wxMax(1, width
), wxMax(1, height
) );
943 XWindowChanges windowChanges
;
946 windowChanges
.width
= width
;
947 windowChanges
.height
= height
;
948 windowChanges
.stack_mode
= 0;
949 int valueMask
= CWX
| CWY
| CWWidth
| CWHeight
;
951 XConfigureWindow( wxGlobalDisplay(), xwindow
, valueMask
, &windowChanges
);
956 void wxWindowX11::DoSetSizeHints(int minW
, int minH
, int maxW
, int maxH
, int incW
, int incH
)
964 XSizeHints sizeHints
;
967 if (minW
> -1 && minH
> -1)
969 sizeHints
.flags
|= PMinSize
;
970 sizeHints
.min_width
= minW
;
971 sizeHints
.min_height
= minH
;
973 if (maxW
> -1 && maxH
> -1)
975 sizeHints
.flags
|= PMaxSize
;
976 sizeHints
.max_width
= maxW
;
977 sizeHints
.max_height
= maxH
;
979 if (incW
> -1 && incH
> -1)
981 sizeHints
.flags
|= PResizeInc
;
982 sizeHints
.width_inc
= incW
;
983 sizeHints
.height_inc
= incH
;
986 XSetWMNormalHints(wxGlobalDisplay(), (Window
) m_mainWindow
, &sizeHints
);
990 // ---------------------------------------------------------------------------
992 // ---------------------------------------------------------------------------
994 int wxWindowX11::GetCharHeight() const
996 wxCHECK_MSG( m_font
.Ok(), 0, wxT("valid window font needed") );
999 // There should be an easier way.
1000 PangoLayout
*layout
= pango_layout_new( wxTheApp
->GetPangoContext() );
1001 pango_layout_set_font_description( layout
, GetFont().GetNativeFontInfo()->description
);
1002 pango_layout_set_text(layout
, "H", 1 );
1004 pango_layout_get_pixel_size(layout
, &w
, &h
);
1005 g_object_unref( G_OBJECT( layout
) );
1009 WXFontStructPtr pFontStruct
= m_font
.GetFontStruct(1.0, wxGlobalDisplay());
1011 int direction
, ascent
, descent
;
1012 XCharStruct overall
;
1013 XTextExtents ((XFontStruct
*) pFontStruct
, "x", 1, &direction
, &ascent
,
1014 &descent
, &overall
);
1016 // return (overall.ascent + overall.descent);
1017 return (ascent
+ descent
);
1021 int wxWindowX11::GetCharWidth() const
1023 wxCHECK_MSG( m_font
.Ok(), 0, wxT("valid window font needed") );
1026 // There should be an easier way.
1027 PangoLayout
*layout
= pango_layout_new( wxTheApp
->GetPangoContext() );
1028 pango_layout_set_font_description( layout
, GetFont().GetNativeFontInfo()->description
);
1029 pango_layout_set_text(layout
, "H", 1 );
1031 pango_layout_get_pixel_size(layout
, &w
, &h
);
1032 g_object_unref( G_OBJECT( layout
) );
1036 WXFontStructPtr pFontStruct
= m_font
.GetFontStruct(1.0, wxGlobalDisplay());
1038 int direction
, ascent
, descent
;
1039 XCharStruct overall
;
1040 XTextExtents ((XFontStruct
*) pFontStruct
, "x", 1, &direction
, &ascent
,
1041 &descent
, &overall
);
1043 return overall
.width
;
1047 void wxWindowX11::GetTextExtent(const wxString
& string
,
1049 int *descent
, int *externalLeading
,
1050 const wxFont
*theFont
) const
1052 wxFont fontToUse
= m_font
;
1053 if (theFont
) fontToUse
= *theFont
;
1055 wxCHECK_RET( fontToUse
.Ok(), wxT("invalid font") );
1057 if (string
.IsEmpty())
1065 PangoLayout
*layout
= pango_layout_new( wxTheApp
->GetPangoContext() );
1067 PangoFontDescription
*desc
= fontToUse
.GetNativeFontInfo()->description
;
1068 pango_layout_set_font_description(layout
, desc
);
1070 const wxCharBuffer data
= wxConvUTF8
.cWC2MB( string
);
1071 pango_layout_set_text(layout
, (const char*) data
, strlen( (const char*) data
));
1073 PangoLayoutLine
*line
= (PangoLayoutLine
*)pango_layout_get_lines(layout
)->data
;
1076 PangoRectangle rect
;
1077 pango_layout_line_get_extents(line
, NULL
, &rect
);
1079 if (x
) (*x
) = (wxCoord
) (rect
.width
/ PANGO_SCALE
);
1080 if (y
) (*y
) = (wxCoord
) (rect
.height
/ PANGO_SCALE
);
1083 // Do something about metrics here
1086 if (externalLeading
) (*externalLeading
) = 0; // ??
1088 g_object_unref( G_OBJECT( layout
) );
1090 WXFontStructPtr pFontStruct
= fontToUse
.GetFontStruct(1.0, wxGlobalDisplay());
1092 int direction
, ascent
, descent2
;
1093 XCharStruct overall
;
1094 int slen
= string
.Len();
1096 XTextExtents((XFontStruct
*) pFontStruct
, (char*) string
.c_str(), slen
,
1097 &direction
, &ascent
, &descent2
, &overall
);
1100 *x
= (overall
.width
);
1102 *y
= (ascent
+ descent2
);
1104 *descent
= descent2
;
1105 if (externalLeading
)
1106 *externalLeading
= 0;
1110 // ----------------------------------------------------------------------------
1112 // ----------------------------------------------------------------------------
1114 void wxWindowX11::Refresh(bool eraseBack
, const wxRect
*rect
)
1120 // Schedule for later Updating in ::Update() or ::OnInternalIdle().
1121 m_clearRegion
.Union( rect
->x
, rect
->y
, rect
->width
, rect
->height
);
1126 GetSize( &width
, &height
);
1128 // Schedule for later Updating in ::Update() or ::OnInternalIdle().
1129 m_clearRegion
.Clear();
1130 m_clearRegion
.Union( 0, 0, width
, height
);
1136 // Schedule for later Updating in ::Update() or ::OnInternalIdle().
1137 m_updateRegion
.Union( rect
->x
, rect
->y
, rect
->width
, rect
->height
);
1142 GetSize( &width
, &height
);
1144 // Schedule for later Updating in ::Update() or ::OnInternalIdle().
1145 m_updateRegion
.Clear();
1146 m_updateRegion
.Union( 0, 0, width
, height
);
1150 void wxWindowX11::Update()
1154 // wxLogDebug("wxWindowX11::UpdateNC: %s", GetClassInfo()->GetClassName());
1155 // Send nc paint events.
1156 SendNcPaintEvents();
1159 if (!m_updateRegion
.IsEmpty())
1161 // wxLogDebug("wxWindowX11::Update: %s", GetClassInfo()->GetClassName());
1162 // Actually send erase events.
1165 // Actually send paint events.
1170 void wxWindowX11::SendEraseEvents()
1172 if (m_clearRegion
.IsEmpty()) return;
1174 wxClientDC
dc( (wxWindow
*)this );
1175 dc
.SetClippingRegion( m_clearRegion
);
1177 wxEraseEvent
erase_event( GetId(), &dc
);
1178 erase_event
.SetEventObject( this );
1180 if (!GetEventHandler()->ProcessEvent(erase_event
) )
1182 Display
*xdisplay
= wxGlobalDisplay();
1183 Window xwindow
= (Window
) GetClientAreaWindow();
1184 XSetForeground( xdisplay
, g_eraseGC
, m_backgroundColour
.GetPixel() );
1186 wxRegionIterator
upd( m_clearRegion
);
1189 XFillRectangle( xdisplay
, xwindow
, g_eraseGC
,
1190 upd
.GetX(), upd
.GetY(), upd
.GetWidth(), upd
.GetHeight() );
1195 m_clearRegion
.Clear();
1198 void wxWindowX11::SendPaintEvents()
1200 // wxLogDebug("SendPaintEvents: %s (%ld)", GetClassInfo()->GetClassName(), GetId());
1202 m_clipPaintRegion
= TRUE
;
1204 wxPaintEvent
paint_event( GetId() );
1205 paint_event
.SetEventObject( this );
1206 GetEventHandler()->ProcessEvent( paint_event
);
1208 m_updateRegion
.Clear();
1210 m_clipPaintRegion
= FALSE
;
1213 void wxWindowX11::SendNcPaintEvents()
1215 wxWindow
*window
= (wxWindow
*) this;
1217 // All this for drawing the small square between the scrollbars.
1222 wxScrollBar
*sb
= window
->GetScrollbar( wxHORIZONTAL
);
1223 if (sb
&& sb
->IsShown())
1225 height
= sb
->GetSize().y
;
1226 y
= sb
->GetPosition().y
;
1228 sb
= window
->GetScrollbar( wxVERTICAL
);
1229 if (sb
&& sb
->IsShown())
1231 width
= sb
->GetSize().x
;
1232 x
= sb
->GetPosition().x
;
1234 Display
*xdisplay
= wxGlobalDisplay();
1235 Window xwindow
= (Window
) GetMainWindow();
1236 Colormap cm
= (Colormap
) wxTheApp
->GetMainColormap( wxGetDisplay() );
1237 wxColour colour
= wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
);
1238 colour
.CalcPixel( (WXColormap
) cm
);
1240 XSetForeground( xdisplay
, g_eraseGC
, colour
.GetPixel() );
1242 XFillRectangle( xdisplay
, xwindow
, g_eraseGC
, x
, y
, width
, height
);
1246 wxNcPaintEvent
nc_paint_event( GetId() );
1247 nc_paint_event
.SetEventObject( this );
1248 GetEventHandler()->ProcessEvent( nc_paint_event
);
1250 m_updateNcArea
= FALSE
;
1253 // ----------------------------------------------------------------------------
1255 // ----------------------------------------------------------------------------
1257 // Responds to colour changes: passes event on to children.
1258 void wxWindowX11::OnSysColourChanged(wxSysColourChangedEvent
& event
)
1260 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
1263 // Only propagate to non-top-level windows
1264 wxWindow
*win
= node
->GetData();
1265 if ( win
->GetParent() )
1267 wxSysColourChangedEvent event2
;
1268 event
.SetEventObject(win
);
1269 win
->GetEventHandler()->ProcessEvent(event2
);
1272 node
= node
->GetNext();
1276 // See handler for InFocus case in app.cpp for details.
1277 wxWindow
* g_GettingFocus
= NULL
;
1279 void wxWindowX11::OnInternalIdle()
1281 // Update invalidated regions.
1284 // This calls the UI-update mechanism (querying windows for
1285 // menu/toolbar/control state information)
1286 if (wxUpdateUIEvent::CanUpdate((wxWindow
*) this))
1287 UpdateWindowUI(wxUPDATE_UI_FROMIDLE
);
1289 // Set the input focus if couldn't do it before
1290 if (m_needsInputFocus
)
1294 msg
.Printf("Setting focus for %s from OnInternalIdle\n", GetClassInfo()->GetClassName());
1295 printf(msg
.c_str());
1299 // If it couldn't set the focus now, there's
1300 // no point in trying again.
1301 m_needsInputFocus
= FALSE
;
1303 g_GettingFocus
= NULL
;
1306 // ----------------------------------------------------------------------------
1307 // function which maintain the global hash table mapping Widgets to wxWidgets
1308 // ----------------------------------------------------------------------------
1310 static bool DoAddWindowToTable(wxWindowHash
*hash
, Window w
, wxWindow
*win
)
1312 if ( !hash
->insert(wxWindowHash::value_type(w
, win
)).second
)
1314 wxLogDebug( wxT("Widget table clash: new widget is 0x%08x, %s"),
1315 (unsigned int)w
, win
->GetClassInfo()->GetClassName());
1319 wxLogTrace( wxT("widget"), wxT("XWindow 0x%08x <-> window %p (%s)"),
1320 (unsigned int) w
, win
, win
->GetClassInfo()->GetClassName());
1325 static inline wxWindow
*DoGetWindowFromTable(wxWindowHash
*hash
, Window w
)
1327 wxWindowHash::iterator i
= hash
->find(w
);
1328 return i
== hash
->end() ? NULL
: i
->second
;
1331 static inline void DoDeleteWindowFromTable(wxWindowHash
*hash
, Window w
)
1333 wxLogTrace( wxT("widget"), wxT("XWindow 0x%08x deleted"), (unsigned int) w
);
1338 // ----------------------------------------------------------------------------
1340 // ----------------------------------------------------------------------------
1342 bool wxAddWindowToTable(Window w
, wxWindow
*win
)
1344 return DoAddWindowToTable(wxWidgetHashTable
, w
, win
);
1347 wxWindow
*wxGetWindowFromTable(Window w
)
1349 return DoGetWindowFromTable(wxWidgetHashTable
, w
);
1352 void wxDeleteWindowFromTable(Window w
)
1354 DoDeleteWindowFromTable(wxWidgetHashTable
, w
);
1357 bool wxAddClientWindowToTable(Window w
, wxWindow
*win
)
1359 return DoAddWindowToTable(wxClientWidgetHashTable
, w
, win
);
1362 wxWindow
*wxGetClientWindowFromTable(Window w
)
1364 return DoGetWindowFromTable(wxClientWidgetHashTable
, w
);
1367 void wxDeleteClientWindowFromTable(Window w
)
1369 DoDeleteWindowFromTable(wxClientWidgetHashTable
, w
);
1372 // ----------------------------------------------------------------------------
1373 // X11-specific accessors
1374 // ----------------------------------------------------------------------------
1376 WXWindow
wxWindowX11::GetMainWindow() const
1378 return m_mainWindow
;
1381 WXWindow
wxWindowX11::GetClientAreaWindow() const
1383 return m_clientWindow
;
1386 // ----------------------------------------------------------------------------
1387 // TranslateXXXEvent() functions
1388 // ----------------------------------------------------------------------------
1390 bool wxTranslateMouseEvent(wxMouseEvent
& wxevent
, wxWindow
*win
, Window window
, XEvent
*xevent
)
1392 switch (XEventGetType(xevent
))
1400 wxEventType eventType
= wxEVT_NULL
;
1402 if (XEventGetType(xevent
) == EnterNotify
)
1404 //if (local_event.xcrossing.mode!=NotifyNormal)
1405 // return ; // Ignore grab events
1406 eventType
= wxEVT_ENTER_WINDOW
;
1407 // canvas->GetEventHandler()->OnSetFocus();
1409 else if (XEventGetType(xevent
) == LeaveNotify
)
1411 //if (local_event.xcrossingr.mode!=NotifyNormal)
1412 // return ; // Ignore grab events
1413 eventType
= wxEVT_LEAVE_WINDOW
;
1414 // canvas->GetEventHandler()->OnKillFocus();
1416 else if (XEventGetType(xevent
) == MotionNotify
)
1418 eventType
= wxEVT_MOTION
;
1420 else if (XEventGetType(xevent
) == ButtonPress
)
1422 wxevent
.SetTimestamp(XButtonEventGetTime(xevent
));
1424 if (XButtonEventLChanged(xevent
))
1426 eventType
= wxEVT_LEFT_DOWN
;
1429 else if (XButtonEventMChanged(xevent
))
1431 eventType
= wxEVT_MIDDLE_DOWN
;
1434 else if (XButtonEventRChanged(xevent
))
1436 eventType
= wxEVT_RIGHT_DOWN
;
1440 // check for a double click
1441 // TODO: where can we get this value from?
1442 //long dclickTime = XtGetMultiClickTime(wxGlobalDisplay());
1443 long dclickTime
= 200;
1444 long ts
= wxevent
.GetTimestamp();
1446 int buttonLast
= win
->GetLastClickedButton();
1447 long lastTS
= win
->GetLastClickTime();
1448 if ( buttonLast
&& buttonLast
== button
&& (ts
- lastTS
) < dclickTime
)
1451 win
->SetLastClick(0, ts
);
1452 if ( eventType
== wxEVT_LEFT_DOWN
)
1453 eventType
= wxEVT_LEFT_DCLICK
;
1454 else if ( eventType
== wxEVT_MIDDLE_DOWN
)
1455 eventType
= wxEVT_MIDDLE_DCLICK
;
1456 else if ( eventType
== wxEVT_RIGHT_DOWN
)
1457 eventType
= wxEVT_RIGHT_DCLICK
;
1461 // not fast enough or different button
1462 win
->SetLastClick(button
, ts
);
1465 else if (XEventGetType(xevent
) == ButtonRelease
)
1467 if (XButtonEventLChanged(xevent
))
1469 eventType
= wxEVT_LEFT_UP
;
1471 else if (XButtonEventMChanged(xevent
))
1473 eventType
= wxEVT_MIDDLE_UP
;
1475 else if (XButtonEventRChanged(xevent
))
1477 eventType
= wxEVT_RIGHT_UP
;
1486 wxevent
.SetEventType(eventType
);
1488 wxevent
.m_x
= XButtonEventGetX(xevent
);
1489 wxevent
.m_y
= XButtonEventGetY(xevent
);
1491 wxevent
.m_leftDown
= ((eventType
== wxEVT_LEFT_DOWN
)
1492 || (XButtonEventLIsDown(xevent
)
1493 && (eventType
!= wxEVT_LEFT_UP
)));
1494 wxevent
.m_middleDown
= ((eventType
== wxEVT_MIDDLE_DOWN
)
1495 || (XButtonEventMIsDown(xevent
)
1496 && (eventType
!= wxEVT_MIDDLE_UP
)));
1497 wxevent
.m_rightDown
= ((eventType
== wxEVT_RIGHT_DOWN
)
1498 || (XButtonEventRIsDown (xevent
)
1499 && (eventType
!= wxEVT_RIGHT_UP
)));
1501 wxevent
.m_shiftDown
= XButtonEventShiftIsDown(xevent
);
1502 wxevent
.m_controlDown
= XButtonEventCtrlIsDown(xevent
);
1503 wxevent
.m_altDown
= XButtonEventAltIsDown(xevent
);
1504 wxevent
.m_metaDown
= XButtonEventMetaIsDown(xevent
);
1506 wxevent
.SetId(win
->GetId());
1507 wxevent
.SetEventObject(win
);
1515 bool wxTranslateKeyEvent(wxKeyEvent
& wxevent
, wxWindow
*win
, Window
WXUNUSED(win
), XEvent
*xevent
, bool isAscii
)
1517 switch (XEventGetType(xevent
))
1525 (void) XLookupString ((XKeyEvent
*) xevent
, buf
, 20, &keySym
, NULL
);
1526 int id
= wxCharCodeXToWX (keySym
);
1527 // id may be WXK_xxx code - these are outside ASCII range, so we
1528 // can't just use toupper() on id.
1529 // Only change this if we want the raw key that was pressed,
1530 // and don't change it if we want an ASCII value.
1531 if (!isAscii
&& (id
>= 'a' && id
<= 'z'))
1533 id
= id
+ 'A' - 'a';
1536 wxevent
.m_shiftDown
= XKeyEventShiftIsDown(xevent
);
1537 wxevent
.m_controlDown
= XKeyEventCtrlIsDown(xevent
);
1538 wxevent
.m_altDown
= XKeyEventAltIsDown(xevent
);
1539 wxevent
.m_metaDown
= XKeyEventMetaIsDown(xevent
);
1540 wxevent
.SetEventObject(win
);
1541 wxevent
.m_keyCode
= id
;
1542 wxevent
.SetTimestamp(XKeyEventGetTime(xevent
));
1544 wxevent
.m_x
= XKeyEventGetX(xevent
);
1545 wxevent
.m_y
= XKeyEventGetY(xevent
);
1555 // ----------------------------------------------------------------------------
1557 // ----------------------------------------------------------------------------
1559 bool wxWindowX11::SetBackgroundColour(const wxColour
& col
)
1561 wxWindowBase::SetBackgroundColour(col
);
1563 Display
*xdisplay
= (Display
*) wxGlobalDisplay();
1564 int xscreen
= DefaultScreen( xdisplay
);
1565 Colormap cm
= DefaultColormap( xdisplay
, xscreen
);
1567 m_backgroundColour
.CalcPixel( (WXColormap
) cm
);
1569 // We don't set the background colour as we paint
1570 // the background ourselves.
1571 // XSetWindowBackground( xdisplay, (Window) m_clientWindow, m_backgroundColour.GetPixel() );
1576 bool wxWindowX11::SetForegroundColour(const wxColour
& col
)
1578 if ( !wxWindowBase::SetForegroundColour(col
) )
1584 // ----------------------------------------------------------------------------
1586 // ----------------------------------------------------------------------------
1588 wxWindow
*wxGetActiveWindow()
1591 wxFAIL_MSG(wxT("Not implemented"));
1596 wxWindow
*wxWindowBase::GetCapture()
1598 return (wxWindow
*)g_captureWindow
;
1602 // Find the wxWindow at the current mouse position, returning the mouse
1604 wxWindow
* wxFindWindowAtPointer(wxPoint
& pt
)
1606 return wxFindWindowAtPoint(wxGetMousePosition());
1609 // Get the current mouse position.
1610 wxPoint
wxGetMousePosition()
1614 return wxPoint(0, 0);
1616 Display
*display
= wxGlobalDisplay();
1617 Window rootWindow
= RootWindowOfScreen (DefaultScreenOfDisplay(display
));
1618 Window rootReturn
, childReturn
;
1619 int rootX
, rootY
, winX
, winY
;
1620 unsigned int maskReturn
;
1622 XQueryPointer (display
,
1626 &rootX
, &rootY
, &winX
, &winY
, &maskReturn
);
1627 return wxPoint(rootX
, rootY
);
1632 // ----------------------------------------------------------------------------
1633 // wxNoOptimize: switch off size optimization
1634 // ----------------------------------------------------------------------------
1636 int wxNoOptimize::ms_count
= 0;
1639 // ----------------------------------------------------------------------------
1641 // ----------------------------------------------------------------------------
1643 class wxWinModule
: public wxModule
1650 DECLARE_DYNAMIC_CLASS(wxWinModule
)
1653 IMPLEMENT_DYNAMIC_CLASS(wxWinModule
, wxModule
)
1655 bool wxWinModule::OnInit()
1657 Display
*xdisplay
= wxGlobalDisplay();
1658 int xscreen
= DefaultScreen( xdisplay
);
1659 Window xroot
= RootWindow( xdisplay
, xscreen
);
1660 g_eraseGC
= XCreateGC( xdisplay
, xroot
, 0, NULL
);
1661 XSetFillStyle( xdisplay
, g_eraseGC
, FillSolid
);
1666 void wxWinModule::OnExit()
1668 Display
*xdisplay
= wxGlobalDisplay();
1669 XFreeGC( xdisplay
, g_eraseGC
);