T *gdk_event)
{
event.SetTimestamp( gdk_event->time );
- event.m_shiftDown = (gdk_event->state & GDK_SHIFT_MASK);
- event.m_controlDown = (gdk_event->state & GDK_CONTROL_MASK);
- event.m_altDown = (gdk_event->state & GDK_MOD1_MASK);
- event.m_metaDown = (gdk_event->state & GDK_MOD2_MASK);
- event.m_leftDown = (gdk_event->state & GDK_BUTTON1_MASK);
- event.m_middleDown = (gdk_event->state & GDK_BUTTON2_MASK);
- event.m_rightDown = (gdk_event->state & GDK_BUTTON3_MASK);
+ event.m_shiftDown = gdk_event->state & GDK_SHIFT_MASK;
+ event.m_controlDown = gdk_event->state & GDK_CONTROL_MASK;
+ event.m_altDown = gdk_event->state & GDK_MOD1_MASK;
+ event.m_metaDown = gdk_event->state & GDK_MOD2_MASK;
+ event.m_leftDown = gdk_event->state & GDK_BUTTON1_MASK;
+ event.m_middleDown = gdk_event->state & GDK_BUTTON2_MASK;
+ event.m_rightDown = gdk_event->state & GDK_BUTTON3_MASK;
+ event.m_aux1Down = gdk_event->state & GDK_BUTTON4_MASK;
+ event.m_aux2Down = gdk_event->state & GDK_BUTTON5_MASK;
wxPoint pt = win->GetClientAreaOrigin();
event.m_x = (wxCoord)gdk_event->x - pt.x;
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.
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)
}
wxMouseEvent event(wxEVT_MOUSEWHEEL);
- // Can't use InitMouse macro because scroll events don't have button
- event.SetTimestamp( gdk_event->time );
- event.m_shiftDown = (gdk_event->state & GDK_SHIFT_MASK);
- event.m_controlDown = (gdk_event->state & GDK_CONTROL_MASK);
- event.m_altDown = (gdk_event->state & GDK_MOD1_MASK);
- event.m_metaDown = (gdk_event->state & GDK_MOD2_MASK);
- event.m_leftDown = (gdk_event->state & GDK_BUTTON1_MASK);
- event.m_middleDown = (gdk_event->state & GDK_BUTTON2_MASK);
- event.m_rightDown = (gdk_event->state & GDK_BUTTON3_MASK);
+ InitMouseEvent(win, event, gdk_event);
event.m_linesPerAction = 3;
event.m_wheelDelta = 120;
if (gdk_event->direction == GDK_SCROLL_UP)
else
event.m_wheelRotation = -120;
- wxPoint pt = win->GetClientAreaOrigin();
- event.m_x = (wxCoord)gdk_event->x - pt.x;
- event.m_y = (wxCoord)gdk_event->y - pt.y;
-
- event.SetEventObject( win );
- event.SetId( win->GetId() );
- event.SetTimestamp( gdk_event->time );
-
return win->GTKProcessEvent(event);
}
// Disable default focus handling for custom windows
// since the default GTK+ handler issues a repaint
if ( has_wxwindow )
+ {
return TRUE;
+ }
}
// continue with normal processing
if (gdk_event->mode != GDK_CROSSING_NORMAL) return FALSE;
wxMouseEvent event( wxEVT_LEAVE_WINDOW );
- event.SetTimestamp( gdk_event->time );
- event.SetEventObject( win );
int x = 0;
int y = 0;
gdk_window_get_pointer( widget->window, &x, &y, &state );
- event.m_shiftDown = (state & GDK_SHIFT_MASK) != 0;
- event.m_controlDown = (state & GDK_CONTROL_MASK) != 0;
- event.m_altDown = (state & GDK_MOD1_MASK) != 0;
- event.m_metaDown = (state & GDK_MOD2_MASK) != 0;
- event.m_leftDown = (state & GDK_BUTTON1_MASK) != 0;
- event.m_middleDown = (state & GDK_BUTTON2_MASK) != 0;
- event.m_rightDown = (state & GDK_BUTTON3_MASK) != 0;
-
- wxPoint pt = win->GetClientAreaOrigin();
- event.m_x = x + pt.x;
- event.m_y = y + pt.y;
+ InitMouseEvent(win, event, gdk_event);
return win->GTKProcessEvent(event);
}
}
}
+//-----------------------------------------------------------------------------
+// "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"
// ----------------------------------------------------------------------------
ms.SetLeftDown(mask & GDK_BUTTON1_MASK);
ms.SetMiddleDown(mask & GDK_BUTTON2_MASK);
ms.SetRightDown(mask & GDK_BUTTON3_MASK);
+ ms.SetAux1Down(mask & GDK_BUTTON4_MASK);
+ ms.SetAux2Down(mask & GDK_BUTTON5_MASK);
ms.SetControlDown(mask & GDK_CONTROL_MASK);
ms.SetShiftDown(mask & GDK_SHIFT_MASK);
// 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
g_signal_connect (gcombo->entry, "size_request",
G_CALLBACK (wxgtk_combo_size_request_callback),
this);
- }
- else
+ } else
#endif // wxUSE_COMBOBOX
#ifdef GTK_IS_FILE_CHOOSER_BUTTON
if (!gtk_check_version(2,6,0) && GTK_IS_FILE_CHOOSER_BUTTON(m_widget))
// then that control won't be sized properly when placed inside sizers
// (this can be tested removing this elseif and running XRC or WIDGETS samples)
// FIXME: what should be done here ?
- }
+ } else
#endif
- else if ( !IsTopLevel() ) // top level windows use their own callback
+ if ( !IsTopLevel() ) // top level windows use their own callback
{
// This is needed if we want to add our windows into native
// GTK controls, such as the toolbar. With this callback, the
}
else // navigate inside the container
{
- wxWindow *parent = wxGetTopLevelParent(this);
+ wxWindow *parent = wxGetTopLevelParent((wxWindow *)this);
wxCHECK_MSG( parent, false, _T("every window must have a TLW parent") );
GtkDirectionType dir;
gdk_pointer_ungrab ( (guint32)GDK_CURRENT_TIME );
}
+void wxWindowGTK::GTKReleaseMouseAndNotify()
+{
+ DoReleaseMouse();
+ wxMouseCaptureLostEvent evt(GetId());
+ evt.SetEventObject( this );
+ GetEventHandler()->ProcessEvent( evt );
+}
+
/* static */
wxWindow *wxWindowBase::GetCapture()
{