1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
11 #pragma implementation "popupwin.h"
18 #include "wx/popupwin.h"
20 #include "wx/settings.h"
22 #include "wx/x11/private.h"
23 #include "X11/Xatom.h"
24 #include "X11/Xutil.h"
26 //-----------------------------------------------------------------------------
28 //-----------------------------------------------------------------------------
30 BEGIN_EVENT_TABLE(wxPopupWindow
,wxPopupWindowBase
)
33 IMPLEMENT_DYNAMIC_CLASS(wxPopupWindow
, wxWindow
)
35 bool wxPopupWindow::Create( wxWindow
*parent
, int style
)
37 if (!CreateBase( parent
, -1, wxDefaultPosition
, wxDefaultSize
, style
, wxDefaultValidator
, wxT("popup") ))
39 wxFAIL_MSG( wxT("wxPopupWindow creation failed") );
43 // All dialogs should really have this style
44 m_windowStyle
= style
;
45 m_windowStyle
|= wxTAB_TRAVERSAL
;
53 if (m_parent
) m_parent
->AddChild( this );
55 Display
*xdisplay
= wxGlobalDisplay();
56 int xscreen
= DefaultScreen( xdisplay
);
57 Visual
*xvisual
= DefaultVisual( xdisplay
, xscreen
);
58 Window xparent
= RootWindow( xdisplay
, xscreen
);
61 bool need_two_windows
=
62 ((( wxSUNKEN_BORDER
| wxRAISED_BORDER
| wxSIMPLE_BORDER
| wxHSCROLL
| wxVSCROLL
) & m_windowStyle
) != 0);
64 bool need_two_windows
= FALSE
;
68 long xattributes_mask
= 0;
71 XSetWindowAttributes xattributes
;
72 long xattributes_mask
= 0;
74 xattributes_mask
|= CWBackPixel
;
75 xattributes
.background_pixel
= m_backgroundColour
.GetPixel();
77 xattributes_mask
|= CWBorderPixel
;
78 xattributes
.border_pixel
= BlackPixel( xdisplay
, xscreen
);
80 xattributes_mask
|= CWOverrideRedirect
| CWSaveUnder
;
81 xattributes
.override_redirect
= True
;
82 xattributes
.save_under
= True
;
84 xattributes_mask
|= CWEventMask
;
90 xattributes
.event_mask
=
91 ExposureMask
| StructureNotifyMask
| ColormapChangeMask
;
94 Window xwindow
= XCreateWindow( xdisplay
, xparent
, pos
.x
, pos
.y
, size
.x
, size
.y
,
95 0, DefaultDepth(xdisplay
,xscreen
), InputOutput
, xvisual
, xattributes_mask
, &xattributes
);
98 XSelectInput( xdisplay
, xwindow
,
99 ExposureMask
| KeyPressMask
| KeyReleaseMask
| ButtonPressMask
| ButtonReleaseMask
|
100 ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
|
101 KeymapStateMask
| FocusChangeMask
| ColormapChangeMask
| StructureNotifyMask
|
102 PropertyChangeMask
);
105 // Set background to None which will prevent X11 from clearing the
106 // background comletely.
107 XSetWindowBackgroundPixmap( xdisplay
, xwindow
, None
);
109 m_mainWindow
= (WXWindow
) xwindow
;
110 wxAddWindowToTable( xwindow
, (wxWindow
*) this );
112 // XMapWindow( xdisplay, xwindow );
114 xattributes
.event_mask
=
115 ExposureMask
| KeyPressMask
| KeyReleaseMask
| ButtonPressMask
| ButtonReleaseMask
|
116 ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
|
117 KeymapStateMask
| FocusChangeMask
| ColormapChangeMask
| StructureNotifyMask
|
118 PropertyChangeMask
| VisibilityChangeMask
;
121 if (HasFlag( wxSUNKEN_BORDER
) || HasFlag( wxRAISED_BORDER
))
128 if (HasFlag( wxSIMPLE_BORDER
))
140 xwindow
= XCreateWindow( xdisplay
, xwindow
, pos2
.x
, pos2
.y
, size2
.x
, size2
.y
,
141 0, DefaultDepth(xdisplay
,xscreen
), InputOutput
, xvisual
, xattributes_mask
, &xattributes
);
143 // Set background to None which will prevent X11 from clearing the
144 // background comletely.
145 XSetWindowBackgroundPixmap( xdisplay
, xwindow
, None
);
148 XSelectInput( xdisplay
, xwindow
,
149 ExposureMask
| KeyPressMask
| KeyReleaseMask
| ButtonPressMask
| ButtonReleaseMask
|
150 ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
|
151 KeymapStateMask
| FocusChangeMask
| ColormapChangeMask
| StructureNotifyMask
|
152 PropertyChangeMask
);
155 m_clientWindow
= (WXWindow
) xwindow
;
156 wxAddClientWindowToTable( xwindow
, (wxWindow
*) this );
159 XMapWindow( xdisplay
, xwindow
);
165 xattributes
.event_mask
=
166 ExposureMask
| KeyPressMask
| KeyReleaseMask
| ButtonPressMask
| ButtonReleaseMask
|
167 ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
|
168 KeymapStateMask
| FocusChangeMask
| ColormapChangeMask
| StructureNotifyMask
|
169 PropertyChangeMask
| VisibilityChangeMask
;
172 Window xwindow
= XCreateWindow( xdisplay
, xparent
, pos
.x
, pos
.y
, size
.x
, size
.y
,
173 0, DefaultDepth(xdisplay
,xscreen
), InputOutput
, xvisual
, xattributes_mask
, &xattributes
);
176 XSelectInput( xdisplay
, xwindow
,
177 ExposureMask
| KeyPressMask
| KeyReleaseMask
| ButtonPressMask
| ButtonReleaseMask
|
178 ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
|
179 KeymapStateMask
| FocusChangeMask
| ColormapChangeMask
| StructureNotifyMask
|
180 PropertyChangeMask
);
183 // Set background to None which will prevent X11 from clearing the
184 // background comletely.
185 XSetWindowBackgroundPixmap( xdisplay
, xwindow
, None
);
187 m_mainWindow
= (WXWindow
) xwindow
;
188 m_clientWindow
= (WXWindow
) xwindow
;
189 wxAddWindowToTable( xwindow
, (wxWindow
*) this );
192 // XMapWindow( xdisplay, xwindow );
195 XSetTransientForHint( xdisplay
, (Window
) m_mainWindow
, xparent
);
199 wxSetWMDecorations( (Window
) m_mainWindow
, 0 );
202 wm_hints
.flags
= InputHint
| StateHint
/* | WindowGroupHint */;
203 wm_hints
.input
= True
;
204 wm_hints
.initial_state
= NormalState
;
205 XSetWMHints( xdisplay
, (Window
) m_mainWindow
, &wm_hints
);
211 void wxPopupWindow::DoMoveWindow(int x
, int y
, int width
, int height
)
213 wxWindowX11::DoMoveWindow( x
, y
, width
, height
);
216 void wxPopupWindow::DoSetSize( int x
, int y
, int width
, int height
, int sizeFlags
)
218 wxWindowX11::DoSetSize(x
, y
, width
, height
, sizeFlags
);
221 bool wxPopupWindow::Show( bool show
)
223 bool ret
= wxWindowX11::Show( show
);
230 #endif // wxUSE_POPUPWIN