mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-09-07 15:33:20 +02:00
gdk: Use a Dictionary to hold the filter functions in Window class
This commit is contained in:
parent
eddc5fa796
commit
6ecd2d01f9
@ -25,7 +25,7 @@
|
|||||||
namespace Gdk {
|
namespace Gdk {
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections.Generic;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
public partial class Window {
|
public partial class Window {
|
||||||
@ -119,11 +119,12 @@ namespace Gdk {
|
|||||||
[DllImport ("libgdk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
[DllImport ("libgdk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
static extern void gdk_window_remove_filter (IntPtr handle, GdkSharp.FilterFuncNative wrapper, IntPtr data);
|
static extern void gdk_window_remove_filter (IntPtr handle, GdkSharp.FilterFuncNative wrapper, IntPtr data);
|
||||||
|
|
||||||
static Hashtable filter_all_hash;
|
static IDictionary<FilterFunc, GdkSharp.FilterFuncWrapper> filter_all_hash;
|
||||||
static Hashtable FilterAllHash {
|
static IDictionary<FilterFunc, GdkSharp.FilterFuncWrapper> FilterAllHash {
|
||||||
get {
|
get {
|
||||||
if (filter_all_hash == null)
|
if (filter_all_hash == null) {
|
||||||
filter_all_hash = new Hashtable ();
|
filter_all_hash = new Dictionary<FilterFunc, GdkSharp.FilterFuncWrapper> ();
|
||||||
|
}
|
||||||
return filter_all_hash;
|
return filter_all_hash;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -137,18 +138,19 @@ namespace Gdk {
|
|||||||
|
|
||||||
public static void RemoveFilterForAll (FilterFunc func)
|
public static void RemoveFilterForAll (FilterFunc func)
|
||||||
{
|
{
|
||||||
GdkSharp.FilterFuncWrapper wrapper = FilterAllHash [func] as GdkSharp.FilterFuncWrapper;
|
GdkSharp.FilterFuncWrapper wrapper = null;
|
||||||
if (wrapper == null)
|
if (FilterAllHash.TryGetValue (func, out wrapper)) {
|
||||||
return;
|
FilterAllHash.Remove (func);
|
||||||
FilterAllHash.Remove (func);
|
gdk_window_remove_filter (IntPtr.Zero, wrapper.NativeDelegate, IntPtr.Zero);
|
||||||
gdk_window_remove_filter (IntPtr.Zero, wrapper.NativeDelegate, IntPtr.Zero);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddFilter (FilterFunc function)
|
public void AddFilter (FilterFunc function)
|
||||||
{
|
{
|
||||||
if (!Data.Contains ("filter_func_hash"))
|
if (!Data.ContainsKey ("filter_func_hash")) {
|
||||||
Data ["filter_func_hash"] = new Hashtable ();
|
Data ["filter_func_hash"] = new Dictionary<FilterFunc, GdkSharp.FilterFuncWrapper> ();
|
||||||
Hashtable hash = Data ["filter_func_hash"] as Hashtable;
|
}
|
||||||
|
var hash = Data ["filter_func_hash"] as Dictionary<FilterFunc, GdkSharp.FilterFuncWrapper>;
|
||||||
GdkSharp.FilterFuncWrapper wrapper = new GdkSharp.FilterFuncWrapper (function);
|
GdkSharp.FilterFuncWrapper wrapper = new GdkSharp.FilterFuncWrapper (function);
|
||||||
hash [function] = wrapper;
|
hash [function] = wrapper;
|
||||||
gdk_window_add_filter (Handle, wrapper.NativeDelegate, IntPtr.Zero);
|
gdk_window_add_filter (Handle, wrapper.NativeDelegate, IntPtr.Zero);
|
||||||
@ -156,12 +158,12 @@ namespace Gdk {
|
|||||||
|
|
||||||
public void RemoveFilter (FilterFunc function)
|
public void RemoveFilter (FilterFunc function)
|
||||||
{
|
{
|
||||||
Hashtable hash = Data ["filter_func_hash"] as Hashtable;
|
var hash = Data ["filter_func_hash"] as Dictionary<FilterFunc, GdkSharp.FilterFuncWrapper>;
|
||||||
GdkSharp.FilterFuncWrapper wrapper = hash [function] as GdkSharp.FilterFuncWrapper;
|
GdkSharp.FilterFuncWrapper wrapper = null;
|
||||||
if (wrapper == null)
|
if (hash.TryGetValue (function, out wrapper)) {
|
||||||
return;
|
hash.Remove (function);
|
||||||
hash.Remove (function);
|
gdk_window_remove_filter (Handle, wrapper.NativeDelegate, IntPtr.Zero);
|
||||||
gdk_window_remove_filter (Handle, wrapper.NativeDelegate, IntPtr.Zero);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MANLY_ENOUGH_TO_INCLUDE
|
#if MANLY_ENOUGH_TO_INCLUDE
|
||||||
|
Loading…
Reference in New Issue
Block a user