1 ///////////////////////////////////////////////////////////////////////////// 
   2 // Name:        srx/x11/popupwin.cpp 
   4 // Author:      Robert Roebling 
   6 // Copyright:   (c) 1998 Robert Roebling 
   7 // Licence:     wxWindows licence 
   8 ///////////////////////////////////////////////////////////////////////////// 
  10 // for compilers that support precompilation, includes "wx.h". 
  11 #include "wx/wxprec.h" 
  15 #include "wx/popupwin.h" 
  20     #include "wx/settings.h" 
  23 #include "wx/x11/private.h" 
  24 #include "X11/Xatom.h" 
  25 #include "X11/Xutil.h" 
  27 //----------------------------------------------------------------------------- 
  29 //----------------------------------------------------------------------------- 
  31 BEGIN_EVENT_TABLE(wxPopupWindow
,wxPopupWindowBase
) 
  34 wxPopupWindow::~wxPopupWindow() 
  38 bool wxPopupWindow::Create( wxWindow 
*parent
, int style 
) 
  40     if (!CreateBase( parent
, -1, wxDefaultPosition
, wxDefaultSize
, style
, wxDefaultValidator
, wxT("popup") )) 
  42         wxFAIL_MSG( wxT("wxPopupWindow creation failed") ); 
  46     // All dialogs should really have this style 
  47     m_windowStyle 
= style
; 
  48     m_windowStyle 
|= wxTAB_TRAVERSAL
; 
  56     if (m_parent
) m_parent
->AddChild( this ); 
  58     Display 
*xdisplay 
= wxGlobalDisplay(); 
  59     int xscreen 
= DefaultScreen( xdisplay 
); 
  60     Visual 
*xvisual 
= DefaultVisual( xdisplay
, xscreen 
); 
  61     Window xparent 
= RootWindow( xdisplay
, xscreen 
); 
  62     Colormap cm 
= DefaultColormap( xdisplay
, xscreen
); 
  65     bool need_two_windows 
= 
  66         ((( wxSUNKEN_BORDER 
| wxRAISED_BORDER 
| wxSIMPLE_BORDER 
| wxHSCROLL 
| wxVSCROLL 
) & m_windowStyle
) != 0); 
  68     bool need_two_windows 
= false; 
  72     long xattributes_mask 
= 0; 
  75     XSetWindowAttributes xattributes
; 
  76     long xattributes_mask 
= 0; 
  78     m_backgroundColour 
= wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE
); 
  79     m_backgroundColour
.CalcPixel( (WXColormap
) cm
); 
  81     m_foregroundColour 
= *wxBLACK
; 
  82     m_foregroundColour
.CalcPixel( (WXColormap
) cm
); 
  84     xattributes_mask 
|= CWBackPixel
; 
  85     xattributes
.background_pixel 
= m_backgroundColour
.GetPixel(); 
  87     xattributes_mask 
|= CWBorderPixel
; 
  88     xattributes
.border_pixel 
= BlackPixel( xdisplay
, xscreen 
); 
  90     xattributes_mask 
|= CWOverrideRedirect 
| CWSaveUnder
; 
  91     xattributes
.override_redirect 
= True
; 
  92     xattributes
.save_under 
= True
; 
  94     xattributes_mask 
|= CWEventMask
; 
 100         xattributes
.event_mask 
= 
 101             ExposureMask 
| StructureNotifyMask 
| ColormapChangeMask
; 
 104         Window xwindow 
= XCreateWindow( xdisplay
, xparent
, pos
.x
, pos
.y
, size
.x
, size
.y
, 
 105             0, DefaultDepth(xdisplay
,xscreen
), InputOutput
, xvisual
, xattributes_mask
, &xattributes 
); 
 108         XSelectInput( xdisplay
, xwindow
, 
 109           ExposureMask 
| KeyPressMask 
| KeyReleaseMask 
| ButtonPressMask 
| ButtonReleaseMask 
| 
 110           ButtonMotionMask 
| EnterWindowMask 
| LeaveWindowMask 
| PointerMotionMask 
| 
 111           KeymapStateMask 
| FocusChangeMask 
| ColormapChangeMask 
| StructureNotifyMask 
| 
 112           PropertyChangeMask 
); 
 115         // Set background to None which will prevent X11 from clearing the 
 116         // background comletely. 
 117         XSetWindowBackgroundPixmap( xdisplay
, xwindow
, None 
); 
 119         m_mainWindow 
= (WXWindow
) xwindow
; 
 120         wxAddWindowToTable( xwindow
, (wxWindow
*) this ); 
 122         // XMapWindow( xdisplay, xwindow ); 
 124         xattributes
.event_mask 
= 
 125             ExposureMask 
