gtk/gdk/gdkwindow.c
Owen Taylor e9b6bfcc01 Move all X specific code into the x11/ directory. Aside from shuffling
Mon Nov  8 14:47:04 1999  Owen Taylor  <otaylor@redhat.com>

	Move all X specific code into the x11/ directory.
	Aside from shuffling things around, did the following:

       * gdk/gdkprivate.h gdk/gdk.h gdk/x11/gdkmain-x11.h: Add
	 gdk_arg_context_* - a simple argument parsing system
	 in the style of popt.

       * gdk/gdkdrawable.[ch] gdk/gdkprivate.h gdk/gdkwindow.[ch]
	 gdk/x11/gdkprivate-x11.h:
	 Remove X specific stuff from GdkDrawable and GdkWindowPrivate -
	 add ->klass and ->klass_data fields. The klass_data
	 field points to an auxilliary structure that is
	 windowing system dependent.

       * gdk/gdkfont.c: Make most of the measurement functions
	 simply wrappers around gdk_text_extents().

       * gdk/gdkfont.c gdk/gdkprivate.h gdk/x11/gdkfont-x11.c: Add a
	 _gdk_font_strlen() function that hides the weird
	 behavior in gtk+-1.[02] where a string is interpreted
	 differently for 8-bit and 16-bit fonts.

       * gdk/gdkevents.c: Add a new function gdk_event_button_generate()
	 to store common code for synthesizing double/triple
	 press events.

       * gdk/gdkgc.[ch]: Virtualize in the same way as gdkdrawable.h.
	 Make all the function that modify an existing GC
	 simply wrappers around gdk_gc_set_values().

       * gdk/gdkcc.[ch]: Moved into x11/ directory in preparation
	 for throwing out later.

       * gdk/gdkfont.c gdk/gdkimage.c gdk/gdkcolor.c: Change GdkFontPrivate,
	 GdkImagePrivate and GdkColormapPrivate to have a
	 windowing system dependent part (GdkFontPrivateX etc.)
	 that "derives" from the system-independent part.

       * configure.in gdk/x11/Makefile.in gdk/x11/gdkinput*.c:
	 Got rid of the included-source-files for XInput in
	 favor of automake conditionals. (Which didn't exist
	 when XInput support was originally added.)

       * gdk/gdkrgb.c: Remove the visual id from the debugging
	 statements since that is X11 specific; print out
	 type/depth info instead.
1999-11-08 20:14:59 +00:00

271 lines
6.5 KiB
C

