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
);
62 bool need_two_windows
=
63 ((( wxSUNKEN_BORDER
| wxRAISED_BORDER
| wxSIMPLE_BORDER
| wxHSCROLL
| wxVSCROLL
) & m_windowStyle
) != 0);
65 bool need_two_windows
= FALSE
;
68 XSetWindowAttributes xattributes
;
69 long xattributes_mask
= 0;
71 xattributes_mask
|= CWBackPixel
;
72 xattributes
.background_pixel
= m_backgroundColour
.GetPixel();
74 xattributes_mask
|= CWBorderPixel
;
75 xattributes
.border_pixel
= BlackPixel( xdisplay
, xscreen
);
77 xattributes_mask
|= CWOverrideRedirect
| CWSaveUnder
;
78 xattributes
.override_redirect
= True
;
79 xattributes
.save_under
= True
;
81 xattributes_mask
|= CWEventMask
;
85 xattributes
.event_mask
=
86 ExposureMask
| StructureNotifyMask
| ColormapChangeMask
;
88 Window xwindow
= XCreateWindow( xdisplay
, xparent
, pos
.x
, pos
.y
, size
.x
, size
.y
,
89 0, DefaultDepth(xdisplay
,xscreen
), InputOutput
, xvisual
, xattributes_mask
, &xattributes
);
91 XSetWindowBackgroundPixmap( xdisplay
, xwindow
, None
);
93 m_mainWindow
= (WXWindow
) xwindow
;
94 wxAddWindowToTable( xwindow
, (wxWindow
*) this );
96 // XMapWindow( xdisplay, xwindow );
98 xattributes
.event_mask
=
99 ExposureMask
| KeyPressMask
| KeyReleaseMask
| ButtonPressMask
| ButtonReleaseMask
|
100 ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
|
101 KeymapStateMask
| FocusChangeMask
| ColormapChangeMask
| StructureNotifyMask
|
102 PropertyChangeMask
| VisibilityChangeMask
;
104 if (HasFlag( wxSUNKEN_BORDER
) || HasFlag( wxRAISED_BORDER
))
111 if (HasFlag( wxSIMPLE_BORDER
))
123 xwindow
= XCreateWindow( xdisplay
, xwindow
, pos2
.x
, pos2
.y
, size2
.x
, size2
.y
,
124 0, DefaultDepth(xdisplay
,xscreen
), InputOutput
, xvisual
, xattributes_mask
, &xattributes
);
126 XSetWindowBackgroundPixmap( xdisplay
, xwindow
, None
);
128 m_clientWindow
= (WXWindow
) xwindow
;
129 wxAddClientWindowToTable( xwindow
, (wxWindow
*) this );
132 XMapWindow( xdisplay
, xwindow
);
136 xattributes
.event_mask
=
137 ExposureMask
| KeyPressMask
| KeyReleaseMask
| ButtonPressMask
| ButtonReleaseMask
|
138 ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
|
139 KeymapStateMask
| FocusChangeMask
| ColormapChangeMask
| StructureNotifyMask
|
140 PropertyChangeMask
| VisibilityChangeMask
;
142 Window xwindow
= XCreateWindow( xdisplay
, xparent
, pos
.x
, pos
.y
, size
.x
, size
.y
,
143 0, DefaultDepth(xdisplay
,xscreen
), InputOutput
, xvisual
, xattributes_mask
, &xattributes
);
145 XSetWindowBackgroundPixmap( xdisplay
, xwindow
, None
);
147 m_mainWindow
= (WXWindow
) xwindow
;
148 m_clientWindow
= (WXWindow
) xwindow
;
149 wxAddWindowToTable( xwindow
, (wxWindow
*) this );
152 // XMapWindow( xdisplay, xwindow );
158 XSetTransientForHint( xdisplay
, (Window
) m_mainWindow
, xparent
);
162 wxSetWMDecorations( (Window
) m_mainWindow
, 0 );
165 wm_hints
.flags
= InputHint
| StateHint
/* | WindowGroupHint */;
166 wm_hints
.input
= True
;
167 wm_hints
.initial_state
= NormalState
;
168 XSetWMHints( xdisplay
, (Window
) m_mainWindow
, &wm_hints
);
174 void wxPopupWindow::DoMoveWindow(int x
, int y
, int width
, int height
)
176 wxWindowX11::DoMoveWindow( x
, y
, width
, height
);
179 void wxPopupWindow::DoSetSize( int x
, int y
, int width
, int height
, int sizeFlags
)
181 wxWindowX11::DoSetSize(x
, y
, width
, height
, sizeFlags
);
184 bool wxPopupWindow::Show( bool show
)
186 bool ret
= wxWindowX11::Show( show
);
193 #endif // wxUSE_POPUPWIN