gtk2/gdk/win32/gdkmain-win32.c
Owen Taylor e5ae081ebe Start implementing display/screen closing scheme; keep a flag for whether
Thu Aug  1 11:26:03 2002  Owen Taylor  <otaylor@redhat.com>

	* gdk/gdkdisplay.[ch] gdk/gdkscreen.[ch] gdkinternals.h:
	Start implementing display/screen closing scheme; keep a
	flag for whether displays and screens are closed,
	call g_object_run_dispose(). Remove public gdk_screen_close().

	* gdk/x11/gdkdisplay-x11.c gdk/x11/gdkscreen-x11.c: Add
	dispose() methods; move appropriate parts of the finalize
	there.

	* gdk/x11/gdkcolor-x11.c gdk/x11/gdkimage-x11.c
	gdk/x11/gdkmain-x11.c gdk/x11/gdkpango-x11.c
	gdk/x11/gdkpixmap-x11.c gdk/x11/gdkproperty-x11.c
	gdk/x11/gdkselection-x11.c gdk/x11/gdkwindow-x11.c:
	Start of making everything correctly ignore operations
	when a display has been closed.

	* gdk/x11/gdkwindow-x11.c (gdk_window_get_decorations):
	Handle decorations == NULL.

	* gdk/x11/gdkcolor-x11.c (gdk_colormap_remove):
	Remove unnecessary hash table creation.

	* gdk/x11/gdkinput.c gdk/x11/gdkinput-x11.c gdk/win32/gdkinput.c
	Fix up gdk_device_get_history - handle events, n_events == NULL,
	etc.

	* gdk/x11/gdkproperty-x11.c (gdk_property_get):
	Handle failure better.

	* gdk/x11/gdkselection-x11.c (gdk_selection_property_get):
	Handle failure better, handle data == NULL, move docs
	here, remove an excess round trip by asking for
	all selection data at once.

	* gdk/gdkselection.c gdk/win32/{x11,win32}/gdkselection-{x11,win32}.c
	  gdk/{x11,win32}/gdkmain-{x11,win32}.c	gdk/gdkdisplay.c: Move
	gdk_text_property_to_text_list(), gdk_string_to_compound_text(),
	gdk_display_set_sm_client_id() to display-independent part of GDK.

	* gdk/Makefile.am (gdk_c_sources): Sort gdkdisplay/screen.[ch]
	into the right place.
2002-08-01 15:28:40 +00:00

215 lines
5.4 KiB
C

