Browse Source

Implemented mouse leave event for GTK3 backend

pull/1056/head
Nikita Tsukanov 9 years ago
parent
commit
644708bb7c
  1. 18
      src/Gtk/Avalonia.Gtk3/Interop/Native.cs
  2. 13
      src/Gtk/Avalonia.Gtk3/WindowBaseImpl.cs

18
src/Gtk/Avalonia.Gtk3/Interop/Native.cs

@ -500,6 +500,24 @@ namespace Avalonia.Gtk3.Interop
public gdouble delta_y;
}
[StructLayout(LayoutKind.Sequential)]
unsafe struct GdkEventCrossing
{
public GdkEventType type;
public IntPtr window;
public gint8 send_event;
public IntPtr subwindow;
public guint32 time;
public gdouble x;
public gdouble y;
public gdouble x_root;
public gdouble y_root;
public int mode;
public int detail;
public bool focus;
public GdkModifierType state;
};
[StructLayout(LayoutKind.Sequential)]
unsafe struct GdkEventWindowState
{

13
src/Gtk/Avalonia.Gtk3/WindowBaseImpl.cs

@ -45,6 +45,7 @@ namespace Avalonia.Gtk3
ConnectEvent("window-state-event", OnStateChanged);
ConnectEvent("key-press-event", OnKeyEvent);
ConnectEvent("key-release-event", OnKeyEvent);
ConnectEvent("leave-notify-event", OnLeaveNotifyEvent);
Connect<Native.D.signal_generic>("destroy", OnDestroy);
Native.GtkWidgetRealize(gtkWidget);
_lastSize = ClientSize;
@ -194,6 +195,18 @@ namespace Avalonia.Gtk3
return true;
}
private unsafe bool OnLeaveNotifyEvent(IntPtr w, IntPtr pev, IntPtr userData)
{
var evnt = (GdkEventCrossing*) pev;
var position = new Point(evnt->x, evnt->y);
Input(new RawMouseEventArgs(Gtk3Platform.Mouse,
evnt->time,
_inputRoot,
RawMouseEventType.Move,
position, GetModifierKeys(evnt->state)));
return true;
}
private unsafe bool OnCommit(IntPtr gtkwidget, IntPtr utf8string, IntPtr userdata)
{
Input(new RawTextInputEventArgs(Gtk3Platform.Keyboard, _lastKbdEvent, Utf8Buffer.StringFromPtr(utf8string)));

Loading…
Cancel
Save