+
+#ifdef __WXMSW__
+ // MSW doesn't allow to set focus to the popup window, but we need to
+ // subclass the window which has the focus, and not winFocus passed in or
+ // otherwise everything else breaks down
+ m_focus = FindFocus();
+ if ( m_focus )
+ {
+ delete m_handlerFocus;
+ m_handlerFocus = new wxPopupFocusHandler(this);
+
+ m_focus->PushEventHandler(m_handlerFocus);
+ }
+#else
+ // GTK+ catches the activate events from the popup
+ // window, not the focus events from the child window
+ delete m_handlerFocus;
+ m_handlerFocus = new wxPopupFocusHandler(this);
+ PushEventHandler(m_handlerFocus);
+#endif // __WXMSW__
+
+}
+
+bool wxPopupTransientWindow::Show( bool show )
+{
+#ifdef __WXGTK__
+ if (!show)
+ {
+ gdk_pointer_ungrab( (guint32)GDK_CURRENT_TIME );
+
+ gtk_grab_remove( m_widget );
+ }
+#endif
+
+#ifdef __WXX11__
+ if (!show)
+ {
+ XUngrabPointer( wxGlobalDisplay(), CurrentTime );
+ }
+#endif
+
+ bool ret = wxPopupWindow::Show( show );
+
+#ifdef __WXGTK__
+ if (show)
+ {
+ gtk_grab_add( m_widget );
+
+ gdk_pointer_grab( m_widget->window, TRUE,
+ (GdkEventMask)
+ (GDK_BUTTON_PRESS_MASK |
+ GDK_BUTTON_RELEASE_MASK |
+ GDK_POINTER_MOTION_HINT_MASK |
+ GDK_POINTER_MOTION_MASK),
+ (GdkWindow *) NULL,
+ (GdkCursor *) NULL,
+ (guint32)GDK_CURRENT_TIME );
+ }
+#endif
+
+#ifdef __WXX11__
+ if (show)
+ {
+ Window xwindow = (Window) m_clientWindow;
+
+ /* int res =*/ XGrabPointer(wxGlobalDisplay(), xwindow,
+ True,
+ ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask,
+ GrabModeAsync,
+ GrabModeAsync,
+ None,
+ None,
+ CurrentTime );
+ }
+#endif
+ return ret;