1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/x11/windows.cpp
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.
151 if (pos2
.x
== wxDefaultCoord
)
153 if (pos2
.y
== wxDefaultCoord
)
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::SetLabel(const wxString
& WXUNUSED(label
))
466 wxString
wxWindowX11::GetLabel() const
469 return wxEmptyString
;
472 void wxWindowX11::DoCaptureMouse()
474 if ((g_captureWindow
!= NULL
) && (g_captureWindow
!= this))
476 wxASSERT_MSG(false, wxT("Trying to capture before mouse released."));
487 Window xwindow
= (Window
) m_clientWindow
;
489 wxCHECK_RET( xwindow
, wxT("invalid window") );
491 g_captureWindow
= (wxWindow
*) this;
495 int res
= XGrabPointer(wxGlobalDisplay(), xwindow
,
497 ButtonPressMask
| ButtonReleaseMask
| ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
,
501 None
, /* cursor */ // TODO: This may need to be set to the cursor of this window
504 if (res
!= GrabSuccess
)
507 msg
.Printf(wxT("Failed to grab pointer for window %s"), this->GetClassInfo()->GetClassName());
509 if (res
== GrabNotViewable
)
510 wxLogDebug( wxT("This is not a viewable window - perhaps not shown yet?") );
512 g_captureWindow
= NULL
;
516 m_winCaptured
= true;
520 void wxWindowX11::DoReleaseMouse()
522 g_captureWindow
= NULL
;
524 if ( !m_winCaptured
)
527 Window xwindow
= (Window
) m_clientWindow
;
531 XUngrabPointer( wxGlobalDisplay(), CurrentTime
);
534 // wxLogDebug( "Ungrabbed pointer in %s", GetName().c_str() );
536 m_winCaptured
= false;
539 bool wxWindowX11::SetFont(const wxFont
& font
)
541 if ( !wxWindowBase::SetFont(font
) )
550 bool wxWindowX11::SetCursor(const wxCursor
& cursor
)
552 if ( !wxWindowBase::SetCursor(cursor
) )
558 Window xwindow
= (Window
) m_clientWindow
;
560 wxCHECK_MSG( xwindow
, false, wxT("invalid window") );
562 wxCursor cursorToUse
;
564 cursorToUse
= m_cursor
;
566 cursorToUse
= *wxSTANDARD_CURSOR
;
568 Cursor xcursor
= (Cursor
) cursorToUse
.GetCursor();
570 XDefineCursor( wxGlobalDisplay(), xwindow
, xcursor
);
575 // Coordinates relative to the window
576 void wxWindowX11::WarpPointer (int x
, int y
)
578 Window xwindow
= (Window
) m_clientWindow
;
580 wxCHECK_RET( xwindow
, wxT("invalid window") );
582 XWarpPointer( wxGlobalDisplay(), None
, xwindow
, 0, 0, 0, 0, x
, y
);
585 // Does a physical scroll
586 void wxWindowX11::ScrollWindow(int dx
, int dy
, const wxRect
*rect
)
588 // No scrolling requested.
589 if ((dx
== 0) && (dy
== 0)) return;
591 if (!m_updateRegion
.IsEmpty())
593 m_updateRegion
.Offset( dx
, dy
);
597 GetSize( &cw
, &ch
); // GetClientSize() ??
598 m_updateRegion
.Intersect( 0, 0, cw
, ch
);
601 if (!m_clearRegion
.IsEmpty())
603 m_clearRegion
.Offset( dx
, dy
);
607 GetSize( &cw
, &ch
); // GetClientSize() ??
608 m_clearRegion
.Intersect( 0, 0, cw
, ch
);
611 Window xwindow
= (Window
) GetClientAreaWindow();
613 wxCHECK_RET( xwindow
, wxT("invalid window") );
615 Display
*xdisplay
= wxGlobalDisplay();
617 GC xgc
= XCreateGC( xdisplay
, xwindow
, 0, NULL
);
618 XSetGraphicsExposures( xdisplay
, xgc
, True
);
636 GetClientSize( &cw
, &ch
);
639 #if wxUSE_TWO_WINDOWS
640 wxPoint
offset( 0,0 );
642 wxPoint offset
= GetClientAreaOrigin();
647 int w
= cw
- abs(dx
);
648 int h
= ch
- abs(dy
);
650 if ((h
< 0) || (w
< 0))
657 if (dx
< 0) rect
.x
= cw
+dx
+ offset
.x
; else rect
.x
= s_x
;
658 if (dy
< 0) rect
.y
= ch
+dy
+ offset
.y
; else rect
.y
= s_y
;
659 if (dy
!= 0) rect
.width
= cw
; else rect
.width
= abs(dx
);
660 if (dx
!= 0) rect
.height
= ch
; else rect
.height
= abs(dy
);
665 if (dx
< 0) s_x
+= -dx
;
666 if (dy
< 0) s_y
+= -dy
;
667 if (dx
> 0) d_x
= dx
+ offset
.x
;
668 if (dy
> 0) d_y
= dy
+ offset
.y
;
670 XCopyArea( xdisplay
, xwindow
, xwindow
, xgc
, s_x
, s_y
, w
, h
, d_x
, d_y
);
672 // 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 );
674 // wxLogDebug( "Update: %d %d %d %d", rect.x, rect.y, rect.width, rect.height );
676 m_updateRegion
.Union( rect
);
677 m_clearRegion
.Union( rect
);
680 XFreeGC( xdisplay
, xgc
);
682 // Move Clients, but not the scrollbars
683 // FIXME: There may be a better method to move a lot of Windows within X11
684 wxScrollBar
*sbH
= ((wxWindow
*) this)->GetScrollbar( wxHORIZONTAL
);
685 wxScrollBar
*sbV
= ((wxWindow
*) this)->GetScrollbar( wxVERTICAL
);
686 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
689 // Only propagate to non-top-level windows
690 wxWindow
*win
= node
->GetData();
691 if ( win
->GetParent() && win
!= sbH
&& win
!= sbV
)
693 wxPoint pos
= win
->GetPosition();
694 // Add the delta to the old Position
697 win
->SetPosition(pos
);
699 node
= node
->GetNext();
703 // ---------------------------------------------------------------------------
705 // ---------------------------------------------------------------------------
707 #if wxUSE_DRAG_AND_DROP
709 void wxWindowX11::SetDropTarget(wxDropTarget
* WXUNUSED(pDropTarget
))
716 // Old style file-manager drag&drop
717 void wxWindowX11::DragAcceptFiles(bool WXUNUSED(accept
))
722 // ----------------------------------------------------------------------------
724 // ----------------------------------------------------------------------------
728 void wxWindowX11::DoSetToolTip(wxToolTip
* WXUNUSED(tooltip
))
733 #endif // wxUSE_TOOLTIPS
735 // ---------------------------------------------------------------------------
736 // moving and resizing
737 // ---------------------------------------------------------------------------
739 bool wxWindowX11::PreResize()
745 void wxWindowX11::DoGetSize(int *x
, int *y
) const
747 Window xwindow
= (Window
) m_mainWindow
;
749 wxCHECK_RET( xwindow
, wxT("invalid window") );
751 //XSync(wxGlobalDisplay(), False);
753 XWindowAttributes attr
;
754 Status status
= XGetWindowAttributes( wxGlobalDisplay(), xwindow
, &attr
);
759 *x
= attr
.width
/* + 2*m_borderSize */ ;
760 *y
= attr
.height
/* + 2*m_borderSize */ ;
764 void wxWindowX11::DoGetPosition(int *x
, int *y
) const
766 Window window
= (Window
) m_mainWindow
;
769 //XSync(wxGlobalDisplay(), False);
770 XWindowAttributes attr
;
771 Status status
= XGetWindowAttributes(wxGlobalDisplay(), window
, & attr
);
779 // We may be faking the client origin. So a window that's really at (0, 30)
780 // may appear (to wxWin apps) to be at (0, 0).
783 wxPoint
pt(GetParent()->GetClientAreaOrigin());
791 void wxWindowX11::DoScreenToClient(int *x
, int *y
) const
793 Display
*display
= wxGlobalDisplay();
794 Window rootWindow
= RootWindowOfScreen(DefaultScreenOfDisplay(display
));
795 Window thisWindow
= (Window
) m_clientWindow
;
800 XTranslateCoordinates(display
, rootWindow
, thisWindow
, xx
, yy
, x
, y
, &childWindow
);
803 void wxWindowX11::DoClientToScreen(int *x
, int *y
) const
805 Display
*display
= wxGlobalDisplay();
806 Window rootWindow
= RootWindowOfScreen(DefaultScreenOfDisplay(display
));
807 Window thisWindow
= (Window
) m_clientWindow
;
812 XTranslateCoordinates(display
, thisWindow
, rootWindow
, xx
, yy
, x
, y
, &childWindow
);
816 // Get size *available for subwindows* i.e. excluding menu bar etc.
817 void wxWindowX11::DoGetClientSize(int *x
, int *y
) const
819 Window window
= (Window
) m_mainWindow
;
823 XWindowAttributes attr
;
824 Status status
= XGetWindowAttributes( wxGlobalDisplay(), window
, &attr
);
835 void wxWindowX11::DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
837 // wxLogDebug("DoSetSize: %s (%ld) %d, %d %dx%d", GetClassInfo()->GetClassName(), GetId(), x, y, width, height);
839 Window xwindow
= (Window
) m_mainWindow
;
841 wxCHECK_RET( xwindow
, wxT("invalid window") );
843 XWindowAttributes attr
;
844 Status status
= XGetWindowAttributes( wxGlobalDisplay(), xwindow
, &attr
);
845 wxCHECK_RET( status
, wxT("invalid window attributes") );
849 int new_w
= attr
.width
;
850 int new_h
= attr
.height
;
852 if (x
!= wxDefaultCoord
|| (sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
855 AdjustForParentClientOrigin( x
, yy
, sizeFlags
);
858 if (y
!= wxDefaultCoord
|| (sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
861 AdjustForParentClientOrigin( xx
, y
, sizeFlags
);
864 if (width
!= wxDefaultCoord
)
870 if (height
!= wxDefaultCoord
)
877 DoMoveWindow( new_x
, new_y
, new_w
, new_h
);
880 void wxWindowX11::DoSetClientSize(int width
, int height
)
882 // wxLogDebug("DoSetClientSize: %s (%ld) %dx%d", GetClassInfo()->GetClassName(), GetId(), width, height);
884 Window xwindow
= (Window
) m_mainWindow
;
886 wxCHECK_RET( xwindow
, wxT("invalid window") );
888 XResizeWindow( wxGlobalDisplay(), xwindow
, width
, height
);
890 if (m_mainWindow
!= m_clientWindow
)
892 xwindow
= (Window
) m_clientWindow
;
894 wxWindow
*window
= (wxWindow
*) this;
895 wxRenderer
*renderer
= window
->GetRenderer();
898 wxRect border
= renderer
->GetBorderDimensions( (wxBorder
)(m_windowStyle
& wxBORDER_MASK
) );
899 width
-= border
.x
+ border
.width
;
900 height
-= border
.y
+ border
.height
;
903 XResizeWindow( wxGlobalDisplay(), xwindow
, width
, height
);
907 void wxWindowX11::DoMoveWindow(int x
, int y
, int width
, int height
)
909 Window xwindow
= (Window
) m_mainWindow
;
911 wxCHECK_RET( xwindow
, wxT("invalid window") );
915 XMoveResizeWindow( wxGlobalDisplay(), xwindow
, x
, y
, width
, height
);
916 if (m_mainWindow
!= m_clientWindow
)
918 xwindow
= (Window
) m_clientWindow
;
920 wxWindow
*window
= (wxWindow
*) this;
921 wxRenderer
*renderer
= window
->GetRenderer();
924 wxRect border
= renderer
->GetBorderDimensions( (wxBorder
)(m_windowStyle
& wxBORDER_MASK
) );
927 width
-= border
.x
+ border
.width
;
928 height
-= border
.y
+ border
.height
;
936 wxScrollBar
*sb
= window
->GetScrollbar( wxHORIZONTAL
);
937 if (sb
&& sb
->IsShown())
939 wxSize size
= sb
->GetSize();
942 sb
= window
->GetScrollbar( wxVERTICAL
);
943 if (sb
&& sb
->IsShown())
945 wxSize size
= sb
->GetSize();
949 XMoveResizeWindow( wxGlobalDisplay(), xwindow
, x
, y
, wxMax(1, width
), wxMax(1, height
) );
954 XWindowChanges windowChanges
;
957 windowChanges
.width
= width
;
958 windowChanges
.height
= height
;
959 windowChanges
.stack_mode
= 0;
960 int valueMask
= CWX
| CWY
| CWWidth
| CWHeight
;
962 XConfigureWindow( wxGlobalDisplay(), xwindow
, valueMask
, &windowChanges
);
967 void wxWindowX11::DoSetSizeHints(int minW
, int minH
, int maxW
, int maxH
, int incW
, int incH
)
975 XSizeHints sizeHints
;
978 if (minW
> -1 && minH
> -1)
980 sizeHints
.flags
|= PMinSize
;
981 sizeHints
.min_width
= minW
;
982 sizeHints
.min_height
= minH
;
984 if (maxW
> -1 && maxH
> -1)
986 sizeHints
.flags
|= PMaxSize
;
987 sizeHints
.max_width
= maxW
;
988 sizeHints
.max_height
= maxH
;
990 if (incW
> -1 && incH
> -1)
992 sizeHints
.flags
|= PResizeInc
;
993 sizeHints
.width_inc
= incW
;
994 sizeHints
.height_inc
= incH
;
997 XSetWMNormalHints(wxGlobalDisplay(), (Window
) m_mainWindow
, &sizeHints
);
1001 // ---------------------------------------------------------------------------
1003 // ---------------------------------------------------------------------------
1005 int wxWindowX11::GetCharHeight() const
1007 wxFont
font(GetFont());
1008 wxCHECK_MSG( font
.Ok(), 0, wxT("valid window font needed") );
1011 // There should be an easier way.
1012 PangoLayout
*layout
= pango_layout_new( wxTheApp
->GetPangoContext() );
1013 pango_layout_set_font_description( layout
, font
.GetNativeFontInfo()->description
);
1014 pango_layout_set_text(layout
, "H", 1 );
1016 pango_layout_get_pixel_size(layout
, &w
, &h
);
1017 g_object_unref( G_OBJECT( layout
) );
1021 WXFontStructPtr pFontStruct
= font
.GetFontStruct(1.0, wxGlobalDisplay());
1023 int direction
, ascent
, descent
;
1024 XCharStruct overall
;
1025 XTextExtents ((XFontStruct
*) pFontStruct
, "x", 1, &direction
, &ascent
,
1026 &descent
, &overall
);
1028 // return (overall.ascent + overall.descent);
1029 return (ascent
+ descent
);
1033 int wxWindowX11::GetCharWidth() const
1035 wxFont
font(GetFont());
1036 wxCHECK_MSG( font
.Ok(), 0, wxT("valid window font needed") );
1039 // There should be an easier way.
1040 PangoLayout
*layout
= pango_layout_new( wxTheApp
->GetPangoContext() );
1041 pango_layout_set_font_description( layout
, font
.GetNativeFontInfo()->description
);
1042 pango_layout_set_text(layout
, "H", 1 );
1044 pango_layout_get_pixel_size(layout
, &w
, &h
);
1045 g_object_unref( G_OBJECT( layout
) );
1049 WXFontStructPtr pFontStruct
= font
.GetFontStruct(1.0, wxGlobalDisplay());
1051 int direction
, ascent
, descent
;
1052 XCharStruct overall
;
1053 XTextExtents ((XFontStruct
*) pFontStruct
, "x", 1, &direction
, &ascent
,
1054 &descent
, &overall
);
1056 return overall
.width
;
1060 void wxWindowX11::GetTextExtent(const wxString
& string
,
1062 int *descent
, int *externalLeading
,
1063 const wxFont
*theFont
) const
1065 wxFont fontToUse
= GetFont();
1066 if (theFont
) fontToUse
= *theFont
;
1068 wxCHECK_RET( fontToUse
.Ok(), wxT("invalid font") );
1078 PangoLayout
*layout
= pango_layout_new( wxTheApp
->GetPangoContext() );
1080 PangoFontDescription
*desc
= fontToUse
.GetNativeFontInfo()->description
;
1081 pango_layout_set_font_description(layout
, desc
);
1083 const wxCharBuffer data
= wxConvUTF8
.cWC2MB( string
);
1084 pango_layout_set_text(layout
, (const char*) data
, strlen( (const char*) data
));
1086 PangoLayoutLine
*line
= (PangoLayoutLine
*)pango_layout_get_lines(layout
)->data
;
1089 PangoRectangle rect
;
1090 pango_layout_line_get_extents(line
, NULL
, &rect
);
1092 if (x
) (*x
) = (wxCoord
) (rect
.width
/ PANGO_SCALE
);
1093 if (y
) (*y
) = (wxCoord
) (rect
.height
/ PANGO_SCALE
);
1096 // Do something about metrics here
1099 if (externalLeading
) (*externalLeading
) = 0; // ??
1101 g_object_unref( G_OBJECT( layout
) );
1103 WXFontStructPtr pFontStruct
= fontToUse
.GetFontStruct(1.0, wxGlobalDisplay());
1105 int direction
, ascent
, descent2
;
1106 XCharStruct overall
;
1107 int slen
= string
.Len();
1109 XTextExtents((XFontStruct
*) pFontStruct
, (char*) string
.c_str(), slen
,
1110 &direction
, &ascent
, &descent2
, &overall
);
1113 *x
= (overall
.width
);
1115 *y
= (ascent
+ descent2
);
1117 *descent
= descent2
;
1118 if (externalLeading
)
1119 *externalLeading
= 0;
1123 // ----------------------------------------------------------------------------
1125 // ----------------------------------------------------------------------------
1127 void wxWindowX11::Refresh(bool eraseBack
, const wxRect
*rect
)
1133 // Schedule for later Updating in ::Update() or ::OnInternalIdle().
1134 m_clearRegion
.Union( rect
->x
, rect
->y
, rect
->width
, rect
->height
);
1139 GetSize( &width
, &height
);
1141 // Schedule for later Updating in ::Update() or ::OnInternalIdle().
1142 m_clearRegion
.Clear();
1143 m_clearRegion
.Union( 0, 0, width
, height
);
1149 // Schedule for later Updating in ::Update() or ::OnInternalIdle().
1150 m_updateRegion
.Union( rect
->x
, rect
->y
, rect
->width
, rect
->height
);
1155 GetSize( &width
, &height
);
1157 // Schedule for later Updating in ::Update() or ::OnInternalIdle().
1158 m_updateRegion
.Clear();
1159 m_updateRegion
.Union( 0, 0, width
, height
);
1163 void wxWindowX11::Update()
1167 // wxLogDebug("wxWindowX11::UpdateNC: %s", GetClassInfo()->GetClassName());
1168 // Send nc paint events.
1169 SendNcPaintEvents();
1172 if (!m_updateRegion
.IsEmpty())
1174 // wxLogDebug("wxWindowX11::Update: %s", GetClassInfo()->GetClassName());
1175 // Actually send erase events.
1178 // Actually send paint events.
1183 void wxWindowX11::SendEraseEvents()
1185 if (m_clearRegion
.IsEmpty()) return;
1187 wxClientDC
dc( (wxWindow
*)this );
1188 dc
.SetClippingRegion( m_clearRegion
);
1190 wxEraseEvent
erase_event( GetId(), &dc
);
1191 erase_event
.SetEventObject( this );
1193 if (!GetEventHandler()->ProcessEvent(erase_event
) )
1195 Display
*xdisplay
= wxGlobalDisplay();
1196 Window xwindow
= (Window
) GetClientAreaWindow();
1197 XSetForeground( xdisplay
, g_eraseGC
, m_backgroundColour
.GetPixel() );
1199 wxRegionIterator
upd( m_clearRegion
);
1202 XFillRectangle( xdisplay
, xwindow
, g_eraseGC
,
1203 upd
.GetX(), upd
.GetY(), upd
.GetWidth(), upd
.GetHeight() );
1208 m_clearRegion
.Clear();
1211 void wxWindowX11::SendPaintEvents()
1213 // wxLogDebug("SendPaintEvents: %s (%ld)", GetClassInfo()->GetClassName(), GetId());
1215 m_clipPaintRegion
= true;
1217 wxPaintEvent
paint_event( GetId() );
1218 paint_event
.SetEventObject( this );
1219 GetEventHandler()->ProcessEvent( paint_event
);
1221 m_updateRegion
.Clear();
1223 m_clipPaintRegion
= false;
1226 void wxWindowX11::SendNcPaintEvents()
1228 wxWindow
*window
= (wxWindow
*) this;
1230 // All this for drawing the small square between the scrollbars.
1235 wxScrollBar
*sb
= window
->GetScrollbar( wxHORIZONTAL
);
1236 if (sb
&& sb
->IsShown())
1238 height
= sb
->GetSize().y
;
1239 y
= sb
->GetPosition().y
;
1241 sb
= window
->GetScrollbar( wxVERTICAL
);
1242 if (sb
&& sb
->IsShown())
1244 width
= sb
->GetSize().x
;
1245 x
= sb
->GetPosition().x
;
1247 Display
*xdisplay
= wxGlobalDisplay();
1248 Window xwindow
= (Window
) GetMainWindow();
1249 Colormap cm
= (Colormap
) wxTheApp
->GetMainColormap( wxGetDisplay() );
1250 wxColour colour
= wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
);
1251 colour
.CalcPixel( (WXColormap
) cm
);
1253 XSetForeground( xdisplay
, g_eraseGC
, colour
.GetPixel() );
1255 XFillRectangle( xdisplay
, xwindow
, g_eraseGC
, x
, y
, width
, height
);
1259 wxNcPaintEvent
nc_paint_event( GetId() );
1260 nc_paint_event
.SetEventObject( this );
1261 GetEventHandler()->ProcessEvent( nc_paint_event
);
1263 m_updateNcArea
= false;
1266 // ----------------------------------------------------------------------------
1268 // ----------------------------------------------------------------------------
1270 // Responds to colour changes: passes event on to children.
1271 void wxWindowX11::OnSysColourChanged(wxSysColourChangedEvent
& event
)
1273 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
1276 // Only propagate to non-top-level windows
1277 wxWindow
*win
= node
->GetData();
1278 if ( win
->GetParent() )
1280 wxSysColourChangedEvent event2
;
1281 event
.SetEventObject(win
);
1282 win
->GetEventHandler()->ProcessEvent(event2
);
1285 node
= node
->GetNext();
1289 // See handler for InFocus case in app.cpp for details.
1290 wxWindow
* g_GettingFocus
= NULL
;
1292 void wxWindowX11::OnInternalIdle()
1294 // Update invalidated regions.
1297 // This calls the UI-update mechanism (querying windows for
1298 // menu/toolbar/control state information)
1299 if (wxUpdateUIEvent::CanUpdate((wxWindow
*) this))
1300 UpdateWindowUI(wxUPDATE_UI_FROMIDLE
);
1302 // Set the input focus if couldn't do it before
1303 if (m_needsInputFocus
)
1307 msg
.Printf("Setting focus for %s from OnInternalIdle\n", GetClassInfo()->GetClassName());
1308 printf(msg
.c_str());
1312 // If it couldn't set the focus now, there's
1313 // no point in trying again.
1314 m_needsInputFocus
= false;
1316 g_GettingFocus
= NULL
;
1319 // ----------------------------------------------------------------------------
1320 // function which maintain the global hash table mapping Widgets to wxWidgets
1321 // ----------------------------------------------------------------------------
1323 static bool DoAddWindowToTable(wxWindowHash
*hash
, Window w
, wxWindow
*win
)
1325 if ( !hash
->insert(wxWindowHash::value_type(w
, win
)).second
)
1327 wxLogDebug( wxT("Widget table clash: new widget is 0x%08x, %s"),
1328 (unsigned int)w
, win
->GetClassInfo()->GetClassName());
1332 wxLogTrace( wxT("widget"), wxT("XWindow 0x%08x <-> window %p (%s)"),
1333 (unsigned int) w
, win
, win
->GetClassInfo()->GetClassName());
1338 static inline wxWindow
*DoGetWindowFromTable(wxWindowHash
*hash
, Window w
)
1340 wxWindowHash::iterator i
= hash
->find(w
);
1341 return i
== hash
->end() ? NULL
: i
->second
;
1344 static inline void DoDeleteWindowFromTable(wxWindowHash
*hash
, Window w
)
1346 wxLogTrace( wxT("widget"), wxT("XWindow 0x%08x deleted"), (unsigned int) w
);
1351 // ----------------------------------------------------------------------------
1353 // ----------------------------------------------------------------------------
1355 bool wxAddWindowToTable(Window w
, wxWindow
*win
)
1357 return DoAddWindowToTable(wxWidgetHashTable
, w
, win
);
1360 wxWindow
*wxGetWindowFromTable(Window w
)
1362 return DoGetWindowFromTable(wxWidgetHashTable
, w
);
1365 void wxDeleteWindowFromTable(Window w
)
1367 DoDeleteWindowFromTable(wxWidgetHashTable
, w
);
1370 bool wxAddClientWindowToTable(Window w
, wxWindow
*win
)
1372 return DoAddWindowToTable(wxClientWidgetHashTable
, w
, win
);
1375 wxWindow
*wxGetClientWindowFromTable(Window w
)
1377 return DoGetWindowFromTable(wxClientWidgetHashTable
, w
);
1380 void wxDeleteClientWindowFromTable(Window w
)
1382 DoDeleteWindowFromTable(wxClientWidgetHashTable
, w
);
1385 // ----------------------------------------------------------------------------
1386 // X11-specific accessors
1387 // ----------------------------------------------------------------------------
1389 WXWindow
wxWindowX11::GetMainWindow() const
1391 return m_mainWindow
;
1394 WXWindow
wxWindowX11::GetClientAreaWindow() const
1396 return m_clientWindow
;
1399 // ----------------------------------------------------------------------------
1400 // TranslateXXXEvent() functions
1401 // ----------------------------------------------------------------------------
1403 bool wxTranslateMouseEvent(wxMouseEvent
& wxevent
, wxWindow
*win
, Window window
, XEvent
*xevent
)
1405 switch (XEventGetType(xevent
))
1413 wxEventType eventType
= wxEVT_NULL
;
1415 if (XEventGetType(xevent
) == EnterNotify
)
1417 //if (local_event.xcrossing.mode!=NotifyNormal)
1418 // return ; // Ignore grab events
1419 eventType
= wxEVT_ENTER_WINDOW
;
1420 // canvas->GetEventHandler()->OnSetFocus();
1422 else if (XEventGetType(xevent
) == LeaveNotify
)
1424 //if (local_event.xcrossingr.mode!=NotifyNormal)
1425 // return ; // Ignore grab events
1426 eventType
= wxEVT_LEAVE_WINDOW
;
1427 // canvas->GetEventHandler()->OnKillFocus();
1429 else if (XEventGetType(xevent
) == MotionNotify
)
1431 eventType
= wxEVT_MOTION
;
1433 else if (XEventGetType(xevent
) == ButtonPress
)
1435 wxevent
.SetTimestamp(XButtonEventGetTime(xevent
));
1437 if (XButtonEventLChanged(xevent
))
1439 eventType
= wxEVT_LEFT_DOWN
;
1442 else if (XButtonEventMChanged(xevent
))
1444 eventType
= wxEVT_MIDDLE_DOWN
;
1447 else if (XButtonEventRChanged(xevent
))
1449 eventType
= wxEVT_RIGHT_DOWN
;
1453 // check for a double click
1454 // TODO: where can we get this value from?
1455 //long dclickTime = XtGetMultiClickTime(wxGlobalDisplay());
1456 long dclickTime
= 200;
1457 long ts
= wxevent
.GetTimestamp();
1459 int buttonLast
= win
->GetLastClickedButton();
1460 long lastTS
= win
->GetLastClickTime();
1461 if ( buttonLast
&& buttonLast
== button
&& (ts
- lastTS
) < dclickTime
)
1464 win
->SetLastClick(0, ts
);
1465 if ( eventType
== wxEVT_LEFT_DOWN
)
1466 eventType
= wxEVT_LEFT_DCLICK
;
1467 else if ( eventType
== wxEVT_MIDDLE_DOWN
)
1468 eventType
= wxEVT_MIDDLE_DCLICK
;
1469 else if ( eventType
== wxEVT_RIGHT_DOWN
)
1470 eventType
= wxEVT_RIGHT_DCLICK
;
1474 // not fast enough or different button
1475 win
->SetLastClick(button
, ts
);
1478 else if (XEventGetType(xevent
) == ButtonRelease
)
1480 if (XButtonEventLChanged(xevent
))
1482 eventType
= wxEVT_LEFT_UP
;
1484 else if (XButtonEventMChanged(xevent
))
1486 eventType
= wxEVT_MIDDLE_UP
;
1488 else if (XButtonEventRChanged(xevent
))
1490 eventType
= wxEVT_RIGHT_UP
;
1499 wxevent
.SetEventType(eventType
);
1501 wxevent
.m_x
= XButtonEventGetX(xevent
);
1502 wxevent
.m_y
= XButtonEventGetY(xevent
);
1504 wxevent
.m_leftDown
= ((eventType
== wxEVT_LEFT_DOWN
)
1505 || (XButtonEventLIsDown(xevent
)
1506 && (eventType
!= wxEVT_LEFT_UP
)));
1507 wxevent
.m_middleDown
= ((eventType
== wxEVT_MIDDLE_DOWN
)
1508 || (XButtonEventMIsDown(xevent
)
1509 && (eventType
!= wxEVT_MIDDLE_UP
)));
1510 wxevent
.m_rightDown
= ((eventType
== wxEVT_RIGHT_DOWN
)
1511 || (XButtonEventRIsDown (xevent
)
1512 && (eventType
!= wxEVT_RIGHT_UP
)));
1514 wxevent
.m_shiftDown
= XButtonEventShiftIsDown(xevent
);
1515 wxevent
.m_controlDown
= XButtonEventCtrlIsDown(xevent
);
1516 wxevent
.m_altDown
= XButtonEventAltIsDown(xevent
);
1517 wxevent
.m_metaDown
= XButtonEventMetaIsDown(xevent
);
1519 wxevent
.SetId(win
->GetId());
1520 wxevent
.SetEventObject(win
);
1528 bool wxTranslateKeyEvent(wxKeyEvent
& wxevent
, wxWindow
*win
, Window
WXUNUSED(win
), XEvent
*xevent
, bool isAscii
)
1530 switch (XEventGetType(xevent
))
1538 (void) XLookupString ((XKeyEvent
*) xevent
, buf
, 20, &keySym
, NULL
);
1539 int id
= wxCharCodeXToWX (keySym
);
1540 // id may be WXK_xxx code - these are outside ASCII range, so we
1541 // can't just use toupper() on id.
1542 // Only change this if we want the raw key that was pressed,
1543 // and don't change it if we want an ASCII value.
1544 if (!isAscii
&& (id
>= 'a' && id
<= 'z'))
1546 id
= id
+ 'A' - 'a';
1549 wxevent
.m_shiftDown
= XKeyEventShiftIsDown(xevent
);
1550 wxevent
.m_controlDown
= XKeyEventCtrlIsDown(xevent
);
1551 wxevent
.m_altDown
= XKeyEventAltIsDown(xevent
);
1552 wxevent
.m_metaDown
= XKeyEventMetaIsDown(xevent
);
1553 wxevent
.SetEventObject(win
);
1554 wxevent
.m_keyCode
= id
;
1555 wxevent
.SetTimestamp(XKeyEventGetTime(xevent
));
1557 wxevent
.m_x
= XKeyEventGetX(xevent
);
1558 wxevent
.m_y
= XKeyEventGetY(xevent
);
1568 // ----------------------------------------------------------------------------
1570 // ----------------------------------------------------------------------------
1572 bool wxWindowX11::SetBackgroundColour(const wxColour
& col
)
1574 wxWindowBase::SetBackgroundColour(col
);
1576 Display
*xdisplay
= (Display
*) wxGlobalDisplay();
1577 int xscreen
= DefaultScreen( xdisplay
);
1578 Colormap cm
= DefaultColormap( xdisplay
, xscreen
);
1580 m_backgroundColour
.CalcPixel( (WXColormap
) cm
);
1582 // We don't set the background colour as we paint
1583 // the background ourselves.
1584 // XSetWindowBackground( xdisplay, (Window) m_clientWindow, m_backgroundColour.GetPixel() );
1589 bool wxWindowX11::SetForegroundColour(const wxColour
& col
)
1591 if ( !wxWindowBase::SetForegroundColour(col
) )
1597 // ----------------------------------------------------------------------------
1599 // ----------------------------------------------------------------------------
1601 wxWindow
*wxGetActiveWindow()
1604 wxFAIL_MSG(wxT("Not implemented"));
1609 wxWindow
*wxWindowBase::GetCapture()
1611 return (wxWindow
*)g_captureWindow
;
1615 // Find the wxWindow at the current mouse position, returning the mouse
1617 wxWindow
* wxFindWindowAtPointer(wxPoint
& pt
)
1619 return wxFindWindowAtPoint(wxGetMousePosition());
1622 // Get the current mouse position.
1623 wxPoint
wxGetMousePosition()
1627 return wxPoint(0, 0);
1629 Display
*display
= wxGlobalDisplay();
1630 Window rootWindow
= RootWindowOfScreen (DefaultScreenOfDisplay(display
));
1631 Window rootReturn
, childReturn
;
1632 int rootX
, rootY
, winX
, winY
;
1633 unsigned int maskReturn
;
1635 XQueryPointer (display
,
1639 &rootX
, &rootY
, &winX
, &winY
, &maskReturn
);
1640 return wxPoint(rootX
, rootY
);
1645 // ----------------------------------------------------------------------------
1646 // wxNoOptimize: switch off size optimization
1647 // ----------------------------------------------------------------------------
1649 int wxNoOptimize::ms_count
= 0;
1652 // ----------------------------------------------------------------------------
1654 // ----------------------------------------------------------------------------
1656 class wxWinModule
: public wxModule
1663 DECLARE_DYNAMIC_CLASS(wxWinModule
)
1666 IMPLEMENT_DYNAMIC_CLASS(wxWinModule
, wxModule
)
1668 bool wxWinModule::OnInit()
1670 Display
*xdisplay
= wxGlobalDisplay();
1671 int xscreen
= DefaultScreen( xdisplay
);
1672 Window xroot
= RootWindow( xdisplay
, xscreen
);
1673 g_eraseGC
= XCreateGC( xdisplay
, xroot
, 0, NULL
);
1674 XSetFillStyle( xdisplay
, g_eraseGC
, FillSolid
);
1679 void wxWinModule::OnExit()
1681 Display
*xdisplay
= wxGlobalDisplay();
1682 XFreeGC( xdisplay
, g_eraseGC
);