]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/window.cpp
[ 1793012 ] wxSpinCtrl::SetValue() doesn't update internal counter
[wxWidgets.git] / src / gtk / window.cpp
index a113e7105fddd884147f1c9246714768fafe6572..e8b8ed17199df2c4bd92977964fb616459fdd0ac 100644 (file)
@@ -1440,11 +1440,6 @@ gtk_window_button_press_callback( GtkWidget *widget,
 
     g_lastButtonNumber = gdk_event->button;
 
 
     g_lastButtonNumber = gdk_event->button;
 
-    if (win->m_wxwindow && (g_focusWindow != win) && win->IsFocusable())
-    {
-        gtk_widget_grab_focus( win->m_wxwindow );
-    }
-
     // GDK sends surplus button down events
     // before a double click event. We
     // need to filter these out.
     // GDK sends surplus button down events
     // before a double click event. We
     // need to filter these out.
@@ -1576,9 +1571,9 @@ gtk_window_button_press_callback( GtkWidget *widget,
         return TRUE;
 
     if ((event_type == wxEVT_LEFT_DOWN) && !win->IsOfStandardClass() && 
         return TRUE;
 
     if ((event_type == wxEVT_LEFT_DOWN) && !win->IsOfStandardClass() && 
-        (g_focusWindow != win) && win->IsFocusable())
+        (g_focusWindow != win) /* && win->IsFocusable() */)
     {
     {
-        gtk_widget_grab_focus( win->m_wxwindow );
+        win->SetFocus();
     }
 
     if (event_type == wxEVT_RIGHT_DOWN)
     }
 
     if (event_type == wxEVT_RIGHT_DOWN)
@@ -1870,7 +1865,9 @@ gtk_window_focus_out_callback( GtkWidget *widget,
         // Disable default focus handling for custom windows
         // since the default GTK+ handler issues a repaint
         if ( has_wxwindow )
         // Disable default focus handling for custom windows
         // since the default GTK+ handler issues a repaint
         if ( has_wxwindow )
+       {
             return TRUE;
             return TRUE;
+       }
     }
 
     // continue with normal processing
     }
 
     // continue with normal processing
@@ -2107,6 +2104,27 @@ void gtk_window_size_callback( GtkWidget *WXUNUSED(widget),
     }
 }
 
     }
 }
 
+//-----------------------------------------------------------------------------
+// "grab_broken" 
+//-----------------------------------------------------------------------------
+
+#ifdef __WXGTK210__
+static void
+gtk_window_grab_broken( GtkWidget *m_widget,
+                        GdkEventGrabBroken *event,
+                        wxWindow *win )
+{
+    // Mouse capture has been lost involuntarily, notify the application
+    if( !event->keyboard && win && wxWindow::GetCapture() == win )
+    {
+        wxMouseCaptureLostEvent evt( win->GetId() );
+        evt.SetEventObject( win );
+        win->GetEventHandler()->ProcessEvent( evt );
+    }
+}
+#endif
+
+
 } // extern "C"
 
 // ----------------------------------------------------------------------------
 } // extern "C"
 
 // ----------------------------------------------------------------------------
@@ -2521,6 +2539,26 @@ void wxWindowGTK::PostCreation()
         // Catch native resize events
         g_signal_connect (m_wxwindow, "size_allocate",
                           G_CALLBACK (gtk_window_size_callback), this);
         // Catch native resize events
         g_signal_connect (m_wxwindow, "size_allocate",
                           G_CALLBACK (gtk_window_size_callback), this);
+#ifdef __WXGTK210__
+        if (!gtk_check_version(2,8,0))
+        {
+            // Make sure we can notify the app when mouse capture is lost
+            g_signal_connect (m_wxwindow, "grab_broken_event",
+                          G_CALLBACK (gtk_window_grab_broken), this);
+        }
+#endif
+    }
+
+    if ( connect_widget != m_wxwindow )
+    {
+#ifdef __WXGTK210__
+        if (!gtk_check_version(2,8,0))
+        {
+            // Make sure we can notify app code when mouse capture is lost
+            g_signal_connect (connect_widget, "grab_broken_event",
+                        G_CALLBACK (gtk_window_grab_broken), this);
+        }
+#endif
     }
 
 #if wxUSE_COMBOBOX
     }
 
 #if wxUSE_COMBOBOX
@@ -4069,6 +4107,14 @@ void wxWindowGTK::DoReleaseMouse()
     gdk_pointer_ungrab ( (guint32)GDK_CURRENT_TIME );
 }
 
     gdk_pointer_ungrab ( (guint32)GDK_CURRENT_TIME );
 }
 
+void wxWindowGTK::GTKReleaseMouseAndNotify()
+{
+    DoReleaseMouse();
+    wxMouseCaptureLostEvent evt(GetId());
+    evt.SetEventObject( this );
+    GetEventHandler()->ProcessEvent( evt );
+}
+
 /* static */
 wxWindow *wxWindowBase::GetCapture()
 {
 /* static */
 wxWindow *wxWindowBase::GetCapture()
 {