1 /* GDK - The GIMP Drawing Kit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3 * Copyright (C) 1998-2002 Tor Lillqvist
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
22 * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
23 * file for a list of people on the GTK+ Team. See the ChangeLog
24 * files for a list of changes. These files are distributed with
25 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
37 #include "gdkkeysyms.h"
38 #include "gdkinternals.h"
39 #include "gdkprivate-win32.h"
40 #include "gdkinput-win32.h"
44 static gboolean gdk_synchronize = FALSE;
46 GdkArgDesc _gdk_windowing_args[] = {
47 { "sync", GDK_ARG_BOOL, &gdk_synchronize, (GdkArgFunc) NULL},
48 { "no-wintab", GDK_ARG_BOOL, &gdk_input_ignore_wintab,
50 { "ignore-wintab", GDK_ARG_BOOL, &gdk_input_ignore_wintab,
52 { "event-func-from-window-proc",
53 GDK_ARG_BOOL, &gdk_event_func_from_window_proc,
55 { "max-colors", GDK_ARG_INT, &gdk_max_colors, (GdkArgFunc) NULL},
60 DllMain(HINSTANCE hinstDLL,
64 gdk_dll_hinstance = hinstDLL;
70 _gdk_windowing_init (gint *argc,
76 if (getenv ("GDK_IGNORE_WINTAB") != NULL)
77 gdk_input_ignore_wintab = TRUE;
79 if (getenv ("GDK_EVENT_FUNC_FROM_WINDOW_PROC") != NULL)
80 gdk_event_func_from_window_proc = TRUE;
85 gdk_app_hmodule = GetModuleHandle (NULL);
86 gdk_display_hdc = CreateDC ("DISPLAY", NULL, NULL, NULL);
87 gdk_root_window = GetDesktopWindow ();
88 windows_version = GetVersion ();
90 _gdk_input_locale = GetKeyboardLayout (0);
91 GetLocaleInfo (MAKELCID (LOWORD (_gdk_input_locale), SORT_DEFAULT),
92 LOCALE_IDEFAULTANSICODEPAGE,
94 _gdk_input_codepage = atoi (buf);
95 GDK_NOTE (MISC, g_print ("input_locale: %#lx, codepage:%d\n",
96 _gdk_input_locale, _gdk_input_codepage));
100 cf_rtf = RegisterClipboardFormat ("Rich Text Format");
101 cf_utf8_string = RegisterClipboardFormat ("UTF8_STRING");
103 utf8_string = gdk_atom_intern ("UTF8_STRING", FALSE);
104 compound_text = gdk_atom_intern ("COMPOUND_TEXT", FALSE);
105 text_uri_list = gdk_atom_intern ("text/uri-list", FALSE);
107 local_dnd = gdk_atom_intern ("LocalDndSelection", FALSE);
108 gdk_win32_dropfiles = gdk_atom_intern ("DROPFILES_DND", FALSE);
109 gdk_ole2_dnd = gdk_atom_intern ("OLE2_DND", FALSE);
111 _gdk_selection_property = gdk_atom_intern ("GDK_SELECTION", FALSE);
113 _gdk_win32_selection_init ();
117 gdk_win32_api_failed (const gchar *where,
121 gchar *msg = g_win32_error_message (GetLastError ());
122 g_warning ("%s:%d: %s failed: %s", where, line, api, msg);
127 gdk_other_api_failed (const gchar *where,
131 g_warning ("%s:%d: %s failed", where, line, api);
135 gdk_win32_gdi_failed (const gchar *where,
139 /* On Win9x GDI calls are implemented in 16-bit code and thus
140 * don't set the 32-bit error code, sigh.
143 gdk_win32_api_failed (where, line, api);
145 gdk_other_api_failed (where, line, api);
149 gdk_set_use_xshm (gboolean use_xshm)
155 gdk_get_use_xshm (void)
161 gdk_screen_get_width (GdkScreen *screen)
163 return GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (_gdk_parent_root)->impl)->width;
167 gdk_screen_get_height (GdkScreen *screen)
169 return GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (_gdk_parent_root)->impl)->height;
172 gdk_screen_get_width_mm (GdkScreen *screen)
174 return (double) GetDeviceCaps (gdk_display_hdc, HORZRES) / GetDeviceCaps (gdk_display_hdc, LOGPIXELSX) * 25.4;
178 gdk_screen_get_height_mm (GdkScreen *screen)
180 return (double) GetDeviceCaps (gdk_display_hdc, VERTRES) / GetDeviceCaps (gdk_display_hdc, LOGPIXELSY) * 25.4;
184 gdk_set_sm_client_id (const gchar* sm_client_id)
186 g_warning("gdk_set_sm_client_id %s", sm_client_id ? sm_client_id : "NULL");
190 gdk_display_beep (GdkDisplay *display)
192 g_return_if_fail (display == gdk_display_get_default());
197 _gdk_windowing_exit (void)
199 _gdk_win32_dnd_exit ();
201 DeleteDC (gdk_display_hdc);
202 gdk_display_hdc = NULL;
206 gdk_error_trap_push (void)
211 gdk_error_trap_pop (void)