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
;
50 if (m_parent
) m_parent
->AddChild( this );
52 Display
*xdisplay
= wxGlobalDisplay();
53 int xscreen
= DefaultScreen( xdisplay
);
54 Visual
*xvisual
= DefaultVisual( xdisplay
, xscreen
);
55 Window xparent
= RootWindow( xdisplay
, xscreen
);
57 XSetWindowAttributes xattributes
;
59 long xattributes_mask
=
62 CWBorderPixel
| CWBackPixel
;
63 xattributes
.background_pixel
= BlackPixel( xdisplay
, xscreen
);
64 xattributes
.border_pixel
= BlackPixel( xdisplay
, xscreen
);
65 xattributes
.override_redirect
= True
;
66 xattributes
.save_under
= True
;
68 Window xwindow
= XCreateWindow( xdisplay
, xparent
, pos
.x
, pos
.y
, size
.x
, size
.y
,
69 0, DefaultDepth(xdisplay
,xscreen
), InputOutput
, xvisual
, xattributes_mask
, &xattributes
);
71 XSelectInput( xdisplay
, xwindow
,
72 ExposureMask
| KeyPressMask
| KeyReleaseMask
| ButtonPressMask
| ButtonReleaseMask
|
73 ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
|
74 KeymapStateMask
| FocusChangeMask
| ColormapChangeMask
| StructureNotifyMask
|
77 m_mainWidget
= (WXWindow
) xwindow
;
78 wxAddWindowToTable( xwindow
, (wxWindow
*) this );
80 // Set background to None which will prevent X11 from clearing the
81 // background comletely.
82 XSetWindowBackgroundPixmap( xdisplay
, xwindow
, None
);
84 XSetTransientForHint( xdisplay
, xwindow
, xparent
);
87 wm_hints
.flags
= InputHint
| StateHint
/* | WindowGroupHint */;
88 wm_hints
.input
= True
;
89 wm_hints
.initial_state
= NormalState
;
90 XSetWMHints( xdisplay
, xwindow
, &wm_hints
);
95 void wxPopupWindow::DoMoveWindow(int x
, int y
, int width
, int height
)
97 wxWindowX11::DoMoveWindow( x
, y
, width
, height
);
100 void wxPopupWindow::DoSetSize( int x
, int y
, int width
, int height
, int sizeFlags
)
102 wxWindowX11::DoSetSize(x
, y
, width
, height
, sizeFlags
);
105 bool wxPopupWindow::Show( bool show
)
107 bool ret
= wxWindowX11::Show( show
);
114 #endif // wxUSE_POPUPWIN