| KeyPressMask 
| KeyReleaseMask 
| ButtonPressMask 
| ButtonReleaseMask 
| 
 126             ButtonMotionMask 
| EnterWindowMask 
| LeaveWindowMask 
| PointerMotionMask 
| 
 127             KeymapStateMask 
| FocusChangeMask 
| ColormapChangeMask 
| StructureNotifyMask 
| 
 128             PropertyChangeMask 
| VisibilityChangeMask 
; 
 131         if (HasFlag( wxSUNKEN_BORDER
) || HasFlag( wxRAISED_BORDER
)) 
 138         if (HasFlag( wxSIMPLE_BORDER 
)) 
 150         xwindow 
= XCreateWindow( xdisplay
, xwindow
, pos2
.x
, pos2
.y
, size2
.x
, size2
.y
, 
 151             0, DefaultDepth(xdisplay
,xscreen
), InputOutput
, xvisual
, xattributes_mask
, &xattributes 
); 
 153         // Set background to None which will prevent X11 from clearing the 
 154         // background comletely. 
 155         XSetWindowBackgroundPixmap( xdisplay
, xwindow
, None 
); 
 158         XSelectInput( xdisplay
, xwindow
, 
 159             ExposureMask 
| KeyPressMask 
| KeyReleaseMask 
| ButtonPressMask 
| ButtonReleaseMask 
| 
 160             ButtonMotionMask 
| EnterWindowMask 
| LeaveWindowMask 
| PointerMotionMask 
| 
 161             KeymapStateMask 
| FocusChangeMask 
| ColormapChangeMask 
| StructureNotifyMask 
| 
 162             PropertyChangeMask 
); 
 165         m_clientWindow 
= (WXWindow
) xwindow
; 
 166         wxAddClientWindowToTable( xwindow
, (wxWindow
*) this ); 
 169         XMapWindow( xdisplay
, xwindow 
); 
 175         xattributes
.event_mask 
= 
 176             ExposureMask 
| KeyPressMask 
| KeyReleaseMask 
| ButtonPressMask 
| ButtonReleaseMask 
| 
 177             ButtonMotionMask 
| EnterWindowMask 
| LeaveWindowMask 
| PointerMotionMask 
| 
 178             KeymapStateMask 
| FocusChangeMask 
| ColormapChangeMask 
| StructureNotifyMask 
| 
 179             PropertyChangeMask 
| VisibilityChangeMask 
; 
 182         Window xwindow 
= XCreateWindow( xdisplay
, xparent
, pos
.x
, pos
.y
, size
.x
, size
.y
, 
 183             0, DefaultDepth(xdisplay
,xscreen
), InputOutput
, xvisual
, xattributes_mask
, &xattributes 
); 
 186         XSelectInput( xdisplay
, xwindow
, 
 187           ExposureMask 
| KeyPressMask 
| KeyReleaseMask 
| ButtonPressMask 
| ButtonReleaseMask 
| 
 188           ButtonMotionMask 
| EnterWindowMask 
| LeaveWindowMask 
| PointerMotionMask 
| 
 189           KeymapStateMask 
| FocusChangeMask 
| ColormapChangeMask 
| StructureNotifyMask 
| 
 190           PropertyChangeMask 
); 
 193         // Set background to None which will prevent X11 from clearing the 
 194         // background comletely. 
 195         XSetWindowBackgroundPixmap( xdisplay
, xwindow
, None 
); 
 197         m_mainWindow 
= (WXWindow
) xwindow
; 
 198         m_clientWindow 
= (WXWindow
) xwindow
; 
 199         wxAddWindowToTable( xwindow
, (wxWindow
*) this ); 
 202         // XMapWindow( xdisplay, xwindow ); 
 205     XSetTransientForHint( xdisplay
, (Window
) m_mainWindow
, xparent 
); 
 209     wxSetWMDecorations( (Window
) m_mainWindow
, 0 ); 
 212     wm_hints
.flags 
= InputHint 
| StateHint 
/* | WindowGroupHint */; 
 213     wm_hints
.input 
= True
; 
 214     wm_hints
.initial_state 
= NormalState
; 
 215     XSetWMHints( xdisplay
, (Window
) m_mainWindow
, &wm_hints
); 
 221 void wxPopupWindow::DoMoveWindow(int x
, int y
, int width
, int height 
) 
 223     wxWindowX11::DoMoveWindow( x
, y
, width
, height 
); 
 226 void wxPopupWindow::DoSetSize( int x
, int y
, int width
, int height
, int sizeFlags 
) 
 228     wxWindowX11::DoSetSize(x
, y
, width
, height
, sizeFlags
); 
 231 bool wxPopupWindow::Show( bool show 
) 
 233     bool ret 
= wxWindowX11::Show( show 
); 
 240 #endif // wxUSE_POPUPWIN