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 AdjustForParentClientOrigin(pos2
.x
, pos2
.y
);
165 #if wxUSE_TWO_WINDOWS
166 bool need_two_windows
=
167 ((( wxSUNKEN_BORDER
| wxRAISED_BORDER
| wxSIMPLE_BORDER
| wxHSCROLL
| wxVSCROLL
) & m_windowStyle
) != 0);
169 bool need_two_windows
= false;
173 long xattributes
= 0;
175 XSetWindowAttributes xattributes
;
176 long xattributes_mask
= 0;
178 xattributes_mask
|= CWBackPixel
;
179 xattributes
.background_pixel
= m_backgroundColour
.GetPixel();
181 xattributes_mask
|= CWBorderPixel
;
182 xattributes
.border_pixel
= BlackPixel( xdisplay
, xscreen
);
184 xattributes_mask
|= CWEventMask
;
187 if (need_two_windows
)
190 long backColor
, foreColor
;
191 backColor
= GR_RGB(m_backgroundColour
.Red(), m_backgroundColour
.Green(), m_backgroundColour
.Blue());
192 foreColor
= GR_RGB(m_foregroundColour
.Red(), m_foregroundColour
.Green(), m_foregroundColour
.Blue());
194 Window xwindow
= XCreateWindowWithColor( xdisplay
, xparent
, pos2
.x
, pos2
.y
, size2
.x
, size2
.y
,
195 0, 0, InputOutput
, xvisual
, backColor
, foreColor
);
196 XSelectInput( xdisplay
, xwindow
,
197 GR_EVENT_MASK_CLOSE_REQ
| ExposureMask
| KeyPressMask
| KeyReleaseMask
| ButtonPressMask
| ButtonReleaseMask
|
198 ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
|
199 KeymapStateMask
| FocusChangeMask
| ColormapChangeMask
| StructureNotifyMask
|
200 PropertyChangeMask
);
204 xattributes
.event_mask
=
205 ExposureMask
| StructureNotifyMask
| ColormapChangeMask
;
207 Window xwindow
= XCreateWindow( xdisplay
, xparent
, pos2
.x
, pos2
.y
, size2
.x
, size2
.y
,
208 0, DefaultDepth(xdisplay
,xscreen
), InputOutput
, xvisual
, xattributes_mask
, &xattributes
);
212 XSetWindowBackgroundPixmap( xdisplay
, xwindow
, None
);
214 m_mainWindow
= (WXWindow
) xwindow
;
215 wxAddWindowToTable( xwindow
, (wxWindow
*) this );
217 XMapWindow( xdisplay
, xwindow
);
220 xattributes
.event_mask
=
221 ExposureMask
| KeyPressMask
| KeyReleaseMask
| ButtonPressMask
| ButtonReleaseMask
|
222 ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
|
223 KeymapStateMask
| FocusChangeMask
| ColormapChangeMask
| StructureNotifyMask
|
224 PropertyChangeMask
| VisibilityChangeMask
;
226 if (!HasFlag( wxFULL_REPAINT_ON_RESIZE
))
228 xattributes_mask
|= CWBitGravity
;
229 xattributes
.bit_gravity
= StaticGravity
;
233 if (HasFlag( wxSUNKEN_BORDER
) || HasFlag( wxRAISED_BORDER
))
240 else if (HasFlag( wxSIMPLE_BORDER
))
253 // Make again sure the size is nonzero.
260 backColor
= GR_RGB(m_backgroundColour
.Red(), m_backgroundColour
.Green(), m_backgroundColour
.Blue());
261 foreColor
= GR_RGB(m_foregroundColour
.Red(), m_foregroundColour
.Green(), m_foregroundColour
.Blue());
263 xwindow
= XCreateWindowWithColor( xdisplay
, xwindow
, pos2
.x
, pos2
.y
, size2
.x
, size2
.y
,
264 0, 0, InputOutput
, xvisual
, backColor
, foreColor
);
265 XSelectInput( xdisplay
, xwindow
,
266 GR_EVENT_MASK_CLOSE_REQ
| ExposureMask
| KeyPressMask
| KeyReleaseMask
| ButtonPressMask
| ButtonReleaseMask
|
267 ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
|
268 KeymapStateMask
| FocusChangeMask
| ColormapChangeMask
| StructureNotifyMask
|
269 PropertyChangeMask
);
272 xwindow
= XCreateWindow( xdisplay
, xwindow
, pos2
.x
, pos2
.y
, size2
.x
, size2
.y
,
273 0, DefaultDepth(xdisplay
,xscreen
), InputOutput
, xvisual
, xattributes_mask
, &xattributes
);
276 XSetWindowBackgroundPixmap( xdisplay
, xwindow
, None
);
278 m_clientWindow
= (WXWindow
) xwindow
;
279 wxAddClientWindowToTable( xwindow
, (wxWindow
*) this );
281 XMapWindow( xdisplay
, xwindow
);
285 // wxLogDebug( "No two windows needed %s", GetName().c_str() );
287 long backColor
, foreColor
;
288 backColor
= GR_RGB(m_backgroundColour
.Red(), m_backgroundColour
.Green(), m_backgroundColour
.Blue());
289 foreColor
= GR_RGB(m_foregroundColour
.Red(), m_foregroundColour
.Green(), m_foregroundColour
.Blue());
291 Window xwindow
= XCreateWindowWithColor( xdisplay
, xparent
, pos2
.x
, pos2
.y
, size2
.x
, size2
.y
,
292 0, 0, InputOutput
, xvisual
, backColor
, foreColor
);
293 XSelectInput( xdisplay
, xwindow
,
294 GR_EVENT_MASK_CLOSE_REQ
| ExposureMask
| KeyPressMask
| KeyReleaseMask
| ButtonPressMask
| ButtonReleaseMask
|
295 ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
|
296 KeymapStateMask
| FocusChangeMask
| ColormapChangeMask
| StructureNotifyMask
|
297 PropertyChangeMask
);
300 xattributes
.event_mask
=
301 ExposureMask
| KeyPressMask
| KeyReleaseMask
| ButtonPressMask
| ButtonReleaseMask
|
302 ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
|
303 KeymapStateMask
| FocusChangeMask
| ColormapChangeMask
| StructureNotifyMask
|
304 PropertyChangeMask
| VisibilityChangeMask
;
306 if (!HasFlag( wxFULL_REPAINT_ON_RESIZE
))
308 xattributes_mask
|= CWBitGravity
;
309 xattributes
.bit_gravity
= NorthWestGravity
;
312 Window xwindow
= XCreateWindow( xdisplay
, xparent
, pos2
.x
, pos2
.y
, size2
.x
, size2
.y
,
313 0, DefaultDepth(xdisplay
,xscreen
), InputOutput
, xvisual
, xattributes_mask
, &xattributes
);
316 XSetWindowBackgroundPixmap( xdisplay
, xwindow
, None
);
318 m_mainWindow
= (WXWindow
) xwindow
;
319 m_clientWindow
= m_mainWindow
;
320 wxAddWindowToTable( xwindow
, (wxWindow
*) this );
322 XMapWindow( xdisplay
, xwindow
);
325 // Is a subwindow, so map immediately
328 // Without this, the cursor may not be restored properly (e.g. in splitter
330 SetCursor(*wxSTANDARD_CURSOR
);
331 SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
));
333 // Don't call this, it can have nasty repercussions for composite controls,
335 // SetSize(pos.x, pos.y, size.x, size.y);
341 wxWindowX11::~wxWindowX11()
345 if (g_captureWindow
== this)
346 g_captureWindow
= NULL
;
348 m_isBeingDeleted
= true;
352 if (m_clientWindow
!= m_mainWindow
)
354 // Destroy the cleint window
355 Window xwindow
= (Window
) m_clientWindow
;
356 wxDeleteClientWindowFromTable( xwindow
);
357 XDestroyWindow( wxGlobalDisplay(), xwindow
);
358 m_clientWindow
= NULL
;
361 // Destroy the window
364 Window xwindow
= (Window
) m_mainWindow
;
365 wxDeleteWindowFromTable( xwindow
);
366 XDestroyWindow( wxGlobalDisplay(), xwindow
);
371 // ---------------------------------------------------------------------------
373 // ---------------------------------------------------------------------------
375 void wxWindowX11::SetFocus()
377 Window xwindow
= (Window
) m_clientWindow
;
379 wxCHECK_RET( xwindow
, wxT("invalid window") );
381 // Don't assert; we might be trying to set the focus for a panel
382 // with only static controls, so the panel returns false from AcceptsFocus.
383 // The app should be not be expected to deal with this.
388 if (GetName() == "scrollBar")
395 if (wxWindowIsVisible(xwindow
))
397 wxLogTrace( _T("focus"), _T("wxWindowX11::SetFocus: %s"), GetClassInfo()->GetClassName());
398 // XSetInputFocus( wxGlobalDisplay(), xwindow, RevertToParent, CurrentTime );
399 XSetInputFocus( wxGlobalDisplay(), xwindow
, RevertToNone
, CurrentTime
);
400 m_needsInputFocus
= false;
404 m_needsInputFocus
= true;
408 // Get the window with the focus
409 wxWindow
*wxWindowBase::DoFindFocus()
411 Window xfocus
= (Window
) 0;
414 XGetInputFocus( wxGlobalDisplay(), &xfocus
, &revert
);
417 wxWindow
*win
= wxGetWindowFromTable( xfocus
);
420 win
= wxGetClientWindowFromTable( xfocus
);
429 // Enabling/disabling handled by event loop, and not sending events
431 bool wxWindowX11::Enable(bool enable
)
433 if ( !wxWindowBase::Enable(enable
) )
439 bool wxWindowX11::Show(bool show
)
441 wxWindowBase::Show(show
);
443 Window xwindow
= (Window
) m_mainWindow
;
444 Display
*xdisp
= wxGlobalDisplay();
447 // wxLogDebug( "Mapping window of type %s", GetName().c_str() );
448 XMapWindow(xdisp
, xwindow
);
452 // wxLogDebug( "Unmapping window of type %s", GetName().c_str() );
453 XUnmapWindow(xdisp
, xwindow
);
459 // Raise the window to the top of the Z order
460 void wxWindowX11::Raise()
463 XRaiseWindow( wxGlobalDisplay(), (Window
) m_mainWindow
);
466 // Lower the window to the bottom of the Z order
467 void wxWindowX11::Lower()
470 XLowerWindow( wxGlobalDisplay(), (Window
) m_mainWindow
);
473 void wxWindowX11::SetLabel(const wxString
& WXUNUSED(label
))
478 wxString
wxWindowX11::GetLabel() const
481 return wxEmptyString
;
484 void wxWindowX11::DoCaptureMouse()
486 if ((g_captureWindow
!= NULL
) && (g_captureWindow
!= this))
488 wxFAIL_MSG(wxT("Trying to capture before mouse released."));
499 Window xwindow
= (Window
) m_clientWindow
;
501 wxCHECK_RET( xwindow
, wxT("invalid window") );
503 g_captureWindow
= (wxWindow
*) this;
507 int res
= XGrabPointer(wxGlobalDisplay(), xwindow
,
509 ButtonPressMask
| ButtonReleaseMask
| ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
,
513 None
, /* cursor */ // TODO: This may need to be set to the cursor of this window
516 if (res
!= GrabSuccess
)
519 msg
.Printf(wxT("Failed to grab pointer for window %s"), this->GetClassInfo()->GetClassName());
521 if (res
== GrabNotViewable
)
522 wxLogDebug( wxT("This is not a viewable window - perhaps not shown yet?") );
524 g_captureWindow
= NULL
;
528 m_winCaptured
= true;
532 void wxWindowX11::DoReleaseMouse()
534 g_captureWindow
= NULL
;
536 if ( !m_winCaptured
)
539 Window xwindow
= (Window
) m_clientWindow
;
543 XUngrabPointer( wxGlobalDisplay(), CurrentTime
);
546 // wxLogDebug( "Ungrabbed pointer in %s", GetName().c_str() );
548 m_winCaptured
= false;
551 bool wxWindowX11::SetFont(const wxFont
& font
)
553 if ( !wxWindowBase::SetFont(font
) )
562 bool wxWindowX11::SetCursor(const wxCursor
& cursor
)
564 if ( !wxWindowBase::SetCursor(cursor
) )
570 Window xwindow
= (Window
) m_clientWindow
;
572 wxCHECK_MSG( xwindow
, false, wxT("invalid window") );
574 wxCursor cursorToUse
;
576 cursorToUse
= m_cursor
;
578 cursorToUse
= *wxSTANDARD_CURSOR
;
580 Cursor xcursor
= (Cursor
) cursorToUse
.GetCursor();
582 XDefineCursor( wxGlobalDisplay(), xwindow
, xcursor
);
587 // Coordinates relative to the window
588 void wxWindowX11::WarpPointer (int x
, int y
)
590 Window xwindow
= (Window
) m_clientWindow
;
592 wxCHECK_RET( xwindow
, wxT("invalid window") );
594 XWarpPointer( wxGlobalDisplay(), None
, xwindow
, 0, 0, 0, 0, x
, y
);
597 // Does a physical scroll
598 void wxWindowX11::ScrollWindow(int dx
, int dy
, const wxRect
*rect
)
600 // No scrolling requested.
601 if ((dx
== 0) && (dy
== 0)) return;
603 if (!m_updateRegion
.IsEmpty())
605 m_updateRegion
.Offset( dx
, dy
);
609 GetSize( &cw
, &ch
); // GetClientSize() ??
610 m_updateRegion
.Intersect( 0, 0, cw
, ch
);
613 if (!m_clearRegion
.IsEmpty())
615 m_clearRegion
.Offset( dx
, dy
);
619 GetSize( &cw
, &ch
); // GetClientSize() ??
620 m_clearRegion
.Intersect( 0, 0, cw
, ch
);
623 Window xwindow
= (Window
) GetClientAreaWindow();
625 wxCHECK_RET( xwindow
, wxT("invalid window") );
627 Display
*xdisplay
= wxGlobalDisplay();
629 GC xgc
= XCreateGC( xdisplay
, xwindow
, 0, NULL
);
630 XSetGraphicsExposures( xdisplay
, xgc
, True
);
648 GetClientSize( &cw
, &ch
);
651 #if wxUSE_TWO_WINDOWS
652 wxPoint
offset( 0,0 );
654 wxPoint offset
= GetClientAreaOrigin();
659 int w
= cw
- abs(dx
);
660 int h
= ch
- abs(dy
);
662 if ((h
< 0) || (w
< 0))
669 if (dx
< 0) rect
.x
= cw
+dx
+ offset
.x
; else rect
.x
= s_x
;
670 if (dy
< 0) rect
.y
= ch
+dy
+ offset
.y
; else rect
.y
= s_y
;
671 if (dy
!= 0) rect
.width
= cw
; else rect
.width
= abs(dx
);
672 if (dx
!= 0) rect
.height
= ch
; else rect
.height
= abs(dy
);
677 if (dx
< 0) s_x
+= -dx
;
678 if (dy
< 0) s_y
+= -dy
;
679 if (dx
> 0) d_x
+= dx
+ offset
.x
;
680 if (dy
> 0) d_y
+= dy
+ offset
.y
;
682 XCopyArea( xdisplay
, xwindow
, xwindow
, xgc
, s_x
, s_y
, w
, h
, d_x
, d_y
);
684 // 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 );
686 // wxLogDebug( "Update: %d %d %d %d", rect.x, rect.y, rect.width, rect.height );
688 m_updateRegion
.Union( rect
);
689 m_clearRegion
.Union( rect
);
692 XFreeGC( xdisplay
, xgc
);
694 // Move Clients, but not the scrollbars
695 // FIXME: There may be a better method to move a lot of Windows within X11
696 wxScrollBar
*sbH
= ((wxWindow
*) this)->GetScrollbar( wxHORIZONTAL
);
697 wxScrollBar
*sbV
= ((wxWindow
*) this)->GetScrollbar( wxVERTICAL
);
698 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
701 // Only propagate to non-top-level windows
702 wxWindow
*win
= node
->GetData();
703 if ( win
->GetParent() && win
!= sbH
&& win
!= sbV
)
705 wxPoint pos
= win
->GetPosition();
706 // Add the delta to the old Position
709 win
->SetPosition(pos
);
711 node
= node
->GetNext();
715 // ---------------------------------------------------------------------------
717 // ---------------------------------------------------------------------------
719 #if wxUSE_DRAG_AND_DROP
721 void wxWindowX11::SetDropTarget(wxDropTarget
* WXUNUSED(pDropTarget
))
728 // Old style file-manager drag&drop
729 void wxWindowX11::DragAcceptFiles(bool WXUNUSED(accept
))
734 // ----------------------------------------------------------------------------
736 // ----------------------------------------------------------------------------
740 void wxWindowX11::DoSetToolTip(wxToolTip
* WXUNUSED(tooltip
))
745 #endif // wxUSE_TOOLTIPS
747 // ---------------------------------------------------------------------------
748 // moving and resizing
749 // ---------------------------------------------------------------------------
751 bool wxWindowX11::PreResize()
757 void wxWindowX11::DoGetSize(int *x
, int *y
) const
759 Window xwindow
= (Window
) m_mainWindow
;
761 wxCHECK_RET( xwindow
, wxT("invalid window") );
763 //XSync(wxGlobalDisplay(), False);
765 XWindowAttributes attr
;
766 Status status
= XGetWindowAttributes( wxGlobalDisplay(), xwindow
, &attr
);
771 *x
= attr
.width
/* + 2*m_borderSize */ ;
772 *y
= attr
.height
/* + 2*m_borderSize */ ;
776 void wxWindowX11::DoGetPosition(int *x
, int *y
) const
778 Window window
= (Window
) m_mainWindow
;
781 //XSync(wxGlobalDisplay(), False);
782 XWindowAttributes attr
;
783 Status status
= XGetWindowAttributes(wxGlobalDisplay(), window
, & attr
);
791 // We may be faking the client origin. So a window that's really at (0, 30)
792 // may appear (to wxWin apps) to be at (0, 0).
795 wxPoint
pt(GetParent()->GetClientAreaOrigin());
803 void wxWindowX11::DoScreenToClient(int *x
, int *y
) const
805 Display
*display
= wxGlobalDisplay();
806 Window rootWindow
= RootWindowOfScreen(DefaultScreenOfDisplay(display
));
807 Window thisWindow
= (Window
) m_clientWindow
;
812 XTranslateCoordinates(display
, rootWindow
, thisWindow
,
813 xx
, yy
, x
? x
: &xx
, y
? y
: &yy
,
817 void wxWindowX11::DoClientToScreen(int *x
, int *y
) const
819 Display
*display
= wxGlobalDisplay();
820 Window rootWindow
= RootWindowOfScreen(DefaultScreenOfDisplay(display
));
821 Window thisWindow
= (Window
) m_clientWindow
;
826 XTranslateCoordinates(display
, thisWindow
, rootWindow
,
827 xx
, yy
, x
? x
: &xx
, y
? y
: &yy
,
832 // Get size *available for subwindows* i.e. excluding menu bar etc.
833 void wxWindowX11::DoGetClientSize(int *x
, int *y
) const
835 Window window
= (Window
) m_mainWindow
;
839 XWindowAttributes attr
;
840 Status status
= XGetWindowAttributes( wxGlobalDisplay(), window
, &attr
);
851 void wxWindowX11::DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
853 // wxLogDebug("DoSetSize: %s (%ld) %d, %d %dx%d", GetClassInfo()->GetClassName(), GetId(), x, y, width, height);
855 Window xwindow
= (Window
) m_mainWindow
;
857 wxCHECK_RET( xwindow
, wxT("invalid window") );
859 XWindowAttributes attr
;
860 Status status
= XGetWindowAttributes( wxGlobalDisplay(), xwindow
, &attr
);
861 wxCHECK_RET( status
, wxT("invalid window attributes") );
865 int new_w
= attr
.width
;
866 int new_h
= attr
.height
;
868 if (x
!= wxDefaultCoord
|| (sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
871 AdjustForParentClientOrigin( x
, yy
, sizeFlags
);
874 if (y
!= wxDefaultCoord
|| (sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
877 AdjustForParentClientOrigin( xx
, y
, sizeFlags
);
880 if (width
!= wxDefaultCoord
)
886 if (height
!= wxDefaultCoord
)
893 DoMoveWindow( new_x
, new_y
, new_w
, new_h
);
896 void wxWindowX11::DoSetClientSize(int width
, int height
)
898 // wxLogDebug("DoSetClientSize: %s (%ld) %dx%d", GetClassInfo()->GetClassName(), GetId(), width, height);
900 Window xwindow
= (Window
) m_mainWindow
;
902 wxCHECK_RET( xwindow
, wxT("invalid window") );
904 XResizeWindow( wxGlobalDisplay(), xwindow
, width
, height
);
906 if (m_mainWindow
!= m_clientWindow
)
908 xwindow
= (Window
) m_clientWindow
;
910 wxWindow
*window
= (wxWindow
*) this;
911 wxRenderer
*renderer
= window
->GetRenderer();
914 wxRect border
= renderer
->GetBorderDimensions( (wxBorder
)(m_windowStyle
& wxBORDER_MASK
) );
915 width
-= border
.x
+ border
.width
;
916 height
-= border
.y
+ border
.height
;
919 XResizeWindow( wxGlobalDisplay(), xwindow
, width
, height
);
923 void wxWindowX11::DoMoveWindow(int x
, int y
, int width
, int height
)
925 Window xwindow
= (Window
) m_mainWindow
;
927 wxCHECK_RET( xwindow
, wxT("invalid window") );
931 XMoveResizeWindow( wxGlobalDisplay(), xwindow
, x
, y
, width
, height
);
932 if (m_mainWindow
!= m_clientWindow
)
934 xwindow
= (Window
) m_clientWindow
;
936 wxWindow
*window
= (wxWindow
*) this;
937 wxRenderer
*renderer
= window
->GetRenderer();
940 wxRect border
= renderer
->GetBorderDimensions( (wxBorder
)(m_windowStyle
& wxBORDER_MASK
) );
943 width
-= border
.x
+ border
.width
;
944 height
-= border
.y
+ border
.height
;
952 wxScrollBar
*sb
= window
->GetScrollbar( wxHORIZONTAL
);
953 if (sb
&& sb
->IsShown())
955 wxSize size
= sb
->GetSize();
958 sb
= window
->GetScrollbar( wxVERTICAL
);
959 if (sb
&& sb
->IsShown())
961 wxSize size
= sb
->GetSize();
965 XMoveResizeWindow( wxGlobalDisplay(), xwindow
, x
, y
, wxMax(1, width
), wxMax(1, height
) );
970 XWindowChanges windowChanges
;
973 windowChanges
.width
= width
;
974 windowChanges
.height
= height
;
975 windowChanges
.stack_mode
= 0;
976 int valueMask
= CWX
| CWY
| CWWidth
| CWHeight
;
978 XConfigureWindow( wxGlobalDisplay(), xwindow
, valueMask
, &windowChanges
);
983 void wxWindowX11::DoSetSizeHints(int minW
, int minH
, int maxW
, int maxH
, int incW
, int incH
)
991 XSizeHints sizeHints
;
994 if (minW
> -1 && minH
> -1)
996 sizeHints
.flags
|= PMinSize
;
997 sizeHints
.min_width
= minW
;
998 sizeHints
.min_height
= minH
;
1000 if (maxW
> -1 && maxH
> -1)
1002 sizeHints
.flags
|= PMaxSize
;
1003 sizeHints
.max_width
= maxW
;
1004 sizeHints
.max_height
= maxH
;
1006 if (incW
> -1 && incH
> -1)
1008 sizeHints
.flags
|= PResizeInc
;
1009 sizeHints
.width_inc
= incW
;
1010 sizeHints
.height_inc
= incH
;
1013 XSetWMNormalHints(wxGlobalDisplay(), (Window
) m_mainWindow
, &sizeHints
);
1017 // ---------------------------------------------------------------------------
1019 // ---------------------------------------------------------------------------
1021 int wxWindowX11::GetCharHeight() const
1023 wxFont
font(GetFont());
1024 wxCHECK_MSG( font
.Ok(), 0, wxT("valid window font needed") );
1027 // There should be an easier way.
1028 PangoLayout
*layout
= pango_layout_new( wxTheApp
->GetPangoContext() );
1029 pango_layout_set_font_description( layout
, font
.GetNativeFontInfo()->description
);
1030 pango_layout_set_text(layout
, "H", 1 );
1032 pango_layout_get_pixel_size(layout
, &w
, &h
);
1033 g_object_unref( G_OBJECT( layout
) );
1037 WXFontStructPtr pFontStruct
= font
.GetFontStruct(1.0, wxGlobalDisplay());
1039 int direction
, ascent
, descent
;
1040 XCharStruct overall
;
1041 XTextExtents ((XFontStruct
*) pFontStruct
, "x", 1, &direction
, &ascent
,
1042 &descent
, &overall
);
1044 // return (overall.ascent + overall.descent);
1045 return (ascent
+ descent
);
1049 int wxWindowX11::GetCharWidth() const
1051 wxFont
font(GetFont());
1052 wxCHECK_MSG( font
.Ok(), 0, wxT("valid window font needed") );
1055 // There should be an easier way.
1056 PangoLayout
*layout
= pango_layout_new( wxTheApp
->GetPangoContext() );
1057 pango_layout_set_font_description( layout
, font
.GetNativeFontInfo()->description
);
1058 pango_layout_set_text(layout
, "H", 1 );
1060 pango_layout_get_pixel_size(layout
, &w
, &h
);
1061 g_object_unref( G_OBJECT( layout
) );
1065 WXFontStructPtr pFontStruct
= font
.GetFontStruct(1.0, wxGlobalDisplay());
1067 int direction
, ascent
, descent
;
1068 XCharStruct overall
;
1069 XTextExtents ((XFontStruct
*) pFontStruct
, "x", 1, &direction
, &ascent
,
1070 &descent
, &overall
);
1072 return overall
.width
;
1076 void wxWindowX11::GetTextExtent(const wxString
& string
,
1078 int *descent
, int *externalLeading
,
1079 const wxFont
*theFont
) const
1081 wxFont fontToUse
= GetFont();
1082 if (theFont
) fontToUse
= *theFont
;
1084 wxCHECK_RET( fontToUse
.Ok(), wxT("invalid font") );
1094 PangoLayout
*layout
= pango_layout_new( wxTheApp
->GetPangoContext() );
1096 PangoFontDescription
*desc
= fontToUse
.GetNativeFontInfo()->description
;
1097 pango_layout_set_font_description(layout
, desc
);
1099 const wxCharBuffer data
= wxConvUTF8
.cWC2MB( string
);
1100 pango_layout_set_text(layout
, (const char*) data
, strlen( (const char*) data
));
1102 PangoLayoutLine
*line
= (PangoLayoutLine
*)pango_layout_get_lines(layout
)->data
;
1105 PangoRectangle rect
;
1106 pango_layout_line_get_extents(line
, NULL
, &rect
);
1108 if (x
) (*x
) = (wxCoord
) (rect
.width
/ PANGO_SCALE
);
1109 if (y
) (*y
) = (wxCoord
) (rect
.height
/ PANGO_SCALE
);
1112 // Do something about metrics here
1115 if (externalLeading
) (*externalLeading
) = 0; // ??
1117 g_object_unref( G_OBJECT( layout
) );
1119 WXFontStructPtr pFontStruct
= fontToUse
.GetFontStruct(1.0, wxGlobalDisplay());
1121 int direction
, ascent
, descent2
;
1122 XCharStruct overall
;
1123 int slen
= string
.length();
1125 XTextExtents((XFontStruct
*) pFontStruct
, (const char*) string
.c_str(), slen
,
1126 &direction
, &ascent
, &descent2
, &overall
);
1129 *x
= (overall
.width
);
1131 *y
= (ascent
+ descent2
);
1133 *descent
= descent2
;
1134 if (externalLeading
)
1135 *externalLeading
= 0;
1139 // ----------------------------------------------------------------------------
1141 // ----------------------------------------------------------------------------
1143 void wxWindowX11::Refresh(bool eraseBack
, const wxRect
*rect
)
1149 // Schedule for later Updating in ::Update() or ::OnInternalIdle().
1150 m_clearRegion
.Union( rect
->x
, rect
->y
, rect
->width
, rect
->height
);
1155 GetSize( &width
, &height
);
1157 // Schedule for later Updating in ::Update() or ::OnInternalIdle().
1158 m_clearRegion
.Clear();
1159 m_clearRegion
.Union( 0, 0, width
, height
);
1165 // Schedule for later Updating in ::Update() or ::OnInternalIdle().
1166 m_updateRegion
.Union( rect
->x
, rect
->y
, rect
->width
, rect
->height
);
1171 GetSize( &width
, &height
);
1173 // Schedule for later Updating in ::Update() or ::OnInternalIdle().
1174 m_updateRegion
.Clear();
1175 m_updateRegion
.Union( 0, 0, width
, height
);
1179 void wxWindowX11::Update()
1183 // wxLogDebug("wxWindowX11::UpdateNC: %s", GetClassInfo()->GetClassName());
1184 // Send nc paint events.
1185 SendNcPaintEvents();
1188 if (!m_updateRegion
.IsEmpty())
1190 // wxLogDebug("wxWindowX11::Update: %s", GetClassInfo()->GetClassName());
1191 // Actually send erase events.
1194 // Actually send paint events.
1199 void wxWindowX11::SendEraseEvents()
1201 if (m_clearRegion
.IsEmpty()) return;
1203 wxClientDC
dc( (wxWindow
*)this );
1204 dc
.SetClippingRegion( m_clearRegion
);
1206 wxEraseEvent
erase_event( GetId(), &dc
);
1207 erase_event
.SetEventObject( this );
1209 if (!GetEventHandler()->ProcessEvent(erase_event
) )
1211 Display
*xdisplay
= wxGlobalDisplay();
1212 Window xwindow
= (Window
) GetClientAreaWindow();
1213 XSetForeground( xdisplay
, g_eraseGC
, m_backgroundColour
.GetPixel() );
1215 wxRegionIterator
upd( m_clearRegion
);
1218 XFillRectangle( xdisplay
, xwindow
, g_eraseGC
,
1219 upd
.GetX(), upd
.GetY(), upd
.GetWidth(), upd
.GetHeight() );
1224 m_clearRegion
.Clear();
1227 void wxWindowX11::SendPaintEvents()
1229 // wxLogDebug("SendPaintEvents: %s (%ld)", GetClassInfo()->GetClassName(), GetId());
1231 m_clipPaintRegion
= true;
1233 wxPaintEvent
paint_event( GetId() );
1234 paint_event
.SetEventObject( this );
1235 GetEventHandler()->ProcessEvent( paint_event
);
1237 m_updateRegion
.Clear();
1239 m_clipPaintRegion
= false;
1242 void wxWindowX11::SendNcPaintEvents()
1244 wxWindow
*window
= (wxWindow
*) this;
1246 // All this for drawing the small square between the scrollbars.
1251 wxScrollBar
*sb
= window
->GetScrollbar( wxHORIZONTAL
);
1252 if (sb
&& sb
->IsShown())
1254 height
= sb
->GetSize().y
;
1255 y
= sb
->GetPosition().y
;
1257 sb
= window
->GetScrollbar( wxVERTICAL
);
1258 if (sb
&& sb
->IsShown())
1260 width
= sb
->GetSize().x
;
1261 x
= sb
->GetPosition().x
;
1263 Display
*xdisplay
= wxGlobalDisplay();
1264 Window xwindow
= (Window
) GetMainWindow();
1265 Colormap cm
= (Colormap
) wxTheApp
->GetMainColormap( wxGetDisplay() );
1266 wxColour colour
= wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
);
1267 colour
.CalcPixel( (WXColormap
) cm
);
1269 XSetForeground( xdisplay
, g_eraseGC
, colour
.GetPixel() );
1271 XFillRectangle( xdisplay
, xwindow
, g_eraseGC
, x
, y
, width
, height
);
1275 wxNcPaintEvent
nc_paint_event( GetId() );
1276 nc_paint_event
.SetEventObject( this );
1277 GetEventHandler()->ProcessEvent( nc_paint_event
);
1279 m_updateNcArea
= false;
1282 // ----------------------------------------------------------------------------
1284 // ----------------------------------------------------------------------------
1286 // Responds to colour changes: passes event on to children.
1287 void wxWindowX11::OnSysColourChanged(wxSysColourChangedEvent
& event
)
1289 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
1292 // Only propagate to non-top-level windows
1293 wxWindow
*win
= node
->GetData();
1294 if ( win
->GetParent() )
1296 wxSysColourChangedEvent event2
;
1297 event
.SetEventObject(win
);
1298 win
->GetEventHandler()->ProcessEvent(event2
);
1301 node
= node
->GetNext();
1305 // See handler for InFocus case in app.cpp for details.
1306 wxWindow
* g_GettingFocus
= NULL
;
1308 void wxWindowX11::OnInternalIdle()
1310 // Update invalidated regions.
1313 // This calls the UI-update mechanism (querying windows for
1314 // menu/toolbar/control state information)
1315 if (wxUpdateUIEvent::CanUpdate((wxWindow
*) this) && IsShown())
1316 UpdateWindowUI(wxUPDATE_UI_FROMIDLE
);
1318 // Set the input focus if couldn't do it before
1319 if (m_needsInputFocus
)
1323 msg
.Printf("Setting focus for %s from OnInternalIdle\n", GetClassInfo()->GetClassName());
1324 printf(msg
.c_str());
1328 // If it couldn't set the focus now, there's
1329 // no point in trying again.
1330 m_needsInputFocus
= false;
1332 g_GettingFocus
= NULL
;
1335 // ----------------------------------------------------------------------------
1336 // function which maintain the global hash table mapping Widgets to wxWidgets
1337 // ----------------------------------------------------------------------------
1339 static bool DoAddWindowToTable(wxWindowHash
*hash
, Window w
, wxWindow
*win
)
1341 if ( !hash
->insert(wxWindowHash::value_type(w
, win
)).second
)
1343 wxLogDebug( wxT("Widget table clash: new widget is 0x%08x, %s"),
1344 (unsigned int)w
, win
->GetClassInfo()->GetClassName());
1348 wxLogTrace( wxT("widget"), wxT("XWindow 0x%08x <-> window %p (%s)"),
1349 (unsigned int) w
, win
, win
->GetClassInfo()->GetClassName());
1354 static inline wxWindow
*DoGetWindowFromTable(wxWindowHash
*hash
, Window w
)
1356 wxWindowHash::iterator i
= hash
->find(w
);
1357 return i
== hash
->end() ? NULL
: i
->second
;
1360 static inline void DoDeleteWindowFromTable(wxWindowHash
*hash
, Window w
)
1362 wxLogTrace( wxT("widget"), wxT("XWindow 0x%08x deleted"), (unsigned int) w
);
1367 // ----------------------------------------------------------------------------
1369 // ----------------------------------------------------------------------------
1371 bool wxAddWindowToTable(Window w
, wxWindow
*win
)
1373 return DoAddWindowToTable(wxWidgetHashTable
, w
, win
);
1376 wxWindow
*wxGetWindowFromTable(Window w
)
1378 return DoGetWindowFromTable(wxWidgetHashTable
, w
);
1381 void wxDeleteWindowFromTable(Window w
)
1383 DoDeleteWindowFromTable(wxWidgetHashTable
, w
);
1386 bool wxAddClientWindowToTable(Window w
, wxWindow
*win
)
1388 return DoAddWindowToTable(wxClientWidgetHashTable
, w
, win
);
1391 wxWindow
*wxGetClientWindowFromTable(Window w
)
1393 return DoGetWindowFromTable(wxClientWidgetHashTable
, w
);
1396 void wxDeleteClientWindowFromTable(Window w
)
1398 DoDeleteWindowFromTable(wxClientWidgetHashTable
, w
);
1401 // ----------------------------------------------------------------------------
1402 // X11-specific accessors
1403 // ----------------------------------------------------------------------------
1405 WXWindow
wxWindowX11::GetMainWindow() const
1407 return m_mainWindow
;
1410 WXWindow
wxWindowX11::GetClientAreaWindow() const
1412 return m_clientWindow
;
1415 // ----------------------------------------------------------------------------
1416 // TranslateXXXEvent() functions
1417 // ----------------------------------------------------------------------------
1419 bool wxTranslateMouseEvent(wxMouseEvent
& wxevent
, wxWindow
*win
, Window window
, XEvent
*xevent
)
1421 switch (XEventGetType(xevent
))
1429 wxEventType eventType
= wxEVT_NULL
;
1431 if (XEventGetType(xevent
) == EnterNotify
)
1433 //if (local_event.xcrossing.mode!=NotifyNormal)
1434 // return ; // Ignore grab events
1435 eventType
= wxEVT_ENTER_WINDOW
;
1436 // canvas->GetEventHandler()->OnSetFocus();
1438 else if (XEventGetType(xevent
) == LeaveNotify
)
1440 //if (local_event.xcrossingr.mode!=NotifyNormal)
1441 // return ; // Ignore grab events
1442 eventType
= wxEVT_LEAVE_WINDOW
;
1443 // canvas->GetEventHandler()->OnKillFocus();
1445 else if (XEventGetType(xevent
) == MotionNotify
)
1447 eventType
= wxEVT_MOTION
;
1449 else if (XEventGetType(xevent
) == ButtonPress
)
1451 wxevent
.SetTimestamp(XButtonEventGetTime(xevent
));
1453 if (XButtonEventLChanged(xevent
))
1455 eventType
= wxEVT_LEFT_DOWN
;
1458 else if (XButtonEventMChanged(xevent
))
1460 eventType
= wxEVT_MIDDLE_DOWN
;
1463 else if (XButtonEventRChanged(xevent
))
1465 eventType
= wxEVT_RIGHT_DOWN
;
1468 else if ( xevent
->xbutton
.button
== Button4
||
1469 xevent
->xbutton
.button
== Button5
)
1471 // this is the same value as used under wxMSW
1472 static const int WHEEL_DELTA
= 120;
1474 eventType
= wxEVT_MOUSEWHEEL
;
1475 button
= xevent
->xbutton
.button
;
1477 wxevent
.m_linesPerAction
= 3;
1478 wxevent
.m_wheelDelta
= WHEEL_DELTA
;
1480 // Button 4 means mousewheel up, 5 means down
1481 wxevent
.m_wheelRotation
= button
== Button4
? WHEEL_DELTA
1485 // check for a double click
1486 // TODO: where can we get this value from?
1487 //long dclickTime = XtGetMultiClickTime(wxGlobalDisplay());
1488 long dclickTime
= 200;
1489 long ts
= wxevent
.GetTimestamp();
1491 int buttonLast
= win
->GetLastClickedButton();
1492 long lastTS
= win
->GetLastClickTime();
1493 if ( buttonLast
&& buttonLast
== button
&& (ts
- lastTS
) < dclickTime
)
1496 win
->SetLastClick(0, ts
);
1497 if ( eventType
== wxEVT_LEFT_DOWN
)
1498 eventType
= wxEVT_LEFT_DCLICK
;
1499 else if ( eventType
== wxEVT_MIDDLE_DOWN
)
1500 eventType
= wxEVT_MIDDLE_DCLICK
;
1501 else if ( eventType
== wxEVT_RIGHT_DOWN
)
1502 eventType
= wxEVT_RIGHT_DCLICK
;
1506 // not fast enough or different button
1507 win
->SetLastClick(button
, ts
);
1510 else if (XEventGetType(xevent
) == ButtonRelease
)
1512 if (XButtonEventLChanged(xevent
))
1514 eventType
= wxEVT_LEFT_UP
;
1516 else if (XButtonEventMChanged(xevent
))
1518 eventType
= wxEVT_MIDDLE_UP
;
1520 else if (XButtonEventRChanged(xevent
))
1522 eventType
= wxEVT_RIGHT_UP
;
1531 wxevent
.SetEventType(eventType
);
1533 wxevent
.m_x
= XButtonEventGetX(xevent
);
1534 wxevent
.m_y
= XButtonEventGetY(xevent
);
1536 wxevent
.m_leftDown
= ((eventType
== wxEVT_LEFT_DOWN
)
1537 || (XButtonEventLIsDown(xevent
)
1538 && (eventType
!= wxEVT_LEFT_UP
)));
1539 wxevent
.m_middleDown
= ((eventType
== wxEVT_MIDDLE_DOWN
)
1540 || (XButtonEventMIsDown(xevent
)
1541 && (eventType
!= wxEVT_MIDDLE_UP
)));
1542 wxevent
.m_rightDown
= ((eventType
== wxEVT_RIGHT_DOWN
)
1543 || (XButtonEventRIsDown (xevent
)
1544 && (eventType
!= wxEVT_RIGHT_UP
)));
1546 wxevent
.m_shiftDown
= XButtonEventShiftIsDown(xevent
);
1547 wxevent
.m_controlDown
= XButtonEventCtrlIsDown(xevent
);
1548 wxevent
.m_altDown
= XButtonEventAltIsDown(xevent
);
1549 wxevent
.m_metaDown
= XButtonEventMetaIsDown(xevent
);
1551 wxevent
.SetId(win
->GetId());
1552 wxevent
.SetEventObject(win
);
1560 bool wxTranslateKeyEvent(wxKeyEvent
& wxevent
, wxWindow
*win
, Window
WXUNUSED(win
), XEvent
*xevent
, bool isAscii
)
1562 switch (XEventGetType(xevent
))
1570 (void) XLookupString ((XKeyEvent
*) xevent
, buf
, 20, &keySym
, NULL
);
1571 int id
= wxCharCodeXToWX (keySym
);
1572 // id may be WXK_xxx code - these are outside ASCII range, so we
1573 // can't just use toupper() on id.
1574 // Only change this if we want the raw key that was pressed,
1575 // and don't change it if we want an ASCII value.
1576 if (!isAscii
&& (id
>= 'a' && id
<= 'z'))
1578 id
= id
+ 'A' - 'a';
1581 wxevent
.m_shiftDown
= XKeyEventShiftIsDown(xevent
);
1582 wxevent
.m_controlDown
= XKeyEventCtrlIsDown(xevent
);
1583 wxevent
.m_altDown
= XKeyEventAltIsDown(xevent
);
1584 wxevent
.m_metaDown
= XKeyEventMetaIsDown(xevent
);
1585 wxevent
.SetEventObject(win
);
1586 wxevent
.m_keyCode
= id
;
1587 wxevent
.SetTimestamp(XKeyEventGetTime(xevent
));
1589 wxevent
.m_x
= XKeyEventGetX(xevent
);
1590 wxevent
.m_y
= XKeyEventGetY(xevent
);
1600 // ----------------------------------------------------------------------------
1602 // ----------------------------------------------------------------------------
1604 bool wxWindowX11::SetBackgroundColour(const wxColour
& col
)
1606 wxWindowBase::SetBackgroundColour(col
);
1608 Display
*xdisplay
= (Display
*) wxGlobalDisplay();
1609 int xscreen
= DefaultScreen( xdisplay
);
1610 Colormap cm
= DefaultColormap( xdisplay
, xscreen
);
1612 m_backgroundColour
.CalcPixel( (WXColormap
) cm
);
1614 // We don't set the background colour as we paint
1615 // the background ourselves.
1616 // XSetWindowBackground( xdisplay, (Window) m_clientWindow, m_backgroundColour.GetPixel() );
1621 bool wxWindowX11::SetForegroundColour(const wxColour
& col
)
1623 if ( !wxWindowBase::SetForegroundColour(col
) )
1629 // ----------------------------------------------------------------------------
1631 // ----------------------------------------------------------------------------
1633 wxWindow
*wxGetActiveWindow()
1636 wxFAIL_MSG(wxT("Not implemented"));
1641 wxWindow
*wxWindowBase::GetCapture()
1643 return (wxWindow
*)g_captureWindow
;
1647 // Find the wxWindow at the current mouse position, returning the mouse
1649 wxWindow
* wxFindWindowAtPointer(wxPoint
& pt
)
1651 return wxFindWindowAtPoint(wxGetMousePosition());
1654 void wxGetMouseState(int& rootX
, int& rootY
, unsigned& maskReturn
)
1661 Display
*display
= wxGlobalDisplay();
1662 Window rootWindow
= RootWindowOfScreen (DefaultScreenOfDisplay(display
));
1663 Window rootReturn
, childReturn
;
1666 XQueryPointer (display
,
1670 &rootX
, &rootY
, &winX
, &winY
, &maskReturn
);
1674 // Get the current mouse position.
1675 wxPoint
wxGetMousePosition()
1680 wxGetMouseState(x
, y
, mask
);
1681 return wxPoint(x
, y
);
1684 wxMouseState
wxGetMouseState()
1690 wxGetMouseState(x
, y
, mask
);
1695 ms
.SetLeftDown(mask
& Button1Mask
);
1696 ms
.SetMiddleDown(mask
& Button2Mask
);
1697 ms
.SetRightDown(mask
& Button3Mask
);
1699 ms
.SetControlDown(mask
& ControlMask
);
1700 ms
.SetShiftDown(mask
& ShiftMask
);
1701 ms
.SetAltDown(mask
& Mod3Mask
);
1702 ms
.SetMetaDown(mask
& Mod1Mask
);
1708 // ----------------------------------------------------------------------------
1709 // wxNoOptimize: switch off size optimization
1710 // ----------------------------------------------------------------------------
1712 int wxNoOptimize::ms_count
= 0;
1715 // ----------------------------------------------------------------------------
1717 // ----------------------------------------------------------------------------
1719 class wxWinModule
: public wxModule
1724 // we must be cleaned up before the display is closed
1725 AddDependency(wxClassInfo::FindClass(_T("wxX11DisplayModule")));
1728 virtual bool OnInit();
1729 virtual void OnExit();
1732 DECLARE_DYNAMIC_CLASS(wxWinModule
)
1735 IMPLEMENT_DYNAMIC_CLASS(wxWinModule
, wxModule
)
1737 bool wxWinModule::OnInit()
1739 Display
*xdisplay
= wxGlobalDisplay();
1740 int xscreen
= DefaultScreen( xdisplay
);
1741 Window xroot
= RootWindow( xdisplay
, xscreen
);
1742 g_eraseGC
= XCreateGC( xdisplay
, xroot
, 0, NULL
);
1743 XSetFillStyle( xdisplay
, g_eraseGC
, FillSolid
);
1748 void wxWinModule::OnExit()
1750 Display
*xdisplay
= wxGlobalDisplay();
1751 XFreeGC( xdisplay
, g_eraseGC
);