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 // ----------------------------------------------------------------------------
29 #include "wx/dcclient.h"
33 #include "wx/layout.h"
34 #include "wx/dialog.h"
35 #include "wx/listbox.h"
36 #include "wx/button.h"
37 #include "wx/settings.h"
38 #include "wx/msgdlg.h"
40 #include "wx/scrolwin.h"
41 #include "wx/scrolbar.h"
42 #include "wx/module.h"
43 #include "wx/menuitem.h"
45 #include "wx/fontutil.h"
46 #include "wx/univ/renderer.h"
49 #if wxUSE_DRAG_AND_DROP
53 #include "wx/x11/private.h"
54 #include "X11/Xutil.h"
57 // For wxGetLocalTime, used by XButtonEventGetTime
63 // ----------------------------------------------------------------------------
64 // global variables for this module
65 // ----------------------------------------------------------------------------
67 static wxWindow
* g_captureWindow
= NULL
;
70 // ----------------------------------------------------------------------------
72 // ----------------------------------------------------------------------------
74 #define event_left_is_down(x) ((x)->xbutton.state & Button1Mask)
75 #define event_middle_is_down(x) ((x)->xbutton.state & Button2Mask)
76 #define event_right_is_down(x) ((x)->xbutton.state & Button3Mask)
78 // ----------------------------------------------------------------------------
80 // ----------------------------------------------------------------------------
82 IMPLEMENT_ABSTRACT_CLASS(wxWindowX11
, wxWindowBase
)
84 BEGIN_EVENT_TABLE(wxWindowX11
, wxWindowBase
)
85 EVT_SYS_COLOUR_CHANGED(wxWindowX11::OnSysColourChanged
)
88 // ============================================================================
90 // ============================================================================
92 // ----------------------------------------------------------------------------
94 // ----------------------------------------------------------------------------
96 // ----------------------------------------------------------------------------
98 // ----------------------------------------------------------------------------
100 void wxWindowX11::Init()
103 m_mainWindow
= (WXWindow
) 0;
104 m_clientWindow
= (WXWindow
) 0;
105 m_insertIntoMain
= false;
106 m_updateNcArea
= false;
108 m_winCaptured
= false;
109 m_needsInputFocus
= false;
115 // real construction (Init() must have been called before!)
116 bool wxWindowX11::Create(wxWindow
*parent
, wxWindowID id
,
120 const wxString
& name
)
122 wxCHECK_MSG( parent
, false, wxT("can't create wxWindow without parent") );
124 CreateBase(parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
);
126 parent
->AddChild(this);
128 Display
*xdisplay
= (Display
*) wxGlobalDisplay();
129 int xscreen
= DefaultScreen( xdisplay
);
130 Visual
*xvisual
= DefaultVisual( xdisplay
, xscreen
);
131 Colormap cm
= DefaultColormap( xdisplay
, xscreen
);
133 m_backgroundColour
= wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE
);
134 m_backgroundColour
.CalcPixel( (WXColormap
) cm
);
136 m_foregroundColour
= *wxBLACK
;
137 m_foregroundColour
.CalcPixel( (WXColormap
) cm
);
139 Window xparent
= (Window
) parent
->GetClientAreaWindow();
141 // Add window's own scrollbars to main window, not to client window
142 if (parent
->GetInsertIntoMain())
144 // wxLogDebug( "Inserted into main: %s", GetName().c_str() );
145 xparent
= (Window
) parent
->GetMainWindow();
148 // Size (not including the border) must be nonzero (or a Value error results)!
149 // Note: The Xlib manual doesn't mention this restriction of XCreateWindow.
157 if (pos2
.x
== wxDefaultCoord
)
159 if (pos2
.y
== wxDefaultCoord
)
162 #if wxUSE_TWO_WINDOWS
163 bool need_two_windows
=
164 ((( wxSUNKEN_BORDER
| wxRAISED_BORDER
| wxSIMPLE_BORDER
| wxHSCROLL
| wxVSCROLL
) & m_windowStyle
) != 0);
166 bool need_two_windows
= false;
170 long xattributes
= 0;
172 XSetWindowAttributes xattributes
;
173 long xattributes_mask
= 0;
175 xattributes_mask
|= CWBackPixel
;
176 xattributes
.background_pixel
= m_backgroundColour
.GetPixel();
178 xattributes_mask
|= CWBorderPixel
;
179 xattributes
.border_pixel
= BlackPixel( xdisplay
, xscreen
);
181 xattributes_mask
|= CWEventMask
;
184 if (need_two_windows
)
187 long backColor
, foreColor
;
188 backColor
= GR_RGB(m_backgroundColour
.Red(), m_backgroundColour
.Green(), m_backgroundColour
.Blue());
189 foreColor
= GR_RGB(m_foregroundColour
.Red(), m_foregroundColour
.Green(), m_foregroundColour
.Blue());
191 Window xwindow
= XCreateWindowWithColor( xdisplay
, xparent
, pos2
.x
, pos2
.y
, size2
.x
, size2
.y
,
192 0, 0, InputOutput
, xvisual
, backColor
, foreColor
);
193 XSelectInput( xdisplay
, xwindow
,
194 GR_EVENT_MASK_CLOSE_REQ
| ExposureMask
| KeyPressMask
| KeyReleaseMask
| ButtonPressMask
| ButtonReleaseMask
|
195 ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
|
196 KeymapStateMask
| FocusChangeMask
| ColormapChangeMask
| StructureNotifyMask
|
197 PropertyChangeMask
);
201 xattributes
.event_mask
=
202 ExposureMask
| StructureNotifyMask
| ColormapChangeMask
;
204 Window xwindow
= XCreateWindow( xdisplay
, xparent
, pos2
.x
, pos2
.y
, size2
.x
, size2
.y
,
205 0, DefaultDepth(xdisplay
,xscreen
), InputOutput
, xvisual
, xattributes_mask
, &xattributes
);
209 XSetWindowBackgroundPixmap( xdisplay
, xwindow
, None
);
211 m_mainWindow
= (WXWindow
) xwindow
;
212 wxAddWindowToTable( xwindow
, (wxWindow
*) this );
214 XMapWindow( xdisplay
, xwindow
);
217 xattributes
.event_mask
=
218 ExposureMask
| KeyPressMask
| KeyReleaseMask
| ButtonPressMask
| ButtonReleaseMask
|
219 ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
|
220 KeymapStateMask
| FocusChangeMask
| ColormapChangeMask
| StructureNotifyMask
|
221 PropertyChangeMask
| VisibilityChangeMask
;
223 if (!HasFlag( wxFULL_REPAINT_ON_RESIZE
))
225 xattributes_mask
|= CWBitGravity
;
226 xattributes
.bit_gravity
= StaticGravity
;
230 if (HasFlag( wxSUNKEN_BORDER
) || HasFlag( wxRAISED_BORDER
))
237 else if (HasFlag( wxSIMPLE_BORDER
))
250 // Make again sure the size is nonzero.
257 backColor
= GR_RGB(m_backgroundColour
.Red(), m_backgroundColour
.Green(), m_backgroundColour
.Blue());
258 foreColor
= GR_RGB(m_foregroundColour
.Red(), m_foregroundColour
.Green(), m_foregroundColour
.Blue());
260 xwindow
= XCreateWindowWithColor( xdisplay
, xwindow
, pos2
.x
, pos2
.y
, size2
.x
, size2
.y
,
261 0, 0, InputOutput
, xvisual
, backColor
, foreColor
);
262 XSelectInput( xdisplay
, xwindow
,
263 GR_EVENT_MASK_CLOSE_REQ
| ExposureMask
| KeyPressMask
| KeyReleaseMask
| ButtonPressMask
| ButtonReleaseMask
|
264 ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
|
265 KeymapStateMask
| FocusChangeMask
| ColormapChangeMask
| StructureNotifyMask
|
266 PropertyChangeMask
);
269 xwindow
= XCreateWindow( xdisplay
, xwindow
, pos2
.x
, pos2
.y
, size2
.x
, size2
.y
,
270 0, DefaultDepth(xdisplay
,xscreen
), InputOutput
, xvisual
, xattributes_mask
, &xattributes
);
273 XSetWindowBackgroundPixmap( xdisplay
, xwindow
, None
);
275 m_clientWindow
= (WXWindow
) xwindow
;
276 wxAddClientWindowToTable( xwindow
, (wxWindow
*) this );
278 XMapWindow( xdisplay
, xwindow
);
282 // wxLogDebug( "No two windows needed %s", GetName().c_str() );
284 long backColor
, foreColor
;
285 backColor
= GR_RGB(m_backgroundColour
.Red(), m_backgroundColour
.Green(), m_backgroundColour
.Blue());
286 foreColor
= GR_RGB(m_foregroundColour
.Red(), m_foregroundColour
.Green(), m_foregroundColour
.Blue());
288 Window xwindow
= XCreateWindowWithColor( xdisplay
, xparent
, pos2
.x
, pos2
.y
, size2
.x
, size2
.y
,
289 0, 0, InputOutput
, xvisual
, backColor
, foreColor
);
290 XSelectInput( xdisplay
, xwindow
,
291 GR_EVENT_MASK_CLOSE_REQ
| ExposureMask
| KeyPressMask
| KeyReleaseMask
| ButtonPressMask
| ButtonReleaseMask
|
292 ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
|
293 KeymapStateMask
| FocusChangeMask
| ColormapChangeMask
| StructureNotifyMask
|
294 PropertyChangeMask
);
297 xattributes
.event_mask
=
298 ExposureMask
| KeyPressMask
| KeyReleaseMask
| ButtonPressMask
| ButtonReleaseMask
|
299 ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
|
300 KeymapStateMask
| FocusChangeMask
| ColormapChangeMask
| StructureNotifyMask
|
301 PropertyChangeMask
| VisibilityChangeMask
;
303 if (!HasFlag( wxFULL_REPAINT_ON_RESIZE
))
305 xattributes_mask
|= CWBitGravity
;
306 xattributes
.bit_gravity
= NorthWestGravity
;
309 Window xwindow
= XCreateWindow( xdisplay
, xparent
, pos2
.x
, pos2
.y
, size2
.x
, size2
.y
,
310 0, DefaultDepth(xdisplay
,xscreen
), InputOutput
, xvisual
, xattributes_mask
, &xattributes
);
313 XSetWindowBackgroundPixmap( xdisplay
, xwindow
, None
);
315 m_mainWindow
= (WXWindow
) xwindow
;
316 m_clientWindow
= m_mainWindow
;
317 wxAddWindowToTable( xwindow
, (wxWindow
*) this );
319 XMapWindow( xdisplay
, xwindow
);
322 // Is a subwindow, so map immediately
325 // Without this, the cursor may not be restored properly (e.g. in splitter
327 SetCursor(*wxSTANDARD_CURSOR
);
328 SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
));
330 // Don't call this, it can have nasty repercussions for composite controls,
332 // SetSize(pos.x, pos.y, size.x, size.y);
338 wxWindowX11::~wxWindowX11()
342 if (g_captureWindow
== this)
343 g_captureWindow
= NULL
;
345 m_isBeingDeleted
= true;
349 if (m_clientWindow
!= m_mainWindow
)
351 // Destroy the cleint window
352 Window xwindow
= (Window
) m_clientWindow
;
353 wxDeleteClientWindowFromTable( xwindow
);
354 XDestroyWindow( wxGlobalDisplay(), xwindow
);
355 m_clientWindow
= NULL
;
358 // Destroy the window
359 Window xwindow
= (Window
) m_mainWindow
;
360 wxDeleteWindowFromTable( xwindow
);
361 XDestroyWindow( wxGlobalDisplay(), xwindow
);
365 // ---------------------------------------------------------------------------
367 // ---------------------------------------------------------------------------
369 void wxWindowX11::SetFocus()
371 Window xwindow
= (Window
) m_clientWindow
;
373 wxCHECK_RET( xwindow
, wxT("invalid window") );
375 // Don't assert; we might be trying to set the focus for a panel
376 // with only static controls, so the panel returns false from AcceptsFocus.
377 // The app should be not be expected to deal with this.
382 if (GetName() == "scrollBar")
389 if (wxWindowIsVisible(xwindow
))
391 wxLogTrace( _T("focus"), _T("wxWindowX11::SetFocus: %s"), GetClassInfo()->GetClassName());
392 // XSetInputFocus( wxGlobalDisplay(), xwindow, RevertToParent, CurrentTime );
393 XSetInputFocus( wxGlobalDisplay(), xwindow
, RevertToNone
, CurrentTime
);
394 m_needsInputFocus
= false;
398 m_needsInputFocus
= true;
402 // Get the window with the focus
403 wxWindow
*wxWindowBase::DoFindFocus()
405 Window xfocus
= (Window
) 0;
408 XGetInputFocus( wxGlobalDisplay(), &xfocus
, &revert
);
411 wxWindow
*win
= wxGetWindowFromTable( xfocus
);
414 win
= wxGetClientWindowFromTable( xfocus
);
423 // Enabling/disabling handled by event loop, and not sending events
425 bool wxWindowX11::Enable(bool enable
)
427 if ( !wxWindowBase::Enable(enable
) )
433 bool wxWindowX11::Show(bool show
)
435 wxWindowBase::Show(show
);
437 Window xwindow
= (Window
) m_mainWindow
;
438 Display
*xdisp
= wxGlobalDisplay();
441 // wxLogDebug( "Mapping window of type %s", GetName().c_str() );
442 XMapWindow(xdisp
, xwindow
);
446 // wxLogDebug( "Unmapping window of type %s", GetName().c_str() );
447 XUnmapWindow(xdisp
, xwindow
);
453 // Raise the window to the top of the Z order
454 void wxWindowX11::Raise()
457 XRaiseWindow( wxGlobalDisplay(), (Window
) m_mainWindow
);
460 // Lower the window to the bottom of the Z order
461 void wxWindowX11::Lower()
464 XLowerWindow( wxGlobalDisplay(), (Window
) m_mainWindow
);
467 void wxWindowX11::SetLabel(const wxString
& WXUNUSED(label
))
472 wxString
wxWindowX11::GetLabel() const
475 return wxEmptyString
;
478 void wxWindowX11::DoCaptureMouse()
480 if ((g_captureWindow
!= NULL
) && (g_captureWindow
!= this))
482 wxASSERT_MSG(false, wxT("Trying to capture before mouse released."));
493 Window xwindow
= (Window
) m_clientWindow
;
495 wxCHECK_RET( xwindow
, wxT("invalid window") );
497 g_captureWindow
= (wxWindow
*) this;
501 int res
= XGrabPointer(wxGlobalDisplay(), xwindow
,
503 ButtonPressMask
| ButtonReleaseMask
| ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
,
507 None
, /* cursor */ // TODO: This may need to be set to the cursor of this window
510 if (res
!= GrabSuccess
)
513 msg
.Printf(wxT("Failed to grab pointer for window %s"), this->GetClassInfo()->GetClassName());
515 if (res
== GrabNotViewable
)
516 wxLogDebug( wxT("This is not a viewable window - perhaps not shown yet?") );
518 g_captureWindow
= NULL
;
522 m_winCaptured
= true;
526 void wxWindowX11::DoReleaseMouse()
528 g_captureWindow
= NULL
;
530 if ( !m_winCaptured
)
533 Window xwindow
= (Window
) m_clientWindow
;
537 XUngrabPointer( wxGlobalDisplay(), CurrentTime
);
540 // wxLogDebug( "Ungrabbed pointer in %s", GetName().c_str() );
542 m_winCaptured
= false;
545 bool wxWindowX11::SetFont(const wxFont
& font
)
547 if ( !wxWindowBase::SetFont(font
) )
556 bool wxWindowX11::SetCursor(const wxCursor
& cursor
)
558 if ( !wxWindowBase::SetCursor(cursor
) )
564 Window xwindow
= (Window
) m_clientWindow
;
566 wxCHECK_MSG( xwindow
, false, wxT("invalid window") );
568 wxCursor cursorToUse
;
570 cursorToUse
= m_cursor
;
572 cursorToUse
= *wxSTANDARD_CURSOR
;
574 Cursor xcursor
= (Cursor
) cursorToUse
.GetCursor();
576 XDefineCursor( wxGlobalDisplay(), xwindow
, xcursor
);
581 // Coordinates relative to the window
582 void wxWindowX11::WarpPointer (int x
, int y
)
584 Window xwindow
= (Window
) m_clientWindow
;
586 wxCHECK_RET( xwindow
, wxT("invalid window") );
588 XWarpPointer( wxGlobalDisplay(), None
, xwindow
, 0, 0, 0, 0, x
, y
);
591 // Does a physical scroll
592 void wxWindowX11::ScrollWindow(int dx
, int dy
, const wxRect
*rect
)
594 // No scrolling requested.
595 if ((dx
== 0) && (dy
== 0)) return;
597 if (!m_updateRegion
.IsEmpty())
599 m_updateRegion
.Offset( dx
, dy
);
603 GetSize( &cw
, &ch
); // GetClientSize() ??
604 m_updateRegion
.Intersect( 0, 0, cw
, ch
);
607 if (!m_clearRegion
.IsEmpty())
609 m_clearRegion
.Offset( dx
, dy
);
613 GetSize( &cw
, &ch
); // GetClientSize() ??
614 m_clearRegion
.Intersect( 0, 0, cw
, ch
);
617 Window xwindow
= (Window
) GetClientAreaWindow();
619 wxCHECK_RET( xwindow
, wxT("invalid window") );
621 Display
*xdisplay
= wxGlobalDisplay();
623 GC xgc
= XCreateGC( xdisplay
, xwindow
, 0, NULL
);
624 XSetGraphicsExposures( xdisplay
, xgc
, True
);
642 GetClientSize( &cw
, &ch
);
645 #if wxUSE_TWO_WINDOWS
646 wxPoint
offset( 0,0 );
648 wxPoint offset
= GetClientAreaOrigin();
653 int w
= cw
- abs(dx
);
654 int h
= ch
- abs(dy
);
656 if ((h
< 0) || (w
< 0))
663 if (dx
< 0) rect
.x
= cw
+dx
+ offset
.x
; else rect
.x
= s_x
;
664 if (dy
< 0) rect
.y
= ch
+dy
+ offset
.y
; else rect
.y
= s_y
;
665 if (dy
!= 0) rect
.width
= cw
; else rect
.width
= abs(dx
);
666 if (dx
!= 0) rect
.height
= ch
; else rect
.height
= abs(dy
);
671 if (dx
< 0) s_x
+= -dx
;
672 if (dy
< 0) s_y
+= -dy
;
673 if (dx
> 0) d_x
= dx
+ offset
.x
;
674 if (dy
> 0) d_y
= dy
+ offset
.y
;
676 XCopyArea( xdisplay
, xwindow
, xwindow
, xgc
, s_x
, s_y
, w
, h
, d_x
, d_y
);
678 // 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 );
680 // wxLogDebug( "Update: %d %d %d %d", rect.x, rect.y, rect.width, rect.height );
682 m_updateRegion
.Union( rect
);
683 m_clearRegion
.Union( rect
);
686 XFreeGC( xdisplay
, xgc
);
688 // Move Clients, but not the scrollbars
689 // FIXME: There may be a better method to move a lot of Windows within X11
690 wxScrollBar
*sbH
= ((wxWindow
*) this)->GetScrollbar( wxHORIZONTAL
);
691 wxScrollBar
*sbV
= ((wxWindow
*) this)->GetScrollbar( wxVERTICAL
);
692 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
695 // Only propagate to non-top-level windows
696 wxWindow
*win
= node
->GetData();
697 if ( win
->GetParent() && win
!= sbH
&& win
!= sbV
)
699 wxPoint pos
= win
->GetPosition();
700 // Add the delta to the old Position
703 win
->SetPosition(pos
);
705 node
= node
->GetNext();
709 // ---------------------------------------------------------------------------
711 // ---------------------------------------------------------------------------
713 #if wxUSE_DRAG_AND_DROP
715 void wxWindowX11::SetDropTarget(wxDropTarget
* WXUNUSED(pDropTarget
))
722 // Old style file-manager drag&drop
723 void wxWindowX11::DragAcceptFiles(bool WXUNUSED(accept
))
728 // ----------------------------------------------------------------------------
730 // ----------------------------------------------------------------------------
734 void wxWindowX11::DoSetToolTip(wxToolTip
* WXUNUSED(tooltip
))
739 #endif // wxUSE_TOOLTIPS
741 // ---------------------------------------------------------------------------
742 // moving and resizing
743 // ---------------------------------------------------------------------------
745 bool wxWindowX11::PreResize()
751 void wxWindowX11::DoGetSize(int *x
, int *y
) const
753 Window xwindow
= (Window
) m_mainWindow
;
755 wxCHECK_RET( xwindow
, wxT("invalid window") );
757 //XSync(wxGlobalDisplay(), False);
759 XWindowAttributes attr
;
760 Status status
= XGetWindowAttributes( wxGlobalDisplay(), xwindow
, &attr
);
765 *x
= attr
.width
/* + 2*m_borderSize */ ;
766 *y
= attr
.height
/* + 2*m_borderSize */ ;
770 void wxWindowX11::DoGetPosition(int *x
, int *y
) const
772 Window window
= (Window
) m_mainWindow
;
775 //XSync(wxGlobalDisplay(), False);
776 XWindowAttributes attr
;
777 Status status
= XGetWindowAttributes(wxGlobalDisplay(), window
, & attr
);
785 // We may be faking the client origin. So a window that's really at (0, 30)
786 // may appear (to wxWin apps) to be at (0, 0).
789 wxPoint
pt(GetParent()->GetClientAreaOrigin());
797 void wxWindowX11::DoScreenToClient(int *x
, int *y
) const
799 Display
*display
= wxGlobalDisplay();
800 Window rootWindow
= RootWindowOfScreen(DefaultScreenOfDisplay(display
));
801 Window thisWindow
= (Window
) m_clientWindow
;
806 XTranslateCoordinates(display
, rootWindow
, thisWindow
, xx
, yy
, x
, y
, &childWindow
);
809 void wxWindowX11::DoClientToScreen(int *x
, int *y
) const
811 Display
*display
= wxGlobalDisplay();
812 Window rootWindow
= RootWindowOfScreen(DefaultScreenOfDisplay(display
));
813 Window thisWindow
= (Window
) m_clientWindow
;
818 XTranslateCoordinates(display
, thisWindow
, rootWindow
, xx
, yy
, x
, y
, &childWindow
);
822 // Get size *available for subwindows* i.e. excluding menu bar etc.
823 void wxWindowX11::DoGetClientSize(int *x
, int *y
) const
825 Window window
= (Window
) m_mainWindow
;
829 XWindowAttributes attr
;
830 Status status
= XGetWindowAttributes( wxGlobalDisplay(), window
, &attr
);
841 void wxWindowX11::DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
843 // wxLogDebug("DoSetSize: %s (%ld) %d, %d %dx%d", GetClassInfo()->GetClassName(), GetId(), x, y, width, height);
845 Window xwindow
= (Window
) m_mainWindow
;
847 wxCHECK_RET( xwindow
, wxT("invalid window") );
849 XWindowAttributes attr
;
850 Status status
= XGetWindowAttributes( wxGlobalDisplay(), xwindow
, &attr
);
851 wxCHECK_RET( status
, wxT("invalid window attributes") );
855 int new_w
= attr
.width
;
856 int new_h
= attr
.height
;
858 if (x
!= wxDefaultCoord
|| (sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
861 AdjustForParentClientOrigin( x
, yy
, sizeFlags
);
864 if (y
!= wxDefaultCoord
|| (sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
867 AdjustForParentClientOrigin( xx
, y
, sizeFlags
);
870 if (width
!= wxDefaultCoord
)
876 if (height
!= wxDefaultCoord
)
883 DoMoveWindow( new_x
, new_y
, new_w
, new_h
);
886 void wxWindowX11::DoSetClientSize(int width
, int height
)
888 // wxLogDebug("DoSetClientSize: %s (%ld) %dx%d", GetClassInfo()->GetClassName(), GetId(), width, height);
890 Window xwindow
= (Window
) m_mainWindow
;
892 wxCHECK_RET( xwindow
, wxT("invalid window") );
894 XResizeWindow( wxGlobalDisplay(), xwindow
, width
, height
);
896 if (m_mainWindow
!= m_clientWindow
)
898 xwindow
= (Window
) m_clientWindow
;
900 wxWindow
*window
= (wxWindow
*) this;
901 wxRenderer
*renderer
= window
->GetRenderer();
904 wxRect border
= renderer
->GetBorderDimensions( (wxBorder
)(m_windowStyle
& wxBORDER_MASK
) );
905 width
-= border
.x
+ border
.width
;
906 height
-= border
.y
+ border
.height
;
909 XResizeWindow( wxGlobalDisplay(), xwindow
, width
, height
);
913 void wxWindowX11::DoMoveWindow(int x
, int y
, int width
, int height
)
915 Window xwindow
= (Window
) m_mainWindow
;
917 wxCHECK_RET( xwindow
, wxT("invalid window") );
921 XMoveResizeWindow( wxGlobalDisplay(), xwindow
, x
, y
, width
, height
);
922 if (m_mainWindow
!= m_clientWindow
)
924 xwindow
= (Window
) m_clientWindow
;
926 wxWindow
*window
= (wxWindow
*) this;
927 wxRenderer
*renderer
= window
->GetRenderer();
930 wxRect border
= renderer
->GetBorderDimensions( (wxBorder
)(m_windowStyle
& wxBORDER_MASK
) );
933 width
-= border
.x
+ border
.width
;
934 height
-= border
.y
+ border
.height
;
942 wxScrollBar
*sb
= window
->GetScrollbar( wxHORIZONTAL
);
943 if (sb
&& sb
->IsShown())
945 wxSize size
= sb
->GetSize();
948 sb
= window
->GetScrollbar( wxVERTICAL
);
949 if (sb
&& sb
->IsShown())
951 wxSize size
= sb
->GetSize();
955 XMoveResizeWindow( wxGlobalDisplay(), xwindow
, x
, y
, wxMax(1, width
), wxMax(1, height
) );
960 XWindowChanges windowChanges
;
963 windowChanges
.width
= width
;
964 windowChanges
.height
= height
;
965 windowChanges
.stack_mode
= 0;
966 int valueMask
= CWX
| CWY
| CWWidth
| CWHeight
;
968 XConfigureWindow( wxGlobalDisplay(), xwindow
, valueMask
, &windowChanges
);
973 void wxWindowX11::DoSetSizeHints(int minW
, int minH
, int maxW
, int maxH
, int incW
, int incH
)
981 XSizeHints sizeHints
;
984 if (minW
> -1 && minH
> -1)
986 sizeHints
.flags
|= PMinSize
;
987 sizeHints
.min_width
= minW
;
988 sizeHints
.min_height
= minH
;
990 if (maxW
> -1 && maxH
> -1)
992 sizeHints
.flags
|= PMaxSize
;
993 sizeHints
.max_width
= maxW
;
994 sizeHints
.max_height
= maxH
;
996 if (incW
> -1 && incH
> -1)
998 sizeHints
.flags
|= PResizeInc
;
999 sizeHints
.width_inc
= incW
;
1000 sizeHints
.height_inc
= incH
;
1003 XSetWMNormalHints(wxGlobalDisplay(), (Window
) m_mainWindow
, &sizeHints
);
1007 // ---------------------------------------------------------------------------
1009 // ---------------------------------------------------------------------------
1011 int wxWindowX11::GetCharHeight() const
1013 wxFont
font(GetFont());
1014 wxCHECK_MSG( font
.Ok(), 0, wxT("valid window font needed") );
1017 // There should be an easier way.
1018 PangoLayout
*layout
= pango_layout_new( wxTheApp
->GetPangoContext() );
1019 pango_layout_set_font_description( layout
, font
.GetNativeFontInfo()->description
);
1020 pango_layout_set_text(layout
, "H", 1 );
1022 pango_layout_get_pixel_size(layout
, &w
, &h
);
1023 g_object_unref( G_OBJECT( layout
) );
1027 WXFontStructPtr pFontStruct
= font
.GetFontStruct(1.0, wxGlobalDisplay());
1029 int direction
, ascent
, descent
;
1030 XCharStruct overall
;
1031 XTextExtents ((XFontStruct
*) pFontStruct
, "x", 1, &direction
, &ascent
,
1032 &descent
, &overall
);
1034 // return (overall.ascent + overall.descent);
1035 return (ascent
+ descent
);
1039 int wxWindowX11::GetCharWidth() const
1041 wxFont
font(GetFont());
1042 wxCHECK_MSG( font
.Ok(), 0, wxT("valid window font needed") );
1045 // There should be an easier way.
1046 PangoLayout
*layout
= pango_layout_new( wxTheApp
->GetPangoContext() );
1047 pango_layout_set_font_description( layout
, font
.GetNativeFontInfo()->description
);
1048 pango_layout_set_text(layout
, "H", 1 );
1050 pango_layout_get_pixel_size(layout
, &w
, &h
);
1051 g_object_unref( G_OBJECT( layout
) );
1055 WXFontStructPtr pFontStruct
= font
.GetFontStruct(1.0, wxGlobalDisplay());
1057 int direction
, ascent
, descent
;
1058 XCharStruct overall
;
1059 XTextExtents ((XFontStruct
*) pFontStruct
, "x", 1, &direction
, &ascent
,
1060 &descent
, &overall
);
1062 return overall
.width
;
1066 void wxWindowX11::GetTextExtent(const wxString
& string
,
1068 int *descent
, int *externalLeading
,
1069 const wxFont
*theFont
) const
1071 wxFont fontToUse
= GetFont();
1072 if (theFont
) fontToUse
= *theFont
;
1074 wxCHECK_RET( fontToUse
.Ok(), wxT("invalid font") );
1084 PangoLayout
*layout
= pango_layout_new( wxTheApp
->GetPangoContext() );
1086 PangoFontDescription
*desc
= fontToUse
.GetNativeFontInfo()->description
;
1087 pango_layout_set_font_description(layout
, desc
);
1089 const wxCharBuffer data
= wxConvUTF8
.cWC2MB( string
);
1090 pango_layout_set_text(layout
, (const char*) data
, strlen( (const char*) data
));
1092 PangoLayoutLine
*line
= (PangoLayoutLine
*)pango_layout_get_lines(layout
)->data
;
1095 PangoRectangle rect
;
1096 pango_layout_line_get_extents(line
, NULL
, &rect
);
1098 if (x
) (*x
) = (wxCoord
) (rect
.width
/ PANGO_SCALE
);
1099 if (y
) (*y
) = (wxCoord
) (rect
.height
/ PANGO_SCALE
);
1102 // Do something about metrics here
1105 if (externalLeading
) (*externalLeading
) = 0; // ??
1107 g_object_unref( G_OBJECT( layout
) );
1109 WXFontStructPtr pFontStruct
= fontToUse
.GetFontStruct(1.0, wxGlobalDisplay());
1111 int direction
, ascent
, descent2
;
1112 XCharStruct overall
;
1113 int slen
= string
.Len();
1115 XTextExtents((XFontStruct
*) pFontStruct
, (char*) string
.c_str(), slen
,
1116 &direction
, &ascent
, &descent2
, &overall
);
1119 *x
= (overall
.width
);
1121 *y
= (ascent
+ descent2
);
1123 *descent
= descent2
;
1124 if (externalLeading
)
1125 *externalLeading
= 0;
1129 // ----------------------------------------------------------------------------
1131 // ----------------------------------------------------------------------------
1133 void wxWindowX11::Refresh(bool eraseBack
, const wxRect
*rect
)
1139 // Schedule for later Updating in ::Update() or ::OnInternalIdle().
1140 m_clearRegion
.Union( rect
->x
, rect
->y
, rect
->width
, rect
->height
);
1145 GetSize( &width
, &height
);
1147 // Schedule for later Updating in ::Update() or ::OnInternalIdle().
1148 m_clearRegion
.Clear();
1149 m_clearRegion
.Union( 0, 0, width
, height
);
1155 // Schedule for later Updating in ::Update() or ::OnInternalIdle().
1156 m_updateRegion
.Union( rect
->x
, rect
->y
, rect
->width
, rect
->height
);
1161 GetSize( &width
, &height
);
1163 // Schedule for later Updating in ::Update() or ::OnInternalIdle().
1164 m_updateRegion
.Clear();
1165 m_updateRegion
.Union( 0, 0, width
, height
);
1169 void wxWindowX11::Update()
1173 // wxLogDebug("wxWindowX11::UpdateNC: %s", GetClassInfo()->GetClassName());
1174 // Send nc paint events.
1175 SendNcPaintEvents();
1178 if (!m_updateRegion
.IsEmpty())
1180 // wxLogDebug("wxWindowX11::Update: %s", GetClassInfo()->GetClassName());
1181 // Actually send erase events.
1184 // Actually send paint events.
1189 void wxWindowX11::SendEraseEvents()
1191 if (m_clearRegion
.IsEmpty()) return;
1193 wxClientDC
dc( (wxWindow
*)this );
1194 dc
.SetClippingRegion( m_clearRegion
);
1196 wxEraseEvent
erase_event( GetId(), &dc
);
1197 erase_event
.SetEventObject( this );
1199 if (!GetEventHandler()->ProcessEvent(erase_event
) )
1201 Display
*xdisplay
= wxGlobalDisplay();
1202 Window xwindow
= (Window
) GetClientAreaWindow();
1203 XSetForeground( xdisplay
, g_eraseGC
, m_backgroundColour
.GetPixel() );
1205 wxRegionIterator
upd( m_clearRegion
);
1208 XFillRectangle( xdisplay
, xwindow
, g_eraseGC
,
1209 upd
.GetX(), upd
.GetY(), upd
.GetWidth(), upd
.GetHeight() );
1214 m_clearRegion
.Clear();
1217 void wxWindowX11::SendPaintEvents()
1219 // wxLogDebug("SendPaintEvents: %s (%ld)", GetClassInfo()->GetClassName(), GetId());
1221 m_clipPaintRegion
= true;
1223 wxPaintEvent
paint_event( GetId() );
1224 paint_event
.SetEventObject( this );
1225 GetEventHandler()->ProcessEvent( paint_event
);
1227 m_updateRegion
.Clear();
1229 m_clipPaintRegion
= false;
1232 void wxWindowX11::SendNcPaintEvents()
1234 wxWindow
*window
= (wxWindow
*) this;
1236 // All this for drawing the small square between the scrollbars.
1241 wxScrollBar
*sb
= window
->GetScrollbar( wxHORIZONTAL
);
1242 if (sb
&& sb
->IsShown())
1244 height
= sb
->GetSize().y
;
1245 y
= sb
->GetPosition().y
;
1247 sb
= window
->GetScrollbar( wxVERTICAL
);
1248 if (sb
&& sb
->IsShown())
1250 width
= sb
->GetSize().x
;
1251 x
= sb
->GetPosition().x
;
1253 Display
*xdisplay
= wxGlobalDisplay();
1254 Window xwindow
= (Window
) GetMainWindow();
1255 Colormap cm
= (Colormap
) wxTheApp
->GetMainColormap( wxGetDisplay() );
1256 wxColour colour
= wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
);
1257 colour
.CalcPixel( (WXColormap
) cm
);
1259 XSetForeground( xdisplay
, g_eraseGC
, colour
.GetPixel() );
1261 XFillRectangle( xdisplay
, xwindow
, g_eraseGC
, x
, y
, width
, height
);
1265 wxNcPaintEvent
nc_paint_event( GetId() );
1266 nc_paint_event
.SetEventObject( this );
1267 GetEventHandler()->ProcessEvent( nc_paint_event
);
1269 m_updateNcArea
= false;
1272 // ----------------------------------------------------------------------------
1274 // ----------------------------------------------------------------------------
1276 // Responds to colour changes: passes event on to children.
1277 void wxWindowX11::OnSysColourChanged(wxSysColourChangedEvent
& event
)
1279 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
1282 // Only propagate to non-top-level windows
1283 wxWindow
*win
= node
->GetData();
1284 if ( win
->GetParent() )
1286 wxSysColourChangedEvent event2
;
1287 event
.SetEventObject(win
);
1288 win
->GetEventHandler()->ProcessEvent(event2
);
1291 node
= node
->GetNext();
1295 // See handler for InFocus case in app.cpp for details.
1296 wxWindow
* g_GettingFocus
= NULL
;
1298 void wxWindowX11::OnInternalIdle()
1300 // Update invalidated regions.
1303 // This calls the UI-update mechanism (querying windows for
1304 // menu/toolbar/control state information)
1305 if (wxUpdateUIEvent::CanUpdate((wxWindow
*) this))
1306 UpdateWindowUI(wxUPDATE_UI_FROMIDLE
);
1308 // Set the input focus if couldn't do it before
1309 if (m_needsInputFocus
)
1313 msg
.Printf("Setting focus for %s from OnInternalIdle\n", GetClassInfo()->GetClassName());
1314 printf(msg
.c_str());
1318 // If it couldn't set the focus now, there's
1319 // no point in trying again.
1320 m_needsInputFocus
= false;
1322 g_GettingFocus
= NULL
;
1325 // ----------------------------------------------------------------------------
1326 // function which maintain the global hash table mapping Widgets to wxWidgets
1327 // ----------------------------------------------------------------------------
1329 static bool DoAddWindowToTable(wxWindowHash
*hash
, Window w
, wxWindow
*win
)
1331 if ( !hash
->insert(wxWindowHash::value_type(w
, win
)).second
)
1333 wxLogDebug( wxT("Widget table clash: new widget is 0x%08x, %s"),
1334 (unsigned int)w
, win
->GetClassInfo()->GetClassName());
1338 wxLogTrace( wxT("widget"), wxT("XWindow 0x%08x <-> window %p (%s)"),
1339 (unsigned int) w
, win
, win
->GetClassInfo()->GetClassName());
1344 static inline wxWindow
*DoGetWindowFromTable(wxWindowHash
*hash
, Window w
)
1346 wxWindowHash::iterator i
= hash
->find(w
);
1347 return i
== hash
->end() ? NULL
: i
->second
;
1350 static inline void DoDeleteWindowFromTable(wxWindowHash
*hash
, Window w
)
1352 wxLogTrace( wxT("widget"), wxT("XWindow 0x%08x deleted"), (unsigned int) w
);
1357 // ----------------------------------------------------------------------------
1359 // ----------------------------------------------------------------------------
1361 bool wxAddWindowToTable(Window w
, wxWindow
*win
)
1363 return DoAddWindowToTable(wxWidgetHashTable
, w
, win
);
1366 wxWindow
*wxGetWindowFromTable(Window w
)
1368 return DoGetWindowFromTable(wxWidgetHashTable
, w
);
1371 void wxDeleteWindowFromTable(Window w
)
1373 DoDeleteWindowFromTable(wxWidgetHashTable
, w
);
1376 bool wxAddClientWindowToTable(Window w
, wxWindow
*win
)
1378 return DoAddWindowToTable(wxClientWidgetHashTable
, w
, win
);
1381 wxWindow
*wxGetClientWindowFromTable(Window w
)
1383 return DoGetWindowFromTable(wxClientWidgetHashTable
, w
);
1386 void wxDeleteClientWindowFromTable(Window w
)
1388 DoDeleteWindowFromTable(wxClientWidgetHashTable
, w
);
1391 // ----------------------------------------------------------------------------
1392 // X11-specific accessors
1393 // ----------------------------------------------------------------------------
1395 WXWindow
wxWindowX11::GetMainWindow() const
1397 return m_mainWindow
;
1400 WXWindow
wxWindowX11::GetClientAreaWindow() const
1402 return m_clientWindow
;
1405 // ----------------------------------------------------------------------------
1406 // TranslateXXXEvent() functions
1407 // ----------------------------------------------------------------------------
1409 bool wxTranslateMouseEvent(wxMouseEvent
& wxevent
, wxWindow
*win
, Window window
, XEvent
*xevent
)
1411 switch (XEventGetType(xevent
))
1419 wxEventType eventType
= wxEVT_NULL
;
1421 if (XEventGetType(xevent
) == EnterNotify
)
1423 //if (local_event.xcrossing.mode!=NotifyNormal)
1424 // return ; // Ignore grab events
1425 eventType
= wxEVT_ENTER_WINDOW
;
1426 // canvas->GetEventHandler()->OnSetFocus();
1428 else if (XEventGetType(xevent
) == LeaveNotify
)
1430 //if (local_event.xcrossingr.mode!=NotifyNormal)
1431 // return ; // Ignore grab events
1432 eventType
= wxEVT_LEAVE_WINDOW
;
1433 // canvas->GetEventHandler()->OnKillFocus();
1435 else if (XEventGetType(xevent
) == MotionNotify
)
1437 eventType
= wxEVT_MOTION
;
1439 else if (XEventGetType(xevent
) == ButtonPress
)
1441 wxevent
.SetTimestamp(XButtonEventGetTime(xevent
));
1443 if (XButtonEventLChanged(xevent
))
1445 eventType
= wxEVT_LEFT_DOWN
;
1448 else if (XButtonEventMChanged(xevent
))
1450 eventType
= wxEVT_MIDDLE_DOWN
;
1453 else if (XButtonEventRChanged(xevent
))
1455 eventType
= wxEVT_RIGHT_DOWN
;
1459 // check for a double click
1460 // TODO: where can we get this value from?
1461 //long dclickTime = XtGetMultiClickTime(wxGlobalDisplay());
1462 long dclickTime
= 200;
1463 long ts
= wxevent
.GetTimestamp();
1465 int buttonLast
= win
->GetLastClickedButton();
1466 long lastTS
= win
->GetLastClickTime();
1467 if ( buttonLast
&& buttonLast
== button
&& (ts
- lastTS
) < dclickTime
)
1470 win
->SetLastClick(0, ts
);
1471 if ( eventType
== wxEVT_LEFT_DOWN
)
1472 eventType
= wxEVT_LEFT_DCLICK
;
1473 else if ( eventType
== wxEVT_MIDDLE_DOWN
)
1474 eventType
= wxEVT_MIDDLE_DCLICK
;
1475 else if ( eventType
== wxEVT_RIGHT_DOWN
)
1476 eventType
= wxEVT_RIGHT_DCLICK
;
1480 // not fast enough or different button
1481 win
->SetLastClick(button
, ts
);
1484 else if (XEventGetType(xevent
) == ButtonRelease
)
1486 if (XButtonEventLChanged(xevent
))
1488 eventType
= wxEVT_LEFT_UP
;
1490 else if (XButtonEventMChanged(xevent
))
1492 eventType
= wxEVT_MIDDLE_UP
;
1494 else if (XButtonEventRChanged(xevent
))
1496 eventType
= wxEVT_RIGHT_UP
;
1505 wxevent
.SetEventType(eventType
);
1507 wxevent
.m_x
= XButtonEventGetX(xevent
);
1508 wxevent
.m_y
= XButtonEventGetY(xevent
);
1510 wxevent
.m_leftDown
= ((eventType
== wxEVT_LEFT_DOWN
)
1511 || (XButtonEventLIsDown(xevent
)
1512 && (eventType
!= wxEVT_LEFT_UP
)));
1513 wxevent
.m_middleDown
= ((eventType
== wxEVT_MIDDLE_DOWN
)
1514 || (XButtonEventMIsDown(xevent
)
1515 && (eventType
!= wxEVT_MIDDLE_UP
)));
1516 wxevent
.m_rightDown
= ((eventType
== wxEVT_RIGHT_DOWN
)
1517 || (XButtonEventRIsDown (xevent
)
1518 && (eventType
!= wxEVT_RIGHT_UP
)));
1520 wxevent
.m_shiftDown
= XButtonEventShiftIsDown(xevent
);
1521 wxevent
.m_controlDown
= XButtonEventCtrlIsDown(xevent
);
1522 wxevent
.m_altDown
= XButtonEventAltIsDown(xevent
);
1523 wxevent
.m_metaDown
= XButtonEventMetaIsDown(xevent
);
1525 wxevent
.SetId(win
->GetId());
1526 wxevent
.SetEventObject(win
);
1534 bool wxTranslateKeyEvent(wxKeyEvent
& wxevent
, wxWindow
*win
, Window
WXUNUSED(win
), XEvent
*xevent
, bool isAscii
)
1536 switch (XEventGetType(xevent
))
1544 (void) XLookupString ((XKeyEvent
*) xevent
, buf
, 20, &keySym
, NULL
);
1545 int id
= wxCharCodeXToWX (keySym
);
1546 // id may be WXK_xxx code - these are outside ASCII range, so we
1547 // can't just use toupper() on id.
1548 // Only change this if we want the raw key that was pressed,
1549 // and don't change it if we want an ASCII value.
1550 if (!isAscii
&& (id
>= 'a' && id
<= 'z'))
1552 id
= id
+ 'A' - 'a';
1555 wxevent
.m_shiftDown
= XKeyEventShiftIsDown(xevent
);
1556 wxevent
.m_controlDown
= XKeyEventCtrlIsDown(xevent
);
1557 wxevent
.m_altDown
= XKeyEventAltIsDown(xevent
);
1558 wxevent
.m_metaDown
= XKeyEventMetaIsDown(xevent
);
1559 wxevent
.SetEventObject(win
);
1560 wxevent
.m_keyCode
= id
;
1561 wxevent
.SetTimestamp(XKeyEventGetTime(xevent
));
1563 wxevent
.m_x
= XKeyEventGetX(xevent
);
1564 wxevent
.m_y
= XKeyEventGetY(xevent
);
1574 // ----------------------------------------------------------------------------
1576 // ----------------------------------------------------------------------------
1578 bool wxWindowX11::SetBackgroundColour(const wxColour
& col
)
1580 wxWindowBase::SetBackgroundColour(col
);
1582 Display
*xdisplay
= (Display
*) wxGlobalDisplay();
1583 int xscreen
= DefaultScreen( xdisplay
);
1584 Colormap cm
= DefaultColormap( xdisplay
, xscreen
);
1586 m_backgroundColour
.CalcPixel( (WXColormap
) cm
);
1588 // We don't set the background colour as we paint
1589 // the background ourselves.
1590 // XSetWindowBackground( xdisplay, (Window) m_clientWindow, m_backgroundColour.GetPixel() );
1595 bool wxWindowX11::SetForegroundColour(const wxColour
& col
)
1597 if ( !wxWindowBase::SetForegroundColour(col
) )
1603 // ----------------------------------------------------------------------------
1605 // ----------------------------------------------------------------------------
1607 wxWindow
*wxGetActiveWindow()
1610 wxFAIL_MSG(wxT("Not implemented"));
1615 wxWindow
*wxWindowBase::GetCapture()
1617 return (wxWindow
*)g_captureWindow
;
1621 // Find the wxWindow at the current mouse position, returning the mouse
1623 wxWindow
* wxFindWindowAtPointer(wxPoint
& pt
)
1625 return wxFindWindowAtPoint(wxGetMousePosition());
1628 // Get the current mouse position.
1629 wxPoint
wxGetMousePosition()
1633 return wxPoint(0, 0);
1635 Display
*display
= wxGlobalDisplay();
1636 Window rootWindow
= RootWindowOfScreen (DefaultScreenOfDisplay(display
));
1637 Window rootReturn
, childReturn
;
1638 int rootX
, rootY
, winX
, winY
;
1639 unsigned int maskReturn
;
1641 XQueryPointer (display
,
1645 &rootX
, &rootY
, &winX
, &winY
, &maskReturn
);
1646 return wxPoint(rootX
, rootY
);
1651 // ----------------------------------------------------------------------------
1652 // wxNoOptimize: switch off size optimization
1653 // ----------------------------------------------------------------------------
1655 int wxNoOptimize::ms_count
= 0;
1658 // ----------------------------------------------------------------------------
1660 // ----------------------------------------------------------------------------
1662 class wxWinModule
: public wxModule
1669 DECLARE_DYNAMIC_CLASS(wxWinModule
)
1672 IMPLEMENT_DYNAMIC_CLASS(wxWinModule
, wxModule
)
1674 bool wxWinModule::OnInit()
1676 Display
*xdisplay
= wxGlobalDisplay();
1677 int xscreen
= DefaultScreen( xdisplay
);
1678 Window xroot
= RootWindow( xdisplay
, xscreen
);
1679 g_eraseGC
= XCreateGC( xdisplay
, xroot
, 0, NULL
);
1680 XSetFillStyle( xdisplay
, g_eraseGC
, FillSolid
);
1685 void wxWinModule::OnExit()
1687 Display
*xdisplay
= wxGlobalDisplay();
1688 XFreeGC( xdisplay
, g_eraseGC
);