1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/x11/window.cpp
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // for compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
15 #if defined(__BORLANDC__)
19 // ============================================================================
21 // ============================================================================
23 // ----------------------------------------------------------------------------
25 // ----------------------------------------------------------------------------
27 #include "wx/window.h"
37 #include "wx/dcclient.h"
38 #include "wx/button.h"
40 #include "wx/dialog.h"
42 #include "wx/settings.h"
43 #include "wx/msgdlg.h"
46 #include "wx/layout.h"
47 #include "wx/listbox.h"
48 #include "wx/scrolwin.h"
49 #include "wx/scrolbar.h"
50 #include "wx/module.h"
51 #include "wx/menuitem.h"
52 #include "wx/fontutil.h"
53 #include "wx/univ/renderer.h"
55 #if wxUSE_DRAG_AND_DROP
59 #include "wx/x11/private.h"
60 #include "X11/Xutil.h"
64 // ----------------------------------------------------------------------------
65 // global variables for this module
66 // ----------------------------------------------------------------------------
68 static wxWindow
* g_captureWindow
= NULL
;
71 // ----------------------------------------------------------------------------
73 // ----------------------------------------------------------------------------
75 #define event_left_is_down(x) ((x)->xbutton.state & Button1Mask)
76 #define event_middle_is_down(x) ((x)->xbutton.state & Button2Mask)
77 #define event_right_is_down(x) ((x)->xbutton.state & Button3Mask)
79 // ----------------------------------------------------------------------------
81 // ----------------------------------------------------------------------------
83 IMPLEMENT_ABSTRACT_CLASS(wxWindowX11
, wxWindowBase
)
85 BEGIN_EVENT_TABLE(wxWindowX11
, wxWindowBase
)
86 EVT_SYS_COLOUR_CHANGED(wxWindowX11::OnSysColourChanged
)
89 // ============================================================================
91 // ============================================================================
93 // ----------------------------------------------------------------------------
95 // ----------------------------------------------------------------------------
97 // ----------------------------------------------------------------------------
99 // ----------------------------------------------------------------------------
101 void wxWindowX11::Init()
104 m_mainWindow
= (WXWindow
) 0;
105 m_clientWindow
= (WXWindow
) 0;
106 m_insertIntoMain
= false;
107 m_updateNcArea
= false;
109 m_winCaptured
= false;
110 m_needsInputFocus
= false;
116 // real construction (Init() must have been called before!)
117 bool wxWindowX11::Create(wxWindow
*parent
, wxWindowID id
,
121 const wxString
& name
)
123 wxCHECK_MSG( parent
, false, wxT("can't create wxWindow without parent") );
125 CreateBase(parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
);
127 parent
->AddChild(this);
129 Display
*xdisplay
= (Display
*) wxGlobalDisplay();
130 int xscreen
= DefaultScreen( xdisplay
);
131 Visual
*xvisual
= DefaultVisual( xdisplay
, xscreen
);
132 Colormap cm
= DefaultColormap( xdisplay
, xscreen
);
134 m_backgroundColour
= wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE
);
135 m_backgroundColour
.CalcPixel( (WXColormap
) cm
);
137 m_foregroundColour
= *wxBLACK
;
138 m_foregroundColour
.CalcPixel( (WXColormap
) cm
);
140 Window xparent
= (Window
) parent
->GetClientAreaWindow();
142 // Add window's own scrollbars to main window, not to client window
143 if (parent
->GetInsertIntoMain())
145 // wxLogDebug( "Inserted into main: %s", GetName().c_str() );
146 xparent
= (Window
) parent
->GetMainWindow();
149 // Size (not including the border) must be nonzero (or a Value error results)!
150 // Note: The Xlib manual doesn't mention this restriction of XCreateWindow.
158 if (pos2
.x
== wxDefaultCoord
)
160 if (pos2
.y
== wxDefaultCoord
)
163 #if wxUSE_TWO_WINDOWS
164 bool need_two_windows
=
165 ((( wxSUNKEN_BORDER
| wxRAISED_BORDER
| wxSIMPLE_BORDER
| wxHSCROLL
| wxVSCROLL
) & m_windowStyle
) != 0);
167 bool need_two_windows
= false;
171 long xattributes
= 0;
173 XSetWindowAttributes xattributes
;
174 long xattributes_mask
= 0;
176 xattributes_mask
|= CWBackPixel
;
177 xattributes
.background_pixel
= m_backgroundColour
.GetPixel();
179 xattributes_mask
|= CWBorderPixel
;
180 xattributes
.border_pixel
= BlackPixel( xdisplay
, xscreen
);
182 xattributes_mask
|= CWEventMask
;
185 if (need_two_windows
)
188 long backColor
, foreColor
;
189 backColor
= GR_RGB(m_backgroundColour
.Red(), m_backgroundColour
.Green(), m_backgroundColour
.Blue());
190 foreColor
= GR_RGB(m_foregroundColour
.Red(), m_foregroundColour
.Green(), m_foregroundColour
.Blue());
192 Window xwindow
= XCreateWindowWithColor( xdisplay
, xparent
, pos2
.x
, pos2
.y
, size2
.x
, size2
.y
,
193 0, 0, InputOutput
, xvisual
, backColor
, foreColor
);
194 XSelectInput( xdisplay
, xwindow
,
195 GR_EVENT_MASK_CLOSE_REQ
| ExposureMask
| KeyPressMask
| KeyReleaseMask
| ButtonPressMask
| ButtonReleaseMask
|
196 ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
|
197 KeymapStateMask
| FocusChangeMask
| ColormapChangeMask
| StructureNotifyMask
|
198 PropertyChangeMask
);
202 xattributes
.event_mask
=
203 ExposureMask
| StructureNotifyMask
| ColormapChangeMask
;
205 Window xwindow
= XCreateWindow( xdisplay
, xparent
, pos2
.x
, pos2
.y
, size2
.x
, size2
.y
,
206 0, DefaultDepth(xdisplay
,xscreen
), InputOutput
, xvisual
, xattributes_mask
, &xattributes
);
210 XSetWindowBackgroundPixmap( xdisplay
, xwindow
, None
);
212 m_mainWindow
= (WXWindow
) xwindow
;
213 wxAddWindowToTable( xwindow
, (wxWindow
*) this );
215 XMapWindow( xdisplay
, xwindow
);
218 xattributes
.event_mask
=
219 ExposureMask
| KeyPressMask
| KeyReleaseMask
| ButtonPressMask
| ButtonReleaseMask
|
220 ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
|
221 KeymapStateMask
| FocusChangeMask
| ColormapChangeMask
| StructureNotifyMask
|
222 PropertyChangeMask
| VisibilityChangeMask
;
224 if (!HasFlag( wxFULL_REPAINT_ON_RESIZE
))
226 xattributes_mask
|= CWBitGravity
;
227 xattributes
.bit_gravity
= StaticGravity
;
231 if (HasFlag( wxSUNKEN_BORDER
) || HasFlag( wxRAISED_BORDER
))
238 else if (HasFlag( wxSIMPLE_BORDER
))
251 // Make again sure the size is nonzero.
258 backColor
= GR_RGB(m_backgroundColour
.Red(), m_backgroundColour
.Green(), m_backgroundColour
.Blue());
259 foreColor
= GR_RGB(m_foregroundColour
.Red(), m_foregroundColour
.Green(), m_foregroundColour
.Blue());
261 xwindow
= XCreateWindowWithColor( xdisplay
, xwindow
, pos2
.x
, pos2
.y
, size2
.x
, size2
.y
,
262 0, 0, InputOutput
, xvisual
, backColor
, foreColor
);
263 XSelectInput( xdisplay
, xwindow
,
264 GR_EVENT_MASK_CLOSE_REQ
| ExposureMask
| KeyPressMask
| KeyReleaseMask
| ButtonPressMask
| ButtonReleaseMask
|
265 ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
|
266 KeymapStateMask
| FocusChangeMask
| ColormapChangeMask
| StructureNotifyMask
|
267 PropertyChangeMask
);
270 xwindow
= XCreateWindow( xdisplay
, xwindow
, pos2
.x
, pos2
.y
, size2
.x
, size2
.y
,
271 0, DefaultDepth(xdisplay
,xscreen
), InputOutput
, xvisual
, xattributes_mask
, &xattributes
);
274 XSetWindowBackgroundPixmap( xdisplay
, xwindow
, None
);
276 m_clientWindow
= (WXWindow
) xwindow
;
277 wxAddClientWindowToTable( xwindow
, (wxWindow
*) this );
279 XMapWindow( xdisplay
, xwindow
);
283 // wxLogDebug( "No two windows needed %s", GetName().c_str() );
285 long backColor
, foreColor
;
286 backColor
= GR_RGB(m_backgroundColour
.Red(), m_backgroundColour
.Green(), m_backgroundColour
.Blue());
287 foreColor
= GR_RGB(m_foregroundColour
.Red(), m_foregroundColour
.Green(), m_foregroundColour
.Blue());
289 Window xwindow
= XCreateWindowWithColor( xdisplay
, xparent
, pos2
.x
, pos2
.y
, size2
.x
, size2
.y
,
290 0, 0, InputOutput
, xvisual
, backColor
, foreColor
);
291 XSelectInput( xdisplay
, xwindow
,
292 GR_EVENT_MASK_CLOSE_REQ
| ExposureMask
| KeyPressMask
| KeyReleaseMask
| ButtonPressMask
| ButtonReleaseMask
|
293 ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
|
294 KeymapStateMask
| FocusChangeMask
| ColormapChangeMask
| StructureNotifyMask
|
295 PropertyChangeMask
);
298 xattributes
.event_mask
=
299 ExposureMask
| KeyPressMask
| KeyReleaseMask
| ButtonPressMask
| ButtonReleaseMask
|
300 ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
|
301 KeymapStateMask
| FocusChangeMask
| ColormapChangeMask
| StructureNotifyMask
|
302 PropertyChangeMask
| VisibilityChangeMask
;
304 if (!HasFlag( wxFULL_REPAINT_ON_RESIZE
))
306 xattributes_mask
|= CWBitGravity
;
307 xattributes
.bit_gravity
= NorthWestGravity
;
310 Window xwindow
= XCreateWindow( xdisplay
, xparent
, pos2
.x
, pos2
.y
, size2
.x
, size2
.y
,
311 0, DefaultDepth(xdisplay
,xscreen
), InputOutput
, xvisual
, xattributes_mask
, &xattributes
);
314 XSetWindowBackgroundPixmap( xdisplay
, xwindow
, None
);
316 m_mainWindow
= (WXWindow
) xwindow
;
317 m_clientWindow
= m_mainWindow
;
318 wxAddWindowToTable( xwindow
, (wxWindow
*) this );
320 XMapWindow( xdisplay
, xwindow
);
323 // Is a subwindow, so map immediately
326 // Without this, the cursor may not be restored properly (e.g. in splitter
328 SetCursor(*wxSTANDARD_CURSOR
);
329 SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
));
331 // Don't call this, it can have nasty repercussions for composite controls,
333 // SetSize(pos.x, pos.y, size.x, size.y);
339 wxWindowX11::~wxWindowX11()
343 if (g_captureWindow
== this)
344 g_captureWindow
= NULL
;
346 m_isBeingDeleted
= true;
350 if (m_clientWindow
!= m_mainWindow
)
352 // Destroy the cleint window
353 Window xwindow
= (Window
) m_clientWindow
;
354 wxDeleteClientWindowFromTable( xwindow
);
355 XDestroyWindow( wxGlobalDisplay(), xwindow
);
356 m_clientWindow
= NULL
;
359 // Destroy the window
360 Window xwindow
= (Window
) m_mainWindow
;
361 wxDeleteWindowFromTable( xwindow
);
362 XDestroyWindow( wxGlobalDisplay(), xwindow
);
366 // ---------------------------------------------------------------------------
368 // ---------------------------------------------------------------------------
370 void wxWindowX11::SetFocus()
372 Window xwindow
= (Window
) m_clientWindow
;
374 wxCHECK_RET( xwindow
, wxT("invalid window") );
376 // Don't assert; we might be trying to set the focus for a panel
377 // with only static controls, so the panel returns false from AcceptsFocus.
378 // The app should be not be expected to deal with this.
383 if (GetName() == "scrollBar")
390 if (wxWindowIsVisible(xwindow
))
392 wxLogTrace( _T("focus"), _T("wxWindowX11::SetFocus: %s"), GetClassInfo()->GetClassName());
393 // XSetInputFocus( wxGlobalDisplay(), xwindow, RevertToParent, CurrentTime );
394 XSetInputFocus( wxGlobalDisplay(), xwindow
, RevertToNone
, CurrentTime
);
395 m_needsInputFocus
= false;
399 m_needsInputFocus
= true;
403 // Get the window with the focus
404 wxWindow
*wxWindowBase::DoFindFocus()
406 Window xfocus
= (Window
) 0;
409 XGetInputFocus( wxGlobalDisplay(), &xfocus
, &revert
);
412 wxWindow
*win
= wxGetWindowFromTable( xfocus
);
415 win
= wxGetClientWindowFromTable( xfocus
);
424 // Enabling/disabling handled by event loop, and not sending events
426 bool wxWindowX11::Enable(bool enable
)
428 if ( !wxWindowBase::Enable(enable
) )
434 bool wxWindowX11::Show(bool show
)
436 wxWindowBase::Show(show
);
438 Window xwindow
= (Window
) m_mainWindow
;
439 Display
*xdisp
= wxGlobalDisplay();
442 // wxLogDebug( "Mapping window of type %s", GetName().c_str() );
443 XMapWindow(xdisp
, xwindow
);
447 // wxLogDebug( "Unmapping window of type %s", GetName().c_str() );
448 XUnmapWindow(xdisp
, xwindow
);
454 // Raise the window to the top of the Z order
455 void wxWindowX11::Raise()
458 XRaiseWindow( wxGlobalDisplay(), (Window
) m_mainWindow
);
461 // Lower the window to the bottom of the Z order
462 void wxWindowX11::Lower()
465 XLowerWindow( wxGlobalDisplay(), (Window
) m_mainWindow
);
468 void wxWindowX11::SetLabel(const wxString
& WXUNUSED(label
))
473 wxString
wxWindowX11::GetLabel() const
476 return wxEmptyString
;
479 void wxWindowX11::DoCaptureMouse()
481 if ((g_captureWindow
!= NULL
) && (g_captureWindow
!= this))
483 wxFAIL_MSG(wxT("Trying to capture before mouse released."));
494 Window xwindow
= (Window
) m_clientWindow
;
496 wxCHECK_RET( xwindow
, wxT("invalid window") );
498 g_captureWindow
= (wxWindow
*) this;
502 int res
= XGrabPointer(wxGlobalDisplay(), xwindow
,
504 ButtonPressMask
| ButtonReleaseMask
| ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
,
508 None
, /* cursor */ // TODO: This may need to be set to the cursor of this window
511 if (res
!= GrabSuccess
)
514 msg
.Printf(wxT("Failed to grab pointer for window %s"), this->GetClassInfo()->GetClassName());
516 if (res
== GrabNotViewable
)
517 wxLogDebug( wxT("This is not a viewable window - perhaps not shown yet?") );
519 g_captureWindow
= NULL
;
523 m_winCaptured
= true;
527 void wxWindowX11::DoReleaseMouse()
529 g_captureWindow
= NULL
;
531 if ( !m_winCaptured
)
534 Window xwindow
= (Window
) m_clientWindow
;
538 XUngrabPointer( wxGlobalDisplay(), CurrentTime
);
541 // wxLogDebug( "Ungrabbed pointer in %s", GetName().c_str() );
543 m_winCaptured
= false;
546 bool wxWindowX11::SetFont(const wxFont
& font
)
548 if ( !wxWindowBase::SetFont(font
) )
557 bool wxWindowX11::SetCursor(const wxCursor
& cursor
)
559 if ( !wxWindowBase::SetCursor(cursor
) )
565 Window xwindow
= (Window
) m_clientWindow
;
567 wxCHECK_MSG( xwindow
, false, wxT("invalid window") );
569 wxCursor cursorToUse
;
571 cursorToUse
= m_cursor
;
573 cursorToUse
= *wxSTANDARD_CURSOR
;
575 Cursor xcursor
= (Cursor
) cursorToUse
.GetCursor();
577 XDefineCursor( wxGlobalDisplay(), xwindow
, xcursor
);
582 // Coordinates relative to the window
583 void wxWindowX11::WarpPointer (int x
, int y
)
585 Window xwindow
= (Window
) m_clientWindow
;
587 wxCHECK_RET( xwindow
, wxT("invalid window") );
589 XWarpPointer( wxGlobalDisplay(), None
, xwindow
, 0, 0, 0, 0, x
, y
);
592 // Does a physical scroll
593 void wxWindowX11::ScrollWindow(int dx
, int dy
, const wxRect
*rect
)
595 // No scrolling requested.
596 if ((dx
== 0) && (dy
== 0)) return;
598 if (!m_updateRegion
.IsEmpty())
600 m_updateRegion
.Offset( dx
, dy
);
604 GetSize( &cw
, &ch
); // GetClientSize() ??
605 m_updateRegion
.Intersect( 0, 0, cw
, ch
);
608 if (!m_clearRegion
.IsEmpty())
610 m_clearRegion
.Offset( dx
, dy
);
614 GetSize( &cw
, &ch
); // GetClientSize() ??
615 m_clearRegion
.Intersect( 0, 0, cw
, ch
);
618 Window xwindow
= (Window
) GetClientAreaWindow();
620 wxCHECK_RET( xwindow
, wxT("invalid window") );
622 Display
*xdisplay
= wxGlobalDisplay();
624 GC xgc
= XCreateGC( xdisplay
, xwindow
, 0, NULL
);
625 XSetGraphicsExposures( xdisplay
, xgc
, True
);
643 GetClientSize( &cw
, &ch
);
646 #if wxUSE_TWO_WINDOWS
647 wxPoint
offset( 0,0 );
649 wxPoint offset
= GetClientAreaOrigin();
654 int w
= cw
- abs(dx
);
655 int h
= ch
- abs(dy
);
657 if ((h
< 0) || (w
< 0))
664 if (dx
< 0) rect
.x
= cw
+dx
+ offset
.x
; else rect
.x
= s_x
;
665 if (dy
< 0) rect
.y
= ch
+dy
+ offset
.y
; else rect
.y
= s_y
;
666 if (dy
!= 0) rect
.width
= cw
; else rect
.width
= abs(dx
);
667 if (dx
!= 0) rect
.height
= ch
; else rect
.height
= abs(dy
);
672 if (dx
< 0) s_x
+= -dx
;
673 if (dy
< 0) s_y
+= -dy
;
674 if (dx
> 0) d_x
= dx
+ offset
.x
;
675 if (dy
> 0) d_y
= dy
+ offset
.y
;
677 XCopyArea( xdisplay
, xwindow
, xwindow
, xgc
, s_x
, s_y
, w
, h
, d_x
, d_y
);
679 // 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 );
681 // wxLogDebug( "Update: %d %d %d %d", rect.x, rect.y, rect.width, rect.height );
683 m_updateRegion
.Union( rect
);
684 m_clearRegion
.Union( rect
);
687 XFreeGC( xdisplay
, xgc
);
689 // Move Clients, but not the scrollbars
690 // FIXME: There may be a better method to move a lot of Windows within X11
691 wxScrollBar
*sbH
= ((wxWindow
*) this)->GetScrollbar( wxHORIZONTAL
);
692 wxScrollBar
*sbV
= ((wxWindow
*) this)->GetScrollbar( wxVERTICAL
);
693 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
696 // Only propagate to non-top-level windows
697 wxWindow
*win
= node
->GetData();
698 if ( win
->GetParent() && win
!= sbH
&& win
!= sbV
)
700 wxPoint pos
= win
->GetPosition();
701 // Add the delta to the old Position
704 win
->SetPosition(pos
);
706 node
= node
->GetNext();
710 // ---------------------------------------------------------------------------
712 // ---------------------------------------------------------------------------
714 #if wxUSE_DRAG_AND_DROP
716 void wxWindowX11::SetDropTarget(wxDropTarget
* WXUNUSED(pDropTarget
))
723 // Old style file-manager drag&drop
724 void wxWindowX11::DragAcceptFiles(bool WXUNUSED(accept
))
729 // ----------------------------------------------------------------------------
731 // ----------------------------------------------------------------------------
735 void wxWindowX11::DoSetToolTip(wxToolTip
* WXUNUSED(tooltip
))
740 #endif // wxUSE_TOOLTIPS
742 // ---------------------------------------------------------------------------
743 // moving and resizing
744 // ---------------------------------------------------------------------------
746 bool wxWindowX11::PreResize()
752 void wxWindowX11::DoGetSize(int *x
, int *y
) const
754 Window xwindow
= (Window
) m_mainWindow
;
756 wxCHECK_RET( xwindow
, wxT("invalid window") );
758 //XSync(wxGlobalDisplay(), False);
760 XWindowAttributes attr
;
761 Status status
= XGetWindowAttributes( wxGlobalDisplay(), xwindow
, &attr
);
766 *x
= attr
.width
/* + 2*m_borderSize */ ;
767 *y
= attr
.height
/* + 2*m_borderSize */ ;
771 void wxWindowX11::DoGetPosition(int *x
, int *y
) const
773 Window window
= (Window
) m_mainWindow
;
776 //XSync(wxGlobalDisplay(), False);
777 XWindowAttributes attr
;
778 Status status
= XGetWindowAttributes(wxGlobalDisplay(), window
, & attr
);
786 // We may be faking the client origin. So a window that's really at (0, 30)
787 // may appear (to wxWin apps) to be at (0, 0).
790 wxPoint
pt(GetParent()->GetClientAreaOrigin());
798 void wxWindowX11::DoScreenToClient(int *x
, int *y
) const
800 Display
*display
= wxGlobalDisplay();
801 Window rootWindow
= RootWindowOfScreen(DefaultScreenOfDisplay(display
));
802 Window thisWindow
= (Window
) m_clientWindow
;
807 XTranslateCoordinates(display
, rootWindow
, thisWindow
, xx
, yy
, x
, y
, &childWindow
);
810 void wxWindowX11::DoClientToScreen(int *x
, int *y
) const
812 Display
*display
= wxGlobalDisplay();
813 Window rootWindow
= RootWindowOfScreen(DefaultScreenOfDisplay(display
));
814 Window thisWindow
= (Window
) m_clientWindow
;
819 XTranslateCoordinates(display
, thisWindow
, rootWindow
, xx
, yy
, x
, y
, &childWindow
);
823 // Get size *available for subwindows* i.e. excluding menu bar etc.
824 void wxWindowX11::DoGetClientSize(int *x
, int *y
) const
826 Window window
= (Window
) m_mainWindow
;
830 XWindowAttributes attr
;
831 Status status
= XGetWindowAttributes( wxGlobalDisplay(), window
, &attr
);
842 void wxWindowX11::DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
844 // wxLogDebug("DoSetSize: %s (%ld) %d, %d %dx%d", GetClassInfo()->GetClassName(), GetId(), x, y, width, height);
846 Window xwindow
= (Window
) m_mainWindow
;
848 wxCHECK_RET( xwindow
, wxT("invalid window") );
850 XWindowAttributes attr
;
851 Status status
= XGetWindowAttributes( wxGlobalDisplay(), xwindow
, &attr
);
852 wxCHECK_RET( status
, wxT("invalid window attributes") );
856 int new_w
= attr
.width
;
857 int new_h
= attr
.height
;
859 if (x
!= wxDefaultCoord
|| (sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
862 AdjustForParentClientOrigin( x
, yy
, sizeFlags
);
865 if (y
!= wxDefaultCoord
|| (sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
868 AdjustForParentClientOrigin( xx
, y
, sizeFlags
);
871 if (width
!= wxDefaultCoord
)
877 if (height
!= wxDefaultCoord
)
884 DoMoveWindow( new_x
, new_y
, new_w
, new_h
);
887 void wxWindowX11::DoSetClientSize(int width
, int height
)
889 // wxLogDebug("DoSetClientSize: %s (%ld) %dx%d", GetClassInfo()->GetClassName(), GetId(), width, height);
891 Window xwindow
= (Window
) m_mainWindow
;
893 wxCHECK_RET( xwindow
, wxT("invalid window") );
895 XResizeWindow( wxGlobalDisplay(), xwindow
, width
, height
);
897 if (m_mainWindow
!= m_clientWindow
)
899 xwindow
= (Window
) m_clientWindow
;
901 wxWindow
*window
= (wxWindow
*) this;
902 wxRenderer
*renderer
= window
->GetRenderer();
905 wxRect border
= renderer
->GetBorderDimensions( (wxBorder
)(m_windowStyle
& wxBORDER_MASK
) );
906 width
-= border
.x
+ border
.width
;
907 height
-= border
.y
+ border
.height
;
910 XResizeWindow( wxGlobalDisplay(), xwindow
, width
, height
);
914 void wxWindowX11::DoMoveWindow(int x
, int y
, int width
, int height
)
916 Window xwindow
= (Window
) m_mainWindow
;
918 wxCHECK_RET( xwindow
, wxT("invalid window") );
922 XMoveResizeWindow( wxGlobalDisplay(), xwindow
, x
, y
, width
, height
);
923 if (m_mainWindow
!= m_clientWindow
)
925 xwindow
= (Window
) m_clientWindow
;
927 wxWindow
*window
= (wxWindow
*) this;
928 wxRenderer
*renderer
= window
->GetRenderer();
931 wxRect border
= renderer
->GetBorderDimensions( (wxBorder
)(m_windowStyle
& wxBORDER_MASK
) );
934 width
-= border
.x
+ border
.width
;
935 height
-= border
.y
+ border
.height
;
943 wxScrollBar
*sb
= window
->GetScrollbar( wxHORIZONTAL
);
944 if (sb
&& sb
->IsShown())
946 wxSize size
= sb
->GetSize();
949 sb
= window
->GetScrollbar( wxVERTICAL
);
950 if (sb
&& sb
->IsShown())
952 wxSize size
= sb
->GetSize();
956 XMoveResizeWindow( wxGlobalDisplay(), xwindow
, x
, y
, wxMax(1, width
), wxMax(1, height
) );
961 XWindowChanges windowChanges
;
964 windowChanges
.width
= width
;
965 windowChanges
.height
= height
;
966 windowChanges
.stack_mode
= 0;
967 int valueMask
= CWX
| CWY
| CWWidth
| CWHeight
;
969 XConfigureWindow( wxGlobalDisplay(), xwindow
, valueMask
, &windowChanges
);
974 void wxWindowX11::DoSetSizeHints(int minW
, int minH
, int maxW
, int maxH
, int incW
, int incH
)
982 XSizeHints sizeHints
;
985 if (minW
> -1 && minH
> -1)
987 sizeHints
.flags
|= PMinSize
;
988 sizeHints
.min_width
= minW
;
989 sizeHints
.min_height
= minH
;
991 if (maxW
> -1 && maxH
> -1)
993 sizeHints
.flags
|= PMaxSize
;
994 sizeHints
.max_width
= maxW
;
995 sizeHints
.max_height
= maxH
;
997 if (incW
> -1 && incH
> -1)
999 sizeHints
.flags
|= PResizeInc
;
1000 sizeHints
.width_inc
= incW
;
1001 sizeHints
.height_inc
= incH
;
1004 XSetWMNormalHints(wxGlobalDisplay(), (Window
) m_mainWindow
, &sizeHints
);
1008 // ---------------------------------------------------------------------------
1010 // ---------------------------------------------------------------------------
1012 int wxWindowX11::GetCharHeight() const
1014 wxFont
font(GetFont());
1015 wxCHECK_MSG( font
.Ok(), 0, wxT("valid window font needed") );
1018 // There should be an easier way.
1019 PangoLayout
*layout
= pango_layout_new( wxTheApp
->GetPangoContext() );
1020 pango_layout_set_font_description( layout
, font
.GetNativeFontInfo()->description
);
1021 pango_layout_set_text(layout
, "H", 1 );
1023 pango_layout_get_pixel_size(layout
, &w
, &h
);
1024 g_object_unref( G_OBJECT( layout
) );
1028 WXFontStructPtr pFontStruct
= font
.GetFontStruct(1.0, wxGlobalDisplay());
1030 int direction
, ascent
, descent
;
1031 XCharStruct overall
;
1032 XTextExtents ((XFontStruct
*) pFontStruct
, "x", 1, &direction
, &ascent
,
1033 &descent
, &overall
);
1035 // return (overall.ascent + overall.descent);
1036 return (ascent
+ descent
);
1040 int wxWindowX11::GetCharWidth() const
1042 wxFont
font(GetFont());
1043 wxCHECK_MSG( font
.Ok(), 0, wxT("valid window font needed") );
1046 // There should be an easier way.
1047 PangoLayout
*layout
= pango_layout_new( wxTheApp
->GetPangoContext() );
1048 pango_layout_set_font_description( layout
, font
.GetNativeFontInfo()->description
);
1049 pango_layout_set_text(layout
, "H", 1 );
1051 pango_layout_get_pixel_size(layout
, &w
, &h
);
1052 g_object_unref( G_OBJECT( layout
) );
1056 WXFontStructPtr pFontStruct
= font
.GetFontStruct(1.0, wxGlobalDisplay());
1058 int direction
, ascent
, descent
;
1059 XCharStruct overall
;
1060 XTextExtents ((XFontStruct
*) pFontStruct
, "x", 1, &direction
, &ascent
,
1061 &descent
, &overall
);
1063 return overall
.width
;
1067 void wxWindowX11::GetTextExtent(const wxString
& string
,
1069 int *descent
, int *externalLeading
,
1070 const wxFont
*theFont
) const
1072 wxFont fontToUse
= GetFont();
1073 if (theFont
) fontToUse
= *theFont
;
1075 wxCHECK_RET( fontToUse
.Ok(), wxT("invalid font") );
1085 PangoLayout
*layout
= pango_layout_new( wxTheApp
->GetPangoContext() );
1087 PangoFontDescription
*desc
= fontToUse
.GetNativeFontInfo()->description
;
1088 pango_layout_set_font_description(layout
, desc
);
1090 const wxCharBuffer data
= wxConvUTF8
.cWC2MB( string
);
1091 pango_layout_set_text(layout
, (const char*) data
, strlen( (const char*) data
));
1093 PangoLayoutLine
*line
= (PangoLayoutLine
*)pango_layout_get_lines(layout
)->data
;
1096 PangoRectangle rect
;
1097 pango_layout_line_get_extents(line
, NULL
, &rect
);
1099 if (x
) (*x
) = (wxCoord
) (rect
.width
/ PANGO_SCALE
);
1100 if (y
) (*y
) = (wxCoord
) (rect
.height
/ PANGO_SCALE
);
1103 // Do something about metrics here
1106 if (externalLeading
) (*externalLeading
) = 0; // ??
1108 g_object_unref( G_OBJECT( layout
) );
1110 WXFontStructPtr pFontStruct
= fontToUse
.GetFontStruct(1.0, wxGlobalDisplay());
1112 int direction
, ascent
, descent2
;
1113 XCharStruct overall
;
1114 int slen
= string
.Len();
1116 XTextExtents((XFontStruct
*) pFontStruct
, (char*) string
.c_str(), slen
,
1117 &direction
, &ascent
, &descent2
, &overall
);
1120 *x
= (overall
.width
);
1122 *y
= (ascent
+ descent2
);
1124 *descent
= descent2
;
1125 if (externalLeading
)
1126 *externalLeading
= 0;
1130 // ----------------------------------------------------------------------------
1132 // ----------------------------------------------------------------------------
1134 void wxWindowX11::Refresh(bool eraseBack
, const wxRect
*rect
)
1140 // Schedule for later Updating in ::Update() or ::OnInternalIdle().
1141 m_clearRegion
.Union( rect
->x
, rect
->y
, rect
->width
, rect
->height
);
1146 GetSize( &width
, &height
);
1148 // Schedule for later Updating in ::Update() or ::OnInternalIdle().
1149 m_clearRegion
.Clear();
1150 m_clearRegion
.Union( 0, 0, width
, height
);
1156 // Schedule for later Updating in ::Update() or ::OnInternalIdle().
1157 m_updateRegion
.Union( rect
->x
, rect
->y
, rect
->width
, rect
->height
);
1162 GetSize( &width
, &height
);
1164 // Schedule for later Updating in ::Update() or ::OnInternalIdle().
1165 m_updateRegion
.Clear();
1166 m_updateRegion
.Union( 0, 0, width
, height
);
1170 void wxWindowX11::Update()
1174 // wxLogDebug("wxWindowX11::UpdateNC: %s", GetClassInfo()->GetClassName());
1175 // Send nc paint events.
1176 SendNcPaintEvents();
1179 if (!m_updateRegion
.IsEmpty())
1181 // wxLogDebug("wxWindowX11::Update: %s", GetClassInfo()->GetClassName());
1182 // Actually send erase events.
1185 // Actually send paint events.
1190 void wxWindowX11::SendEraseEvents()
1192 if (m_clearRegion
.IsEmpty()) return;
1194 wxClientDC
dc( (wxWindow
*)this );
1195 dc
.SetClippingRegion( m_clearRegion
);
1197 wxEraseEvent
erase_event( GetId(), &dc
);
1198 erase_event
.SetEventObject( this );
1200 if (!GetEventHandler()->ProcessEvent(erase_event
) )
1202 Display
*xdisplay
= wxGlobalDisplay();
1203 Window xwindow
= (Window
) GetClientAreaWindow();
1204 XSetForeground( xdisplay
, g_eraseGC
, m_backgroundColour
.GetPixel() );
1206 wxRegionIterator
upd( m_clearRegion
);
1209 XFillRectangle( xdisplay
, xwindow
, g_eraseGC
,
1210 upd
.GetX(), upd
.GetY(), upd
.GetWidth(), upd
.GetHeight() );
1215 m_clearRegion
.Clear();
1218 void wxWindowX11::SendPaintEvents()
1220 // wxLogDebug("SendPaintEvents: %s (%ld)", GetClassInfo()->GetClassName(), GetId());
1222 m_clipPaintRegion
= true;
1224 wxPaintEvent
paint_event( GetId() );
1225 paint_event
.SetEventObject( this );
1226 GetEventHandler()->ProcessEvent( paint_event
);
1228 m_updateRegion
.Clear();
1230 m_clipPaintRegion
= false;
1233 void wxWindowX11::SendNcPaintEvents()
1235 wxWindow
*window
= (wxWindow
*) this;
1237 // All this for drawing the small square between the scrollbars.
1242 wxScrollBar
*sb
= window
->GetScrollbar( wxHORIZONTAL
);
1243 if (sb
&& sb
->IsShown())
1245 height
= sb
->GetSize().y
;
1246 y
= sb
->GetPosition().y
;
1248 sb
= window
->GetScrollbar( wxVERTICAL
);
1249 if (sb
&& sb
->IsShown())
1251 width
= sb
->GetSize().x
;
1252 x
= sb
->GetPosition().x
;
1254 Display
*xdisplay
= wxGlobalDisplay();
1255 Window xwindow
= (Window
) GetMainWindow();
1256 Colormap cm
= (Colormap
) wxTheApp
->GetMainColormap( wxGetDisplay() );
1257 wxColour colour
= wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
);
1258 colour
.CalcPixel( (WXColormap
) cm
);
1260 XSetForeground( xdisplay
, g_eraseGC
, colour
.GetPixel() );
1262 XFillRectangle( xdisplay
, xwindow
, g_eraseGC
, x
, y
, width
, height
);
1266 wxNcPaintEvent
nc_paint_event( GetId() );
1267 nc_paint_event
.SetEventObject( this );
1268 GetEventHandler()->ProcessEvent( nc_paint_event
);
1270 m_updateNcArea
= false;
1273 // ----------------------------------------------------------------------------
1275 // ----------------------------------------------------------------------------
1277 // Responds to colour changes: passes event on to children.
1278 void wxWindowX11::OnSysColourChanged(wxSysColourChangedEvent
& event
)
1280 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
1283 // Only propagate to non-top-level windows
1284 wxWindow
*win
= node
->GetData();
1285 if ( win
->GetParent() )
1287 wxSysColourChangedEvent event2
;
1288 event
.SetEventObject(win
);
1289 win
->GetEventHandler()->ProcessEvent(event2
);
1292 node
= node
->GetNext();
1296 // See handler for InFocus case in app.cpp for details.
1297 wxWindow
* g_GettingFocus
= NULL
;
1299 void wxWindowX11::OnInternalIdle()
1301 // Update invalidated regions.
1304 // This calls the UI-update mechanism (querying windows for
1305 // menu/toolbar/control state information)
1306 if (wxUpdateUIEvent::CanUpdate((wxWindow
*) this))
1307 UpdateWindowUI(wxUPDATE_UI_FROMIDLE
);
1309 // Set the input focus if couldn't do it before
1310 if (m_needsInputFocus
)
1314 msg
.Printf("Setting focus for %s from OnInternalIdle\n", GetClassInfo()->GetClassName());
1315 printf(msg
.c_str());
1319 // If it couldn't set the focus now, there's
1320 // no point in trying again.
1321 m_needsInputFocus
= false;
1323 g_GettingFocus
= NULL
;
1326 // ----------------------------------------------------------------------------
1327 // function which maintain the global hash table mapping Widgets to wxWidgets
1328 // ----------------------------------------------------------------------------
1330 static bool DoAddWindowToTable(wxWindowHash
*hash
, Window w
, wxWindow
*win
)
1332 if ( !hash
->insert(wxWindowHash::value_type(w
, win
)).second
)
1334 wxLogDebug( wxT("Widget table clash: new widget is 0x%08x, %s"),
1335 (unsigned int)w
, win
->GetClassInfo()->GetClassName());
1339 wxLogTrace( wxT("widget"), wxT("XWindow 0x%08x <-> window %p (%s)"),
1340 (unsigned int) w
, win
, win
->GetClassInfo()->GetClassName());
1345 static inline wxWindow
*DoGetWindowFromTable(wxWindowHash
*hash
, Window w
)
1347 wxWindowHash::iterator i
= hash
->find(w
);
1348 return i
== hash
->end() ? NULL
: i
->second
;
1351 static inline void DoDeleteWindowFromTable(wxWindowHash
*hash
, Window w
)
1353 wxLogTrace( wxT("widget"), wxT("XWindow 0x%08x deleted"), (unsigned int) w
);
1358 // ----------------------------------------------------------------------------
1360 // ----------------------------------------------------------------------------
1362 bool wxAddWindowToTable(Window w
, wxWindow
*win
)
1364 return DoAddWindowToTable(wxWidgetHashTable
, w
, win
);
1367 wxWindow
*wxGetWindowFromTable(Window w
)
1369 return DoGetWindowFromTable(wxWidgetHashTable
, w
);
1372 void wxDeleteWindowFromTable(Window w
)
1374 DoDeleteWindowFromTable(wxWidgetHashTable
, w
);
1377 bool wxAddClientWindowToTable(Window w
, wxWindow
*win
)
1379 return DoAddWindowToTable(wxClientWidgetHashTable
, w
, win
);
1382 wxWindow
*wxGetClientWindowFromTable(Window w
)
1384 return DoGetWindowFromTable(wxClientWidgetHashTable
, w
);
1387 void wxDeleteClientWindowFromTable(Window w
)
1389 DoDeleteWindowFromTable(wxClientWidgetHashTable
, w
);
1392 // ----------------------------------------------------------------------------
1393 // X11-specific accessors
1394 // ----------------------------------------------------------------------------
1396 WXWindow
wxWindowX11::GetMainWindow() const
1398 return m_mainWindow
;
1401 WXWindow
wxWindowX11::GetClientAreaWindow() const
1403 return m_clientWindow
;
1406 // ----------------------------------------------------------------------------
1407 // TranslateXXXEvent() functions
1408 // ----------------------------------------------------------------------------
1410 bool wxTranslateMouseEvent(wxMouseEvent
& wxevent
, wxWindow
*win
, Window window
, XEvent
*xevent
)
1412 switch (XEventGetType(xevent
))
1420 wxEventType eventType
= wxEVT_NULL
;
1422 if (XEventGetType(xevent
) == EnterNotify
)
1424 //if (local_event.xcrossing.mode!=NotifyNormal)
1425 // return ; // Ignore grab events
1426 eventType
= wxEVT_ENTER_WINDOW
;
1427 // canvas->GetEventHandler()->OnSetFocus();
1429 else if (XEventGetType(xevent
) == LeaveNotify
)
1431 //if (local_event.xcrossingr.mode!=NotifyNormal)
1432 // return ; // Ignore grab events
1433 eventType
= wxEVT_LEAVE_WINDOW
;
1434 // canvas->GetEventHandler()->OnKillFocus();
1436 else if (XEventGetType(xevent
) == MotionNotify
)
1438 eventType
= wxEVT_MOTION
;
1440 else if (XEventGetType(xevent
) == ButtonPress
)
1442 wxevent
.SetTimestamp(XButtonEventGetTime(xevent
));
1444 if (XButtonEventLChanged(xevent
))
1446 eventType
= wxEVT_LEFT_DOWN
;
1449 else if (XButtonEventMChanged(xevent
))
1451 eventType
= wxEVT_MIDDLE_DOWN
;
1454 else if (XButtonEventRChanged(xevent
))
1456 eventType
= wxEVT_RIGHT_DOWN
;
1460 // check for a double click
1461 // TODO: where can we get this value from?
1462 //long dclickTime = XtGetMultiClickTime(wxGlobalDisplay());
1463 long dclickTime
= 200;
1464 long ts
= wxevent
.GetTimestamp();
1466 int buttonLast
= win
->GetLastClickedButton();
1467 long lastTS
= win
->GetLastClickTime();
1468 if ( buttonLast
&& buttonLast
== button
&& (ts
- lastTS
) < dclickTime
)
1471 win
->SetLastClick(0, ts
);
1472 if ( eventType
== wxEVT_LEFT_DOWN
)
1473 eventType
= wxEVT_LEFT_DCLICK
;
1474 else if ( eventType
== wxEVT_MIDDLE_DOWN
)
1475 eventType
= wxEVT_MIDDLE_DCLICK
;
1476 else if ( eventType
== wxEVT_RIGHT_DOWN
)
1477 eventType
= wxEVT_RIGHT_DCLICK
;
1481 // not fast enough or different button
1482 win
->SetLastClick(button
, ts
);
1485 else if (XEventGetType(xevent
) == ButtonRelease
)
1487 if (XButtonEventLChanged(xevent
))
1489 eventType
= wxEVT_LEFT_UP
;
1491 else if (XButtonEventMChanged(xevent
))
1493 eventType
= wxEVT_MIDDLE_UP
;
1495 else if (XButtonEventRChanged(xevent
))
1497 eventType
= wxEVT_RIGHT_UP
;
1506 wxevent
.SetEventType(eventType
);
1508 wxevent
.m_x
= XButtonEventGetX(xevent
);
1509 wxevent
.m_y
= XButtonEventGetY(xevent
);
1511 wxevent
.m_leftDown
= ((eventType
== wxEVT_LEFT_DOWN
)
1512 || (XButtonEventLIsDown(xevent
)
1513 && (eventType
!= wxEVT_LEFT_UP
)));
1514 wxevent
.m_middleDown
= ((eventType
== wxEVT_MIDDLE_DOWN
)
1515 || (XButtonEventMIsDown(xevent
)
1516 && (eventType
!= wxEVT_MIDDLE_UP
)));
1517 wxevent
.m_rightDown
= ((eventType
== wxEVT_RIGHT_DOWN
)
1518 || (XButtonEventRIsDown (xevent
)
1519 && (eventType
!= wxEVT_RIGHT_UP
)));
1521 wxevent
.m_shiftDown
= XButtonEventShiftIsDown(xevent
);
1522 wxevent
.m_controlDown
= XButtonEventCtrlIsDown(xevent
);
1523 wxevent
.m_altDown
= XButtonEventAltIsDown(xevent
);
1524 wxevent
.m_metaDown
= XButtonEventMetaIsDown(xevent
);
1526 wxevent
.SetId(win
->GetId());
1527 wxevent
.SetEventObject(win
);
1535 bool wxTranslateKeyEvent(wxKeyEvent
& wxevent
, wxWindow
*win
, Window
WXUNUSED(win
), XEvent
*xevent
, bool isAscii
)
1537 switch (XEventGetType(xevent
))
1545 (void) XLookupString ((XKeyEvent
*) xevent
, buf
, 20, &keySym
, NULL
);
1546 int id
= wxCharCodeXToWX (keySym
);
1547 // id may be WXK_xxx code - these are outside ASCII range, so we
1548 // can't just use toupper() on id.
1549 // Only change this if we want the raw key that was pressed,
1550 // and don't change it if we want an ASCII value.
1551 if (!isAscii
&& (id
>= 'a' && id
<= 'z'))
1553 id
= id
+ 'A' - 'a';
1556 wxevent
.m_shiftDown
= XKeyEventShiftIsDown(xevent
);
1557 wxevent
.m_controlDown
= XKeyEventCtrlIsDown(xevent
);
1558 wxevent
.m_altDown
= XKeyEventAltIsDown(xevent
);
1559 wxevent
.m_metaDown
= XKeyEventMetaIsDown(xevent
);
1560 wxevent
.SetEventObject(win
);
1561 wxevent
.m_keyCode
= id
;
1562 wxevent
.SetTimestamp(XKeyEventGetTime(xevent
));
1564 wxevent
.m_x
= XKeyEventGetX(xevent
);
1565 wxevent
.m_y
= XKeyEventGetY(xevent
);
1575 // ----------------------------------------------------------------------------
1577 // ----------------------------------------------------------------------------
1579 bool wxWindowX11::SetBackgroundColour(const wxColour
& col
)
1581 wxWindowBase::SetBackgroundColour(col
);
1583 Display
*xdisplay
= (Display
*) wxGlobalDisplay();
1584 int xscreen
= DefaultScreen( xdisplay
);
1585 Colormap cm
= DefaultColormap( xdisplay
, xscreen
);
1587 m_backgroundColour
.CalcPixel( (WXColormap
) cm
);
1589 // We don't set the background colour as we paint
1590 // the background ourselves.
1591 // XSetWindowBackground( xdisplay, (Window) m_clientWindow, m_backgroundColour.GetPixel() );
1596 bool wxWindowX11::SetForegroundColour(const wxColour
& col
)
1598 if ( !wxWindowBase::SetForegroundColour(col
) )
1604 // ----------------------------------------------------------------------------
1606 // ----------------------------------------------------------------------------
1608 wxWindow
*wxGetActiveWindow()
1611 wxFAIL_MSG(wxT("Not implemented"));
1616 wxWindow
*wxWindowBase::GetCapture()
1618 return (wxWindow
*)g_captureWindow
;
1622 // Find the wxWindow at the current mouse position, returning the mouse
1624 wxWindow
* wxFindWindowAtPointer(wxPoint
& pt
)
1626 return wxFindWindowAtPoint(wxGetMousePosition());
1629 // Get the current mouse position.
1630 wxPoint
wxGetMousePosition()
1634 return wxPoint(0, 0);
1636 Display
*display
= wxGlobalDisplay();
1637 Window rootWindow
= RootWindowOfScreen (DefaultScreenOfDisplay(display
));
1638 Window rootReturn
, childReturn
;
1639 int rootX
, rootY
, winX
, winY
;
1640 unsigned int maskReturn
;
1642 XQueryPointer (display
,
1646 &rootX
, &rootY
, &winX
, &winY
, &maskReturn
);
1647 return wxPoint(rootX
, rootY
);
1652 // ----------------------------------------------------------------------------
1653 // wxNoOptimize: switch off size optimization
1654 // ----------------------------------------------------------------------------
1656 int wxNoOptimize::ms_count
= 0;
1659 // ----------------------------------------------------------------------------
1661 // ----------------------------------------------------------------------------
1663 class wxWinModule
: public wxModule
1670 DECLARE_DYNAMIC_CLASS(wxWinModule
)
1673 IMPLEMENT_DYNAMIC_CLASS(wxWinModule
, wxModule
)
1675 bool wxWinModule::OnInit()
1677 Display
*xdisplay
= wxGlobalDisplay();
1678 int xscreen
= DefaultScreen( xdisplay
);
1679 Window xroot
= RootWindow( xdisplay
, xscreen
);
1680 g_eraseGC
= XCreateGC( xdisplay
, xroot
, 0, NULL
);
1681 XSetFillStyle( xdisplay
, g_eraseGC
, FillSolid
);
1686 void wxWinModule::OnExit()
1688 Display
*xdisplay
= wxGlobalDisplay();
1689 XFreeGC( xdisplay
, g_eraseGC
);