// there is also the exception of wxMenuBar)
virtual bool GTKNeedsParent() const { return !IsTopLevel(); }
+ // This is called when capture is taken from the window. It will
+ // fire off capture lost events.
+ void GTKReleaseMouseAndNotify();
+
protected:
// Override GTKWidgetNeedsMnemonic and return true if your
// needs to set its mnemonic widget, such as for a
return GetReturnCode();
}
+ // release the mouse if it's currently captured as the window having it
+ // will be disabled when this dialog is shown -- but will still keep the
+ // capture making it impossible to do anything in the modal dialog itself
+ wxWindow * const win = wxWindow::GetCapture();
+ if ( win )
+ win->GTKReleaseMouseAndNotify();
+
// use the apps top level window as parent if none given unless explicitly
// forbidden
if ( !GetParent() && !(GetWindowStyleFlag() & wxDIALOG_NO_PARENT) )
}
}
+//-----------------------------------------------------------------------------
+// "grab_broken"
+//-----------------------------------------------------------------------------
+
+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 );
+ }
+}
+
+
} // extern "C"
// ----------------------------------------------------------------------------
// Catch native resize events
g_signal_connect (m_wxwindow, "size_allocate",
G_CALLBACK (gtk_window_size_callback), this);
+ // 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);
+ }
+
+ if ( connect_widget != m_wxwindow )
+ {
+ // 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);
}
#if wxUSE_COMBOBOX
gdk_pointer_ungrab ( (guint32)GDK_CURRENT_TIME );
}
+void wxWindowGTK::GTKReleaseMouseAndNotify()
+{
+ DoReleaseMouse();
+ wxMouseCaptureLostEvent evt(GetId());
+ evt.SetEventObject( this );
+ GetEventHandler()->ProcessEvent( evt );
+}
+
/* static */
wxWindow *wxWindowBase::GetCapture()
{