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"
21 #include "wx/x11/private.h"
22 #include "X11/Xatom.h"
23 #include "X11/Xutil.h"
25 //-----------------------------------------------------------------------------
27 //-----------------------------------------------------------------------------
29 BEGIN_EVENT_TABLE(wxPopupWindow
,wxPopupWindowBase
)
32 IMPLEMENT_DYNAMIC_CLASS(wxPopupWindow
, wxWindow
)
34 bool wxPopupWindow::Create( wxWindow
*parent
, int style
)
36 if (!CreateBase( parent
, -1, wxDefaultPosition
, wxDefaultSize
, style
, wxDefaultValidator
, "popup" ))
38 wxFAIL_MSG( wxT("wxPopupWindow creation failed") );
42 // All dialogs should really have this style
43 m_windowStyle
= style
;
44 m_windowStyle
|= wxTAB_TRAVERSAL
;
52 if (m_parent
) m_parent
->AddChild( this );
54 Display
*xdisplay
= wxGlobalDisplay();
55 int xscreen
= DefaultScreen( xdisplay
);
56 Visual
*xvisual
= DefaultVisual( xdisplay
, xscreen
);
57 Window xparent
= RootWindow( xdisplay
, xscreen
);
60 bool need_two_windows
=
61 ((( wxSUNKEN_BORDER
| wxRAISED_BORDER
| wxSIMPLE_BORDER
| wxHSCROLL
| wxVSCROLL
) & m_windowStyle
) != 0);
63 bool need_two_windows
= FALSE
;
67 long xattributes_mask
= 0;
70 XSetWindowAttributes xattributes
;
71 long xattributes_mask
= 0;
73 xattributes_mask
|= CWBackPixel
;
74 xattributes
.background_pixel
= m_backgroundColour
.GetPixel();
76 xattributes_mask
|= CWBorderPixel
;
77 xattributes
.border_pixel
= BlackPixel( xdisplay
, xscreen
);
79 xattributes_mask
|= CWOverrideRedirect
| CWSaveUnder
;
80 xattributes
.override_redirect
= True
;
81 xattributes
.save_under
= True
;
83 xattributes_mask
|= CWEventMask
;
89 xattributes
.event_mask
=
90 ExposureMask
| StructureNotifyMask
| ColormapChangeMask
;
93 Window xwindow
= XCreateWindow( xdisplay
, xparent
, pos
.x
, pos
.y
, size
.x
, size
.y
,
94 0, DefaultDepth(xdisplay
,xscreen
), InputOutput
, xvisual
, xattributes_mask
, &xattributes
);
97 XSelectInput( xdisplay
, xwindow
,
98 ExposureMask
| KeyPressMask
| KeyReleaseMask
| ButtonPressMask
| ButtonReleaseMask
|
99 ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
|
100 KeymapStateMask
| FocusChangeMask
| ColormapChangeMask
| StructureNotifyMask
|
101 PropertyChangeMask
);
104 // Set background to None which will prevent X11 from clearing the
105 // background comletely.
106 XSetWindowBackgroundPixmap( xdisplay
, xwindow
, None
);
108 m_mainWindow
= (WXWindow
) xwindow
;
109 wxAddWindowToTable( xwindow
, (wxWindow
*) this );
111 // XMapWindow( xdisplay, xwindow );
113 xattributes
.event_mask
=
114 ExposureMask
| KeyPressMask
| KeyReleaseMask
| ButtonPressMask
| ButtonReleaseMask
|
115 ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
|
116 KeymapStateMask
| FocusChangeMask
| ColormapChangeMask
| StructureNotifyMask
|
117 PropertyChangeMask
| VisibilityChangeMask
;
120 if (HasFlag( wxSUNKEN_BORDER
) || HasFlag( wxRAISED_BORDER
))
127 if (HasFlag( wxSIMPLE_BORDER
))
139 xwindow
= XCreateWindow( xdisplay
, xwindow
, pos2
.x
, pos2
.y
, size2
.x
, size2
.y
,
140 0, DefaultDepth(xdisplay
,xscreen
), InputOutput
, xvisual
, xattributes_mask
, &xattributes
);
142 // Set background to None which will prevent X11 from clearing the
143 // background comletely.
144 XSetWindowBackgroundPixmap( xdisplay
, xwindow
, None
);
147 XSelectInput( xdisplay
, xwindow
,
148 ExposureMask
| KeyPressMask
| KeyReleaseMask
| ButtonPressMask
| ButtonReleaseMask
|
149 ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
|
150 KeymapStateMask
| FocusChangeMask
| ColormapChangeMask
| StructureNotifyMask
|
151 PropertyChangeMask
);
154 m_clientWindow
= (WXWindow
) xwindow
;
155 wxAddClientWindowToTable( xwindow
, (wxWindow
*) this );
158 XMapWindow( xdisplay
, xwindow
);
164 xattributes
.event_mask
=
165 ExposureMask
| KeyPressMask
| KeyReleaseMask
| ButtonPressMask
| ButtonReleaseMask
|
166 ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
|
167 KeymapStateMask
| FocusChangeMask
| ColormapChangeMask
| StructureNotifyMask
|
168 PropertyChangeMask
| VisibilityChangeMask
;
171 Window xwindow
= XCreateWindow( xdisplay
, xparent
, pos
.x
, pos
.y
, size
.x
, size
.y
,
172 0, DefaultDepth(xdisplay
,xscreen
), InputOutput
, xvisual
, xattributes_mask
, &xattributes
);
175 XSelectInput( xdisplay
, xwindow
,
176 ExposureMask
| KeyPressMask
| KeyReleaseMask
| ButtonPressMask
| ButtonReleaseMask
|
177 ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
|
178 KeymapStateMask
| FocusChangeMask
| ColormapChangeMask
| StructureNotifyMask
|
179 PropertyChangeMask
);
182 // Set background to None which will prevent X11 from clearing the
183 // background comletely.
184 XSetWindowBackgroundPixmap( xdisplay
, xwindow
, None
);
186 m_mainWindow
= (WXWindow
) xwindow
;
187 m_clientWindow
= (WXWindow
) xwindow
;
188 wxAddWindowToTable( xwindow
, (wxWindow
*) this );
191 // XMapWindow( xdisplay, xwindow );
194 XSetTransientForHint( xdisplay
, (Window
) m_mainWindow
, xparent
);
198 wxSetWMDecorations( (Window
) m_mainWindow
, 0 );
201 wm_hints
.flags
= InputHint
| StateHint
/* | WindowGroupHint */;
202 wm_hints
.input
= True
;
203 wm_hints
.initial_state
= NormalState
;
204 XSetWMHints( xdisplay
, (Window
) m_mainWindow
, &wm_hints
);
210 void wxPopupWindow::DoMoveWindow(int x
, int y
, int width
, int height
)
212 wxWindowX11::DoMoveWindow( x
, y
, width
, height
);
215 void wxPopupWindow::DoSetSize( int x
, int y
, int width
, int height
, int sizeFlags
)
217 wxWindowX11::DoSetSize(x
, y
, width
, height
, sizeFlags
);
220 bool wxPopupWindow::Show( bool show
)
222 bool ret
= wxWindowX11::Show( show
);
229 #endif // wxUSE_POPUPWIN