Browse Source

Various fixes

pull/875/head
Nikita Tsukanov 9 years ago
parent
commit
f7ebaf4c8a
  1. 2
      src/Gtk/Avalonia.Gtk3/Gtk3Platform.cs
  2. 4
      src/Gtk/Avalonia.Gtk3/Interop/Native.cs
  3. 4
      src/Gtk/Avalonia.Gtk3/PopupImpl.cs
  4. 4
      src/Gtk/Avalonia.Gtk3/SystemDialogs.cs
  5. 20
      src/Gtk/Avalonia.Gtk3/TopLevelImpl.cs

2
src/Gtk/Avalonia.Gtk3/Gtk3Platform.cs

@ -36,7 +36,7 @@ namespace Avalonia.Gtk3
.Bind<IMouseDevice>().ToConstant(Mouse)
.Bind<IPlatformSettings>().ToConstant(Instance)
.Bind<IPlatformThreadingInterface>().ToConstant(Instance)
.Bind<ISystemDialogImpl>().ToSingleton<SystemDialogStub>()
.Bind<ISystemDialogImpl>().ToSingleton<SystemDialog>()
.Bind<IRenderLoop>().ToConstant(new DefaultRenderLoop(60))
.Bind<IPlatformIconLoader>().ToConstant(new PlatformIconLoader());

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

@ -168,6 +168,9 @@ namespace Avalonia.Gtk3.Interop
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gdk)]
public delegate void gdk_window_begin_resize_drag(IntPtr window, WindowEdge edge, gint button, gint root_x, gint root_y, guint32 timestamp);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gdk)]
public delegate void gdk_event_request_motions(IntPtr ev);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)]
public delegate IntPtr gtk_clipboard_get_for_display(IntPtr display, IntPtr atom);
@ -299,6 +302,7 @@ namespace Avalonia.Gtk3.Interop
public static D.gdk_window_get_pointer GdkWindowGetPointer;
public static D.gdk_window_begin_move_drag GdkWindowBeginMoveDrag;
public static D.gdk_window_begin_resize_drag GdkWindowBeginResizeDrag;
public static D.gdk_event_request_motions GdkEventRequestMotions;
public static D.gdk_pixbuf_new_from_file GdkPixbufNewFromFile;
public static D.gtk_icon_theme_get_default GtkIconThemeGetDefault;

4
src/Gtk/Avalonia.Gtk3/PopupImpl.cs

@ -37,7 +37,9 @@ namespace Avalonia.Gtk3
return;
Native.GtkWindowSetDefaultSize(GtkWidget, (int)value.Width, (int)value.Height);
base.ClientSize = value;
var size = ClientSize;
if (Native.GtkWidgetGetWindow(GtkWidget) == IntPtr.Zero)
Native.GtkWidgetRealize(GtkWidget);
Native.GdkWindowResize(Native.GtkWidgetGetWindow(GtkWidget), (int)value.Width, (int)value.Height);
}
}
}

4
src/Gtk/Avalonia.Gtk3/SystemDialogs.cs

@ -9,11 +9,9 @@ using Avalonia.Gtk3.Interop;
using Avalonia.Input.Platform;
using Avalonia.Platform;
//TODO: This file should be empty once everything is implemented
namespace Avalonia.Gtk3
{
class SystemDialogStub : ISystemDialogImpl
class SystemDialog : ISystemDialogImpl
{
unsafe static Task<string[]> ShowDialog(string title, GtkWindow parent, GtkFileChooserAction action,

20
src/Gtk/Avalonia.Gtk3/TopLevelImpl.cs

@ -31,7 +31,7 @@ namespace Avalonia.Gtk3
_framebuffer = new FramebufferManager(this);
_imContext = Native.GtkImMulticontextNew();
Disposables.Add(_imContext);
Native.GtkWidgetSetEvents(gtkWidget, uint.MaxValue);
Native.GtkWidgetSetEvents(gtkWidget, 0xFFFFFE);
Disposables.Add(Signal.Connect<Native.D.signal_commit>(_imContext, "commit", OnCommit));
Connect<Native.D.signal_widget_draw>("draw", OnDraw);
Connect<Native.D.signal_generic>("realize", OnRealized);
@ -111,7 +111,7 @@ namespace Avalonia.Gtk3
: evnt->button == 3 ? RawMouseEventType.RightButtonDown : RawMouseEventType.MiddleButtonDown,
new Point(evnt->x, evnt->y), GetModifierKeys(evnt->state));
Input?.Invoke(e);
return false;
return true;
}
private unsafe bool OnStateChanged(IntPtr w, IntPtr pev, IntPtr userData)
@ -131,8 +131,7 @@ namespace Avalonia.Gtk3
{
var evnt = (GdkEventMotion*)ev;
var position = new Point(evnt->x, evnt->y);
Native.GdkEventRequestMotions(ev);
var e = new RawMouseEventArgs(
Gtk3Platform.Mouse,
evnt->time,
@ -140,7 +139,8 @@ namespace Avalonia.Gtk3
RawMouseEventType.Move,
position, GetModifierKeys(evnt->state));
Input(e);
return false;
return true;
}
private unsafe bool OnScroll(IntPtr w, IntPtr ev, IntPtr userdata)
{
@ -156,12 +156,13 @@ namespace Avalonia.Gtk3
else if (evnt->direction == GdkScrollDirection.Left)
delta = new Vector(step, 0);
else if (evnt->direction == GdkScrollDirection.Smooth)
delta = new Vector(evnt->delta_x, evnt->delta_y);
{
delta = new Vector(-evnt->delta_x, -evnt->delta_y);
}
var e = new RawMouseWheelEventArgs(Gtk3Platform.Mouse, evnt->time, _inputRoot,
new Point(evnt->x, evnt->y), delta, GetModifierKeys(evnt->state));
Input(e);
return false;
return true;
}
private unsafe bool OnKeyEvent(IntPtr w, IntPtr pev, IntPtr userData)
@ -303,9 +304,6 @@ namespace Avalonia.Gtk3
if (GtkWidget.IsClosed)
return;
Native.GtkWindowResize(GtkWidget, (int)value.Width, (int)value.Height);
if (Native.GtkWidgetGetWindow(GtkWidget) == IntPtr.Zero)
Native.GtkWidgetRealize(GtkWidget);
Native.GdkWindowResize(Native.GtkWidgetGetWindow(GtkWidget), (int)value.Width, (int)value.Height);
}
}

Loading…
Cancel
Save