1 ///////////////////////////////////////////////////////////////////////////// 
   4 // Author:      Robert Roebling 
   6 // Copyright:   (c) 1998 Robert Roebling 
   7 // Licence:     wxWindows licence 
   8 ///////////////////////////////////////////////////////////////////////////// 
  10 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) 
  11 #pragma implementation "popupwin.h" 
  19 #include "wx/popupwin.h" 
  21 #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 IMPLEMENT_DYNAMIC_CLASS(wxPopupWindow
, wxWindow
) 
  36 wxPopupWindow::~wxPopupWindow() 
  40 bool wxPopupWindow::Create( wxWindow 
*parent
, int style 
) 
  42     if (!CreateBase( parent
, -1, wxDefaultPosition
, wxDefaultSize
, style
, wxDefaultValidator
, wxT("popup") )) 
  44         wxFAIL_MSG( wxT("wxPopupWindow creation failed") ); 
  48     // All dialogs should really have this style 
  49     m_windowStyle 
= style
; 
  50     m_windowStyle 
|= wxTAB_TRAVERSAL
; 
  58     if (m_parent
) m_parent
->AddChild( this ); 
  60     Display 
*xdisplay 
= wxGlobalDisplay(); 
  61     int xscreen 
= DefaultScreen( xdisplay 
); 
  62     Visual 
*xvisual 
= DefaultVisual( xdisplay
, xscreen 
); 
  63     Window xparent 
= RootWindow( xdisplay
, xscreen 
); 
  64     Colormap cm 
= DefaultColormap( xdisplay
, xscreen
); 
  67     bool need_two_windows 
=  
  68         ((( wxSUNKEN_BORDER 
| wxRAISED_BORDER 
| wxSIMPLE_BORDER 
| wxHSCROLL 
| wxVSCROLL 
) & m_windowStyle
) != 0); 
  70     bool need_two_windows 
= FALSE
; 
  74     long xattributes_mask 
= 0; 
  77     XSetWindowAttributes xattributes
; 
  78     long xattributes_mask 
= 0; 
  80     m_backgroundColour 
= wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE
); 
  81     m_backgroundColour
.CalcPixel( (WXColormap
) cm
); 
  83     m_foregroundColour 
= *wxBLACK
; 
  84     m_foregroundColour
.CalcPixel( (WXColormap
) cm
); 
  86     xattributes_mask 
|= CWBackPixel
; 
  87     xattributes
.background_pixel 
= m_backgroundColour
.GetPixel(); 
  89     xattributes_mask 
|= CWBorderPixel
; 
  90     xattributes
.border_pixel 
= BlackPixel( xdisplay
, xscreen 
); 
  92     xattributes_mask 
|= CWOverrideRedirect 
| CWSaveUnder
; 
  93     xattributes
.override_redirect 
= True
; 
  94     xattributes
.save_under 
= True
; 
  96     xattributes_mask 
|= CWEventMask
; 
 102         xattributes
.event_mask 
=  
 103             ExposureMask 
| StructureNotifyMask 
| ColormapChangeMask
; 
 106         Window xwindow 
= XCreateWindow( xdisplay
, xparent
, pos
.x
, pos
.y
, size
.x
, size
.y
,  
 107             0, DefaultDepth(xdisplay
,xscreen
), InputOutput
, xvisual
, xattributes_mask
, &xattributes 
); 
 110         XSelectInput( xdisplay
, xwindow
, 
 111           ExposureMask 
| KeyPressMask 
| KeyReleaseMask 
| ButtonPressMask 
| ButtonReleaseMask 
| 
 112           ButtonMotionMask 
| EnterWindowMask 
| LeaveWindowMask 
| PointerMotionMask 
| 
 113           KeymapStateMask 
| FocusChangeMask 
| ColormapChangeMask 
| StructureNotifyMask 
| 
 114           PropertyChangeMask 
); 
 117         // Set background to None which will prevent X11 from clearing the 
 118         // background comletely. 
 119         XSetWindowBackgroundPixmap( xdisplay
, xwindow
, None 
); 
 121         m_mainWindow 
= (WXWindow
) xwindow
; 
 122         wxAddWindowToTable( xwindow
, (wxWindow
*) this ); 
 124         // XMapWindow( xdisplay, xwindow ); 
 126         xattributes
.event_mask 
=  
 127             ExposureMask 
| KeyPressMask 
| KeyReleaseMask 
| ButtonPressMask 
| ButtonReleaseMask 
| 
 128             ButtonMotionMask 
| EnterWindowMask 
| LeaveWindowMask 
| PointerMotionMask 
| 
 129             KeymapStateMask 
