1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/x11/windows.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__)
23 // ============================================================================
25 // ============================================================================
27 // ----------------------------------------------------------------------------
29 // ----------------------------------------------------------------------------
33 #include "wx/dcclient.h"
37 #include "wx/layout.h"
38 #include "wx/dialog.h"
39 #include "wx/listbox.h"
40 #include "wx/button.h"
41 #include "wx/settings.h"
42 #include "wx/msgdlg.h"
44 #include "wx/scrolwin.h"
45 #include "wx/scrolbar.h"
46 #include "wx/module.h"
47 #include "wx/menuitem.h"
49 #include "wx/fontutil.h"
50 #include "wx/univ/renderer.h"
52 #if wxUSE_DRAG_AND_DROP
56 #include "wx/x11/private.h"
57 #include "X11/Xutil.h"
60 // For wxGetLocalTime, used by XButtonEventGetTime
66 // ----------------------------------------------------------------------------
67 // global variables for this module
68 // ----------------------------------------------------------------------------
70 static wxWindow
* g_captureWindow
= NULL
;
73 // ----------------------------------------------------------------------------
75 // ----------------------------------------------------------------------------
77 #define event_left_is_down(x) ((x)->xbutton.state & Button1Mask)
78 #define event_middle_is_down(x) ((x)->xbutton.state & Button2Mask)
79 #define event_right_is_down(x) ((x)->xbutton.state & Button3Mask)
81 // ----------------------------------------------------------------------------
83 // ----------------------------------------------------------------------------
85 IMPLEMENT_ABSTRACT_CLASS(wxWindowX11
, wxWindowBase
)
87 BEGIN_EVENT_TABLE(wxWindowX11
, wxWindowBase
)
88 EVT_SYS_COLOUR_CHANGED(wxWindowX11::OnSysColourChanged
)
91 // ============================================================================
93 // ============================================================================
95 // ----------------------------------------------------------------------------
97 // ----------------------------------------------------------------------------
99 // ----------------------------------------------------------------------------
101 // ----------------------------------------------------------------------------
103 void wxWindowX11::Init()
106 m_mainWindow
= (WXWindow
) 0;
107 m_clientWindow
= (WXWindow
) 0;
108 m_insertIntoMain
= false;
109 m_updateNcArea
= false;
111 m_winCaptured
= false;
112 m_needsInputFocus
= false;
118 // real construction (Init() must have been called before!)
119 bool wxWindowX11::Create(wxWindow
*parent
, wxWindowID id
,
123 const wxString
& name
)
125 wxCHECK_MSG( parent
, false, wxT("can't create wxWindow without parent") );
127 CreateBase(parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
);
129 parent
->AddChild(this);
131 Display
*xdisplay
= (Display
*) wxGlobalDisplay();
132 int xscreen
= DefaultScreen( xdisplay
);
133 Visual
*xvisual
= DefaultVisual( xdisplay
, xscreen
);
134 Colormap cm
= DefaultColormap( xdisplay
, xscreen
);
136 m_backgroundColour
= wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE
);
137 m_backgroundColour
.CalcPixel( (WXColormap
) cm
);
139 m_foregroundColour
= *wxBLACK
;
140 m_foregroundColour
.CalcPixel( (WXColormap
) cm
);
142 Window xparent
= (Window
) parent
->GetClientAreaWindow();
144 // Add window's own scrollbars to main window, not to client window
145 if (parent
->GetInsertIntoMain())
147 // wxLogDebug( "Inserted into main: %s", GetName().c_str() );
148 xparent
= (Window
) parent
->GetMainWindow();
151 // Size (not including the border) must be nonzero (or a Value error results)!
152 // Note: The Xlib manual doesn't mention this restriction of XCreateWindow.
160 if (pos2
.x
== wxDefaultCoord
)
162 if (pos2
.y
== wxDefaultCoord
)
165 #if wxUSE_TWO_WINDOWS
166 bool need_two_windows
=
167 ((( wxSUNKEN_BORDER
| wxRAISED_BORDER
| wxSIMPLE_BORDER
| wxHSCROLL
| wxVSCROLL
) & m_windowStyle
) != 0);
169 bool need_two_windows
= false;
173 long xattributes
= 0;
175 XSetWindowAttributes xattributes
;
176 long xattributes_mask
= 0;
178 xattributes_mask
|= CWBackPixel
;
179 xattributes
.background_pixel
= m_backgroundColour
.GetPixel();
181 xattributes_mask
|= CWBorderPixel
;
182 xattributes
.border_pixel
= BlackPixel( xdisplay
, xscreen
);
184 xattributes_mask
|= CWEventMask
;
187 if (need_two_windows
)
190 long backColor
, foreColor
;
191 backColor
= GR_RGB(m_backgroundColour
.Red(), m_backgroundColour
.Green(), m_backgroundColour
.Blue());
192 foreColor
= GR_RGB(m_foregroundColour
.Red(), m_foregroundColour
.Green(), m_foregroundColour
.Blue());
194 Window xwindow
= XCreateWindowWithColor( xdisplay
, xparent
, pos2
.x
, pos2
.y
, size2
.x
, size2
.y
,
195 0, 0, InputOutput
, xvisual
, backColor
, foreColor
);
196 XSelectInput( xdisplay
, xwindow
,
197 GR_EVENT_MASK_CLOSE_REQ
| ExposureMask
| KeyPressMask
| KeyReleaseMask
| ButtonPressMask
| ButtonReleaseMask
|
198 ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
|
199 KeymapStateMask
| FocusChangeMask
| ColormapChangeMask
| StructureNotifyMask
|
200 PropertyChangeMask
);
204 xattributes
.event_mask
=
205 ExposureMask
| StructureNotifyMask
| ColormapChangeMask
;
207 Window xwindow
= XCreateWindow( xdisplay
, xparent
, pos2
.x
, pos2
.y
, size2
.x
, size2
.y
,
208 0, DefaultDepth(xdisplay
,xscreen
), InputOutput
, xvisual
, xattributes_mask
, &xattributes
);
212 XSetWindowBackgroundPixmap( xdisplay
, xwindow
, None
);
214 m_mainWindow
= (WXWindow
) xwindow
;
215 wxAddWindowToTable( xwindow
, (wxWindow
*) this );
217 XMapWindow( xdisplay
, xwindow
);
220 xattributes
.event_mask
=
221 ExposureMask
| KeyPressMask
| KeyReleaseMask
| ButtonPressMask
| ButtonReleaseMask
|
222 ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
|
223 KeymapStateMask
| FocusChangeMask
| ColormapChangeMask
| StructureNotifyMask
|
224 PropertyChangeMask
| VisibilityChangeMask
;
226 if (!HasFlag( wxFULL_REPAINT_ON_RESIZE
))
228 xattributes_mask
|= CWBitGravity
;
229 xattributes
.bit_gravity
= StaticGravity
;
233 if (HasFlag( wxSUNKEN_BORDER
) || HasFlag( wxRAISED_BORDER
))
240 else if (HasFlag( wxSIMPLE_BORDER
))
253 // Make again sure the size is nonzero.
260 backColor
= GR_RGB(m_backgroundColour
.Red(), m_backgroundColour
.Green(), m_backgroundColour
.Blue());
261 foreColor
= GR_RGB(m_foregroundColour
.Red(), m_foregroundColour
.Green(), m_foregroundColour
.Blue());
263 xwindow
= XCreateWindowWithColor( xdisplay
, xwindow
, pos2
.x
, pos2
.y
, size2
.x
, size2
.y
,
264 0, 0, InputOutput
, xvisual
, backColor
, foreColor
);
265 XSelectInput( xdisplay
, xwindow
,
266 GR_EVENT_MASK_CLOSE_REQ
| ExposureMask
| KeyPressMask
| KeyReleaseMask
| ButtonPressMask
| ButtonReleaseMask
|
267 ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
|
268 KeymapStateMask
| FocusChangeMask
| ColormapChangeMask
| StructureNotifyMask
|
269 PropertyChangeMask
);
272 xwindow
= XCreateWindow( xdisplay
, xwindow
, pos2
.x
, pos2
.y
, size2
.x
, size2
.y
,
273 0, DefaultDepth(xdisplay
,xscreen
), InputOutput
, xvisual
, xattributes_mask
, &xattributes
);
276 XSetWindowBackgroundPixmap( xdisplay
, xwindow
, None
);
278 m_clientWindow
= (WXWindow
) xwindow
;
279 wxAddClientWindowToTable( xwindow
, (wxWindow
*) this );
281 XMapWindow( xdisplay
, xwindow
);
285 // wxLogDebug( "No two windows needed %s", GetName().c_str() );
287 long backColor
, foreColor
;
288 backColor
= GR_RGB(m_backgroundColour
.Red(), m_backgroundColour
.Green(), m_backgroundColour
.Blue());
289 foreColor
= GR_RGB(m_foregroundColour
.Red(), m_foregroundColour
.Green(), m_foregroundColour
.Blue());
291 Window xwindow
= XCreateWindowWithColor( xdisplay
, xparent
, pos2
.x
, pos2
.y
, size2
.x
, size2
.y
,
292 0, 0, InputOutput
, xvisual
, backColor
, foreColor
);
293 XSelectInput( xdisplay
, xwindow
,
294 GR_EVENT_MASK_CLOSE_REQ
| ExposureMask
| KeyPressMask
| KeyReleaseMask
| ButtonPressMask
| ButtonReleaseMask
|
295 ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
|
296 KeymapStateMask
| FocusChangeMask
| ColormapChangeMask
| StructureNotifyMask
|
297 PropertyChangeMask
);
300 xattributes
.event_mask
=
301 ExposureMask
| KeyPressMask
| KeyReleaseMask
| ButtonPressMask
| ButtonReleaseMask
|
302 ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
|
303 KeymapStateMask
| FocusChangeMask
| ColormapChangeMask
| StructureNotifyMask
|
304 PropertyChangeMask
| VisibilityChangeMask
;
306 if (!HasFlag( wxFULL_REPAINT_ON_RESIZE
))
308 xattributes_mask
|= CWBitGravity
;
309 xattributes
.bit_gravity
= NorthWestGravity
;
312 Window xwindow
= XCreateWindow( xdisplay
, xparent
, pos2
.x
, pos2
.y
, size2
.x
, size2
.y
,
313 0, DefaultDepth(xdisplay
,xscreen
), InputOutput
, xvisual
, xattributes_mask
, &xattributes
);
316 XSetWindowBackgroundPixmap( xdisplay
, xwindow
, None
);
318 m_mainWindow
= (WXWindow
) xwindow
;
319 m_clientWindow
= m_mainWindow
;
320 wxAddWindowToTable( xwindow
, (wxWindow
*) this );
322 XMapWindow( xdisplay
, xwindow
);
325 // Is a subwindow, so map immediately
328 // Without this, the cursor may not be restored properly (e.g. in splitter
330 SetCursor(*wxSTANDARD_CURSOR
);
331 SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
));
333 // Don't call this, it can have nasty repercussions for composite controls,
335 // SetSize(pos.x, pos.y, size.x, size.y);
341 wxWindowX11::~wxWindowX11()
345 if (g_captureWindow
== this)
346 g_captureWindow
= NULL
;
348 m_isBeingDeleted
= true;
352 if (m_clientWindow
!= m_mainWindow
)
354 // Destroy the cleint window
355 Window xwindow
= (Window
) m_clientWindow
;
356 wxDeleteClientWindowFromTable( xwindow
);
357 XDestroyWindow( wxGlobalDisplay(), xwindow
);
358 m_clientWindow
= NULL
;
361 // Destroy the window
362 Window xwindow
= (Window
) m_mainWindow
;
363 wxDeleteWindowFromTable( xwindow
);
364 XDestroyWindow( wxGlobalDisplay(), xwindow
);
368 // ---------------------------------------------------------------------------
370 // ---------------------------------------------------------------------------
372 void wxWindowX11::SetFocus()
374 Window xwindow
= (Window
) m_clientWindow
;
376 wxCHECK_RET( xwindow
, wxT("invalid window") );
378 // Don't assert; we might be trying to set the focus for a panel
379 // with only static controls, so the panel returns false from AcceptsFocus.
380 // The app should be not be expected to deal with this.
385 if (GetName() == "scrollBar")
392 if (wxWindowIsVisible(xwindow
))
394 wxLogTrace( _T("focus"), _T("wxWindowX11::SetFocus: %s"), GetClassInfo()->GetClassName());
395 // XSetInputFocus( wxGlobalDisplay(), xwindow, RevertToParent, CurrentTime );
396 XSetInputFocus( wxGlobalDisplay(), xwindow
, RevertToNone
, CurrentTime
);
397 m_needsInputFocus
= false;
401 m_needsInputFocus
= true;
405 // Get the window with the focus
406 wxWindow
*wxWindowBase::DoFindFocus()
408 Window xfocus
= (Window
) 0;
411 XGetInputFocus( wxGlobalDisplay(), &xfocus
, &revert
);
414 wxWindow
*win
= wxGetWindowFromTable( xfocus
);
417 win
= wxGetClientWindowFromTable( xfocus
);
426 // Enabling/disabling handled by event loop, and not sending events
428 bool wxWindowX11::Enable(bool enable
)
430 if ( !wxWindowBase::Enable(enable
) )
436 bool wxWindowX11::Show(bool show
)
438 wxWindowBase::Show(show
);
440 Window xwindow
= (Window
) m_mainWindow
;
441 Display
*xdisp
= wxGlobalDisplay();
444 // wxLogDebug( "Mapping window of type %s", GetName().c_str() );
445 XMapWindow(xdisp
, xwindow
);
449 // wxLogDebug( "Unmapping window of type %s", GetName().c_str() );
450 XUnmapWindow(xdisp
, xwindow
);
456 // Raise the window to the top of the Z order
457 void wxWindowX11::Raise()
460 XRaiseWindow( wxGlobalDisplay(), (Window
) m_mainWindow
);
463 // Lower the window to the bottom of the Z order
464 void wxWindowX11::Lower()
467 XLowerWindow( wxGlobalDisplay(), (Window
) m_mainWindow
);
470 void wxWindowX11::SetLabel(const wxString
& WXUNUSED(label
))
475 wxString
wxWindowX11::GetLabel() const
478 return wxEmptyString
;
481 void wxWindowX11::DoCaptureMouse()
483 if ((g_captureWindow
!= NULL
) && (g_captureWindow
!= this))
485 wxASSERT_MSG(false, wxT("Trying to capture before mouse released."));
496 Window xwindow
= (Window
) m_clientWindow
;
498 wxCHECK_RET( xwindow
, wxT("invalid window") );
500 g_captureWindow
= (wxWindow
*) this;
504 int res
= XGrabPointer(wxGlobalDisplay(), xwindow
,
506 ButtonPressMask
| ButtonReleaseMask
| ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
,
510 None
, /* cursor */ // TODO: This may need to be set to the cursor of this window
513 if (res
!= GrabSuccess
)
516 msg
.Printf(wxT("Failed to grab pointer for window %s"), this->GetClassInfo()->GetClassName());
518 if (res
== GrabNotViewable
)
519 wxLogDebug( wxT("This is not a viewable window - perhaps not shown yet?") );
521 g_captureWindow
= NULL
;
525 m_winCaptured
= true;
529 void wxWindowX11::DoReleaseMouse()
531 g_captureWindow
= NULL
;
533 if ( !m_winCaptured
)
536 Window xwindow
= (Window
) m_clientWindow
;
540 XUngrabPointer( wxGlobalDisplay(), CurrentTime
);
543 // wxLogDebug( "Ungrabbed pointer in %s", GetName().c_str() );
545 m_winCaptured
= false;
548 bool wxWindowX11::SetFont(const wxFont
& font
)
550 if ( !wxWindowBase::SetFont(font
) )
559 bool wxWindowX11::SetCursor(const wxCursor
& cursor
)
561 if ( !wxWindowBase::SetCursor(cursor
) )
567 Window xwindow
= (Window
) m_clientWindow
;
569 wxCHECK_MSG( xwindow
, false, wxT("invalid window") );
571 wxCursor cursorToUse
;
573 cursorToUse
= m_cursor
;
575 cursorToUse
= *wxSTANDARD_CURSOR
;
577 Cursor xcursor
= (Cursor
) cursorToUse
.GetCursor();
579 XDefineCursor( wxGlobalDisplay(), xwindow
, xcursor
);
584 // Coordinates relative to the window
585 void wxWindowX11::WarpPointer (int x
, int y
)
587 Window xwindow
= (Window
) m_clientWindow
;
589 wxCHECK_RET( xwindow
, wxT("invalid window") );
591 XWarpPointer( wxGlobalDisplay(), None
, xwindow
, 0, 0, 0, 0, x
, y
);
594 // Does a physical scroll
595 void wxWindowX11::ScrollWindow(int dx
, int dy
, const wxRect
*rect
)
597 // No scrolling requested.
598 if ((dx
== 0) && (dy
== 0)) return;
600 if (!m_updateRegion
.IsEmpty())
602 m_updateRegion
.Offset( dx
, dy
);
606 GetSize( &cw
, &ch
); // GetClientSize() ??
607 m_updateRegion
.Intersect( 0, 0, cw
, ch
);
610 if (!m_clearRegion
.IsEmpty())
612 m_clearRegion
.Offset( dx
, dy
);
616 GetSize( &cw
, &ch
); // GetClientSize() ??
617 m_clearRegion
.Intersect( 0, 0, cw
, ch
);
620 Window xwindow
= (Window
) GetClientAreaWindow();
622 wxCHECK_RET( xwindow
, wxT("invalid window") );
624 Display
*xdisplay
= wxGlobalDisplay();
626 GC xgc
= XCreateGC( xdisplay
, xwindow
, 0, NULL
);
627 XSetGraphicsExposures( xdisplay
, xgc
, True
);
645 GetClientSize( &cw
, &ch
);
648 #if wxUSE_TWO_WINDOWS
649 wxPoint
offset( 0,0 );
651 wxPoint offset
= GetClientAreaOrigin();
656 int w
= cw
- abs(dx
);
657 int h
= ch
- abs(dy
);
659 if ((h
< 0) || (w
< 0))
666 if (dx
< 0) rect
.x
= cw
+dx
+ offset
.x
; else rect
.x
= s_x
;
667 if (dy
< 0) rect
.y
= ch
+dy
+ offset
.y
; else rect
.y
= s_y
;
668 if (dy
!= 0) rect
.width
= cw
; else rect
.width
= abs(dx
);
669 if (dx
!= 0) rect
.height
= ch
; else rect
.height
= abs(dy
);
674 if (dx
< 0) s_x
+= -dx
;
675 if (dy
< 0) s_y
+= -dy
;
676 if (dx
> 0) d_x
= dx
+ offset
.x
;
677 if (dy
> 0) d_y
= dy
+ offset
.y
;
679 XCopyArea( xdisplay
, xwindow
, xwindow
, xgc
, s_x
, s_y
, w
, h
, d_x
, d_y
);
681 // 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 );
683 // wxLogDebug( "Update: %d %d %d %d", rect.x, rect.y, rect.width, rect.height );
685 m_updateRegion
.Union( rect
);
686 m_clearRegion
.Union( rect
);
689 XFreeGC( xdisplay
, xgc
);
691 // Move Clients, but not the scrollbars
692 // FIXME: There may be a better method to move a lot of Windows within X11
693 wxScrollBar
*sbH
= ((wxWindow
*) this)->GetScrollbar( wxHORIZONTAL
);
694 wxScrollBar
*sbV
= ((wxWindow
*) this)->GetScrollbar( wxVERTICAL
);
695 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
698 // Only propagate to non-top-level windows
699 wxWindow
*win
= node
->GetData();
700 if ( win
->GetParent() && win
!= sbH
&& win
!= sbV
)
702 wxPoint pos
= win
->GetPosition();
703 // Add the delta to the old Position
706 win
->SetPosition(pos
);
708 node
= node
->GetNext();
712 // ---------------------------------------------------------------------------
714 // ---------------------------------------------------------------------------
716 #if wxUSE_DRAG_AND_DROP
718 void wxWindowX11::SetDropTarget(wxDropTarget
* WXUNUSED(pDropTarget
))
725 // Old style file-manager drag&drop
726 void wxWindowX11::DragAcceptFiles(bool WXUNUSED(accept
))
731 // ----------------------------------------------------------------------------
733 // ----------------------------------------------------------------------------
737 void wxWindowX11::DoSetToolTip(wxToolTip
* WXUNUSED(tooltip
))
742 #endif // wxUSE_TOOLTIPS
744 // ---------------------------------------------------------------------------
745 // moving and resizing
746 // ---------------------------------------------------------------------------
748 bool wxWindowX11::PreResize()
754 void wxWindowX11::DoGetSize(int *x
, int *y
) const
756 Window xwindow
= (Window
) m_mainWindow
;
758 wxCHECK_RET( xwindow
, wxT("invalid window") );
760 //XSync(wxGlobalDisplay(), False);
762 XWindowAttributes attr
;
763 Status status
= XGetWindowAttributes( wxGlobalDisplay(), xwindow
, &attr
);
768 *x
= attr
.width
/* + 2*m_borderSize */ ;
769 *y
= attr
.height
/* + 2*m_borderSize */ ;
773 void wxWindowX11::DoGetPosition(int *x
, int *y
) const
775 Window window
= (Window
) m_mainWindow
;
778 //XSync(wxGlobalDisplay(), False);
779 XWindowAttributes attr
;
780 Status status
= XGetWindowAttributes(wxGlobalDisplay(), window
, & attr
);
788 // We may be faking the client origin. So a window that's really at (0, 30)
789 // may appear (to wxWin apps) to be at (0, 0).
792 wxPoint
pt(GetParent()->GetClientAreaOrigin());
800 void wxWindowX11::DoScreenToClient(int *x
, int *y
) const
802 Display
*display
= wxGlobalDisplay();
803 Window rootWindow
= RootWindowOfScreen(DefaultScreenOfDisplay(display
));
804 Window thisWindow
= (Window
) m_clientWindow
;
809 XTranslateCoordinates(display
, rootWindow
, thisWindow
, xx
, yy
, x
, y
, &childWindow
);
812 void wxWindowX11::DoClientToScreen(int *x
, int *y
) const
814 Display
*display
= wxGlobalDisplay();
815 Window rootWindow
= RootWindowOfScreen(DefaultScreenOfDisplay(display
));
816 Window thisWindow
= (Window
) m_clientWindow
;
821 XTranslateCoordinates(display
, thisWindow
, rootWindow
, xx
, yy
, x
, y
, &childWindow
);
825 // Get size *available for subwindows* i.e. excluding menu bar etc.
826 void wxWindowX11::DoGetClientSize(int *x
, int *y
) const
828 Window window
= (Window
) m_mainWindow
;
832 XWindowAttributes attr
;
833 Status status
= XGetWindowAttributes( wxGlobalDisplay(), window
, &attr
);
844 void wxWindowX11::DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
846 // wxLogDebug("DoSetSize: %s (%ld) %d, %d %dx%d", GetClassInfo()->GetClassName(), GetId(), x, y, width, height);
848 Window xwindow
= (Window
) m_mainWindow
;
850 wxCHECK_RET( xwindow
, wxT("invalid window") );
852 XWindowAttributes attr
;
853 Status status
= XGetWindowAttributes( wxGlobalDisplay(), xwindow
, &attr
);
854 wxCHECK_RET( status
, wxT("invalid window attributes") );
858 int new_w
= attr
.width
;
859 int new_h
= attr
.height
;
861 if (x
!= wxDefaultCoord
|| (sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
864 AdjustForParentClientOrigin( x
, yy
, sizeFlags
);
867 if (y
!= wxDefaultCoord
|| (sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
870 AdjustForParentClientOrigin( xx
, y
, sizeFlags
);
873 if (width
!= wxDefaultCoord
)
879 if (height
!= wxDefaultCoord
)
886 DoMoveWindow( new_x
, new_y
, new_w
, new_h
);
889 void wxWindowX11::DoSetClientSize(int width
, int height
)
891 // wxLogDebug("DoSetClientSize: %s (%ld) %dx%d", GetClassInfo()->GetClassName(), GetId(), width, height);
893 Window xwindow
= (Window
) m_mainWindow
;
895 wxCHECK_RET( xwindow
, wxT("invalid window") );
897 XResizeWindow( wxGlobalDisplay(), xwindow
, width
, height
);
899 if (m_mainWindow
!= m_clientWindow
)
901 xwindow
= (Window
) m_clientWindow
;
903 wxWindow
*window
= (wxWindow
*) this;
904 wxRenderer
*renderer
= window
->GetRenderer();
907 wxRect border
= renderer
->GetBorderDimensions( (wxBorder
)(m_windowStyle
& wxBORDER_MASK
) );
908 width
-= border
.x
+ border
.width
;
909 height
-= border
.y
+ border
.height
;
912 XResizeWindow( wxGlobalDisplay(), xwindow
, width
, height
);
916 void wxWindowX11::DoMoveWindow(int x
, int y
, int width
, int height
)
918 Window xwindow
= (Window
) m_mainWindow
;
920 wxCHECK_RET( xwindow
, wxT("invalid window") );
924 XMoveResizeWindow( wxGlobalDisplay(), xwindow
, x
, y
, width
, height
);
925 if (m_mainWindow
!= m_clientWindow
)
927 xwindow
= (Window
) m_clientWindow
;
929 wxWindow
*window
= (wxWindow
*) this;
930 wxRenderer
*renderer
= window
->GetRenderer();
933 wxRect border
= renderer
->GetBorderDimensions( (wxBorder
)(m_windowStyle
& wxBORDER_MASK
) );
936 width
-= border
.x
+ border
.width
;
937 height
-= border
.y
+ border
.height
;
945 wxScrollBar
*sb
= window
->GetScrollbar( wxHORIZONTAL
);
946 if (sb
&& sb
->IsShown())
948 wxSize size
= sb
->GetSize();
951 sb
= window
->GetScrollbar( wxVERTICAL
);
952 if (sb
&& sb
->IsShown())
954 wxSize size
= sb
->GetSize();
958 XMoveResizeWindow( wxGlobalDisplay(), xwindow
, x
, y
, wxMax(1, width
), wxMax(1, height
) );
963 XWindowChanges windowChanges
;
966 windowChanges
.width
= width
;
967 windowChanges
.height
= height
;
968 windowChanges
.stack_mode
= 0;
969 int valueMask
= CWX
| CWY
| CWWidth
| CWHeight
;
971 XConfigureWindow( wxGlobalDisplay(), xwindow
, valueMask
, &windowChanges
);
976 void wxWindowX11::DoSetSizeHints(int minW
, int minH
, int maxW
, int maxH
, int incW
, int incH
)
984 XSizeHints sizeHints
;
987 if (minW
> -1 && minH
> -1)
989 sizeHints
.flags
|= PMinSize
;
990 sizeHints
.min_width
= minW
;
991 sizeHints
.min_height
= minH
;
993 if (maxW
> -1 && maxH
> -1)
995 sizeHints
.flags
|= PMaxSize
;
996 sizeHints
.max_width
= maxW
;
997 sizeHints
.max_height
= maxH
;
999 if (incW
> -1 && incH
> -1)
1001 sizeHints
.flags
|= PResizeInc
;
1002 sizeHints
.width_inc
= incW
;
1003 sizeHints
.height_inc
= incH
;
1006 XSetWMNormalHints(wxGlobalDisplay(), (Window
) m_mainWindow
, &sizeHints
);
1010 // ---------------------------------------------------------------------------
1012 // ---------------------------------------------------------------------------
1014 int wxWindowX11::GetCharHeight() const
1016 wxFont
font(GetFont());
1017 wxCHECK_MSG( font
.Ok(), 0, wxT("valid window font needed") );
1020 // There should be an easier way.
1021 PangoLayout
*layout
= pango_layout_new( wxTheApp
->GetPangoContext() );
1022 pango_layout_set_font_description( layout
, font
.GetNativeFontInfo()->description
);
1023 pango_layout_set_text(layout
, "H", 1 );
1025 pango_layout_get_pixel_size(layout
, &w
, &h
);
1026 g_object_unref( G_OBJECT( layout
) );
1030 WXFontStructPtr pFontStruct
= font
.GetFontStruct(1.0, wxGlobalDisplay());
1032 int direction
, ascent
, descent
;
1033 XCharStruct overall
;
1034 XTextExtents ((XFontStruct
*) pFontStruct
, "x", 1, &direction
, &ascent
,
1035 &descent
, &overall
);
1037 // return (overall.ascent + overall.descent);
1038 return (ascent
+ descent
);
1042 int wxWindowX11::GetCharWidth() const
1044 wxFont
font(GetFont());
1045 wxCHECK_MSG( font
.Ok(), 0, wxT("valid window font needed") );
1048 // There should be an easier way.
1049 PangoLayout
*layout
= pango_layout_new( wxTheApp
->GetPangoContext() );
1050 pango_layout_set_font_description( layout
, font
.GetNativeFontInfo()->description
);
1051 pango_layout_set_text(layout
, "H", 1 );
1053 pango_layout_get_pixel_size(layout
, &w
, &h
);
1054 g_object_unref( G_OBJECT( layout
) );
1058 WXFontStructPtr pFontStruct
= font
.GetFontStruct(1.0, wxGlobalDisplay());
1060 int direction
, ascent
, descent
;
1061 XCharStruct overall
;
1062 XTextExtents ((XFontStruct
*) pFontStruct
, "x", 1, &direction
, &ascent
,
1063 &descent
, &overall
);
1065 return overall
.width
;
1069 void wxWindowX11::GetTextExtent(const wxString
& string
,
1071 int *descent
, int *externalLeading
,
1072 const wxFont
*theFont
) const
1074 wxFont fontToUse
= GetFont();
1075 if (theFont
) fontToUse
= *theFont
;
1077 wxCHECK_RET( fontToUse
.Ok(), wxT("invalid font") );
1087 PangoLayout
*layout
= pango_layout_new( wxTheApp
->GetPangoContext() );
1089 PangoFontDescription
*desc
= fontToUse
.GetNativeFontInfo()->description
;
1090 pango_layout_set_font_description(layout
, desc
);
1092 const wxCharBuffer data
= wxConvUTF8
.cWC2MB( string
);
1093 pango_layout_set_text(layout
, (const char*) data
, strlen( (const char*) data
));
1095 PangoLayoutLine
*line
= (PangoLayoutLine
*)pango_layout_get_lines(layout
)->data
;
1098 PangoRectangle rect
;
1099 pango_layout_line_get_extents(line
, NULL
, &rect
);
1101 if (x
) (*x
) = (wxCoord
) (rect
.width
/ PANGO_SCALE
);
1102 if (y
) (*y
) = (wxCoord
) (rect
.height
/ PANGO_SCALE
);
1105 // Do something about metrics here
1108 if (externalLeading
) (*externalLeading
) = 0; // ??
1110 g_object_unref( G_OBJECT( layout
) );
1112 WXFontStructPtr pFontStruct
= fontToUse
.GetFontStruct(1.0, wxGlobalDisplay());
1114 int direction
, ascent
, descent2
;
1115 XCharStruct overall
;
1116 int slen
= string
.Len();
1118 XTextExtents((XFontStruct
*) pFontStruct
, (char*) string
.c_str(), slen
,
1119 &direction
, &ascent
, &descent2
, &overall
);
1122 *x
= (overall
.width
);
1124 *y
= (ascent
+ descent2
);
1126 *descent
= descent2
;
1127 if (externalLeading
)
1128 *externalLeading
= 0;
1132 // ----------------------------------------------------------------------------
1134 // ----------------------------------------------------------------------------
1136 void wxWindowX11::Refresh(bool eraseBack
, const wxRect
*rect
)
1142 // Schedule for later Updating in ::Update() or ::OnInternalIdle().
1143 m_clearRegion
.Union( rect
->x
, rect
->y
, rect
->width
, rect
->height
);
1148 GetSize( &width
, &height
);
1150 // Schedule for later Updating in ::Update() or ::OnInternalIdle().
1151 m_clearRegion
.Clear();
1152 m_clearRegion
.Union( 0, 0, width
, height
);
1158 // Schedule for later Updating in ::Update() or ::OnInternalIdle().
1159 m_updateRegion
.Union( rect
->x
, rect
->y
, rect
->width
, rect
->height
);
1164 GetSize( &width
, &height
);
1166 // Schedule for later Updating in ::Update() or ::OnInternalIdle().
1167 m_updateRegion
.Clear();
1168 m_updateRegion
.Union( 0, 0, width
, height
);
1172 void wxWindowX11::Update()
1176 // wxLogDebug("wxWindowX11::UpdateNC: %s", GetClassInfo()->GetClassName());
1177 // Send nc paint events.
1178 SendNcPaintEvents();
1181 if (!m_updateRegion
.IsEmpty())
1183 // wxLogDebug("wxWindowX11::Update: %s", GetClassInfo()->GetClassName());
1184 // Actually send erase events.
1187 // Actually send paint events.
1192 void wxWindowX11::SendEraseEvents()
1194 if (m_clearRegion
.IsEmpty()) return;
1196 wxClientDC
dc( (wxWindow
*)this );
1197 dc
.SetClippingRegion( m_clearRegion
);
1199 wxEraseEvent
erase_event( GetId(), &dc
);
1200 erase_event
.SetEventObject( this );
1202 if (!GetEventHandler()->ProcessEvent(erase_event
) )
1204 Display
*xdisplay
= wxGlobalDisplay();
1205 Window xwindow
= (Window
) GetClientAreaWindow();
1206 XSetForeground( xdisplay
, g_eraseGC
, m_backgroundColour
.GetPixel() );
1208 wxRegionIterator
upd( m_clearRegion
);
1211 XFillRectangle( xdisplay
, xwindow
, g_eraseGC
,
1212 upd
.GetX(), upd
.GetY(), upd
.GetWidth(), upd
.GetHeight() );
1217 m_clearRegion
.Clear();
1220 void wxWindowX11::SendPaintEvents()
1222 // wxLogDebug("SendPaintEvents: %s (%ld)", GetClassInfo()->GetClassName(), GetId());
1224 m_clipPaintRegion
= true;
1226 wxPaintEvent
paint_event( GetId() );
1227 paint_event
.SetEventObject( this );
1228 GetEventHandler()->ProcessEvent( paint_event
);
1230 m_updateRegion
.Clear();
1232 m_clipPaintRegion
= false;
1235 void wxWindowX11::SendNcPaintEvents()
1237 wxWindow
*window
= (wxWindow
*) this;
1239 // All this for drawing the small square between the scrollbars.
1244 wxScrollBar
*sb
= window
->GetScrollbar( wxHORIZONTAL
);
1245 if (sb
&& sb
->IsShown())
1247 height
= sb
->GetSize().y
;
1248 y
= sb
->GetPosition().y
;
1250 sb
= window
->GetScrollbar( wxVERTICAL
);
1251 if (sb
&& sb
->IsShown())
1253 width
= sb
->GetSize().x
;
1254 x
= sb
->GetPosition().x
;
1256 Display
*xdisplay
= wxGlobalDisplay();
1257 Window xwindow
= (Window
) GetMainWindow();
1258 Colormap cm
= (Colormap
) wxTheApp
->GetMainColormap( wxGetDisplay() );
1259 wxColour colour
= wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
);
1260 colour
.CalcPixel( (WXColormap
) cm
);
1262 XSetForeground( xdisplay
, g_eraseGC
, colour
.GetPixel() );
1264 XFillRectangle( xdisplay
, xwindow
, g_eraseGC
, x
, y
, width
, height
);
1268 wxNcPaintEvent
nc_paint_event( GetId() );
1269 nc_paint_event
.SetEventObject( this );
1270 GetEventHandler()->ProcessEvent( nc_paint_event
);
1272 m_updateNcArea
= false;
1275 // ----------------------------------------------------------------------------
1277 // ----------------------------------------------------------------------------
1279 // Responds to colour changes: passes event on to children.
1280 void wxWindowX11::OnSysColourChanged(wxSysColourChangedEvent
& event
)
1282 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
1285 // Only propagate to non-top-level windows
1286 wxWindow
*win
= node
->GetData();
1287 if ( win
->GetParent() )
1289 wxSysColourChangedEvent event2
;
1290 event
.SetEventObject(win
);
1291 win
->GetEventHandler()->ProcessEvent(event2
);
1294 node
= node
->GetNext();
1298 // See handler for InFocus case in app.cpp for details.
1299 wxWindow
* g_GettingFocus
= NULL
;
1301 void wxWindowX11::OnInternalIdle()
1303 // Update invalidated regions.
1306 // This calls the UI-update mechanism (querying windows for
1307 // menu/toolbar/control state information)
1308 if (wxUpdateUIEvent::CanUpdate((wxWindow
*) this))
1309 UpdateWindowUI(wxUPDATE_UI_FROMIDLE
);
1311 // Set the input focus if couldn't do it before
1312 if (m_needsInputFocus
)
1316 msg
.Printf("Setting focus for %s from OnInternalIdle\n", GetClassInfo()->GetClassName());
1317 printf(msg
.c_str());
1321 // If it couldn't set the focus now, there's
1322 // no point in trying again.
1323 m_needsInputFocus
= false;
1325 g_GettingFocus
= NULL
;
1328 // ----------------------------------------------------------------------------
1329 // function which maintain the global hash table mapping Widgets to wxWidgets
1330 // ----------------------------------------------------------------------------
1332 static bool DoAddWindowToTable(wxWindowHash
*hash
, Window w
, wxWindow
*win
)
1334 if ( !hash
->insert(wxWindowHash::value_type(w
, win
)).second
)
1336 wxLogDebug( wxT("Widget table clash: new widget is 0x%08x, %s"),
1337 (unsigned int)w
, win
->GetClassInfo()->GetClassName());
1341 wxLogTrace( wxT("widget"), wxT("XWindow 0x%08x <-> window %p (%s)"),
1342 (unsigned int) w
, win
, win
->GetClassInfo()->GetClassName());
1347 static inline wxWindow
*DoGetWindowFromTable(wxWindowHash
*hash
, Window w
)
1349 wxWindowHash::iterator i
= hash
->find(w
);
1350 return i
== hash
->end() ? NULL
: i
->second
;
1353 static inline void DoDeleteWindowFromTable(wxWindowHash
*hash
, Window w
)
1355 wxLogTrace( wxT("widget"), wxT("XWindow 0x%08x deleted"), (unsigned int) w
);
1360 // ----------------------------------------------------------------------------
1362 // ----------------------------------------------------------------------------
1364 bool wxAddWindowToTable(Window w
, wxWindow
*win
)
1366 return DoAddWindowToTable(wxWidgetHashTable
, w
, win
);
1369 wxWindow
*wxGetWindowFromTable(Window w
)
1371 return DoGetWindowFromTable(wxWidgetHashTable
, w
);
1374 void wxDeleteWindowFromTable(Window w
)
1376 DoDeleteWindowFromTable(wxWidgetHashTable
, w
);
1379 bool wxAddClientWindowToTable(Window w
, wxWindow
*win
)
1381 return DoAddWindowToTable(wxClientWidgetHashTable
, w
, win
);
1384 wxWindow
*wxGetClientWindowFromTable(Window w
)
1386 return DoGetWindowFromTable(wxClientWidgetHashTable
, w
);
1389 void wxDeleteClientWindowFromTable(Window w
)
1391 DoDeleteWindowFromTable(wxClientWidgetHashTable
, w
);
1394 // ----------------------------------------------------------------------------
1395 // X11-specific accessors
1396 // ----------------------------------------------------------------------------
1398 WXWindow
wxWindowX11::GetMainWindow() const
1400 return m_mainWindow
;
1403 WXWindow
wxWindowX11::GetClientAreaWindow() const
1405 return m_clientWindow
;
1408 // ----------------------------------------------------------------------------
1409 // TranslateXXXEvent() functions
1410 // ----------------------------------------------------------------------------
1412 bool wxTranslateMouseEvent(wxMouseEvent
& wxevent
, wxWindow
*win
, Window window
, XEvent
*xevent
)
1414 switch (XEventGetType(xevent
))
1422 wxEventType eventType
= wxEVT_NULL
;
1424 if (XEventGetType(xevent
) == EnterNotify
)
1426 //if (local_event.xcrossing.mode!=NotifyNormal)
1427 // return ; // Ignore grab events
1428 eventType
= wxEVT_ENTER_WINDOW
;
1429 // canvas->GetEventHandler()->OnSetFocus();
1431 else if (XEventGetType(xevent
) == LeaveNotify
)
1433 //if (local_event.xcrossingr.mode!=NotifyNormal)
1434 // return ; // Ignore grab events
1435 eventType
= wxEVT_LEAVE_WINDOW
;
1436 // canvas->GetEventHandler()->OnKillFocus();
1438 else if (XEventGetType(xevent
) == MotionNotify
)
1440 eventType
= wxEVT_MOTION
;
1442 else if (XEventGetType(xevent
) == ButtonPress
)
1444 wxevent
.SetTimestamp(XButtonEventGetTime(xevent
));
1446 if (XButtonEventLChanged(xevent
))
1448 eventType
= wxEVT_LEFT_DOWN
;
1451 else if (XButtonEventMChanged(xevent
))
1453 eventType
= wxEVT_MIDDLE_DOWN
;
1456 else if (XButtonEventRChanged(xevent
))
1458 eventType
= wxEVT_RIGHT_DOWN
;
1462 // check for a double click
1463 // TODO: where can we get this value from?
1464 //long dclickTime = XtGetMultiClickTime(wxGlobalDisplay());
1465 long dclickTime
= 200;
1466 long ts
= wxevent
.GetTimestamp();
1468 int buttonLast
= win
->GetLastClickedButton();
1469 long lastTS
= win
->GetLastClickTime();
1470 if ( buttonLast
&& buttonLast
== button
&& (ts
- lastTS
) < dclickTime
)
1473 win
->SetLastClick(0, ts
);
1474 if ( eventType
== wxEVT_LEFT_DOWN
)
1475 eventType
= wxEVT_LEFT_DCLICK
;
1476 else if ( eventType
== wxEVT_MIDDLE_DOWN
)
1477 eventType
= wxEVT_MIDDLE_DCLICK
;
1478 else if ( eventType
== wxEVT_RIGHT_DOWN
)
1479 eventType
= wxEVT_RIGHT_DCLICK
;
1483 // not fast enough or different button
1484 win
->SetLastClick(button
, ts
);
1487 else if (XEventGetType(xevent
) == ButtonRelease
)
1489 if (XButtonEventLChanged(xevent
))
1491 eventType
= wxEVT_LEFT_UP
;
1493 else if (XButtonEventMChanged(xevent
))
1495 eventType
= wxEVT_MIDDLE_UP
;
1497 else if (XButtonEventRChanged(xevent
))
1499 eventType
= wxEVT_RIGHT_UP
;
1508 wxevent
.SetEventType(eventType
);
1510 wxevent
.m_x
= XButtonEventGetX(xevent
);
1511 wxevent
.m_y
= XButtonEventGetY(xevent
);
1513 wxevent
.m_leftDown
= ((eventType
== wxEVT_LEFT_DOWN
)
1514 || (XButtonEventLIsDown(xevent
)
1515 && (eventType
!= wxEVT_LEFT_UP
)));
1516 wxevent
.m_middleDown
= ((eventType
== wxEVT_MIDDLE_DOWN
)
1517 || (XButtonEventMIsDown(xevent
)
1518 && (eventType
!= wxEVT_MIDDLE_UP
)));
1519 wxevent
.m_rightDown
= ((eventType
== wxEVT_RIGHT_DOWN
)
1520 || (XButtonEventRIsDown (xevent
)
1521 && (eventType
!= wxEVT_RIGHT_UP
)));
1523 wxevent
.m_shiftDown
= XButtonEventShiftIsDown(xevent
);
1524 wxevent
.m_controlDown
= XButtonEventCtrlIsDown(xevent
);
1525 wxevent
.m_altDown
= XButtonEventAltIsDown(xevent
);
1526 wxevent
.m_metaDown
= XButtonEventMetaIsDown(xevent
);
1528 wxevent
.SetId(win
->GetId());
1529 wxevent
.SetEventObject(win
);
1537 bool wxTranslateKeyEvent(wxKeyEvent
& wxevent
, wxWindow
*win
, Window
WXUNUSED(win
), XEvent
*xevent
, bool isAscii
)
1539 switch (XEventGetType(xevent
))
1547 (void) XLookupString ((XKeyEvent
*) xevent
, buf
, 20, &keySym
, NULL
);
1548 int id
= wxCharCodeXToWX (keySym
);
1549 // id may be WXK_xxx code - these are outside ASCII range, so we
1550 // can't just use toupper() on id.
1551 // Only change this if we want the raw key that was pressed,
1552 // and don't change it if we want an ASCII value.
1553 if (!isAscii
&& (id
>= 'a' && id
<= 'z'))
1555 id
= id
+ 'A' - 'a';
1558 wxevent
.m_shiftDown
= XKeyEventShiftIsDown(xevent
);
1559 wxevent
.m_controlDown
= XKeyEventCtrlIsDown(xevent
);
1560 wxevent
.m_altDown
= XKeyEventAltIsDown(xevent
);
1561 wxevent
.m_metaDown
= XKeyEventMetaIsDown(xevent
);
1562 wxevent
.SetEventObject(win
);
1563 wxevent
.m_keyCode
= id
;
1564 wxevent
.SetTimestamp(XKeyEventGetTime(xevent
));
1566 wxevent
.m_x
= XKeyEventGetX(xevent
);
1567 wxevent
.m_y
= XKeyEventGetY(xevent
);
1577 // ----------------------------------------------------------------------------
1579 // ----------------------------------------------------------------------------
1581 bool wxWindowX11::SetBackgroundColour(const wxColour
& col
)
1583 wxWindowBase::SetBackgroundColour(col
);
1585 Display
*xdisplay
= (Display
*) wxGlobalDisplay();
1586 int xscreen
= DefaultScreen( xdisplay
);
1587 Colormap cm
= DefaultColormap( xdisplay
, xscreen
);
1589 m_backgroundColour
.CalcPixel( (WXColormap
) cm
);
1591 // We don't set the background colour as we paint
1592 // the background ourselves.
1593 // XSetWindowBackground( xdisplay, (Window) m_clientWindow, m_backgroundColour.GetPixel() );
1598 bool wxWindowX11::SetForegroundColour(const wxColour
& col
)
1600 if ( !wxWindowBase::SetForegroundColour(col
) )
1606 // ----------------------------------------------------------------------------
1608 // ----------------------------------------------------------------------------
1610 wxWindow
*wxGetActiveWindow()
1613 wxFAIL_MSG(wxT("Not implemented"));
1618 wxWindow
*wxWindowBase::GetCapture()
1620 return (wxWindow
*)g_captureWindow
;
1624 // Find the wxWindow at the current mouse position, returning the mouse
1626 wxWindow
* wxFindWindowAtPointer(wxPoint
& pt
)
1628 return wxFindWindowAtPoint(wxGetMousePosition());
1631 // Get the current mouse position.
1632 wxPoint
wxGetMousePosition()
1636 return wxPoint(0, 0);
1638 Display
*display
= wxGlobalDisplay();
1639 Window rootWindow
= RootWindowOfScreen (DefaultScreenOfDisplay(display
));
1640 Window rootReturn
, childReturn
;
1641 int rootX
, rootY
, winX
, winY
;
1642 unsigned int maskReturn
;
1644 XQueryPointer (display
,
1648 &rootX
, &rootY
, &winX
, &winY
, &maskReturn
);
1649 return wxPoint(rootX
, rootY
);
1654 // ----------------------------------------------------------------------------
1655 // wxNoOptimize: switch off size optimization
1656 // ----------------------------------------------------------------------------
1658 int wxNoOptimize::ms_count
= 0;
1661 // ----------------------------------------------------------------------------
1663 // ----------------------------------------------------------------------------
1665 class wxWinModule
: public wxModule
1672 DECLARE_DYNAMIC_CLASS(wxWinModule
)
1675 IMPLEMENT_DYNAMIC_CLASS(wxWinModule
, wxModule
)
1677 bool wxWinModule::OnInit()
1679 Display
*xdisplay
= wxGlobalDisplay();
1680 int xscreen
= DefaultScreen( xdisplay
);
1681 Window xroot
= RootWindow( xdisplay
, xscreen
);
1682 g_eraseGC
= XCreateGC( xdisplay
, xroot
, 0, NULL
);
1683 XSetFillStyle( xdisplay
, g_eraseGC
, FillSolid
);
1688 void wxWinModule::OnExit()
1690 Display
*xdisplay
= wxGlobalDisplay();
1691 XFreeGC( xdisplay
, g_eraseGC
);