]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/popupcmn.cpp
Applied patch [ 1117207 ] changed the test for SQL_C_WCHAR
[wxWidgets.git] / src / common / popupcmn.cpp
index 85124079c688c3d66f14132e14724879d77adc58..79b3bbf23b96aa956a6ff7b48e15dd4342f1676a 100644 (file)
@@ -46,6 +46,9 @@
 #ifdef __WXGTK__
     #include <gtk/gtk.h>
 #endif
+#ifdef __WXX11__
+#include "wx/x11/private.h"
+#endif
 
 IMPLEMENT_DYNAMIC_CLASS(wxPopupWindow, wxWindow)
 IMPLEMENT_DYNAMIC_CLASS(wxPopupTransientWindow, wxPopupWindow)
@@ -85,16 +88,7 @@ public:
     }
 
 protected:
-    // event handlers
-#ifdef __WXMSW__
-    // Under MSW, we catch the kill focus event
     void OnKillFocus(wxFocusEvent& event);
-#else
-    // Under GTK+, event a transient popup window
-    // is a toplevel window so we need to catch
-    // deactivate events
-    void OnActivate(wxActivateEvent &event);
-#endif
     void OnKeyDown(wxKeyEvent& event);
 
 private:
@@ -113,11 +107,7 @@ BEGIN_EVENT_TABLE(wxPopupWindowHandler, wxEvtHandler)
 END_EVENT_TABLE()
 
 BEGIN_EVENT_TABLE(wxPopupFocusHandler, wxEvtHandler)
-#ifdef __WXMSW__
     EVT_KILL_FOCUS(wxPopupFocusHandler::OnKillFocus)
-#else
-    EVT_ACTIVATE(wxPopupFocusHandler::OnActivate)
-#endif
     EVT_KEY_DOWN(wxPopupFocusHandler::OnKeyDown)
 END_EVENT_TABLE()
 
@@ -211,7 +201,7 @@ void wxPopupTransientWindow::PopHandlers()
             m_handlerPopup = NULL;
         }
 
-        m_child->ReleaseMouse();
+        // m_child->ReleaseMouse();
         m_child = NULL;
     }
 
@@ -258,7 +248,7 @@ void wxPopupTransientWindow::Popup(wxWindow *winFocus)
     delete m_handlerPopup;
     m_handlerPopup = new wxPopupWindowHandler(this);
 
-    m_child->CaptureMouse();
+    // m_child->CaptureMouse();
     m_child->PushEventHandler(m_handlerPopup);
 
     m_focus = winFocus ? winFocus : this;
@@ -290,16 +280,54 @@ 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;
 }
 
@@ -474,7 +502,6 @@ void wxPopupWindowHandler::OnLeftDown(wxMouseEvent& event)
 // wxPopupFocusHandler
 // ----------------------------------------------------------------------------
 
-#ifdef __WXMSW__
 void wxPopupFocusHandler::OnKillFocus(wxFocusEvent& event)
 {
     // when we lose focus we always disappear - unless it goes to the popup (in
@@ -489,13 +516,6 @@ void wxPopupFocusHandler::OnKillFocus(wxFocusEvent& event)
 
     m_popup->DismissAndNotify();
 }
-#else
-void wxPopupFocusHandler::OnActivate(wxActivateEvent &event)
-{
-    if (event.GetActive())
-        m_popup->DismissAndNotify();
-}
-#endif
 
 void wxPopupFocusHandler::OnKeyDown(wxKeyEvent& event)
 {