1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/x11/window.cpp
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // for compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
15 #if defined(__BORLANDC__)
19 // ============================================================================
21 // ============================================================================
23 // ----------------------------------------------------------------------------
25 // ----------------------------------------------------------------------------
27 #include "wx/window.h"
37 #include "wx/dcclient.h"
38 #include "wx/button.h"
40 #include "wx/dialog.h"
42 #include "wx/settings.h"
43 #include "wx/msgdlg.h"
44 #include "wx/scrolbar.h"
45 #include "wx/listbox.h"
46 #include "wx/scrolwin.h"
47 #include "wx/layout.h"
48 #include "wx/menuitem.h"
49 #include "wx/module.h"
52 #include "wx/fontutil.h"
53 #include "wx/univ/renderer.h"
55 #if wxUSE_DRAG_AND_DROP
59 #include "wx/x11/private.h"
60 #include "X11/Xutil.h"
64 // ----------------------------------------------------------------------------
65 // global variables for this module
66 // ----------------------------------------------------------------------------
68 static wxWindow
* g_captureWindow
= NULL
;
71 // ----------------------------------------------------------------------------
73 // ----------------------------------------------------------------------------
75 #define event_left_is_down(x) ((x)->xbutton.state & Button1Mask)
76 #define event_middle_is_down(x) ((x)->xbutton.state & Button2Mask)
77 #define event_right_is_down(x) ((x)->xbutton.state & Button3Mask)
79 // ----------------------------------------------------------------------------
81 // ----------------------------------------------------------------------------
83 IMPLEMENT_ABSTRACT_CLASS(wxWindowX11
, wxWindowBase
)
85 BEGIN_EVENT_TABLE(wxWindowX11
, wxWindowBase
)
86 EVT_SYS_COLOUR_CHANGED(wxWindowX11::OnSysColourChanged
)
89 // ============================================================================
91 // ============================================================================
93 // ----------------------------------------------------------------------------
95 // ----------------------------------------------------------------------------
97 // ----------------------------------------------------------------------------
99 // ----------------------------------------------------------------------------
101 void wxWindowX11::Init()
104 m_mainWindow
= (WXWindow
) 0;
105 m_clientWindow
= (WXWindow
) 0;
106 m_insertIntoMain
= false;
107 m_updateNcArea
= false;
109 m_winCaptured
= false;
110 m_needsInputFocus
= false;
116 // real construction (Init() must have been called before!)
117 bool wxWindowX11::Create(wxWindow
*parent
, wxWindowID id
,
121 const wxString
& name
)
123 wxCHECK_MSG( parent
, false, wxT("can't create wxWindow without parent") );
125 CreateBase(parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
);
127 parent
->AddChild(this);
129 Display
*xdisplay
= (Display
*) wxGlobalDisplay();
130 int xscreen
= DefaultScreen( xdisplay
);
131 Visual
*xvisual
= DefaultVisual( xdisplay
, xscreen
);
132 Colormap cm
= DefaultColormap( xdisplay
, xscreen
);
134 m_backgroundColour
= wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE
);
135 m_backgroundColour
.CalcPixel( (WXColormap
) cm
);
137 m_foregroundColour
= *wxBLACK
;
138 m_foregroundColour
.CalcPixel( (WXColormap
) cm
);
140 Window xparent
= (Window
) parent
->GetClientAreaWindow();
142 // Add window's own scrollbars to main window, not to client window
143 if (parent
->GetInsertIntoMain())
145 // wxLogDebug( "Inserted into main: %s", GetName().c_str() );
146 xparent
= (Window
) parent
->GetMainWindow();
149 // Size (not including the border) must be nonzero (or a Value error results)!
150 // Note: The Xlib manual doesn't mention this restriction of XCreateWindow.
158 if (pos2
.x
== wxDefaultCoord
)
160 if (pos2
.y
== wxDefaultCoord
)
163 #if wxUSE_TWO_WINDOWS
164 bool need_two_windows
=
165 ((( wxSUNKEN_BORDER
| wxRAISED_BORDER
| wxSIMPLE_BORDER
| wxHSCROLL
| wxVSCROLL
) & m_windowStyle
) != 0);
167 bool need_two_windows
= false;
171 long xattributes
= 0;
173 XSetWindowAttributes xattributes
;
174 long xattributes_mask
= 0;
176 xattributes_mask
|= CWBackPixel
;
177 xattributes
.background_pixel
= m_backgroundColour
.GetPixel();
179 xattributes_mask
|= CWBorderPixel
;
180 xattributes
.border_pixel
= BlackPixel( xdisplay
, xscreen
);
182 xattributes_mask
|= CWEventMask
;
185 if (need_two_windows
)
188 long backColor
, foreColor
;
189 backColor
= GR_RGB(m_backgroundColour
.Red(), m_backgroundColour
.Green(), m_backgroundColour
.Blue());
190 foreColor
= GR_RGB(m_foregroundColour
.Red(), m_foregroundColour
.Green(), m_foregroundColour
.Blue());
192 Window xwindow
= XCreateWindowWithColor( xdisplay
, xparent
, pos2
.x
, pos2
.y
, size2
.x
, size2
.y
,
193 0, 0, InputOutput
, xvisual
, backColor
, foreColor
);
194 XSelectInput( xdisplay
, xwindow
,
195 GR_EVENT_MASK_CLOSE_REQ
| ExposureMask
| KeyPressMask
| KeyReleaseMask
| ButtonPressMask
| ButtonReleaseMask
|
196 ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
|
197 KeymapStateMask
| FocusChangeMask
| ColormapChangeMask
| StructureNotifyMask
|
198 PropertyChangeMask
);
202 xattributes
.event_mask
=
203 ExposureMask
| StructureNotifyMask
| ColormapChangeMask
;
205 Window xwindow
= XCreateWindow( xdisplay
, xparent
, pos2
.x
, pos2
.y
, size2
.x
, size2
.y
,
206 0, DefaultDepth(xdisplay
,xscreen
), InputOutput
, xvisual
, xattributes_mask
, &xattributes
);
210 XSetWindowBackgroundPixmap( xdisplay
, xwindow
, None
);
212 m_mainWindow
= (WXWindow
) xwindow
;
213 wxAddWindowToTable( xwindow
, (wxWindow
*) this );
215 XMapWindow( xdisplay
, xwindow
);
218 xattributes
.event_mask
=
219 ExposureMask
| KeyPressMask
| KeyReleaseMask
| ButtonPressMask
| ButtonReleaseMask
|
220 ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
|
221 KeymapStateMask
| FocusChangeMask
| ColormapChangeMask
| StructureNotifyMask
|
222 PropertyChangeMask
| VisibilityChangeMask
;
224 if (!HasFlag( wxFULL_REPAINT_ON_RESIZE
))
226 xattributes_mask
|= CWBitGravity
;
227 xattributes
.bit_gravity
= StaticGravity
;
231 if (HasFlag( wxSUNKEN_BORDER
) || HasFlag( wxRAISED_BORDER
))
238 else if (HasFlag( wxSIMPLE_BORDER
))
251 // Make again sure the size is nonzero.
258 backColor
= GR_RGB(m_backgroundColour
.Red(), m_backgroundColour
.Green(), m_backgroundColour
.Blue());
259 foreColor
= GR_RGB(m_foregroundColour
.Red(), m_foregroundColour
.Green(), m_foregroundColour
.Blue());
261 xwindow
= XCreateWindowWithColor( xdisplay
, xwindow
, pos2
.x
, pos2
.y
, size2
.x
, size2
.y
,
262 0, 0, InputOutput
, xvisual
, backColor
, foreColor
);
263 XSelectInput( xdisplay
, xwindow
,
264 GR_EVENT_MASK_CLOSE_REQ
| ExposureMask
| KeyPressMask
| KeyReleaseMask
| ButtonPressMask
| ButtonReleaseMask
|
265 ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
|
266 KeymapStateMask
| FocusChangeMask
| ColormapChangeMask
| StructureNotifyMask
|
267 PropertyChangeMask
);
270 xwindow
= XCreateWindow( xdisplay
, xwindow
, pos2
.x
, pos2
.y
, size2
.x
, size2
.y
,
271 0, DefaultDepth(xdisplay
,xscreen
), InputOutput
, xvisual
, xattributes_mask
, &xattributes
);
274 XSetWindowBackgroundPixmap( xdisplay
, xwindow
, None
);
276 m_clientWindow
= (WXWindow
) xwindow
;
277 wxAddClientWindowToTable( xwindow
, (wxWindow
*) this );
279 XMapWindow( xdisplay
, xwindow
);
283 // wxLogDebug( "No two windows needed %s", GetName().c_str() );
285 long backColor
, foreColor
;
286 backColor
= GR_RGB(m_backgroundColour
.Red(), m_backgroundColour
.Green(), m_backgroundColour
.Blue());
287 foreColor
= GR_RGB(m_foregroundColour
.Red(), m_foregroundColour
.Green(), m_foregroundColour
.Blue());
289 Window xwindow
= XCreateWindowWithColor( xdisplay
, xparent
, pos2
.x
, pos2
.y
, size2
.x
, size2
.y
,
290 0, 0, InputOutput
, xvisual
, backColor
, foreColor
);
291 XSelectInput( xdisplay
, xwindow
,
292 GR_EVENT_MASK_CLOSE_REQ
| ExposureMask
| KeyPressMask
| KeyReleaseMask
| ButtonPressMask
| ButtonReleaseMask
|
293 ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
|
294 KeymapStateMask
| FocusChangeMask
| ColormapChangeMask
| StructureNotifyMask
|
295 PropertyChangeMask
);
298 xattributes
.event_mask
=
299 ExposureMask
| KeyPressMask
| KeyReleaseMask
| ButtonPressMask
| ButtonReleaseMask
|
300 ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
|
301 KeymapStateMask
| FocusChangeMask
| ColormapChangeMask
| StructureNotifyMask
|
302 PropertyChangeMask
| VisibilityChangeMask
;
304 if (!HasFlag( wxFULL_REPAINT_ON_RESIZE
))
306 xattributes_mask
|= CWBitGravity
;
307 xattributes
.bit_gravity
= NorthWestGravity
;
310 Window xwindow
= XCreateWindow( xdisplay
, xparent
, pos2
.x
, pos2
.y
, size2
.x
, size2
.y
,
311 0, DefaultDepth(xdisplay
,xscreen
), InputOutput
, xvisual
, xattributes_mask
, &xattributes
);
314 XSetWindowBackgroundPixmap( xdisplay
, xwindow
, None
);
316 m_mainWindow
= (WXWindow
) xwindow
;
317 m_clientWindow
= m_mainWindow
;
318 wxAddWindowToTable( xwindow
, (wxWindow
*) this );
320 XMapWindow( xdisplay
, xwindow
);
323 // Is a subwindow, so map immediately
326 // Without this, the cursor may not be restored properly (e.g. in splitter
328 SetCursor(*wxSTANDARD_CURSOR
);
329 SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
));
331 // Don't call this, it can have nasty repercussions for composite controls,
333 // SetSize(pos.x, pos.y, size.x, size.y);
339 wxWindowX11::~wxWindowX11()
343 if (g_captureWindow
== this)
344 g_captureWindow
= NULL
;
346 m_isBeingDeleted
= true;
350 if (m_clientWindow
!= m_mainWindow
)
352 // Destroy the cleint window
353 Window xwindow
= (Window
) m_clientWindow
;
354 wxDeleteClientWindowFromTable( xwindow
);
355 XDestroyWindow( wxGlobalDisplay(), xwindow
);
356 m_clientWindow
= NULL
;
359 // Destroy the window
362 Window xwindow
= (Window
) m_mainWindow
;
363 wxDeleteWindowFromTable( xwindow
);
364 XDestroyWindow( wxGlobalDisplay(), xwindow
);
369 // ---------------------------------------------------------------------------
371 // ---------------------------------------------------------------------------
373 void wxWindowX11::SetFocus()
375 Window xwindow
= (Window
) m_clientWindow
;
377 wxCHECK_RET( xwindow
, wxT("invalid window") );
379 // Don't assert; we might be trying to set the focus for a panel
380 // with only static controls, so the panel returns false from AcceptsFocus.
381 // The app should be not be expected to deal with this.
386 if (GetName() == "scrollBar")
393 if (wxWindowIsVisible(xwindow
))
395 wxLogTrace( _T("focus"), _T("wxWindowX11::SetFocus: %s"), GetClassInfo()->GetClassName());
396 // XSetInputFocus( wxGlobalDisplay(), xwindow, RevertToParent, CurrentTime );
397 XSetInputFocus( wxGlobalDisplay(), xwindow
, RevertToNone
, CurrentTime
);
398 m_needsInputFocus
= false;
402 m_needsInputFocus
= true;
406 // Get the window with the focus
407 wxWindow
*wxWindowBase::DoFindFocus()
409 Window xfocus
= (Window
) 0;
412 XGetInputFocus( wxGlobalDisplay(), &xfocus
, &revert
);
415 wxWindow
*win
= wxGetWindowFromTable( xfocus
);
418 win
= wxGetClientWindowFromTable( xfocus
);
427 // Enabling/disabling handled by event loop, and not sending events
429 bool wxWindowX11::Enable(bool enable
)
431 if ( !wxWindowBase::Enable(enable
) )
437 bool wxWindowX11::Show(bool show
)
439 wxWindowBase::Show(show
);
441 Window xwindow
= (Window
) m_mainWindow
;
442 Display
*xdisp
= wxGlobalDisplay();
445 // wxLogDebug( "Mapping window of type %s", GetName().c_str() );
446 XMapWindow(xdisp
, xwindow
);
450 // wxLogDebug( "Unmapping window of type %s", GetName().c_str() );
451 XUnmapWindow(xdisp
, xwindow
);
457 // Raise the window to the top of the Z order
458 void wxWindowX11::Raise()
461 XRaiseWindow( wxGlobalDisplay(), (Window
) m_mainWindow
);
464 // Lower the window to the bottom of the Z order
465 void wxWindowX11::Lower()
468 XLowerWindow( wxGlobalDisplay(), (Window
) m_mainWindow
);
471 void wxWindowX11::SetLabel(const wxString
& WXUNUSED(label
))
476 wxString
wxWindowX11::GetLabel() const
479 return wxEmptyString
;
482 void wxWindowX11::DoCaptureMouse()
484 if ((g_captureWindow
!= NULL
) && (g_captureWindow
!= this))
486 wxFAIL_MSG(wxT("Trying to capture before mouse released."));
497 Window xwindow
= (Window
) m_clientWindow
;
499 wxCHECK_RET( xwindow
, wxT("invalid window") );
501 g_captureWindow
= (wxWindow
*) this;
505 int res
= XGrabPointer(wxGlobalDisplay(), xwindow
,
507 ButtonPressMask
| ButtonReleaseMask
| ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
,
511 None
, /* cursor */ // TODO: This may need to be set to the cursor of this window
514 if (res
!= GrabSuccess
)
517 msg
.Printf(wxT("Failed to grab pointer for window %s"), this->GetClassInfo()->GetClassName());
519 if (res
== GrabNotViewable
)
520 wxLogDebug( wxT("This is not a viewable window - perhaps not shown yet?") );
522 g_captureWindow
= NULL
;
526 m_winCaptured
= true;
530 void wxWindowX11::DoReleaseMouse()
532 g_captureWindow
= NULL
;
534 if ( !m_winCaptured
)
537 Window xwindow
= (Window
) m_clientWindow
;
541 XUngrabPointer( wxGlobalDisplay(), CurrentTime
);
544 // wxLogDebug( "Ungrabbed pointer in %s", GetName().c_str() );
546 m_winCaptured
= false;
549 bool wxWindowX11::SetFont(const wxFont
& font
)
551 if ( !wxWindowBase::SetFont(font
) )
560 bool wxWindowX11::SetCursor(const wxCursor
& cursor
)
562 if ( !wxWindowBase::SetCursor(cursor
) )
568 Window xwindow
= (Window
) m_clientWindow
;
570 wxCHECK_MSG( xwindow
, false, wxT("invalid window") );
572 wxCursor cursorToUse
;
574 cursorToUse
= m_cursor
;
576 cursorToUse
= *wxSTANDARD_CURSOR
;
578 Cursor xcursor
= (Cursor
) cursorToUse
.GetCursor();
580 XDefineCursor( wxGlobalDisplay(), xwindow
, xcursor
);
585 // Coordinates relative to the window
586 void wxWindowX11::WarpPointer (int x
, int y
)
588 Window xwindow
= (Window
) m_clientWindow
;
590 wxCHECK_RET( xwindow
, wxT("invalid window") );
592 XWarpPointer( wxGlobalDisplay(), None
, xwindow
, 0, 0, 0, 0, x
, y
);
595 // Does a physical scroll
596 void wxWindowX11::ScrollWindow(int dx
, int dy
, const wxRect
*rect
)
598 // No scrolling requested.
599 if ((dx
== 0) && (dy
== 0)) return;
601 if (!m_updateRegion
.IsEmpty())
603 m_updateRegion
.Offset( dx
, dy
);
607 GetSize( &cw
, &ch
); // GetClientSize() ??
608 m_updateRegion
.Intersect( 0, 0, cw
, ch
);
611 if (!m_clearRegion
.IsEmpty())
613 m_clearRegion
.Offset( dx
, dy
);
617 GetSize( &cw
, &ch
); // GetClientSize() ??
618 m_clearRegion
.Intersect( 0, 0, cw
, ch
);
621 Window xwindow
= (Window
) GetClientAreaWindow();
623 wxCHECK_RET( xwindow
, wxT("invalid window") );
625 Display
*xdisplay
= wxGlobalDisplay();
627 GC xgc
= XCreateGC( xdisplay
, xwindow
, 0, NULL
);
628 XSetGraphicsExposures( xdisplay
, xgc
, True
);
646 GetClientSize( &cw
, &ch
);
649 #if wxUSE_TWO_WINDOWS
650 wxPoint
offset( 0,0 );
652 wxPoint offset
= GetClientAreaOrigin();
657 int w
= cw
- abs(dx
);
658 int h
= ch
- abs(dy
);
660 if ((h
< 0) || (w
< 0))
667 if (dx
< 0) rect
.x
= cw
+dx
+ offset
.x
; else rect
.x
= s_x
;
668 if (dy
< 0) rect
.y
= ch
+dy
+ offset
.y
; else rect
.y
= s_y
;
669 if (dy
!= 0) rect
.width
= cw
; else rect
.width
= abs(dx
);
670 if (dx
!= 0) rect
.height
= ch
; else rect
.height
= abs(dy
);
675 if (dx
< 0) s_x
+= -dx
;
676 if (dy
< 0) s_y
+= -dy
;
677 if (dx
> 0) d_x
= dx
+ offset
.x
;
678 if (dy
> 0) d_y
= dy
+ offset
.y
;
680 XCopyArea( xdisplay
, xwindow
, xwindow
, xgc
, s_x
, s_y
, w
, h
, d_x
, d_y
);
682 // 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 );
684 // wxLogDebug( "Update: %d %d %d %d", rect.x, rect.y, rect.width, rect.height );
686 m_updateRegion
.Union( rect
);
687 m_clearRegion
.Union( rect
);
690 XFreeGC( xdisplay
, xgc
);
692 // Move Clients, but not the scrollbars
693 // FIXME: There may be a better method to move a lot of Windows within X11
694 wxScrollBar
*sbH
= ((wxWindow
*) this)->GetScrollbar( wxHORIZONTAL
);
695 wxScrollBar
*sbV
= ((wxWindow
*) this)->GetScrollbar( wxVERTICAL
);
696 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
699 // Only propagate to non-top-level windows
700 wxWindow
*win
= node
->GetData();
701 if ( win
->GetParent() && win
!= sbH
&& win
!= sbV
)
703 wxPoint pos
= win
->GetPosition();
704 // Add the delta to the old Position
707 win
->SetPosition(pos
);
709 node
= node
->GetNext();
713 // ---------------------------------------------------------------------------
715 // ---------------------------------------------------------------------------
717 #if wxUSE_DRAG_AND_DROP
719 void wxWindowX11::SetDropTarget(wxDropTarget
* WXUNUSED(pDropTarget
))
726 // Old style file-manager drag&drop
727 void wxWindowX11::DragAcceptFiles(bool WXUNUSED(accept
))
732 // ----------------------------------------------------------------------------
734 // ----------------------------------------------------------------------------
738 void wxWindowX11::DoSetToolTip(wxToolTip
* WXUNUSED(tooltip
))
743 #endif // wxUSE_TOOLTIPS
745 // ---------------------------------------------------------------------------
746 // moving and resizing
747 // ---------------------------------------------------------------------------
749 bool wxWindowX11::PreResize()
755 void wxWindowX11::DoGetSize(int *x
, int *y
) const
757 Window xwindow
= (Window
) m_mainWindow
;
759 wxCHECK_RET( xwindow
, wxT("invalid window") );
761 //XSync(wxGlobalDisplay(), False);
763 XWindowAttributes attr
;
764 Status status
= XGetWindowAttributes( wxGlobalDisplay(), xwindow
, &attr
);
769 *x
= attr
.width
/* + 2*m_borderSize */ ;
770 *y
= attr
.height
/* + 2*m_borderSize */ ;
774 void wxWindowX11::DoGetPosition(int *x
, int *y
) const
776 Window window
= (Window
) m_mainWindow
;
779 //XSync(wxGlobalDisplay(), False);
780 XWindowAttributes attr
;
781 Status status
= XGetWindowAttributes(wxGlobalDisplay(), window
, & attr
);
789 // We may be faking the client origin. So a window that's really at (0, 30)
790 // may appear (to wxWin apps) to be at (0, 0).
793 wxPoint
pt(GetParent()->GetClientAreaOrigin());
801 void wxWindowX11::DoScreenToClient(int *x
, int *y
) const
803 Display
*display
= wxGlobalDisplay();
804 Window rootWindow
= RootWindowOfScreen(DefaultScreenOfDisplay(display
));
805 Window thisWindow
= (Window
) m_clientWindow
;
810 XTranslateCoordinates(display
, rootWindow
, thisWindow
, xx
, yy
, x
, y
, &childWindow
);
813 void wxWindowX11::DoClientToScreen(int *x
, int *y
) const
815 Display
*display
= wxGlobalDisplay();
816 Window rootWindow
= RootWindowOfScreen(DefaultScreenOfDisplay(display
));
817 Window thisWindow
= (Window
) m_clientWindow
;
822 XTranslateCoordinates(display
, thisWindow
, rootWindow
, xx
, yy
, x
, y
, &childWindow
);
826 // Get size *available for subwindows* i.e. excluding menu bar etc.
827 void wxWindowX11::DoGetClientSize(int *x
, int *y
) const
829 Window window
= (Window
) m_mainWindow
;
833 XWindowAttributes attr
;
834 Status status
= XGetWindowAttributes( wxGlobalDisplay(), window
, &attr
);
845 void wxWindowX11::DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
847 // wxLogDebug("DoSetSize: %s (%ld) %d, %d %dx%d", GetClassInfo()->GetClassName(), GetId(), x, y, width, height);
849 Window xwindow
= (Window
) m_mainWindow
;
851 wxCHECK_RET( xwindow
, wxT("invalid window") );
853 XWindowAttributes attr
;
854 Status status
= XGetWindowAttributes( wxGlobalDisplay(), xwindow
, &attr
);
855 wxCHECK_RET( status
, wxT("invalid window attributes") );
859 int new_w
= attr
.width
;
860 int new_h
= attr
.height
;
862 if (x
!= wxDefaultCoord
|| (sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
865 AdjustForParentClientOrigin( x
, yy
, sizeFlags
);
868 if (y
!= wxDefaultCoord
|| (sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
871 AdjustForParentClientOrigin( xx
, y
, sizeFlags
);
874 if (width
!= wxDefaultCoord
)
880 if (height
!= wxDefaultCoord
)
887 DoMoveWindow( new_x
, new_y
, new_w
, new_h
);
890 void wxWindowX11::DoSetClientSize(int width
, int height
)
892 // wxLogDebug("DoSetClientSize: %s (%ld) %dx%d", GetClassInfo()->GetClassName(), GetId(), width, height);
894 Window xwindow
= (Window
) m_mainWindow
;
896 wxCHECK_RET( xwindow
, wxT("invalid window") );
898 XResizeWindow( wxGlobalDisplay(), xwindow
, width
, height
);
900 if (m_mainWindow
!= m_clientWindow
)
902 xwindow
= (Window
) m_clientWindow
;
904 wxWindow
*window
= (wxWindow
*) this;
905 wxRenderer
*renderer
= window
->GetRenderer();
908 wxRect border
= renderer
->GetBorderDimensions( (wxBorder
)(m_windowStyle
& wxBORDER_MASK
) );
909 width
-= border
.x
+ border
.width
;
910 height
-= border
.y
+ border
.height
;
913 XResizeWindow( wxGlobalDisplay(), xwindow
, width
, height
);
917 void wxWindowX11::DoMoveWindow(int x
, int y
, int width
, int height
)
919 Window xwindow
= (Window
) m_mainWindow
;
921 wxCHECK_RET( xwindow
, wxT("invalid window") );
925 XMoveResizeWindow( wxGlobalDisplay(), xwindow
, x
, y
, width
, height
);
926 if (m_mainWindow
!= m_clientWindow
)
928 xwindow
= (Window
) m_clientWindow
;
930 wxWindow
*window
= (wxWindow
*) this;
931 wxRenderer
*renderer
= window
->GetRenderer();
934 wxRect border
= renderer
->GetBorderDimensions( (wxBorder
)(m_windowStyle
& wxBORDER_MASK
) );
937 width
-= border
.x
+ border
.width
;
938 height
-= border
.y
+ border
.height
;
946 wxScrollBar
*sb
= window
->GetScrollbar( wxHORIZONTAL
);
947 if (sb
&& sb
->IsShown())
949 wxSize size
= sb
->GetSize();
952 sb
= window
->GetScrollbar( wxVERTICAL
);
953 if (sb
&& sb
->IsShown())
955 wxSize size
= sb
->GetSize();
959 XMoveResizeWindow( wxGlobalDisplay(), xwindow
, x
, y
, wxMax(1, width
), wxMax(1, height
) );
964 XWindowChanges windowChanges
;
967 windowChanges
.width
= width
;
968 windowChanges
.height
= height
;
969 windowChanges
.stack_mode
= 0;
970 int valueMask
= CWX
| CWY
| CWWidth
| CWHeight
;
972 XConfigureWindow( wxGlobalDisplay(), xwindow
, valueMask
, &windowChanges
);
977 void wxWindowX11::DoSetSizeHints(int minW
, int minH
, int maxW
, int maxH
, int incW
, int incH
)
985 XSizeHints sizeHints
;
988 if (minW
> -1 && minH
> -1)
990 sizeHints
.flags
|= PMinSize
;
991 sizeHints
.min_width
= minW
;
992 sizeHints
.min_height
= minH
;
994 if (maxW
> -1 && maxH
> -1)
996 sizeHints
.flags
|= PMaxSize
;
997 sizeHints
.max_width
= maxW
;
998 sizeHints
.max_height
= maxH
;
1000 if (incW
> -1 && incH
> -1)
1002 sizeHints
.flags
|= PResizeInc
;
1003 sizeHints
.width_inc
= incW
;
1004 sizeHints
.height_inc
= incH
;
1007 XSetWMNormalHints(wxGlobalDisplay(), (Window
) m_mainWindow
, &sizeHints
);
1011 // ---------------------------------------------------------------------------
1013 // ---------------------------------------------------------------------------
1015 int wxWindowX11::GetCharHeight() const
1017 wxFont
font(GetFont());
1018 wxCHECK_MSG( font
.Ok(), 0, wxT("valid window font needed") );
1021 // There should be an easier way.
1022 PangoLayout
*layout
= pango_layout_new( wxTheApp
->GetPangoContext() );
1023 pango_layout_set_font_description( layout
, font
.GetNativeFontInfo()->description
);
1024 pango_layout_set_text(layout
, "H", 1 );
1026 pango_layout_get_pixel_size(layout
, &w
, &h
);
1027 g_object_unref( G_OBJECT( layout
) );
1031 WXFontStructPtr pFontStruct
= font
.GetFontStruct(1.0, wxGlobalDisplay());
1033 int direction
, ascent
, descent
;
1034 XCharStruct overall
;
1035 XTextExtents ((XFontStruct
*) pFontStruct
, "x", 1, &direction
, &ascent
,
1036 &descent
, &overall
);
1038 // return (overall.ascent + overall.descent);
1039 return (ascent
+ descent
);
1043 int wxWindowX11::GetCharWidth() const
1045 wxFont
font(GetFont());
1046 wxCHECK_MSG( font
.Ok(), 0, wxT("valid window font needed") );
1049 // There should be an easier way.
1050 PangoLayout
*layout
= pango_layout_new( wxTheApp
->GetPangoContext() );
1051 pango_layout_set_font_description( layout
, font
.GetNativeFontInfo()->description
);
1052 pango_layout_set_text(layout
, "H", 1 );
1054 pango_layout_get_pixel_size(layout
, &w
, &h
);
1055 g_object_unref( G_OBJECT( layout
) );
1059 WXFontStructPtr pFontStruct
= font
.GetFontStruct(1.0, wxGlobalDisplay());
1061 int direction
, ascent
, descent
;
1062 XCharStruct overall
;
1063 XTextExtents ((XFontStruct
*) pFontStruct
, "x", 1, &direction
, &ascent
,
1064 &descent
, &overall
);
1066 return overall
.width
;
1070 void wxWindowX11::GetTextExtent(const wxString
& string
,
1072 int *descent
, int *externalLeading
,
1073 const wxFont
*theFont
) const
1075 wxFont fontToUse
= GetFont();
1076 if (theFont
) fontToUse
= *theFont
;
1078 wxCHECK_RET( fontToUse
.Ok(), wxT("invalid font") );
1088 PangoLayout
*layout
= pango_layout_new( wxTheApp
->GetPangoContext() );
1090 PangoFontDescription
*desc
= fontToUse
.GetNativeFontInfo()->description
;
1091 pango_layout_set_font_description(layout
, desc
);
1093 const wxCharBuffer data
= wxConvUTF8
.cWC2MB( string
);
1094 pango_layout_set_text(layout
, (const char*) data
, strlen( (const char*) data
));
1096 PangoLayoutLine
*line
= (PangoLayoutLine
*)pango_layout_get_lines(layout
)->data
;
1099 PangoRectangle rect
;
1100 pango_layout_line_get_extents(line
, NULL
, &rect
);
1102 if (x
) (*x
) = (wxCoord
) (rect
.width
/ PANGO_SCALE
);
1103 if (y
) (*y
) = (wxCoord
) (rect
.height
/ PANGO_SCALE
);
1106 // Do something about metrics here
1109 if (externalLeading
) (*externalLeading
) = 0; // ??
1111 g_object_unref( G_OBJECT( layout
) );
1113 WXFontStructPtr pFontStruct
= fontToUse
.GetFontStruct(1.0, wxGlobalDisplay());
1115 int direction
, ascent
, descent2
;
1116 XCharStruct overall
;
1117 int slen
= string
.length();
1119 XTextExtents((XFontStruct
*) pFontStruct
, (char*) string
.c_str(), slen
,
1120 &direction
, &ascent
, &descent2
, &overall
);
1123 *x
= (overall
.width
);
1125 *y
= (ascent
+ descent2
);
1127 *descent
= descent2
;
1128 if (externalLeading
)
1129 *externalLeading
= 0;
1133 // ----------------------------------------------------------------------------
1135 // ----------------------------------------------------------------------------
1137 void wxWindowX11::Refresh(bool eraseBack
, const wxRect
*rect
)
1143 // Schedule for later Updating in ::Update() or ::OnInternalIdle().
1144 m_clearRegion
.Union( rect
->x
, rect
->y
, rect
->width
, rect
->height
);
1149 GetSize( &width
, &height
);
1151 // Schedule for later Updating in ::Update() or ::OnInternalIdle().
1152 m_clearRegion
.Clear();
1153 m_clearRegion
.Union( 0, 0, width
, height
);
1159 // Schedule for later Updating in ::Update() or ::OnInternalIdle().
1160 m_updateRegion
.Union( rect
->x
, rect
->y
, rect
->width
, rect
->height
);
1165 GetSize( &width
, &height
);
1167 // Schedule for later Updating in ::Update() or ::OnInternalIdle().
1168 m_updateRegion
.Clear();
1169 m_updateRegion
.Union( 0, 0, width
, height
);
1173 void wxWindowX11::Update()
1177 // wxLogDebug("wxWindowX11::UpdateNC: %s", GetClassInfo()->GetClassName());
1178 // Send nc paint events.
1179 SendNcPaintEvents();
1182 if (!m_updateRegion
.IsEmpty())
1184 // wxLogDebug("wxWindowX11::Update: %s", GetClassInfo()->GetClassName());
1185 // Actually send erase events.
1188 // Actually send paint events.
1193 void wxWindowX11::SendEraseEvents()
1195 if (m_clearRegion
.IsEmpty()) return;
1197 wxClientDC
dc( (wxWindow
*)this );
1198 dc
.SetClippingRegion( m_clearRegion
);
1200 wxEraseEvent
erase_event( GetId(), &dc
);
1201 erase_event
.SetEventObject( this );
1203 if (!GetEventHandler()->ProcessEvent(erase_event
) )
1205 Display
*xdisplay
= wxGlobalDisplay();
1206 Window xwindow
= (Window
) GetClientAreaWindow();
1207 XSetForeground( xdisplay
, g_eraseGC
, m_backgroundColour
.GetPixel() );
1209 wxRegionIterator
upd( m_clearRegion
);
1212 XFillRectangle( xdisplay
, xwindow
, g_eraseGC
,
1213 upd
.GetX(), upd
.GetY(), upd
.GetWidth(), upd
.GetHeight() );
1218 m_clearRegion
.Clear();
1221 void wxWindowX11::SendPaintEvents()
1223 // wxLogDebug("SendPaintEvents: %s (%ld)", GetClassInfo()->GetClassName(), GetId());
1225 m_clipPaintRegion
= true;
1227 wxPaintEvent
paint_event( GetId() );
1228 paint_event
.SetEventObject( this );
1229 GetEventHandler()->ProcessEvent( paint_event
);
1231 m_updateRegion
.Clear();
1233 m_clipPaintRegion
= false;
1236 void wxWindowX11::SendNcPaintEvents()
1238 wxWindow
*window
= (wxWindow
*) this;
1240 // All this for drawing the small square between the scrollbars.
1245 wxScrollBar
*sb
= window
->GetScrollbar( wxHORIZONTAL
);
1246 if (sb
&& sb
->IsShown())
1248 height
= sb
->GetSize().y
;
1249 y
= sb
->GetPosition().y
;
1251 sb
= window
->GetScrollbar( wxVERTICAL
);
1252 if (sb
&& sb
->IsShown())
1254 width
= sb
->GetSize().x
;
1255 x
= sb
->GetPosition().x
;
1257 Display
*xdisplay
= wxGlobalDisplay();
1258 Window xwindow
= (Window
) GetMainWindow();
1259 Colormap cm
= (Colormap
) wxTheApp
->GetMainColormap( wxGetDisplay() );
1260 wxColour colour
= wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
);
1261 colour
.CalcPixel( (WXColormap
) cm
);
1263 XSetForeground( xdisplay
, g_eraseGC
, colour
.GetPixel() );
1265 XFillRectangle( xdisplay
, xwindow
, g_eraseGC
, x
, y
, width
, height
);
1269 wxNcPaintEvent
nc_paint_event( GetId() );
1270 nc_paint_event
.SetEventObject( this );
1271 GetEventHandler()->ProcessEvent( nc_paint_event
);
1273 m_updateNcArea
= false;
1276 // ----------------------------------------------------------------------------
1278 // ----------------------------------------------------------------------------
1280 // Responds to colour changes: passes event on to children.
1281 void wxWindowX11::OnSysColourChanged(wxSysColourChangedEvent
& event
)
1283 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
1286 // Only propagate to non-top-level windows
1287 wxWindow
*win
= node
->GetData();
1288 if ( win
->GetParent() )
1290 wxSysColourChangedEvent event2
;
1291 event
.SetEventObject(win
);
1292 win
->GetEventHandler()->ProcessEvent(event2
);
1295 node
= node
->GetNext();
1299 // See handler for InFocus case in app.cpp for details.
1300 wxWindow
* g_GettingFocus
= NULL
;
1302 void wxWindowX11::OnInternalIdle()
1304 // Update invalidated regions.
1307 // This calls the UI-update mechanism (querying windows for
1308 // menu/toolbar/control state information)
1309 if (wxUpdateUIEvent::CanUpdate((wxWindow
*) this))
1310 UpdateWindowUI(wxUPDATE_UI_FROMIDLE
);
1312 // Set the input focus if couldn't do it before
1313 if (m_needsInputFocus
)
1317 msg
.Printf("Setting focus for %s from OnInternalIdle\n", GetClassInfo()->GetClassName());
1318 printf(msg
.c_str());
1322 // If it couldn't set the focus now, there's
1323 // no point in trying again.
1324 m_needsInputFocus
= false;
1326 g_GettingFocus
= NULL
;
1329 // ----------------------------------------------------------------------------
1330 // function which maintain the global hash table mapping Widgets to wxWidgets
1331 // ----------------------------------------------------------------------------
1333 static bool DoAddWindowToTable(wxWindowHash
*hash
, Window w
, wxWindow
*win
)
1335 if ( !hash
->insert(wxWindowHash::value_type(w
, win
)).second
)
1337 wxLogDebug( wxT("Widget table clash: new widget is 0x%08x, %s"),
1338 (unsigned int)w
, win
->GetClassInfo()->GetClassName());
1342 wxLogTrace( wxT("widget"), wxT("XWindow 0x%08x <-> window %p (%s)"),
1343 (unsigned int) w
, win
, win
->GetClassInfo()->GetClassName());
1348 static inline wxWindow
*DoGetWindowFromTable(wxWindowHash
*hash
, Window w
)
1350 wxWindowHash::iterator i
= hash
->find(w
);
1351 return i
== hash
->end() ? NULL
: i
->second
;
1354 static inline void DoDeleteWindowFromTable(wxWindowHash
*hash
, Window w
)
1356 wxLogTrace( wxT("widget"), wxT("XWindow 0x%08x deleted"), (unsigned int) w
);
1361 // ----------------------------------------------------------------------------
1363 // ----------------------------------------------------------------------------
1365 bool wxAddWindowToTable(Window w
, wxWindow
*win
)
1367 return DoAddWindowToTable(wxWidgetHashTable
, w
, win
);
1370 wxWindow
*wxGetWindowFromTable(Window w
)
1372 return DoGetWindowFromTable(wxWidgetHashTable
, w
);
1375 void wxDeleteWindowFromTable(Window w
)
1377 DoDeleteWindowFromTable(wxWidgetHashTable
, w
);
1380 bool wxAddClientWindowToTable(Window w
, wxWindow
*win
)
1382 return DoAddWindowToTable(wxClientWidgetHashTable
, w
, win
);
1385 wxWindow
*wxGetClientWindowFromTable(Window w
)
1387 return DoGetWindowFromTable(wxClientWidgetHashTable
, w
);
1390 void wxDeleteClientWindowFromTable(Window w
)
1392 DoDeleteWindowFromTable(wxClientWidgetHashTable
, w
);
1395 // ----------------------------------------------------------------------------
1396 // X11-specific accessors
1397 // ----------------------------------------------------------------------------
1399 WXWindow
wxWindowX11::GetMainWindow() const
1401 return m_mainWindow
;
1404 WXWindow
wxWindowX11::GetClientAreaWindow() const
1406 return m_clientWindow
;
1409 // ----------------------------------------------------------------------------
1410 // TranslateXXXEvent() functions
1411 // ----------------------------------------------------------------------------
1413 bool wxTranslateMouseEvent(wxMouseEvent
& wxevent
, wxWindow
*win
, Window window
, XEvent
*xevent
)
1415 switch (XEventGetType(xevent
))
1423 wxEventType eventType
= wxEVT_NULL
;
1425 if (XEventGetType(xevent
) == EnterNotify
)
1427 //if (local_event.xcrossing.mode!=NotifyNormal)
1428 // return ; // Ignore grab events
1429 eventType
= wxEVT_ENTER_WINDOW
;
1430 // canvas->GetEventHandler()->OnSetFocus();
1432 else if (XEventGetType(xevent
) == LeaveNotify
)
1434 //if (local_event.xcrossingr.mode!=NotifyNormal)
1435 // return ; // Ignore grab events
1436 eventType
= wxEVT_LEAVE_WINDOW
;
1437 // canvas->GetEventHandler()->OnKillFocus();
1439 else if (XEventGetType(xevent
) == MotionNotify
)
1441 eventType
= wxEVT_MOTION
;
1443 else if (XEventGetType(xevent
) == ButtonPress
)
1445 wxevent
.SetTimestamp(XButtonEventGetTime(xevent
));
1447 if (XButtonEventLChanged(xevent
))
1449 eventType
= wxEVT_LEFT_DOWN
;
1452 else if (XButtonEventMChanged(xevent
))
1454 eventType
= wxEVT_MIDDLE_DOWN
;
1457 else if (XButtonEventRChanged(xevent
))
1459 eventType
= wxEVT_RIGHT_DOWN
;
1463 // check for a double click
1464 // TODO: where can we get this value from?
1465 //long dclickTime = XtGetMultiClickTime(wxGlobalDisplay());
1466 long dclickTime
= 200;
1467 long ts
= wxevent
.GetTimestamp();
1469 int buttonLast
= win
->GetLastClickedButton();
1470 long lastTS
= win
->GetLastClickTime();
1471 if ( buttonLast
&& buttonLast
== button
&& (ts
- lastTS
) < dclickTime
)
1474 win
->SetLastClick(0, ts
);
1475 if ( eventType
== wxEVT_LEFT_DOWN
)
1476 eventType
= wxEVT_LEFT_DCLICK
;
1477 else if ( eventType
== wxEVT_MIDDLE_DOWN
)
1478 eventType
= wxEVT_MIDDLE_DCLICK
;
1479 else if ( eventType
== wxEVT_RIGHT_DOWN
)
1480 eventType
= wxEVT_RIGHT_DCLICK
;
1484 // not fast enough or different button
1485 win
->SetLastClick(button
, ts
);
1488 else if (XEventGetType(xevent
) == ButtonRelease
)
1490 if (XButtonEventLChanged(xevent
))
1492 eventType
= wxEVT_LEFT_UP
;
1494 else if (XButtonEventMChanged(xevent
))
1496 eventType
= wxEVT_MIDDLE_UP
;
1498 else if (XButtonEventRChanged(xevent
))
1500 eventType
= wxEVT_RIGHT_UP
;
1509 wxevent
.SetEventType(eventType
);
1511 wxevent
.m_x
= XButtonEventGetX(xevent
);
1512 wxevent
.m_y
= XButtonEventGetY(xevent
);
1514 wxevent
.m_leftDown
= ((eventType
== wxEVT_LEFT_DOWN
)
1515 || (XButtonEventLIsDown(xevent
)
1516 && (eventType
!= wxEVT_LEFT_UP
)));
1517 wxevent
.m_middleDown
= ((eventType
== wxEVT_MIDDLE_DOWN
)
1518 || (XButtonEventMIsDown(xevent
)
1519 && (eventType
!= wxEVT_MIDDLE_UP
)));
1520 wxevent
.m_rightDown
= ((eventType
== wxEVT_RIGHT_DOWN
)
1521 || (XButtonEventRIsDown (xevent
)
1522 && (eventType
!= wxEVT_RIGHT_UP
)));
1524 wxevent
.m_shiftDown
= XButtonEventShiftIsDown(xevent
);
1525 wxevent
.m_controlDown
= XButtonEventCtrlIsDown(xevent
);
1526 wxevent
.m_altDown
= XButtonEventAltIsDown(xevent
);
1527 wxevent
.m_metaDown
= XButtonEventMetaIsDown(xevent
);
1529 wxevent
.SetId(win
->GetId());
1530 wxevent
.SetEventObject(win
);
1538 bool wxTranslateKeyEvent(wxKeyEvent
& wxevent
, wxWindow
*win
, Window
WXUNUSED(win
), XEvent
*xevent
, bool isAscii
)
1540 switch (XEventGetType(xevent
))
1548 (void) XLookupString ((XKeyEvent
*) xevent
, buf
, 20, &keySym
, NULL
);
1549 int id
= wxCharCodeXToWX (keySym
);
1550 // id may be WXK_xxx code - these are outside ASCII range, so we
1551 // can't just use toupper() on id.
1552 // Only change this if we want the raw key that was pressed,
1553 // and don't change it if we want an ASCII value.
1554 if (!isAscii
&& (id
>= 'a' && id
<= 'z'))
1556 id
= id
+ 'A' - 'a';
1559 wxevent
.m_shiftDown
= XKeyEventShiftIsDown(xevent
);
1560 wxevent
.m_controlDown
= XKeyEventCtrlIsDown(xevent
);
1561 wxevent
.m_altDown
= XKeyEventAltIsDown(xevent
);
1562 wxevent
.m_metaDown
= XKeyEventMetaIsDown(xevent
);
1563 wxevent
.SetEventObject(win
);
1564 wxevent
.m_keyCode
= id
;
1565 wxevent
.SetTimestamp(XKeyEventGetTime(xevent
));
1567 wxevent
.m_x
= XKeyEventGetX(xevent
);
1568 wxevent
.m_y
= XKeyEventGetY(xevent
);
1578 // ----------------------------------------------------------------------------
1580 // ----------------------------------------------------------------------------
1582 bool wxWindowX11::SetBackgroundColour(const wxColour
& col
)
1584 wxWindowBase::SetBackgroundColour(col
);
1586 Display
*xdisplay
= (Display
*) wxGlobalDisplay();
1587 int xscreen
= DefaultScreen( xdisplay
);
1588 Colormap cm
= DefaultColormap( xdisplay
, xscreen
);
1590 m_backgroundColour
.CalcPixel( (WXColormap
) cm
);
1592 // We don't set the background colour as we paint
1593 // the background ourselves.
1594 // XSetWindowBackground( xdisplay, (Window) m_clientWindow, m_backgroundColour.GetPixel() );
1599 bool wxWindowX11::SetForegroundColour(const wxColour
& col
)
1601 if ( !wxWindowBase::SetForegroundColour(col
) )
1607 // ----------------------------------------------------------------------------
1609 // ----------------------------------------------------------------------------
1611 wxWindow
*wxGetActiveWindow()
1614 wxFAIL_MSG(wxT("Not implemented"));
1619 wxWindow
*wxWindowBase::GetCapture()
1621 return (wxWindow
*)g_captureWindow
;
1625 // Find the wxWindow at the current mouse position, returning the mouse
1627 wxWindow
* wxFindWindowAtPointer(wxPoint
& pt
)
1629 return wxFindWindowAtPoint(wxGetMousePosition());
1632 void wxGetMouseState(int& rootX
, int& rootY
, unsigned& maskReturn
)
1639 Display
*display
= wxGlobalDisplay();
1640 Window rootWindow
= RootWindowOfScreen (DefaultScreenOfDisplay(display
));
1641 Window rootReturn
, childReturn
;
1644 XQueryPointer (display
,
1648 &rootX
, &rootY
, &winX
, &winY
, &maskReturn
);
1652 // Get the current mouse position.
1653 wxPoint
wxGetMousePosition()
1658 wxGetMouseState(x
, y
, mask
);
1659 return wxPoint(x
, y
);
1662 wxMouseState
wxGetMouseState()
1668 wxGetMouseState(x
, y
, mask
);
1673 ms
.SetLeftDown(mask
& Button1Mask
);
1674 ms
.SetMiddleDown(mask
& Button2Mask
);
1675 ms
.SetRightDown(mask
& Button3Mask
);
1677 ms
.SetControlDown(mask
& ControlMask
);
1678 ms
.SetShiftDown(mask
& ShiftMask
);
1679 ms
.SetAltDown(mask
& Mod3Mask
);
1680 ms
.SetMetaDown(mask
& Mod1Mask
);
1686 // ----------------------------------------------------------------------------
1687 // wxNoOptimize: switch off size optimization
1688 // ----------------------------------------------------------------------------
1690 int wxNoOptimize::ms_count
= 0;
1693 // ----------------------------------------------------------------------------
1695 // ----------------------------------------------------------------------------
1697 class wxWinModule
: public wxModule
1702 // we must be cleaned up before the display is closed
1703 AddDependency(wxClassInfo::FindClass(_T("wxX11DisplayModule")));
1706 virtual bool OnInit();
1707 virtual void OnExit();
1710 DECLARE_DYNAMIC_CLASS(wxWinModule
)
1713 IMPLEMENT_DYNAMIC_CLASS(wxWinModule
, wxModule
)
1715 bool wxWinModule::OnInit()
1717 Display
*xdisplay
= wxGlobalDisplay();
1718 int xscreen
= DefaultScreen( xdisplay
);
1719 Window xroot
= RootWindow( xdisplay
, xscreen
);
1720 g_eraseGC
= XCreateGC( xdisplay
, xroot
, 0, NULL
);
1721 XSetFillStyle( xdisplay
, g_eraseGC
, FillSolid
);
1726 void wxWinModule::OnExit()
1728 Display
*xdisplay
= wxGlobalDisplay();
1729 XFreeGC( xdisplay
, g_eraseGC
);