]> git.saurik.com Git - wxWidgets.git/blame - src/x11/popupwin.cpp
suppress triple clicks generation completely for GTK2 as it makes long click series...
[wxWidgets.git] / src / x11 / popupwin.cpp
CommitLineData
1246e28f
JS
1/////////////////////////////////////////////////////////////////////////////
2// Name: popupwin.cpp
3// Purpose:
4// Author: Robert Roebling
5// Id: $Id$
6// Copyright: (c) 1998 Robert Roebling
7// Licence: wxWindows licence
8/////////////////////////////////////////////////////////////////////////////
9
14f355c2 10#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
1246e28f
JS
11#pragma implementation "popupwin.h"
12#endif
13
14#include "wx/defs.h"
15
16#if wxUSE_POPUPWIN
17
18#include "wx/popupwin.h"
1246e28f 19#include "wx/app.h"
2b5f62a0 20#include "wx/settings.h"
1246e28f
JS
21
22#include "wx/x11/private.h"
6a44bffd
JS
23#include "X11/Xatom.h"
24#include "X11/Xutil.h"
1246e28f
JS
25
26//-----------------------------------------------------------------------------
27// wxPopupWindow
28//-----------------------------------------------------------------------------
29
30BEGIN_EVENT_TABLE(wxPopupWindow,wxPopupWindowBase)
31END_EVENT_TABLE()
32
33IMPLEMENT_DYNAMIC_CLASS(wxPopupWindow, wxWindow)
34
35bool wxPopupWindow::Create( wxWindow *parent, int style )
36{
2b5f62a0 37 if (!CreateBase( parent, -1, wxDefaultPosition, wxDefaultSize, style, wxDefaultValidator, wxT("popup") ))
1246e28f
JS
38 {
39 wxFAIL_MSG( wxT("wxPopupWindow creation failed") );
40 return FALSE;
41 }
42
43 // All dialogs should really have this style
b28d3abf 44 m_windowStyle = style;
1246e28f 45 m_windowStyle |= wxTAB_TRAVERSAL;
1b0b798d
RR
46
47 wxPoint pos( 20,20 );
48 wxSize size( 20,20 );
97bb82cc
RR
49 wxPoint pos2 = pos;
50 wxSize size2 = size;
1246e28f 51
b28d3abf 52 m_parent = parent;
1246e28f
JS
53 if (m_parent) m_parent->AddChild( this );
54
b28d3abf
JS
55 Display *xdisplay = wxGlobalDisplay();
56 int xscreen = DefaultScreen( xdisplay );
57 Visual *xvisual = DefaultVisual( xdisplay, xscreen );
58 Window xparent = RootWindow( xdisplay, xscreen );
59
97bb82cc
RR
60#if wxUSE_TWO_WINDOWS
61 bool need_two_windows =
62 ((( wxSUNKEN_BORDER | wxRAISED_BORDER | wxSIMPLE_BORDER | wxHSCROLL | wxVSCROLL ) & m_windowStyle) != 0);
788519c6 63#else
97bb82cc
RR
64 bool need_two_windows = FALSE;
65#endif
66
8601b2e1
JS
67#if wxUSE_NANOX
68 long xattributes_mask = 0;
69#else
70
b28d3abf 71 XSetWindowAttributes xattributes;
97bb82cc 72 long xattributes_mask = 0;
b28d3abf 73
97bb82cc
RR
74 xattributes_mask |= CWBackPixel;
75 xattributes.background_pixel = m_backgroundColour.GetPixel();
76
77 xattributes_mask |= CWBorderPixel;
b28d3abf 78 xattributes.border_pixel = BlackPixel( xdisplay, xscreen );
97bb82cc
RR
79
80 xattributes_mask |= CWOverrideRedirect | CWSaveUnder;
0d1dff01
RR
81 xattributes.override_redirect = True;
82 xattributes.save_under = True;
788519c6 83
97bb82cc 84 xattributes_mask |= CWEventMask;
8601b2e1 85#endif
b28d3abf 86
97bb82cc
RR
87 if (need_two_windows)
88 {
8601b2e1 89#if !wxUSE_NANOX
97bb82cc
RR
90 xattributes.event_mask =
91 ExposureMask | StructureNotifyMask | ColormapChangeMask;
8601b2e1
JS
92#endif
93
97bb82cc
RR
94 Window xwindow = XCreateWindow( xdisplay, xparent, pos.x, pos.y, size.x, size.y,
95 0, DefaultDepth(xdisplay,xscreen), InputOutput, xvisual, xattributes_mask, &xattributes );
8601b2e1
JS
96
97#if wxUSE_NANOX
98 XSelectInput( xdisplay, xwindow,
99 ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask |
100 ButtonMotionMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask |
101 KeymapStateMask | FocusChangeMask | ColormapChangeMask | StructureNotifyMask |
102 PropertyChangeMask );
103#endif
97bb82cc 104
8601b2e1
JS
105 // Set background to None which will prevent X11 from clearing the
106 // background comletely.
97bb82cc
RR
107 XSetWindowBackgroundPixmap( xdisplay, xwindow, None );
108
109 m_mainWindow = (WXWindow) xwindow;
110 wxAddWindowToTable( xwindow, (wxWindow*) this );
111
e97d2576 112 // XMapWindow( xdisplay, xwindow );
8601b2e1 113#if !wxUSE_NANOX
97bb82cc
RR
114 xattributes.event_mask =
115 ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask |
116 ButtonMotionMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask |
117 KeymapStateMask | FocusChangeMask | ColormapChangeMask | StructureNotifyMask |
118 PropertyChangeMask | VisibilityChangeMask ;
8601b2e1
JS
119#endif
120
97bb82cc
RR
121 if (HasFlag( wxSUNKEN_BORDER) || HasFlag( wxRAISED_BORDER))
122 {
123 pos2.x = 2;
124 pos2.y = 2;
125 size2.x -= 4;
126 size2.y -= 4;
127 } else
128 if (HasFlag( wxSIMPLE_BORDER ))
129 {
130 pos2.x = 1;
131 pos2.y = 1;
132 size2.x -= 2;
133 size2.y -= 2;
134 } else
135 {
136 pos2.x = 0;
137 pos2.y = 0;
138 }
139
140 xwindow = XCreateWindow( xdisplay, xwindow, pos2.x, pos2.y, size2.x, size2.y,
141 0, DefaultDepth(xdisplay,xscreen), InputOutput, xvisual, xattributes_mask, &xattributes );
142
8601b2e1
JS
143 // Set background to None which will prevent X11 from clearing the
144 // background comletely.
97bb82cc
RR
145 XSetWindowBackgroundPixmap( xdisplay, xwindow, None );
146
8601b2e1
JS
147#if wxUSE_NANOX
148 XSelectInput( xdisplay, xwindow,
149 ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask |
150 ButtonMotionMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask |
151 KeymapStateMask | FocusChangeMask | ColormapChangeMask | StructureNotifyMask |
152 PropertyChangeMask );
153#endif
154
97bb82cc
RR
155 m_clientWindow = (WXWindow) xwindow;
156 wxAddClientWindowToTable( xwindow, (wxWindow*) this );
157
e97d2576 158 m_isShown = FALSE;
97bb82cc
RR
159 XMapWindow( xdisplay, xwindow );
160 }
161 else
162 {
8601b2e1
JS
163 // One window
164#if !wxUSE_NANOX
97bb82cc
RR
165 xattributes.event_mask =
166 ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask |
167 ButtonMotionMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask |
168 KeymapStateMask | FocusChangeMask | ColormapChangeMask | StructureNotifyMask |
169 PropertyChangeMask | VisibilityChangeMask ;
8601b2e1
JS
170#endif
171
97bb82cc
RR
172 Window xwindow = XCreateWindow( xdisplay, xparent, pos.x, pos.y, size.x, size.y,
173 0, DefaultDepth(xdisplay,xscreen), InputOutput, xvisual, xattributes_mask, &xattributes );
8601b2e1
JS
174
175#if wxUSE_NANOX
176 XSelectInput( xdisplay, xwindow,
177 ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask |
178 ButtonMotionMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask |
179 KeymapStateMask | FocusChangeMask | ColormapChangeMask | StructureNotifyMask |
180 PropertyChangeMask );
181#endif
182
183 // Set background to None which will prevent X11 from clearing the
184 // background comletely.
97bb82cc
RR
185 XSetWindowBackgroundPixmap( xdisplay, xwindow, None );
186
187 m_mainWindow = (WXWindow) xwindow;
188 m_clientWindow = (WXWindow) xwindow;
189 wxAddWindowToTable( xwindow, (wxWindow*) this );
190
e97d2576
RR
191 m_isShown = FALSE;
192 // XMapWindow( xdisplay, xwindow );
97bb82cc 193 }
ba696cfa 194
97bb82cc 195 XSetTransientForHint( xdisplay, (Window) m_mainWindow, xparent );
5e29f97a 196
70b8ab77
JS
197#if wxUSE_NANOX
198 // Switch off WM
97bb82cc 199 wxSetWMDecorations( (Window) m_mainWindow, 0 );
70b8ab77 200#else
86fd8bda 201 XWMHints wm_hints;
b28d3abf
JS
202 wm_hints.flags = InputHint | StateHint /* | WindowGroupHint */;
203 wm_hints.input = True;
204 wm_hints.initial_state = NormalState;
97bb82cc 205 XSetWMHints( xdisplay, (Window) m_mainWindow, &wm_hints);
788519c6
JS
206#endif
207
1246e28f
JS
208 return TRUE;
209}
210
27398643 211void wxPopupWindow::DoMoveWindow(int x, int y, int width, int height )
1246e28f 212{
27398643 213 wxWindowX11::DoMoveWindow( x, y, width, height );
1246e28f
JS
214}
215
216void wxPopupWindow::DoSetSize( int x, int y, int width, int height, int sizeFlags )
217{
b28d3abf 218 wxWindowX11::DoSetSize(x, y, width, height, sizeFlags);
1246e28f 219}
b28d3abf 220
1246e28f
JS
221bool wxPopupWindow::Show( bool show )
222{
86fd8bda
RR
223 bool ret = wxWindowX11::Show( show );
224
90f501b1 225 Raise();
86fd8bda
RR
226
227 return ret;
1246e28f
JS
228}
229
230#endif // wxUSE_POPUPWIN