1999-11-11 22:12:27 +00:00
|
|
|
/* GDK - The GIMP Drawing Kit
|
|
|
|
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
2000-07-26 11:33:08 +00:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
1999-11-11 22:12:27 +00:00
|
|
|
* 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
|
2000-07-26 11:33:08 +00:00
|
|
|
* Lesser General Public License for more details.
|
1999-11-11 22:12:27 +00:00
|
|
|
*
|
2000-07-26 11:33:08 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
1999-11-11 22:12:27 +00:00
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2000-07-26 11:33:08 +00:00
|
|
|
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
|
1999-11-11 22:12:27 +00:00
|
|
|
* 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 <string.h>
|
|
|
|
|
|
|
|
#include "gdkproperty.h"
|
|
|
|
#include "gdkselection.h"
|
Large changes to the Win32 backend, partially made necessary by the
2000-05-02 Tor Lillqvist <tml@iki.fi>
Large changes to the Win32 backend, partially made necessary by
the changes to the backend-independent internal
structures. Attempts to implement similar backing store stuff as
on X11. The current (CVS) version of the Win32 backend is *not* as
stable as it was before the no-flicker branch was merged. A
zipfile with that version is available from
http://www.gimp.org/win32/. That should be use by "production"
code until this CVS version is usable. (But note, the Win32
backend has never been claimed to be "production quality".)
* README.win32: Add the above comment about versions.
* gdk/gdkwindow.c: Don't use backing store for now on Win32.
* gdk/gdk.def: Update.
* gdk/gdkfont.h: Declare temporary Win32-only functions. Will
presumably be replaced by some more better mechanism as 1.4 gets
closer to release shape.
* gdk/makefile.{cygwin,msc}: Update.
* gdk/win32/*.c: Correct inclusions of the backend-specific and
internal headers. Change code according to changes in these. Use
gdk_drawable_*, not gdk_window_* where necessary.
* gdk/win32/gdkdnd-win32.c: Use MISC selector for GDK_NOTE, not
our old DND.
* gdk/win32/gdkdrawable-win32.c (gdk_win32_draw_text): Don't try
to interpret single characters as UTF-8. Thanks to Hans Breuer.
Use correct function name in warning messages.
* gdk/win32/gdkevents-win32.c: Use correct parameter lists for the
GSourceFuncs gdk_event_prepare and gdk_event_check.
(gdk_event_get_graphics_expose): Do implement, use
PeekMessage. Thanks to Hans Breuer.
(event_mask_string): Debugging function to print an GdkEventMask.
(gdk_pointer_grab): Use it.
* gdk/win32/gdkfont-win32.c: The Unicode subrange that the
(old) book I used claimed was Hangul actually is CJK Unified
Ideographs Extension A. Also, Hangul Syllables were missing.
Improve logging.
* gdk/win32/gdkgc-win32.c: Largish changes.
* gdk/win32/gdkim-win32.c (gdk_set_locale): Use
g_win32_getlocale() from GLib, and not setlocale() to get current
locale name.
* gdk/win32/gdkprivate-win32.h
* gdk/win32/gdkwin32.h: Move stuff from gdkprivate-win32.h to
gdkwin32.h, similarily as in the X11 backend.
* gdk/win32/gdkwindow-win32.c (gdk_propagate_shapes): Bugfix,
assignment was used instead of equals in if test. Thanks to Hans
Breuer.
* gdk/win32/makefile.{cygwin,msc}
* gtk/makefile.{cygwin,msc}: Updates. Better kludge to get the
path to the Win32 headers that works also with the mingw compiler.
* gtk/gtkstyle.c: Include <string.h>.
2000-05-01 22:06:49 +00:00
|
|
|
#include "gdkinternals.h"
|
|
|
|
#include "gdkprivate-win32.h"
|
2000-07-25 17:31:05 +00:00
|
|
|
#include "gdkdrawable-win32.h"
|
|
|
|
#include "gdkwindow-win32.h"
|
1999-11-11 22:12:27 +00:00
|
|
|
|
|
|
|
GdkAtom
|
|
|
|
gdk_atom_intern (const gchar *atom_name,
|
|
|
|
gint only_if_exists)
|
|
|
|
{
|
|
|
|
GdkAtom retval;
|
|
|
|
static GHashTable *atom_hash = NULL;
|
|
|
|
|
|
|
|
if (!atom_hash)
|
|
|
|
atom_hash = g_hash_table_new (g_str_hash, g_str_equal);
|
|
|
|
|
|
|
|
retval = GPOINTER_TO_UINT (g_hash_table_lookup (atom_hash, atom_name));
|
|
|
|
if (!retval)
|
|
|
|
{
|
|
|
|
if (strcmp (atom_name, "PRIMARY") == 0)
|
|
|
|
retval = GDK_SELECTION_PRIMARY;
|
|
|
|
else if (strcmp (atom_name, "SECONDARY") == 0)
|
|
|
|
retval = GDK_SELECTION_SECONDARY;
|
|
|
|
else if (strcmp (atom_name, "ATOM") == 0)
|
|
|
|
retval = GDK_SELECTION_TYPE_ATOM;
|
|
|
|
else if (strcmp (atom_name, "BITMAP") == 0)
|
|
|
|
retval = GDK_SELECTION_TYPE_BITMAP;
|
|
|
|
else if (strcmp (atom_name, "COLORMAP") == 0)
|
|
|
|
retval = GDK_SELECTION_TYPE_COLORMAP;
|
|
|
|
else if (strcmp (atom_name, "DRAWABLE") == 0)
|
|
|
|
retval = GDK_SELECTION_TYPE_DRAWABLE;
|
|
|
|
else if (strcmp (atom_name, "INTEGER") == 0)
|
|
|
|
retval = GDK_SELECTION_TYPE_INTEGER;
|
|
|
|
else if (strcmp (atom_name, "PIXMAP") == 0)
|
|
|
|
retval = GDK_SELECTION_TYPE_PIXMAP;
|
|
|
|
else if (strcmp (atom_name, "WINDOW") == 0)
|
|
|
|
retval = GDK_SELECTION_TYPE_WINDOW;
|
|
|
|
else if (strcmp (atom_name, "STRING") == 0)
|
|
|
|
retval = GDK_SELECTION_TYPE_STRING;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
retval = GlobalFindAtom (atom_name);
|
|
|
|
if (only_if_exists && retval == 0)
|
|
|
|
retval = 0;
|
|
|
|
else
|
|
|
|
retval = GlobalAddAtom (atom_name);
|
|
|
|
}
|
|
|
|
g_hash_table_insert (atom_hash,
|
|
|
|
g_strdup (atom_name),
|
|
|
|
GUINT_TO_POINTER (retval));
|
|
|
|
}
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
gchar *
|
|
|
|
gdk_atom_name (GdkAtom atom)
|
|
|
|
{
|
|
|
|
gchar name[256];
|
|
|
|
|
|
|
|
switch (atom)
|
|
|
|
{
|
|
|
|
case GDK_SELECTION_PRIMARY: return g_strdup ("PRIMARY");
|
|
|
|
case GDK_SELECTION_SECONDARY: return g_strdup ("SECONDARY");
|
|
|
|
case GDK_SELECTION_TYPE_ATOM: return g_strdup ("ATOM");
|
|
|
|
case GDK_SELECTION_TYPE_BITMAP: return g_strdup ("BITMAP");
|
|
|
|
case GDK_SELECTION_TYPE_COLORMAP: return g_strdup ("COLORMAP");
|
|
|
|
case GDK_SELECTION_TYPE_DRAWABLE: return g_strdup ("DRAWABLE");
|
|
|
|
case GDK_SELECTION_TYPE_INTEGER: return g_strdup ("INTEGER");
|
|
|
|
case GDK_SELECTION_TYPE_PIXMAP: return g_strdup ("PIXMAP");
|
|
|
|
case GDK_SELECTION_TYPE_WINDOW: return g_strdup ("WINDOW");
|
|
|
|
case GDK_SELECTION_TYPE_STRING: return g_strdup ("STRING");
|
|
|
|
}
|
|
|
|
if (atom < 0xC000)
|
2000-10-25 18:07:12 +00:00
|
|
|
return g_strdup_printf ("#%x", (guint) atom);
|
1999-11-11 22:12:27 +00:00
|
|
|
else if (GlobalGetAtomName (atom, name, sizeof (name)) == 0)
|
|
|
|
return NULL;
|
|
|
|
return g_strdup (name);
|
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
|
|
|
gdk_property_get (GdkWindow *window,
|
|
|
|
GdkAtom property,
|
|
|
|
GdkAtom type,
|
|
|
|
gulong offset,
|
|
|
|
gulong length,
|
|
|
|
gint pdelete,
|
|
|
|
GdkAtom *actual_property_type,
|
|
|
|
gint *actual_format_type,
|
|
|
|
gint *actual_length,
|
|
|
|
guchar **data)
|
|
|
|
{
|
1999-11-20 01:22:57 +00:00
|
|
|
g_return_val_if_fail (window != NULL, FALSE);
|
2000-02-09 22:31:34 +00:00
|
|
|
g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE);
|
1999-11-20 01:22:57 +00:00
|
|
|
|
2000-07-25 17:31:05 +00:00
|
|
|
if (GDK_WINDOW_DESTROYED (window))
|
1999-11-20 01:22:57 +00:00
|
|
|
return FALSE;
|
|
|
|
|
1999-11-11 22:12:27 +00:00
|
|
|
g_warning ("gdk_property_get: Not implemented");
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2000-03-16 21:58:35 +00:00
|
|
|
gdk_property_change (GdkWindow *window,
|
|
|
|
GdkAtom property,
|
|
|
|
GdkAtom type,
|
|
|
|
gint format,
|
|
|
|
GdkPropMode mode,
|
|
|
|
const guchar *data,
|
|
|
|
gint nelements)
|
1999-11-11 22:12:27 +00:00
|
|
|
{
|
|
|
|
HGLOBAL hdata;
|
|
|
|
gint i, length;
|
|
|
|
gchar *prop_name, *type_name;
|
|
|
|
guchar *ptr;
|
|
|
|
|
1999-11-20 01:22:57 +00:00
|
|
|
g_return_if_fail (window != NULL);
|
2000-02-09 22:31:34 +00:00
|
|
|
g_return_if_fail (GDK_IS_WINDOW (window));
|
1999-11-20 01:22:57 +00:00
|
|
|
|
2000-07-25 17:31:05 +00:00
|
|
|
if (GDK_WINDOW_DESTROYED (window))
|
1999-11-11 22:12:27 +00:00
|
|
|
return;
|
|
|
|
|
1999-11-20 01:22:57 +00:00
|
|
|
GDK_NOTE (MISC,
|
1999-11-11 22:12:27 +00:00
|
|
|
(prop_name = gdk_atom_name (property),
|
|
|
|
type_name = gdk_atom_name (type),
|
|
|
|
g_print ("gdk_property_change: %#x %#x (%s) %#x (%s) %s %d*%d bytes %.10s\n",
|
2000-10-25 18:07:12 +00:00
|
|
|
(guint) GDK_WINDOW_HWND (window),
|
|
|
|
(guint) property, prop_name,
|
|
|
|
(guint) type, type_name,
|
1999-11-11 22:12:27 +00:00
|
|
|
(mode == GDK_PROP_MODE_REPLACE ? "REPLACE" :
|
|
|
|
(mode == GDK_PROP_MODE_PREPEND ? "PREPEND" :
|
|
|
|
(mode == GDK_PROP_MODE_APPEND ? "APPEND" :
|
|
|
|
"???"))),
|
|
|
|
format, nelements, data),
|
|
|
|
g_free (prop_name),
|
|
|
|
g_free (type_name)));
|
|
|
|
|
|
|
|
if (property == gdk_selection_property
|
|
|
|
&& type == GDK_TARGET_STRING
|
|
|
|
&& format == 8
|
|
|
|
&& mode == GDK_PROP_MODE_REPLACE)
|
|
|
|
{
|
|
|
|
length = nelements;
|
|
|
|
for (i = 0; i < nelements; i++)
|
2000-03-16 21:58:35 +00:00
|
|
|
if (data[i] == '\n')
|
1999-11-11 22:12:27 +00:00
|
|
|
length++;
|
|
|
|
#if 1
|
1999-11-20 01:22:57 +00:00
|
|
|
GDK_NOTE (MISC, g_print ("...OpenClipboard(%#x)\n",
|
2000-10-25 18:07:12 +00:00
|
|
|
(guint) GDK_WINDOW_HWND (window)));
|
2000-07-25 17:31:05 +00:00
|
|
|
if (!OpenClipboard (GDK_WINDOW_HWND (window)))
|
1999-11-11 22:12:27 +00:00
|
|
|
{
|
2000-02-13 14:52:47 +00:00
|
|
|
WIN32_API_FAILED ("OpenClipboard");
|
1999-11-11 22:12:27 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
hdata = GlobalAlloc (GMEM_MOVEABLE|GMEM_DDESHARE, length + 1);
|
|
|
|
ptr = GlobalLock (hdata);
|
2000-10-25 18:07:12 +00:00
|
|
|
GDK_NOTE (MISC, g_print ("...hdata=%#x, ptr=%p\n", (guint) hdata, ptr));
|
1999-11-11 22:12:27 +00:00
|
|
|
|
|
|
|
for (i = 0; i < nelements; i++)
|
|
|
|
{
|
|
|
|
if (*data == '\n')
|
|
|
|
*ptr++ = '\r';
|
|
|
|
*ptr++ = *data++;
|
|
|
|
}
|
|
|
|
*ptr++ = '\0';
|
|
|
|
GlobalUnlock (hdata);
|
1999-11-20 01:22:57 +00:00
|
|
|
GDK_NOTE (MISC, g_print ("...SetClipboardData(CF_TEXT, %#x)\n",
|
2000-10-25 18:07:12 +00:00
|
|
|
(guint) hdata));
|
1999-11-11 22:12:27 +00:00
|
|
|
if (!SetClipboardData(CF_TEXT, hdata))
|
2000-02-13 14:52:47 +00:00
|
|
|
WIN32_API_FAILED ("SetClipboardData");
|
1999-11-11 22:12:27 +00:00
|
|
|
#if 1
|
1999-11-20 01:22:57 +00:00
|
|
|
GDK_NOTE (MISC, g_print ("...CloseClipboard()\n"));
|
1999-11-11 22:12:27 +00:00
|
|
|
if (!CloseClipboard ())
|
2000-02-13 14:52:47 +00:00
|
|
|
WIN32_API_FAILED ("CloseClipboard");
|
1999-11-11 22:12:27 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
else
|
|
|
|
g_warning ("gdk_property_change: General case not implemented");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gdk_property_delete (GdkWindow *window,
|
|
|
|
GdkAtom property)
|
|
|
|
{
|
2000-10-25 18:07:12 +00:00
|
|
|
gchar *prop_name;
|
1999-11-11 22:12:27 +00:00
|
|
|
extern void gdk_selection_property_delete (GdkWindow *);
|
|
|
|
|
1999-11-20 01:22:57 +00:00
|
|
|
g_return_if_fail (window != NULL);
|
2000-02-09 22:31:34 +00:00
|
|
|
g_return_if_fail (GDK_IS_WINDOW (window));
|
1999-11-11 22:12:27 +00:00
|
|
|
|
1999-11-20 01:22:57 +00:00
|
|
|
GDK_NOTE (MISC,
|
1999-11-11 22:12:27 +00:00
|
|
|
(prop_name = gdk_atom_name (property),
|
|
|
|
g_print ("gdk_property_delete: %#x %#x (%s)\n",
|
2000-10-25 18:07:12 +00:00
|
|
|
(window ? (guint) GDK_WINDOW_HWND (window) : 0),
|
|
|
|
(guint) property, prop_name),
|
1999-11-11 22:12:27 +00:00
|
|
|
g_free (prop_name)));
|
|
|
|
|
|
|
|
if (property == gdk_selection_property)
|
|
|
|
gdk_selection_property_delete (window);
|
|
|
|
else
|
|
|
|
g_warning ("gdk_property_delete: General case not implemented");
|
|
|
|
}
|