2000-05-31 21:50:38 +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
|
2000-05-31 21:50:38 +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.
|
2000-05-31 21:50:38 +00:00
|
|
|
*
|
2000-07-26 11:33:08 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2000-05-31 21:50:38 +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
|
2000-05-31 21:50:38 +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 <string.h>
|
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
#include "gdkfb.h"
|
|
|
|
#include "gdkproperty.h"
|
|
|
|
#include "gdkprivate.h"
|
|
|
|
#include "gdkprivate-fb.h"
|
|
|
|
|
|
|
|
GdkAtom
|
|
|
|
gdk_atom_intern (const gchar *atom_name,
|
|
|
|
gboolean only_if_exists)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (atom_name != NULL, GDK_NONE);
|
|
|
|
|
Fix problem with g_return_if_fail return value.
Sun Oct 21 23:27:00 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_translate_coordinates): Fix
problem with g_return_if_fail return value.
* gdk/x11/gdkproperty-x11.c docs/Changes-2.0.txt: Move over the
virtual atom code from the gdk-multihead branch, removing the per-display
part. Virtualizing atoms needs to be done now to prevent compat
breakage in direct Xlib accessing code in the future. (#62208)
* gdk/x11/gdkx.h: gdk/gdk/x11/gdkproperty-x11.c: Export
gdk_x11_xatom_to_atom, gdk_x11_atom_to_xatom().
* gdk/gdktypes.h docs/Changes-2.0.txt: Make GdkAtom
an opaque pointer type so the compiler catches attempts
to mingle it with X atoms.
* gdk/x11/{gdkdnd-x11.c,gdkevents-x11.c,gdkglobals-x11.c,
gdkkeys-x11.c, gdkmain-x11.c, gdkprivate-x11.c,
gdkproperty-x11.c, gdkselection-x11.c, gdkwindow-x11.c}
gtk/{gtkclist.c,gtkctree.c,gtkdnd.c,gtkplug.c,gtksocket.c}
tests/testdnd.c,tests/testselection.c:
Fix up for above atom changes.
* gdk/gdkselection.h (GDK_SELECTION_CLIPBOARD): Add, since we
now have the ability to add custom predefines.
* gtk/{gtkentry.c,gtklabel.c,gtkoldeditable.c,gtktextview.c}:
Use GDK_SELECTION_CLIPBOARD instead of GDK_NONE in calls
to gtk_clipboard_get().
* gdk/win32/gdkproperty-win32.c: Add CLIPBOARD, fix up
for GdkAtom => pointer change.
* gdk/linux-fb/gdkproperty-fb.c: Fix handling of predefined
atoms, fix for GdkAtom => pointer change.
2001-10-22 04:34:42 +00:00
|
|
|
if (strcmp (atom_name, "PRIMARY") == 0)
|
|
|
|
return GDK_SELECTION_PRIMARY;
|
|
|
|
else if (strcmp (atom_name, "SECONDARY") == 0)
|
|
|
|
return GDK_SELECTION_SECONDARY;
|
|
|
|
else if (strcmp (atom_name, "CLIPBOARD") == 0)
|
|
|
|
return GDK_SELECTION_CLIPBOARD;
|
|
|
|
else if (strcmp (atom_name, "ATOM") == 0)
|
|
|
|
return GDK_SELECTION_TYPE_ATOM;
|
|
|
|
else if (strcmp (atom_name, "BITMAP") == 0)
|
|
|
|
return GDK_SELECTION_TYPE_BITMAP;
|
|
|
|
else if (strcmp (atom_name, "COLORMAP") == 0)
|
|
|
|
return GDK_SELECTION_TYPE_COLORMAP;
|
|
|
|
else if (strcmp (atom_name, "DRAWABLE") == 0)
|
|
|
|
return GDK_SELECTION_TYPE_DRAWABLE;
|
|
|
|
else if (strcmp (atom_name, "INTEGER") == 0)
|
|
|
|
return GDK_SELECTION_TYPE_INTEGER;
|
|
|
|
else if (strcmp (atom_name, "PIXMAP") == 0)
|
|
|
|
return GDK_SELECTION_TYPE_PIXMAP;
|
|
|
|
else if (strcmp (atom_name, "WINDOW") == 0)
|
|
|
|
return GDK_SELECTION_TYPE_WINDOW;
|
|
|
|
else if (strcmp (atom_name, "STRING") == 0)
|
|
|
|
return GDK_SELECTION_TYPE_STRING;
|
|
|
|
else
|
|
|
|
return GUINT_TO_POINTER (256 + g_quark_from_string (atom_name));
|
2000-05-31 21:50:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gchar*
|
|
|
|
gdk_atom_name (GdkAtom atom)
|
|
|
|
{
|
2001-10-24 23:41:12 +00:00
|
|
|
if (GPOINTER_TO_UINT (atom) < 256)
|
Fix problem with g_return_if_fail return value.
Sun Oct 21 23:27:00 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_translate_coordinates): Fix
problem with g_return_if_fail return value.
* gdk/x11/gdkproperty-x11.c docs/Changes-2.0.txt: Move over the
virtual atom code from the gdk-multihead branch, removing the per-display
part. Virtualizing atoms needs to be done now to prevent compat
breakage in direct Xlib accessing code in the future. (#62208)
* gdk/x11/gdkx.h: gdk/gdk/x11/gdkproperty-x11.c: Export
gdk_x11_xatom_to_atom, gdk_x11_atom_to_xatom().
* gdk/gdktypes.h docs/Changes-2.0.txt: Make GdkAtom
an opaque pointer type so the compiler catches attempts
to mingle it with X atoms.
* gdk/x11/{gdkdnd-x11.c,gdkevents-x11.c,gdkglobals-x11.c,
gdkkeys-x11.c, gdkmain-x11.c, gdkprivate-x11.c,
gdkproperty-x11.c, gdkselection-x11.c, gdkwindow-x11.c}
gtk/{gtkclist.c,gtkctree.c,gtkdnd.c,gtkplug.c,gtksocket.c}
tests/testdnd.c,tests/testselection.c:
Fix up for above atom changes.
* gdk/gdkselection.h (GDK_SELECTION_CLIPBOARD): Add, since we
now have the ability to add custom predefines.
* gtk/{gtkentry.c,gtklabel.c,gtkoldeditable.c,gtktextview.c}:
Use GDK_SELECTION_CLIPBOARD instead of GDK_NONE in calls
to gtk_clipboard_get().
* gdk/win32/gdkproperty-win32.c: Add CLIPBOARD, fix up
for GdkAtom => pointer change.
* gdk/linux-fb/gdkproperty-fb.c: Fix handling of predefined
atoms, fix for GdkAtom => pointer change.
2001-10-22 04:34:42 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
switch (GPOINTER_TO_UINT (atom))
|
|
|
|
{
|
2002-01-19 17:54:11 +00:00
|
|
|
case GPOINTER_TO_UINT (GDK_SELECTION_PRIMARY):
|
|
|
|
return g_strdup ("PRIMARY");
|
|
|
|
case GPOINTER_TO_UINT (GDK_SELECTION_SECONDARY):
|
|
|
|
return g_strdup ("SECONDARY");
|
|
|
|
case GPOINTER_TO_UINT (GDK_SELECTION_CLIPBOARD):
|
|
|
|
return g_strdup ("CLIPBOARD");
|
|
|
|
case GPOINTER_TO_UINT (GDK_SELECTION_TYPE_ATOM):
|
|
|
|
return g_strdup ("ATOM");
|
|
|
|
case GPOINTER_TO_UINT (GDK_SELECTION_TYPE_BITMAP):
|
|
|
|
return g_strdup ("BITMAP");
|
|
|
|
case GPOINTER_TO_UINT (GDK_SELECTION_TYPE_COLORMAP):
|
|
|
|
return g_strdup ("COLORMAP");
|
|
|
|
case GPOINTER_TO_UINT (GDK_SELECTION_TYPE_DRAWABLE):
|
|
|
|
return g_strdup ("DRAWABLE");
|
|
|
|
case GPOINTER_TO_UINT (GDK_SELECTION_TYPE_INTEGER):
|
|
|
|
return g_strdup ("INTEGER");
|
|
|
|
case GPOINTER_TO_UINT (GDK_SELECTION_TYPE_PIXMAP):
|
|
|
|
return g_strdup ("PIXMAP");
|
|
|
|
case GPOINTER_TO_UINT (GDK_SELECTION_TYPE_WINDOW):
|
|
|
|
return g_strdup ("WINDOW");
|
|
|
|
case GPOINTER_TO_UINT (GDK_SELECTION_TYPE_STRING):
|
|
|
|
return g_strdup ("STRING");
|
Fix problem with g_return_if_fail return value.
Sun Oct 21 23:27:00 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_translate_coordinates): Fix
problem with g_return_if_fail return value.
* gdk/x11/gdkproperty-x11.c docs/Changes-2.0.txt: Move over the
virtual atom code from the gdk-multihead branch, removing the per-display
part. Virtualizing atoms needs to be done now to prevent compat
breakage in direct Xlib accessing code in the future. (#62208)
* gdk/x11/gdkx.h: gdk/gdk/x11/gdkproperty-x11.c: Export
gdk_x11_xatom_to_atom, gdk_x11_atom_to_xatom().
* gdk/gdktypes.h docs/Changes-2.0.txt: Make GdkAtom
an opaque pointer type so the compiler catches attempts
to mingle it with X atoms.
* gdk/x11/{gdkdnd-x11.c,gdkevents-x11.c,gdkglobals-x11.c,
gdkkeys-x11.c, gdkmain-x11.c, gdkprivate-x11.c,
gdkproperty-x11.c, gdkselection-x11.c, gdkwindow-x11.c}
gtk/{gtkclist.c,gtkctree.c,gtkdnd.c,gtkplug.c,gtksocket.c}
tests/testdnd.c,tests/testselection.c:
Fix up for above atom changes.
* gdk/gdkselection.h (GDK_SELECTION_CLIPBOARD): Add, since we
now have the ability to add custom predefines.
* gtk/{gtkentry.c,gtklabel.c,gtkoldeditable.c,gtktextview.c}:
Use GDK_SELECTION_CLIPBOARD instead of GDK_NONE in calls
to gtk_clipboard_get().
* gdk/win32/gdkproperty-win32.c: Add CLIPBOARD, fix up
for GdkAtom => pointer change.
* gdk/linux-fb/gdkproperty-fb.c: Fix handling of predefined
atoms, fix for GdkAtom => pointer change.
2001-10-22 04:34:42 +00:00
|
|
|
default:
|
|
|
|
g_warning (G_STRLOC "Invalid atom");
|
|
|
|
return g_strdup ("<invalid>");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2001-10-24 23:41:12 +00:00
|
|
|
return g_strdup (g_quark_to_string (GPOINTER_TO_UINT (atom) - 256));
|
2000-05-31 21:50:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_property_delete_2 (GdkWindow *window,
|
|
|
|
GdkAtom property,
|
|
|
|
GdkWindowProperty *prop)
|
|
|
|
{
|
2000-07-24 16:19:00 +00:00
|
|
|
GdkWindowFBData *fbd = GDK_WINDOW_IMPL_FBDATA(window);
|
2000-05-31 21:50:38 +00:00
|
|
|
GdkEvent *event;
|
2001-01-17 15:52:22 +00:00
|
|
|
GdkWindow *event_window;
|
2000-05-31 21:50:38 +00:00
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
g_hash_table_remove (fbd->properties, GUINT_TO_POINTER (property));
|
|
|
|
g_free (prop);
|
2000-05-31 21:50:38 +00:00
|
|
|
|
2001-01-17 15:52:22 +00:00
|
|
|
event_window = gdk_fb_other_event_window (window, GDK_PROPERTY_NOTIFY);
|
|
|
|
if (event_window)
|
2000-05-31 21:50:38 +00:00
|
|
|
{
|
2001-01-17 15:52:22 +00:00
|
|
|
event = gdk_event_make (event_window, GDK_PROPERTY_NOTIFY, TRUE);
|
2000-05-31 21:50:38 +00:00
|
|
|
event->property.atom = property;
|
|
|
|
event->property.state = GDK_PROPERTY_DELETE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gdk_property_delete (GdkWindow *window,
|
|
|
|
GdkAtom property)
|
|
|
|
{
|
2000-11-13 17:40:23 +00:00
|
|
|
GdkWindowFBData *fbd = GDK_WINDOW_FBDATA (window);
|
2000-05-31 21:50:38 +00:00
|
|
|
GdkWindowProperty *prop;
|
|
|
|
|
|
|
|
g_return_if_fail (window != NULL);
|
|
|
|
g_return_if_fail (GDK_IS_WINDOW (window));
|
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
if (!fbd->properties)
|
2000-05-31 21:50:38 +00:00
|
|
|
return;
|
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
prop = g_hash_table_lookup (fbd->properties, GUINT_TO_POINTER(property));
|
|
|
|
if (!prop)
|
2000-05-31 21:50:38 +00:00
|
|
|
return;
|
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
gdk_property_delete_2 (window, property, prop);
|
2000-05-31 21:50:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2000-11-13 17:40:23 +00:00
|
|
|
GdkWindowFBData *fbd = GDK_WINDOW_FBDATA (window);
|
2000-05-31 21:50:38 +00:00
|
|
|
GdkWindowProperty *prop;
|
|
|
|
int nbytes;
|
|
|
|
|
|
|
|
g_return_val_if_fail (window != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (data != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (actual_length != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE);
|
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
if (!fbd->properties)
|
2000-05-31 21:50:38 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
prop = g_hash_table_lookup (fbd->properties, GUINT_TO_POINTER (property));
|
|
|
|
if (!prop)
|
2000-05-31 21:50:38 +00:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
nbytes = (offset + length * (prop->format >> 3)) - prop->length;
|
2000-11-13 17:40:23 +00:00
|
|
|
nbytes = MAX (nbytes, 0);
|
|
|
|
if (nbytes > 0)
|
2000-05-31 21:50:38 +00:00
|
|
|
{
|
2000-11-13 17:40:23 +00:00
|
|
|
*data = g_malloc (nbytes+1);
|
|
|
|
memcpy (data, prop->data + offset, nbytes);
|
2000-05-31 21:50:38 +00:00
|
|
|
(*data)[nbytes] = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*data = NULL;
|
|
|
|
*actual_length = nbytes / (prop->format >> 3);
|
|
|
|
*actual_property_type = prop->type;
|
|
|
|
*actual_format_type = prop->format;
|
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
if (pdelete)
|
|
|
|
gdk_property_delete_2 (window, property, prop);
|
2000-05-31 21:50:38 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gdk_property_change (GdkWindow *window,
|
|
|
|
GdkAtom property,
|
|
|
|
GdkAtom type,
|
|
|
|
gint format,
|
|
|
|
GdkPropMode mode,
|
|
|
|
const guchar *data,
|
|
|
|
gint nelements)
|
|
|
|
{
|
2000-11-13 17:40:23 +00:00
|
|
|
GdkWindowFBData *fbd = GDK_WINDOW_FBDATA (window);
|
2000-05-31 21:50:38 +00:00
|
|
|
GdkWindowProperty *prop, *new_prop;
|
2000-08-07 03:26:05 +00:00
|
|
|
int new_size = 0;
|
2000-05-31 21:50:38 +00:00
|
|
|
GdkEvent *event;
|
2001-01-17 15:52:22 +00:00
|
|
|
GdkWindow *event_window;
|
2000-05-31 21:50:38 +00:00
|
|
|
|
|
|
|
g_return_if_fail (window != NULL);
|
|
|
|
g_return_if_fail (GDK_IS_WINDOW (window));
|
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
if (!fbd->properties)
|
|
|
|
fbd->properties = g_hash_table_new (NULL, NULL);
|
2000-05-31 21:50:38 +00:00
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
prop = g_hash_table_lookup (fbd->properties, GUINT_TO_POINTER (property));
|
2000-05-31 21:50:38 +00:00
|
|
|
|
|
|
|
switch(mode)
|
|
|
|
{
|
|
|
|
case GDK_PROP_MODE_REPLACE:
|
|
|
|
new_size = nelements * (format >> 3);
|
|
|
|
break;
|
|
|
|
case GDK_PROP_MODE_PREPEND:
|
|
|
|
case GDK_PROP_MODE_APPEND:
|
|
|
|
new_size = nelements * (format >> 3);
|
2000-11-13 17:40:23 +00:00
|
|
|
if (prop)
|
2000-05-31 21:50:38 +00:00
|
|
|
new_size += prop->length;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
new_prop = g_malloc (G_STRUCT_OFFSET (GdkWindowProperty, data) + new_size);
|
2000-05-31 21:50:38 +00:00
|
|
|
new_prop->length = new_size;
|
|
|
|
new_prop->type = type;
|
|
|
|
new_prop->format = format;
|
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
switch (mode)
|
2000-05-31 21:50:38 +00:00
|
|
|
{
|
|
|
|
case GDK_PROP_MODE_REPLACE:
|
2000-11-13 17:40:23 +00:00
|
|
|
memcpy (new_prop->data, data, new_size);
|
2000-05-31 21:50:38 +00:00
|
|
|
break;
|
|
|
|
case GDK_PROP_MODE_APPEND:
|
2000-11-13 17:40:23 +00:00
|
|
|
if (prop)
|
|
|
|
memcpy (new_prop->data, prop->data, prop->length);
|
|
|
|
memcpy (new_prop->data + prop->length, data, (nelements * (format >> 3)));
|
2000-05-31 21:50:38 +00:00
|
|
|
break;
|
|
|
|
case GDK_PROP_MODE_PREPEND:
|
2000-11-13 17:40:23 +00:00
|
|
|
memcpy (new_prop->data, data, (nelements * (format >> 3)));
|
|
|
|
if (prop)
|
|
|
|
memcpy (new_prop->data + (nelements * (format >> 3)), prop->data, prop->length);
|
2000-05-31 21:50:38 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
g_hash_table_insert (fbd->properties, GUINT_TO_POINTER (property), new_prop);
|
|
|
|
g_free (prop);
|
2000-05-31 21:50:38 +00:00
|
|
|
|
2001-01-17 15:52:22 +00:00
|
|
|
event_window = gdk_fb_other_event_window (window, GDK_PROPERTY_NOTIFY);
|
|
|
|
if (event_window)
|
2000-05-31 21:50:38 +00:00
|
|
|
{
|
2001-01-17 15:52:22 +00:00
|
|
|
event = gdk_event_make (event_window, GDK_PROPERTY_NOTIFY, TRUE);
|
2000-05-31 21:50:38 +00:00
|
|
|
event->property.atom = property;
|
|
|
|
event->property.state = GDK_PROPERTY_NEW_VALUE;
|
|
|
|
}
|
|
|
|
}
|