| 1 |
/* GDK - The GIMP Drawing Kit |
| 2 |
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald |
| 3 |
* |
| 4 |
* This library is free software; you can redistribute it and/or |
| 5 |
* modify it under the terms of the GNU Lesser General Public |
| 6 |
* License as published by the Free Software Foundation; either |
| 7 |
* version 2 of the License, or (at your option) any later version. |
| 8 |
* |
| 9 |
* This library is distributed in the hope that it will be useful, |
| 10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 |
* Lesser General Public License for more details. |
| 13 |
* |
| 14 |
* You should have received a copy of the GNU Lesser General Public |
| 15 |
* License along with this library. If not, see <http://www.gnu.org/licenses/>. |
| 16 |
*/ |
| 17 |
|
| 18 |
/* |
| 19 |
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS |
| 20 |
* file for a list of people on the GTK+ Team. See the ChangeLog |
| 21 |
* files for a list of changes. These files are distributed with |
| 22 |
* GTK+ at ftp://ftp.gtk.org/pub/gtk/. |
| 23 |
*/ |
| 24 |
|
| 25 |
#include "config.h" |
| 26 |
#include <gdk/gdk.h> |
| 27 |
|
| 28 |
#include "gdkprivate-win32.h" |
| 29 |
|
| 30 |
static GHashTable *handle_ht = NULL; |
| 31 |
|
| 32 |
static guint |
| 33 |
gdk_handle_hash (HANDLE *handle) |
| 34 |
{ |
| 35 |
#ifdef _WIN64 |
| 36 |
return ((guint *) handle)[0] ^ ((guint *) handle)[1]; |
| 37 |
#else |
| 38 |
return (guint) *handle; |
| 39 |
#endif |
| 40 |
} |
| 41 |
|
| 42 |
static gint |
| 43 |
gdk_handle_equal (HANDLE *a, |
| 44 |
HANDLE *b) |
| 45 |
{ |
| 46 |
return (*a == *b); |
| 47 |
} |
| 48 |
|
| 49 |
void |
| 50 |
gdk_win32_handle_table_insert (HANDLE *handle, |
| 51 |
gpointer data) |
| 52 |
{ |
| 53 |
g_return_if_fail (handle != NULL); |
| 54 |
|
| 55 |
if (!handle_ht) |
| 56 |
handle_ht = g_hash_table_new ((GHashFunc) gdk_handle_hash, |
| 57 |
(GEqualFunc) gdk_handle_equal); |
| 58 |
|
| 59 |
g_hash_table_insert (handle_ht, handle, data); |
| 60 |
} |
| 61 |
|
| 62 |
void |
| 63 |
gdk_win32_handle_table_remove (HANDLE handle) |
| 64 |
{ |
| 65 |
if (!handle_ht) |
| 66 |
handle_ht = g_hash_table_new ((GHashFunc) gdk_handle_hash, |
| 67 |
(GEqualFunc) gdk_handle_equal); |
| 68 |
|
| 69 |
g_hash_table_remove (handle_ht, &handle); |
| 70 |
} |
| 71 |
|
| 72 |
gpointer |
| 73 |
gdk_win32_handle_table_lookup (HWND handle) |
| 74 |
{ |
| 75 |
gpointer data = NULL; |
| 76 |
|
| 77 |
if (handle_ht) |
| 78 |
data = g_hash_table_lookup (handle_ht, &handle); |
| 79 |
|
| 80 |
return data; |
| 81 |
} |