// This file was generated by the Gtk# code generator.
// Any changes made will be lost if regenerated.

namespace Gdk {

	using System;
	using System.Collections;
	using System.Collections.Generic;
	using System.Runtime.InteropServices;
	using static GLib.AbiStructExtension;

#region Autogenerated code
	public partial class DeviceManager : GLib.Object {

		public DeviceManager (IntPtr raw) : base(raw) {}

		protected DeviceManager() : base(IntPtr.Zero)
		{
			CreateNativeObject (Array.Empty<string> (), Array.Empty<GLib.Value> ());
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_gdk_device_manager_get_display(IntPtr raw);
		static d_gdk_device_manager_get_display gdk_device_manager_get_display = FuncLoader.LoadFunction<d_gdk_device_manager_get_display>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gdk), "gdk_device_manager_get_display"));

		[GLib.Property ("display")]
		public Gdk.Display Display {
			get  {
				IntPtr raw_ret = gdk_device_manager_get_display(Handle);
				Gdk.Display ret = GLib.Object.GetObject(raw_ret) as Gdk.Display;
				return ret;
			}
		}

		[GLib.Signal("device-added")]
		public event Gdk.DeviceAddedHandler DeviceAdded {
			add {
				this.AddSignalHandler ("device-added", value, typeof (Gdk.DeviceAddedArgs));
			}
			remove {
				this.RemoveSignalHandler ("device-added", value);
			}
		}

		[GLib.Signal("device-removed")]
		public event Gdk.DeviceRemovedHandler DeviceRemoved {
			add {
				this.AddSignalHandler ("device-removed", value, typeof (Gdk.DeviceRemovedArgs));
			}
			remove {
				this.RemoveSignalHandler ("device-removed", value);
			}
		}

		[GLib.Signal("device-changed")]
		public event Gdk.DeviceChangedHandler DeviceChanged {
			add {
				this.AddSignalHandler ("device-changed", value, typeof (Gdk.DeviceChangedArgs));
			}
			remove {
				this.RemoveSignalHandler ("device-changed", value);
			}
		}

		static DeviceAddedNativeDelegate DeviceAdded_cb_delegate;
		static DeviceAddedNativeDelegate DeviceAddedVMCallback {
			get {
				if (DeviceAdded_cb_delegate == null)
					DeviceAdded_cb_delegate = new DeviceAddedNativeDelegate (DeviceAdded_cb);
				return DeviceAdded_cb_delegate;
			}
		}

		static void OverrideDeviceAdded (GLib.GType gtype)
		{
			OverrideDeviceAdded (gtype, DeviceAddedVMCallback);
		}

		static void OverrideDeviceAdded (GLib.GType gtype, DeviceAddedNativeDelegate callback)
		{
			unsafe {
				IntPtr* raw_ptr = (IntPtr*)(((long) gtype.GetClassPtr()) + (long) class_abi.GetFieldOffset("device_added"));
				*raw_ptr = Marshal.GetFunctionPointerForDelegate(callback);
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void DeviceAddedNativeDelegate (IntPtr inst, IntPtr device);

		static void DeviceAdded_cb (IntPtr inst, IntPtr device)
		{
			try {
				DeviceManager __obj = GLib.Object.GetObject (inst, false) as DeviceManager;
				__obj.OnDeviceAdded (GLib.Object.GetObject(device) as Gdk.Device);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(Gdk.DeviceManager), ConnectionMethod="OverrideDeviceAdded")]
		protected virtual void OnDeviceAdded (Gdk.Device device)
		{
			InternalDeviceAdded (device);
		}

		private void InternalDeviceAdded (Gdk.Device device)
		{
			DeviceAddedNativeDelegate unmanaged = class_abi.BaseOverride<DeviceAddedNativeDelegate>(this.LookupGType(), "device_added");
			if (unmanaged == null) return;

			unmanaged (this.Handle, device == null ? IntPtr.Zero : device.Handle);
		}

		static DeviceRemovedNativeDelegate DeviceRemoved_cb_delegate;
		static DeviceRemovedNativeDelegate DeviceRemovedVMCallback {
			get {
				if (DeviceRemoved_cb_delegate == null)
					DeviceRemoved_cb_delegate = new DeviceRemovedNativeDelegate (DeviceRemoved_cb);
				return DeviceRemoved_cb_delegate;
			}
		}

		static void OverrideDeviceRemoved (GLib.GType gtype)
		{
			OverrideDeviceRemoved (gtype, DeviceRemovedVMCallback);
		}

		static void OverrideDeviceRemoved (GLib.GType gtype, DeviceRemovedNativeDelegate callback)
		{
			unsafe {
				IntPtr* raw_ptr = (IntPtr*)(((long) gtype.GetClassPtr()) + (long) class_abi.GetFieldOffset("device_removed"));
				*raw_ptr = Marshal.GetFunctionPointerForDelegate(callback);
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void DeviceRemovedNativeDelegate (IntPtr inst, IntPtr device);

		static void DeviceRemoved_cb (IntPtr inst, IntPtr device)
		{
			try {
				DeviceManager __obj = GLib.Object.GetObject (inst, false) as DeviceManager;
				__obj.OnDeviceRemoved (GLib.Object.GetObject(device) as Gdk.Device);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(Gdk.DeviceManager), ConnectionMethod="OverrideDeviceRemoved")]
		protected virtual void OnDeviceRemoved (Gdk.Device device)
		{
			InternalDeviceRemoved (device);
		}

		private void InternalDeviceRemoved (Gdk.Device device)
		{
			DeviceRemovedNativeDelegate unmanaged = class_abi.BaseOverride<DeviceRemovedNativeDelegate>(this.LookupGType(), "device_removed");
			if (unmanaged == null) return;

			unmanaged (this.Handle, device == null ? IntPtr.Zero : device.Handle);
		}

		static DeviceChangedNativeDelegate DeviceChanged_cb_delegate;
		static DeviceChangedNativeDelegate DeviceChangedVMCallback {
			get {
				if (DeviceChanged_cb_delegate == null)
					DeviceChanged_cb_delegate = new DeviceChangedNativeDelegate (DeviceChanged_cb);
				return DeviceChanged_cb_delegate;
			}
		}

		static void OverrideDeviceChanged (GLib.GType gtype)
		{
			OverrideDeviceChanged (gtype, DeviceChangedVMCallback);
		}

		static void OverrideDeviceChanged (GLib.GType gtype, DeviceChangedNativeDelegate callback)
		{
			unsafe {
				IntPtr* raw_ptr = (IntPtr*)(((long) gtype.GetClassPtr()) + (long) class_abi.GetFieldOffset("device_changed"));
				*raw_ptr = Marshal.GetFunctionPointerForDelegate(callback);
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void DeviceChangedNativeDelegate (IntPtr inst, IntPtr device);

		static void DeviceChanged_cb (IntPtr inst, IntPtr device)
		{
			try {
				DeviceManager __obj = GLib.Object.GetObject (inst, false) as DeviceManager;
				__obj.OnDeviceChanged (GLib.Object.GetObject(device) as Gdk.Device);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(Gdk.DeviceManager), ConnectionMethod="OverrideDeviceChanged")]
		protected virtual void OnDeviceChanged (Gdk.Device device)
		{
			InternalDeviceChanged (device);
		}

		private void InternalDeviceChanged (Gdk.Device device)
		{
			DeviceChangedNativeDelegate unmanaged = class_abi.BaseOverride<DeviceChangedNativeDelegate>(this.LookupGType(), "device_changed");
			if (unmanaged == null) return;

			unmanaged (this.Handle, device == null ? IntPtr.Zero : device.Handle);
		}

		static ListDevicesNativeDelegate ListDevices_cb_delegate;
		static ListDevicesNativeDelegate ListDevicesVMCallback {
			get {
				if (ListDevices_cb_delegate == null)
					ListDevices_cb_delegate = new ListDevicesNativeDelegate (ListDevices_cb);
				return ListDevices_cb_delegate;
			}
		}

		static void OverrideListDevices (GLib.GType gtype)
		{
			OverrideListDevices (gtype, ListDevicesVMCallback);
		}

		static void OverrideListDevices (GLib.GType gtype, ListDevicesNativeDelegate callback)
		{
			unsafe {
				IntPtr* raw_ptr = (IntPtr*)(((long) gtype.GetClassPtr()) + (long) class_abi.GetFieldOffset("list_devices"));
				*raw_ptr = Marshal.GetFunctionPointerForDelegate(callback);
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr ListDevicesNativeDelegate (IntPtr inst, int type);

		static IntPtr ListDevices_cb (IntPtr inst, int type)
		{
			try {
				DeviceManager __obj = GLib.Object.GetObject (inst, false) as DeviceManager;
				Gdk.Device[] __result;
				__result = __obj.OnListDevices ((Gdk.DeviceType) type);
				return new GLib.List(__result, typeof (Gdk.Device), true, false) == null ? IntPtr.Zero : new GLib.List(__result, typeof (Gdk.Device), true, false).Handle;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw;
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(Gdk.DeviceManager), ConnectionMethod="OverrideListDevices")]
		protected virtual Gdk.Device[] OnListDevices (Gdk.DeviceType type)
		{
			return InternalListDevices (type);
		}

		private Gdk.Device[] InternalListDevices (Gdk.DeviceType type)
		{
			ListDevicesNativeDelegate unmanaged = class_abi.BaseOverride<ListDevicesNativeDelegate>(this.LookupGType(), "list_devices");
			if (unmanaged == null) return null;

			IntPtr __result = unmanaged (this.Handle, (int) type);
			return GLib.Marshaller.ListPtrToArray<Gdk.Device, Gdk.Device> (__result, true, false);
		}

		static GetClientPointerNativeDelegate GetClientPointer_cb_delegate;
		static GetClientPointerNativeDelegate GetClientPointerVMCallback {
			get {
				if (GetClientPointer_cb_delegate == null)
					GetClientPointer_cb_delegate = new GetClientPointerNativeDelegate (GetClientPointer_cb);
				return GetClientPointer_cb_delegate;
			}
		}

		static void OverrideGetClientPointer (GLib.GType gtype)
		{
			OverrideGetClientPointer (gtype, GetClientPointerVMCallback);
		}

		static void OverrideGetClientPointer (GLib.GType gtype, GetClientPointerNativeDelegate callback)
		{
			unsafe {
				IntPtr* raw_ptr = (IntPtr*)(((long) gtype.GetClassPtr()) + (long) class_abi.GetFieldOffset("get_client_pointer"));
				*raw_ptr = Marshal.GetFunctionPointerForDelegate(callback);
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr GetClientPointerNativeDelegate (IntPtr inst);

		static IntPtr GetClientPointer_cb (IntPtr inst)
		{
			try {
				DeviceManager __obj = GLib.Object.GetObject (inst, false) as DeviceManager;
				Gdk.Device __result;
				__result = __obj.OnGetClientPointer ();
				return __result == null ? IntPtr.Zero : __result.Handle;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw;
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(Gdk.DeviceManager), ConnectionMethod="OverrideGetClientPointer")]
		protected virtual Gdk.Device OnGetClientPointer ()
		{
			return InternalGetClientPointer ();
		}

		private Gdk.Device InternalGetClientPointer ()
		{
			GetClientPointerNativeDelegate unmanaged = class_abi.BaseOverride<GetClientPointerNativeDelegate>(this.LookupGType(), "get_client_pointer");
			if (unmanaged == null) return null;

			IntPtr __result = unmanaged (this.Handle);
			return GLib.Object.GetObject(__result) as Gdk.Device;
		}


		// Internal representation of the wrapped structure ABI.
		static GLib.AbiStruct _class_abi = null;
		static public unsafe new GLib.AbiStruct class_abi {
			get {
				if (_class_abi == null)
					_class_abi = new GLib.AbiStruct (new List<GLib.AbiField>{ 
						new GLib.AbiField("device_added"
							, GLib.Object.class_abi.Fields
							, (uint) sizeof( IntPtr ) // device_added
							, null
							, "device_removed"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("device_removed"
							, -1
							, (uint) sizeof( IntPtr ) // device_removed
							, "device_added"
							, "device_changed"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("device_changed"
							, -1
							, (uint) sizeof( IntPtr ) // device_changed
							, "device_removed"
							, "list_devices"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("list_devices"
							, -1
							, (uint) sizeof( IntPtr ) // list_devices
							, "device_changed"
							, "get_client_pointer"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("get_client_pointer"
							, -1
							, (uint) sizeof( IntPtr ) // get_client_pointer
							, "list_devices"
							, null
							, (uint) sizeof(IntPtr)
							, 0
							),
					});

				return _class_abi;
			}
		}


		// End of the ABI representation.

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_gdk_device_manager_get_client_pointer(IntPtr raw);
		static d_gdk_device_manager_get_client_pointer gdk_device_manager_get_client_pointer = FuncLoader.LoadFunction<d_gdk_device_manager_get_client_pointer>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gdk), "gdk_device_manager_get_client_pointer"));

		[Obsolete]
		public Gdk.Device ClientPointer { 
			get {
				IntPtr raw_ret = gdk_device_manager_get_client_pointer(Handle);
				Gdk.Device ret = GLib.Object.GetObject(raw_ret) as Gdk.Device;
				return ret;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_gdk_device_manager_get_type();
		static d_gdk_device_manager_get_type gdk_device_manager_get_type = FuncLoader.LoadFunction<d_gdk_device_manager_get_type>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gdk), "gdk_device_manager_get_type"));

		public static new GLib.GType GType { 
			get {
				IntPtr raw_ret = gdk_device_manager_get_type();
				GLib.GType ret = new GLib.GType(raw_ret);
				return ret;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_gdk_device_manager_list_devices(IntPtr raw, int type);
		static d_gdk_device_manager_list_devices gdk_device_manager_list_devices = FuncLoader.LoadFunction<d_gdk_device_manager_list_devices>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gdk), "gdk_device_manager_list_devices"));

		[Obsolete]
		public Gdk.Device[] ListDevices(Gdk.DeviceType type) {
			IntPtr raw_ret = gdk_device_manager_list_devices(Handle, (int) type);
			Gdk.Device[] ret = GLib.Marshaller.ListPtrToArray<Gdk.Device, Gdk.Device> (raw_ret, true, false);
			return ret;
		}


		// Internal representation of the wrapped structure ABI.
		static GLib.AbiStruct _abi_info = null;
		static public unsafe new GLib.AbiStruct abi_info {
			get {
				if (_abi_info == null)
					_abi_info = new GLib.AbiStruct (GLib.Object.abi_info.Fields);

				return _abi_info;
			}
		}


		// End of the ABI representation.

#endregion
	}
}
