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__)
19 // ============================================================================
21 // ============================================================================
23 // ----------------------------------------------------------------------------
25 // ----------------------------------------------------------------------------
27 #include "wx/window.h"
36 #include "wx/dcclient.h"
40 #include "wx/layout.h"
41 #include "wx/dialog.h"
42 #include "wx/listbox.h"
43 #include "wx/button.h"
44 #include "wx/settings.h"
45 #include "wx/msgdlg.h"
47 #include "wx/scrolwin.h"
48 #include "wx/scrolbar.h"
49 #include "wx/module.h"
50 #include "wx/menuitem.h"
51 #include "wx/fontutil.h"
52 #include "wx/univ/renderer.h"
54 #if wxUSE_DRAG_AND_DROP
58 #include "wx/x11/private.h"
59 #include "X11/Xutil.h"
62 // For wxGetLocalTime, used by XButtonEventGetTime
68 // ----------------------------------------------------------------------------
69 // global variables for this module
70 // ----------------------------------------------------------------------------
72 static wxWindow
* g_captureWindow
= NULL
;
75 // ----------------------------------------------------------------------------
77 // ----------------------------------------------------------------------------
79 #define event_left_is_down(x) ((x)->xbutton.state & Button1Mask)
80 #define event_middle_is_down(x) ((x)->xbutton.state & Button2Mask)
81 #define event_right_is_down(x) ((x)->xbutton.state & Button3Mask)
83 // ----------------------------------------------------------------------------
85 // ----------------------------------------------------------------------------
87 IMPLEMENT_ABSTRACT_CLASS(wxWindowX11
, wxWindowBase
)
89 BEGIN_EVENT_TABLE(wxWindowX11
, wxWindowBase
)
90 EVT_SYS_COLOUR_CHANGED(wxWindowX11::OnSysColourChanged
)
93 // ============================================================================
95 // ============================================================================
97 // ----------------------------------------------------------------------------
99 // ----------------------------------------------------------------------------
101 // ----------------------------------------------------------------------------
103 // ----------------------------------------------------------------------------
105 void wxWindowX11::Init()
108 m_mainWindow
= (WXWindow
) 0;
109 m_clientWindow
= (WXWindow
) 0;
110 m_insertIntoMain
= false;
111 m_updateNcArea
= false;
113 m_winCaptured
= false;
114 m_needsInputFocus
= false;
120 // real construction (Init() must have been called before!)
121 bool wxWindowX11::Create(wxWindow
*parent
, wxWindowID id
,
125 const wxString
& name
)
127 wxCHECK_MSG( parent
, false, wxT("can't create wxWindow without parent") );
129 CreateBase(parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
);
131 parent
->AddChild(this);
133 Display
*xdisplay
= (Display
*) wxGlobalDisplay();
134 int xscreen
= DefaultScreen( xdisplay
);
135 Visual
*xvisual
= DefaultVisual( xdisplay
, xscreen
);
136 Colormap cm
= DefaultColormap( xdisplay
, xscreen
);
138 m_backgroundColour
= wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE
);
139 m_backgroundColour
.CalcPixel( (WXColormap
) cm
);
141 m_foregroundColour
= *wxBLACK
;
142 m_foregroundColour
.CalcPixel( (WXColormap
) cm
);
144 Window xparent
= (Window
) parent
->GetClientAreaWindow();
146 // Add window's own scrollbars to main window, not to client window
147 if (parent
->GetInsertIntoMain())
149 // wxLogDebug( "Inserted into main: %s", GetName().c_str() );
150 xparent
= (Window
) parent
->GetMainWindow();
153 // Size (not including the border) must be nonzero (or a Value error results)!
154 // Note: The Xlib manual doesn't mention this restriction of XCreateWindow.
162 if (pos2
.x
== wxDefaultCoord
)
164 if (pos2
.y
== wxDefaultCoord
)
167 #if wxUSE_TWO_WINDOWS
168 bool need_two_windows
=
169 ((( wxSUNKEN_BORDER
| wxRAISED_BORDER
| wxSIMPLE_BORDER
| wxHSCROLL
| wxVSCROLL
) & m_windowStyle
) != 0);
171 bool need_two_windows
= false;
175 long xattributes
= 0;
177 XSetWindowAttributes xattributes
;
178 long xattributes_mask
= 0;
180 xattributes_mask
|= CWBackPixel
;
181 xattributes
.background_pixel
= m_backgroundColour
.GetPixel();
183 xattributes_mask
|= CWBorderPixel
;
184 xattributes
.border_pixel
= BlackPixel( xdisplay
, xscreen
);
186 xattributes_mask
|= CWEventMask
;
189 if (need_two_windows
)
192 long backColor
, foreColor
;
193 backColor
= GR_RGB(m_backgroundColour
.Red(), m_backgroundColour
.Green(), m_backgroundColour
.Blue());
194 foreColor
= GR_RGB(m_foregroundColour
.Red(), m_foregroundColour
.Green(), m_foregroundColour
.Blue());
196 Window xwindow
= XCreateWindowWithColor( xdisplay
, xparent
, pos2
.x
, pos2
.y
, size2
.x
, size2
.y
,
197 0, 0, InputOutput
, xvisual
, backColor
, foreColor
);
198 XSelectInput( xdisplay
, xwindow
,
199 GR_EVENT_MASK_CLOSE_REQ
| ExposureMask
| KeyPressMask
| KeyReleaseMask
| ButtonPressMask
| ButtonReleaseMask
|
200 ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
|
201 KeymapStateMask
| FocusChangeMask
| ColormapChangeMask
| StructureNotifyMask
|
202 PropertyChangeMask
);
206 xattributes
.event_mask
=
207 ExposureMask
| StructureNotifyMask
| ColormapChangeMask
;
209 Window xwindow
= XCreateWindow( xdisplay
, xparent
, pos2
.x
, pos2
.y
, size2
.x
, size2
.y
,
210 0, DefaultDepth(xdisplay
,xscreen
), InputOutput
, xvisual
, xattributes_mask
, &xattributes
);
214 XSetWindowBackgroundPixmap( xdisplay
, xwindow
, None
);
216 m_mainWindow
= (WXWindow
) xwindow
;
217 wxAddWindowToTable( xwindow
, (wxWindow
*) this );
219 XMapWindow( xdisplay
, xwindow
);
222 xattributes
.event_mask
=
223 ExposureMask
| KeyPressMask
| KeyReleaseMask
| ButtonPressMask
| ButtonReleaseMask
|
224 ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
|
225 KeymapStateMask
| FocusChangeMask
| ColormapChangeMask
| StructureNotifyMask
|
226 PropertyChangeMask
| VisibilityChangeMask
;
228 if (!HasFlag( wxFULL_REPAINT_ON_RESIZE
))
230 xattributes_mask
|= CWBitGravity
;
231 xattributes
.bit_gravity
= StaticGravity
;
235 if (HasFlag( wxSUNKEN_BORDER
) || HasFlag( wxRAISED_BORDER
))
242 else if (HasFlag( wxSIMPLE_BORDER
))
255 // Make again sure the size is nonzero.
262 backColor
= GR_RGB(m_backgroundColour
.Red(), m_backgroundColour
.Green(), m_backgroundColour
.Blue());
263 foreColor
= GR_RGB(m_foregroundColour
.Red(), m_foregroundColour
.Green(), m_foregroundColour
.Blue());
265 xwindow
= XCreateWindowWithColor( xdisplay
, xwindow
, pos2
.x
, pos2
.y
, size2
.x
, size2
.y
,
266 0, 0, InputOutput
, xvisual
, backColor
, foreColor
);
267 XSelectInput( xdisplay
, xwindow
,
268 GR_EVENT_MASK_CLOSE_REQ
| ExposureMask
| KeyPressMask
| KeyReleaseMask
| ButtonPressMask
| ButtonReleaseMask
|
269 ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
|
270 KeymapStateMask
| FocusChangeMask
| ColormapChangeMask
| StructureNotifyMask
|
271 PropertyChangeMask
);
274 xwindow
= XCreateWindow( xdisplay
, xwindow
, pos2
.x
, pos2
.y
, size2
.x
, size2
.y
,
275 0, DefaultDepth(xdisplay
,xscreen
), InputOutput
, xvisual
, xattributes_mask
, &xattributes
);
278 XSetWindowBackgroundPixmap( xdisplay
, xwindow
, None
);
280 m_clientWindow
= (WXWindow
) xwindow
;
281 wxAddClientWindowToTable( xwindow
, (wxWindow
*) this );
283 XMapWindow( xdisplay
, xwindow
);
287 // wxLogDebug( "No two windows needed %s", GetName().c_str() );
289 long backColor
, foreColor
;
290 backColor
= GR_RGB(m_backgroundColour
.Red(), m_backgroundColour
.Green(), m_backgroundColour
.Blue());
291 foreColor
= GR_RGB(m_foregroundColour
.Red(), m_foregroundColour
.Green(), m_foregroundColour
.Blue());
293 Window xwindow
= XCreateWindowWithColor( xdisplay
, xparent
, pos2
.x
, pos2
.y
, size2
.x
, size2
.y
,
294 0, 0, InputOutput
, xvisual
, backColor
, foreColor
);
295 XSelectInput( xdisplay
, xwindow
,
296 GR_EVENT_MASK_CLOSE_REQ
| ExposureMask
| KeyPressMask
| KeyReleaseMask
| ButtonPressMask
| ButtonReleaseMask
|
297 ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
|
298 KeymapStateMask
| FocusChangeMask
| ColormapChangeMask
| StructureNotifyMask
|
299 PropertyChangeMask
);
302 xattributes
.event_mask
=
303 ExposureMask
| KeyPressMask
| KeyReleaseMask
| ButtonPressMask
| ButtonReleaseMask
|
304 ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
|
305 KeymapStateMask
| FocusChangeMask
| ColormapChangeMask
| StructureNotifyMask
|
306 PropertyChangeMask
| VisibilityChangeMask
;
308 if (!HasFlag( wxFULL_REPAINT_ON_RESIZE
))
310 xattributes_mask
|= CWBitGravity
;
311 xattributes
.bit_gravity
= NorthWestGravity
;
314 Window xwindow
= XCreateWindow( xdisplay
, xparent
, pos2
.x
, pos2
.y
, size2
.x
, size2
.y
,
315 0, DefaultDepth(xdisplay
,xscreen
), InputOutput
, xvisual
, xattributes_mask
, &xattributes
);
318 XSetWindowBackgroundPixmap( xdisplay
, xwindow
, None
);
320 m_mainWindow
= (WXWindow
) xwindow
;
321 m_clientWindow
= m_mainWindow
;
322 wxAddWindowToTable( xwindow
, (wxWindow
*) this );
324 XMapWindow( xdisplay
, xwindow
);
327 // Is a subwindow, so map immediately
330 // Without this, the cursor may not be restored properly (e.g. in splitter
332 SetCursor(*wxSTANDARD_CURSOR
);
333 SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
));
335 // Don't call this, it can have nasty repercussions for composite controls,
337 // SetSize(pos.x, pos.y, size.x, size.y);
343 wxWindowX11::~wxWindowX11()
347 if (g_captureWindow
== this)
348 g_captureWindow
= NULL
;
350 m_isBeingDeleted
= true;
354 if (m_clientWindow
!= m_mainWindow
)
356 // Destroy the cleint window
357 Window xwindow
= (Window
) m_clientWindow
;
358 wxDeleteClientWindowFromTable( xwindow
);
359 XDestroyWindow( wxGlobalDisplay(), xwindow
);
360 m_clientWindow
= NULL
;
363 // Destroy the window
364 Window xwindow
= (Window
) m_mainWindow
;
365 wxDeleteWindowFromTable( xwindow
);
366 XDestroyWindow( wxGlobalDisplay(), xwindow
);
370 // ---------------------------------------------------------------------------
372 // ---------------------------------------------------------------------------
374 void wxWindowX11::SetFocus()
376 Window xwindow
= (Window
) m_clientWindow
;
378 wxCHECK_RET( xwindow
, wxT("invalid window") );
380 // Don't assert; we might be trying to set the focus for a panel
381 // with only static controls, so the panel returns false from AcceptsFocus.
382 // The app should be not be expected to deal with this.
387 if (GetName() == "scrollBar")
394 if (wxWindowIsVisible(xwindow
))
396 wxLogTrace( _T("focus"), _T("wxWindowX11::SetFocus: %s"), GetClassInfo()->GetClassName());
397 // XSetInputFocus( wxGlobalDisplay(), xwindow, RevertToParent, CurrentTime );
398 XSetInputFocus( wxGlobalDisplay(), xwindow
, RevertToNone
, CurrentTime
);
399 m_needsInputFocus
= false;
403 m_needsInputFocus
= true;
407 // Get the window with the focus
408 wxWindow
*wxWindowBase::DoFindFocus()
410 Window xfocus
= (Window
) 0;
413 XGetInputFocus( wxGlobalDisplay(), &xfocus
, &revert
);
416 wxWindow
*win
= wxGetWindowFromTable( xfocus
);
419 win
= wxGetClientWindowFromTable( xfocus
);
428 // Enabling/disabling handled by event loop, and not sending events
430 bool wxWindowX11::Enable(bool enable
)
432 if ( !wxWindowBase::Enable(enable
) )
438 bool wxWindowX11::Show(bool show
)
440 wxWindowBase::Show(show
);
442 Window xwindow
= (Window
) m_mainWindow
;
443 Display
*xdisp
= wxGlobalDisplay();
446 // wxLogDebug( "Mapping window of type %s", GetName().c_str() );
447 XMapWindow(xdisp
, xwindow
);
451 // wxLogDebug( "Unmapping window of type %s", GetName().c_str() );
452 XUnmapWindow(xdisp
, xwindow
);
458 // Raise the window to the top of the Z order
459 void wxWindowX11::Raise()
462 XRaiseWindow( wxGlobalDisplay(), (Window
) m_mainWindow
);
465 // Lower the window to the bottom of the Z order
466 void wxWindowX11::Lower()
469 XLowerWindow( wxGlobalDisplay(), (Window
) m_mainWindow
);
472 void wxWindowX11::SetLabel(const wxString
& WXUNUSED(label
))
477 wxString
wxWindowX11::GetLabel() const
480 return wxEmptyString
;
483 void wxWindowX11::DoCaptureMouse()
485 if ((g_captureWindow
!= NULL
) && (g_captureWindow
!= this))
487 wxASSERT_MSG(false, wxT("Trying to capture before mouse released."));
498 Window xwindow
= (Window
) m_clientWindow
;
500 wxCHECK_RET( xwindow
, wxT("invalid window") );
502 g_captureWindow
= (wxWindow
*) this;
506 int res
= XGrabPointer(wxGlobalDisplay(), xwindow
,
508 ButtonPressMask
| ButtonReleaseMask
| ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
,
512 None
, /* cursor */ // TODO: This may need to be set to the cursor of this window
515 if (res
!= GrabSuccess
)
518 msg
.Printf(wxT("Failed to grab pointer for window %s"), this->GetClassInfo()->GetClassName());
520 if (res
== GrabNotViewable
)
521 wxLogDebug( wxT("This is not a viewable window - perhaps not shown yet?") );
523 g_captureWindow
= NULL
;
527 m_winCaptured
= true;
531 void wxWindowX11::DoReleaseMouse()
533 g_captureWindow
= NULL
;
535 if ( !m_winCaptured
)
538 Window xwindow
= (Window
) m_clientWindow
;
542 XUngrabPointer( wxGlobalDisplay(), CurrentTime
);
545 // wxLogDebug( "Ungrabbed pointer in %s", GetName().c_str() );
547 m_winCaptured
= false;
550 bool wxWindowX11::SetFont(const wxFont
& font
)
552 if ( !wxWindowBase::SetFont(font
) )
561 bool wxWindowX11::SetCursor(const wxCursor
& cursor
)
563 if ( !wxWindowBase::SetCursor(cursor
) )
569 Window xwindow
= (Window
) m_clientWindow
;
571 wxCHECK_MSG( xwindow
, false, wxT("invalid window") );
573 wxCursor cursorToUse
;
575 cursorToUse
= m_cursor
;
577 cursorToUse
= *wxSTANDARD_CURSOR
;
579 Cursor xcursor
= (Cursor
) cursorToUse
.GetCursor();
581 XDefineCursor( wxGlobalDisplay(), xwindow
, xcursor
);
586 // Coordinates relative to the window
587 void wxWindowX11::WarpPointer (int x
, int y
)
589 Window xwindow
= (Window
) m_clientWindow
;
591 wxCHECK_RET( xwindow
, wxT("invalid window") );
593 XWarpPointer( wxGlobalDisplay(), None
, xwindow
, 0, 0, 0, 0, x
, y
);
596 // Does a physical scroll
597 void wxWindowX11::ScrollWindow(int dx
, int dy
, const wxRect
*rect
)
599 // No scrolling requested.
600 if ((dx
== 0) && (dy
== 0)) return;
602 if (!m_updateRegion
.IsEmpty())
604 m_updateRegion
.Offset( dx
, dy
);
608 GetSize( &cw
, &ch
); // GetClientSize() ??
609 m_updateRegion
.Intersect( 0, 0, cw
, ch
);
612 if (!m_clearRegion
.IsEmpty())
614 m_clearRegion
.Offset( dx
, dy
);
618 GetSize( &cw
, &ch
); // GetClientSize() ??
619 m_clearRegion
.Intersect( 0, 0, cw
, ch
);
622 Window xwindow
= (Window
) GetClientAreaWindow();
624 wxCHECK_RET( xwindow
, wxT("invalid window") );
626 Display
*xdisplay
= wxGlobalDisplay();
628 GC xgc
= XCreateGC( xdisplay
, xwindow
, 0, NULL
);
629 XSetGraphicsExposures( xdisplay
, xgc
, True
);
647 GetClientSize( &cw
, &ch
);
650 #if wxUSE_TWO_WINDOWS
651 wxPoint
offset( 0,0 );
653 wxPoint offset
= GetClientAreaOrigin();
658 int w
= cw
- abs(dx
);
659 int h
= ch
- abs(dy
);
661 if ((h
< 0) || (w
< 0))
668 if (dx
< 0) rect
.x
= cw
+dx
+ offset
.x
; else rect
.x
= s_x
;
669 if (dy
< 0) rect
.y
= ch
+dy
+ offset
.y
; else rect
.y
= s_y
;
670 if (dy
!= 0) rect
.width
= cw
; else rect
.width
= abs(dx
);
671 if (dx
!= 0) rect
.height
= ch
; else rect
.height
= abs(dy
);
676 if (dx
< 0) s_x
+= -dx
;
677 if (dy
< 0) s_y
+= -dy
;
678 if (dx
> 0) d_x
= dx
+ offset
.x
;
679 if (dy
> 0) d_y
= dy
+ offset
.y
;
681 XCopyArea( xdisplay
, xwindow
, xwindow
, xgc
, s_x
, s_y
, w
, h
, d_x
, d_y
);
683 // 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 );
685 // wxLogDebug( "Update: %d %d %d %d", rect.x, rect.y, rect.width, rect.height );
687 m_updateRegion
.Union( rect
);
688 m_clearRegion
.Union( rect
);
691 XFreeGC( xdisplay
, xgc
);
693 // Move Clients, but not the scrollbars
694 // FIXME: There may be a better method to move a lot of Windows within X11
695 wxScrollBar
*sbH
= ((wxWindow
*) this)->GetScrollbar( wxHORIZONTAL
);
696 wxScrollBar
*sbV
= ((wxWindow
*) this)->GetScrollbar( wxVERTICAL
);
697 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
700 // Only propagate to non-top-level windows
701 wxWindow
*win
= node
->GetData();
702 if ( win
->GetParent() && win
!= sbH
&& win
!= sbV
)
704 wxPoint pos
= win
->GetPosition();
705 // Add the delta to the old Position
708 win
->SetPosition(pos
);
710 node
= node
->GetNext();
714 // ---------------------------------------------------------------------------
716 // ---------------------------------------------------------------------------
718 #if wxUSE_DRAG_AND_DROP
720 void wxWindowX11::SetDropTarget(wxDropTarget
* WXUNUSED(pDropTarget
))
727 // Old style file-manager drag&drop
728 void wxWindowX11::DragAcceptFiles(bool WXUNUSED(accept
))
733 // ----------------------------------------------------------------------------
735 // ----------------------------------------------------------------------------
739 void wxWindowX11::DoSetToolTip(wxToolTip
* WXUNUSED(tooltip
))
744 #endif // wxUSE_TOOLTIPS
746 // ---------------------------------------------------------------------------
747 // moving and resizing
748 // ---------------------------------------------------------------------------
750 bool wxWindowX11::PreResize()
756 void wxWindowX11::DoGetSize(int *x
, int *y
) const
758 Window xwindow
= (Window
) m_mainWindow
;
760 wxCHECK_RET( xwindow
, wxT("invalid window") );
762 //XSync(wxGlobalDisplay(), False);
764 XWindowAttributes attr
;
765 Status status
= XGetWindowAttributes( wxGlobalDisplay(), xwindow
, &attr
);
770 *x
= attr
.width
/* + 2*m_borderSize */ ;
771 *y
= attr
.height
/* + 2*m_borderSize */ ;
775 void wxWindowX11::DoGetPosition(int *x
, int *y
) const
777 Window window
= (Window
) m_mainWindow
;
780 //XSync(wxGlobalDisplay(), False);
781 XWindowAttributes attr
;
782 Status status
= XGetWindowAttributes(wxGlobalDisplay(), window
, & attr
);
790 // We may be faking the client origin. So a window that's really at (0, 30)
791 // may appear (to wxWin apps) to be at (0, 0).
794 wxPoint
pt(GetParent()->GetClientAreaOrigin());
802 void wxWindowX11::DoScreenToClient(int *x
, int *y
) const
804 Display
*display
= wxGlobalDisplay();
805 Window rootWindow
= RootWindowOfScreen(DefaultScreenOfDisplay(display
));
806 Window thisWindow
= (Window
) m_clientWindow
;
811 XTranslateCoordinates(display
, rootWindow
, thisWindow
, xx
, yy
, x
, y
, &childWindow
);
814 void wxWindowX11::DoClientToScreen(int *x
, int *y
) const
816 Display
*display
= wxGlobalDisplay();
817 Window rootWindow
= RootWindowOfScreen(DefaultScreenOfDisplay(display
));
818 Window thisWindow
= (Window
) m_clientWindow
;
823 XTranslateCoordinates(display
, thisWindow
, rootWindow
, xx
, yy
, x
, y
, &childWindow
);
827 // Get size *available for subwindows* i.e. excluding menu bar etc.
828 void wxWindowX11::DoGetClientSize(int *x
, int *y
) const
830 Window window
= (Window
) m_mainWindow
;
834 XWindowAttributes attr
;
835 Status status
= XGetWindowAttributes( wxGlobalDisplay(), window
, &attr
);
846 void wxWindowX11::DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
848 // wxLogDebug("DoSetSize: %s (%ld) %d, %d %dx%d", GetClassInfo()->GetClassName(), GetId(), x, y, width, height);
850 Window xwindow
= (Window
) m_mainWindow
;
852 wxCHECK_RET( xwindow
, wxT("invalid window") );
854 XWindowAttributes attr
;
855 Status status
= XGetWindowAttributes( wxGlobalDisplay(), xwindow
, &attr
);
856 wxCHECK_RET( status
, wxT("invalid window attributes") );
860 int new_w
= attr
.width
;
861 int new_h
= attr
.height
;
863 if (x
!= wxDefaultCoord
|| (sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
866 AdjustForParentClientOrigin( x
, yy
, sizeFlags
);
869 if (y
!= wxDefaultCoord
|| (sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
872 AdjustForParentClientOrigin( xx
, y
, sizeFlags
);
875 if (width
!= wxDefaultCoord
)
881 if (height
!= wxDefaultCoord
)
888 DoMoveWindow( new_x
, new_y
, new_w
, new_h
);
891 void wxWindowX11::DoSetClientSize(int width
, int height
)
893 // wxLogDebug("DoSetClientSize: %s (%ld) %dx%d", GetClassInfo()->GetClassName(), GetId(), width, height);
895 Window xwindow
= (Window
) m_mainWindow
;
897 wxCHECK_RET( xwindow
, wxT("invalid window") );
899 XResizeWindow( wxGlobalDisplay(), xwindow
, width
, height
);
901 if (m_mainWindow
!= m_clientWindow
)
903 xwindow
= (Window
) m_clientWindow
;
905 wxWindow
*window
= (wxWindow
*) this;
906 wxRenderer
*renderer
= window
->GetRenderer();
909 wxRect border
= renderer
->GetBorderDimensions( (wxBorder
)(m_windowStyle
& wxBORDER_MASK
) );
910 width
-= border
.x
+ border
.width
;
911 height
-= border
.y
+ border
.height
;
914 XResizeWindow( wxGlobalDisplay(), xwindow
, width
, height
);
918 void wxWindowX11::DoMoveWindow(int x
, int y
, int width
, int height
)
920 Window xwindow
= (Window
) m_mainWindow
;
922 wxCHECK_RET( xwindow
, wxT("invalid window") );
926 XMoveResizeWindow( wxGlobalDisplay(), xwindow
, x
, y
, width
, height
);
927 if (m_mainWindow
!= m_clientWindow
)
929 xwindow
= (Window
) m_clientWindow
;
931 wxWindow
*window
= (wxWindow
*) this;
932 wxRenderer
*renderer
= window
->GetRenderer();
935 wxRect border
= renderer
->GetBorderDimensions( (wxBorder
)(m_windowStyle
& wxBORDER_MASK
) );
938 width
-= border
.x
+ border
.width
;
939 height
-= border
.y
+ border
.height
;
947 wxScrollBar
*sb
= window
->GetScrollbar( wxHORIZONTAL
);
948 if (sb
&& sb
->IsShown())
950 wxSize size
= sb
->GetSize();
953 sb
= window
->GetScrollbar( wxVERTICAL
);
954 if (sb
&& sb
->IsShown())
956 wxSize size
= sb
->GetSize();
960 XMoveResizeWindow( wxGlobalDisplay(), xwindow
, x
, y
, wxMax(1, width
), wxMax(1, height
) );
965 XWindowChanges windowChanges
;
968 windowChanges
.width
= width
;
969 windowChanges
.height
= height
;
970 windowChanges
.stack_mode
= 0;
971 int valueMask
= CWX
| CWY
| CWWidth
| CWHeight
;
973 XConfigureWindow( wxGlobalDisplay(), xwindow
, valueMask
, &windowChanges
);
978 void wxWindowX11::DoSetSizeHints(int minW
, int minH
, int maxW
, int maxH
, int incW
, int incH
)
986 XSizeHints sizeHints
;
989 if (minW
> -1 && minH
> -1)
991 sizeHints
.flags
|= PMinSize
;
992 sizeHints
.min_width
= minW
;
993 sizeHints
.min_height
= minH
;
995 if (maxW
> -1 && maxH
> -1)
997 sizeHints
.flags
|= PMaxSize
;
998 sizeHints
.max_width
= maxW
;
999 sizeHints
.max_height
= maxH
;
1001 if (incW
> -1 && incH
> -1)
1003 sizeHints
.flags
|= PResizeInc
;
1004 sizeHints
.width_inc
= incW
;
1005 sizeHints
.height_inc
= incH
;
1008 XSetWMNormalHints(wxGlobalDisplay(), (Window
) m_mainWindow
, &sizeHints
);
1012 // ---------------------------------------------------------------------------
1014 // ---------------------------------------------------------------------------
1016 int wxWindowX11::GetCharHeight() const
1018 wxFont
font(GetFont());
1019 wxCHECK_MSG( font
.Ok(), 0, wxT("valid window font needed") );
1022 // There should be an easier way.
1023 PangoLayout
*layout
= pango_layout_new( wxTheApp
->GetPangoContext() );
1024 pango_layout_set_font_description( layout
, font
.GetNativeFontInfo()->description
);
1025 pango_layout_set_text(layout
, "H", 1 );
1027 pango_layout_get_pixel_size(layout
, &w
, &h
);
1028 g_object_unref( G_OBJECT( layout
) );
1032 WXFontStructPtr pFontStruct
= font
.GetFontStruct(1.0, wxGlobalDisplay());
1034 int direction
, ascent
, descent
;
1035 XCharStruct overall
;
1036 XTextExtents ((XFontStruct
*) pFontStruct
, "x", 1, &direction
, &ascent
,
1037 &descent
, &overall
);
1039 // return (overall.ascent + overall.descent);
1040 return (ascent
+ descent
);
1044 int wxWindowX11::GetCharWidth() const
1046 wxFont
font(GetFont());
1047 wxCHECK_MSG( font
.Ok(), 0, wxT("valid window font needed") );
1050 // There should be an easier way.
1051 PangoLayout
*layout
= pango_layout_new( wxTheApp
->GetPangoContext() );
1052 pango_layout_set_font_description( layout
, font
.GetNativeFontInfo()->description
);
1053 pango_layout_set_text(layout
, "H", 1 );
1055 pango_layout_get_pixel_size(layout
, &w
, &h
);
1056 g_object_unref( G_OBJECT( layout
) );
1060 WXFontStructPtr pFontStruct
= font
.GetFontStruct(1.0, wxGlobalDisplay());
1062 int direction
, ascent
, descent
;
1063 XCharStruct overall
;
1064 XTextExtents ((XFontStruct
*) pFontStruct
, "x", 1, &direction
, &ascent
,
1065 &descent
, &overall
);
1067 return overall
.width
;
1071 void wxWindowX11::GetTextExtent(const wxString
& string
,
1073 int *descent
, int *externalLeading
,
1074 const wxFont
*theFont
) const
1076 wxFont fontToUse
= GetFont();
1077 if (theFont
) fontToUse
= *theFont
;
1079 wxCHECK_RET( fontToUse
.Ok(), wxT("invalid font") );
1089 PangoLayout
*layout
= pango_layout_new( wxTheApp
->GetPangoContext() );
1091 PangoFontDescription
*desc
= fontToUse
.GetNativeFontInfo()->description
;
1092 pango_layout_set_font_description(layout
, desc
);
1094 const wxCharBuffer data
= wxConvUTF8
.cWC2MB( string
);
1095 pango_layout_set_text(layout
, (const char*) data
, strlen( (const char*) data
));
1097 PangoLayoutLine
*line
= (PangoLayoutLine
*)pango_layout_get_lines(layout
)->data
;
1100 PangoRectangle rect
;
1101 pango_layout_line_get_extents(line
, NULL
, &rect
);
1103 if (x
) (*x
) = (wxCoord
) (rect
.width
/ PANGO_SCALE
);
1104 if (y
) (*y
) = (wxCoord
) (rect
.height
/ PANGO_SCALE
);
1107 // Do something about metrics here
1110 if (externalLeading
) (*externalLeading
) = 0; // ??
1112 g_object_unref( G_OBJECT( layout
) );
1114 WXFontStructPtr pFontStruct
= fontToUse
.GetFontStruct(1.0, wxGlobalDisplay());
1116 int direction
, ascent
, descent2
;
1117 XCharStruct overall
;
1118 int slen
= string
.Len();
1120 XTextExtents((XFontStruct
*) pFontStruct
, (char*) string
.c_str(), slen
,
1121 &direction
, &ascent
, &descent2
, &overall
);
1124 *x
= (overall
.width
);
1126 *y
= (ascent
+ descent2
);
1128 *descent
= descent2
;
1129 if (externalLeading
)
1130 *externalLeading
= 0;
1134 // ----------------------------------------------------------------------------
1136 // ----------------------------------------------------------------------------
1138 void wxWindowX11::Refresh(bool eraseBack
, const wxRect
*rect
)
1144 // Schedule for later Updating in ::Update() or ::OnInternalIdle().
1145 m_clearRegion
.Union( rect
->x
, rect
->y
, rect
->width
, rect
->height
);
1150 GetSize( &width
, &height
);
1152 // Schedule for later Updating in ::Update() or ::OnInternalIdle().
1153 m_clearRegion
.Clear();
1154 m_clearRegion
.Union( 0, 0, width
, height
);
1160 // Schedule for later Updating in ::Update() or ::OnInternalIdle().
1161 m_updateRegion
.Union( rect
->x
, rect
->y
, rect
->width
, rect
->height
);
1166 GetSize( &width
, &height
);
1168 // Schedule for later Updating in ::Update() or ::OnInternalIdle().
1169 m_updateRegion
.Clear();
1170 m_updateRegion
.Union( 0, 0, width
, height
);
1174 void wxWindowX11::Update()
1178 // wxLogDebug("wxWindowX11::UpdateNC: %s", GetClassInfo()->GetClassName());
1179 // Send nc paint events.
1180 SendNcPaintEvents();
1183 if (!m_updateRegion
.IsEmpty())
1185 // wxLogDebug("wxWindowX11::Update: %s", GetClassInfo()->GetClassName());
1186 // Actually send erase events.
1189 // Actually send paint events.
1194 void wxWindowX11::SendEraseEvents()
1196 if (m_clearRegion
.IsEmpty()) return;
1198 wxClientDC
dc( (wxWindow
*)this );
1199 dc
.SetClippingRegion( m_clearRegion
);
1201 wxEraseEvent
erase_event( GetId(), &dc
);
1202 erase_event
.SetEventObject( this );
1204 if (!GetEventHandler()->ProcessEvent(erase_event
) )
1206 Display
*xdisplay
= wxGlobalDisplay();
1207 Window xwindow
= (Window
) GetClientAreaWindow();
1208 XSetForeground( xdisplay
, g_eraseGC
, m_backgroundColour
.GetPixel() );
1210 wxRegionIterator
upd( m_clearRegion
);
1213 XFillRectangle( xdisplay
, xwindow
, g_eraseGC
,
1214 upd
.GetX(), upd
.GetY(), upd
.GetWidth(), upd
.GetHeight() );
1219 m_clearRegion
.Clear();
1222 void wxWindowX11::SendPaintEvents()
1224 // wxLogDebug("SendPaintEvents: %s (%ld)", GetClassInfo()->GetClassName(), GetId());
1226 m_clipPaintRegion
= true;
1228 wxPaintEvent
paint_event( GetId() );
1229 paint_event
.SetEventObject( this );
1230 GetEventHandler()->ProcessEvent( paint_event
);
1232 m_updateRegion
.Clear();
1234 m_clipPaintRegion
= false;
1237 void wxWindowX11::SendNcPaintEvents()
1239 wxWindow
*window
= (wxWindow
*) this;
1241 // All this for drawing the small square between the scrollbars.
1246 wxScrollBar
*sb
= window
->GetScrollbar( wxHORIZONTAL
);
1247 if (sb
&& sb
->IsShown())
1249 height
= sb
->GetSize().y
;
1250 y
= sb
->GetPosition().y
;
1252 sb
= window
->GetScrollbar( wxVERTICAL
);
1253 if (sb
&& sb
->IsShown())
1255 width
= sb
->GetSize().x
;
1256 x
= sb
->GetPosition().x
;
1258 Display
*xdisplay
= wxGlobalDisplay();
1259 Window xwindow
= (Window
) GetMainWindow();
1260 Colormap cm
= (Colormap
) wxTheApp
->GetMainColormap( wxGetDisplay() );
1261 wxColour colour
= wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
);
1262 colour
.CalcPixel( (WXColormap
) cm
);
1264 XSetForeground( xdisplay
, g_eraseGC
, colour
.GetPixel() );
1266 XFillRectangle( xdisplay
, xwindow
, g_eraseGC
, x
, y
, width
, height
);
1270 wxNcPaintEvent
nc_paint_event( GetId() );
1271 nc_paint_event
.SetEventObject( this );
1272 GetEventHandler()->ProcessEvent( nc_paint_event
);
1274 m_updateNcArea
= false;
1277 // ----------------------------------------------------------------------------
1279 // ----------------------------------------------------------------------------
1281 // Responds to colour changes: passes event on to children.
1282 void wxWindowX11::OnSysColourChanged(wxSysColourChangedEvent
& event
)
1284 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
1287 // Only propagate to non-top-level windows
1288 wxWindow
*win
= node
->GetData();
1289 if ( win
->GetParent() )
1291 wxSysColourChangedEvent event2
;
1292 event
.SetEventObject(win
);
1293 win
->GetEventHandler()->ProcessEvent(event2
);
1296 node
= node
->GetNext();
1300 // See handler for InFocus case in app.cpp for details.
1301 wxWindow
* g_GettingFocus
= NULL
;
1303 void wxWindowX11::OnInternalIdle()
1305 // Update invalidated regions.
1308 // This calls the UI-update mechanism (querying windows for
1309 // menu/toolbar/control state information)
1310 if (wxUpdateUIEvent::CanUpdate((wxWindow
*) this))
1311 UpdateWindowUI(wxUPDATE_UI_FROMIDLE
);
1313 // Set the input focus if couldn't do it before
1314 if (m_needsInputFocus
)
1318 msg
.Printf("Setting focus for %s from OnInternalIdle\n", GetClassInfo()->GetClassName());
1319 printf(msg
.c_str());
1323 // If it couldn't set the focus now, there's
1324 // no point in trying again.
1325 m_needsInputFocus
= false;
1327 g_GettingFocus
= NULL
;
1330 // ----------------------------------------------------------------------------
1331 // function which maintain the global hash table mapping Widgets to wxWidgets
1332 // ----------------------------------------------------------------------------
1334 static bool DoAddWindowToTable(wxWindowHash
*hash
, Window w
, wxWindow
*win
)
1336 if ( !hash
->insert(wxWindowHash::value_type(w
, win
)).second
)
1338 wxLogDebug( wxT("Widget table clash: new widget is 0x%08x, %s"),
1339 (unsigned int)w
, win
->GetClassInfo()->GetClassName());
1343 wxLogTrace( wxT("widget"), wxT("XWindow 0x%08x <-> window %p (%s)"),
1344 (unsigned int) w
, win
, win
->GetClassInfo()->GetClassName());
1349 static inline wxWindow
*DoGetWindowFromTable(wxWindowHash
*hash
, Window w
)
1351 wxWindowHash::iterator i
= hash
->find(w
);
1352 return i
== hash
->end() ? NULL
: i
->second
;
1355 static inline void DoDeleteWindowFromTable(wxWindowHash
*hash
, Window w
)
1357 wxLogTrace( wxT("widget"), wxT("XWindow 0x%08x deleted"), (unsigned int) w
);
1362 // ----------------------------------------------------------------------------
1364 // ----------------------------------------------------------------------------
1366 bool wxAddWindowToTable(Window w
, wxWindow
*win
)
1368 return DoAddWindowToTable(wxWidgetHashTable
, w
, win
);
1371 wxWindow
*wxGetWindowFromTable(Window w
)
1373 return DoGetWindowFromTable(wxWidgetHashTable
, w
);
1376 void wxDeleteWindowFromTable(Window w
)
1378 DoDeleteWindowFromTable(wxWidgetHashTable
, w
);
1381 bool wxAddClientWindowToTable(Window w
, wxWindow
*win
)
1383 return DoAddWindowToTable(wxClientWidgetHashTable
, w
, win
);
1386 wxWindow
*wxGetClientWindowFromTable(Window w
)
1388 return DoGetWindowFromTable(wxClientWidgetHashTable
, w
);
1391 void wxDeleteClientWindowFromTable(Window w
)
1393 DoDeleteWindowFromTable(wxClientWidgetHashTable
, w
);
1396 // ----------------------------------------------------------------------------
1397 // X11-specific accessors
1398 // ----------------------------------------------------------------------------
1400 WXWindow
wxWindowX11::GetMainWindow() const
1402 return m_mainWindow
;
1405 WXWindow
wxWindowX11::GetClientAreaWindow() const
1407 return m_clientWindow
;
1410 // ----------------------------------------------------------------------------
1411 // TranslateXXXEvent() functions
1412 // ----------------------------------------------------------------------------
1414 bool wxTranslateMouseEvent(wxMouseEvent
& wxevent
, wxWindow
*win
, Window window
, XEvent
*xevent
)
1416 switch (XEventGetType(xevent
))
1424 wxEventType eventType
= wxEVT_NULL
;
1426 if (XEventGetType(xevent
) == EnterNotify
)
1428 //if (local_event.xcrossing.mode!=NotifyNormal)
1429 // return ; // Ignore grab events
1430 eventType
= wxEVT_ENTER_WINDOW
;
1431 // canvas->GetEventHandler()->OnSetFocus();
1433 else if (XEventGetType(xevent
) == LeaveNotify
)
1435 //if (local_event.xcrossingr.mode!=NotifyNormal)
1436 // return ; // Ignore grab events
1437 eventType
= wxEVT_LEAVE_WINDOW
;
1438 // canvas->GetEventHandler()->OnKillFocus();
1440 else if (XEventGetType(xevent
) == MotionNotify
)
1442 eventType
= wxEVT_MOTION
;
1444 else if (XEventGetType(xevent
) == ButtonPress
)
1446 wxevent
.SetTimestamp(XButtonEventGetTime(xevent
));
1448 if (XButtonEventLChanged(xevent
))
1450 eventType
= wxEVT_LEFT_DOWN
;
1453 else if (XButtonEventMChanged(xevent
))
1455 eventType
= wxEVT_MIDDLE_DOWN
;
1458 else if (XButtonEventRChanged(xevent
))
1460 eventType
= wxEVT_RIGHT_DOWN
;
1464 // check for a double click
1465 // TODO: where can we get this value from?
1466 //long dclickTime = XtGetMultiClickTime(wxGlobalDisplay());
1467 long dclickTime
= 200;
1468 long ts
= wxevent
.GetTimestamp();
1470 int buttonLast
= win
->GetLastClickedButton();
1471 long lastTS
= win
->GetLastClickTime();
1472 if ( buttonLast
&& buttonLast
== button
&& (ts
- lastTS
) < dclickTime
)
1475 win
->SetLastClick(0, ts
);
1476 if ( eventType
== wxEVT_LEFT_DOWN
)
1477 eventType
= wxEVT_LEFT_DCLICK
;
1478 else if ( eventType
== wxEVT_MIDDLE_DOWN
)
1479 eventType
= wxEVT_MIDDLE_DCLICK
;
1480 else if ( eventType
== wxEVT_RIGHT_DOWN
)
1481 eventType
= wxEVT_RIGHT_DCLICK
;
1485 // not fast enough or different button
1486 win
->SetLastClick(button
, ts
);
1489 else if (XEventGetType(xevent
) == ButtonRelease
)
1491 if (XButtonEventLChanged(xevent
))
1493 eventType
= wxEVT_LEFT_UP
;
1495 else if (XButtonEventMChanged(xevent
))
1497 eventType
= wxEVT_MIDDLE_UP
;
1499 else if (XButtonEventRChanged(xevent
))
1501 eventType
= wxEVT_RIGHT_UP
;
1510 wxevent
.SetEventType(eventType
);
1512 wxevent
.m_x
= XButtonEventGetX(xevent
);
1513 wxevent
.m_y
= XButtonEventGetY(xevent
);
1515 wxevent
.m_leftDown
= ((eventType
== wxEVT_LEFT_DOWN
)
1516 || (XButtonEventLIsDown(xevent
)
1517 && (eventType
!= wxEVT_LEFT_UP
)));
1518 wxevent
.m_middleDown
= ((eventType
== wxEVT_MIDDLE_DOWN
)
1519 || (XButtonEventMIsDown(xevent
)
1520 && (eventType
!= wxEVT_MIDDLE_UP
)));
1521 wxevent
.m_rightDown
= ((eventType
== wxEVT_RIGHT_DOWN
)
1522 || (XButtonEventRIsDown (xevent
)
1523 && (eventType
!= wxEVT_RIGHT_UP
)));
1525 wxevent
.m_shiftDown
= XButtonEventShiftIsDown(xevent
);
1526 wxevent
.m_controlDown
= XButtonEventCtrlIsDown(xevent
);
1527 wxevent
.m_altDown
= XButtonEventAltIsDown(xevent
);
1528 wxevent
.m_metaDown
= XButtonEventMetaIsDown(xevent
);
1530 wxevent
.SetId(win
->GetId());
1531 wxevent
.SetEventObject(win
);
1539 bool wxTranslateKeyEvent(wxKeyEvent
& wxevent
, wxWindow
*win
, Window
WXUNUSED(win
), XEvent
*xevent
, bool isAscii
)
1541 switch (XEventGetType(xevent
))
1549 (void) XLookupString ((XKeyEvent
*) xevent
, buf
, 20, &keySym
, NULL
);
1550 int id
= wxCharCodeXToWX (keySym
);
1551 // id may be WXK_xxx code - these are outside ASCII range, so we
1552 // can't just use toupper() on id.
1553 // Only change this if we want the raw key that was pressed,
1554 // and don't change it if we want an ASCII value.
1555 if (!isAscii
&& (id
>= 'a' && id
<= 'z'))
1557 id
= id
+ 'A' - 'a';
1560 wxevent
.m_shiftDown
= XKeyEventShiftIsDown(xevent
);
1561 wxevent
.m_controlDown
= XKeyEventCtrlIsDown(xevent
);
1562 wxevent
.m_altDown
= XKeyEventAltIsDown(xevent
);
1563 wxevent
.m_metaDown
= XKeyEventMetaIsDown(xevent
);
1564 wxevent
.SetEventObject(win
);
1565 wxevent
.m_keyCode
= id
;
1566 wxevent
.SetTimestamp(XKeyEventGetTime(xevent
));
1568 wxevent
.m_x
= XKeyEventGetX(xevent
);
1569 wxevent
.m_y
= XKeyEventGetY(xevent
);
1579 // ----------------------------------------------------------------------------
1581 // ----------------------------------------------------------------------------
1583 bool wxWindowX11::SetBackgroundColour(const wxColour
& col
)
1585 wxWindowBase::SetBackgroundColour(col
);
1587 Display
*xdisplay
= (Display
*) wxGlobalDisplay();
1588 int xscreen
= DefaultScreen( xdisplay
);
1589 Colormap cm
= DefaultColormap( xdisplay
, xscreen
);
1591 m_backgroundColour
.CalcPixel( (WXColormap
) cm
);
1593 // We don't set the background colour as we paint
1594 // the background ourselves.
1595 // XSetWindowBackground( xdisplay, (Window) m_clientWindow, m_backgroundColour.GetPixel() );
1600 bool wxWindowX11::SetForegroundColour(const wxColour
& col
)
1602 if ( !wxWindowBase::SetForegroundColour(col
) )
1608 // ----------------------------------------------------------------------------
1610 // ----------------------------------------------------------------------------
1612 wxWindow
*wxGetActiveWindow()
1615 wxFAIL_MSG(wxT("Not implemented"));
1620 wxWindow
*wxWindowBase::GetCapture()
1622 return (wxWindow
*)g_captureWindow
;
1626 // Find the wxWindow at the current mouse position, returning the mouse
1628 wxWindow
* wxFindWindowAtPointer(wxPoint
& pt
)
1630 return wxFindWindowAtPoint(wxGetMousePosition());
1633 // Get the current mouse position.
1634 wxPoint
wxGetMousePosition()
1638 return wxPoint(0, 0);
1640 Display
*display
= wxGlobalDisplay();
1641 Window rootWindow
= RootWindowOfScreen (DefaultScreenOfDisplay(display
));
1642 Window rootReturn
, childReturn
;
1643 int rootX
, rootY
, winX
, winY
;
1644 unsigned int maskReturn
;
1646 XQueryPointer (display
,
1650 &rootX
, &rootY
, &winX
, &winY
, &maskReturn
);
1651 return wxPoint(rootX
, rootY
);
1656 // ----------------------------------------------------------------------------
1657 // wxNoOptimize: switch off size optimization
1658 // ----------------------------------------------------------------------------
1660 int wxNoOptimize::ms_count
= 0;
1663 // ----------------------------------------------------------------------------
1665 // ----------------------------------------------------------------------------
1667 class wxWinModule
: public wxModule
1674 DECLARE_DYNAMIC_CLASS(wxWinModule
)
1677 IMPLEMENT_DYNAMIC_CLASS(wxWinModule
, wxModule
)
1679 bool wxWinModule::OnInit()
1681 Display
*xdisplay
= wxGlobalDisplay();
1682 int xscreen
= DefaultScreen( xdisplay
);
1683 Window xroot
= RootWindow( xdisplay
, xscreen
);
1684 g_eraseGC
= XCreateGC( xdisplay
, xroot
, 0, NULL
);
1685 XSetFillStyle( xdisplay
, g_eraseGC
, FillSolid
);
1690 void wxWinModule::OnExit()
1692 Display
*xdisplay
= wxGlobalDisplay();
1693 XFreeGC( xdisplay
, g_eraseGC
);