/* 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
* modify it under the terms of the GNU Library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library 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-1999. 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 "gdkwindow.h"
#include "gdkprivate.h"
GdkWindow *
_gdk_window_alloc (void)
{
GdkWindowPrivate *private = g_new (GdkWindowPrivate, 1);
GdkWindow *window = (GdkWindow*) private;
window->user_data = NULL;
private->drawable.ref_count = 1;
private->drawable.destroyed = FALSE;
private->drawable.klass = NULL;
private->drawable.klass_data = NULL;
private->drawable.window_type = GDK_WINDOW_CHILD;
private->drawable.width = 1;
private->drawable.height = 1;
private->drawable.colormap = NULL;
private->parent = NULL;
private->x = 0;
private->y = 0;
private->resize_count = 0;
private->mapped = FALSE;
private->guffaw_gravity = FALSE;
private->extension_events = FALSE;
private->filters = NULL;
private->children = NULL;
return window;
}
void
gdk_window_set_user_data (GdkWindow *window,
gpointer user_data)
{
g_return_if_fail (window != NULL);
window->user_data = user_data;
}
void
gdk_window_get_user_data (GdkWindow *window,
gpointer *data)
{
g_return_if_fail (window != NULL);
*data = window->user_data;
}
void
gdk_window_get_position (GdkWindow *window,
gint *x,
gint *y)
{
GdkWindowPrivate *window_private;
g_return_if_fail (window != NULL);
g_return_if_fail (GDK_IS_WINDOW (window));
window_private = (GdkWindowPrivate*) window;
if (x)
*x = window_private->x;
if (y)
*y = window_private->y;
}
GdkWindow*
gdk_window_get_parent (GdkWindow *window)
{
g_return_val_if_fail (window != NULL, NULL);
g_return_val_if_fail (GDK_IS_WINDOW (window), NULL);
return ((GdkWindowPrivate*) window)->parent;
}
GdkWindow*
gdk_window_get_toplevel (GdkWindow *window)
{
GdkWindowPrivate *private;
g_return_val_if_fail (window != NULL, NULL);
g_return_val_if_fail (GDK_IS_WINDOW (window), NULL);
private = (GdkWindowPrivate *)window;
while (GDK_DRAWABLE_TYPE (private) == GDK_WINDOW_CHILD)
private = (GdkWindowPrivate *)private->parent;
return (GdkWindow *)window;
}
void
gdk_window_add_filter (GdkWindow *window,
GdkFilterFunc function,
gpointer data)
{
GdkWindowPrivate *private;
GList *tmp_list;
GdkEventFilter *filter;
g_return_if_fail (window != NULL);
g_return_if_fail (GDK_IS_WINDOW (window));
private = (GdkWindowPrivate*) window;
if (private && GDK_DRAWABLE_DESTROYED (window))
return;
if (private)
tmp_list = private->filters;
else
tmp_list = gdk_default_filters;
while (tmp_list)
{
filter = (GdkEventFilter *)tmp_list->data;
if ((filter->function == function) && (filter->data == data))
return;
tmp_list = tmp_list->next;
}
filter = g_new (GdkEventFilter, 1);
filter->function = function;
filter->data = data;
if (private)
private->filters = g_list_append (private->filters, filter);
else
gdk_default_filters = g_list_append (gdk_default_filters, filter);
}
void
gdk_window_remove_filter (GdkWindow *window,
GdkFilterFunc function,
gpointer data)
{
GdkWindowPrivate *private;
GList *tmp_list, *node;
GdkEventFilter *filter;
g_return_if_fail (window != NULL);
g_return_if_fail (GDK_IS_WINDOW (window));
private = (GdkWindowPrivate*) window;
if (private)
tmp_list = private->filters;
else
tmp_list = gdk_default_filters;
while (tmp_list)
{
filter = (GdkEventFilter *)tmp_list->data;
node = tmp_list;
tmp_list = tmp_list->next;
if ((filter->function == function) && (filter->data == data))
{
if (private)
private->filters = g_list_remove_link (private->filters, node);
else
gdk_default_filters = g_list_remove_link (gdk_default_filters, node);
g_list_free_1 (node);
g_free (filter);
return;
}
}
}
GList *
gdk_window_get_toplevels (void)
{
GList *new_list = NULL;
GList *tmp_list;
tmp_list = ((GdkWindowPrivate *)gdk_parent_root)->children;
while (tmp_list)
{
new_list = g_list_prepend (new_list, tmp_list->data);
tmp_list = tmp_list->next;
}
return new_list;
}
/*************************************************************
* gdk_window_is_visible:
* Check if the given window is mapped.
* arguments:
* window:
* results:
* is the window mapped
*************************************************************/
gboolean
gdk_window_is_visible (GdkWindow *window)
{
GdkWindowPrivate *private = (GdkWindowPrivate *)window;
g_return_val_if_fail (window != NULL, FALSE);
g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE);
return private->mapped;
}
/*************************************************************
* gdk_window_is_viewable:
* Check if the window and all ancestors of the window
* are mapped. (This is not necessarily "viewable" in
* the X sense, since we only check as far as we have
* GDK window parents, not to the root window)
* arguments:
* window:
* results:
* is the window viewable
*************************************************************/
gboolean
gdk_window_is_viewable (GdkWindow *window)
{
GdkWindowPrivate *private = (GdkWindowPrivate *)window;
g_return_val_if_fail (window != NULL, FALSE);
g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE);
while (private &&
(private != (GdkWindowPrivate *)gdk_parent_root) &&
(private->drawable.window_type != GDK_WINDOW_FOREIGN))
{
if (!private->mapped)
return FALSE;
private = (GdkWindowPrivate *)private->parent;
}
return TRUE;
}