/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
* Copyright (C) 1998-2002 Tor Lillqvist
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <io.h>
#include "gdk.h"
#include "gdkkeysyms.h"
#include "gdkinternals.h"
#include "gdkprivate-win32.h"
#include "gdkinput-win32.h"
#include <objbase.h>
static gboolean gdk_synchronize = FALSE;
GdkArgDesc _gdk_windowing_args[] = {
{ "sync", GDK_ARG_BOOL, &gdk_synchronize, (GdkArgFunc) NULL},
{ "no-wintab", GDK_ARG_BOOL, &gdk_input_ignore_wintab,
(GdkArgFunc) NULL},
{ "ignore-wintab", GDK_ARG_BOOL, &gdk_input_ignore_wintab,
(GdkArgFunc) NULL},
{ "event-func-from-window-proc",
GDK_ARG_BOOL, &gdk_event_func_from_window_proc,
(GdkArgFunc) NULL},
{ "max-colors", GDK_ARG_INT, &gdk_max_colors, (GdkArgFunc) NULL},
{ NULL }
};
int __stdcall
DllMain(HINSTANCE hinstDLL,
DWORD dwReason,
LPVOID reserved)
{
gdk_dll_hinstance = hinstDLL;
return TRUE;
}
void
_gdk_windowing_init (gint *argc,
gchar ***argv)
{
gchar buf[10];
#ifdef HAVE_WINTAB
if (getenv ("GDK_IGNORE_WINTAB") != NULL)
gdk_input_ignore_wintab = TRUE;
#endif
if (getenv ("GDK_EVENT_FUNC_FROM_WINDOW_PROC") != NULL)
gdk_event_func_from_window_proc = TRUE;
if (gdk_synchronize)
GdiSetBatchLimit (1);
gdk_app_hmodule = GetModuleHandle (NULL);
gdk_display_hdc = CreateDC ("DISPLAY", NULL, NULL, NULL);
gdk_root_window = GetDesktopWindow ();
windows_version = GetVersion ();
_gdk_input_locale = GetKeyboardLayout (0);
GetLocaleInfo (MAKELCID (LOWORD (_gdk_input_locale), SORT_DEFAULT),
LOCALE_IDEFAULTANSICODEPAGE,
buf, sizeof (buf));
_gdk_input_codepage = atoi (buf);
GDK_NOTE (MISC, g_print ("input_locale: %#lx, codepage:%d\n",
_gdk_input_locale, _gdk_input_codepage));
CoInitialize (NULL);
cf_rtf = RegisterClipboardFormat ("Rich Text Format");
cf_utf8_string = RegisterClipboardFormat ("UTF8_STRING");
utf8_string = gdk_atom_intern ("UTF8_STRING", FALSE);
compound_text = gdk_atom_intern ("COMPOUND_TEXT", FALSE);
text_uri_list = gdk_atom_intern ("text/uri-list", FALSE);
local_dnd = gdk_atom_intern ("LocalDndSelection", FALSE);
gdk_win32_dropfiles = gdk_atom_intern ("DROPFILES_DND", FALSE);
gdk_ole2_dnd = gdk_atom_intern ("OLE2_DND", FALSE);
_gdk_selection_property = gdk_atom_intern ("GDK_SELECTION", FALSE);
_gdk_win32_selection_init ();
}
void
gdk_win32_api_failed (const gchar *where,
gint line,
const gchar *api)
{
gchar *msg = g_win32_error_message (GetLastError ());
g_warning ("%s:%d: %s failed: %s", where, line, api, msg);
g_free (msg);
}
void
gdk_other_api_failed (const gchar *where,
gint line,
const gchar *api)
{
g_warning ("%s:%d: %s failed", where, line, api);
}
void
gdk_win32_gdi_failed (const gchar *where,
gint line,
const gchar *api)
{
/* On Win9x GDI calls are implemented in 16-bit code and thus
* don't set the 32-bit error code, sigh.
*/
if (IS_WIN_NT ())
gdk_win32_api_failed (where, line, api);
else
gdk_other_api_failed (where, line, api);
}
void
gdk_set_use_xshm (gboolean use_xshm)
{
/* Always on */
}
gboolean
gdk_get_use_xshm (void)
{
return TRUE;
}
gint
gdk_screen_get_width (GdkScreen *screen)
{
return GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (_gdk_parent_root)->impl)->width;
}
gint
gdk_screen_get_height (GdkScreen *screen)
{
return GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (_gdk_parent_root)->impl)->height;
}
gint
gdk_screen_get_width_mm (GdkScreen *screen)
{
return (double) GetDeviceCaps (gdk_display_hdc, HORZRES) / GetDeviceCaps (gdk_display_hdc, LOGPIXELSX) * 25.4;
}
gint
gdk_screen_get_height_mm (GdkScreen *screen)
{
return (double) GetDeviceCaps (gdk_display_hdc, VERTRES) / GetDeviceCaps (gdk_display_hdc, LOGPIXELSY) * 25.4;
}
void
gdk_display_set_sm_client_id (const gchar* sm_client_id)
{
g_warning("gdk_set_sm_client_id %s", sm_client_id ? sm_client_id : "NULL");
}
void
gdk_display_beep (GdkDisplay *display)
{
g_return_if_fail (display == gdk_display_get_default());
Beep(1000, 50);
}
void
_gdk_windowing_exit (void)
{
_gdk_win32_dnd_exit ();
CoUninitialize ();
DeleteDC (gdk_display_hdc);
gdk_display_hdc = NULL;
}
void
gdk_error_trap_push (void)
{
}
gint
gdk_error_trap_pop (void)
{
return 0;
}