| FocusChangeMask 
| ColormapChangeMask 
| StructureNotifyMask 
| 
 130             PropertyChangeMask 
| VisibilityChangeMask 
; 
 133         if (HasFlag( wxSUNKEN_BORDER
) || HasFlag( wxRAISED_BORDER
)) 
 140         if (HasFlag( wxSIMPLE_BORDER 
)) 
 152         xwindow 
= XCreateWindow( xdisplay
, xwindow
, pos2
.x
, pos2
.y
, size2
.x
, size2
.y
,  
 153             0, DefaultDepth(xdisplay
,xscreen
), InputOutput
, xvisual
, xattributes_mask
, &xattributes 
); 
 155         // Set background to None which will prevent X11 from clearing the 
 156         // background comletely. 
 157         XSetWindowBackgroundPixmap( xdisplay
, xwindow
, None 
); 
 160         XSelectInput( xdisplay
, xwindow
, 
 161             ExposureMask 
| KeyPressMask 
| KeyReleaseMask 
| ButtonPressMask 
| ButtonReleaseMask 
| 
 162             ButtonMotionMask 
| EnterWindowMask 
| LeaveWindowMask 
| PointerMotionMask 
| 
 163             KeymapStateMask 
| FocusChangeMask 
| ColormapChangeMask 
| StructureNotifyMask 
| 
 164             PropertyChangeMask 
); 
 167         m_clientWindow 
= (WXWindow
) xwindow
; 
 168         wxAddClientWindowToTable( xwindow
, (wxWindow
*) this ); 
 171         XMapWindow( xdisplay
, xwindow 
); 
 177         xattributes
.event_mask 
=  
 178             ExposureMask 
| KeyPressMask 
| KeyReleaseMask 
| ButtonPressMask 
| ButtonReleaseMask 
| 
 179             ButtonMotionMask 
| EnterWindowMask 
| LeaveWindowMask 
| PointerMotionMask 
| 
 180             KeymapStateMask 
| FocusChangeMask 
| ColormapChangeMask 
| StructureNotifyMask 
| 
 181             PropertyChangeMask 
| VisibilityChangeMask 
; 
 184         Window xwindow 
= XCreateWindow( xdisplay
, xparent
, pos
.x
, pos
.y
, size
.x
, size
.y
,  
 185             0, DefaultDepth(xdisplay
,xscreen
), InputOutput
, xvisual
, xattributes_mask
, &xattributes 
); 
 188         XSelectInput( xdisplay
, xwindow
, 
 189           ExposureMask 
| KeyPressMask 
| KeyReleaseMask 
| ButtonPressMask 
| ButtonReleaseMask 
| 
 190           ButtonMotionMask 
| EnterWindowMask 
| LeaveWindowMask 
| PointerMotionMask 
| 
 191           KeymapStateMask 
| FocusChangeMask 
| ColormapChangeMask 
| StructureNotifyMask 
| 
 192           PropertyChangeMask 
); 
 195         // Set background to None which will prevent X11 from clearing the 
 196         // background comletely. 
 197         XSetWindowBackgroundPixmap( xdisplay
, xwindow
, None 
); 
 199         m_mainWindow 
= (WXWindow
) xwindow
; 
 200         m_clientWindow 
= (WXWindow
) xwindow
; 
 201         wxAddWindowToTable( xwindow
, (wxWindow
*) this ); 
 204         // XMapWindow( xdisplay, xwindow ); 
 207     XSetTransientForHint( xdisplay
, (Window
) m_mainWindow
, xparent 
); 
 211     wxSetWMDecorations( (Window
) m_mainWindow
, 0 ); 
 214     wm_hints
.flags 
= InputHint 
| StateHint 
/* | WindowGroupHint */; 
 215     wm_hints
.input 
= True
; 
 216     wm_hints
.initial_state 
= NormalState
; 
 217     XSetWMHints( xdisplay
, (Window
) m_mainWindow
, &wm_hints
); 
 223 void wxPopupWindow::DoMoveWindow(int x
, int y
, int width
, int height 
) 
 225     wxWindowX11::DoMoveWindow( x
, y
, width
, height 
); 
 228 void wxPopupWindow::DoSetSize( int x
, int y
, int width
, int height
, int sizeFlags 
) 
 230     wxWindowX11::DoSetSize(x
, y
, width
, height
, sizeFlags
); 
 233 bool wxPopupWindow::Show( bool show 
) 
 235     bool ret 
= wxWindowX11::Show( show 
); 
 242 #endif // wxUSE_POPUPWIN