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 wxTopLevelWindows
.Append(this);
54 Display
*xdisplay
= wxGlobalDisplay();
55 int xscreen
= DefaultScreen( xdisplay
);
56 Visual
*xvisual
= DefaultVisual( xdisplay
, xscreen
);
57 Window xparent
= RootWindow( xdisplay
, xscreen
);
59 XSetWindowAttributes xattributes
;
60 XSizeHints size_hints
;
63 long xattributes_mask
=
65 CWBorderPixel
| CWBackPixel
;
66 xattributes
.background_pixel
= BlackPixel( xdisplay
, xscreen
);
67 xattributes
.border_pixel
= BlackPixel( xdisplay
, xscreen
);
68 xattributes
.override_redirect
= False
;
72 Window xwindow
= XCreateWindow( xdisplay
, xparent
, 0, 0, size
.x
, size
.y
,
73 0, DefaultDepth(xdisplay
,xscreen
), InputOutput
, xvisual
, xattributes_mask
, &xattributes
);
75 XSelectInput( xdisplay
, xwindow
,
76 ExposureMask
| KeyPressMask
| KeyReleaseMask
| ButtonPressMask
| ButtonReleaseMask
|
77 ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
|
78 KeymapStateMask
| FocusChangeMask
| ColormapChangeMask
| StructureNotifyMask
|
81 m_mainWidget
= (WXWindow
) xwindow
;
82 wxAddWindowToTable( xwindow
, (wxWindow
*) this );
84 XSetTransientForHint( xdisplay
, xwindow
, xparent
);
86 size_hints
.flags
= PSize
;
87 size_hints
.width
= size
.x
;
88 size_hints
.height
= size
.y
;
89 XSetWMNormalHints( xdisplay
, xwindow
, &size_hints
);
91 wm_hints
.flags
= InputHint
| StateHint
/* | WindowGroupHint */;
92 wm_hints
.input
= True
;
93 wm_hints
.initial_state
= NormalState
;
94 XSetWMHints( xdisplay
, xwindow
, &wm_hints
);
96 Atom wm_delete_window
= XInternAtom( xdisplay
, "WM_DELETE_WINDOW", False
);
97 XSetWMProtocols( xdisplay
, xwindow
, &wm_delete_window
, 1);
99 wxSetWMDecorations((Window
) GetMainWindow(), style
);
104 void wxPopupWindow::DoMoveWindow(int WXUNUSED(x
), int WXUNUSED(y
), int WXUNUSED(width
), int WXUNUSED(height
) )
106 wxFAIL_MSG( wxT("DoMoveWindow called for wxPopupWindow") );
109 void wxPopupWindow::DoSetSize( int x
, int y
, int width
, int height
, int sizeFlags
)
111 wxWindowX11::DoSetSize(x
, y
, width
, height
, sizeFlags
);
114 bool wxPopupWindow::Show( bool show
)
116 return wxWindowX11::Show( show
);
119 #endif // wxUSE_POPUPWIN