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.
This commit is contained in:
Owen Taylor 1999-11-08 20:14:59 +00:00 committed by Owen Taylor
parent cd02981bf2
commit e9b6bfcc01
77 changed files with 3384 additions and 22467 deletions

View File

@ -1,3 +1,65 @@
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.
Wed Nov 3 18:14:49 1999 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkfont-x11.c (gdk_font_load): Ref fonts when
loading duplicates of hashed fonts.
* gdk/gdk.c (gdk_keysym_convert_case): rename
gdk_XConvertCase to gdk_keysym_convert_case, allow
results to be NULL in the GTK+ style.
* gdk/gdkcompat.h: Started compatibility header
for renames.
1999-11-07 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkprivate.h: New font private structures, related to

View File

@ -1,3 +1,65 @@
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.
Wed Nov 3 18:14:49 1999 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkfont-x11.c (gdk_font_load): Ref fonts when
loading duplicates of hashed fonts.
* gdk/gdk.c (gdk_keysym_convert_case): rename
gdk_XConvertCase to gdk_keysym_convert_case, allow
results to be NULL in the GTK+ style.
* gdk/gdkcompat.h: Started compatibility header
for renames.
1999-11-07 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkprivate.h: New font private structures, related to

View File

@ -1,3 +1,65 @@
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.
Wed Nov 3 18:14:49 1999 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkfont-x11.c (gdk_font_load): Ref fonts when
loading duplicates of hashed fonts.
* gdk/gdk.c (gdk_keysym_convert_case): rename
gdk_XConvertCase to gdk_keysym_convert_case, allow
results to be NULL in the GTK+ style.
* gdk/gdkcompat.h: Started compatibility header
for renames.
1999-11-07 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkprivate.h: New font private structures, related to

View File

@ -1,3 +1,65 @@
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.
Wed Nov 3 18:14:49 1999 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkfont-x11.c (gdk_font_load): Ref fonts when
loading duplicates of hashed fonts.
* gdk/gdk.c (gdk_keysym_convert_case): rename
gdk_XConvertCase to gdk_keysym_convert_case, allow
results to be NULL in the GTK+ style.
* gdk/gdkcompat.h: Started compatibility header
for renames.
1999-11-07 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkprivate.h: New font private structures, related to

View File

@ -1,3 +1,65 @@
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.
Wed Nov 3 18:14:49 1999 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkfont-x11.c (gdk_font_load): Ref fonts when
loading duplicates of hashed fonts.
* gdk/gdk.c (gdk_keysym_convert_case): rename
gdk_XConvertCase to gdk_keysym_convert_case, allow
results to be NULL in the GTK+ style.
* gdk/gdkcompat.h: Started compatibility header
for renames.
1999-11-07 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkprivate.h: New font private structures, related to

View File

@ -1,3 +1,65 @@
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.
Wed Nov 3 18:14:49 1999 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkfont-x11.c (gdk_font_load): Ref fonts when
loading duplicates of hashed fonts.
* gdk/gdk.c (gdk_keysym_convert_case): rename
gdk_XConvertCase to gdk_keysym_convert_case, allow
results to be NULL in the GTK+ style.
* gdk/gdkcompat.h: Started compatibility header
for renames.
1999-11-07 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkprivate.h: New font private structures, related to

View File

@ -1,3 +1,65 @@
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.
Wed Nov 3 18:14:49 1999 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkfont-x11.c (gdk_font_load): Ref fonts when
loading duplicates of hashed fonts.
* gdk/gdk.c (gdk_keysym_convert_case): rename
gdk_XConvertCase to gdk_keysym_convert_case, allow
results to be NULL in the GTK+ style.
* gdk/gdkcompat.h: Started compatibility header
for renames.
1999-11-07 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkprivate.h: New font private structures, related to

View File

@ -406,6 +406,9 @@ else
AC_DEFINE(XINPUT_NONE)
fi
AM_CONDITIONAL(XINPUT_GXI, test x$with_xinput = xgxi)
AM_CONDITIONAL(XINPUT_XFREE, test x$with_xinput = xxfree)
CFLAGS="$saved_cflags"
LDFLAGS="$saved_ldflags"

View File

@ -44,6 +44,7 @@ gdk_public_h_sources = @STRIP_BEGIN@ \
gdk.h \
gdkcc.h \
gdkcolor.h \
gdkcompat.h \
gdkcursor.h \
gdkcursors.h \
gdkdnd.h \
@ -65,36 +66,19 @@ gdk_public_h_sources = @STRIP_BEGIN@ \
gdktypes.h \
gdkvisual.h \
gdkwindow.h \
gdkx.h \
@STRIP_END@
gdk_c_sources = @STRIP_BEGIN@ \
gdk.c \
gdkcc.c \
gdkcolor.c \
gdkcursor.c \
gdkdnd.c \
gdkdraw.c \
gdkevents.c \
gdkfont.c \
gdkgc.c \
gdkglobals.c \
gdkim.c \
gdkimage.c \
gdkinput.c \
gdkinput.h \
gdkinputnone.h \
gdkinputcommon.h\
gdkinputgxi.h \
gdkinputxfree.h \
gdkpixmap.c \
gdkproperty.c \
gdkrgb.c \
gdkrectangle.c \
gdkregion.c \
gdkselection.c \
gdkvisual.c \
gdkwindow.c \
gdkxid.c \
MwmUtil.h \
@STRIP_END@

View File

@ -1,140 +0,0 @@
/**
*
* $Id$
*
* Copyright (C) 1995 Free Software Foundation, Inc.
*
* This file is part of the GNU LessTif Library.
*
* 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.
*
*
* * Feb 21 1999 - George Lebl (jirka@5z.com)
* Owen Taylor (otaylor@redhat.com)
*
* Modified so that the MotifWmHints structure defined here
* is suitable for client side use on 64-bit architectures.
* X expects fields with a format of 32 to be longs, even
* when sizeof(long) == 8.
**/
#ifndef MWMUTIL_H_INCLUDED
#define MWMUTIL_H_INCLUDED
#include <X11/Xmd.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
unsigned long flags;
unsigned long functions;
unsigned long decorations;
long input_mode;
unsigned long status;
} MotifWmHints, MwmHints;
#define MWM_HINTS_FUNCTIONS (1L << 0)
#define MWM_HINTS_DECORATIONS (1L << 1)
#define MWM_HINTS_INPUT_MODE (1L << 2)
#define MWM_HINTS_STATUS (1L << 3)
#define MWM_FUNC_ALL (1L << 0)
#define MWM_FUNC_RESIZE (1L << 1)
#define MWM_FUNC_MOVE (1L << 2)
#define MWM_FUNC_MINIMIZE (1L << 3)
#define MWM_FUNC_MAXIMIZE (1L << 4)
#define MWM_FUNC_CLOSE (1L << 5)
#define MWM_DECOR_ALL (1L << 0)
#define MWM_DECOR_BORDER (1L << 1)
#define MWM_DECOR_RESIZEH (1L << 2)
#define MWM_DECOR_TITLE (1L << 3)
#define MWM_DECOR_MENU (1L << 4)
#define MWM_DECOR_MINIMIZE (1L << 5)
#define MWM_DECOR_MAXIMIZE (1L << 6)
#define MWM_INPUT_MODELESS 0
#define MWM_INPUT_PRIMARY_APPLICATION_MODAL 1
#define MWM_INPUT_SYSTEM_MODAL 2
#define MWM_INPUT_FULL_APPLICATION_MODAL 3
#define MWM_INPUT_APPLICATION_MODAL MWM_INPUT_PRIMARY_APPLICATION_MODAL
#define MWM_TEAROFF_WINDOW (1L<<0)
/*
* atoms
*/
#define _XA_MOTIF_BINDINGS "_MOTIF_BINDINGS"
#define _XA_MOTIF_WM_HINTS "_MOTIF_WM_HINTS"
#define _XA_MOTIF_WM_MESSAGES "_MOTIF_WM_MESSAGES"
#define _XA_MOTIF_WM_OFFSET "_MOTIF_WM_OFFSET"
#define _XA_MOTIF_WM_MENU "_MOTIF_WM_MENU"
#define _XA_MOTIF_WM_INFO "_MOTIF_WM_INFO"
#define _XA_MWM_HINTS _XA_MOTIF_WM_HINTS
#define _XA_MWM_MESSAGES _XA_MOTIF_WM_MESSAGES
#define _XA_MWM_MENU _XA_MOTIF_WM_MENU
#define _XA_MWM_INFO _XA_MOTIF_WM_INFO
/*
* _MWM_INFO property
*/
typedef struct {
long flags;
Window wm_window;
} MotifWmInfo;
typedef MotifWmInfo MwmInfo;
#define MWM_INFO_STARTUP_STANDARD (1L<<0)
#define MWM_INFO_STARTUP_CUSTOM (1L<<1)
/*
* _MWM_HINTS property
*/
typedef struct {
unsigned long flags;
unsigned long functions;
unsigned long decorations;
long inputMode;
unsigned long status;
} PropMotifWmHints;
typedef PropMotifWmHints PropMwmHints;
#define PROP_MOTIF_WM_HINTS_ELEMENTS 5
#define PROP_MWM_HINTS_ELEMENTS PROP_MOTIF_WM_HINTS_ELEMENTS
/*
* _MWM_INFO property, slight return
*/
typedef struct {
unsigned long flags;
unsigned long wmWindow;
} PropMotifWmInfo;
typedef PropMotifWmInfo PropMwmInfo;
#define PROP_MOTIF_WM_INFO_ELEMENTS 2
#define PROP_MWM_INFO_ELEMENTS PROP_MOTIF_WM_INFO_ELEMENTS
#ifdef __cplusplus
}
#endif
#endif /* MWMUTIL_H_INCLUDED */

117
gdk/TODO
View File

@ -4,6 +4,10 @@ General
- gdk_pointer_grab() and gdk_keyboard_grab() are logically member
functions of GdkWindow.
X specific Functions that need to be moved out of the common header files
=========================================================================
Dir structure for ports
=======================
@ -56,6 +60,119 @@ files in the directory, and also for building any
X-specific utilities. (Such as the gxid daemon).
Port Status for Files
=====================
gdk
Much of the contents have been moved to x11/gtkmain.c.
I've added a little argument-parsing abstraction.
(Currently called gdk_arg_context_*) that allows
arguments from multiple places to be combined - that
probably needs to be either fixed up and moved into
GLib or replaced with some existing solution like
popt.
gdkcc
This will be removed for GTK+-1.4. Right now, it has been moved
completely into the x11/ directory to avoid having to port it.
gdkcolor
There are a few common utility functions, and the rest
is in the port-specific files.
gdkcursor
No shared code - completely port-specific.
gdkdnd
No shared code - completely arch-specific. It's possible that some
common code for handling GdkDragContext could exist, but the
GdkDragContextPrivate will be different on each port.
gdkdrawable
Pretty much done. GdkDrawable is completely virtualized.
gdkevents
There are a few common utility functions, and the rest
is in the port-specific files.
gdkfont
Pretty much done for now - gdkfont.c contains a number of functions
reimplemented as utility functions, and the rest is
ports-specific. It will be obsoleted by pango before 1.4.
gdkgc
GdkGC is virtualized to go along with GdkDrawable. There are
a couple of functions I punted on for now and moved into the
port-specific files - the clipmask functions (because gdkregion
is not finalized) and also gdk_gc_copy, which I'm not sure
I like enough to put into the vtable.
gdkim
All in the port-specific directories. The abstraction here probably
will be changed at some point to something more convenient and
more Unicode-based.
gdkimage
GdkImage is virtualized - all of the code except for ref/unref
is in the port-specific files.
gdkinput
Right now all the code is port-specific. It should be possible
to share the code in gdkinputnone.c, but probably not worth it;
I'd like to get rid of the gdk_input_vtable in X11 code -
it doesn't make sense since you can't switch the type of input
on the fly.
gdkpixmap
All moved into the port-specific file for now. The xpm loader
should be changed to render with GdkRGB, and thus be
windowing-system independent, but that requires
first making GdkRGB able to render onto any arbitrary visual.
gdkproperty
All port-specific. Possibly should be X-specific with a higher-level
clipboard API on top of it.
gdkregion
Right now punted to being port-specific, but that probably needs
to change with the virtualized drawables and GC's.
gdkrgb
With a few changes to debugging code, it was already port-independent.
gdkselection
Completely port specific. (In fact, really doesn't make sense
on anything other than X; a higher-level clipboard facility
should be provided somewhere, though.)
gdkvisual
Completely port-specific. (The concepts are rather X-specific)
gdkwindow
The window-private data is split between windowing-system independent
parts and windowing system dependent parts. There are a few
functions in gdk/gdkwindow.c and the rest is moved off
into x11/gdkwindow-x11.c
Virtualization
==============

1160
gdk/gdk.c

File diff suppressed because it is too large Load Diff

View File

@ -138,11 +138,15 @@ gboolean gdk_event_send_client_message (GdkEvent *event,
*/
gchar* gdk_keyval_name (guint keyval);
guint gdk_keyval_from_name (const gchar *keyval_name);
void gdk_keyval_convert_case (guint symbol,
guint *lower,
guint *upper);
guint gdk_keyval_to_upper (guint keyval);
guint gdk_keyval_to_lower (guint keyval);
gboolean gdk_keyval_is_upper (guint keyval);
gboolean gdk_keyval_is_lower (guint keyval);
/* Threading
*/

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -13,15 +13,28 @@ extern "C" {
#define GdkWindowType GdkDrawableType
#define gdk_draw_pixmap gdk_draw_drawable
#define gdk_draw_bitmap gdk_draw_drawable
#define gdk_window_get_size gdk_drawable_get_size
#define gdk_window_get_type gdk_drawable_get_type
#define gdk_window_get_colormap gdk_drawable_get_colormap
#define gdk_window_set_colormap gdk_drawable_set_colormap
#define gdk_window_get_visual gdk_drawable_get_visual
#define gdk_window_ref gdk_drawable_ref
#define gdk_window_unref gdk_drawable_unref
#define gdk_bitmap_ref gdk_drawable_ref
#define gdk_bitmap_unref gdk_drawable_unref
#define gdk_pixmap_ref gdk_drawable_ref
#define gdk_pixmap_unref gdk_drawable_unref
#define gdk_window_copy_area(drawable,gc,x,y,source_drawable,source_x,source_y,width,height) \
gdk_draw_pixmap(drawable,gc,source_drawable,source_x,source_y,x,y,width,height)
#define gdk_gc_destroy gdk_gc_unref
#define gdk_image_destroy gdk_image_unref
#define GDK_WINDOW_PIXMAP GDK_DRAWABLE_PIXMAP
#endif /* GDK_DISABLE_COMPAT_H */

View File

@ -1,94 +0,0 @@
/* 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 <X11/Xlib.h>
#include <X11/cursorfont.h>
#include "gdkx.h"
#include "gdkcursor.h"
#include "gdkprivate.h"
GdkCursor*
gdk_cursor_new (GdkCursorType cursor_type)
{
GdkCursorPrivate *private;
GdkCursor *cursor;
Cursor xcursor;
xcursor = XCreateFontCursor (gdk_display, cursor_type);
private = g_new (GdkCursorPrivate, 1);
private->xdisplay = gdk_display;
private->xcursor = xcursor;
cursor = (GdkCursor*) private;
cursor->type = cursor_type;
return cursor;
}
GdkCursor*
gdk_cursor_new_from_pixmap (GdkPixmap *source, GdkPixmap *mask, GdkColor *fg, GdkColor *bg, gint x, gint y)
{
GdkCursorPrivate *private;
GdkCursor *cursor;
Pixmap source_pixmap, mask_pixmap;
Cursor xcursor;
XColor xfg, xbg;
source_pixmap = GDK_DRAWABLE_XID (source);
mask_pixmap = GDK_DRAWABLE_XID (mask);
xfg.pixel = fg->pixel;
xfg.red = fg->red;
xfg.blue = fg->blue;
xfg.green = fg->green;
xbg.pixel = bg->pixel;
xbg.red = bg->red;
xbg.blue = bg->blue;
xbg.green = bg->green;
xcursor = XCreatePixmapCursor (gdk_display, source_pixmap, mask_pixmap, &xfg, &xbg, x, y);
private = g_new (GdkCursorPrivate, 1);
private->xdisplay = gdk_display;
private->xcursor = xcursor;
cursor = (GdkCursor *) private;
cursor->type = GDK_CURSOR_IS_PIXMAP;
return cursor;
}
void
gdk_cursor_destroy (GdkCursor *cursor)
{
GdkCursorPrivate *private;
g_return_if_fail (cursor != NULL);
private = (GdkCursorPrivate *) cursor;
XFreeCursor (private->xdisplay, private->xcursor);
g_free (private);
}

File diff suppressed because it is too large Load Diff

View File

@ -24,16 +24,34 @@
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#include <X11/Xlib.h>
#include <X11/Xos.h>
#include "gdkx.h"
#include "gdkdrawable.h"
#include "gdkprivate.h"
#include "gdkwindow.h"
/* Manipulation of drawables
*/
GdkDrawable *
gdk_drawable_alloc (void)
{
GdkDrawablePrivate *private = g_new (GdkDrawablePrivate, 1);
GdkDrawable *drawable = (GdkDrawable*) private;
drawable->user_data = NULL;
private->ref_count = 1;
private->destroyed = FALSE;
private->klass = NULL;
private->klass_data = NULL;
private->window_type = GDK_WINDOW_CHILD;
private->width = 1;
private->height = 1;
private->colormap = NULL;
return drawable;
}
void
gdk_drawable_set_data (GdkDrawable *drawable,
const gchar *key,
@ -75,68 +93,6 @@ gdk_drawable_get_size (GdkDrawable *drawable,
*height = drawable_private->height;
}
void
gdk_drawable_set_colormap (GdkDrawable *drawable,
GdkColormap *colormap)
{
GdkDrawablePrivate *drawable_private;
GdkColormapPrivate *colormap_private;
g_return_if_fail (drawable != NULL);
g_return_if_fail (colormap != NULL);
drawable_private = (GdkDrawablePrivate*) drawable;
colormap_private = (GdkColormapPrivate*) colormap;
if (!GDK_DRAWABLE_DESTROYED (drawable))
{
if (GDK_IS_WINDOW (drawable))
{
g_return_if_fail (colormap_private->visual !=
((GdkColormapPrivate *)(drawable_private->colormap))->visual);
XSetWindowColormap (GDK_DRAWABLE_XDISPLAY (drawable),
GDK_DRAWABLE_XID (drawable),
colormap_private->xcolormap);
}
if (drawable_private->colormap)
gdk_colormap_unref (drawable_private->colormap);
drawable_private->colormap = colormap;
gdk_colormap_ref (drawable_private->colormap);
if (GDK_IS_WINDOW (drawable) &&
drawable_private->window_type != GDK_WINDOW_TOPLEVEL)
gdk_window_add_colormap_windows (drawable);
}
}
GdkColormap*
gdk_drawable_get_colormap (GdkDrawable *drawable)
{
GdkDrawablePrivate *drawable_private;
XWindowAttributes window_attributes;
g_return_val_if_fail (drawable != NULL, NULL);
drawable_private = (GdkDrawablePrivate*) drawable;
if (!GDK_DRAWABLE_DESTROYED (drawable))
{
if (drawable_private->colormap == NULL &&
GDK_IS_WINDOW (drawable))
{
XGetWindowAttributes (GDK_DRAWABLE_XDISPLAY (drawable),
GDK_DRAWABLE_XID (drawable),
&window_attributes);
drawable_private->colormap = gdk_colormap_lookup (window_attributes.colormap);
}
return drawable_private->colormap;
}
return NULL;
}
GdkVisual*
gdk_drawable_get_visual (GdkDrawable *drawable)
{
@ -148,6 +104,33 @@ gdk_drawable_get_visual (GdkDrawable *drawable)
return colormap ? gdk_colormap_get_visual (colormap) : NULL;
}
GdkDrawable*
gdk_drawable_ref (GdkDrawable *drawable)
{
GdkDrawablePrivate *private = (GdkDrawablePrivate *)drawable;
g_return_val_if_fail (drawable != NULL, NULL);
private->ref_count += 1;
return drawable;
}
void
gdk_drawable_unref (GdkDrawable *drawable)
{
GdkDrawablePrivate *private = (GdkDrawablePrivate *)drawable;
g_return_if_fail (drawable != NULL);
g_return_if_fail (private->ref_count > 0);
private->ref_count -= 1;
if (private->ref_count == 0)
{
private->klass->destroy (drawable);
g_dataset_destroy (drawable);
g_free (drawable);
}
}
/* Drawing
*/
void
@ -157,6 +140,7 @@ gdk_draw_point (GdkDrawable *drawable,
gint y)
{
GdkGCPrivate *gc_private;
GdkPoint point;
g_return_if_fail (drawable != NULL);
g_return_if_fail (gc != NULL);
@ -165,8 +149,10 @@ gdk_draw_point (GdkDrawable *drawable,
return;
gc_private = (GdkGCPrivate*) gc;
XDrawPoint (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
gc_private->xgc, x, y);
point.x = x;
point.y = y;
((GdkDrawablePrivate *)drawable)->klass->draw_points (drawable, gc, &point, 1);
}
void
@ -178,6 +164,7 @@ gdk_draw_line (GdkDrawable *drawable,
gint y2)
{
GdkGCPrivate *gc_private;
GdkSegment segment;
g_return_if_fail (drawable != NULL);
g_return_if_fail (gc != NULL);
@ -186,8 +173,11 @@ gdk_draw_line (GdkDrawable *drawable,
return;
gc_private = (GdkGCPrivate*) gc;
XDrawLine (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
gc_private->xgc, x1, y1, x2, y2);
segment.x1 = x1;
segment.y1 = y1;
segment.x2 = x2;
segment.y2 = y2;
((GdkDrawablePrivate *)drawable)->klass->draw_segments (drawable, gc, &segment, 1);
}
void
@ -200,7 +190,6 @@ gdk_draw_rectangle (GdkDrawable *drawable,
gint height)
{
GdkDrawablePrivate *drawable_private;
GdkGCPrivate *gc_private;
g_return_if_fail (drawable != NULL);
g_return_if_fail (gc != NULL);
@ -208,19 +197,14 @@ gdk_draw_rectangle (GdkDrawable *drawable,
drawable_private = (GdkDrawablePrivate*) drawable;
if (GDK_DRAWABLE_DESTROYED (drawable))
return;
gc_private = (GdkGCPrivate*) gc;
if (width == -1)
if (width < 0)
width = drawable_private->width;
if (height == -1)
if (height < 0)
height = drawable_private->height;
if (filled)
XFillRectangle (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
gc_private->xgc, x, y, width, height);
else
XDrawRectangle (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
gc_private->xgc, x, y, width, height);
((GdkDrawablePrivate *)drawable)->klass->draw_rectangle (drawable, gc, filled, x, y,
width, height);
}
void
@ -245,17 +229,13 @@ gdk_draw_arc (GdkDrawable *drawable,
return;
gc_private = (GdkGCPrivate*) gc;
if (width == -1)
if (width < 0)
width = drawable_private->width;
if (height == -1)
if (height < 0)
height = drawable_private->height;
if (filled)
XFillArc (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
gc_private->xgc, x, y, width, height, angle1, angle2);
else
XDrawArc (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
gc_private->xgc, x, y, width, height, angle1, angle2);
((GdkDrawablePrivate *)drawable)->klass->draw_arc (drawable, gc, filled,
x, y, width, height, angle1, angle2);
}
void
@ -265,44 +245,14 @@ gdk_draw_polygon (GdkDrawable *drawable,
GdkPoint *points,
gint npoints)
{
GdkGCPrivate *gc_private;
GdkPoint *local_points = points;
gint local_npoints = npoints;
gint local_alloc = 0;
g_return_if_fail (drawable != NULL);
g_return_if_fail (gc != NULL);
if (GDK_DRAWABLE_DESTROYED (drawable))
return;
gc_private = (GdkGCPrivate*) gc;
if (filled)
{
XFillPolygon (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
gc_private->xgc, (XPoint*) points, npoints, Complex, CoordModeOrigin);
}
else
{
if ((points[0].x != points[npoints-1].x) ||
(points[0].y != points[npoints-1].y))
{
local_alloc = 1;
++local_npoints;
local_points = (GdkPoint*) g_malloc (local_npoints * sizeof(GdkPoint));
memcpy (local_points, points, npoints * sizeof(GdkPoint));
local_points[npoints].x = points[0].x;
local_points[npoints].y = points[0].y;
}
XDrawLines (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
gc_private->xgc,
(XPoint*) local_points, local_npoints,
CoordModeOrigin);
if (local_alloc)
g_free (local_points);
}
((GdkDrawablePrivate *)drawable)->klass->draw_polygon (drawable, gc, filled,
points, npoints);
}
/* gdk_draw_string
@ -319,43 +269,7 @@ gdk_draw_string (GdkDrawable *drawable,
gint y,
const gchar *string)
{
GdkFontPrivate *font_private;
GdkGCPrivate *gc_private;
g_return_if_fail (drawable != NULL);
g_return_if_fail (font != NULL);
g_return_if_fail (gc != NULL);
g_return_if_fail (string != NULL);
if (GDK_DRAWABLE_DESTROYED (drawable))
return;
gc_private = (GdkGCPrivate*) gc;
font_private = (GdkFontPrivate*) font;
if (font->type == GDK_FONT_FONT)
{
XFontStruct *xfont = (XFontStruct *) font_private->xfont;
XSetFont(GDK_DRAWABLE_XDISPLAY (drawable), gc_private->xgc, xfont->fid);
if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))
{
XDrawString (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
gc_private->xgc, x, y, string, strlen (string));
}
else
{
XDrawString16 (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
gc_private->xgc, x, y, (XChar2b *) string,
strlen (string) / 2);
}
}
else if (font->type == GDK_FONT_FONTSET)
{
XFontSet fontset = (XFontSet) font_private->xfont;
XmbDrawString (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
fontset, gc_private->xgc, x, y, string, strlen (string));
}
else
g_error("undefined font type\n");
gdk_draw_text (drawable, font, gc, x, y, string, _gdk_font_strlen (font, string));
}
/* gdk_draw_text
@ -373,42 +287,12 @@ gdk_draw_text (GdkDrawable *drawable,
const gchar *text,
gint text_length)
{
GdkFontPrivate *font_private;
GdkGCPrivate *gc_private;
g_return_if_fail (drawable != NULL);
g_return_if_fail (font != NULL);
g_return_if_fail (gc != NULL);
g_return_if_fail (text != NULL);
if (GDK_DRAWABLE_DESTROYED (drawable))
return;
gc_private = (GdkGCPrivate*) gc;
font_private = (GdkFontPrivate*) font;
if (font->type == GDK_FONT_FONT)
{
XFontStruct *xfont = (XFontStruct *) font_private->xfont;
XSetFont(GDK_DRAWABLE_XDISPLAY (drawable), gc_private->xgc, xfont->fid);
if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))
{
XDrawString (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
gc_private->xgc, x, y, text, text_length);
}
else
{
XDrawString16 (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
gc_private->xgc, x, y, (XChar2b *) text, text_length / 2);
}
}
else if (font->type == GDK_FONT_FONTSET)
{
XFontSet fontset = (XFontSet) font_private->xfont;
XmbDrawString (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
fontset, gc_private->xgc, x, y, text, text_length);
}
else
g_error("undefined font type\n");
((GdkDrawablePrivate *)drawable)->klass->draw_text (drawable, font, gc, x, y, text, text_length);
}
void
@ -420,59 +304,18 @@ gdk_draw_text_wc (GdkDrawable *drawable,
const GdkWChar *text,
gint text_length)
{
GdkFontPrivate *font_private;
GdkGCPrivate *gc_private;
g_return_if_fail (drawable != NULL);
g_return_if_fail (font != NULL);
g_return_if_fail (gc != NULL);
g_return_if_fail (text != NULL);
if (GDK_DRAWABLE_DESTROYED (drawable))
return;
gc_private = (GdkGCPrivate*) gc;
font_private = (GdkFontPrivate*) font;
if (font->type == GDK_FONT_FONT)
{
XFontStruct *xfont = (XFontStruct *) font_private->xfont;
gchar *text_8bit;
gint i;
XSetFont(GDK_DRAWABLE_XDISPLAY (drawable), gc_private->xgc, xfont->fid);
text_8bit = g_new (gchar, text_length);
for (i=0; i<text_length; i++) text_8bit[i] = text[i];
XDrawString (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
gc_private->xgc, x, y, text_8bit, text_length);
g_free (text_8bit);
}
else if (font->type == GDK_FONT_FONTSET)
{
if (sizeof(GdkWChar) == sizeof(wchar_t))
{
XwcDrawString (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
(XFontSet) font_private->xfont,
gc_private->xgc, x, y, (wchar_t *)text, text_length);
}
else
{
wchar_t *text_wchar;
gint i;
text_wchar = g_new (wchar_t, text_length);
for (i=0; i<text_length; i++) text_wchar[i] = text[i];
XwcDrawString (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
(XFontSet) font_private->xfont,
gc_private->xgc, x, y, text_wchar, text_length);
g_free (text_wchar);
}
}
else
g_error("undefined font type\n");
((GdkDrawablePrivate *)drawable)->klass->draw_text_wc (drawable, font, gc, x, y, text, text_length);
}
void
gdk_draw_pixmap (GdkDrawable *drawable,
gdk_draw_drawable (GdkDrawable *drawable,
GdkGC *gc,
GdkPixmap *src,
GdkDrawable *src,
gint xsrc,
gint ysrc,
gint xdest,
@ -480,28 +323,21 @@ gdk_draw_pixmap (GdkDrawable *drawable,
gint width,
gint height)
{
GdkGCPrivate *gc_private;
g_return_if_fail (drawable != NULL);
g_return_if_fail (src != NULL);
g_return_if_fail (gc != NULL);
if (GDK_DRAWABLE_DESTROYED (drawable) || GDK_DRAWABLE_DESTROYED (src))
return;
gc_private = (GdkGCPrivate*) gc;
if (width == -1)
width = ((GdkDrawablePrivate *)src)->width;
if (height == -1)
height = ((GdkDrawablePrivate *)src)->height;
XCopyArea (GDK_DRAWABLE_XDISPLAY (drawable),
GDK_DRAWABLE_XID (src),
GDK_DRAWABLE_XID (drawable),
gc_private->xgc,
xsrc, ysrc,
width, height,
xdest, ydest);
((GdkDrawablePrivate *)drawable)->klass->draw_drawable (drawable, gc, src,
xsrc, ysrc, xdest, ydest,
width, height);
}
void
@ -523,14 +359,13 @@ gdk_draw_image (GdkDrawable *drawable,
image_private = (GdkImagePrivate*) image;
g_return_if_fail (image_private->image_put != NULL);
if (width == -1)
width = image->width;
if (height == -1)
height = image->height;
(* image_private->image_put) (drawable, gc, image, xsrc, ysrc,
image_private->klass->image_put (image, drawable, gc, xsrc, ysrc,
xdest, ydest, width, height);
}
@ -540,22 +375,18 @@ gdk_draw_points (GdkDrawable *drawable,
GdkPoint *points,
gint npoints)
{
GdkGCPrivate *gc_private;
g_return_if_fail (drawable != NULL);
g_return_if_fail ((points != NULL) && (npoints > 0));
g_return_if_fail (gc != NULL);
g_return_if_fail (npoints >= 0);
if (npoints == 0)
return;
if (GDK_DRAWABLE_DESTROYED (drawable))
return;
gc_private = (GdkGCPrivate*) gc;
XDrawPoints (GDK_DRAWABLE_XDISPLAY (drawable),
GDK_DRAWABLE_XID (drawable),
gc_private->xgc,
(XPoint *) points,
npoints,
CoordModeOrigin);
((GdkDrawablePrivate *)drawable)->klass->draw_points (drawable, gc, points, npoints);
}
void
@ -564,24 +395,18 @@ gdk_draw_segments (GdkDrawable *drawable,
GdkSegment *segs,
gint nsegs)
{
GdkGCPrivate *gc_private;
if (nsegs <= 0)
return;
g_return_if_fail (drawable != NULL);
g_return_if_fail (segs != NULL);
g_return_if_fail (gc != NULL);
g_return_if_fail (nsegs >= 0);
if (nsegs == 0)
return;
if (GDK_DRAWABLE_DESTROYED (drawable))
return;
gc_private = (GdkGCPrivate*) gc;
XDrawSegments (GDK_DRAWABLE_XDISPLAY (drawable),
GDK_DRAWABLE_XID (drawable),
gc_private->xgc,
(XSegment *) segs,
nsegs);
((GdkDrawablePrivate *)drawable)->klass->draw_segments (drawable, gc, segs, nsegs);
}
void
@ -590,23 +415,17 @@ gdk_draw_lines (GdkDrawable *drawable,
GdkPoint *points,
gint npoints)
{
GdkGCPrivate *gc_private;
if (npoints <= 0)
return;
g_return_if_fail (drawable != NULL);
g_return_if_fail (points != NULL);
g_return_if_fail (gc != NULL);
g_return_if_fail (npoints >= 0);
if (npoints == 0)
return;
if (GDK_DRAWABLE_DESTROYED (drawable))
return;
gc_private = (GdkGCPrivate*) gc;
XDrawLines (GDK_DRAWABLE_XDISPLAY (drawable),
GDK_DRAWABLE_XID (drawable),
gc_private->xgc,
(XPoint *) points,
npoints,
CoordModeOrigin);
((GdkDrawablePrivate *)drawable)->klass->draw_points (drawable, gc, points, npoints);
}

View File

@ -2,11 +2,14 @@
#define __GDK_DRAWABLE_H__
#include <gdk/gdktypes.h>
#include <gdk/gdkgc.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
typedef struct _GdkDrawableClass GdkDrawableClass;
/* Types of windows.
* Root: There is only 1 root window and it is initialized
* at startup. Creating a window of type GDK_WINDOW_ROOT
@ -43,8 +46,74 @@ struct _GdkDrawable
gpointer user_data;
};
struct _GdkDrawableClass
{
void (*destroy) (GdkDrawable *drawable);
GdkGC *(*create_gc) (GdkDrawable *drawable,
GdkGCValues *values,
GdkGCValuesMask mask);
void (*draw_rectangle) (GdkDrawable *drawable,
GdkGC *gc,
gint filled,
gint x,
gint y,
gint width,
gint height);
void (*draw_arc) (GdkDrawable *drawable,
GdkGC *gc,
gint filled,
gint x,
gint y,
gint width,
gint height,
gint angle1,
gint angle2);
void (*draw_polygon) (GdkDrawable *drawable,
GdkGC *gc,
gint filled,
GdkPoint *points,
gint npoints);
void (*draw_text) (GdkDrawable *drawable,
GdkFont *font,
GdkGC *gc,
gint x,
gint y,
const gchar *text,
gint text_length);
void (*draw_text_wc) (GdkDrawable *drawable,
GdkFont *font,
GdkGC *gc,
gint x,
gint y,
const GdkWChar *text,
gint text_length);
void (*draw_drawable) (GdkDrawable *drawable,
GdkGC *gc,
GdkDrawable *src,
gint xsrc,
gint ysrc,
gint xdest,
gint ydest,
gint width,
gint height);
void (*draw_points) (GdkDrawable *drawable,
GdkGC *gc,
GdkPoint *points,
gint npoints);
void (*draw_segments) (GdkDrawable *drawable,
GdkGC *gc,
GdkSegment *segs,
gint nsegs);
void (*draw_lines) (GdkDrawable *drawable,
GdkGC *gc,
GdkPoint *points,
gint npoints);
};
/* Manipulation of drawables
*/
GdkDrawable * gdk_drawable_alloc (void);
GdkDrawableType gdk_drawable_get_type (GdkDrawable *window);
void gdk_drawable_set_data (GdkDrawable *drawable,
@ -61,6 +130,8 @@ void gdk_drawable_set_colormap (GdkDrawable *drawable,
GdkColormap *colormap);
GdkColormap* gdk_drawable_get_colormap (GdkDrawable *drawable);
GdkVisual* gdk_drawable_get_visual (GdkDrawable *drawable);
GdkDrawable* gdk_drawable_ref (GdkDrawable *drawable);
void gdk_drawable_unref (GdkDrawable *drawable);
/* Drawing
*/
@ -115,16 +186,7 @@ void gdk_draw_text_wc (GdkDrawable *drawable,
gint y,
const GdkWChar *text,
gint text_length);
void gdk_draw_pixmap (GdkDrawable *drawable,
GdkGC *gc,
GdkDrawable *src,
gint xsrc,
gint ysrc,
gint xdest,
gint ydest,
gint width,
gint height);
void gdk_draw_bitmap (GdkDrawable *drawable,
void gdk_draw_drawable (GdkDrawable *drawable,
GdkGC *gc,
GdkDrawable *src,
gint xsrc,

File diff suppressed because it is too large Load Diff

View File

@ -24,179 +24,9 @@
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#include <X11/Xlib.h>
#include <X11/Xos.h>
#include "gdkfont.h"
#include "gdkprivate.h"
static GHashTable *font_name_hash = NULL;
static GHashTable *fontset_name_hash = NULL;
static void
gdk_font_hash_insert (GdkFontType type, GdkFont *font, const gchar *font_name)
{
GdkFontPrivate *private = (GdkFontPrivate *)font;
GHashTable **hashp = (type == GDK_FONT_FONT) ?
&font_name_hash : &fontset_name_hash;
if (!*hashp)
*hashp = g_hash_table_new (g_str_hash, g_str_equal);
private->names = g_slist_prepend (private->names, g_strdup (font_name));
g_hash_table_insert (*hashp, private->names->data, font);
}
static void
gdk_font_hash_remove (GdkFontType type, GdkFont *font)
{
GdkFontPrivate *private = (GdkFontPrivate *)font;
GSList *tmp_list;
GHashTable *hash = (type == GDK_FONT_FONT) ?
font_name_hash : fontset_name_hash;
tmp_list = private->names;
while (tmp_list)
{
g_hash_table_remove (hash, tmp_list->data);
g_free (tmp_list->data);
tmp_list = tmp_list->next;
}
g_slist_free (private->names);
private->names = NULL;
}
static GdkFont *
gdk_font_hash_lookup (GdkFontType type, const gchar *font_name)
{
GdkFont *result;
GHashTable *hash = (type == GDK_FONT_FONT) ?
font_name_hash : fontset_name_hash;
if (!hash)
return NULL;
else
{
result = g_hash_table_lookup (hash, font_name);
if (result)
gdk_font_ref (result);
return result;
}
}
GdkFont*
gdk_font_load (const gchar *font_name)
{
GdkFont *font;
GdkFontPrivate *private;
XFontStruct *xfont;
g_return_val_if_fail (font_name != NULL, NULL);
font = gdk_font_hash_lookup (GDK_FONT_FONT, font_name);
if (font)
return font;
xfont = XLoadQueryFont (gdk_display, font_name);
if (xfont == NULL)
return NULL;
font = gdk_font_lookup (xfont->fid);
if (font != NULL)
{
private = (GdkFontPrivate *) font;
if (xfont != private->xfont)
XFreeFont (gdk_display, xfont);
gdk_font_ref (font);
}
else
{
private = g_new (GdkFontPrivate, 1);
private->xdisplay = gdk_display;
private->xfont = xfont;
private->ref_count = 1;
private->names = NULL;
font = (GdkFont*) private;
font->type = GDK_FONT_FONT;
font->ascent = xfont->ascent;
font->descent = xfont->descent;
gdk_xid_table_insert (&xfont->fid, font);
}
gdk_font_hash_insert (GDK_FONT_FONT, font, font_name);
return font;
}
GdkFont*
gdk_fontset_load (gchar *fontset_name)
{
GdkFont *font;
GdkFontPrivate *private;
XFontSet fontset;
gint missing_charset_count;
gchar **missing_charset_list;
gchar *def_string;
font = gdk_font_hash_lookup (GDK_FONT_FONTSET, fontset_name);
if (font)
return font;
private = g_new (GdkFontPrivate, 1);
font = (GdkFont*) private;
private->xdisplay = gdk_display;
fontset = XCreateFontSet (gdk_display, fontset_name,
&missing_charset_list, &missing_charset_count,
&def_string);
if (missing_charset_count)
{
gint i;
g_warning ("Missing charsets in FontSet creation\n");
for (i=0;i<missing_charset_count;i++)
g_warning (" %s\n", missing_charset_list[i]);
XFreeStringList (missing_charset_list);
}
private->ref_count = 1;
if (!fontset)
{
g_free (font);
return NULL;
}
else
{
gint num_fonts;
gint i;
XFontStruct **font_structs;
gchar **font_names;
private->xfont = fontset;
font->type = GDK_FONT_FONTSET;
num_fonts = XFontsOfFontSet (fontset, &font_structs, &font_names);
font->ascent = font->descent = 0;
for (i = 0; i < num_fonts; i++)
{
font->ascent = MAX (font->ascent, font_structs[i]->ascent);
font->descent = MAX (font->descent, font_structs[i]->descent);
}
private->names = NULL;
gdk_font_hash_insert (GDK_FONT_FONTSET, font, fontset_name);
return font;
}
}
GdkFont*
gdk_font_ref (GdkFont *font)
{
@ -220,304 +50,35 @@ gdk_font_unref (GdkFont *font)
private->ref_count -= 1;
if (private->ref_count == 0)
{
gdk_font_hash_remove (font->type, font);
switch (font->type)
{
case GDK_FONT_FONT:
gdk_xid_table_remove (((XFontStruct *) private->xfont)->fid);
XFreeFont (private->xdisplay, (XFontStruct *) private->xfont);
break;
case GDK_FONT_FONTSET:
XFreeFontSet (private->xdisplay, (XFontSet) private->xfont);
break;
default:
g_error ("unknown font type.");
break;
}
g_free (font);
}
}
gint
gdk_font_id (const GdkFont *font)
{
const GdkFontPrivate *font_private;
g_return_val_if_fail (font != NULL, 0);
font_private = (const GdkFontPrivate*) font;
if (font->type == GDK_FONT_FONT)
{
return ((XFontStruct *) font_private->xfont)->fid;
}
else
{
return 0;
}
}
gint
gdk_font_equal (const GdkFont *fonta,
const GdkFont *fontb)
{
const GdkFontPrivate *privatea;
const GdkFontPrivate *privateb;
g_return_val_if_fail (fonta != NULL, FALSE);
g_return_val_if_fail (fontb != NULL, FALSE);
privatea = (const GdkFontPrivate*) fonta;
privateb = (const GdkFontPrivate*) fontb;
if (fonta->type == GDK_FONT_FONT && fontb->type == GDK_FONT_FONT)
{
return (((XFontStruct *) privatea->xfont)->fid ==
((XFontStruct *) privateb->xfont)->fid);
}
else if (fonta->type == GDK_FONT_FONTSET && fontb->type == GDK_FONT_FONTSET)
{
gchar *namea, *nameb;
namea = XBaseFontNameListOfFontSet((XFontSet) privatea->xfont);
nameb = XBaseFontNameListOfFontSet((XFontSet) privateb->xfont);
return (strcmp(namea, nameb) == 0);
}
else
/* fontset != font */
return 0;
_gdk_font_destroy (font);
}
gint
gdk_string_width (GdkFont *font,
const gchar *string)
{
GdkFontPrivate *font_private;
gint width;
XFontStruct *xfont;
XFontSet fontset;
g_return_val_if_fail (font != NULL, -1);
g_return_val_if_fail (string != NULL, -1);
font_private = (GdkFontPrivate*) font;
switch (font->type)
{
case GDK_FONT_FONT:
xfont = (XFontStruct *) font_private->xfont;
if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))
{
width = XTextWidth (xfont, string, strlen (string));
}
else
{
width = XTextWidth16 (xfont, (XChar2b *) string, strlen (string) / 2);
}
break;
case GDK_FONT_FONTSET:
fontset = (XFontSet) font_private->xfont;
width = XmbTextEscapement (fontset, string, strlen(string));
break;
default:
width = 0;
return gdk_text_width (font, string, _gdk_font_strlen (font, string));
}
return width;
}
gint
gdk_text_width (GdkFont *font,
const gchar *text,
gint text_length)
{
GdkFontPrivate *private;
gint width;
XFontStruct *xfont;
XFontSet fontset;
g_return_val_if_fail (font != NULL, -1);
g_return_val_if_fail (text != NULL, -1);
private = (GdkFontPrivate*) font;
switch (font->type)
{
case GDK_FONT_FONT:
xfont = (XFontStruct *) private->xfont;
if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))
{
width = XTextWidth (xfont, text, text_length);
}
else
{
width = XTextWidth16 (xfont, (XChar2b *) text, text_length / 2);
}
break;
case GDK_FONT_FONTSET:
fontset = (XFontSet) private->xfont;
width = XmbTextEscapement (fontset, text, text_length);
break;
default:
width = 0;
}
return width;
}
gint
gdk_text_width_wc (GdkFont *font,
const GdkWChar *text,
gint text_length)
{
GdkFontPrivate *private;
gint width;
XFontStruct *xfont;
XFontSet fontset;
g_return_val_if_fail (font != NULL, -1);
g_return_val_if_fail (text != NULL, -1);
private = (GdkFontPrivate*) font;
switch (font->type)
{
case GDK_FONT_FONT:
xfont = (XFontStruct *) private->xfont;
if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))
{
gchar *text_8bit;
gint i;
text_8bit = g_new (gchar, text_length);
for (i=0; i<text_length; i++) text_8bit[i] = text[i];
width = XTextWidth (xfont, text_8bit, text_length);
g_free (text_8bit);
}
else
{
width = 0;
}
break;
case GDK_FONT_FONTSET:
if (sizeof(GdkWChar) == sizeof(wchar_t))
{
fontset = (XFontSet) private->xfont;
width = XwcTextEscapement (fontset, (wchar_t *)text, text_length);
}
else
{
wchar_t *text_wchar;
gint i;
fontset = (XFontSet) private->xfont;
text_wchar = g_new(wchar_t, text_length);
for (i=0; i<text_length; i++) text_wchar[i] = text[i];
width = XwcTextEscapement (fontset, text_wchar, text_length);
g_free (text_wchar);
}
break;
default:
width = 0;
}
return width;
}
/* Problem: What if a character is a 16 bits character ?? */
gint
gdk_char_width (GdkFont *font,
gchar character)
{
GdkFontPrivate *private;
XCharStruct *chars;
gint width;
guint ch = character & 0xff; /* get rid of sign-extension */
XFontStruct *xfont;
XFontSet fontset;
g_return_val_if_fail (font != NULL, -1);
private = (GdkFontPrivate*) font;
switch (font->type)
{
case GDK_FONT_FONT:
/* only 8 bits characters are considered here */
xfont = (XFontStruct *) private->xfont;
if ((xfont->min_byte1 == 0) &&
(xfont->max_byte1 == 0) &&
(ch >= xfont->min_char_or_byte2) &&
(ch <= xfont->max_char_or_byte2))
{
chars = xfont->per_char;
if (chars)
width = chars[ch - xfont->min_char_or_byte2].width;
else
width = xfont->min_bounds.width;
}
else
{
width = XTextWidth (xfont, &character, 1);
}
break;
case GDK_FONT_FONTSET:
fontset = (XFontSet) private->xfont;
width = XmbTextEscapement (fontset, &character, 1) ;
break;
default:
width = 0;
}
return width;
return gdk_text_width (font, &character, 1);
}
gint
gdk_char_width_wc (GdkFont *font,
GdkWChar character)
{
GdkFontPrivate *private;
XCharStruct *chars;
gint width;
guint ch = character & 0xff; /* get rid of sign-extension */
XFontStruct *xfont;
XFontSet fontset;
g_return_val_if_fail (font != NULL, -1);
private = (GdkFontPrivate*) font;
switch (font->type)
{
case GDK_FONT_FONT:
/* only 8 bits characters are considered here */
xfont = (XFontStruct *) private->xfont;
if ((xfont->min_byte1 == 0) &&
(xfont->max_byte1 == 0) &&
(ch >= xfont->min_char_or_byte2) &&
(ch <= xfont->max_char_or_byte2))
{
chars = xfont->per_char;
if (chars)
width = chars[ch - xfont->min_char_or_byte2].width;
else
width = xfont->min_bounds.width;
}
else
{
char ch2 = character;
width = XTextWidth (xfont, &ch2, 1);
}
break;
case GDK_FONT_FONTSET:
fontset = (XFontSet) private->xfont;
{
wchar_t char_wc = character;
width = XwcTextEscapement (fontset, &char_wc, 1) ;
}
break;
default:
width = 0;
}
return width;
return gdk_text_width_wc (font, &character, 1);
}
gint
@ -527,162 +88,7 @@ gdk_string_measure (GdkFont *font,
g_return_val_if_fail (font != NULL, -1);
g_return_val_if_fail (string != NULL, -1);
return gdk_text_measure (font, string, strlen (string));
}
void
gdk_text_extents (GdkFont *font,
const gchar *text,
gint text_length,
gint *lbearing,
gint *rbearing,
gint *width,
gint *ascent,
gint *descent)
{
GdkFontPrivate *private;
XCharStruct overall;
XFontStruct *xfont;
XFontSet fontset;
XRectangle ink, logical;
int direction;
int font_ascent;
int font_descent;
g_return_if_fail (font != NULL);
g_return_if_fail (text != NULL);
private = (GdkFontPrivate*) font;
switch (font->type)
{
case GDK_FONT_FONT:
xfont = (XFontStruct *) private->xfont;
if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))
{
XTextExtents (xfont, text, text_length,
&direction, &font_ascent, &font_descent,
&overall);
}
else
{
XTextExtents16 (xfont, (XChar2b *) text, text_length / 2,
&direction, &font_ascent, &font_descent,
&overall);
}
if (lbearing)
*lbearing = overall.lbearing;
if (rbearing)
*rbearing = overall.rbearing;
if (width)
*width = overall.width;
if (ascent)
*ascent = overall.ascent;
if (descent)
*descent = overall.descent;
break;
case GDK_FONT_FONTSET:
fontset = (XFontSet) private->xfont;
XmbTextExtents (fontset, text, text_length, &ink, &logical);
if (lbearing)
*lbearing = ink.x;
if (rbearing)
*rbearing = ink.x + ink.width;
if (width)
*width = logical.width;
if (ascent)
*ascent = -ink.y;
if (descent)
*descent = ink.y + ink.height;
break;
}
}
void
gdk_text_extents_wc (GdkFont *font,
const GdkWChar *text,
gint text_length,
gint *lbearing,
gint *rbearing,
gint *width,
gint *ascent,
gint *descent)
{
GdkFontPrivate *private;
XCharStruct overall;
XFontStruct *xfont;
XFontSet fontset;
XRectangle ink, logical;
int direction;
int font_ascent;
int font_descent;
g_return_if_fail (font != NULL);
g_return_if_fail (text != NULL);
private = (GdkFontPrivate*) font;
switch (font->type)
{
case GDK_FONT_FONT:
{
gchar *text_8bit;
gint i;
xfont = (XFontStruct *) private->xfont;
g_return_if_fail ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0));
text_8bit = g_new (gchar, text_length);
for (i=0; i<text_length; i++)
text_8bit[i] = text[i];
XTextExtents (xfont, text_8bit, text_length,
&direction, &font_ascent, &font_descent,
&overall);
g_free (text_8bit);
if (lbearing)
*lbearing = overall.lbearing;
if (rbearing)
*rbearing = overall.rbearing;
if (width)
*width = overall.width;
if (ascent)
*ascent = overall.ascent;
if (descent)
*descent = overall.descent;
break;
}
case GDK_FONT_FONTSET:
fontset = (XFontSet) private->xfont;
if (sizeof(GdkWChar) == sizeof(wchar_t))
XwcTextExtents (fontset, (wchar_t *)text, text_length, &ink, &logical);
else
{
wchar_t *text_wchar;
gint i;
text_wchar = g_new (wchar_t, text_length);
for (i = 0; i < text_length; i++)
text_wchar[i] = text[i];
XwcTextExtents (fontset, text_wchar, text_length, &ink, &logical);
g_free (text_wchar);
}
if (lbearing)
*lbearing = ink.x;
if (rbearing)
*rbearing = ink.x + ink.width;
if (width)
*width = logical.width;
if (ascent)
*ascent = -ink.y;
if (descent)
*descent = ink.y + ink.height;
break;
}
return gdk_text_measure (font, string, _gdk_font_strlen (font, string));
}
void
@ -697,7 +103,7 @@ gdk_string_extents (GdkFont *font,
g_return_if_fail (font != NULL);
g_return_if_fail (string != NULL);
gdk_text_extents (font, string, strlen (string),
gdk_text_extents (font, string, _gdk_font_strlen (font, string),
lbearing, rbearing, width, ascent, descent);
}
@ -707,50 +113,14 @@ gdk_text_measure (GdkFont *font,
const gchar *text,
gint text_length)
{
GdkFontPrivate *private;
XCharStruct overall;
XFontStruct *xfont;
XFontSet fontset;
XRectangle ink, log;
int direction;
int font_ascent;
int font_descent;
gint width;
gint rbearing;
g_return_val_if_fail (font != NULL, -1);
g_return_val_if_fail (text != NULL, -1);
private = (GdkFontPrivate*) font;
switch (font->type)
{
case GDK_FONT_FONT:
xfont = (XFontStruct *) private->xfont;
if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))
{
XTextExtents (xfont, text, text_length,
&direction, &font_ascent, &font_descent,
&overall);
gdk_text_extents (font, text, text_length, NULL, &rbearing, NULL, NULL, NULL);
return rbearing;
}
else
{
XTextExtents16 (xfont, (XChar2b *) text, text_length / 2,
&direction, &font_ascent, &font_descent,
&overall);
}
width = overall.rbearing;
break;
case GDK_FONT_FONTSET:
fontset = (XFontSet) private->xfont;
XmbTextExtents (fontset, text, text_length, &ink, &log);
width = ink.x + ink.width;
break;
default:
width = 0;
}
return width;
}
gint
gdk_char_measure (GdkFont *font,
gchar character)
@ -767,7 +137,7 @@ gdk_string_height (GdkFont *font,
g_return_val_if_fail (font != NULL, -1);
g_return_val_if_fail (string != NULL, -1);
return gdk_text_height (font, string, strlen (string));
return gdk_text_height (font, string, _gdk_font_strlen (font, string));
}
gint
@ -775,48 +145,13 @@ gdk_text_height (GdkFont *font,
const gchar *text,
gint text_length)
{
GdkFontPrivate *private;
XCharStruct overall;
XFontStruct *xfont;
XFontSet fontset;
XRectangle ink, log;
int direction;
int font_ascent;
int font_descent;
gint height;
gint ascent, descent;
g_return_val_if_fail (font != NULL, -1);
g_return_val_if_fail (text != NULL, -1);
private = (GdkFontPrivate*) font;
switch (font->type)
{
case GDK_FONT_FONT:
xfont = (XFontStruct *) private->xfont;
if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))
{
XTextExtents (xfont, text, text_length,
&direction, &font_ascent, &font_descent,
&overall);
}
else
{
XTextExtents16 (xfont, (XChar2b *) text, text_length / 2,
&direction, &font_ascent, &font_descent,
&overall);
}
height = overall.ascent + overall.descent;
break;
case GDK_FONT_FONTSET:
fontset = (XFontSet) private->xfont;
XmbTextExtents (fontset, text, text_length, &ink, &log);
height = log.height;
break;
default:
height = 0;
}
return height;
gdk_text_extents (font, text, text_length, NULL, NULL, NULL, &ascent, &descent);
return ascent + descent;
}
gint

View File

@ -25,247 +25,48 @@
*/
#include <string.h>
#include <X11/Xlib.h>
#include "gdkgc.h"
#include "gdkprivate.h"
#include "gdkx.h"
GdkGC*
gdk_gc_new (GdkWindow *window)
gdk_gc_alloc (void)
{
return gdk_gc_new_with_values (window, NULL, 0);
GdkGCPrivate *private;
private = g_new (GdkGCPrivate, 1);
private->ref_count = 1;
private->klass = NULL;
private->klass = NULL;
private->klass_data = NULL;
return (GdkGC *)private;
}
GdkGC*
gdk_gc_new_with_values (GdkWindow *window,
gdk_gc_new (GdkDrawable *drawable)
{
g_return_val_if_fail (drawable != NULL, NULL);
if (GDK_DRAWABLE_DESTROYED (drawable))
return NULL;
return gdk_gc_new_with_values (drawable, NULL, 0);
}
GdkGC*
gdk_gc_new_with_values (GdkDrawable *drawable,
GdkGCValues *values,
GdkGCValuesMask values_mask)
{
GdkGC *gc;
GdkGCPrivate *private;
Window xwindow;
XGCValues xvalues;
unsigned long xvalues_mask;
g_return_val_if_fail (drawable != NULL, NULL);
g_return_val_if_fail (window != NULL, NULL);
if (GDK_DRAWABLE_DESTROYED (window))
if (GDK_DRAWABLE_DESTROYED (drawable))
return NULL;
private = g_new (GdkGCPrivate, 1);
gc = (GdkGC*) private;
xwindow = GDK_DRAWABLE_XID (window);
private->xdisplay = GDK_DRAWABLE_XDISPLAY (window);
private->ref_count = 1;
xvalues.function = GXcopy;
xvalues.fill_style = FillSolid;
xvalues.arc_mode = ArcPieSlice;
xvalues.subwindow_mode = ClipByChildren;
xvalues.graphics_exposures = True;
xvalues_mask = GCFunction | GCFillStyle | GCArcMode | GCSubwindowMode | GCGraphicsExposures;
if (values_mask & GDK_GC_FOREGROUND)
{
xvalues.foreground = values->foreground.pixel;
xvalues_mask |= GCForeground;
}
if (values_mask & GDK_GC_BACKGROUND)
{
xvalues.background = values->background.pixel;
xvalues_mask |= GCBackground;
}
if ((values_mask & GDK_GC_FONT) && (values->font->type == GDK_FONT_FONT))
{
xvalues.font = ((XFontStruct *) ((GdkFontPrivate*) values->font)->xfont)->fid;
xvalues_mask |= GCFont;
}
if (values_mask & GDK_GC_FUNCTION)
{
switch (values->function)
{
case GDK_COPY:
xvalues.function = GXcopy;
break;
case GDK_INVERT:
xvalues.function = GXinvert;
break;
case GDK_XOR:
xvalues.function = GXxor;
break;
case GDK_CLEAR:
xvalues.function = GXclear;
break;
case GDK_AND:
xvalues.function = GXand;
break;
case GDK_AND_REVERSE:
xvalues.function = GXandReverse;
break;
case GDK_AND_INVERT:
xvalues.function = GXandInverted;
break;
case GDK_NOOP:
xvalues.function = GXnoop;
break;
case GDK_OR:
xvalues.function = GXor;
break;
case GDK_EQUIV:
xvalues.function = GXequiv;
break;
case GDK_OR_REVERSE:
xvalues.function = GXorReverse;
break;
case GDK_COPY_INVERT:
xvalues.function = GXcopyInverted;
break;
case GDK_OR_INVERT:
xvalues.function = GXorInverted;
break;
case GDK_NAND:
xvalues.function = GXnand;
break;
case GDK_SET:
xvalues.function = GXset;
break;
}
xvalues_mask |= GCFunction;
}
if (values_mask & GDK_GC_FILL)
{
switch (values->fill)
{
case GDK_SOLID:
xvalues.fill_style = FillSolid;
break;
case GDK_TILED:
xvalues.fill_style = FillTiled;
break;
case GDK_STIPPLED:
xvalues.fill_style = FillStippled;
break;
case GDK_OPAQUE_STIPPLED:
xvalues.fill_style = FillOpaqueStippled;
break;
}
xvalues_mask |= GCFillStyle;
}
if (values_mask & GDK_GC_TILE)
{
xvalues.tile = GDK_DRAWABLE_XID (values->tile);
xvalues_mask |= GCTile;
}
if (values_mask & GDK_GC_STIPPLE)
{
xvalues.stipple = GDK_DRAWABLE_XID (values->stipple);
xvalues_mask |= GCStipple;
}
if (values_mask & GDK_GC_CLIP_MASK)
{
xvalues.clip_mask = GDK_DRAWABLE_XID (values->clip_mask);
xvalues_mask |= GCClipMask;
}
if (values_mask & GDK_GC_SUBWINDOW)
{
xvalues.subwindow_mode = values->subwindow_mode;
xvalues_mask |= GCSubwindowMode;
}
if (values_mask & GDK_GC_TS_X_ORIGIN)
{
xvalues.ts_x_origin = values->ts_x_origin;
xvalues_mask |= GCTileStipXOrigin;
}
if (values_mask & GDK_GC_TS_Y_ORIGIN)
{
xvalues.ts_y_origin = values->ts_y_origin;
xvalues_mask |= GCTileStipYOrigin;
}
if (values_mask & GDK_GC_CLIP_X_ORIGIN)
{
xvalues.clip_x_origin = values->clip_x_origin;
xvalues_mask |= GCClipXOrigin;
}
if (values_mask & GDK_GC_CLIP_Y_ORIGIN)
{
xvalues.clip_y_origin = values->clip_y_origin;
xvalues_mask |= GCClipYOrigin;
}
if (values_mask & GDK_GC_EXPOSURES)
xvalues.graphics_exposures = values->graphics_exposures;
else
xvalues.graphics_exposures = False;
xvalues_mask |= GCGraphicsExposures;
if (values_mask & GDK_GC_LINE_WIDTH)
{
xvalues.line_width = values->line_width;
xvalues_mask |= GCLineWidth;
}
if (values_mask & GDK_GC_LINE_STYLE)
{
switch (values->line_style)
{
case GDK_LINE_SOLID:
xvalues.line_style = LineSolid;
break;
case GDK_LINE_ON_OFF_DASH:
xvalues.line_style = LineOnOffDash;
break;
case GDK_LINE_DOUBLE_DASH:
xvalues.line_style = LineDoubleDash;
break;
}
xvalues_mask |= GCLineStyle;
}
if (values_mask & GDK_GC_CAP_STYLE)
{
switch (values->cap_style)
{
case GDK_CAP_NOT_LAST:
xvalues.cap_style = CapNotLast;
break;
case GDK_CAP_BUTT:
xvalues.cap_style = CapButt;
break;
case GDK_CAP_ROUND:
xvalues.cap_style = CapRound;
break;
case GDK_CAP_PROJECTING:
xvalues.cap_style = CapProjecting;
break;
}
xvalues_mask |= GCCapStyle;
}
if (values_mask & GDK_GC_JOIN_STYLE)
{
switch (values->join_style)
{
case GDK_JOIN_MITER:
xvalues.join_style = JoinMiter;
break;
case GDK_JOIN_ROUND:
xvalues.join_style = JoinRound;
break;
case GDK_JOIN_BEVEL:
xvalues.join_style = JoinBevel;
break;
}
xvalues_mask |= GCJoinStyle;
}
private->xgc = XCreateGC (private->xdisplay, xwindow, xvalues_mask, &xvalues);
return gc;
}
void
gdk_gc_destroy (GdkGC *gc)
{
gdk_gc_unref (gc);
return ((GdkDrawablePrivate *)drawable)->klass->create_gc (drawable,
values,
values_mask);
}
GdkGC *
@ -287,332 +88,118 @@ gdk_gc_unref (GdkGC *gc)
g_return_if_fail (gc != NULL);
g_return_if_fail (private->ref_count > 0);
if (private->ref_count > 1)
private->ref_count -= 1;
else
{
XFreeGC (private->xdisplay, private->xgc);
memset (gc, 0, sizeof (GdkGCPrivate));
g_free (gc);
}
private->ref_count--;
if (private->ref_count == 0)
private->klass->destroy (gc);
}
void
gdk_gc_get_values (GdkGC *gc,
GdkGCValues *values)
{
GdkGCPrivate *private;
XGCValues xvalues;
g_return_if_fail (gc != NULL);
g_return_if_fail (values != NULL);
private = (GdkGCPrivate*) gc;
if (XGetGCValues (private->xdisplay, private->xgc,
GCForeground | GCBackground | GCFont |
GCFunction | GCTile | GCStipple | /* GCClipMask | */
GCSubwindowMode | GCGraphicsExposures |
GCTileStipXOrigin | GCTileStipYOrigin |
GCClipXOrigin | GCClipYOrigin |
GCLineWidth | GCLineStyle | GCCapStyle |
GCFillStyle | GCJoinStyle, &xvalues))
{
values->foreground.pixel = xvalues.foreground;
values->background.pixel = xvalues.background;
values->font = gdk_font_lookup (xvalues.font);
switch (xvalues.function)
{
case GXcopy:
values->function = GDK_COPY;
break;
case GXinvert:
values->function = GDK_INVERT;
break;
case GXxor:
values->function = GDK_XOR;
break;
case GXclear:
values->function = GDK_CLEAR;
break;
case GXand:
values->function = GDK_AND;
break;
case GXandReverse:
values->function = GDK_AND_REVERSE;
break;
case GXandInverted:
values->function = GDK_AND_INVERT;
break;
case GXnoop:
values->function = GDK_NOOP;
break;
case GXor:
values->function = GDK_OR;
break;
case GXequiv:
values->function = GDK_EQUIV;
break;
case GXorReverse:
values->function = GDK_OR_REVERSE;
break;
case GXcopyInverted:
values->function =GDK_COPY_INVERT;
break;
case GXorInverted:
values->function = GDK_OR_INVERT;
break;
case GXnand:
values->function = GDK_NAND;
break;
case GXset:
values->function = GDK_SET;
break;
((GdkGCPrivate *)gc)->klass->get_values (gc, values);
}
switch (xvalues.fill_style)
void
gdk_gc_set_values (GdkGC *gc,
GdkGCValues *values,
GdkGCValuesMask values_mask)
{
case FillSolid:
values->fill = GDK_SOLID;
break;
case FillTiled:
values->fill = GDK_TILED;
break;
case FillStippled:
values->fill = GDK_STIPPLED;
break;
case FillOpaqueStippled:
values->fill = GDK_OPAQUE_STIPPLED;
break;
}
g_return_if_fail (gc != NULL);
g_return_if_fail (values != NULL);
values->tile = gdk_pixmap_lookup (xvalues.tile);
values->stipple = gdk_pixmap_lookup (xvalues.stipple);
values->clip_mask = NULL;
values->subwindow_mode = xvalues.subwindow_mode;
values->ts_x_origin = xvalues.ts_x_origin;
values->ts_y_origin = xvalues.ts_y_origin;
values->clip_x_origin = xvalues.clip_x_origin;
values->clip_y_origin = xvalues.clip_y_origin;
values->graphics_exposures = xvalues.graphics_exposures;
values->line_width = xvalues.line_width;
switch (xvalues.line_style)
{
case LineSolid:
values->line_style = GDK_LINE_SOLID;
break;
case LineOnOffDash:
values->line_style = GDK_LINE_ON_OFF_DASH;
break;
case LineDoubleDash:
values->line_style = GDK_LINE_DOUBLE_DASH;
break;
}
switch (xvalues.cap_style)
{
case CapNotLast:
values->cap_style = GDK_CAP_NOT_LAST;
break;
case CapButt:
values->cap_style = GDK_CAP_BUTT;
break;
case CapRound:
values->cap_style = GDK_CAP_ROUND;
break;
case CapProjecting:
values->cap_style = GDK_CAP_PROJECTING;
break;
}
switch (xvalues.join_style)
{
case JoinMiter:
values->join_style = GDK_JOIN_MITER;
break;
case JoinRound:
values->join_style = GDK_JOIN_ROUND;
break;
case JoinBevel:
values->join_style = GDK_JOIN_BEVEL;
break;
}
}
else
{
memset (values, 0, sizeof (GdkGCValues));
}
((GdkGCPrivate *)gc)->klass->set_values (gc, values, values_mask);
}
void
gdk_gc_set_foreground (GdkGC *gc,
GdkColor *color)
{
GdkGCPrivate *private;
GdkGCValues values;
g_return_if_fail (gc != NULL);
g_return_if_fail (color != NULL);
private = (GdkGCPrivate*) gc;
XSetForeground (private->xdisplay, private->xgc, color->pixel);
values.foreground = *color;
gdk_gc_set_values (gc, &values, GDK_GC_FOREGROUND);
}
void
gdk_gc_set_background (GdkGC *gc,
GdkColor *color)
{
GdkGCPrivate *private;
GdkGCValues values;
g_return_if_fail (gc != NULL);
g_return_if_fail (color != NULL);
private = (GdkGCPrivate*) gc;
XSetBackground (private->xdisplay, private->xgc, color->pixel);
values.background = *color;
gdk_gc_set_values (gc, &values, GDK_GC_BACKGROUND);
}
void
gdk_gc_set_font (GdkGC *gc,
GdkFont *font)
{
GdkGCPrivate *gc_private;
GdkFontPrivate *font_private;
GdkGCValues values;
g_return_if_fail (gc != NULL);
g_return_if_fail (font != NULL);
if (font->type == GDK_FONT_FONT)
{
gc_private = (GdkGCPrivate*) gc;
font_private = (GdkFontPrivate*) font;
XSetFont (gc_private->xdisplay, gc_private->xgc,
((XFontStruct *) font_private->xfont)->fid);
}
values.font = font;
gdk_gc_set_values (gc, &values, GDK_GC_FONT);
}
void
gdk_gc_set_function (GdkGC *gc,
GdkFunction function)
{
GdkGCPrivate *private;
GdkGCValues values;
g_return_if_fail (gc != NULL);
private = (GdkGCPrivate*) gc;
switch (function)
{
case GDK_COPY:
XSetFunction (private->xdisplay, private->xgc, GXcopy);
break;
case GDK_INVERT:
XSetFunction (private->xdisplay, private->xgc, GXinvert);
break;
case GDK_XOR:
XSetFunction (private->xdisplay, private->xgc, GXxor);
break;
case GDK_CLEAR:
XSetFunction (private->xdisplay, private->xgc, GXclear);
break;
case GDK_AND:
XSetFunction (private->xdisplay, private->xgc, GXand);
break;
case GDK_AND_REVERSE:
XSetFunction (private->xdisplay, private->xgc, GXandReverse);
break;
case GDK_AND_INVERT:
XSetFunction (private->xdisplay, private->xgc, GXandInverted);
break;
case GDK_NOOP:
XSetFunction (private->xdisplay, private->xgc, GXnoop);
break;
case GDK_OR:
XSetFunction (private->xdisplay, private->xgc, GXor);
break;
case GDK_EQUIV:
XSetFunction (private->xdisplay, private->xgc, GXequiv);
break;
case GDK_OR_REVERSE:
XSetFunction (private->xdisplay, private->xgc, GXorReverse);
break;
case GDK_COPY_INVERT:
XSetFunction (private->xdisplay, private->xgc, GXcopyInverted);
break;
case GDK_OR_INVERT:
XSetFunction (private->xdisplay, private->xgc, GXorInverted);
break;
case GDK_NAND:
XSetFunction (private->xdisplay, private->xgc, GXnand);
break;
case GDK_SET:
XSetFunction (private->xdisplay, private->xgc, GXset);
break;
}
values.function = function;
gdk_gc_set_values (gc, &values, GDK_GC_FUNCTION);
}
void
gdk_gc_set_fill (GdkGC *gc,
GdkFill fill)
{
GdkGCPrivate *private;
GdkGCValues values;
g_return_if_fail (gc != NULL);
private = (GdkGCPrivate*) gc;
switch (fill)
{
case GDK_SOLID:
XSetFillStyle (private->xdisplay, private->xgc, FillSolid);
break;
case GDK_TILED:
XSetFillStyle (private->xdisplay, private->xgc, FillTiled);
break;
case GDK_STIPPLED:
XSetFillStyle (private->xdisplay, private->xgc, FillStippled);
break;
case GDK_OPAQUE_STIPPLED:
XSetFillStyle (private->xdisplay, private->xgc, FillOpaqueStippled);
break;
}
values.fill = fill;
gdk_gc_set_values (gc, &values, GDK_GC_FILL);
}
void
gdk_gc_set_tile (GdkGC *gc,
GdkPixmap *tile)
{
GdkGCPrivate *private;
Pixmap pixmap;
GdkGCValues values;
g_return_if_fail (gc != NULL);
private = (GdkGCPrivate*) gc;
pixmap = None;
if (tile)
pixmap = GDK_DRAWABLE_XID (tile);
XSetTile (private->xdisplay, private->xgc, pixmap);
values.tile = tile;
gdk_gc_set_values (gc, &values, GDK_GC_TILE);
}
void
gdk_gc_set_stipple (GdkGC *gc,
GdkPixmap *stipple)
{
GdkGCPrivate *private;
Pixmap pixmap;
GdkGCValues values;
g_return_if_fail (gc != NULL);
private = (GdkGCPrivate*) gc;
pixmap = None;
if (stipple)
pixmap = GDK_DRAWABLE_XID (stipple);
XSetStipple (private->xdisplay, private->xgc, pixmap);
values.stipple = stipple;
gdk_gc_set_values (gc, &values, GDK_GC_STIPPLE);
}
void
@ -620,13 +207,15 @@ gdk_gc_set_ts_origin (GdkGC *gc,
gint x,
gint y)
{
GdkGCPrivate *private;
GdkGCValues values;
g_return_if_fail (gc != NULL);
private = (GdkGCPrivate*) gc;
values.ts_x_origin = x;
values.ts_x_origin = y;
XSetTSOrigin (private->xdisplay, private->xgc, x, y);
gdk_gc_set_values (gc, &values,
GDK_GC_TS_X_ORIGIN | GDK_GC_TS_Y_ORIGIN);
}
void
@ -634,105 +223,52 @@ gdk_gc_set_clip_origin (GdkGC *gc,
gint x,
gint y)
{
GdkGCPrivate *private;
GdkGCValues values;
g_return_if_fail (gc != NULL);
private = (GdkGCPrivate*) gc;
values.clip_x_origin = x;
values.clip_x_origin = y;
XSetClipOrigin (private->xdisplay, private->xgc, x, y);
gdk_gc_set_values (gc, &values,
GDK_GC_CLIP_X_ORIGIN | GDK_GC_CLIP_Y_ORIGIN);
}
void
gdk_gc_set_clip_mask (GdkGC *gc,
GdkBitmap *mask)
{
GdkGCPrivate *private;
Pixmap xmask;
GdkGCValues values;
g_return_if_fail (gc != NULL);
if (mask)
xmask = GDK_DRAWABLE_XID (mask);
else
xmask = None;
private = (GdkGCPrivate*) gc;
XSetClipMask (private->xdisplay, private->xgc, xmask);
values.clip_mask = mask;
gdk_gc_set_values (gc, &values, GDK_GC_CLIP_MASK);
}
void
gdk_gc_set_clip_rectangle (GdkGC *gc,
GdkRectangle *rectangle)
{
GdkGCPrivate *private;
XRectangle xrectangle;
g_return_if_fail (gc != NULL);
private = (GdkGCPrivate*) gc;
if (rectangle)
{
xrectangle.x = rectangle->x;
xrectangle.y = rectangle->y;
xrectangle.width = rectangle->width;
xrectangle.height = rectangle->height;
XSetClipRectangles (private->xdisplay, private->xgc, 0, 0,
&xrectangle, 1, Unsorted);
}
else
XSetClipMask (private->xdisplay, private->xgc, None);
}
void
gdk_gc_set_clip_region (GdkGC *gc,
GdkRegion *region)
{
GdkGCPrivate *private;
g_return_if_fail (gc != NULL);
private = (GdkGCPrivate*) gc;
if (region)
{
GdkRegionPrivate *region_private;
region_private = (GdkRegionPrivate*) region;
XSetRegion (private->xdisplay, private->xgc, region_private->xregion);
}
else
XSetClipMask (private->xdisplay, private->xgc, None);
}
void
gdk_gc_set_subwindow (GdkGC *gc,
GdkSubwindowMode mode)
{
GdkGCPrivate *private;
GdkGCValues values;
g_return_if_fail (gc != NULL);
private = (GdkGCPrivate*) gc;
XSetSubwindowMode (private->xdisplay, private->xgc, mode);
values.subwindow_mode = mode;
gdk_gc_set_values (gc, &values, GDK_GC_SUBWINDOW);
}
void
gdk_gc_set_exposures (GdkGC *gc,
gint exposures)
gboolean exposures)
{
GdkGCPrivate *private;
GdkGCValues values;
g_return_if_fail (gc != NULL);
private = (GdkGCPrivate*) gc;
XSetGraphicsExposures (private->xdisplay, private->xgc, exposures);
values.graphics_exposures = exposures;
gdk_gc_set_values (gc, &values, GDK_GC_EXPOSURES);
}
void
@ -742,65 +278,18 @@ gdk_gc_set_line_attributes (GdkGC *gc,
GdkCapStyle cap_style,
GdkJoinStyle join_style)
{
GdkGCPrivate *private;
int xline_style;
int xcap_style;
int xjoin_style;
GdkGCValues values;
g_return_if_fail (gc != NULL);
values.line_width = line_width;
values.line_style = line_style;
values.cap_style = cap_style;
values.join_style = join_style;
private = (GdkGCPrivate*) gc;
switch (line_style)
{
case GDK_LINE_SOLID:
xline_style = LineSolid;
break;
case GDK_LINE_ON_OFF_DASH:
xline_style = LineOnOffDash;
break;
case GDK_LINE_DOUBLE_DASH:
xline_style = LineDoubleDash;
break;
default:
xline_style = None;
}
switch (cap_style)
{
case GDK_CAP_NOT_LAST:
xcap_style = CapNotLast;
break;
case GDK_CAP_BUTT:
xcap_style = CapButt;
break;
case GDK_CAP_ROUND:
xcap_style = CapRound;
break;
case GDK_CAP_PROJECTING:
xcap_style = CapProjecting;
break;
default:
xcap_style = None;
}
switch (join_style)
{
case GDK_JOIN_MITER:
xjoin_style = JoinMiter;
break;
case GDK_JOIN_ROUND:
xjoin_style = JoinRound;
break;
case GDK_JOIN_BEVEL:
xjoin_style = JoinBevel;
break;
default:
xjoin_style = None;
}
XSetLineAttributes (private->xdisplay, private->xgc, line_width,
xline_style, xcap_style, xjoin_style);
gdk_gc_set_values (gc, &values,
GDK_GC_LINE_WIDTH |
GDK_GC_LINE_STYLE |
GDK_GC_CAP_STYLE |
GDK_GC_JOIN_STYLE);
}
void
@ -809,24 +298,8 @@ gdk_gc_set_dashes (GdkGC *gc,
gchar dash_list[],
gint n)
{
GdkGCPrivate *private;
g_return_if_fail (gc != NULL);
g_return_if_fail (dash_list != NULL);
private = (GdkGCPrivate*) gc;
XSetDashes (private->xdisplay, private->xgc, dash_offset, dash_list, n);
}
void
gdk_gc_copy (GdkGC *dst_gc, GdkGC *src_gc)
{
GdkGCPrivate *dst_private, *src_private;
src_private = (GdkGCPrivate *) src_gc;
dst_private = (GdkGCPrivate *) dst_gc;
XCopyGC (src_private->xdisplay, src_private->xgc, ~((~1) << GCLastBit),
dst_private->xgc);
((GdkGCPrivate *)gc)->klass->set_dashes (gc, dash_offset, dash_list, n);
}

View File

@ -9,6 +9,7 @@ extern "C" {
#endif /* __cplusplus */
typedef struct _GdkGCValues GdkGCValues;
typedef struct _GdkGCClass GdkGCClass;
/* GC cap styles
* CapNotLast:
@ -154,13 +155,31 @@ struct _GdkGC
gint dummy_var;
};
GdkGC* gdk_gc_new (GdkWindow *window);
GdkGC* gdk_gc_new_with_values (GdkWindow *window,
struct _GdkGCClass
{
void (*destroy) (GdkGC *gc);
void (*get_values) (GdkGC *gc,
GdkGCValues *values);
void (*set_values) (GdkGC *gc,
GdkGCValues *values,
GdkGCValuesMask mask);
void (*set_dashes) (GdkGC *gc,
gint dash_offset,
gchar dash_list[],
gint n);
};
GdkGC *gdk_gc_new (GdkDrawable *drawable);
GdkGC *gdk_gc_alloc (void);
GdkGC *gdk_gc_new_with_values (GdkDrawable *drawable,
GdkGCValues *values,
GdkGCValuesMask values_mask);
void gdk_gc_init (GdkGC *gc,
GdkGCClass *klass);
GdkGC *gdk_gc_ref (GdkGC *gc);
void gdk_gc_unref (GdkGC *gc);
void gdk_gc_destroy (GdkGC *gc);
void gdk_gc_get_values (GdkGC *gc,
GdkGCValues *values);
void gdk_gc_set_foreground (GdkGC *gc,
@ -192,7 +211,7 @@ void gdk_gc_set_clip_region (GdkGC *gc,
void gdk_gc_set_subwindow (GdkGC *gc,
GdkSubwindowMode mode);
void gdk_gc_set_exposures (GdkGC *gc,
gint exposures);
gboolean exposures);
void gdk_gc_set_line_attributes (GdkGC *gc,
gint line_width,
GdkLineStyle line_style,

View File

@ -25,57 +25,17 @@
*/
#include <stdio.h>
#include <X11/Xlib.h>
#include "gdktypes.h"
#include "gdkprivate.h"
#include "config.h"
guint gdk_debug_flags = 0;
gint gdk_use_xshm = TRUE;
gchar *gdk_display_name = NULL;
Display *gdk_display = NULL;
gint gdk_screen;
Window gdk_root_window;
Window gdk_leader_window;
GdkWindowPrivate gdk_root_parent = { { NULL, }, NULL, };
Atom gdk_wm_delete_window;
Atom gdk_wm_take_focus;
Atom gdk_wm_protocols;
Atom gdk_wm_window_protocols[2];
Atom gdk_selection_property;
GdkDndCursorInfo gdk_dnd_cursorinfo = {None, None, NULL, NULL,
{0,0}, {0,0}, NULL};
GdkDndGlobals gdk_dnd = {None,None,None,
None,None,None,
None,
&gdk_dnd_cursorinfo,
NULL,
0,
FALSE, FALSE, FALSE,
None,
{0,0},
{0,0}, {0,0},
{0,0,0,0}, NULL, None, 0};
gchar *gdk_progclass = NULL;
GdkWindow *gdk_parent_root = NULL;
gint gdk_error_code = 0;
gint gdk_error_warnings = TRUE;
gint gdk_null_window_warnings = TRUE;
GList *gdk_default_filters = NULL;
gboolean gdk_xim_using; /* using XIM Protocol if TRUE */
#ifdef USE_XIM
GdkICPrivate *gdk_xim_ic; /* currently using IC */
#endif /* USE_XIM */
GdkWindow *gdk_xim_window; /* currently using Widow */
GdkWindowPrivate *gdk_xgrab_window = NULL; /* Window that currently holds the
* x pointer grab
*/
GMutex *gdk_threads_mutex = NULL; /* Global GDK lock */
GList *gdk_queued_events = NULL;
GList *gdk_queued_tail = NULL;
#ifdef USE_XIM
GdkICPrivate *gdk_xim_ic; /* currently using IC */
GdkWindow *gdk_xim_window; /* currently using Window */
#endif

File diff suppressed because it is too large Load Diff

View File

@ -24,485 +24,33 @@
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#include <config.h>
/* gcc -ansi -pedantic on GNU/Linux causes warnings and errors
* unless this is defined:
* warning: #warning "Files using this header must be compiled with _SVID_SOURCE or _XOPEN_SOURCE"
*/
#ifndef _XOPEN_SOURCE
# define _XOPEN_SOURCE 1
#endif
#include <stdlib.h>
#include <sys/types.h>
#if defined (HAVE_IPC_H) && defined (HAVE_SHM_H) && defined (HAVE_XSHM_H)
#define USE_SHM
#endif
#ifdef USE_SHM
#include <sys/ipc.h>
#include <sys/shm.h>
#endif /* USE_SHM */
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#ifdef USE_SHM
#include <X11/extensions/XShm.h>
#endif /* USE_SHM */
#include "gdk.h" /* For gdk_error_trap_* / gdk_flush_* */
#include "gdkimage.h"
#include "gdkprivate.h"
#include "gdkx.h"
static void gdk_image_put_normal (GdkDrawable *drawable,
GdkGC *gc,
GdkImage *image,
gint xsrc,
gint ysrc,
gint xdest,
gint ydest,
gint width,
gint height);
static void gdk_image_put_shared (GdkDrawable *drawable,
GdkGC *gc,
GdkImage *image,
gint xsrc,
gint ysrc,
gint xdest,
gint ydest,
gint width,
gint height);
static GList *image_list = NULL;
void
gdk_image_exit (void)
{
GdkImage *image;
while (image_list)
{
image = image_list->data;
gdk_image_destroy (image);
}
}
GdkImage *
gdk_image_new_bitmap(GdkVisual *visual, gpointer data, gint w, gint h)
/*
* Desc: create a new bitmap image
*/
gdk_image_ref (GdkImage *image)
{
Visual *xvisual;
GdkImage *image;
GdkImagePrivate *private;
private = g_new(GdkImagePrivate, 1);
image = (GdkImage *) private;
private->xdisplay = gdk_display;
private->image_put = gdk_image_put_normal;
image->type = GDK_IMAGE_NORMAL;
image->visual = visual;
image->width = w;
image->height = h;
image->depth = 1;
xvisual = ((GdkVisualPrivate*) visual)->xvisual;
private->ximage = XCreateImage(private->xdisplay, xvisual, 1, XYBitmap,
0, 0, w ,h, 8, 0);
private->ximage->data = data;
private->ximage->bitmap_bit_order = MSBFirst;
private->ximage->byte_order = MSBFirst;
image->byte_order = MSBFirst;
image->mem = private->ximage->data;
image->bpl = private->ximage->bytes_per_line;
image->bpp = 1;
return(image);
} /* gdk_image_new_bitmap() */
GdkImagePrivate *private = (GdkImagePrivate *)image;
static int
gdk_image_check_xshm(Display *display)
/*
* Desc: query the server for support for the MIT_SHM extension
* Return: 0 = not available
* 1 = shared XImage support available
* 2 = shared Pixmap support available also
*/
{
#ifdef USE_SHM
int major, minor, ignore;
Bool pixmaps;
g_return_val_if_fail (image != NULL, NULL);
if (XQueryExtension(display, "MIT-SHM", &ignore, &ignore, &ignore))
{
if (XShmQueryVersion(display, &major, &minor, &pixmaps )==True)
{
return (pixmaps==True) ? 2 : 1;
}
}
#endif /* USE_SHM */
return 0;
private->ref_count++;
}
void
gdk_image_init (void)
gdk_image_unref (GdkImage *image)
{
if (gdk_use_xshm)
{
if (!gdk_image_check_xshm (gdk_display))
{
gdk_use_xshm = False;
}
}
}
GdkImage*
gdk_image_new (GdkImageType type,
GdkVisual *visual,
gint width,
gint height)
{
GdkImage *image;
GdkImagePrivate *private;
#ifdef USE_SHM
XShmSegmentInfo *x_shm_info;
#endif /* USE_SHM */
Visual *xvisual;
switch (type)
{
case GDK_IMAGE_FASTEST:
image = gdk_image_new (GDK_IMAGE_SHARED, visual, width, height);
if (!image)
image = gdk_image_new (GDK_IMAGE_NORMAL, visual, width, height);
break;
default:
private = g_new (GdkImagePrivate, 1);
image = (GdkImage*) private;
private->xdisplay = gdk_display;
private->image_put = NULL;
image->type = type;
image->visual = visual;
image->width = width;
image->height = height;
image->depth = visual->depth;
xvisual = ((GdkVisualPrivate*) visual)->xvisual;
switch (type)
{
case GDK_IMAGE_SHARED:
#ifdef USE_SHM
if (gdk_use_xshm)
{
private->image_put = gdk_image_put_shared;
private->x_shm_info = g_new (XShmSegmentInfo, 1);
x_shm_info = private->x_shm_info;
private->ximage = XShmCreateImage (private->xdisplay, xvisual, visual->depth,
ZPixmap, NULL, x_shm_info, width, height);
if (private->ximage == NULL)
{
g_warning ("XShmCreateImage failed");
g_free (image);
gdk_use_xshm = False;
return NULL;
}
x_shm_info->shmid = shmget (IPC_PRIVATE,
private->ximage->bytes_per_line * private->ximage->height,
IPC_CREAT | 0777);
if (x_shm_info->shmid == -1)
{
g_warning ("shmget failed!");
XDestroyImage (private->ximage);
g_free (private->x_shm_info);
g_free (image);
gdk_use_xshm = False;
return NULL;
}
x_shm_info->readOnly = False;
x_shm_info->shmaddr = shmat (x_shm_info->shmid, 0, 0);
private->ximage->data = x_shm_info->shmaddr;
if (x_shm_info->shmaddr == (char*) -1)
{
g_warning ("shmat failed!");
XDestroyImage (private->ximage);
shmctl (x_shm_info->shmid, IPC_RMID, 0);
g_free (private->x_shm_info);
g_free (image);
return NULL;
}
gdk_error_trap_push ();
XShmAttach (private->xdisplay, x_shm_info);
XSync (private->xdisplay, False);
if (gdk_error_trap_pop ())
{
/* this is the common failure case so omit warning */
XDestroyImage (private->ximage);
shmdt (x_shm_info->shmaddr);
shmctl (x_shm_info->shmid, IPC_RMID, 0);
g_free (private->x_shm_info);
g_free (image);
gdk_use_xshm = False;
return NULL;
}
/* We mark the segment as destroyed so that when
* the last process detaches, it will be deleted.
* There is a small possibility of leaking if
* we die in XShmAttach. In theory, a signal handler
* could be set up.
*/
shmctl (x_shm_info->shmid, IPC_RMID, 0);
if (image)
image_list = g_list_prepend (image_list, image);
}
else
{
g_free (image);
return NULL;
}
break;
#else /* USE_SHM */
g_free (image);
return NULL;
#endif /* USE_SHM */
case GDK_IMAGE_NORMAL:
private->image_put = gdk_image_put_normal;
private->ximage = XCreateImage (private->xdisplay, xvisual, visual->depth,
ZPixmap, 0, 0, width, height, 32, 0);
/* Use malloc, not g_malloc here, because X will call free()
* on this data
*/
private->ximage->data = malloc (private->ximage->bytes_per_line *
private->ximage->height);
break;
case GDK_IMAGE_FASTEST:
g_assert_not_reached ();
}
if (image)
{
image->byte_order = private->ximage->byte_order;
image->mem = private->ximage->data;
image->bpl = private->ximage->bytes_per_line;
image->bpp = (private->ximage->bits_per_pixel + 7) / 8;
}
}
return image;
}
GdkImage*
gdk_image_get (GdkWindow *window,
gint x,
gint y,
gint width,
gint height)
{
GdkImage *image;
GdkImagePrivate *private;
g_return_val_if_fail (window != NULL, NULL);
if (GDK_DRAWABLE_DESTROYED (window))
return NULL;
private = g_new (GdkImagePrivate, 1);
image = (GdkImage*) private;
private->xdisplay = gdk_display;
private->image_put = gdk_image_put_normal;
private->ximage = XGetImage (private->xdisplay,
GDK_DRAWABLE_XID (window),
x, y, width, height,
AllPlanes, ZPixmap);
image->type = GDK_IMAGE_NORMAL;
image->visual = gdk_window_get_visual (window);
image->width = width;
image->height = height;
image->depth = private->ximage->depth;
image->mem = private->ximage->data;
image->bpl = private->ximage->bytes_per_line;
if (private->ximage->bits_per_pixel <= 8)
image->bpp = 1;
else if (private->ximage->bits_per_pixel <= 16)
image->bpp = 2;
else if (private->ximage->bits_per_pixel <= 24)
image->bpp = 3;
else
image->bpp = 4;
image->byte_order = private->ximage->byte_order;
return image;
}
guint32
gdk_image_get_pixel (GdkImage *image,
gint x,
gint y)
{
guint32 pixel;
GdkImagePrivate *private;
g_return_val_if_fail (image != NULL, 0);
private = (GdkImagePrivate *) image;
pixel = XGetPixel (private->ximage, x, y);
return pixel;
}
void
gdk_image_put_pixel (GdkImage *image,
gint x,
gint y,
guint32 pixel)
{
GdkImagePrivate *private;
GdkImagePrivate *private = (GdkImagePrivate *)image;
g_return_if_fail (image != NULL);
g_return_if_fail (private->ref_count > 0);
private = (GdkImagePrivate *) image;
pixel = XPutPixel (private->ximage, x, y, pixel);
private->ref_count--;
if (private->ref_count == 0)
private->klass->destroy (image);
}
void
gdk_image_destroy (GdkImage *image)
{
GdkImagePrivate *private;
#ifdef USE_SHM
XShmSegmentInfo *x_shm_info;
#endif /* USE_SHM */
g_return_if_fail (image != NULL);
private = (GdkImagePrivate*) image;
switch (image->type)
{
case GDK_IMAGE_NORMAL:
XDestroyImage (private->ximage);
break;
case GDK_IMAGE_SHARED:
#ifdef USE_SHM
gdk_flush();
XShmDetach (private->xdisplay, private->x_shm_info);
XDestroyImage (private->ximage);
x_shm_info = private->x_shm_info;
shmdt (x_shm_info->shmaddr);
g_free (private->x_shm_info);
image_list = g_list_remove (image_list, image);
#else /* USE_SHM */
g_error ("trying to destroy shared memory image when gdk was compiled without shared memory support");
#endif /* USE_SHM */
break;
case GDK_IMAGE_FASTEST:
g_assert_not_reached ();
}
g_free (image);
}
static void
gdk_image_put_normal (GdkDrawable *drawable,
GdkGC *gc,
GdkImage *image,
gint xsrc,
gint ysrc,
gint xdest,
gint ydest,
gint width,
gint height)
{
GdkImagePrivate *image_private;
GdkGCPrivate *gc_private;
g_return_if_fail (drawable != NULL);
g_return_if_fail (image != NULL);
g_return_if_fail (gc != NULL);
if (GDK_DRAWABLE_DESTROYED (drawable))
return;
image_private = (GdkImagePrivate*) image;
gc_private = (GdkGCPrivate*) gc;
g_return_if_fail (image->type == GDK_IMAGE_NORMAL);
XPutImage (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
gc_private->xgc, image_private->ximage,
xsrc, ysrc, xdest, ydest, width, height);
}
static void
gdk_image_put_shared (GdkDrawable *drawable,
GdkGC *gc,
GdkImage *image,
gint xsrc,
gint ysrc,
gint xdest,
gint ydest,
gint width,
gint height)
{
#ifdef USE_SHM
GdkImagePrivate *image_private;
GdkGCPrivate *gc_private;
g_return_if_fail (drawable != NULL);
g_return_if_fail (image != NULL);
g_return_if_fail (gc != NULL);
if (GDK_DRAWABLE_DESTROYED (drawable))
return;
image_private = (GdkImagePrivate*) image;
gc_private = (GdkGCPrivate*) gc;
g_return_if_fail (image->type == GDK_IMAGE_SHARED);
XShmPutImage (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
gc_private->xgc, image_private->ximage,
xsrc, ysrc, xdest, ydest, width, height, False);
#else /* USE_SHM */
g_error ("trying to draw shared memory image when gdk was compiled without shared memory support");
#endif /* USE_SHM */
}

View File

@ -42,7 +42,6 @@ struct _GdkImage
gpointer mem;
};
GdkImage* gdk_image_new_bitmap(GdkVisual *visual,
gpointer data,
gint width,
@ -56,12 +55,17 @@ GdkImage* gdk_image_bitmap_new(GdkImageType type,
GdkVisual *visual,
gint width,
gint height);
#endif
GdkImage* gdk_image_get (GdkDrawable *drawable,
gint x,
gint y,
gint width,
gint height);
GdkImage * gdk_image_ref (GdkImage *image);
void gdk_image_unref (GdkImage *image);
void gdk_image_put_pixel (GdkImage *image,
gint x,
gint y,
@ -69,7 +73,6 @@ void gdk_image_put_pixel (GdkImage *image,
guint32 gdk_image_get_pixel (GdkImage *image,
gint x,
gint y);
void gdk_image_destroy (GdkImage *image);
#ifdef __cplusplus

View File

@ -1,355 +0,0 @@
/* 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 <stdlib.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include "config.h"
#include "gdkx.h"
#include "gdkinput.h"
#include "gdkprivate.h"
#include "gdkinputprivate.h"
/* Forward declarations */
static gint gdk_input_enable_window (GdkWindow *window,
GdkDevicePrivate *gdkdev);
static gint gdk_input_disable_window (GdkWindow *window,
GdkDevicePrivate *gdkdev);
static GdkInputWindow *gdk_input_window_find (GdkWindow *window);
static GdkDevicePrivate *gdk_input_find_device (guint32 id);
/* Incorporate the specific routines depending on compilation options */
static const GdkAxisUse gdk_input_core_axes[] = { GDK_AXIS_X, GDK_AXIS_Y };
static const GdkDeviceInfo gdk_input_core_info =
{
GDK_CORE_POINTER,
"Core Pointer",
GDK_SOURCE_MOUSE,
GDK_MODE_SCREEN,
TRUE,
2,
gdk_input_core_axes
};
/* Global variables */
GdkInputVTable gdk_input_vtable;
/* information about network port and host for gxid daemon */
gchar *gdk_input_gxid_host;
gint gdk_input_gxid_port;
gint gdk_input_ignore_core;
/* Local variables */
static GList *gdk_input_devices;
static GList *gdk_input_windows;
#include "gdkinputnone.h"
#include "gdkinputcommon.h"
#include "gdkinputxfree.h"
#include "gdkinputgxi.h"
GList *
gdk_input_list_devices (void)
{
return gdk_input_devices;
}
void
gdk_input_set_source (guint32 deviceid, GdkInputSource source)
{
GdkDevicePrivate *gdkdev = gdk_input_find_device(deviceid);
g_return_if_fail (gdkdev != NULL);
gdkdev->info.source = source;
}
gint
gdk_input_set_mode (guint32 deviceid, GdkInputMode mode)
{
if (deviceid == GDK_CORE_POINTER)
return FALSE;
if (gdk_input_vtable.set_mode)
return gdk_input_vtable.set_mode(deviceid,mode);
else
return FALSE;
}
void
gdk_input_set_axes (guint32 deviceid, GdkAxisUse *axes)
{
if (deviceid != GDK_CORE_POINTER && gdk_input_vtable.set_axes)
gdk_input_vtable.set_axes (deviceid, axes);
}
void gdk_input_set_key (guint32 deviceid,
guint index,
guint keyval,
GdkModifierType modifiers)
{
if (deviceid != GDK_CORE_POINTER && gdk_input_vtable.set_key)
gdk_input_vtable.set_key (deviceid, index, keyval, modifiers);
}
GdkTimeCoord *
gdk_input_motion_events (GdkWindow *window,
guint32 deviceid,
guint32 start,
guint32 stop,
gint *nevents_return)
{
XTimeCoord *xcoords;
GdkTimeCoord *coords;
int i;
g_return_val_if_fail (window != NULL, NULL);
g_return_val_if_fail (GDK_IS_WINDOW (window), NULL);
if (GDK_DRAWABLE_DESTROYED (window))
return NULL;
if (deviceid == GDK_CORE_POINTER)
{
xcoords = XGetMotionEvents (GDK_DRAWABLE_XDISPLAY (window),
GDK_DRAWABLE_XID (window),
start, stop, nevents_return);
if (xcoords)
{
coords = g_new (GdkTimeCoord, *nevents_return);
for (i=0; i<*nevents_return; i++)
{
coords[i].time = xcoords[i].time;
coords[i].x = xcoords[i].x;
coords[i].y = xcoords[i].y;
coords[i].pressure = 0.5;
coords[i].xtilt = 0.0;
coords[i].ytilt = 0.0;
}
XFree (xcoords);
return coords;
}
else
return NULL;
}
else
{
if (gdk_input_vtable.motion_events)
{
return gdk_input_vtable.motion_events(window,
deviceid, start, stop,
nevents_return);
}
else
{
*nevents_return = 0;
return NULL;
}
}
}
static gint
gdk_input_enable_window (GdkWindow *window, GdkDevicePrivate *gdkdev)
{
if (gdk_input_vtable.enable_window)
return gdk_input_vtable.enable_window (window, gdkdev);
else
return TRUE;
}
static gint
gdk_input_disable_window (GdkWindow *window, GdkDevicePrivate *gdkdev)
{
if (gdk_input_vtable.disable_window)
return gdk_input_vtable.disable_window(window,gdkdev);
else
return TRUE;
}
static GdkInputWindow *
gdk_input_window_find(GdkWindow *window)
{
GList *tmp_list;
for (tmp_list=gdk_input_windows; tmp_list; tmp_list=tmp_list->next)
if (((GdkInputWindow *)(tmp_list->data))->window == window)
return (GdkInputWindow *)(tmp_list->data);
return NULL; /* Not found */
}
/* FIXME: this routine currently needs to be called between creation
and the corresponding configure event (because it doesn't get the
root_relative_geometry). This should work with
gtk_window_set_extension_events, but will likely fail in other
cases */
void
gdk_input_set_extension_events (GdkWindow *window, gint mask,
GdkExtensionMode mode)
{
GdkWindowPrivate *window_private;
GList *tmp_list;
GdkInputWindow *iw;
g_return_if_fail (window != NULL);
g_return_if_fail (GDK_IS_WINDOW (window));
window_private = (GdkWindowPrivate*) window;
if (GDK_DRAWABLE_DESTROYED (window))
return;
if (mode == GDK_EXTENSION_EVENTS_NONE)
mask = 0;
if (mask != 0)
{
iw = g_new(GdkInputWindow,1);
iw->window = window;
iw->mode = mode;
iw->obscuring = NULL;
iw->num_obscuring = 0;
iw->grabbed = FALSE;
gdk_input_windows = g_list_append(gdk_input_windows,iw);
window_private->extension_events = mask;
/* Add enter window events to the event mask */
/* FIXME, this is not needed for XINPUT_NONE */
gdk_window_set_events (window,
gdk_window_get_events (window) |
GDK_ENTER_NOTIFY_MASK);
}
else
{
iw = gdk_input_window_find (window);
if (iw)
{
gdk_input_windows = g_list_remove(gdk_input_windows,iw);
g_free(iw);
}
window_private->extension_events = 0;
}
for (tmp_list = gdk_input_devices; tmp_list; tmp_list = tmp_list->next)
{
GdkDevicePrivate *gdkdev = (GdkDevicePrivate *)(tmp_list->data);
if (gdkdev->info.deviceid != GDK_CORE_POINTER)
{
if (mask != 0 && gdkdev->info.mode != GDK_MODE_DISABLED
&& (gdkdev->info.has_cursor || mode == GDK_EXTENSION_EVENTS_ALL))
gdk_input_enable_window(window,gdkdev);
else
gdk_input_disable_window(window,gdkdev);
}
}
}
void
gdk_input_window_destroy (GdkWindow *window)
{
GdkInputWindow *input_window;
input_window = gdk_input_window_find (window);
g_return_if_fail (input_window != NULL);
gdk_input_windows = g_list_remove (gdk_input_windows,input_window);
g_free(input_window);
}
void
gdk_input_exit (void)
{
GList *tmp_list;
GdkDevicePrivate *gdkdev;
for (tmp_list = gdk_input_devices; tmp_list; tmp_list = tmp_list->next)
{
gdkdev = (GdkDevicePrivate *)(tmp_list->data);
if (gdkdev->info.deviceid != GDK_CORE_POINTER)
{
gdk_input_set_mode(gdkdev->info.deviceid,GDK_MODE_DISABLED);
g_free(gdkdev->info.name);
#ifndef XINPUT_NONE
g_free(gdkdev->axes);
#endif
g_free(gdkdev->info.axes);
g_free(gdkdev->info.keys);
g_free(gdkdev);
}
}
g_list_free(gdk_input_devices);
for (tmp_list = gdk_input_windows; tmp_list; tmp_list = tmp_list->next)
{
g_free(tmp_list->data);
}
g_list_free(gdk_input_windows);
}
static GdkDevicePrivate *
gdk_input_find_device(guint32 id)
{
GList *tmp_list = gdk_input_devices;
GdkDevicePrivate *gdkdev;
while (tmp_list)
{
gdkdev = (GdkDevicePrivate *)(tmp_list->data);
if (gdkdev->info.deviceid == id)
return gdkdev;
tmp_list = tmp_list->next;
}
return NULL;
}
void
gdk_input_window_get_pointer (GdkWindow *window,
guint32 deviceid,
gdouble *x,
gdouble *y,
gdouble *pressure,
gdouble *xtilt,
gdouble *ytilt,
GdkModifierType *mask)
{
if (gdk_input_vtable.get_pointer)
gdk_input_vtable.get_pointer (window, deviceid, x, y, pressure,
xtilt, ytilt, mask);
}

View File

@ -1,892 +0,0 @@
/* 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/.
*/
#if defined(XINPUT_GXI) || defined(XINPUT_XFREE)
/* Forward declarations */
static void gdk_input_get_root_relative_geometry (Display *dpy, Window w,
int *x_ret, int *y_ret,
int *width_ret,
int *height_ret);
static GdkDevicePrivate *gdk_input_device_new(XDeviceInfo *device,
gint include_core);
static void gdk_input_common_find_events(GdkWindow *window,
GdkDevicePrivate *gdkdev,
gint mask,
XEventClass *classes,
int *num_classes);
static void gdk_input_common_select_events(GdkWindow *window,
GdkDevicePrivate *gdkdev);
static void gdk_input_translate_coordinates(GdkDevicePrivate *gdkdev,
GdkInputWindow *input_window,
gint *axis_data,
gdouble *x, gdouble *y,
gdouble *pressure,
gdouble *xtilt, gdouble *ytilt);
static guint gdk_input_translate_state(guint state, guint device_state);
static gint gdk_input_common_init(gint include_core);
static gint gdk_input_common_other_event (GdkEvent *event,
XEvent *xevent,
GdkInputWindow *input_window,
GdkDevicePrivate *gdkdev);
static void gdk_input_common_set_axes (guint32 deviceid, GdkAxisUse *axes);
static GdkTimeCoord * gdk_input_common_motion_events (GdkWindow *window,
guint32 deviceid,
guint32 start,
guint32 stop,
gint *nevents_return);
static void gdk_input_common_get_pointer (GdkWindow *window,
guint32 deviceid,
gdouble *x,
gdouble *y,
gdouble *pressure,
gdouble *xtilt,
gdouble *ytilt,
GdkModifierType *mask);
#define GDK_MAX_DEVICE_CLASSES 13
/* Global variables */
static gint gdk_input_root_width;
static gint gdk_input_root_height;
static void
gdk_input_get_root_relative_geometry(Display *dpy, Window w, int *x_ret, int *y_ret,
int *width_ret, int *height_ret)
{
Window root,parent;
Window *children;
guint nchildren;
gint x,y;
guint width, height;
gint xc,yc;
guint widthc,heightc,border_widthc,depthc;
XQueryTree(dpy,w,&root,&parent,&children,&nchildren);
if (children) XFree(children);
XGetGeometry(dpy,w,&root,&x,&y,&width,&height,&border_widthc,
&depthc);
x += border_widthc;
y += border_widthc;
while (root != parent)
{
w = parent;
XQueryTree(dpy,w,&root,&parent,&children,&nchildren);
if (children) XFree(children);
XGetGeometry(dpy,w,&root,&xc,&yc,&widthc,&heightc,
&border_widthc,&depthc);
x += xc + border_widthc;
y += yc + border_widthc;
}
if (x_ret)
*x_ret = x;
if (y_ret)
*y_ret = y;
if (width_ret)
*width_ret = width;
if (height_ret)
*height_ret = height;
}
static GdkDevicePrivate *
gdk_input_device_new(XDeviceInfo *device, gint include_core)
{
GdkDevicePrivate *gdkdev;
gchar *tmp_name, *p;
XAnyClassPtr class;
gint i,j;
gdkdev = g_new(GdkDevicePrivate,1);
gdkdev->info.deviceid = device->id;
if (device->name[0]) {
gdkdev->info.name = g_new(char, strlen(device->name)+1);
strcpy(gdkdev->info.name,device->name);
} else {
/* XFree86 3.2 gives an empty name to the default core devices,
(fixed in 3.2A) */
gdkdev->info.name = g_strdup("pointer");
strcpy(gdkdev->info.name,"pointer");
gdkdev->info.source = GDK_SOURCE_MOUSE;
}
gdkdev->info.mode = GDK_MODE_DISABLED;
/* Try to figure out what kind of device this is by its name -
could invite a very, very, long list... Lowercase name
for comparison purposes */
tmp_name = g_strdup(gdkdev->info.name);
for (p = tmp_name; *p; p++)
{
if (*p >= 'A' && *p <= 'Z')
*p += 'a' - 'A';
}
if (!strcmp (tmp_name, "pointer"))
gdkdev->info.source = GDK_SOURCE_MOUSE;
else if (!strcmp (tmp_name, "wacom") ||
!strcmp (tmp_name, "pen"))
gdkdev->info.source = GDK_SOURCE_PEN;
else if (!strcmp (tmp_name, "eraser"))
gdkdev->info.source = GDK_SOURCE_ERASER;
else if (!strcmp (tmp_name, "cursor"))
gdkdev->info.source = GDK_SOURCE_CURSOR;
else
gdkdev->info.source = GDK_SOURCE_PEN;
g_free(tmp_name);
gdkdev->xdevice = NULL;
/* step through the classes */
gdkdev->info.num_axes = 0;
gdkdev->info.num_keys = 0;
gdkdev->info.keys = NULL;
gdkdev->axes = 0;
gdkdev->info.has_cursor = 0;
gdkdev->needs_update = FALSE;
gdkdev->claimed = FALSE;
gdkdev->button_state = 0;
class = device->inputclassinfo;
for (i=0;i<device->num_classes;i++)
{
switch (class->class) {
case ButtonClass:
{
break;
}
case KeyClass:
{
XKeyInfo *xki = (XKeyInfo *)class;
/* Hack to catch XFree86 3.3.1 bug. Other devices better
* not have exactly 25 keys...
*/
if ((xki->min_keycode == 8) && (xki->max_keycode == 32))
{
gdkdev->info.num_keys = 32;
gdkdev->min_keycode = 1;
}
else
{
gdkdev->info.num_keys = xki->max_keycode - xki->min_keycode + 1;
gdkdev->min_keycode = xki->min_keycode;
}
gdkdev->info.keys = g_new (GdkDeviceKey, gdkdev->info.num_keys);
for (j=0; j<gdkdev->info.num_keys; j++)
{
gdkdev->info.keys[j].keyval = 0;
gdkdev->info.keys[j].modifiers = 0;
}
break;
}
case ValuatorClass:
{
XValuatorInfo *xvi = (XValuatorInfo *)class;
gdkdev->info.num_axes = xvi->num_axes;
gdkdev->axes = g_new(GdkAxisInfo, xvi->num_axes);
gdkdev->info.axes = g_new(GdkAxisUse, xvi->num_axes);
for (j=0;j<xvi->num_axes;j++)
{
gdkdev->axes[j].resolution =
gdkdev->axes[j].xresolution = xvi->axes[j].resolution;
gdkdev->axes[j].min_value =
gdkdev->axes[j].xmin_value = xvi->axes[j].min_value;
gdkdev->axes[j].max_value =
gdkdev->axes[j].xmax_value = xvi->axes[j].max_value;
gdkdev->info.axes[j] = GDK_AXIS_IGNORE;
}
j=0;
if (j<xvi->num_axes)
gdkdev->info.axes[j++] = GDK_AXIS_X;
if (j<xvi->num_axes)
gdkdev->info.axes[j++] = GDK_AXIS_Y;
if (j<xvi->num_axes)
gdkdev->info.axes[j++] = GDK_AXIS_PRESSURE;
if (j<xvi->num_axes)
gdkdev->info.axes[j++] = GDK_AXIS_XTILT;
if (j<xvi->num_axes)
gdkdev->info.axes[j++] = GDK_AXIS_YTILT;
/* set up reverse lookup on axis use */
for (j=GDK_AXIS_IGNORE;j<GDK_AXIS_LAST;j++)
gdkdev->axis_for_use[j] = -1;
for (j=0;j<xvi->num_axes;j++)
if (gdkdev->info.axes[j] != GDK_AXIS_IGNORE)
gdkdev->axis_for_use[gdkdev->info.axes[j]] = j;
break;
}
}
class = (XAnyClassPtr)(((char *)class) + class->length);
}
/* return NULL if no axes */
if (!gdkdev->info.num_axes || !gdkdev->axes ||
(!include_core && device->use == IsXPointer))
{
g_free(gdkdev->info.name);
if (gdkdev->axes)
g_free(gdkdev->axes);
if (gdkdev->info.keys)
g_free(gdkdev->info.keys);
g_free(gdkdev);
return NULL;
}
if (device->use != IsXPointer)
{
int error_warn = gdk_error_warnings;
gdk_error_warnings = 0;
gdk_error_code = 0;
gdkdev->xdevice = XOpenDevice(gdk_display, gdkdev->info.deviceid);
gdk_error_warnings = error_warn;
/* return NULL if device is not ready */
if (gdk_error_code)
{
g_free (gdkdev->info.name);
if (gdkdev->axes)
g_free (gdkdev->axes);
if (gdkdev->info.keys)
g_free (gdkdev->info.keys);
if (gdkdev->info.axes)
g_free (gdkdev->info.axes);
g_free (gdkdev);
return NULL;
}
}
gdkdev->buttonpress_type = 0;
gdkdev->buttonrelease_type = 0;
gdkdev->keypress_type = 0;
gdkdev->keyrelease_type = 0;
gdkdev->motionnotify_type = 0;
gdkdev->proximityin_type = 0;
gdkdev->proximityout_type = 0;
gdkdev->changenotify_type = 0;
return gdkdev;
}
static void
gdk_input_common_find_events(GdkWindow *window,
GdkDevicePrivate *gdkdev,
gint mask,
XEventClass *classes,
int *num_classes)
{
gint i;
XEventClass class;
i = 0;
/* We have to track press and release events in pairs to keep
track of button state correctly and implement grabbing for
the gxi support */
if (mask & GDK_BUTTON_PRESS_MASK || mask & GDK_BUTTON_RELEASE_MASK)
{
DeviceButtonPress (gdkdev->xdevice, gdkdev->buttonpress_type,
class);
if (class != 0)
classes[i++] = class;
DeviceButtonPressGrab (gdkdev->xdevice, 0, class);
if (class != 0)
classes[i++] = class;
DeviceButtonRelease (gdkdev->xdevice, gdkdev->buttonrelease_type,
class);
if (class != 0)
classes[i++] = class;
}
if (mask & GDK_POINTER_MOTION_MASK)
{
DeviceMotionNotify (gdkdev->xdevice, gdkdev->motionnotify_type, class);
if (class != 0)
classes[i++] = class;
}
else
if (mask & (GDK_BUTTON1_MOTION_MASK | GDK_BUTTON2_MOTION_MASK |
GDK_BUTTON3_MOTION_MASK | GDK_BUTTON_MOTION_MASK |
GDK_POINTER_MOTION_HINT_MASK))
{
/* Make sure gdkdev->motionnotify_type is set */
DeviceMotionNotify (gdkdev->xdevice, gdkdev->motionnotify_type, class);
}
if (mask & GDK_BUTTON1_MOTION_MASK)
{
DeviceButton1Motion (gdkdev->xdevice, 0, class);
if (class != 0)
classes[i++] = class;
}
if (mask & GDK_BUTTON2_MOTION_MASK)
{
DeviceButton2Motion (gdkdev->xdevice, 0, class);
if (class != 0)
classes[i++] = class;
}
if (mask & GDK_BUTTON3_MOTION_MASK)
{
DeviceButton3Motion (gdkdev->xdevice, 0, class);
if (class != 0)
classes[i++] = class;
}
if (mask & GDK_BUTTON_MOTION_MASK)
{
DeviceButtonMotion (gdkdev->xdevice, 0, class);
if (class != 0)
classes[i++] = class;
}
if (mask & GDK_POINTER_MOTION_HINT_MASK)
{
/* We'll get into trouble if the macros change, but at least we'll
know about it, and we avoid warnings now */
DevicePointerMotionHint (gdkdev->xdevice, 0, class);
if (class != 0)
classes[i++] = class;
}
if (mask & GDK_KEY_PRESS_MASK)
{
DeviceKeyPress (gdkdev->xdevice, gdkdev->keypress_type, class);
if (class != 0)
classes[i++] = class;
}
if (mask & GDK_KEY_RELEASE_MASK)
{
DeviceKeyRelease (gdkdev->xdevice, gdkdev->keyrelease_type, class);
if (class != 0)
classes[i++] = class;
}
if (mask & GDK_PROXIMITY_IN_MASK)
{
ProximityIn (gdkdev->xdevice, gdkdev->proximityin_type, class);
if (class != 0)
classes[i++] = class;
}
if (mask & GDK_PROXIMITY_OUT_MASK)
{
ProximityOut (gdkdev->xdevice, gdkdev->proximityout_type, class);
if (class != 0)
classes[i++] = class;
}
*num_classes = i;
}
static void
gdk_input_common_select_events(GdkWindow *window,
GdkDevicePrivate *gdkdev)
{
XEventClass classes[GDK_MAX_DEVICE_CLASSES];
gint num_classes;
if (gdkdev->info.mode == GDK_MODE_DISABLED)
gdk_input_common_find_events(window, gdkdev, 0, classes, &num_classes);
else
gdk_input_common_find_events(window, gdkdev,
((GdkWindowPrivate *)window)->extension_events,
classes, &num_classes);
XSelectExtensionEvent (gdk_display,
GDK_WINDOW_XWINDOW(window),
classes, num_classes);
}
gint
gdk_input_common_init(gint include_core)
{
char **extensions;
XDeviceInfo *devices;
int num_devices;
int num_extensions, loop;
Display *display = gdk_display;
/* Init global vars */
gdk_window_get_geometry(NULL, /* use root window */
NULL,NULL,
&gdk_input_root_width,&gdk_input_root_height,
NULL);
/* Init XInput extension */
extensions = XListExtensions(display, &num_extensions);
for (loop = 0; loop < num_extensions &&
(strcmp(extensions[loop], "XInputExtension") != 0); loop++);
XFreeExtensionList(extensions);
gdk_input_devices = NULL;
if (loop < num_extensions)
{
/* XInput extension found */
devices = XListInputDevices(display, &num_devices);
for(loop=0; loop<num_devices; loop++)
{
GdkDevicePrivate *gdkdev = gdk_input_device_new(&devices[loop],
include_core);
if (gdkdev)
gdk_input_devices = g_list_append(gdk_input_devices, gdkdev);
}
XFreeDeviceList(devices);
}
gdk_input_devices = g_list_append (gdk_input_devices, &gdk_input_core_info);
return TRUE;
}
static void
gdk_input_translate_coordinates (GdkDevicePrivate *gdkdev,
GdkInputWindow *input_window,
gint *axis_data,
gdouble *x, gdouble *y, gdouble *pressure,
gdouble *xtilt, gdouble *ytilt)
{
GdkDrawablePrivate *drawable_priv;
int x_axis, y_axis, pressure_axis, xtilt_axis, ytilt_axis;
double device_width, device_height;
double x_offset, y_offset, x_scale, y_scale;
drawable_priv = (GdkDrawablePrivate *) input_window->window;
x_axis = gdkdev->axis_for_use[GDK_AXIS_X];
y_axis = gdkdev->axis_for_use[GDK_AXIS_Y];
pressure_axis = gdkdev->axis_for_use[GDK_AXIS_PRESSURE];
xtilt_axis = gdkdev->axis_for_use[GDK_AXIS_XTILT];
ytilt_axis = gdkdev->axis_for_use[GDK_AXIS_YTILT];
device_width = gdkdev->axes[x_axis].max_value -
gdkdev->axes[x_axis].min_value;
device_height = gdkdev->axes[y_axis].max_value -
gdkdev->axes[y_axis].min_value;
if (gdkdev->info.mode == GDK_MODE_SCREEN)
{
x_scale = gdk_input_root_width / device_width;
y_scale = gdk_input_root_height / device_height;
x_offset = - input_window->root_x;
y_offset = - input_window->root_y;
}
else /* GDK_MODE_WINDOW */
{
double device_aspect = (device_height*gdkdev->axes[y_axis].resolution) /
(device_width*gdkdev->axes[x_axis].resolution);
if (device_aspect * drawable_priv->width >= drawable_priv->height)
{
/* device taller than window */
x_scale = drawable_priv->width / device_width;
y_scale = (x_scale * gdkdev->axes[x_axis].resolution)
/ gdkdev->axes[y_axis].resolution;
x_offset = 0;
y_offset = -(device_height * y_scale -
drawable_priv->height)/2;
}
else
{
/* window taller than device */
y_scale = drawable_priv->height / device_height;
x_scale = (y_scale * gdkdev->axes[y_axis].resolution)
/ gdkdev->axes[x_axis].resolution;
y_offset = 0;
x_offset = - (device_width * x_scale - drawable_priv->width)/2;
}
}
if (x) *x = x_offset + x_scale*axis_data[x_axis];
if (y) *y = y_offset + y_scale*axis_data[y_axis];
if (pressure)
{
if (pressure_axis != -1)
*pressure = ((double)axis_data[pressure_axis]
- gdkdev->axes[pressure_axis].min_value)
/ (gdkdev->axes[pressure_axis].max_value
- gdkdev->axes[pressure_axis].min_value);
else
*pressure = 0.5;
}
if (xtilt)
{
if (xtilt_axis != -1)
{
*xtilt = 2. * (double)(axis_data[xtilt_axis] -
(gdkdev->axes[xtilt_axis].min_value +
gdkdev->axes[xtilt_axis].max_value)/2) /
(gdkdev->axes[xtilt_axis].max_value -
gdkdev->axes[xtilt_axis].min_value);
}
else *xtilt = 0;
}
if (ytilt)
{
if (ytilt_axis != -1)
{
*ytilt = 2. * (double)(axis_data[ytilt_axis] -
(gdkdev->axes[ytilt_axis].min_value +
gdkdev->axes[ytilt_axis].max_value)/2) /
(gdkdev->axes[ytilt_axis].max_value -
gdkdev->axes[ytilt_axis].min_value);
}
else
*ytilt = 0;
}
}
/* combine the state of the core device and the device state
into one - for now we do this in a simple-minded manner -
we just take the keyboard portion of the core device and
the button portion (all of?) the device state.
Any button remapping should go on here. */
static guint
gdk_input_translate_state(guint state, guint device_state)
{
return device_state | (state & 0xFF);
}
static gint
gdk_input_common_other_event (GdkEvent *event,
XEvent *xevent,
GdkInputWindow *input_window,
GdkDevicePrivate *gdkdev)
{
if ((xevent->type == gdkdev->buttonpress_type) ||
(xevent->type == gdkdev->buttonrelease_type))
{
XDeviceButtonEvent *xdbe = (XDeviceButtonEvent *)(xevent);
if (xdbe->type == gdkdev->buttonpress_type)
{
event->button.type = GDK_BUTTON_PRESS;
gdkdev->button_state |= 1 << xdbe->button;
}
else
{
event->button.type = GDK_BUTTON_RELEASE;
gdkdev->button_state &= ~(1 << xdbe->button);
}
event->button.window = input_window->window;
event->button.time = xdbe->time;
event->button.source = gdkdev->info.source;
event->button.deviceid = xdbe->deviceid;
gdk_input_translate_coordinates (gdkdev,input_window, xdbe->axis_data,
&event->button.x,&event->button.y,
&event->button.pressure,
&event->button.xtilt,
&event->button.ytilt);
event->button.state = gdk_input_translate_state(xdbe->state,xdbe->device_state);
event->button.button = xdbe->button;
GDK_NOTE (EVENTS,
g_print ("button %s:\t\twindow: %ld device: %ld x,y: %f %f button: %d\n",
(event->button.type == GDK_BUTTON_PRESS) ? "press" : "release",
xdbe->window,
xdbe->deviceid,
event->button.x, event->button.y,
xdbe->button));
return TRUE;
}
if ((xevent->type == gdkdev->keypress_type) ||
(xevent->type == gdkdev->keyrelease_type))
{
XDeviceKeyEvent *xdke = (XDeviceKeyEvent *)(xevent);
GDK_NOTE (EVENTS,
g_print ("device key %s:\twindow: %ld device: %ld keycode: %d\n",
(event->key.type == GDK_KEY_PRESS) ? "press" : "release",
xdke->window,
xdke->deviceid,
xdke->keycode));
if (xdke->keycode < gdkdev->min_keycode ||
xdke->keycode >= gdkdev->min_keycode + gdkdev->info.num_keys)
{
g_warning ("Invalid device key code received");
return FALSE;
}
event->key.keyval = gdkdev->info.keys[xdke->keycode - gdkdev->min_keycode].keyval;
if (event->key.keyval == 0)
{
GDK_NOTE (EVENTS,
g_print ("\t\ttranslation - NONE\n"));
return FALSE;
}
event->key.type = (xdke->type == gdkdev->keypress_type) ?
GDK_KEY_PRESS : GDK_KEY_RELEASE;
event->key.window = input_window->window;
event->key.time = xdke->time;
event->key.state = gdk_input_translate_state(xdke->state, xdke->device_state)
| gdkdev->info.keys[xdke->keycode - gdkdev->min_keycode].modifiers;
/* Add a string translation for the key event */
if ((event->key.keyval >= 0x20) && (event->key.keyval <= 0xFF))
{
event->key.length = 1;
event->key.string = g_new (gchar, 2);
event->key.string[0] = (gchar)event->key.keyval;
event->key.string[1] = 0;
}
else
{
event->key.length = 0;
event->key.string = g_new0 (gchar, 1);
}
GDK_NOTE (EVENTS,
g_print ("\t\ttranslation - keyval: %d modifiers: %#x\n",
event->key.keyval,
event->key.state));
return TRUE;
}
if (xevent->type == gdkdev->motionnotify_type)
{
XDeviceMotionEvent *xdme = (XDeviceMotionEvent *)(xevent);
gdk_input_translate_coordinates(gdkdev,input_window,xdme->axis_data,
&event->motion.x,&event->motion.y,
&event->motion.pressure,
&event->motion.xtilt,
&event->motion.ytilt);
event->motion.type = GDK_MOTION_NOTIFY;
event->motion.window = input_window->window;
event->motion.time = xdme->time;
event->motion.deviceid = xdme->deviceid;
event->motion.state = gdk_input_translate_state(xdme->state,
xdme->device_state);
event->motion.is_hint = xdme->is_hint;
event->motion.source = gdkdev->info.source;
event->motion.deviceid = xdme->deviceid;
GDK_NOTE (EVENTS,
g_print ("motion notify:\t\twindow: %ld device: %ld x,y: %f %f state %#4x hint: %s\n",
xdme->window,
xdme->deviceid,
event->motion.x, event->motion.y,
event->motion.state,
(xdme->is_hint) ? "true" : "false"));
return TRUE;
}
if (xevent->type == gdkdev->proximityin_type ||
xevent->type == gdkdev->proximityout_type)
{
XProximityNotifyEvent *xpne = (XProximityNotifyEvent *)(xevent);
event->proximity.type = (xevent->type == gdkdev->proximityin_type)?
GDK_PROXIMITY_IN:GDK_PROXIMITY_OUT;
event->proximity.window = input_window->window;
event->proximity.time = xpne->time;
event->proximity.source = gdkdev->info.source;
event->proximity.deviceid = xpne->deviceid;
return TRUE;
}
return -1; /* wasn't one of our event types */
}
static void
gdk_input_common_set_axes (guint32 deviceid, GdkAxisUse *axes)
{
int i;
GdkDevicePrivate *gdkdev = gdk_input_find_device(deviceid);
g_return_if_fail (gdkdev != NULL);
for (i=GDK_AXIS_IGNORE;i<GDK_AXIS_LAST;i++)
{
gdkdev->axis_for_use[i] = -1;
}
for (i=0;i<gdkdev->info.num_axes;i++)
{
gdkdev->info.axes[i] = axes[i];
gdkdev->axis_for_use[axes[i]] = i;
}
}
void gdk_input_common_set_key (guint32 deviceid,
guint index,
guint keyval,
GdkModifierType modifiers)
{
GdkDevicePrivate *gdkdev = gdk_input_find_device(deviceid);
gdkdev = gdk_input_find_device (deviceid);
g_return_if_fail (gdkdev != NULL);
g_return_if_fail (index < gdkdev->info.num_keys);
gdkdev->info.keys[index].keyval = keyval;
gdkdev->info.keys[index].modifiers = modifiers;
}
static GdkTimeCoord *
gdk_input_common_motion_events (GdkWindow *window,
guint32 deviceid,
guint32 start,
guint32 stop,
gint *nevents_return)
{
GdkTimeCoord *coords;
XDeviceTimeCoord *device_coords;
GdkInputWindow *input_window;
GdkDevicePrivate *gdkdev;
int mode_return;
int axis_count_return;
int i;
gdkdev = gdk_input_find_device (deviceid);
input_window = gdk_input_window_find (window);
g_return_val_if_fail (gdkdev != NULL, NULL);
g_return_val_if_fail (gdkdev->xdevice != NULL, NULL);
g_return_val_if_fail (input_window != NULL, NULL);
device_coords = XGetDeviceMotionEvents (gdk_display,
gdkdev->xdevice,
start, stop,
nevents_return, &mode_return,
&axis_count_return);
if (device_coords)
{
coords = g_new (GdkTimeCoord, *nevents_return);
for (i=0; i<*nevents_return; i++)
{
gdk_input_translate_coordinates (gdkdev, input_window,
device_coords[i].data,
&coords[i].x, &coords[i].y,
&coords[i].pressure,
&coords[i].xtilt, &coords[i].ytilt);
}
XFreeDeviceMotionEvents (device_coords);
return coords;
}
else
return NULL;
}
static void
gdk_input_common_get_pointer (GdkWindow *window,
guint32 deviceid,
gdouble *x,
gdouble *y,
gdouble *pressure,
gdouble *xtilt,
gdouble *ytilt,
GdkModifierType *mask)
{
GdkDevicePrivate *gdkdev;
GdkInputWindow *input_window;
XDeviceState *state;
XInputClass *input_class;
gint x_int, y_int;
gint i;
/* we probably need to get the mask in any case */
if (deviceid == GDK_CORE_POINTER)
{
gdk_window_get_pointer (window, &x_int, &y_int, mask);
if (x) *x = x_int;
if (y) *y = y_int;
if (pressure) *pressure = 0.5;
if (xtilt) *xtilt = 0;
if (ytilt) *ytilt = 0;
}
else
{
if (mask)
gdk_window_get_pointer (window, NULL, NULL, mask);
gdkdev = gdk_input_find_device (deviceid);
input_window = gdk_input_window_find (window);
g_return_if_fail (gdkdev != NULL);
g_return_if_fail (gdkdev->xdevice != NULL);
g_return_if_fail (input_window != NULL);
state = XQueryDeviceState (gdk_display, gdkdev->xdevice);
input_class = state->data;
for (i=0; i<state->num_classes; i++)
{
switch (input_class->class)
{
case ValuatorClass:
gdk_input_translate_coordinates (gdkdev, input_window,
((XValuatorState *)input_class)->valuators,
x, y, pressure,
xtilt, ytilt);
break;
case ButtonClass:
if (mask)
{
*mask &= 0xFF;
if (((XButtonState *)input_class)->num_buttons > 0)
*mask |= ((XButtonState *)input_class)->buttons[0] << 7;
/* GDK_BUTTON1_MASK = 1 << 8, and button n is stored
* in bit 1<<(n%8) in byte n/8. n = 1,2,... */
}
break;
}
input_class = (XInputClass *)(((char *)input_class)+input_class->length);
}
}
}
#endif

View File

@ -1,649 +0,0 @@
/* 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/.
*/
#ifdef XINPUT_GXI
/* #define DEBUG_SWITCHING */
#include <gxid_lib.h>
/* Forward declarations */
static void gdk_input_gxi_select_notify (GdkDevicePrivate *gdkdev);
static gint gdk_input_gxi_set_mode (guint32 deviceid, GdkInputMode mode);
static gint gdk_input_is_extension_device (guint32 deviceid);
static void gdk_input_gxi_configure_event (XConfigureEvent *xevent,
GdkWindow *window);
static void gdk_input_gxi_enter_event (XCrossingEvent *xevent,
GdkWindow *window);
static gint gdk_input_gxi_other_event (GdkEvent *event,
XEvent *xevent,
GdkWindow *window);
static void gdk_input_gxi_update_device (GdkDevicePrivate *gdkdev);
static gint gdk_input_gxi_window_none_event (GdkEvent *event, XEvent *xevent);
static gint gdk_input_gxi_enable_window (GdkWindow *window,
GdkDevicePrivate *gdkdev);
static gint gdk_input_gxi_disable_window (GdkWindow *window,
GdkDevicePrivate *gdkdev);
static Window gdk_input_find_root_child(Display *dpy, Window w);
static void gdk_input_compute_obscuring(GdkInputWindow *input_window);
static gint gdk_input_is_obscured(GdkInputWindow *input_window, gdouble x,
gdouble y);
static GdkTimeCoord *gdk_input_gxi_motion_events (GdkWindow *window,
guint32 deviceid,
guint32 start,
guint32 stop,
gint *nevents_return);
static void gdk_input_gxi_get_pointer (GdkWindow *window,
guint32 deviceid,
gdouble *x,
gdouble *y,
gdouble *pressure,
gdouble *xtilt,
gdouble *ytilt,
GdkModifierType *mask);
static gint gdk_input_gxi_grab_pointer (GdkWindow * window,
gint owner_events,
GdkEventMask event_mask,
GdkWindow * confine_to,
guint32 time);
static void gdk_input_gxi_ungrab_pointer (guint32 time);
/* Local variables */
static GdkDevicePrivate *gdk_input_current_device;
static GdkDevicePrivate *gdk_input_core_pointer;
void
gdk_input_init(void)
{
GList *tmp_list;
gdk_input_vtable.set_mode = gdk_input_gxi_set_mode;
gdk_input_vtable.set_axes = gdk_input_common_set_axes;
gdk_input_vtable.set_key = gdk_input_common_set_key;
gdk_input_vtable.motion_events = gdk_input_gxi_motion_events;
gdk_input_vtable.get_pointer = gdk_input_gxi_get_pointer;
gdk_input_vtable.grab_pointer = gdk_input_gxi_grab_pointer;
gdk_input_vtable.ungrab_pointer = gdk_input_gxi_ungrab_pointer;
gdk_input_vtable.configure_event = gdk_input_gxi_configure_event;
gdk_input_vtable.enter_event = gdk_input_gxi_enter_event;
gdk_input_vtable.other_event = gdk_input_gxi_other_event;
gdk_input_vtable.window_none_event = gdk_input_gxi_window_none_event;
gdk_input_vtable.enable_window = gdk_input_gxi_enable_window;
gdk_input_vtable.disable_window = gdk_input_gxi_disable_window;
gdk_input_ignore_core = FALSE;
gdk_input_core_pointer = NULL;
if (!gdk_input_gxid_host)
{
gdk_input_gxid_host = getenv("GXID_HOST");
}
if (!gdk_input_gxid_port)
{
char *t = getenv("GXID_PORT");
if (t)
gdk_input_gxid_port = atoi(t);
}
gdk_input_common_init(TRUE);
/* find initial core pointer */
for (tmp_list = gdk_input_devices; tmp_list; tmp_list = tmp_list->next)
{
GdkDevicePrivate *gdkdev = (GdkDevicePrivate *)tmp_list->data;
if (gdk_input_is_extension_device(gdkdev->info.deviceid))
{
gdk_input_gxi_select_notify (gdkdev);
}
else
{
if (gdkdev->info.deviceid != GDK_CORE_POINTER)
gdk_input_core_pointer = gdkdev;
}
}
}
static void
gdk_input_gxi_select_notify (GdkDevicePrivate *gdkdev)
{
XEventClass class;
ChangeDeviceNotify (gdkdev->xdevice, gdkdev->changenotify_type, class);
XSelectExtensionEvent (gdk_display, gdk_root_window, &class, 1);
}
/* Set the core pointer. Device should already be enabled. */
static gint
gdk_input_gxi_set_core_pointer(GdkDevicePrivate *gdkdev)
{
int x_axis,y_axis;
g_return_val_if_fail(gdkdev->xdevice,FALSE);
x_axis = gdkdev->axis_for_use[GDK_AXIS_X];
y_axis = gdkdev->axis_for_use[GDK_AXIS_Y];
g_return_val_if_fail(x_axis != -1 && y_axis != -1,FALSE);
/* core_pointer might not be up to date so we check with the server
before change the pointer */
if ( !gdk_input_is_extension_device(gdkdev->info.deviceid) )
{
#if 0
if (gdkdev != gdk_input_core_pointer)
g_warning("core pointer inconsistency");
#endif
return TRUE;
}
if ( XChangePointerDevice(gdk_display,gdkdev->xdevice, x_axis, y_axis)
!= Success )
{
return FALSE;
}
else
{
gdk_input_gxi_update_device (gdk_input_core_pointer);
gdk_input_core_pointer = gdkdev;
return TRUE;
}
}
/* FIXME, merge with gdk_input_xfree_set_mode */
static gint
gdk_input_gxi_set_mode (guint32 deviceid, GdkInputMode mode)
{
GList *tmp_list;
GdkDevicePrivate *gdkdev;
GdkInputMode old_mode;
GdkInputWindow *input_window;
gdkdev = gdk_input_find_device(deviceid);
g_return_val_if_fail (gdkdev != NULL,FALSE);
old_mode = gdkdev->info.mode;
if (gdkdev->info.mode == mode)
return TRUE;
gdkdev->info.mode = mode;
if (old_mode != GDK_MODE_DISABLED)
{
for (tmp_list = gdk_input_windows; tmp_list; tmp_list = tmp_list->next)
{
input_window = (GdkInputWindow *)tmp_list->data;
if (input_window->mode != GDK_EXTENSION_EVENTS_CURSOR)
gdk_input_disable_window (input_window->window, gdkdev);
}
}
if (mode != GDK_MODE_DISABLED)
{
for (tmp_list = gdk_input_windows; tmp_list; tmp_list = tmp_list->next)
{
input_window = (GdkInputWindow *)tmp_list->data;
if (input_window->mode != GDK_EXTENSION_EVENTS_CURSOR)
if (!gdk_input_enable_window(input_window->window, gdkdev))
{
gdk_input_set_mode(deviceid, old_mode);
return FALSE;
}
}
}
return TRUE;
}
gint
gdk_input_is_extension_device (guint32 deviceid)
{
XDeviceInfo *devices;
int num_devices, loop;
if (deviceid == GDK_CORE_POINTER)
return FALSE;
devices = XListInputDevices(gdk_display, &num_devices);
for(loop=0; loop<num_devices; loop++)
{
if ((devices[loop].id == deviceid) && (devices[loop].use == IsXExtensionDevice))
{
XFreeDeviceList(devices);
return TRUE;
}
}
XFreeDeviceList(devices);
return FALSE;
}
static void
gdk_input_gxi_configure_event (XConfigureEvent *xevent, GdkWindow *window)
{
GdkInputWindow *input_window;
gint root_x, root_y;
input_window = gdk_input_window_find(window);
g_return_if_fail (input_window != NULL);
gdk_input_get_root_relative_geometry(gdk_display,GDK_WINDOW_XWINDOW(window),
&root_x, &root_y, NULL, NULL);
input_window->root_x = root_x;
input_window->root_y = root_y;
gdk_input_compute_obscuring(input_window);
}
static void
gdk_input_gxi_enter_event (XCrossingEvent *xevent, GdkWindow *window)
{
GdkInputWindow *input_window;
input_window = gdk_input_window_find(window);
g_return_if_fail (input_window != NULL);
gdk_input_compute_obscuring(input_window);
}
static gint
gdk_input_gxi_other_event (GdkEvent *event,
XEvent *xevent,
GdkWindow *window)
{
GdkInputWindow *input_window;
GdkDevicePrivate *gdkdev;
gint return_val;
input_window = gdk_input_window_find(window);
g_return_val_if_fail (window != NULL, -1);
/* This is a sort of a hack, as there isn't any XDeviceAnyEvent -
but it's potentially faster than scanning through the types of
every device. If we were deceived, then it won't match any of
the types for the device anyways */
gdkdev = gdk_input_find_device(((XDeviceButtonEvent *)xevent)->deviceid);
if (!gdkdev) {
return -1; /* we don't handle it - not an XInput event */
}
if (gdkdev->info.mode == GDK_MODE_DISABLED ||
input_window->mode == GDK_EXTENSION_EVENTS_CURSOR)
return FALSE;
if (gdkdev != gdk_input_current_device &&
xevent->type != gdkdev->changenotify_type)
{
gdk_input_current_device = gdkdev;
}
return_val = gdk_input_common_other_event (event, xevent,
input_window, gdkdev);
if (return_val > 0 && event->type == GDK_MOTION_NOTIFY &&
(!gdkdev->button_state) && (!input_window->grabbed) &&
((event->motion.x < 0) || (event->motion.y < 0) ||
(event->motion.x > ((GdkWindowPrivate *)window)->width) ||
(event->motion.y > ((GdkWindowPrivate *)window)->height) ||
gdk_input_is_obscured(input_window,event->motion.x,event->motion.y)))
{
#ifdef DEBUG_SWITCHING
g_print("gdkinput: Setting core pointer to %d on motion at (%f,%f)\n",
gdkdev->info.deviceid,event->motion.x,event->motion.y);
g_print(" window geometry is: %dx%d\n",
((GdkWindowPrivate *)window)->width,
((GdkWindowPrivate *)window)->height);
#endif
gdk_input_gxi_set_core_pointer(gdkdev);
return FALSE;
}
else
return return_val;
}
static void
gdk_input_gxi_update_device (GdkDevicePrivate *gdkdev)
{
GList *t;
if (gdk_input_is_extension_device (gdkdev->info.deviceid))
{
if (!gdkdev->xdevice)
{
gdkdev->xdevice = XOpenDevice(gdk_display, gdkdev->info.deviceid);
gdk_input_gxi_select_notify (gdkdev);
gdkdev->needs_update = 1;
}
if (gdkdev->needs_update && gdkdev->xdevice)
{
for (t = gdk_input_windows; t; t = t->next)
gdk_input_common_select_events (((GdkInputWindow *)t->data)->window,
gdkdev);
gdkdev->needs_update = 0;
}
}
}
static gint
gdk_input_gxi_window_none_event (GdkEvent *event, XEvent *xevent)
{
GdkDevicePrivate *gdkdev =
gdk_input_find_device(((XDeviceButtonEvent *)xevent)->deviceid);
if (!gdkdev) {
return -1; /* we don't handle it - not an XInput event */
}
if (xevent->type == gdkdev->changenotify_type)
{
if (gdk_input_core_pointer != gdkdev)
{
#ifdef DEBUG_SWITCHING
g_print("ChangeNotify from %d to %d:\n",
gdk_input_core_pointer->info.deviceid,
gdkdev->info.deviceid);
#endif
gdk_input_gxi_update_device (gdk_input_core_pointer);
gdk_input_core_pointer = gdkdev;
}
}
return FALSE;
}
static gint
gdk_input_gxi_enable_window (GdkWindow *window, GdkDevicePrivate *gdkdev)
{
GdkInputWindow *input_window;
input_window = gdk_input_window_find (window);
g_return_val_if_fail (input_window != NULL, FALSE);
if (!gdkdev->claimed)
{
if (gxid_claim_device(gdk_input_gxid_host, gdk_input_gxid_port,
gdkdev->info.deviceid,
GDK_WINDOW_XWINDOW(window), FALSE) !=
GXID_RETURN_OK)
{
g_warning("Could not get device (is gxid running?)\n");
return FALSE;
}
gdkdev->claimed = TRUE;
}
if (gdkdev->xdevice && gdkdev != gdk_input_core_pointer)
gdk_input_common_select_events(window, gdkdev);
else
gdkdev->needs_update = TRUE;
return TRUE;
}
static gint
gdk_input_gxi_disable_window(GdkWindow *window, GdkDevicePrivate *gdkdev)
{
GdkInputWindow *input_window;
input_window = gdk_input_window_find (window);
g_return_val_if_fail (input_window != NULL, FALSE);
if (gdkdev->claimed)
{
gxid_release_device(gdk_input_gxid_host, gdk_input_gxid_port,
gdkdev->info.deviceid,
GDK_WINDOW_XWINDOW(window));
gdkdev->claimed = FALSE;
}
if (gdkdev->xdevice && gdkdev != gdk_input_core_pointer)
gdk_input_common_select_events(window, gdkdev);
else
gdkdev->needs_update = TRUE;
return TRUE;
}
static gint
gdk_input_is_obscured(GdkInputWindow *input_window, gdouble x, gdouble y)
{
int i;
for (i=0;i<input_window->num_obscuring;i++)
{
GdkRectangle *rect = &input_window->obscuring[i];
if ((x >= rect->x) &&
(y >= rect->y) &&
(x < rect->x + rect->width) &&
(y < rect->y + rect->height))
return TRUE;
}
return FALSE;
}
/* If this routine needs fixing, the corresponding routine
in gxid.c will need it too. */
static Window
gdk_input_find_root_child(Display *dpy, Window w)
{
Window root,parent;
Window *children;
int nchildren;
parent = w;
do
{
w = parent;
XQueryTree(dpy,w,&root,&parent,&children,&nchildren);
if (children) XFree(children);
}
while (parent != root);
return w;
}
void
gdk_input_compute_obscuring(GdkInputWindow *input_window)
{
int i;
int x,y,width,height;
int xc,yc,widthc,heightc,border_widthc,depthc;
Window root,parent;
Window *children;
int nchildren;
Window w = GDK_WINDOW_XWINDOW(input_window->window);
Window root_child = gdk_input_find_root_child(gdk_display,w);
gdk_input_get_root_relative_geometry(gdk_display,w,&x,&y,&width,&height);
input_window->root_x = x;
input_window->root_y = y;
XQueryTree(gdk_display,GDK_ROOT_WINDOW(),
&root,&parent,&children,&nchildren);
if (input_window->obscuring)
g_free(input_window->obscuring);
input_window->obscuring = 0;
input_window->num_obscuring = 0;
for (i=0;i<nchildren;i++)
if (children[i] == root_child)
break;
if (i>=nchildren-1)
{
if (nchildren)
XFree(children);
return;
}
input_window->obscuring = g_new(GdkRectangle,(nchildren-i-1));
for (i=i+1;i<nchildren;i++)
{
int xmin, xmax, ymin, ymax;
XGetGeometry(gdk_display,children[i],&root,&xc,&yc,&widthc,&heightc,
&border_widthc, &depthc);
xmin = xc>x ? xc : x;
xmax = (xc+widthc)<(x+width) ? xc+widthc : x+width;
ymin = yc>y ? yc : y;
ymax = (yc+heightc)<(y+height) ? yc+heightc : y+height;
if ((xmin < xmax) && (ymin < ymax))
{
XWindowAttributes attributes;
XGetWindowAttributes(gdk_display,children[i],&attributes);
if (attributes.map_state == IsViewable)
{
GdkRectangle *rect = &input_window->obscuring[input_window->num_obscuring];
/* we store the whole window, not just the obscuring part */
rect->x = xc - x;
rect->y = yc - y;
rect->width = widthc;
rect->height = heightc;
input_window->num_obscuring++;
}
}
}
if (nchildren)
XFree(children);
}
static void
gdk_input_gxi_get_pointer (GdkWindow *window,
guint32 deviceid,
gdouble *x,
gdouble *y,
gdouble *pressure,
gdouble *xtilt,
gdouble *ytilt,
GdkModifierType *mask)
{
GdkDevicePrivate *gdkdev;
gdkdev = gdk_input_find_device (deviceid);
g_return_if_fail (gdkdev != NULL);
if (gdkdev == gdk_input_core_pointer)
gdk_input_common_get_pointer (window, GDK_CORE_POINTER, x, y,
pressure, xtilt, ytilt, mask);
else
gdk_input_common_get_pointer (window, deviceid, x, y,
pressure, xtilt, ytilt, mask);
}
static GdkTimeCoord *
gdk_input_gxi_motion_events (GdkWindow *window,
guint32 deviceid,
guint32 start,
guint32 stop,
gint *nevents_return)
{
GdkDevicePrivate *gdkdev;
gdkdev = gdk_input_find_device (deviceid);
g_return_val_if_fail (gdkdev != NULL, NULL);
if (gdkdev == gdk_input_core_pointer)
return gdk_input_motion_events (window, GDK_CORE_POINTER, start, stop,
nevents_return);
else
return gdk_input_common_motion_events (window, deviceid, start, stop,
nevents_return);
}
static gint
gdk_input_gxi_grab_pointer (GdkWindow * window,
gint owner_events,
GdkEventMask event_mask,
GdkWindow * confine_to,
guint32 time)
{
GList *tmp_list;
GdkInputWindow *input_window;
GdkDevicePrivate *gdkdev;
tmp_list = gdk_input_windows;
while (tmp_list)
{
input_window = (GdkInputWindow *)tmp_list->data;
if (input_window->window == window)
input_window->grabbed = TRUE;
else if (input_window->grabbed)
input_window->grabbed = FALSE;
tmp_list = tmp_list->next;
}
tmp_list = gdk_input_devices;
while (tmp_list)
{
gdkdev = (GdkDevicePrivate *)tmp_list->data;
if (gdkdev->info.deviceid != GDK_CORE_POINTER &&
gdkdev->xdevice &&
(gdkdev->button_state != 0))
gdkdev->button_state = 0;
tmp_list = tmp_list->next;
}
return Success;
}
static void
gdk_input_gxi_ungrab_pointer (guint32 time)
{
GdkInputWindow *input_window;
GList *tmp_list;
tmp_list = gdk_input_windows;
while (tmp_list)
{
input_window = (GdkInputWindow *)tmp_list->data;
if (input_window->grabbed)
input_window->grabbed = FALSE;
tmp_list = tmp_list->next;
}
}
#endif /* XINPUT_GXI */

View File

@ -1,81 +0,0 @@
/* 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/.
*/
#ifdef XINPUT_NONE
static void gdk_input_none_get_pointer (GdkWindow *window,
guint32 deviceid,
gdouble *x,
gdouble *y,
gdouble *pressure,
gdouble *xtilt,
gdouble *ytilt,
GdkModifierType *mask);
void
gdk_input_init (void)
{
gdk_input_vtable.set_mode = NULL;
gdk_input_vtable.set_axes = NULL;
gdk_input_vtable.set_key = NULL;
gdk_input_vtable.motion_events = NULL;
gdk_input_vtable.get_pointer = gdk_input_none_get_pointer;
gdk_input_vtable.grab_pointer = NULL;
gdk_input_vtable.ungrab_pointer = NULL;
gdk_input_vtable.configure_event = NULL;
gdk_input_vtable.enter_event = NULL;
gdk_input_vtable.other_event = NULL;
gdk_input_vtable.window_none_event = NULL;
gdk_input_vtable.enable_window = NULL;
gdk_input_vtable.disable_window = NULL;
gdk_input_devices = g_list_append (NULL, (GdkDeviceInfo *) &gdk_input_core_info);
gdk_input_ignore_core = FALSE;
}
static void
gdk_input_none_get_pointer (GdkWindow *window,
guint32 deviceid,
gdouble *x,
gdouble *y,
gdouble *pressure,
gdouble *xtilt,
gdouble *ytilt,
GdkModifierType *mask)
{
gint x_int, y_int;
gdk_window_get_pointer (window, &x_int, &y_int, mask);
if (x) *x = x_int;
if (y) *y = y_int;
if (pressure) *pressure = 0.5;
if (xtilt) *xtilt = 0;
if (ytilt) *ytilt = 0;
}
#endif /* XINPUT_NONE */

View File

@ -1,162 +0,0 @@
/* 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/.
*/
#ifndef __GDK_INPUTPRIVATE_H__
#define __GDK_INPUTPRIVATE_H__
#ifndef XINPUT_NONE
#include <X11/extensions/XInput.h>
#endif
typedef struct _GdkAxisInfo GdkAxisInfo;
typedef struct _GdkInputVTable GdkInputVTable;
typedef struct _GdkDevicePrivate GdkDevicePrivate;
typedef struct _GdkInputWindow GdkInputWindow;
struct _GdkInputVTable {
gint (*set_mode) (guint32 deviceid, GdkInputMode mode);
void (*set_axes) (guint32 deviceid, GdkAxisUse *axes);
void (*set_key) (guint32 deviceid,
guint index,
guint keyval,
GdkModifierType modifiers);
GdkTimeCoord* (*motion_events) (GdkWindow *window,
guint32 deviceid,
guint32 start,
guint32 stop,
gint *nevents_return);
void (*get_pointer) (GdkWindow *window,
guint32 deviceid,
gdouble *x,
gdouble *y,
gdouble *pressure,
gdouble *xtilt,
gdouble *ytilt,
GdkModifierType *mask);
gint (*grab_pointer) (GdkWindow * window,
gint owner_events,
GdkEventMask event_mask,
GdkWindow * confine_to,
guint32 time);
void (*ungrab_pointer) (guint32 time);
void (*configure_event) (XConfigureEvent *xevent, GdkWindow *window);
void (*enter_event) (XCrossingEvent *xevent, GdkWindow *window);
gint (*other_event) (GdkEvent *event, XEvent *xevent, GdkWindow *window);
/* Handle an unidentified event. Returns TRUE if handled, FALSE
otherwise */
gint (*window_none_event) (GdkEvent *event, XEvent *xevent);
gint (*enable_window) (GdkWindow *window, GdkDevicePrivate *gdkdev);
gint (*disable_window) (GdkWindow *window, GdkDevicePrivate *gdkdev);
};
/* information about a device axis */
struct _GdkAxisInfo
{
/* reported x resolution */
gint xresolution;
/* reported x minimum/maximum values */
gint xmin_value, xmax_value;
/* calibrated resolution (for aspect ration) - only relative values
between axes used */
gint resolution;
/* calibrated minimum/maximum values */
gint min_value, max_value;
};
#define GDK_INPUT_NUM_EVENTC 6
struct _GdkDevicePrivate {
GdkDeviceInfo info;
#ifndef XINPUT_NONE
/* information about the axes */
GdkAxisInfo *axes;
/* reverse lookup on axis use type */
gint axis_for_use[GDK_AXIS_LAST];
/* Information about XInput device */
XDevice *xdevice;
/* minimum key code for device */
gint min_keycode;
int buttonpress_type, buttonrelease_type, keypress_type,
keyrelease_type, motionnotify_type, proximityin_type,
proximityout_type, changenotify_type;
/* true if we need to select a different set of events, but
can't because this is the core pointer */
gint needs_update;
/* Mask of buttons (used for button grabs) */
gint button_state;
/* true if we've claimed the device as active. (used only for XINPUT_GXI) */
gint claimed;
#endif /* !XINPUT_NONE */
};
struct _GdkInputWindow
{
/* gdk window */
GdkWindow *window;
/* Extension mode (GDK_EXTENSION_EVENTS_ALL/CURSOR) */
GdkExtensionMode mode;
/* position relative to root window */
gint16 root_x;
gint16 root_y;
/* rectangles relative to window of windows obscuring this one */
GdkRectangle *obscuring;
gint num_obscuring;
/* Is there a pointer grab for this window ? */
gint grabbed;
};
/* Global data */
extern GdkInputVTable gdk_input_vtable;
/* information about network port and host for gxid daemon */
extern gchar *gdk_input_gxid_host;
extern gint gdk_input_gxid_port;
extern gint gdk_input_ignore_core;
/* Function declarations */
void gdk_input_window_destroy (GdkWindow *window);
void gdk_input_init (void);
void gdk_input_exit (void);
#endif /* __GDK_INPUTPRIVATE_H__ */

View File

@ -1,374 +0,0 @@
/* 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/.
*/
#ifdef XINPUT_XFREE
/* forward declarations */
static gint gdk_input_xfree_set_mode (guint32 deviceid, GdkInputMode mode);
static void gdk_input_check_proximity (void);
static void gdk_input_xfree_configure_event (XConfigureEvent *xevent,
GdkWindow *window);
static void gdk_input_xfree_enter_event (XCrossingEvent *xevent,
GdkWindow *window);
static gint gdk_input_xfree_other_event (GdkEvent *event,
XEvent *xevent,
GdkWindow *window);
static gint gdk_input_xfree_enable_window(GdkWindow *window,
GdkDevicePrivate *gdkdev);
static gint gdk_input_xfree_disable_window(GdkWindow *window,
GdkDevicePrivate *gdkdev);
static gint gdk_input_xfree_grab_pointer (GdkWindow * window,
gint owner_events,
GdkEventMask event_mask,
GdkWindow * confine_to,
guint32 time);
static void gdk_input_xfree_ungrab_pointer (guint32 time);
void
gdk_input_init(void)
{
gdk_input_vtable.set_mode = gdk_input_xfree_set_mode;
gdk_input_vtable.set_axes = gdk_input_common_set_axes;
gdk_input_vtable.set_key = gdk_input_common_set_key;
gdk_input_vtable.motion_events = gdk_input_common_motion_events;
gdk_input_vtable.get_pointer = gdk_input_common_get_pointer;
gdk_input_vtable.grab_pointer = gdk_input_xfree_grab_pointer;
gdk_input_vtable.ungrab_pointer = gdk_input_xfree_ungrab_pointer;
gdk_input_vtable.configure_event = gdk_input_xfree_configure_event;
gdk_input_vtable.enter_event = gdk_input_xfree_enter_event;
gdk_input_vtable.other_event = gdk_input_xfree_other_event;
gdk_input_vtable.window_none_event = NULL;
gdk_input_vtable.enable_window = gdk_input_xfree_enable_window;
gdk_input_vtable.disable_window = gdk_input_xfree_disable_window;
gdk_input_ignore_core = FALSE;
gdk_input_common_init(FALSE);
}
static gint
gdk_input_xfree_set_mode (guint32 deviceid, GdkInputMode mode)
{
GList *tmp_list;
GdkDevicePrivate *gdkdev;
GdkInputMode old_mode;
GdkInputWindow *input_window;
gdkdev = gdk_input_find_device(deviceid);
g_return_val_if_fail (gdkdev != NULL,FALSE);
old_mode = gdkdev->info.mode;
if (gdkdev->info.mode == mode)
return TRUE;
gdkdev->info.mode = mode;
if (mode == GDK_MODE_WINDOW)
{
gdkdev->info.has_cursor = FALSE;
for (tmp_list = gdk_input_windows; tmp_list; tmp_list = tmp_list->next)
{
input_window = (GdkInputWindow *)tmp_list->data;
if (input_window->mode != GDK_EXTENSION_EVENTS_CURSOR)
gdk_input_enable_window (input_window->window, gdkdev);
else
if (old_mode != GDK_MODE_DISABLED)
gdk_input_disable_window (input_window->window, gdkdev);
}
}
else if (mode == GDK_MODE_SCREEN)
{
gdkdev->info.has_cursor = TRUE;
for (tmp_list = gdk_input_windows; tmp_list; tmp_list = tmp_list->next)
gdk_input_enable_window (((GdkInputWindow *)tmp_list->data)->window,
gdkdev);
}
else /* mode == GDK_MODE_DISABLED */
{
for (tmp_list = gdk_input_windows; tmp_list; tmp_list = tmp_list->next)
{
input_window = (GdkInputWindow *)tmp_list->data;
if (old_mode != GDK_MODE_WINDOW ||
input_window->mode != GDK_EXTENSION_EVENTS_CURSOR)
gdk_input_disable_window (input_window->window, gdkdev);
}
}
return TRUE;
}
static void
gdk_input_check_proximity (void)
{
gint new_proximity = 0;
GList *tmp_list = gdk_input_devices;
while (tmp_list && !new_proximity)
{
GdkDevicePrivate *gdkdev = (GdkDevicePrivate *)(tmp_list->data);
if (gdkdev->info.mode != GDK_MODE_DISABLED
&& gdkdev->info.deviceid != GDK_CORE_POINTER
&& gdkdev->xdevice)
{
XDeviceState *state = XQueryDeviceState(GDK_DISPLAY(),
gdkdev->xdevice);
XInputClass *xic;
int i;
xic = state->data;
for (i=0; i<state->num_classes; i++)
{
if (xic->class == ValuatorClass)
{
XValuatorState *xvs = (XValuatorState *)xic;
if ((xvs->mode & ProximityState) == InProximity)
{
new_proximity = TRUE;
}
break;
}
xic = (XInputClass *)((char *)xic + xic->length);
}
}
tmp_list = tmp_list->next;
}
gdk_input_ignore_core = new_proximity;
}
static void
gdk_input_xfree_configure_event (XConfigureEvent *xevent, GdkWindow *window)
{
GdkInputWindow *input_window;
gint root_x, root_y;
input_window = gdk_input_window_find(window);
g_return_if_fail (window != NULL);
gdk_input_get_root_relative_geometry(GDK_DISPLAY(),GDK_WINDOW_XWINDOW(window),
&root_x,
&root_y, NULL, NULL);
input_window->root_x = root_x;
input_window->root_y = root_y;
}
static void
gdk_input_xfree_enter_event (XCrossingEvent *xevent,
GdkWindow *window)
{
GdkInputWindow *input_window;
gint root_x, root_y;
input_window = gdk_input_window_find(window);
g_return_if_fail (window != NULL);
gdk_input_check_proximity();
gdk_input_get_root_relative_geometry(GDK_DISPLAY(),GDK_WINDOW_XWINDOW(window),
&root_x,
&root_y, NULL, NULL);
input_window->root_x = root_x;
input_window->root_y = root_y;
}
static gint
gdk_input_xfree_other_event (GdkEvent *event,
XEvent *xevent,
GdkWindow *window)
{
GdkInputWindow *input_window;
GdkDevicePrivate *gdkdev;
gint return_val;
input_window = gdk_input_window_find(window);
g_return_val_if_fail (window != NULL, -1);
/* This is a sort of a hack, as there isn't any XDeviceAnyEvent -
but it's potentially faster than scanning through the types of
every device. If we were deceived, then it won't match any of
the types for the device anyways */
gdkdev = gdk_input_find_device(((XDeviceButtonEvent *)xevent)->deviceid);
if (!gdkdev) {
return -1; /* we don't handle it - not an XInput event */
}
/* FIXME: It would be nice if we could just get rid of the events
entirely, instead of having to ignore them */
if (gdkdev->info.mode == GDK_MODE_DISABLED ||
(gdkdev->info.mode == GDK_MODE_WINDOW
&& input_window->mode == GDK_EXTENSION_EVENTS_CURSOR))
return FALSE;
if (!gdk_input_ignore_core)
gdk_input_check_proximity();
return_val = gdk_input_common_other_event (event, xevent,
input_window, gdkdev);
if (return_val > 0 && event->type == GDK_PROXIMITY_OUT &&
gdk_input_ignore_core)
gdk_input_check_proximity();
return return_val;
}
static gint
gdk_input_xfree_enable_window(GdkWindow *window, GdkDevicePrivate *gdkdev)
{
/* FIXME: watchout, gdkdev might be core pointer, never opened */
gdk_input_common_select_events (window, gdkdev);
return TRUE;
}
static gint
gdk_input_xfree_disable_window(GdkWindow *window, GdkDevicePrivate *gdkdev)
{
gdk_input_common_select_events (window, gdkdev);
return TRUE;
}
static gint
gdk_input_xfree_grab_pointer (GdkWindow * window,
gint owner_events,
GdkEventMask event_mask,
GdkWindow * confine_to,
guint32 time)
{
GdkInputWindow *input_window, *new_window;
gboolean need_ungrab;
GdkDevicePrivate *gdkdev;
GList *tmp_list;
XEventClass event_classes[GDK_MAX_DEVICE_CLASSES];
gint num_classes;
gint result;
tmp_list = gdk_input_windows;
new_window = NULL;
need_ungrab = FALSE;
while (tmp_list)
{
input_window = (GdkInputWindow *)tmp_list->data;
if (input_window->window == window)
new_window = input_window;
else if (input_window->grabbed)
{
input_window->grabbed = FALSE;
need_ungrab = TRUE;
}
tmp_list = tmp_list->next;
}
if (new_window)
{
new_window->grabbed = TRUE;
tmp_list = gdk_input_devices;
while (tmp_list)
{
gdkdev = (GdkDevicePrivate *)tmp_list->data;
if (gdkdev->info.deviceid != GDK_CORE_POINTER &&
gdkdev->xdevice)
{
gdk_input_common_find_events (window, gdkdev,
event_mask,
event_classes, &num_classes);
result = XGrabDevice( GDK_DISPLAY(), gdkdev->xdevice,
GDK_WINDOW_XWINDOW (window),
owner_events, num_classes, event_classes,
GrabModeAsync, GrabModeAsync, time);
/* FIXME: if failure occurs on something other than the first
device, things will be badly inconsistent */
if (result != Success)
return result;
}
tmp_list = tmp_list->next;
}
}
else
{
tmp_list = gdk_input_devices;
while (tmp_list)
{
gdkdev = (GdkDevicePrivate *)tmp_list->data;
if (gdkdev->info.deviceid != GDK_CORE_POINTER && gdkdev->xdevice &&
((gdkdev->button_state != 0) || need_ungrab))
{
XUngrabDevice( gdk_display, gdkdev->xdevice, time);
gdkdev->button_state = 0;
}
tmp_list = tmp_list->next;
}
}
return Success;
}
static void
gdk_input_xfree_ungrab_pointer (guint32 time)
{
GdkInputWindow *input_window;
GdkDevicePrivate *gdkdev;
GList *tmp_list;
tmp_list = gdk_input_windows;
while (tmp_list)
{
input_window = (GdkInputWindow *)tmp_list->data;
if (input_window->grabbed)
break;
tmp_list = tmp_list->next;
}
if (tmp_list) /* we found a grabbed window */
{
input_window->grabbed = FALSE;
tmp_list = gdk_input_devices;
while (tmp_list)
{
gdkdev = (GdkDevicePrivate *)tmp_list->data;
if (gdkdev->info.deviceid != GDK_CORE_POINTER && gdkdev->xdevice)
XUngrabDevice( gdk_display, gdkdev->xdevice, time);
tmp_list = tmp_list->next;
}
}
}
#endif /* XINPUT_XFREE */

View File

@ -1,826 +0,0 @@
/* 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 "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
/* Needed for SEEK_END in SunOS */
#include <unistd.h>
#include <X11/Xlib.h>
#include "gdkpixmap.h"
#include "gdkprivate.h"
#include "gdkx.h"
typedef struct
{
gchar *color_string;
GdkColor color;
gint transparent;
} _GdkPixmapColor;
typedef struct
{
guint ncolors;
GdkColormap *colormap;
gulong pixels[1];
} _GdkPixmapInfo;
GdkPixmap*
gdk_pixmap_new (GdkWindow *window,
gint width,
gint height,
gint depth)
{
GdkPixmap *pixmap;
GdkDrawablePrivate *private;
g_return_val_if_fail (window == NULL || GDK_IS_WINDOW (window), NULL);
g_return_val_if_fail ((window != NULL) || (depth != -1), NULL);
g_return_val_if_fail ((width != 0) && (height != 0), NULL);
if (!window)
window = (GdkWindow*) &gdk_root_parent;
if (GDK_DRAWABLE_DESTROYED (window))
return NULL;
if (depth == -1)
depth = gdk_drawable_get_visual (window)->depth;
private = g_new0 (GdkDrawablePrivate, 1);
pixmap = (GdkPixmap*) private;
private->xdisplay = GDK_DRAWABLE_XDISPLAY (window);
private->window_type = GDK_DRAWABLE_PIXMAP;
private->xwindow = XCreatePixmap (private->xdisplay,
GDK_DRAWABLE_XID (window),
width, height, depth);
private->colormap = NULL;
private->width = width;
private->height = height;
private->ref_count = 1;
private->destroyed = 0;
gdk_xid_table_insert (&private->xwindow, pixmap);
return pixmap;
}
GdkPixmap *
gdk_bitmap_create_from_data (GdkWindow *window,
const gchar *data,
gint width,
gint height)
{
GdkPixmap *pixmap;
GdkDrawablePrivate *private;
g_return_val_if_fail (data != NULL, NULL);
g_return_val_if_fail ((width != 0) && (height != 0), NULL);
g_return_val_if_fail (window == NULL || GDK_IS_WINDOW (window), NULL);
if (!window)
window = (GdkWindow*) &gdk_root_parent;
if (GDK_DRAWABLE_DESTROYED (window))
return NULL;
private = g_new0 (GdkDrawablePrivate, 1);
pixmap = (GdkPixmap*) private;
private->xdisplay = GDK_DRAWABLE_XDISPLAY (window);
private->window_type = GDK_DRAWABLE_PIXMAP;
private->width = width;
private->height = height;
private->ref_count = 1;
private->destroyed = FALSE;
private->xwindow = XCreateBitmapFromData (private->xdisplay,
GDK_DRAWABLE_XID (window),
(char *)data, width, height);
gdk_xid_table_insert (&private->xwindow, pixmap);
return pixmap;
}
GdkPixmap*
gdk_pixmap_create_from_data (GdkWindow *window,
const gchar *data,
gint width,
gint height,
gint depth,
GdkColor *fg,
GdkColor *bg)
{
GdkPixmap *pixmap;
GdkDrawablePrivate *private;
g_return_val_if_fail (window == NULL || GDK_IS_WINDOW (window), NULL);
g_return_val_if_fail (data != NULL, NULL);
g_return_val_if_fail (fg != NULL, NULL);
g_return_val_if_fail (bg != NULL, NULL);
g_return_val_if_fail ((window != NULL) || (depth != -1), NULL);
g_return_val_if_fail ((width != 0) && (height != 0), NULL);
if (!window)
window = (GdkWindow*) &gdk_root_parent;
if (GDK_DRAWABLE_DESTROYED (window))
return NULL;
if (depth == -1)
depth = gdk_drawable_get_visual (window)->depth;
private = g_new0 (GdkDrawablePrivate, 1);
pixmap = (GdkPixmap*) private;
private->xdisplay = GDK_DRAWABLE_XDISPLAY (window);
private->window_type = GDK_DRAWABLE_PIXMAP;
private->width = width;
private->height = height;
private->ref_count = 1;
private->destroyed = FALSE;
private->xwindow = XCreatePixmapFromBitmapData (private->xdisplay,
GDK_DRAWABLE_XID (window),
(char *)data, width, height,
fg->pixel, bg->pixel, depth);
gdk_xid_table_insert (&private->xwindow, pixmap);
return pixmap;
}
static gint
gdk_pixmap_seek_string (FILE *infile,
const gchar *str,
gint skip_comments)
{
char instr[1024];
while (!feof (infile))
{
fscanf (infile, "%1023s", instr);
if (skip_comments == TRUE && strcmp (instr, "/*") == 0)
{
fscanf (infile, "%1023s", instr);
while (!feof (infile) && strcmp (instr, "*/") != 0)
fscanf (infile, "%1023s", instr);
fscanf(infile, "%1023s", instr);
}
if (strcmp (instr, str)==0)
return TRUE;
}
return FALSE;
}
static gint
gdk_pixmap_seek_char (FILE *infile,
gchar c)
{
gint b, oldb;
while ((b = getc(infile)) != EOF)
{
if (c != b && b == '/')
{
b = getc (infile);
if (b == EOF)
return FALSE;
else if (b == '*') /* we have a comment */
{
b = -1;
do
{
oldb = b;
b = getc (infile);
if (b == EOF)
return FALSE;
}
while (!(oldb == '*' && b == '/'));
}
}
else if (c == b)
return TRUE;
}
return FALSE;
}
static gint
gdk_pixmap_read_string (FILE *infile,
gchar **buffer,
guint *buffer_size)
{
gint c;
guint cnt = 0, bufsiz, ret = FALSE;
gchar *buf;
buf = *buffer;
bufsiz = *buffer_size;
if (buf == NULL)
{
bufsiz = 10 * sizeof (gchar);
buf = g_new(gchar, bufsiz);
}
do
c = getc (infile);
while (c != EOF && c != '"');
if (c != '"')
goto out;
while ((c = getc(infile)) != EOF)
{
if (cnt == bufsiz)
{
guint new_size = bufsiz * 2;
if (new_size > bufsiz)
bufsiz = new_size;
else
goto out;
buf = (gchar *) g_realloc (buf, bufsiz);
buf[bufsiz-1] = '\0';
}
if (c != '"')
buf[cnt++] = c;
else
{
buf[cnt] = 0;
ret = TRUE;
break;
}
}
out:
buf[bufsiz-1] = '\0'; /* ensure null termination for errors */
*buffer = buf;
*buffer_size = bufsiz;
return ret;
}
static gchar*
gdk_pixmap_skip_whitespaces (gchar *buffer)
{
gint32 index = 0;
while (buffer[index] != 0 && (buffer[index] == 0x20 || buffer[index] == 0x09))
index++;
return &buffer[index];
}
static gchar*
gdk_pixmap_skip_string (gchar *buffer)
{
gint32 index = 0;
while (buffer[index] != 0 && buffer[index] != 0x20 && buffer[index] != 0x09)
index++;
return &buffer[index];
}
/* Xlib crashed ince at a color name lengths around 125 */
#define MAX_COLOR_LEN 120
static gchar*
gdk_pixmap_extract_color (gchar *buffer)
{
gint counter, numnames;
gchar *ptr = NULL, ch, temp[128];
gchar color[MAX_COLOR_LEN], *retcol;
gint space;
counter = 0;
while (ptr == NULL)
{
if (buffer[counter] == 'c')
{
ch = buffer[counter + 1];
if (ch == 0x20 || ch == 0x09)
ptr = &buffer[counter + 1];
}
else if (buffer[counter] == 0)
return NULL;
counter++;
}
ptr = gdk_pixmap_skip_whitespaces (ptr);
if (ptr[0] == 0)
return NULL;
else if (ptr[0] == '#')
{
counter = 1;
while (ptr[counter] != 0 &&
((ptr[counter] >= '0' && ptr[counter] <= '9') ||
(ptr[counter] >= 'a' && ptr[counter] <= 'f') ||
(ptr[counter] >= 'A' && ptr[counter] <= 'F')))
counter++;
retcol = g_new (gchar, counter+1);
strncpy (retcol, ptr, counter);
retcol[counter] = 0;
return retcol;
}
color[0] = 0;
numnames = 0;
space = MAX_COLOR_LEN - 1;
while (space > 0)
{
sscanf (ptr, "%127s", temp);
if (((gint)ptr[0] == 0) ||
(strcmp ("s", temp) == 0) || (strcmp ("m", temp) == 0) ||
(strcmp ("g", temp) == 0) || (strcmp ("g4", temp) == 0))
{
break;
}
else
{
if (numnames > 0)
{
space -= 1;
strcat (color, " ");
}
strncat (color, temp, space);
space -= MIN (space, strlen (temp));
ptr = gdk_pixmap_skip_string (ptr);
ptr = gdk_pixmap_skip_whitespaces (ptr);
numnames++;
}
}
retcol = g_strdup (color);
return retcol;
}
enum buffer_op
{
op_header,
op_cmap,
op_body
};
static void
gdk_xpm_destroy_notify (gpointer data)
{
_GdkPixmapInfo *info = (_GdkPixmapInfo *)data;
GdkColor color;
int i;
for (i=0; i<info->ncolors; i++)
{
color.pixel = info->pixels[i];
gdk_colormap_free_colors (info->colormap, &color, 1);
}
gdk_colormap_unref (info->colormap);
g_free (info);
}
static GdkPixmap *
_gdk_pixmap_create_from_xpm (GdkWindow *window,
GdkColormap *colormap,
GdkBitmap **mask,
GdkColor *transparent_color,
gchar * (*get_buf) (enum buffer_op op,
gpointer handle),
gpointer handle)
{
GdkPixmap *pixmap = NULL;
GdkImage *image = NULL;
GdkVisual *visual;
GdkGC *gc = NULL;
GdkColor tmp_color;
gint width, height, num_cols, cpp, n, ns, cnt, xcnt, ycnt, wbytes;
gchar *buffer, pixel_str[32];
gchar *name_buf;
_GdkPixmapColor *color = NULL, *fallbackcolor = NULL;
_GdkPixmapColor *colors = NULL;
gulong index;
GHashTable *color_hash = NULL;
_GdkPixmapInfo *color_info = NULL;
if ((window == NULL) && (colormap == NULL))
g_warning ("Creating pixmap from xpm with NULL window and colormap");
if (window == NULL)
window = (GdkWindow *)&gdk_root_parent;
if (colormap == NULL)
{
colormap = gdk_drawable_get_colormap (window);
visual = gdk_drawable_get_visual (window);
}
else
visual = ((GdkColormapPrivate *)colormap)->visual;
buffer = (*get_buf) (op_header, handle);
if (buffer == NULL)
return NULL;
sscanf (buffer,"%d %d %d %d", &width, &height, &num_cols, &cpp);
if (cpp >= 32)
{
g_warning ("Pixmap has more than 31 characters per color\n");
return NULL;
}
color_hash = g_hash_table_new (g_str_hash, g_str_equal);
if (transparent_color == NULL)
{
gdk_color_white (colormap, &tmp_color);
transparent_color = &tmp_color;
}
/* For pseudo-color and grayscale visuals, we have to remember
* the colors we allocated, so we can free them later.
*/
if ((visual->type == GDK_VISUAL_PSEUDO_COLOR) ||
(visual->type == GDK_VISUAL_GRAYSCALE))
{
color_info = g_malloc (sizeof (_GdkPixmapInfo) +
sizeof(gulong) * (num_cols - 1));
color_info->ncolors = num_cols;
color_info->colormap = colormap;
gdk_colormap_ref (colormap);
}
name_buf = g_new (gchar, num_cols * (cpp+1));
colors = g_new (_GdkPixmapColor, num_cols);
for (cnt = 0; cnt < num_cols; cnt++)
{
gchar *color_name;
buffer = (*get_buf) (op_cmap, handle);
if (buffer == NULL)
goto error;
color = &colors[cnt];
color->color_string = &name_buf [cnt * (cpp + 1)];
strncpy (color->color_string, buffer, cpp);
color->color_string[cpp] = 0;
buffer += strlen (color->color_string);
color->transparent = FALSE;
color_name = gdk_pixmap_extract_color (buffer);
if (color_name == NULL || g_strcasecmp (color_name, "None") == 0 ||
gdk_color_parse (color_name, &color->color) == FALSE)
{
color->color = *transparent_color;
color->transparent = TRUE;
}
g_free (color_name);
/* FIXME: The remaining slowness appears to happen in this
function. */
gdk_color_alloc (colormap, &color->color);
if (color_info)
color_info->pixels[cnt] = color->color.pixel;
g_hash_table_insert (color_hash, color->color_string, color);
if (cnt == 0)
fallbackcolor = color;
}
index = 0;
image = gdk_image_new (GDK_IMAGE_FASTEST, visual, width, height);
if (mask)
{
/* The pixmap mask is just a bits pattern.
* Color 0 is used for background and 1 for foreground.
* We don't care about the colormap, we just need 0 and 1.
*/
GdkColor mask_pattern;
*mask = gdk_pixmap_new (window, width, height, 1);
gc = gdk_gc_new (*mask);
mask_pattern.pixel = 0;
gdk_gc_set_foreground (gc, &mask_pattern);
gdk_draw_rectangle (*mask, gc, TRUE, 0, 0, -1, -1);
mask_pattern.pixel = 1;
gdk_gc_set_foreground (gc, &mask_pattern);
}
wbytes = width * cpp;
for (ycnt = 0; ycnt < height; ycnt++)
{
buffer = (*get_buf) (op_body, handle);
/* FIXME: this slows things down a little - it could be
* integrated into the strncpy below, perhaps. OTOH, strlen
* is fast.
*/
if ((buffer == NULL) || strlen (buffer) < wbytes)
continue;
for (n = 0, cnt = 0, xcnt = 0; n < wbytes; n += cpp, xcnt++)
{
strncpy (pixel_str, &buffer[n], cpp);
pixel_str[cpp] = 0;
ns = 0;
color = g_hash_table_lookup (color_hash, pixel_str);
if (!color) /* screwed up XPM file */
color = fallbackcolor;
gdk_image_put_pixel (image, xcnt, ycnt, color->color.pixel);
if (mask && color->transparent)
{
if (cnt < xcnt)
gdk_draw_line (*mask, gc, cnt, ycnt, xcnt - 1, ycnt);
cnt = xcnt + 1;
}
}
if (mask && (cnt < xcnt))
gdk_draw_line (*mask, gc, cnt, ycnt, xcnt - 1, ycnt);
}
error:
if (mask)
gdk_gc_destroy (gc);
if (image != NULL)
{
pixmap = gdk_pixmap_new (window, width, height, visual->depth);
if (color_info)
gdk_drawable_set_data (pixmap, "gdk-xpm", color_info,
gdk_xpm_destroy_notify);
gc = gdk_gc_new (pixmap);
gdk_gc_set_foreground (gc, transparent_color);
gdk_draw_image (pixmap, gc, image, 0, 0, 0, 0, image->width, image->height);
gdk_gc_destroy (gc);
gdk_image_destroy (image);
}
else if (color_info)
gdk_xpm_destroy_notify (color_info);
if (color_hash != NULL)
g_hash_table_destroy (color_hash);
if (colors != NULL)
g_free (colors);
if (name_buf != NULL)
g_free (name_buf);
return pixmap;
}
struct file_handle
{
FILE *infile;
gchar *buffer;
guint buffer_size;
};
static gchar *
file_buffer (enum buffer_op op, gpointer handle)
{
struct file_handle *h = handle;
switch (op)
{
case op_header:
if (gdk_pixmap_seek_string (h->infile, "XPM", FALSE) != TRUE)
break;
if (gdk_pixmap_seek_char (h->infile,'{') != TRUE)
break;
/* Fall through to the next gdk_pixmap_seek_char. */
case op_cmap:
gdk_pixmap_seek_char (h->infile, '"');
fseek (h->infile, -1, SEEK_CUR);
/* Fall through to the gdk_pixmap_read_string. */
case op_body:
gdk_pixmap_read_string (h->infile, &h->buffer, &h->buffer_size);
return h->buffer;
}
return 0;
}
GdkPixmap*
gdk_pixmap_colormap_create_from_xpm (GdkWindow *window,
GdkColormap *colormap,
GdkBitmap **mask,
GdkColor *transparent_color,
const gchar *filename)
{
struct file_handle h;
GdkPixmap *pixmap = NULL;
memset (&h, 0, sizeof (h));
h.infile = fopen (filename, "rb");
if (h.infile != NULL)
{
pixmap = _gdk_pixmap_create_from_xpm (window, colormap, mask,
transparent_color,
file_buffer, &h);
fclose (h.infile);
g_free (h.buffer);
}
return pixmap;
}
GdkPixmap*
gdk_pixmap_create_from_xpm (GdkWindow *window,
GdkBitmap **mask,
GdkColor *transparent_color,
const gchar *filename)
{
return gdk_pixmap_colormap_create_from_xpm (window, NULL, mask,
transparent_color, filename);
}
struct mem_handle
{
gchar **data;
int offset;
};
static gchar *
mem_buffer (enum buffer_op op, gpointer handle)
{
struct mem_handle *h = handle;
switch (op)
{
case op_header:
case op_cmap:
case op_body:
if (h->data[h->offset])
return h->data[h->offset ++];
}
return 0;
}
GdkPixmap*
gdk_pixmap_colormap_create_from_xpm_d (GdkWindow *window,
GdkColormap *colormap,
GdkBitmap **mask,
GdkColor *transparent_color,
gchar **data)
{
struct mem_handle h;
GdkPixmap *pixmap = NULL;
memset (&h, 0, sizeof (h));
h.data = data;
pixmap = _gdk_pixmap_create_from_xpm (window, colormap, mask,
transparent_color,
mem_buffer, &h);
return pixmap;
}
GdkPixmap*
gdk_pixmap_create_from_xpm_d (GdkWindow *window,
GdkBitmap **mask,
GdkColor *transparent_color,
gchar **data)
{
return gdk_pixmap_colormap_create_from_xpm_d (window, NULL, mask,
transparent_color, data);
}
GdkPixmap*
gdk_pixmap_foreign_new (guint32 anid)
{
GdkPixmap *pixmap;
GdkDrawablePrivate *private;
Pixmap xpixmap;
Window root_return;
unsigned int x_ret, y_ret, w_ret, h_ret, bw_ret, depth_ret;
/* check to make sure we were passed something at
least a little sane */
g_return_val_if_fail((anid != 0), NULL);
/* set the pixmap to the passed in value */
xpixmap = anid;
/* get information about the Pixmap to fill in the structure for
the gdk window */
if (!XGetGeometry(GDK_DISPLAY(),
xpixmap, &root_return,
&x_ret, &y_ret, &w_ret, &h_ret, &bw_ret, &depth_ret))
return NULL;
/* allocate a new gdk pixmap */
private = g_new(GdkDrawablePrivate, 1);
pixmap = (GdkPixmap *)private;
private->xdisplay = GDK_DISPLAY();
private->window_type = GDK_DRAWABLE_PIXMAP;
private->xwindow = xpixmap;
private->colormap = NULL;
private->width = w_ret;
private->height = h_ret;
private->ref_count = 1;
private->destroyed = 0;
gdk_xid_table_insert(&private->xwindow, pixmap);
return pixmap;
}
GdkPixmap*
gdk_pixmap_ref (GdkPixmap *pixmap)
{
GdkDrawablePrivate *private = (GdkDrawablePrivate *)pixmap;
g_return_val_if_fail (pixmap != NULL, NULL);
g_return_val_if_fail (GDK_IS_PIXMAP (private), NULL);
private->ref_count += 1;
return pixmap;
}
void
gdk_pixmap_unref (GdkPixmap *pixmap)
{
GdkDrawablePrivate *private = (GdkDrawablePrivate *)pixmap;
g_return_if_fail (pixmap != NULL);
g_return_if_fail (GDK_IS_PIXMAP (private));
g_return_if_fail (private->ref_count > 0);
private->ref_count -= 1;
if (private->ref_count == 0)
{
XFreePixmap (private->xdisplay, private->xwindow);
gdk_xid_table_remove (private->xwindow);
g_dataset_destroy (private);
g_free (private);
}
}
GdkBitmap *
gdk_bitmap_ref (GdkBitmap *bitmap)
{
return (GdkBitmap *)gdk_pixmap_ref ((GdkPixmap *)bitmap);
}
void
gdk_bitmap_unref (GdkBitmap *bitmap)
{
gdk_pixmap_unref ((GdkPixmap *)bitmap);
}

View File

@ -27,13 +27,7 @@
#ifndef __GDK_PRIVATE_H__
#define __GDK_PRIVATE_H__
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <gdk/gdktypes.h>
#include <gdk/gdkcursor.h>
#include <gdk/gdkevents.h>
#include <gdk/gdkfont.h>
#include <gdk/gdkgc.h>
@ -60,20 +54,20 @@ extern "C" {
typedef struct _GdkDrawablePrivate GdkDrawablePrivate;
/* typedef struct _GdkDrawablePrivate GdkPixmapPrivate; */
typedef struct _GdkWindowPrivate GdkWindowPrivate;
typedef struct _GdkImageClass GdkImageClass;
typedef struct _GdkImagePrivate GdkImagePrivate;
typedef struct _GdkGCPrivate GdkGCPrivate;
typedef struct _GdkColormapPrivate GdkColormapPrivate;
typedef struct _GdkColorInfo GdkColorInfo;
typedef struct _GdkVisualPrivate GdkVisualPrivate;
typedef struct _GdkFontPrivate GdkFontPrivate;
typedef struct _GdkCursorPrivate GdkCursorPrivate;
typedef struct _GdkEventFilter GdkEventFilter;
typedef struct _GdkClientFilter GdkClientFilter;
typedef struct _GdkRegionPrivate GdkRegionPrivate;
struct _GdkDrawablePrivate
{
GdkDrawable drawable;
GdkDrawableClass *klass;
gpointer klass_data;
guint8 window_type;
guint ref_count;
@ -81,8 +75,6 @@ struct _GdkDrawablePrivate
guint16 width;
guint16 height;
Window xwindow;
Display *xdisplay;
GdkColormap *colormap;
guint destroyed : 2;
@ -92,7 +84,6 @@ struct _GdkWindowPrivate
{
GdkDrawablePrivate drawable;
GdkWindow window;
GdkWindow *parent;
gint16 x;
gint16 y;
@ -103,20 +94,15 @@ struct _GdkWindowPrivate
gint extension_events;
GList *filters;
GdkColormap *colormap;
GList *children;
};
struct _GdkImagePrivate
struct _GdkImageClass
{
GdkImage image;
XImage *ximage;
Display *xdisplay;
gpointer x_shm_info;
void (*image_put) (GdkDrawable *window,
void (*destroy) (GdkImage *image);
void (*image_put) (GdkImage *image,
GdkDrawable *window,
GdkGC *gc,
GdkImage *image,
gint xsrc,
gint ysrc,
gint xdest,
@ -125,12 +111,25 @@ struct _GdkImagePrivate
gint height);
};
struct _GdkImagePrivate
{
GdkImage image;
guint ref_count;
GdkImageClass *klass;
};
struct _GdkFontPrivate
{
GdkFont font;
guint ref_count;
};
struct _GdkGCPrivate
{
GdkGC gc;
GC xgc;
Display *xdisplay;
guint ref_count;
GdkGCClass *klass;
gpointer klass_data;
};
typedef enum {
@ -146,71 +145,11 @@ struct _GdkColorInfo
struct _GdkColormapPrivate
{
GdkColormap colormap;
Colormap xcolormap;
Display *xdisplay;
GdkVisual *visual;
gint private_val;
GHashTable *hash;
GdkColorInfo *info;
time_t last_sync_time;
guint ref_count;
};
struct _GdkVisualPrivate
{
GdkVisual visual;
Visual *xvisual;
};
struct _GdkFontPrivate
{
GdkFont font;
/* XFontStruct *xfont; */
/* generic pointer point to XFontStruct or XFontSet */
gpointer xfont;
Display *xdisplay;
guint ref_count;
GSList *names;
};
struct _GdkCursorPrivate
{
GdkCursor cursor;
Cursor xcursor;
Display *xdisplay;
};
struct _GdkDndCursorInfo {
Cursor gdk_cursor_dragdefault, gdk_cursor_dragok;
GdkWindow *drag_pm_default, *drag_pm_ok;
GdkPoint default_hotspot, ok_hotspot;
GList *xids;
};
typedef struct _GdkDndCursorInfo GdkDndCursorInfo;
struct _GdkDndGlobals {
GdkAtom gdk_XdeEnter, gdk_XdeLeave, gdk_XdeRequest;
GdkAtom gdk_XdeDataAvailable, gdk_XdeDataShow, gdk_XdeCancel;
GdkAtom gdk_XdeTypelist;
GdkDndCursorInfo *c;
GdkWindow **drag_startwindows;
guint drag_numwindows;
gboolean drag_really, drag_perhaps, dnd_grabbed;
Window dnd_drag_target;
GdkPoint drag_dropcoords;
GdkPoint dnd_drag_start, dnd_drag_oldpos;
GdkRectangle dnd_drag_dropzone;
GdkWindowPrivate *real_sw;
Window dnd_drag_curwin;
Time last_drop_time; /* An incredible hack, sosumi miguel */
};
typedef struct _GdkDndGlobals GdkDndGlobals;
struct _GdkEventFilter {
GdkFilterFunc function;
gpointer data;
@ -222,25 +161,36 @@ struct _GdkClientFilter {
gpointer data;
};
#ifdef USE_XIM
typedef struct _GdkICPrivate GdkICPrivate;
struct _GdkICPrivate
typedef enum
{
XIC xic;
GdkICAttr *attr;
GdkICAttributesType mask;
GDK_ARG_STRING,
GDK_ARG_INT,
GDK_ARG_BOOL,
GDK_ARG_NOBOOL,
GDK_ARG_CALLBACK
} GdkArgType;
typedef struct _GdkArgContext GdkArgContext;
typedef struct _GdkArgDesc GdkArgDesc;
typedef void (*GdkArgFunc) (const char *name, const char *arg, gpointer data);
struct _GdkArgContext
{
GPtrArray *tables;
gpointer cb_data;
};
#endif /* USE_XIM */
struct _GdkRegionPrivate
struct _GdkArgDesc
{
GdkRegion region;
Region xregion;
const char *name;
GdkArgType type;
gpointer location;
GdkArgFunc callback;
};
typedef enum {
GDK_DEBUG_MISC = 1 << 0,
GDK_DEBUG_EVENTS = 1 << 1,
@ -249,7 +199,28 @@ typedef enum {
GDK_DEBUG_XIM = 1 << 4
} GdkDebugFlag;
void gdk_event_button_generate (GdkEvent *event);
/* FIFO's for event queue, and for events put back using
* gdk_event_put().
*/
extern GList *gdk_queued_events;
extern GList *gdk_queued_tail;
extern GdkEventFunc gdk_event_func; /* Callback for events */
extern gpointer gdk_event_data;
extern GDestroyNotify gdk_event_notify;
GdkEvent* gdk_event_new (void);
void gdk_events_init (void);
void gdk_events_queue (void);
GdkEvent* gdk_event_unqueue (void);
GList* gdk_event_queue_find_first (void);
void gdk_event_queue_remove_link (GList *node);
void gdk_event_queue_append (GdkEvent *event);
void gdk_window_init (void);
void gdk_visual_init (void);
void gdk_dnd_init (void);
@ -257,20 +228,14 @@ void gdk_dnd_init (void);
void gdk_image_init (void);
void gdk_image_exit (void);
GdkColormap* gdk_colormap_lookup (Colormap xcolormap);
GdkVisual* gdk_visual_lookup (Visual *xvisual);
void gdk_input_init (void);
void gdk_input_exit (void);
void gdk_windowing_exit (void);
void gdk_window_add_colormap_windows (GdkWindow *window);
void gdk_window_destroy_notify (GdkWindow *window);
void gdk_xid_table_insert (XID *xid,
gpointer data);
void gdk_xid_table_remove (XID xid);
gpointer gdk_xid_table_lookup (XID xid);
gint gdk_send_xevent (Window window, gboolean propagate, glong event_mask,
XEvent *event_send);
/* If you pass x = y = -1, it queries the pointer
to find out where it currently is.
If you pass x = y = -2, it does anything necessary
@ -281,47 +246,32 @@ void gdk_dnd_display_drag_cursor(gint x,
gboolean drag_ok,
gboolean change_made);
/* Please see gdkwindow.c for comments on how to use */
Window gdk_window_xid_at(Window base, gint bx, gint by, gint x, gint y, GList *excludes, gboolean excl_child);
Window gdk_window_xid_at_coords(gint x, gint y, GList *excludes, gboolean excl_child);
extern gint gdk_debug_level;
extern gint gdk_show_events;
extern gint gdk_use_xshm;
extern gint gdk_stack_trace;
extern gchar *gdk_display_name;
extern Display *gdk_display;
extern gboolean gdk_show_events;
extern gint gdk_screen;
extern Window gdk_root_window;
extern Window gdk_leader_window;
extern GdkWindowPrivate gdk_root_parent;
extern Atom gdk_wm_delete_window;
extern Atom gdk_wm_take_focus;
extern Atom gdk_wm_protocols;
extern Atom gdk_wm_window_protocols[];
extern Atom gdk_selection_property;
extern GdkDndGlobals gdk_dnd;
extern GdkWindow *selection_owner[];
extern gchar *gdk_progclass;
extern GdkWindow *gdk_parent_root;
extern gint gdk_error_code;
extern gint gdk_error_warnings;
extern gint gdk_null_window_warnings;
extern GList *gdk_default_filters;
extern const int gdk_nevent_masks;
extern const int gdk_event_mask_table[];
extern GdkWindowPrivate *gdk_xgrab_window; /* Window that currently holds the
* x pointer grab
*/
GdkWindow* _gdk_window_alloc (void);
/* Font/string functions implemented in module-specific code */
gint _gdk_font_strlen (GdkFont *font, const char *str);
void _gdk_font_destroy (GdkFont *font);
void _gdk_colormap_real_destroy (GdkColormap *colormap);
/* Initialization */
extern GdkArgDesc _gdk_windowing_args[];
gboolean _gdk_windowing_init_check (int argc, char **argv);
#ifdef USE_XIM
/* XIM support */
gint gdk_im_open (void);
void gdk_im_close (void);
void gdk_ic_cleanup (void);
extern GdkICPrivate *gdk_xim_ic; /* currently using IC */
extern GdkWindow *gdk_xim_window; /* currently using Window */
#endif /* USE_XIM */
/* Debugging support */

View File

@ -1,239 +0,0 @@
/* 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 <X11/Xlib.h>
#include <X11/Xatom.h>
#include <string.h>
#include "gdkx.h"
#include "gdkproperty.h"
#include "gdkprivate.h"
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)
{
retval = XInternAtom (gdk_display, atom_name, only_if_exists);
if (retval != None)
g_hash_table_insert (atom_hash,
g_strdup (atom_name),
GUINT_TO_POINTER (retval));
}
return retval;
}
gchar*
gdk_atom_name (GdkAtom atom)
{
gchar *t;
gchar *name;
gint old_error_warnings;
/* If this atom doesn't exist, we'll die with an X error unless
we take precautions */
old_error_warnings = gdk_error_warnings;
gdk_error_warnings = 0;
gdk_error_code = 0;
t = XGetAtomName (gdk_display, atom);
gdk_error_warnings = old_error_warnings;
if (gdk_error_code)
{
if (t)
XFree (t);
return NULL;
}
else
{
name = g_strdup (t);
if (t)
XFree (t);
return 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)
{
Display *xdisplay;
Window xwindow;
Atom ret_prop_type;
gint ret_format;
gulong ret_nitems;
gulong ret_bytes_after;
gulong ret_length;
guchar *ret_data;
if (window)
{
if (GDK_DRAWABLE_DESTROYED (window))
return FALSE;
xdisplay = GDK_WINDOW_XDISPLAY (window);
xwindow = GDK_WINDOW_XWINDOW (window);
}
else
{
xdisplay = gdk_display;
xwindow = gdk_root_window;
}
ret_data = NULL;
XGetWindowProperty (xdisplay, xwindow, property,
offset, (length + 3) / 4, pdelete,
type, &ret_prop_type, &ret_format,
&ret_nitems, &ret_bytes_after,
&ret_data);
if ((ret_prop_type == None) && (ret_format == 0)) {
return FALSE;
}
if (actual_property_type)
*actual_property_type = ret_prop_type;
if (actual_format_type)
*actual_format_type = ret_format;
if ((type != AnyPropertyType) && (ret_prop_type != type))
{
gchar *rn, *pn;
XFree (ret_data);
rn = gdk_atom_name(ret_prop_type);
pn = gdk_atom_name(type);
g_warning("Couldn't match property type %s to %s\n", rn, pn);
g_free(rn); g_free(pn);
return FALSE;
}
/* FIXME: ignoring bytes_after could have very bad effects */
if (data)
{
switch (ret_format)
{
case 8:
ret_length = ret_nitems;
break;
case 16:
ret_length = sizeof(short) * ret_nitems;
break;
case 32:
ret_length = sizeof(long) * ret_nitems;
break;
default:
g_warning ("unknown property return format: %d", ret_format);
XFree (ret_data);
return FALSE;
}
*data = g_new (guchar, ret_length);
memcpy (*data, ret_data, ret_length);
if (actual_length)
*actual_length = ret_length;
}
XFree (ret_data);
return TRUE;
}
void
gdk_property_change (GdkWindow *window,
GdkAtom property,
GdkAtom type,
gint format,
GdkPropMode mode,
guchar *data,
gint nelements)
{
Display *xdisplay;
Window xwindow;
if (window)
{
if (GDK_DRAWABLE_DESTROYED (window))
return;
xdisplay = GDK_WINDOW_XDISPLAY (window);
xwindow = GDK_WINDOW_XWINDOW (window);
}
else
{
xdisplay = gdk_display;
xwindow = gdk_root_window;
}
XChangeProperty (xdisplay, xwindow, property, type,
format, mode, data, nelements);
}
void
gdk_property_delete (GdkWindow *window,
GdkAtom property)
{
Display *xdisplay;
Window xwindow;
if (window)
{
if (GDK_DRAWABLE_DESTROYED (window))
return;
xdisplay = GDK_WINDOW_XDISPLAY (window);
xwindow = GDK_WINDOW_XWINDOW (window);
}
else
{
xdisplay = gdk_display;
xwindow = gdk_root_window;
}
XDeleteProperty (xdisplay, xwindow, property);
}

View File

@ -1,328 +0,0 @@
/* 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 <X11/Xlib.h>
#include <X11/Xutil.h>
#include "gdk.h"
#include "gdkprivate.h"
GdkRegion*
gdk_region_new (void)
{
GdkRegionPrivate *private;
GdkRegion *region;
Region xregion;
xregion = XCreateRegion();
private = g_new (GdkRegionPrivate, 1);
private->xregion = xregion;
region = (GdkRegion*) private;
region->user_data = NULL;
return region;
}
void
gdk_region_destroy (GdkRegion *region)
{
GdkRegionPrivate *private;
g_return_if_fail (region != NULL);
private = (GdkRegionPrivate *) region;
XDestroyRegion (private->xregion);
g_free (private);
}
gboolean
gdk_region_empty (GdkRegion *region)
{
GdkRegionPrivate *private;
g_return_val_if_fail (region != NULL, 0);
private = (GdkRegionPrivate *) region;
return XEmptyRegion (private->xregion);
}
gboolean
gdk_region_equal (GdkRegion *region1,
GdkRegion *region2)
{
GdkRegionPrivate *private1;
GdkRegionPrivate *private2;
g_return_val_if_fail (region1 != NULL, 0);
g_return_val_if_fail (region2 != NULL, 0);
private1 = (GdkRegionPrivate *) region1;
private2 = (GdkRegionPrivate *) region2;
return XEqualRegion (private1->xregion, private2->xregion);
}
void
gdk_region_get_clipbox(GdkRegion *region,
GdkRectangle *rectangle)
{
GdkRegionPrivate *rp;
XRectangle r;
g_return_if_fail(region != NULL);
g_return_if_fail(rectangle != NULL);
rp = (GdkRegionPrivate *)region;
XClipBox(rp->xregion, &r);
rectangle->x = r.x;
rectangle->y = r.y;
rectangle->width = r.width;
rectangle->height = r.height;
}
gboolean
gdk_region_point_in (GdkRegion *region,
gint x,
gint y)
{
GdkRegionPrivate *private;
g_return_val_if_fail (region != NULL, 0);
private = (GdkRegionPrivate *) region;
return XPointInRegion (private->xregion, x, y);
}
GdkOverlapType
gdk_region_rect_in (GdkRegion *region,
GdkRectangle *rect)
{
GdkRegionPrivate *private;
int res;
g_return_val_if_fail (region != NULL, 0);
private = (GdkRegionPrivate *) region;
res = XRectInRegion (private->xregion, rect->x, rect->y, rect->width, rect->height);
switch (res)
{
case RectangleIn: return GDK_OVERLAP_RECTANGLE_IN;
case RectangleOut: return GDK_OVERLAP_RECTANGLE_OUT;
case RectanglePart: return GDK_OVERLAP_RECTANGLE_PART;
}
return GDK_OVERLAP_RECTANGLE_OUT; /*what else ? */
}
GdkRegion *
gdk_region_polygon (GdkPoint *points,
gint npoints,
GdkFillRule fill_rule)
{
GdkRegionPrivate *private;
GdkRegion *region;
Region xregion;
gint xfill_rule = EvenOddRule;
g_return_val_if_fail (points != NULL, NULL);
g_return_val_if_fail (npoints != 0, NULL); /* maybe we should check for at least three points */
switch (fill_rule)
{
case GDK_EVEN_ODD_RULE:
xfill_rule = EvenOddRule;
break;
case GDK_WINDING_RULE:
xfill_rule = WindingRule;
break;
}
xregion = XPolygonRegion ((XPoint *) points, npoints, xfill_rule);
private = g_new (GdkRegionPrivate, 1);
private->xregion = xregion;
region = (GdkRegion *) private;
region->user_data = NULL;
return region;
}
void
gdk_region_offset (GdkRegion *region,
gint dx,
gint dy)
{
GdkRegionPrivate *private;
g_return_if_fail (region != NULL);
private = (GdkRegionPrivate *) region;
XOffsetRegion (private->xregion, dx, dy);
}
void
gdk_region_shrink (GdkRegion *region,
gint dx,
gint dy)
{
GdkRegionPrivate *private;
g_return_if_fail (region != NULL);
private = (GdkRegionPrivate *) region;
XShrinkRegion (private->xregion, dx, dy);
}
GdkRegion*
gdk_region_union_with_rect (GdkRegion *region,
GdkRectangle *rect)
{
GdkRegionPrivate *private;
GdkRegion *res;
GdkRegionPrivate *res_private;
XRectangle xrect;
g_return_val_if_fail (region != NULL, NULL);
private = (GdkRegionPrivate *) region;
xrect.x = rect->x;
xrect.y = rect->y;
xrect.width = rect->width;
xrect.height = rect->height;
res = gdk_region_new ();
res_private = (GdkRegionPrivate *) res;
XUnionRectWithRegion (&xrect, private->xregion, res_private->xregion);
return res;
}
GdkRegion*
gdk_regions_intersect (GdkRegion *source1,
GdkRegion *source2)
{
GdkRegionPrivate *private1;
GdkRegionPrivate *private2;
GdkRegion *res;
GdkRegionPrivate *res_private;
g_return_val_if_fail (source1 != NULL, NULL);
g_return_val_if_fail (source2 != NULL, NULL);
private1 = (GdkRegionPrivate *) source1;
private2 = (GdkRegionPrivate *) source2;
res = gdk_region_new ();
res_private = (GdkRegionPrivate *) res;
XIntersectRegion (private1->xregion, private2->xregion, res_private->xregion);
return res;
}
GdkRegion*
gdk_regions_union (GdkRegion *source1,
GdkRegion *source2)
{
GdkRegionPrivate *private1;
GdkRegionPrivate *private2;
GdkRegion *res;
GdkRegionPrivate *res_private;
g_return_val_if_fail (source1 != NULL, NULL);
g_return_val_if_fail (source2 != NULL, NULL);
private1 = (GdkRegionPrivate *) source1;
private2 = (GdkRegionPrivate *) source2;
res = gdk_region_new ();
res_private = (GdkRegionPrivate *) res;
XUnionRegion (private1->xregion, private2->xregion, res_private->xregion);
return res;
}
GdkRegion*
gdk_regions_subtract (GdkRegion *source1,
GdkRegion *source2)
{
GdkRegionPrivate *private1;
GdkRegionPrivate *private2;
GdkRegion *res;
GdkRegionPrivate *res_private;
g_return_val_if_fail (source1 != NULL, NULL);
g_return_val_if_fail (source2 != NULL, NULL);
private1 = (GdkRegionPrivate *) source1;
private2 = (GdkRegionPrivate *) source2;
res = gdk_region_new ();
res_private = (GdkRegionPrivate *) res;
XSubtractRegion (private1->xregion, private2->xregion, res_private->xregion);
return res;
}
GdkRegion*
gdk_regions_xor (GdkRegion *source1,
GdkRegion *source2)
{
GdkRegionPrivate *private1;
GdkRegionPrivate *private2;
GdkRegion *res;
GdkRegionPrivate *res_private;
g_return_val_if_fail (source1 != NULL, NULL);
g_return_val_if_fail (source2 != NULL, NULL);
private1 = (GdkRegionPrivate *) source1;
private2 = (GdkRegionPrivate *) source2;
res = gdk_region_new ();
res_private = (GdkRegionPrivate *) res;
XXorRegion (private1->xregion, private2->xregion, res_private->xregion);
return res;
}

View File

@ -73,6 +73,16 @@ typedef void (*GdkRgbConvFunc) (GdkImage *image,
gint x_align, gint y_align,
GdkRgbCmap *cmap);
static const gchar* visual_names[] =
{
"static gray",
"grayscale",
"static color",
"pseudo color",
"true color",
"direct color",
};
/* Some of these fields should go, as they're not being used at all.
Globals should generally migrate into here - it's very likely that
we'll want to run more than one GdkRgbInfo context at the same time
@ -405,16 +415,6 @@ static guint32
gdk_rgb_score_visual (GdkVisual *visual)
{
guint32 quality, speed, sys, pseudo;
static const gchar* visual_names[] =
{
"static gray",
"grayscale",
"static color",
"pseudo color",
"true color",
"direct color",
};
quality = 0;
speed = 1;
@ -466,8 +466,7 @@ gdk_rgb_score_visual (GdkVisual *visual)
pseudo = (visual->type == GDK_VISUAL_PSEUDO_COLOR || visual->type == GDK_VISUAL_TRUE_COLOR);
if (gdk_rgb_verbose)
g_print ("Visual 0x%x, type = %s, depth = %d, %x:%x:%x%s; score=%x\n",
(gint)(((GdkVisualPrivate *)visual)->xvisual->visualid),
g_print ("Visual type = %s, depth = %d, %x:%x:%x%s; score=%x\n",
visual_names[visual->type],
visual->depth,
visual->red_mask,
@ -2681,16 +2680,19 @@ gdk_rgb_select_conv (GdkImage *image)
gboolean mask_rgb, mask_bgr;
depth = image_info->visual->depth;
#if defined (GDK_RGB_STANDALONE) || defined (GDK_WINDOWING_X11)
bpp = ((GdkImagePrivate *)image)->ximage->bits_per_pixel;
#elif defined (GDK_WINDOWING_WIN32)
bpp = ((GdkVisualPrivate *) gdk_visual_get_system())->xvisual->bitspixel;
#endif
/* FIXME: save the bpp in the image; this is hack that works for
* common visuals, not otherwise.
*/
if (depth <= 8)
bpp = depth;
else
bpp = 8 * image->bpp;
byte_order = image->byte_order;
if (gdk_rgb_verbose)
g_print ("Chose visual 0x%x, image bpp=%d, %s first\n",
(gint)(((GdkVisualPrivate *)image_info->visual)->xvisual->visualid),
g_print ("Chose visual type=%s depth=%d, image bpp=%d, %s first\n",
visual_names[image_info->visual->type], image_info->visual->depth,
bpp, byte_order == GDK_LSB_FIRST ? "lsb" : "msb");
#if G_BYTE_ORDER == G_BIG_ENDIAN

View File

@ -1,257 +0,0 @@
/* 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 <X11/Xlib.h>
#include <X11/Xatom.h>
#include <string.h>
#include "gdkproperty.h"
#include "gdkselection.h"
#include "gdkprivate.h"
#include "gdkx.h"
gint
gdk_selection_owner_set (GdkWindow *owner,
GdkAtom selection,
guint32 time,
gint send_event)
{
Display *xdisplay;
Window xwindow;
if (owner)
{
if (GDK_DRAWABLE_DESTROYED (owner))
return FALSE;
xdisplay = GDK_DRAWABLE_XDISPLAY (owner);
xwindow = GDK_DRAWABLE_XID (owner);
}
else
{
xdisplay = gdk_display;
xwindow = None;
}
XSetSelectionOwner (xdisplay, selection, xwindow, time);
return (XGetSelectionOwner (xdisplay, selection) == xwindow);
}
GdkWindow*
gdk_selection_owner_get (GdkAtom selection)
{
Window xwindow;
xwindow = XGetSelectionOwner (gdk_display, selection);
if (xwindow == None)
return NULL;
return gdk_window_lookup (xwindow);
}
void
gdk_selection_convert (GdkWindow *requestor,
GdkAtom selection,
GdkAtom target,
guint32 time)
{
if (GDK_DRAWABLE_DESTROYED (requestor))
return;
XConvertSelection (GDK_DRAWABLE_XDISPLAY (requestor), selection, target,
gdk_selection_property, GDK_DRAWABLE_XID (requestor), time);
}
gint
gdk_selection_property_get (GdkWindow *requestor,
guchar **data,
GdkAtom *ret_type,
gint *ret_format)
{
gulong nitems;
gulong nbytes;
gulong length;
GdkAtom prop_type;
gint prop_format;
guchar *t = NULL;
g_return_val_if_fail (requestor != NULL, 0);
g_return_val_if_fail (GDK_IS_WINDOW (requestor), 0);
/* If retrieved chunks are typically small, (and the ICCCM says the
should be) it would be a win to try first with a buffer of
moderate length, to avoid two round trips to the server */
if (GDK_DRAWABLE_DESTROYED (requestor))
return 0;
t = NULL;
XGetWindowProperty (GDK_DRAWABLE_XDISPLAY (requestor),
GDK_DRAWABLE_XID (requestor),
gdk_selection_property, 0, 0, False,
AnyPropertyType, &prop_type, &prop_format,
&nitems, &nbytes, &t);
if (ret_type)
*ret_type = prop_type;
if (ret_format)
*ret_format = prop_format;
if (prop_type == None)
{
*data = NULL;
return 0;
}
if (t)
{
XFree (t);
t = NULL;
}
/* Add on an extra byte to handle null termination. X guarantees
that t will be 1 longer than nbytes and null terminated */
length = nbytes + 1;
/* We can't delete the selection here, because it might be the INCR
protocol, in which case the client has to make sure they'll be
notified of PropertyChange events _before_ the property is deleted.
Otherwise there's no guarantee we'll win the race ... */
XGetWindowProperty (GDK_DRAWABLE_XDISPLAY (requestor),
GDK_DRAWABLE_XID (requestor),
gdk_selection_property, 0, (nbytes + 3) / 4, False,
AnyPropertyType, &prop_type, &prop_format,
&nitems, &nbytes, &t);
if (prop_type != None)
{
*data = g_new (guchar, length);
memcpy (*data, t, length);
if (t)
XFree (t);
return length-1;
}
else
{
*data = NULL;
return 0;
}
}
void
gdk_selection_send_notify (guint32 requestor,
GdkAtom selection,
GdkAtom target,
GdkAtom property,
guint32 time)
{
XSelectionEvent xevent;
xevent.type = SelectionNotify;
xevent.serial = 0;
xevent.send_event = True;
xevent.display = gdk_display;
xevent.requestor = requestor;
xevent.selection = selection;
xevent.target = target;
xevent.property = property;
xevent.time = time;
gdk_send_xevent (requestor, False, NoEventMask, (XEvent*) &xevent);
}
gint
gdk_text_property_to_text_list (GdkAtom encoding, gint format,
guchar *text, gint length,
gchar ***list)
{
XTextProperty property;
gint count = 0;
gint res;
if (!list)
return 0;
property.value = text;
property.encoding = encoding;
property.format = format;
property.nitems = length;
res = XmbTextPropertyToTextList (GDK_DISPLAY(), &property, list, &count);
if (res == XNoMemory || res == XLocaleNotSupported ||
res == XConverterNotFound)
return 0;
else
return count;
}
void
gdk_free_text_list (gchar **list)
{
g_return_if_fail (list != NULL);
XFreeStringList (list);
}
gint
gdk_string_to_compound_text (gchar *str,
GdkAtom *encoding, gint *format,
guchar **ctext, gint *length)
{
gint res;
XTextProperty property;
res = XmbTextListToTextProperty (GDK_DISPLAY(),
&str, 1, XCompoundTextStyle,
&property);
if (res != Success)
{
property.encoding = None;
property.format = None;
property.value = NULL;
property.nitems = 0;
}
if (encoding)
*encoding = property.encoding;
if (format)
*format = property.format;
if (ctext)
*ctext = property.value;
if (length)
*length = property.nitems;
return res;
}
void gdk_free_compound_text (guchar *ctext)
{
if (ctext)
XFree (ctext);
}

View File

@ -1,452 +0,0 @@
/* 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 <X11/Xlib.h>
#include <X11/Xutil.h>
#include "gdkvisual.h"
#include "gdkprivate.h"
static void gdk_visual_add (GdkVisual *visual);
static void gdk_visual_decompose_mask (gulong mask,
gint *shift,
gint *prec);
static guint gdk_visual_hash (Visual *key);
static gint gdk_visual_compare (Visual *a,
Visual *b);
static GdkVisualPrivate *system_visual;
static GdkVisualPrivate *visuals;
static gint nvisuals;
static gint available_depths[7];
static gint navailable_depths;
static GdkVisualType available_types[6];
static gint navailable_types;
#ifdef G_ENABLE_DEBUG
static const gchar* visual_names[] =
{
"static gray",
"grayscale",
"static color",
"pseudo color",
"true color",
"direct color",
};
#endif /* G_ENABLE_DEBUG */
static GHashTable *visual_hash = NULL;
void
gdk_visual_init (void)
{
static const gint possible_depths[7] = { 32, 24, 16, 15, 8, 4, 1 };
static const GdkVisualType possible_types[6] =
{
GDK_VISUAL_DIRECT_COLOR,
GDK_VISUAL_TRUE_COLOR,
GDK_VISUAL_PSEUDO_COLOR,
GDK_VISUAL_STATIC_COLOR,
GDK_VISUAL_GRAYSCALE,
GDK_VISUAL_STATIC_GRAY
};
static const gint npossible_depths = sizeof(possible_depths)/sizeof(gint);
static const gint npossible_types = sizeof(possible_types)/sizeof(GdkVisualType);
XVisualInfo *visual_list;
XVisualInfo visual_template;
GdkVisualPrivate temp_visual;
Visual *default_xvisual;
int nxvisuals;
int i, j;
visual_template.screen = gdk_screen;
visual_list = XGetVisualInfo (gdk_display, VisualScreenMask, &visual_template, &nxvisuals);
visuals = g_new (GdkVisualPrivate, nxvisuals);
default_xvisual = DefaultVisual (gdk_display, gdk_screen);
nvisuals = 0;
for (i = 0; i < nxvisuals; i++)
{
if (visual_list[i].depth >= 1)
{
#ifdef __cplusplus
switch (visual_list[i].c_class)
#else /* __cplusplus */
switch (visual_list[i].class)
#endif /* __cplusplus */
{
case StaticGray:
visuals[nvisuals].visual.type = GDK_VISUAL_STATIC_GRAY;
break;
case GrayScale:
visuals[nvisuals].visual.type = GDK_VISUAL_GRAYSCALE;
break;
case StaticColor:
visuals[nvisuals].visual.type = GDK_VISUAL_STATIC_COLOR;
break;
case PseudoColor:
visuals[nvisuals].visual.type = GDK_VISUAL_PSEUDO_COLOR;
break;
case TrueColor:
visuals[nvisuals].visual.type = GDK_VISUAL_TRUE_COLOR;
break;
case DirectColor:
visuals[nvisuals].visual.type = GDK_VISUAL_DIRECT_COLOR;
break;
}
visuals[nvisuals].visual.depth = visual_list[i].depth;
visuals[nvisuals].visual.byte_order =
(ImageByteOrder(gdk_display) == LSBFirst) ?
GDK_LSB_FIRST : GDK_MSB_FIRST;
visuals[nvisuals].visual.red_mask = visual_list[i].red_mask;
visuals[nvisuals].visual.green_mask = visual_list[i].green_mask;
visuals[nvisuals].visual.blue_mask = visual_list[i].blue_mask;
visuals[nvisuals].visual.colormap_size = visual_list[i].colormap_size;
visuals[nvisuals].visual.bits_per_rgb = visual_list[i].bits_per_rgb;
visuals[nvisuals].xvisual = visual_list[i].visual;
if ((visuals[nvisuals].visual.type == GDK_VISUAL_TRUE_COLOR) ||
(visuals[nvisuals].visual.type == GDK_VISUAL_DIRECT_COLOR))
{
gdk_visual_decompose_mask (visuals[nvisuals].visual.red_mask,
&visuals[nvisuals].visual.red_shift,
&visuals[nvisuals].visual.red_prec);
gdk_visual_decompose_mask (visuals[nvisuals].visual.green_mask,
&visuals[nvisuals].visual.green_shift,
&visuals[nvisuals].visual.green_prec);
gdk_visual_decompose_mask (visuals[nvisuals].visual.blue_mask,
&visuals[nvisuals].visual.blue_shift,
&visuals[nvisuals].visual.blue_prec);
}
else
{
visuals[nvisuals].visual.red_mask = 0;
visuals[nvisuals].visual.red_shift = 0;
visuals[nvisuals].visual.red_prec = 0;
visuals[nvisuals].visual.green_mask = 0;
visuals[nvisuals].visual.green_shift = 0;
visuals[nvisuals].visual.green_prec = 0;
visuals[nvisuals].visual.blue_mask = 0;
visuals[nvisuals].visual.blue_shift = 0;
visuals[nvisuals].visual.blue_prec = 0;
}
nvisuals += 1;
}
}
if (visual_list)
XFree (visual_list);
for (i = 0; i < nvisuals; i++)
{
for (j = i+1; j < nvisuals; j++)
{
if (visuals[j].visual.depth >= visuals[i].visual.depth)
{
if ((visuals[j].visual.depth == 8) && (visuals[i].visual.depth == 8))
{
if (visuals[j].visual.type == GDK_VISUAL_PSEUDO_COLOR)
{
temp_visual = visuals[j];
visuals[j] = visuals[i];
visuals[i] = temp_visual;
}
else if ((visuals[i].visual.type != GDK_VISUAL_PSEUDO_COLOR) &&
visuals[j].visual.type > visuals[i].visual.type)
{
temp_visual = visuals[j];
visuals[j] = visuals[i];
visuals[i] = temp_visual;
}
}
else if ((visuals[j].visual.depth > visuals[i].visual.depth) ||
((visuals[j].visual.depth == visuals[i].visual.depth) &&
(visuals[j].visual.type > visuals[i].visual.type)))
{
temp_visual = visuals[j];
visuals[j] = visuals[i];
visuals[i] = temp_visual;
}
}
}
}
for (i = 0; i < nvisuals; i++)
if (default_xvisual->visualid == visuals[i].xvisual->visualid)
{
system_visual = &visuals[i];
break;
}
#ifdef G_ENABLE_DEBUG
if (gdk_debug_flags & GDK_DEBUG_MISC)
for (i = 0; i < nvisuals; i++)
g_message ("visual: %s: %d",
visual_names[visuals[i].visual.type],
visuals[i].visual.depth);
#endif /* G_ENABLE_DEBUG */
navailable_depths = 0;
for (i = 0; i < npossible_depths; i++)
{
for (j = 0; j < nvisuals; j++)
{
if (visuals[j].visual.depth == possible_depths[i])
{
available_depths[navailable_depths++] = visuals[j].visual.depth;
break;
}
}
}
if (navailable_depths == 0)
g_error ("unable to find a usable depth");
navailable_types = 0;
for (i = 0; i < npossible_types; i++)
{
for (j = 0; j < nvisuals; j++)
{
if (visuals[j].visual.type == possible_types[i])
{
available_types[navailable_types++] = visuals[j].visual.type;
break;
}
}
}
for (i = 0; i < nvisuals; i++)
gdk_visual_add ((GdkVisual*) &visuals[i]);
if (npossible_types == 0)
g_error ("unable to find a usable visual type");
}
GdkVisual*
gdk_visual_ref (GdkVisual *visual)
{
return visual;
}
void
gdk_visual_unref (GdkVisual *visual)
{
return;
}
gint
gdk_visual_get_best_depth (void)
{
return available_depths[0];
}
GdkVisualType
gdk_visual_get_best_type (void)
{
return available_types[0];
}
GdkVisual*
gdk_visual_get_system (void)
{
return ((GdkVisual*) system_visual);
}
GdkVisual*
gdk_visual_get_best (void)
{
return ((GdkVisual*) &(visuals[0]));
}
GdkVisual*
gdk_visual_get_best_with_depth (gint depth)
{
GdkVisual *return_val;
int i;
return_val = NULL;
for (i = 0; i < nvisuals; i++)
if (depth == visuals[i].visual.depth)
{
return_val = (GdkVisual*) &(visuals[i]);
break;
}
return return_val;
}
GdkVisual*
gdk_visual_get_best_with_type (GdkVisualType visual_type)
{
GdkVisual *return_val;
int i;
return_val = NULL;
for (i = 0; i < nvisuals; i++)
if (visual_type == visuals[i].visual.type)
{
return_val = (GdkVisual*) &(visuals[i]);
break;
}
return return_val;
}
GdkVisual*
gdk_visual_get_best_with_both (gint depth,
GdkVisualType visual_type)
{
GdkVisual *return_val;
int i;
return_val = NULL;
for (i = 0; i < nvisuals; i++)
if ((depth == visuals[i].visual.depth) &&
(visual_type == visuals[i].visual.type))
{
return_val = (GdkVisual*) &(visuals[i]);
break;
}
return return_val;
}
void
gdk_query_depths (gint **depths,
gint *count)
{
*count = navailable_depths;
*depths = available_depths;
}
void
gdk_query_visual_types (GdkVisualType **visual_types,
gint *count)
{
*count = navailable_types;
*visual_types = available_types;
}
GList*
gdk_list_visuals (void)
{
GList *list;
guint i;
list = NULL;
for (i = 0; i < nvisuals; ++i)
list = g_list_append (list, (gpointer) &visuals[i]);
return list;
}
GdkVisual*
gdk_visual_lookup (Visual *xvisual)
{
GdkVisual *visual;
if (!visual_hash)
return NULL;
visual = g_hash_table_lookup (visual_hash, xvisual);
return visual;
}
GdkVisual*
gdkx_visual_get (VisualID xvisualid)
{
int i;
for (i = 0; i < nvisuals; i++)
if (xvisualid == visuals[i].xvisual->visualid)
return (GdkVisual*) &visuals[i];
return NULL;
}
static void
gdk_visual_add (GdkVisual *visual)
{
GdkVisualPrivate *private;
if (!visual_hash)
visual_hash = g_hash_table_new ((GHashFunc) gdk_visual_hash,
(GCompareFunc) gdk_visual_compare);
private = (GdkVisualPrivate*) visual;
g_hash_table_insert (visual_hash, private->xvisual, visual);
}
static void
gdk_visual_decompose_mask (gulong mask,
gint *shift,
gint *prec)
{
*shift = 0;
*prec = 0;
while (!(mask & 0x1))
{
(*shift)++;
mask >>= 1;
}
while (mask & 0x1)
{
(*prec)++;
mask >>= 1;
}
}
static guint
gdk_visual_hash (Visual *key)
{
return key->visualid;
}
static gint
gdk_visual_compare (Visual *a,
Visual *b)
{
return (a->visualid == b->visualid);
}

File diff suppressed because it is too large Load Diff

View File

@ -3,6 +3,8 @@
#include <gdk/gdkdrawable.h>
#include <gdk/gdktypes.h>
#include <gdk/gdkwindow.h>
#include <gdk/gdkevents.h>
#ifdef __cplusplus
extern "C" {

View File

@ -1,64 +0,0 @@
/* 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/.
*/
#ifndef __GDK_X_H__
#define __GDK_X_H__
#include <gdk/gdkprivate.h>
#define GDK_ROOT_WINDOW() gdk_root_window
#define GDK_ROOT_PARENT() ((GdkWindow *)&gdk_root_parent)
#define GDK_DISPLAY() gdk_display
#define GDK_DRAWABLE_XDISPLAY(win) (((GdkDrawablePrivate*) win)->xdisplay)
#define GDK_DRAWABLE_XID(win) (((GdkDrawablePrivate*) win)->xwindow)
#define GDK_WINDOW_XDISPLAY GDK_DRAWABLE_XDISPLAY
#define GDK_WINDOW_XWINDOW GDK_DRAWABLE_XID
#define GDK_IMAGE_XDISPLAY(image) (((GdkImagePrivate*) image)->xdisplay)
#define GDK_IMAGE_XIMAGE(image) (((GdkImagePrivate*) image)->ximage)
#define GDK_GC_XDISPLAY(gc) (((GdkGCPrivate*) gc)->xdisplay)
#define GDK_GC_XGC(gc) (((GdkGCPrivate*) gc)->xgc)
#define GDK_COLORMAP_XDISPLAY(cmap) (((GdkColormapPrivate*) cmap)->xdisplay)
#define GDK_COLORMAP_XCOLORMAP(cmap) (((GdkColormapPrivate*) cmap)->xcolormap)
#define GDK_VISUAL_XVISUAL(vis) (((GdkVisualPrivate*) vis)->xvisual)
#define GDK_FONT_XDISPLAY(font) (((GdkFontPrivate*) font)->xdisplay)
#define GDK_FONT_XFONT(font) (((GdkFontPrivate*) font)->xfont)
GdkVisual* gdkx_visual_get (VisualID xvisualid);
/* XXX: Do not use this function until it is fixed. An X Colormap
* is useless unless we also have the visual. */
GdkColormap* gdkx_colormap_get (Colormap xcolormap);
/* Utility function in gdk.c - not sure where it belongs, but it's
needed in more than one place, so make it public */
Window gdk_get_client_window (Display *dpy,
Window win);
/* Functions to create pixmaps and windows from their X equivalents */
GdkPixmap *gdk_pixmap_foreign_new (guint32 anid);
GdkWindow *gdk_window_foreign_new (guint32 anid);
#endif /* __GDK_X_H__ */

View File

@ -1,84 +0,0 @@
/* 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 "gdkprivate.h"
#include <stdio.h>
static guint gdk_xid_hash (XID *xid);
static gint gdk_xid_compare (XID *a,
XID *b);
static GHashTable *xid_ht = NULL;
void
gdk_xid_table_insert (XID *xid,
gpointer data)
{
g_return_if_fail (xid != NULL);
if (!xid_ht)
xid_ht = g_hash_table_new ((GHashFunc) gdk_xid_hash,
(GCompareFunc) gdk_xid_compare);
g_hash_table_insert (xid_ht, xid, data);
}
void
gdk_xid_table_remove (XID xid)
{
if (!xid_ht)
xid_ht = g_hash_table_new ((GHashFunc) gdk_xid_hash,
(GCompareFunc) gdk_xid_compare);
g_hash_table_remove (xid_ht, &xid);
}
gpointer
gdk_xid_table_lookup (XID xid)
{
gpointer data = NULL;
if (xid_ht)
data = g_hash_table_lookup (xid_ht, &xid);
return data;
}
static guint
gdk_xid_hash (XID *xid)
{
return *xid;
}
static gint
gdk_xid_compare (XID *a,
XID *b)
{
return (*a == *b);
}

View File

@ -5137,6 +5137,46 @@ gdk_synthesize_click (GdkEvent *event,
gdk_event_put (&temp_event);
}
void
gdk_event_button_generate (GdkEvent *event)
{
if ((event->button.time < (button_click_time[1] + TRIPLE_CLICK_TIME)) &&
(event->button.window == button_window[1]) &&
(event->button.button == button_number[1]))
{
gdk_synthesize_click (event, 3);
button_click_time[1] = 0;
button_click_time[0] = 0;
button_window[1] = NULL;
button_window[0] = 0;
button_number[1] = -1;
button_number[0] = -1;
}
else if ((event->button.time < (button_click_time[0] + DOUBLE_CLICK_TIME)) &&
(event->button.window == button_window[0]) &&
(event->button.button == button_number[0]))
{
gdk_synthesize_click (event, 2);
button_click_time[1] = button_click_time[0];
button_click_time[0] = event->button.time;
button_window[1] = button_window[0];
button_window[0] = event->button.window;
button_number[1] = button_number[0];
button_number[0] = event->button.button;
}
else
{
button_click_time[1] = 0;
button_click_time[0] = event->button.time;
button_window[1] = NULL;
button_window[0] = event->button.window;
button_number[1] = -1;
button_number[0] = event->button.button;
}
}
/* Sends a ClientMessage to all toplevel client windows */
gboolean
gdk_event_send_client_message (GdkEvent *event, guint32 xid)

View File

@ -5137,6 +5137,46 @@ gdk_synthesize_click (GdkEvent *event,
gdk_event_put (&temp_event);
}
void
gdk_event_button_generate (GdkEvent *event)
{
if ((event->button.time < (button_click_time[1] + TRIPLE_CLICK_TIME)) &&
(event->button.window == button_window[1]) &&
(event->button.button == button_number[1]))
{
gdk_synthesize_click (event, 3);
button_click_time[1] = 0;
button_click_time[0] = 0;
button_window[1] = NULL;
button_window[0] = 0;
button_number[1] = -1;
button_number[0] = -1;
}
else if ((event->button.time < (button_click_time[0] + DOUBLE_CLICK_TIME)) &&
(event->button.window == button_window[0]) &&
(event->button.button == button_number[0]))
{
gdk_synthesize_click (event, 2);
button_click_time[1] = button_click_time[0];
button_click_time[0] = event->button.time;
button_window[1] = button_window[0];
button_window[0] = event->button.window;
button_number[1] = button_number[0];
button_number[0] = event->button.button;
}
else
{
button_click_time[1] = 0;
button_click_time[0] = event->button.time;
button_window[1] = NULL;
button_window[0] = event->button.window;
button_number[1] = -1;
button_number[0] = event->button.button;
}
}
/* Sends a ClientMessage to all toplevel client windows */
gboolean
gdk_event_send_client_message (GdkEvent *event, guint32 xid)

View File

@ -3,6 +3,7 @@
INCLUDES = @STRIP_BEGIN@ \
-DG_LOG_DOMAIN=\"Gdk\" \
-I$(top_srcdir) \
-I$(top_srcdir)/gdk \
@GTK_DEBUG_FLAGS@ \
@GTK_XIM_FLAGS@ \
@GTK_LOCALE_FLAGS@ \
@ -19,10 +20,47 @@ LDADDS = @STRIP_BEGIN@ \
noinst_LTLIBRARIES = libgdk-x11.la
if XINPUT_GXI
xinput_sources = \
gdkinput-x11.c \
gdkinput-gxi.c
else
if XINPUT_XFREE
xinput_sources = \
gdkinput-x11.c \
gdkinput-xfree.c
else
xinput_sources =
gdkinput-none.c
endif
endif
libgdk_x11_la_SOURCES = \
MwmUtil.h \
gdkcc-x11.c \
gdkcolor-x11.c \
gdkcursor-x11.c \
gdkdnd-x11.c \
gdkdrawable-x11.c \
gdkevents-x11.c \
gdkfont-x11.c \
gdkgc-x11.c \
gdkglobals-x11.c \
gdkim-x11.c \
gdkimage-x11.c \
gdkinput.c \
gdkmain-x11.c \
gdkpixmap-x11.c \
gdkproperty-x11.c \
gdkregion-x11.c \
gdkselection-x11.c \
gdkvisual-x11.c \
gdkwindow-x11.c \
gdkxid.c \
gxid_lib.c \
gxid_lib.h \
gxid_proto.h
gxid_proto.h \
$(xinput_sources)
EXTRA_PROGRAMS = gxid
bin_PROGRAMS = @xinput_progs@
@ -30,7 +68,4 @@ bin_PROGRAMS = @xinput_progs@
gxid_SOURCES = gxid.c
gxid_LDADD = $(LDADDS)
#EXTRA_DIST = \
# MwmUtil.h \

View File

@ -61,6 +61,7 @@
*/
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <stdlib.h>
#include <string.h>

View File

@ -25,11 +25,9 @@
*/
#include <time.h>
#include <X11/Xlib.h>
#include "gdkcolor.h"
#include "gdkprivate.h"
#include "gdkx.h"
static gint gdk_colormap_match_color (GdkColormap *cmap,
GdkColor *color,
@ -39,7 +37,6 @@ static void gdk_colormap_remove (GdkColormap *cmap);
static guint gdk_colormap_hash (Colormap *cmap);
static gint gdk_colormap_cmp (Colormap *a,
Colormap *b);
static void gdk_colormap_real_destroy (GdkColormap *colormap);
static GHashTable *colormap_hash = NULL;
@ -49,19 +46,19 @@ gdk_colormap_new (GdkVisual *visual,
gint private_cmap)
{
GdkColormap *colormap;
GdkColormapPrivate *private;
GdkColormapPrivateX *private;
Visual *xvisual;
int size;
int i;
g_return_val_if_fail (visual != NULL, NULL);
private = g_new (GdkColormapPrivate, 1);
private = g_new (GdkColormapPrivateX, 1);
colormap = (GdkColormap*) private;
private->xdisplay = gdk_display;
private->visual = visual;
private->ref_count = 1;
private->base.visual = visual;
private->base.ref_count = 1;
private->hash = NULL;
private->last_sync_time = 0;
@ -148,13 +145,10 @@ gdk_colormap_new (GdkVisual *visual,
return colormap;
}
static void
gdk_colormap_real_destroy (GdkColormap *colormap)
void
_gdk_colormap_real_destroy (GdkColormap *colormap)
{
GdkColormapPrivate *private = (GdkColormapPrivate*) colormap;
g_return_if_fail (colormap != NULL);
g_return_if_fail (private->ref_count == 0);
GdkColormapPrivateX *private = (GdkColormapPrivateX*) colormap;
gdk_colormap_remove (colormap);
XFreeColormap (private->xdisplay, private->xcolormap);
@ -167,42 +161,6 @@ gdk_colormap_real_destroy (GdkColormap *colormap)
g_free (colormap);
}
GdkColormap*
gdk_colormap_ref (GdkColormap *cmap)
{
GdkColormapPrivate *private = (GdkColormapPrivate *)cmap;
g_return_val_if_fail (cmap != NULL, NULL);
private->ref_count += 1;
return cmap;
}
void
gdk_colormap_unref (GdkColormap *cmap)
{
GdkColormapPrivate *private = (GdkColormapPrivate *)cmap;
g_return_if_fail (cmap != NULL);
g_return_if_fail (private->ref_count > 0);
private->ref_count -= 1;
if (private->ref_count == 0)
gdk_colormap_real_destroy (cmap);
}
GdkVisual *
gdk_colormap_get_visual (GdkColormap *colormap)
{
GdkColormapPrivate *private;
g_return_val_if_fail (colormap != NULL, NULL);
private = (GdkColormapPrivate *)colormap;
return private->visual;
}
#define MIN_SYNC_TIME 2
void
@ -210,7 +168,7 @@ gdk_colormap_sync (GdkColormap *colormap,
gboolean force)
{
time_t current_time;
GdkColormapPrivate *private = (GdkColormapPrivate *)colormap;
GdkColormapPrivateX *private = (GdkColormapPrivateX *)colormap;
XColor *xpalette;
gint nlookup;
gint i;
@ -257,28 +215,28 @@ GdkColormap*
gdk_colormap_get_system (void)
{
static GdkColormap *colormap = NULL;
GdkColormapPrivate *private;
GdkColormapPrivateX *private;
if (!colormap)
{
private = g_new (GdkColormapPrivate, 1);
private = g_new (GdkColormapPrivateX, 1);
colormap = (GdkColormap*) private;
private->xdisplay = gdk_display;
private->xcolormap = DefaultColormap (gdk_display, gdk_screen);
private->visual = gdk_visual_get_system ();
private->base.visual = gdk_visual_get_system ();
private->private_val = FALSE;
private->ref_count = 1;
private->base.ref_count = 1;
private->hash = NULL;
private->last_sync_time = 0;
private->info = NULL;
colormap->colors = NULL;
colormap->size = private->visual->colormap_size;
colormap->size = private->base.visual->colormap_size;
if ((private->visual->type == GDK_VISUAL_GRAYSCALE) ||
(private->visual->type == GDK_VISUAL_PSEUDO_COLOR))
if ((private->base.visual->type == GDK_VISUAL_GRAYSCALE) ||
(private->base.visual->type == GDK_VISUAL_PSEUDO_COLOR))
{
private->info = g_new0 (GdkColorInfo, colormap->size);
colormap->colors = g_new (GdkColor, colormap->size);
@ -305,7 +263,7 @@ void
gdk_colormap_change (GdkColormap *colormap,
gint ncolors)
{
GdkColormapPrivate *private;
GdkColormapPrivateX *private;
GdkVisual *visual;
XColor *palette;
gint shift;
@ -317,8 +275,8 @@ gdk_colormap_change (GdkColormap *colormap,
palette = g_new (XColor, ncolors);
private = (GdkColormapPrivate*) colormap;
switch (private->visual->type)
private = (GdkColormapPrivateX*) colormap;
switch (private->base.visual->type)
{
case GDK_VISUAL_GRAYSCALE:
case GDK_VISUAL_PSEUDO_COLOR:
@ -335,7 +293,7 @@ gdk_colormap_change (GdkColormap *colormap,
break;
case GDK_VISUAL_DIRECT_COLOR:
visual = private->visual;
visual = private->base.visual;
shift = visual->red_shift;
max_colors = 1 << visual->red_prec;
@ -384,24 +342,6 @@ gdk_colormap_change (GdkColormap *colormap,
g_free (palette);
}
void
gdk_colors_store (GdkColormap *colormap,
GdkColor *colors,
gint ncolors)
{
gint i;
for (i = 0; i < ncolors; i++)
{
colormap->colors[i].pixel = colors[i].pixel;
colormap->colors[i].red = colors[i].red;
colormap->colors[i].green = colors[i].green;
colormap->colors[i].blue = colors[i].blue;
}
gdk_colormap_change (colormap, ncolors);
}
gboolean
gdk_colors_alloc (GdkColormap *colormap,
gint contiguous,
@ -410,13 +350,13 @@ gdk_colors_alloc (GdkColormap *colormap,
gulong *pixels,
gint npixels)
{
GdkColormapPrivate *private;
GdkColormapPrivateX *private;
gint return_val;
gint i;
g_return_val_if_fail (colormap != NULL, 0);
private = (GdkColormapPrivate*) colormap;
private = (GdkColormapPrivateX*) colormap;
return_val = XAllocColorCells (private->xdisplay, private->xcolormap,
contiguous, planes, nplanes, pixels, npixels);
@ -433,108 +373,6 @@ gdk_colors_alloc (GdkColormap *colormap,
return return_val != 0;
}
/*
*--------------------------------------------------------------
* gdk_color_copy
*
* Copy a color structure into new storage.
*
* Arguments:
* "color" is the color struct to copy.
*
* Results:
* A new color structure. Free it with gdk_color_free.
*
*--------------------------------------------------------------
*/
static GMemChunk *color_chunk;
GdkColor*
gdk_color_copy (GdkColor *color)
{
GdkColor *new_color;
g_return_val_if_fail (color != NULL, NULL);
if (color_chunk == NULL)
color_chunk = g_mem_chunk_new ("colors",
sizeof (GdkColor),
4096,
G_ALLOC_AND_FREE);
new_color = g_chunk_new (GdkColor, color_chunk);
*new_color = *color;
return new_color;
}
/*
*--------------------------------------------------------------
* gdk_color_free
*
* Free a color structure obtained from gdk_color_copy. Do not use
* with other color structures.
*
* Arguments:
* "color" is the color struct to free.
*
*-------------------------------------------------------------- */
void
gdk_color_free (GdkColor *color)
{
g_assert (color_chunk != NULL);
g_return_if_fail (color != NULL);
g_mem_chunk_free (color_chunk, color);
}
gboolean
gdk_color_white (GdkColormap *colormap,
GdkColor *color)
{
gint return_val;
g_return_val_if_fail (colormap != NULL, FALSE);
if (color)
{
color->pixel = WhitePixel (gdk_display, gdk_screen);
color->red = 65535;
color->green = 65535;
color->blue = 65535;
return_val = gdk_color_alloc (colormap, color);
}
else
return_val = FALSE;
return return_val;
}
gboolean
gdk_color_black (GdkColormap *colormap,
GdkColor *color)
{
gint return_val;
g_return_val_if_fail (colormap != NULL, FALSE);
if (color)
{
color->pixel = BlackPixel (gdk_display, gdk_screen);
color->red = 0;
color->green = 0;
color->blue = 0;
return_val = gdk_color_alloc (colormap, color);
}
else
return_val = FALSE;
return return_val;
}
gboolean
gdk_color_parse (const gchar *spec,
GdkColor *color)
@ -570,7 +408,7 @@ gdk_colors_free (GdkColormap *colormap,
gint in_npixels,
gulong planes)
{
GdkColormapPrivate *private;
GdkColormapPrivateX *private;
gulong *pixels;
gint npixels = 0;
gint i;
@ -578,10 +416,10 @@ gdk_colors_free (GdkColormap *colormap,
g_return_if_fail (colormap != NULL);
g_return_if_fail (in_pixels != NULL);
private = (GdkColormapPrivate*) colormap;
private = (GdkColormapPrivateX*) colormap;
if ((private->visual->type != GDK_VISUAL_PSEUDO_COLOR) &&
(private->visual->type != GDK_VISUAL_GRAYSCALE))
if ((private->base.visual->type != GDK_VISUAL_PSEUDO_COLOR) &&
(private->base.visual->type != GDK_VISUAL_GRAYSCALE))
return;
pixels = g_new (gulong, in_npixels);
@ -618,7 +456,7 @@ gdk_colormap_free_colors (GdkColormap *colormap,
GdkColor *colors,
gint ncolors)
{
GdkColormapPrivate *private;
GdkColormapPrivateX *private;
gulong *pixels;
gint npixels = 0;
gint i;
@ -626,10 +464,10 @@ gdk_colormap_free_colors (GdkColormap *colormap,
g_return_if_fail (colormap != NULL);
g_return_if_fail (colors != NULL);
private = (GdkColormapPrivate*) colormap;
private = (GdkColormapPrivateX*) colormap;
if ((private->visual->type != GDK_VISUAL_PSEUDO_COLOR) &&
(private->visual->type != GDK_VISUAL_GRAYSCALE))
if ((private->base.visual->type != GDK_VISUAL_PSEUDO_COLOR) &&
(private->base.visual->type != GDK_VISUAL_GRAYSCALE))
return;
pixels = g_new (gulong, ncolors);
@ -671,10 +509,10 @@ gdk_colormap_alloc1 (GdkColormap *colormap,
GdkColor *color,
GdkColor *ret)
{
GdkColormapPrivate *private;
GdkColormapPrivateX *private;
XColor xcolor;
private = (GdkColormapPrivate*) colormap;
private = (GdkColormapPrivateX*) colormap;
xcolor.red = color->red;
xcolor.green = color->green;
@ -723,12 +561,12 @@ gdk_colormap_alloc_colors_writeable (GdkColormap *colormap,
gboolean best_match,
gboolean *success)
{
GdkColormapPrivate *private;
GdkColormapPrivateX *private;
gulong *pixels;
Status status;
gint i, index;
private = (GdkColormapPrivate*) colormap;
private = (GdkColormapPrivateX*) colormap;
if (private->private_val)
{
@ -781,13 +619,13 @@ gdk_colormap_alloc_colors_private (GdkColormap *colormap,
gboolean best_match,
gboolean *success)
{
GdkColormapPrivate *private;
GdkColormapPrivateX *private;
gint i, index;
XColor *store = g_new (XColor, ncolors);
gint nstore = 0;
gint nremaining = 0;
private = (GdkColormapPrivate*) colormap;
private = (GdkColormapPrivateX*) colormap;
index = -1;
/* First, store the colors we have room for */
@ -860,12 +698,12 @@ gdk_colormap_alloc_colors_shared (GdkColormap *colormap,
gboolean best_match,
gboolean *success)
{
GdkColormapPrivate *private;
GdkColormapPrivateX *private;
gint i, index;
gint nremaining = 0;
gint nfailed = 0;
private = (GdkColormapPrivate*) colormap;
private = (GdkColormapPrivateX*) colormap;
index = -1;
for (i=0; i<ncolors; i++)
@ -952,12 +790,12 @@ gdk_colormap_alloc_colors_pseudocolor (GdkColormap *colormap,
gboolean best_match,
gboolean *success)
{
GdkColormapPrivate *private;
GdkColormapPrivateX *private;
GdkColor *lookup_color;
gint i;
gint nremaining = 0;
private = (GdkColormapPrivate*) colormap;
private = (GdkColormapPrivateX*) colormap;
/* Check for an exact match among previously allocated colors */
@ -999,7 +837,7 @@ gdk_colormap_alloc_colors (GdkColormap *colormap,
gboolean best_match,
gboolean *success)
{
GdkColormapPrivate *private;
GdkColormapPrivateX *private;
GdkVisual *visual;
gint i;
gint nremaining = 0;
@ -1008,14 +846,14 @@ gdk_colormap_alloc_colors (GdkColormap *colormap,
g_return_val_if_fail (colormap != NULL, FALSE);
g_return_val_if_fail (colors != NULL, FALSE);
private = (GdkColormapPrivate*) colormap;
private = (GdkColormapPrivateX*) colormap;
for (i=0; i<ncolors; i++)
{
success[i] = FALSE;
}
switch (private->visual->type)
switch (private->base.visual->type)
{
case GDK_VISUAL_PSEUDO_COLOR:
case GDK_VISUAL_GRAYSCALE:
@ -1029,7 +867,7 @@ gdk_colormap_alloc_colors (GdkColormap *colormap,
case GDK_VISUAL_DIRECT_COLOR:
case GDK_VISUAL_TRUE_COLOR:
visual = private->visual;
visual = private->base.visual;
for (i=0; i<ncolors; i++)
{
@ -1063,36 +901,11 @@ gdk_colormap_alloc_colors (GdkColormap *colormap,
return nremaining;
}
gboolean
gdk_colormap_alloc_color (GdkColormap *colormap,
GdkColor *color,
gboolean writeable,
gboolean best_match)
{
gboolean success;
gdk_colormap_alloc_colors (colormap, color, 1, writeable, best_match,
&success);
return success;
}
gboolean
gdk_color_alloc (GdkColormap *colormap,
GdkColor *color)
{
gboolean success;
gdk_colormap_alloc_colors (colormap, color, 1, FALSE, TRUE, &success);
return success;
}
gboolean
gdk_color_change (GdkColormap *colormap,
GdkColor *color)
{
GdkColormapPrivate *private;
GdkColormapPrivateX *private;
XColor xcolor;
g_return_val_if_fail (colormap != NULL, FALSE);
@ -1104,33 +917,12 @@ gdk_color_change (GdkColormap *colormap,
xcolor.blue = color->blue;
xcolor.flags = DoRed | DoGreen | DoBlue;
private = (GdkColormapPrivate*) colormap;
private = (GdkColormapPrivateX*) colormap;
XStoreColor (private->xdisplay, private->xcolormap, &xcolor);
return TRUE;
}
guint
gdk_color_hash (const GdkColor *colora)
{
return ((colora->red) +
(colora->green << 11) +
(colora->blue << 22) +
(colora->blue >> 6));
}
gint
gdk_color_equal (const GdkColor *colora,
const GdkColor *colorb)
{
g_return_val_if_fail (colora != NULL, FALSE);
g_return_val_if_fail (colorb != NULL, FALSE);
return ((colora->red == colorb->red) &&
(colora->green == colorb->green) &&
(colora->blue == colorb->blue));
}
/* XXX: Do not use this function until it is fixed. An X Colormap
* is useless unless we also have the visual.
*/
@ -1138,7 +930,7 @@ GdkColormap*
gdkx_colormap_get (Colormap xcolormap)
{
GdkColormap *colormap;
GdkColormapPrivate *private;
GdkColormapPrivateX *private;
colormap = gdk_colormap_lookup (xcolormap);
if (colormap)
@ -1147,12 +939,12 @@ gdkx_colormap_get (Colormap xcolormap)
if (xcolormap == DefaultColormap (gdk_display, gdk_screen))
return gdk_colormap_get_system ();
private = g_new (GdkColormapPrivate, 1);
private = g_new (GdkColormapPrivateX, 1);
colormap = (GdkColormap*) private;
private->xdisplay = gdk_display;
private->xcolormap = xcolormap;
private->visual = NULL;
private->base.visual = NULL;
private->private_val = TRUE;
/* To do the following safely, we would have to have some way of finding
@ -1243,13 +1035,13 @@ gdk_colormap_lookup (Colormap xcolormap)
static void
gdk_colormap_add (GdkColormap *cmap)
{
GdkColormapPrivate *private;
GdkColormapPrivateX *private;
if (!colormap_hash)
colormap_hash = g_hash_table_new ((GHashFunc) gdk_colormap_hash,
(GCompareFunc) gdk_colormap_cmp);
private = (GdkColormapPrivate*) cmap;
private = (GdkColormapPrivateX*)cmap;
g_hash_table_insert (colormap_hash, &private->xcolormap, cmap);
}
@ -1257,13 +1049,13 @@ gdk_colormap_add (GdkColormap *cmap)
static void
gdk_colormap_remove (GdkColormap *cmap)
{
GdkColormapPrivate *private;
GdkColormapPrivateX *private;
if (!colormap_hash)
colormap_hash = g_hash_table_new ((GHashFunc) gdk_colormap_hash,
(GCompareFunc) gdk_colormap_cmp);
private = (GdkColormapPrivate*) cmap;
private = (GdkColormapPrivateX *)cmap;
g_hash_table_remove (colormap_hash, &private->xcolormap);
}

View File

@ -29,8 +29,6 @@
#include "gdkx.h"
#include "gdkcursor.h"
#include "gdkprivate.h"
GdkCursor*
gdk_cursor_new (GdkCursorType cursor_type)

View File

@ -201,12 +201,12 @@ gdk_drag_context_find (gboolean is_source,
context_dest_xid = context->dest_window ?
(private->drop_xid ?
private->drop_xid :
GDK_WINDOW_XWINDOW (context->dest_window)) :
GDK_DRAWABLE_XID (context->dest_window)) :
None;
if ((!context->is_source == !is_source) &&
((source_xid == None) || (context->source_window &&
(GDK_WINDOW_XWINDOW (context->source_window) == source_xid))) &&
(GDK_DRAWABLE_XID (context->source_window) == source_xid))) &&
((dest_xid == None) || (context_dest_xid == dest_xid)))
return context;
@ -372,7 +372,7 @@ gdk_window_cache_new (void)
result->old_event_mask = xwa.your_event_mask;
XSelectInput (gdk_display, gdk_root_window,
result->old_event_mask | SubstructureNotifyMask);
gdk_window_add_filter ((GdkWindow *)&gdk_root_parent,
gdk_window_add_filter (gdk_parent_root,
gdk_window_cache_filter, result);
gdk_error_code = 0;
@ -411,7 +411,7 @@ static void
gdk_window_cache_destroy (GdkWindowCache *cache)
{
XSelectInput (gdk_display, gdk_root_window, cache->old_event_mask);
gdk_window_remove_filter ((GdkWindow *)&gdk_root_parent,
gdk_window_remove_filter (gdk_parent_root,
gdk_window_cache_filter, cache);
g_list_foreach (cache->children, (GFunc)g_free, NULL);
@ -1273,8 +1273,8 @@ motif_set_targets (GdkDragContext *context)
info.selection_atom = private->motif_selection;
XChangeProperty (GDK_WINDOW_XDISPLAY (context->source_window),
GDK_WINDOW_XWINDOW (context->source_window),
XChangeProperty (GDK_DRAWABLE_XDISPLAY (context->source_window),
GDK_DRAWABLE_XID (context->source_window),
private->motif_selection,
motif_drag_initiator_info, 8, PropModeReplace,
(guchar *)&info, sizeof (info));
@ -1333,24 +1333,24 @@ motif_send_enter (GdkDragContext *context,
xev.xclient.type = ClientMessage;
xev.xclient.message_type = gdk_atom_intern ("_MOTIF_DRAG_AND_DROP_MESSAGE", FALSE);
xev.xclient.format = 8;
xev.xclient.window = GDK_WINDOW_XWINDOW (context->dest_window);
xev.xclient.window = GDK_DRAWABLE_XID (context->dest_window);
MOTIF_XCLIENT_BYTE (&xev, 0) = XmTOP_LEVEL_ENTER;
MOTIF_XCLIENT_BYTE (&xev, 1) = local_byte_order;
MOTIF_XCLIENT_SHORT (&xev, 1) = 0;
MOTIF_XCLIENT_LONG (&xev, 1) = time;
MOTIF_XCLIENT_LONG (&xev, 2) = GDK_WINDOW_XWINDOW (context->source_window);
MOTIF_XCLIENT_LONG (&xev, 2) = GDK_DRAWABLE_XID (context->source_window);
if (!private->motif_targets_set)
motif_set_targets (context);
MOTIF_XCLIENT_LONG (&xev, 3) = private->motif_selection;
if (!gdk_send_xevent (GDK_WINDOW_XWINDOW (context->dest_window),
if (!gdk_send_xevent (GDK_DRAWABLE_XID (context->dest_window),
FALSE, 0, &xev))
GDK_NOTE (DND,
g_message ("Send event to %lx failed",
GDK_WINDOW_XWINDOW (context->dest_window)));
GDK_DRAWABLE_XID (context->dest_window)));
}
static void
@ -1362,20 +1362,20 @@ motif_send_leave (GdkDragContext *context,
xev.xclient.type = ClientMessage;
xev.xclient.message_type = gdk_atom_intern ("_MOTIF_DRAG_AND_DROP_MESSAGE", FALSE);
xev.xclient.format = 8;
xev.xclient.window = GDK_WINDOW_XWINDOW (context->dest_window);
xev.xclient.window = GDK_DRAWABLE_XID (context->dest_window);
MOTIF_XCLIENT_BYTE (&xev, 0) = XmTOP_LEVEL_LEAVE;
MOTIF_XCLIENT_BYTE (&xev, 1) = local_byte_order;
MOTIF_XCLIENT_SHORT (&xev, 1) = 0;
MOTIF_XCLIENT_LONG (&xev, 1) = time;
MOTIF_XCLIENT_LONG (&xev, 2) = GDK_WINDOW_XWINDOW (context->source_window);
MOTIF_XCLIENT_LONG (&xev, 2) = GDK_DRAWABLE_XID (context->source_window);
MOTIF_XCLIENT_LONG (&xev, 3) = 0;
if (!gdk_send_xevent (GDK_WINDOW_XWINDOW (context->dest_window),
if (!gdk_send_xevent (GDK_DRAWABLE_XID (context->dest_window),
FALSE, 0, &xev))
GDK_NOTE (DND,
g_message ("Send event to %lx failed",
GDK_WINDOW_XWINDOW (context->dest_window)));
GDK_DRAWABLE_XID (context->dest_window)));
}
static gboolean
@ -1392,7 +1392,7 @@ motif_send_motion (GdkDragContext *context,
xev.xclient.type = ClientMessage;
xev.xclient.message_type = gdk_atom_intern ("_MOTIF_DRAG_AND_DROP_MESSAGE", FALSE);
xev.xclient.format = 8;
xev.xclient.window = GDK_WINDOW_XWINDOW (context->dest_window);
xev.xclient.window = GDK_DRAWABLE_XID (context->dest_window);
MOTIF_XCLIENT_BYTE (&xev, 1) = local_byte_order;
MOTIF_XCLIENT_SHORT (&xev, 1) = motif_dnd_get_flags (context);
@ -1417,11 +1417,11 @@ motif_send_motion (GdkDragContext *context,
retval = FALSE;
}
if (!gdk_send_xevent (GDK_WINDOW_XWINDOW (context->dest_window),
if (!gdk_send_xevent (GDK_DRAWABLE_XID (context->dest_window),
FALSE, 0, &xev))
GDK_NOTE (DND,
g_message ("Send event to %lx failed",
GDK_WINDOW_XWINDOW (context->dest_window)));
GDK_DRAWABLE_XID (context->dest_window)));
return retval;
}
@ -1435,7 +1435,7 @@ motif_send_drop (GdkDragContext *context, guint32 time)
xev.xclient.type = ClientMessage;
xev.xclient.message_type = gdk_atom_intern ("_MOTIF_DRAG_AND_DROP_MESSAGE", FALSE);
xev.xclient.format = 8;
xev.xclient.window = GDK_WINDOW_XWINDOW (context->dest_window);
xev.xclient.window = GDK_DRAWABLE_XID (context->dest_window);
MOTIF_XCLIENT_BYTE (&xev, 0) = XmDROP_START;
MOTIF_XCLIENT_BYTE (&xev, 1) = local_byte_order;
@ -1446,13 +1446,13 @@ motif_send_drop (GdkDragContext *context, guint32 time)
MOTIF_XCLIENT_SHORT (&xev, 5) = private->last_y;
MOTIF_XCLIENT_LONG (&xev, 3) = private->motif_selection;
MOTIF_XCLIENT_LONG (&xev, 4) = GDK_WINDOW_XWINDOW (context->source_window);
MOTIF_XCLIENT_LONG (&xev, 4) = GDK_DRAWABLE_XID (context->source_window);
if (!gdk_send_xevent (GDK_WINDOW_XWINDOW (context->dest_window),
if (!gdk_send_xevent (GDK_DRAWABLE_XID (context->dest_window),
FALSE, 0, &xev))
GDK_NOTE (DND,
g_message ("Send event to %lx failed",
GDK_WINDOW_XWINDOW (context->dest_window)));
GDK_DRAWABLE_XID (context->dest_window)));
}
/* Target Side */
@ -1756,7 +1756,7 @@ motif_drag_status (GdkEvent *event,
g_message ("Motif status message: flags %x", flags));
context = gdk_drag_context_find (TRUE,
GDK_WINDOW_XWINDOW (event->any.window),
GDK_DRAWABLE_XID (event->any.window),
None);
if (context)
@ -2028,8 +2028,8 @@ xdnd_set_targets (GdkDragContext *context)
i++;
}
XChangeProperty (GDK_WINDOW_XDISPLAY (context->source_window),
GDK_WINDOW_XWINDOW (context->source_window),
XChangeProperty (GDK_DRAWABLE_XDISPLAY (context->source_window),
GDK_DRAWABLE_XID (context->source_window),
gdk_atom_intern ("XdndTypeList", FALSE),
XA_ATOM, 32, PropModeReplace,
(guchar *)atomlist, n_atoms);
@ -2076,8 +2076,8 @@ xdnd_set_actions (GdkDragContext *context)
}
}
XChangeProperty (GDK_WINDOW_XDISPLAY (context->source_window),
GDK_WINDOW_XWINDOW (context->source_window),
XChangeProperty (GDK_DRAWABLE_XDISPLAY (context->source_window),
GDK_DRAWABLE_XID (context->source_window),
gdk_atom_intern ("XdndActionList", FALSE),
XA_ATOM, 32, PropModeReplace,
(guchar *)atomlist, n_atoms);
@ -2119,8 +2119,8 @@ xdnd_send_enter (GdkDragContext *context)
xev.xclient.format = 32;
xev.xclient.window = private->drop_xid ?
private->drop_xid :
GDK_WINDOW_XWINDOW (context->dest_window);
xev.xclient.data.l[0] = GDK_WINDOW_XWINDOW (context->source_window);
GDK_DRAWABLE_XID (context->dest_window);
xev.xclient.data.l[0] = GDK_DRAWABLE_XID (context->source_window);
xev.xclient.data.l[1] = (3 << 24); /* version */
xev.xclient.data.l[2] = 0;
xev.xclient.data.l[3] = 0;
@ -2148,12 +2148,12 @@ xdnd_send_enter (GdkDragContext *context)
}
}
if (!xdnd_send_xevent (GDK_WINDOW_XWINDOW (context->dest_window),
if (!xdnd_send_xevent (GDK_DRAWABLE_XID (context->dest_window),
FALSE, &xev))
{
GDK_NOTE (DND,
g_message ("Send event to %lx failed",
GDK_WINDOW_XWINDOW (context->dest_window)));
GDK_DRAWABLE_XID (context->dest_window)));
gdk_window_unref (context->dest_window);
context->dest_window = NULL;
}
@ -2171,19 +2171,19 @@ xdnd_send_leave (GdkDragContext *context)
xev.xclient.format = 32;
xev.xclient.window = private->drop_xid ?
private->drop_xid :
GDK_WINDOW_XWINDOW (context->dest_window);
xev.xclient.data.l[0] = GDK_WINDOW_XWINDOW (context->source_window);
GDK_DRAWABLE_XID (context->dest_window);
xev.xclient.data.l[0] = GDK_DRAWABLE_XID (context->source_window);
xev.xclient.data.l[1] = 0;
xev.xclient.data.l[2] = 0;
xev.xclient.data.l[3] = 0;
xev.xclient.data.l[4] = 0;
if (!xdnd_send_xevent (GDK_WINDOW_XWINDOW (context->dest_window),
if (!xdnd_send_xevent (GDK_DRAWABLE_XID (context->dest_window),
FALSE, &xev))
{
GDK_NOTE (DND,
g_message ("Send event to %lx failed",
GDK_WINDOW_XWINDOW (context->dest_window)));
GDK_DRAWABLE_XID (context->dest_window)));
gdk_window_unref (context->dest_window);
context->dest_window = NULL;
}
@ -2200,19 +2200,19 @@ xdnd_send_drop (GdkDragContext *context, guint32 time)
xev.xclient.format = 32;
xev.xclient.window = private->drop_xid ?
private->drop_xid :
GDK_WINDOW_XWINDOW (context->dest_window);
xev.xclient.data.l[0] = GDK_WINDOW_XWINDOW (context->source_window);
GDK_DRAWABLE_XID (context->dest_window);
xev.xclient.data.l[0] = GDK_DRAWABLE_XID (context->source_window);
xev.xclient.data.l[1] = 0;
xev.xclient.data.l[2] = time;
xev.xclient.data.l[3] = 0;
xev.xclient.data.l[4] = 0;
if (!xdnd_send_xevent (GDK_WINDOW_XWINDOW (context->dest_window),
if (!xdnd_send_xevent (GDK_DRAWABLE_XID (context->dest_window),
FALSE, &xev))
{
GDK_NOTE (DND,
g_message ("Send event to %lx failed",
GDK_WINDOW_XWINDOW (context->dest_window)));
GDK_DRAWABLE_XID (context->dest_window)));
gdk_window_unref (context->dest_window);
context->dest_window = NULL;
}
@ -2233,19 +2233,19 @@ xdnd_send_motion (GdkDragContext *context,
xev.xclient.format = 32;
xev.xclient.window = private->drop_xid ?
private->drop_xid :
GDK_WINDOW_XWINDOW (context->dest_window);
xev.xclient.data.l[0] = GDK_WINDOW_XWINDOW (context->source_window);
GDK_DRAWABLE_XID (context->dest_window);
xev.xclient.data.l[0] = GDK_DRAWABLE_XID (context->source_window);
xev.xclient.data.l[1] = 0;
xev.xclient.data.l[2] = (x_root << 16) | y_root;
xev.xclient.data.l[3] = time;
xev.xclient.data.l[4] = xdnd_action_to_atom (action);
if (!xdnd_send_xevent (GDK_WINDOW_XWINDOW (context->dest_window),
if (!xdnd_send_xevent (GDK_DRAWABLE_XID (context->dest_window),
FALSE, &xev))
{
GDK_NOTE (DND,
g_message ("Send event to %lx failed",
GDK_WINDOW_XWINDOW (context->dest_window)));
GDK_DRAWABLE_XID (context->dest_window)));
gdk_window_unref (context->dest_window);
context->dest_window = NULL;
}
@ -2345,8 +2345,8 @@ xdnd_read_actions (GdkDragContext *context)
/* Get the XdndActionList, if set */
XGetWindowProperty (GDK_WINDOW_XDISPLAY (context->source_window),
GDK_WINDOW_XWINDOW (context->source_window),
XGetWindowProperty (GDK_DRAWABLE_XDISPLAY (context->source_window),
GDK_DRAWABLE_XID (context->source_window),
gdk_atom_intern ("XdndActionList", FALSE), 0, 65536,
False, XA_ATOM, &type, &format, &nitems,
&after, (guchar **)&data);
@ -2511,7 +2511,7 @@ xdnd_enter_filter (GdkXEvent *xev,
new_context->targets = NULL;
if (get_types)
{
XGetWindowProperty (GDK_WINDOW_XDISPLAY (event->any.window),
XGetWindowProperty (GDK_DRAWABLE_XDISPLAY (event->any.window),
source_window,
gdk_atom_intern ("XdndTypeList", FALSE), 0, 65536,
False, XA_ATOM, &type, &format, &nitems,
@ -2570,7 +2570,7 @@ xdnd_leave_filter (GdkXEvent *xev,
if ((current_dest_drag != NULL) &&
(current_dest_drag->protocol == GDK_DRAG_PROTO_XDND) &&
(GDK_WINDOW_XWINDOW (current_dest_drag->source_window) == source_window))
(GDK_DRAWABLE_XID (current_dest_drag->source_window) == source_window))
{
event->dnd.type = GDK_DRAG_LEAVE;
/* Pass ownership of context to the event */
@ -2603,7 +2603,7 @@ xdnd_position_filter (GdkXEvent *xev,
if ((current_dest_drag != NULL) &&
(current_dest_drag->protocol == GDK_DRAG_PROTO_XDND) &&
(GDK_WINDOW_XWINDOW (current_dest_drag->source_window) == source_window))
(GDK_DRAWABLE_XID (current_dest_drag->source_window) == source_window))
{
event->dnd.type = GDK_DRAG_MOTION;
event->dnd.context = current_dest_drag;
@ -2642,7 +2642,7 @@ xdnd_drop_filter (GdkXEvent *xev,
if ((current_dest_drag != NULL) &&
(current_dest_drag->protocol == GDK_DRAG_PROTO_XDND) &&
(GDK_WINDOW_XWINDOW (current_dest_drag->source_window) == source_window))
(GDK_DRAWABLE_XID (current_dest_drag->source_window) == source_window))
{
GdkDragContextPrivate *private;
private = (GdkDragContextPrivate *)current_dest_drag;
@ -2843,7 +2843,7 @@ gdk_drag_find_window (GdkDragContext *context,
dest = get_client_window_at_coords (private->window_cache,
drag_window ?
GDK_WINDOW_XWINDOW (drag_window) : GDK_NONE,
GDK_DRAWABLE_XID (drag_window) : GDK_NONE,
x_root, y_root);
if (private->dest_xid != dest)
@ -3077,7 +3077,7 @@ gdk_drag_status (GdkDragContext *context,
xev.xclient.type = ClientMessage;
xev.xclient.message_type = gdk_atom_intern ("_MOTIF_DRAG_AND_DROP_MESSAGE", FALSE);
xev.xclient.format = 8;
xev.xclient.window = GDK_WINDOW_XWINDOW (context->source_window);
xev.xclient.window = GDK_DRAWABLE_XID (context->source_window);
if (private->drag_status == GDK_DRAG_STATUS_ACTION_WAIT)
{
@ -3123,30 +3123,30 @@ gdk_drag_status (GdkDragContext *context,
MOTIF_XCLIENT_SHORT (&xev, 4) = private->last_x;
MOTIF_XCLIENT_SHORT (&xev, 5) = private->last_y;
if (!gdk_send_xevent (GDK_WINDOW_XWINDOW (context->source_window),
if (!gdk_send_xevent (GDK_DRAWABLE_XID (context->source_window),
FALSE, 0, &xev))
GDK_NOTE (DND,
g_message ("Send event to %lx failed",
GDK_WINDOW_XWINDOW (context->source_window)));
GDK_DRAWABLE_XID (context->source_window)));
}
else if (context->protocol == GDK_DRAG_PROTO_XDND)
{
xev.xclient.type = ClientMessage;
xev.xclient.message_type = gdk_atom_intern ("XdndStatus", FALSE);
xev.xclient.format = 32;
xev.xclient.window = GDK_WINDOW_XWINDOW (context->source_window);
xev.xclient.window = GDK_DRAWABLE_XID (context->source_window);
xev.xclient.data.l[0] = GDK_WINDOW_XWINDOW (context->dest_window);
xev.xclient.data.l[0] = GDK_DRAWABLE_XID (context->dest_window);
xev.xclient.data.l[1] = (action != 0) ? (2 | 1) : 0;
xev.xclient.data.l[2] = 0;
xev.xclient.data.l[3] = 0;
xev.xclient.data.l[4] = xdnd_action_to_atom (action);
if (!xdnd_send_xevent (GDK_WINDOW_XWINDOW (context->source_window),
if (!xdnd_send_xevent (GDK_DRAWABLE_XID (context->source_window),
FALSE, &xev))
GDK_NOTE (DND,
g_message ("Send event to %lx failed",
GDK_WINDOW_XWINDOW (context->source_window)));
GDK_DRAWABLE_XID (context->source_window)));
}
private->old_action = action;
@ -3186,7 +3186,7 @@ gdk_drop_reply (GdkDragContext *context,
MOTIF_XCLIENT_SHORT (&xev, 2) = private->last_x;
MOTIF_XCLIENT_SHORT (&xev, 3) = private->last_y;
gdk_send_xevent (GDK_WINDOW_XWINDOW (context->source_window),
gdk_send_xevent (GDK_DRAWABLE_XID (context->source_window),
FALSE, 0, &xev);
}
}
@ -3205,19 +3205,19 @@ gdk_drop_finish (GdkDragContext *context,
xev.xclient.type = ClientMessage;
xev.xclient.message_type = gdk_atom_intern ("XdndFinished", FALSE);
xev.xclient.format = 32;
xev.xclient.window = GDK_WINDOW_XWINDOW (context->source_window);
xev.xclient.window = GDK_DRAWABLE_XID (context->source_window);
xev.xclient.data.l[0] = GDK_WINDOW_XWINDOW (context->dest_window);
xev.xclient.data.l[0] = GDK_DRAWABLE_XID (context->dest_window);
xev.xclient.data.l[1] = 0;
xev.xclient.data.l[2] = 0;
xev.xclient.data.l[3] = 0;
xev.xclient.data.l[4] = 0;
if (!xdnd_send_xevent (GDK_WINDOW_XWINDOW (context->source_window),
if (!xdnd_send_xevent (GDK_DRAWABLE_XID (context->source_window),
FALSE, &xev))
GDK_NOTE (DND,
g_message ("Send event to %lx failed",
GDK_WINDOW_XWINDOW (context->source_window)));
GDK_DRAWABLE_XID (context->source_window)));
}
}
@ -3242,7 +3242,7 @@ gdk_window_register_dnd (GdkWindow *window)
info.num_drop_sites = 0;
info.total_size = sizeof(info);
XChangeProperty (gdk_display, GDK_WINDOW_XWINDOW (window),
XChangeProperty (gdk_display, GDK_DRAWABLE_XID (window),
motif_drag_receiver_info_atom,
motif_drag_receiver_info_atom,
8, PropModeReplace,
@ -3255,8 +3255,8 @@ gdk_window_register_dnd (GdkWindow *window)
xdnd_aware_atom = gdk_atom_intern ("XdndAware", FALSE);
/* The property needs to be of type XA_ATOM, not XA_INTEGER. Blech */
XChangeProperty (GDK_WINDOW_XDISPLAY (window),
GDK_WINDOW_XWINDOW (window),
XChangeProperty (GDK_DRAWABLE_XDISPLAY (window),
GDK_DRAWABLE_XID (window),
xdnd_aware_atom, XA_ATOM,
32, PropModeReplace,
(guchar *)&xdnd_version, 1);

409
gdk/x11/gdkdrawable-x11.c Normal file
View File

@ -0,0 +1,409 @@
#include "gdkx.h"
static void gdk_x11_drawable_destroy (GdkDrawable *drawable);
static void gdk_x11_draw_rectangle (GdkDrawable *drawable,
GdkGC *gc,
gint filled,
gint x,
gint y,
gint width,
gint height);
static void gdk_x11_draw_arc (GdkDrawable *drawable,
GdkGC *gc,
gint filled,
gint x,
gint y,
gint width,
gint height,
gint angle1,
gint angle2);
static void gdk_x11_draw_polygon (GdkDrawable *drawable,
GdkGC *gc,
gint filled,
GdkPoint *points,
gint npoints);
static void gdk_x11_draw_text (GdkDrawable *drawable,
GdkFont *font,
GdkGC *gc,
gint x,
gint y,
const gchar *text,
gint text_length);
static void gdk_x11_draw_text_wc (GdkDrawable *drawable,
GdkFont *font,
GdkGC *gc,
gint x,
gint y,
const GdkWChar *text,
gint text_length);
static void gdk_x11_draw_drawable (GdkDrawable *drawable,
GdkGC *gc,
GdkPixmap *src,
gint xsrc,
gint ysrc,
gint xdest,
gint ydest,
gint width,
gint height);
static void gdk_x11_draw_points (GdkDrawable *drawable,
GdkGC *gc,
GdkPoint *points,
gint npoints);
static void gdk_x11_draw_segments (GdkDrawable *drawable,
GdkGC *gc,
GdkSegment *segs,
gint nsegs);
static void gdk_x11_draw_lines (GdkDrawable *drawable,
GdkGC *gc,
GdkPoint *points,
gint npoints);
GdkDrawableClass _gdk_x11_drawable_class = {
gdk_x11_drawable_destroy,
_gdk_x11_gc_new,
gdk_x11_draw_rectangle,
gdk_x11_draw_arc,
gdk_x11_draw_polygon,
gdk_x11_draw_text,
gdk_x11_draw_text_wc,
gdk_x11_draw_drawable,
gdk_x11_draw_points,
gdk_x11_draw_segments,
gdk_x11_draw_lines
};
/*****************************************************
* X11 specific implementations of generic functions *
*****************************************************/
GdkColormap*
gdk_drawable_get_colormap (GdkDrawable *drawable)
{
GdkDrawablePrivate *drawable_private;
XWindowAttributes window_attributes;
g_return_val_if_fail (drawable != NULL, NULL);
drawable_private = (GdkDrawablePrivate*) drawable;
if (!GDK_DRAWABLE_DESTROYED (drawable))
{
if (drawable_private->colormap == NULL &&
GDK_IS_WINDOW (drawable))
{
XGetWindowAttributes (GDK_DRAWABLE_XDISPLAY (drawable),
GDK_DRAWABLE_XID (drawable),
&window_attributes);
drawable_private->colormap = gdk_colormap_lookup (window_attributes.colormap);
}
return drawable_private->colormap;
}
return NULL;
}
void
gdk_drawable_set_colormap (GdkDrawable *drawable,
GdkColormap *colormap)
{
GdkDrawablePrivate *drawable_private;
GdkColormapPrivateX *colormap_private;
g_return_if_fail (drawable != NULL);
g_return_if_fail (colormap != NULL);
drawable_private = (GdkDrawablePrivate *)drawable;
colormap_private = (GdkColormapPrivateX *)colormap;
if (!GDK_DRAWABLE_DESTROYED (drawable))
{
if (GDK_IS_WINDOW (drawable))
{
g_return_if_fail (colormap_private->base.visual !=
((GdkColormapPrivate *)(drawable_private->colormap))->visual);
XSetWindowColormap (GDK_DRAWABLE_XDISPLAY (drawable),
GDK_DRAWABLE_XID (drawable),
colormap_private->xcolormap);
}
if (drawable_private->colormap)
gdk_colormap_unref (drawable_private->colormap);
drawable_private->colormap = colormap;
gdk_colormap_ref (drawable_private->colormap);
if (GDK_IS_WINDOW (drawable) &&
drawable_private->window_type != GDK_WINDOW_TOPLEVEL)
gdk_window_add_colormap_windows (drawable);
}
}
/* Drawing
*/
static void
gdk_x11_drawable_destroy (GdkDrawable *drawable)
{
}
static void
gdk_x11_draw_rectangle (GdkDrawable *drawable,
GdkGC *gc,
gint filled,
gint x,
gint y,
gint width,
gint height)
{
if (filled)
XFillRectangle (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
GDK_GC_XGC (gc), x, y, width, height);
else
XDrawRectangle (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
GDK_GC_XGC (gc), x, y, width, height);
}
static void
gdk_x11_draw_arc (GdkDrawable *drawable,
GdkGC *gc,
gint filled,
gint x,
gint y,
gint width,
gint height,
gint angle1,
gint angle2)
{
if (filled)
XFillArc (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
GDK_GC_XGC (gc), x, y, width, height, angle1, angle2);
else
XDrawArc (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
GDK_GC_XGC (gc), x, y, width, height, angle1, angle2);
}
static void
gdk_x11_draw_polygon (GdkDrawable *drawable,
GdkGC *gc,
gint filled,
GdkPoint *points,
gint npoints)
{
if (filled)
{
XFillPolygon (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
GDK_GC_XGC (gc), (XPoint*) points, npoints, Complex, CoordModeOrigin);
}
else
{
GdkPoint *local_points = points;
gint local_npoints = npoints;
gint local_alloc = 0;
if ((points[0].x != points[npoints-1].x) ||
(points[0].y != points[npoints-1].y))
{
local_alloc = 1;
++local_npoints;
local_points = (GdkPoint*) g_malloc (local_npoints * sizeof(GdkPoint));
memcpy (local_points, points, npoints * sizeof(GdkPoint));
local_points[npoints].x = points[0].x;
local_points[npoints].y = points[0].y;
}
XDrawLines (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
GDK_GC_XGC (gc),
(XPoint*) local_points, local_npoints,
CoordModeOrigin);
if (local_alloc)
g_free (local_points);
}
}
/* gdk_x11_draw_text
*
* Modified by Li-Da Lho to draw 16 bits and Multibyte strings
*
* Interface changed: add "GdkFont *font" to specify font or fontset explicitely
*/
static void
gdk_x11_draw_text (GdkDrawable *drawable,
GdkFont *font,
GdkGC *gc,
gint x,
gint y,
const gchar *text,
gint text_length)
{
if (font->type == GDK_FONT_FONT)
{
XFontStruct *xfont = (XFontStruct *) GDK_FONT_XFONT (font);
XSetFont(GDK_DRAWABLE_XDISPLAY (drawable), GDK_GC_XGC (gc), xfont->fid);
if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))
{
XDrawString (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
GDK_GC_XGC (gc), x, y, text, text_length);
}
else
{
XDrawString16 (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
GDK_GC_XGC (gc), x, y, (XChar2b *) text, text_length / 2);
}
}
else if (font->type == GDK_FONT_FONTSET)
{
XFontSet fontset = (XFontSet) GDK_FONT_XFONT (font);
XmbDrawString (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
fontset, GDK_GC_XGC (gc), x, y, text, text_length);
}
else
g_error("undefined font type\n");
}
static void
gdk_x11_draw_text_wc (GdkDrawable *drawable,
GdkFont *font,
GdkGC *gc,
gint x,
gint y,
const GdkWChar *text,
gint text_length)
{
if (font->type == GDK_FONT_FONT)
{
XFontStruct *xfont = (XFontStruct *) GDK_FONT_XFONT (font);
gchar *text_8bit;
gint i;
XSetFont(GDK_DRAWABLE_XDISPLAY (drawable), GDK_GC_XGC (gc), xfont->fid);
text_8bit = g_new (gchar, text_length);
for (i=0; i<text_length; i++) text_8bit[i] = text[i];
XDrawString (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
GDK_GC_XGC (gc), x, y, text_8bit, text_length);
g_free (text_8bit);
}
else if (font->type == GDK_FONT_FONTSET)
{
if (sizeof(GdkWChar) == sizeof(wchar_t))
{
XwcDrawString (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
(XFontSet) GDK_FONT_XFONT (font),
GDK_GC_XGC (gc), x, y, (wchar_t *)text, text_length);
}
else
{
wchar_t *text_wchar;
gint i;
text_wchar = g_new (wchar_t, text_length);
for (i=0; i<text_length; i++) text_wchar[i] = text[i];
XwcDrawString (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
(XFontSet) GDK_FONT_XFONT (font),
GDK_GC_XGC (gc), x, y, text_wchar, text_length);
g_free (text_wchar);
}
}
else
g_error("undefined font type\n");
}
static void
gdk_x11_draw_drawable (GdkDrawable *drawable,
GdkGC *gc,
GdkPixmap *src,
gint xsrc,
gint ysrc,
gint xdest,
gint ydest,
gint width,
gint height)
{
/* FIXME: this doesn't work because bitmaps don't have visuals */
if (gdk_drawable_get_visual (src)->depth == 1)
{
XCopyArea (GDK_DRAWABLE_XDISPLAY (drawable),
GDK_DRAWABLE_XID (src),
GDK_DRAWABLE_XID (drawable),
GDK_GC_XGC (gc),
xsrc, ysrc,
width, height,
xdest, ydest);
}
else
{
XCopyArea (GDK_DRAWABLE_XDISPLAY (drawable),
GDK_DRAWABLE_XID (src),
GDK_DRAWABLE_XID (drawable),
GDK_GC_XGC (gc),
xsrc, ysrc,
width, height,
xdest, ydest);
}
}
static void
gdk_x11_draw_points (GdkDrawable *drawable,
GdkGC *gc,
GdkPoint *points,
gint npoints)
{
/* We special-case npoints == 1, because X will merge multiple
* consecutive XDrawPoint requests into a PolyPoint request
*/
if (npoints == 1)
{
XDrawPoint (GDK_DRAWABLE_XDISPLAY (drawable),
GDK_DRAWABLE_XID (drawable),
GDK_GC_XGC (gc),
points[0].x, points[0].y);
}
else
{
XDrawPoints (GDK_DRAWABLE_XDISPLAY (drawable),
GDK_DRAWABLE_XID (drawable),
GDK_GC_XGC (gc),
(XPoint *) points,
npoints,
CoordModeOrigin);
}
}
static void
gdk_x11_draw_segments (GdkDrawable *drawable,
GdkGC *gc,
GdkSegment *segs,
gint nsegs)
{
/* We special-case nsegs == 1, because X will merge multiple
* consecutive XDrawLine requests into a PolySegment request
*/
if (nsegs == 1)
{
XDrawLine (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
GDK_GC_XGC (gc), segs[0].x1, segs[0].y1,
segs[0].x2, segs[0].y2);
}
else
{
XDrawSegments (GDK_DRAWABLE_XDISPLAY (drawable),
GDK_DRAWABLE_XID (drawable),
GDK_GC_XGC (gc),
(XSegment *) segs,
nsegs);
}
}
static void
gdk_x11_draw_lines (GdkDrawable *drawable,
GdkGC *gc,
GdkPoint *points,
gint npoints)
{
XDrawLines (GDK_DRAWABLE_XDISPLAY (drawable),
GDK_DRAWABLE_XID (drawable),
GDK_GC_XGC (gc),
(XPoint *) points,
npoints,
CoordModeOrigin);
}

View File

@ -73,7 +73,6 @@ struct _GdkEventPrivate
* Private function declarations
*/
static GdkEvent *gdk_event_new (void);
static gint gdk_event_apply_filters (XEvent *xevent,
GdkEvent *event,
GList *filters);
@ -84,8 +83,6 @@ static Bool gdk_event_get_type (Display *display,
XEvent *xevent,
XPointer arg);
#endif
static void gdk_events_queue (void);
static GdkEvent* gdk_event_unqueue (void);
static gboolean gdk_event_prepare (gpointer source_data,
GTimeVal *current_time,
@ -98,9 +95,6 @@ static gboolean gdk_event_dispatch (gpointer source_data,
GTimeVal *current_time,
gpointer user_data);
static void gdk_synthesize_click (GdkEvent *event,
gint nclicks);
GdkFilterReturn gdk_wm_protocols_filter (GdkXEvent *xev,
GdkEvent *event,
gpointer data);
@ -114,28 +108,8 @@ static int connection_number = 0; /* The file descriptor number of our
* when events are pending by using
* the "select" system call.
*/
static guint32 button_click_time[2]; /* The last 2 button click times. Used
* to determine if the latest button click
* is part of a double or triple click.
*/
static GdkWindow *button_window[2]; /* The last 2 windows to receive button presses.
* Also used to determine if the latest button
* click is part of a double or triple click.
*/
static guint button_number[2]; /* The last 2 buttons to be pressed.
*/
static GdkEventFunc event_func = NULL; /* Callback for events */
static gpointer event_data = NULL;
static GDestroyNotify event_notify = NULL;
static GList *client_filters; /* Filters for client messages */
/* FIFO's for event queue, and for events put back using
* gdk_event_put().
*/
static GList *queued_events = NULL;
static GList *queued_tail = NULL;
static GSourceFuncs event_funcs = {
gdk_event_prepare,
gdk_event_check,
@ -149,75 +123,6 @@ GPollFD event_poll_fd;
* Functions for maintaining the event queue *
*********************************************/
/*************************************************************
* gdk_event_queue_find_first:
* Find the first event on the queue that is not still
* being filled in.
* arguments:
*
* results:
* Pointer to the list node for that event, or NULL
*************************************************************/
static GList*
gdk_event_queue_find_first (void)
{
GList *tmp_list = queued_events;
while (tmp_list)
{
GdkEventPrivate *event = tmp_list->data;
if (!(event->flags & GDK_EVENT_PENDING))
return tmp_list;
tmp_list = g_list_next (tmp_list);
}
return NULL;
}
/*************************************************************
* gdk_event_queue_remove_link:
* Remove a specified list node from the event queue.
* arguments:
* node: Node to remove.
* results:
*************************************************************/
static void
gdk_event_queue_remove_link (GList *node)
{
if (node->prev)
node->prev->next = node->next;
else
queued_events = node->next;
if (node->next)
node->next->prev = node->prev;
else
queued_tail = node->prev;
}
/*************************************************************
* gdk_event_queue_append:
* Append an event onto the tail of the event queue.
* arguments:
* event: Event to append.
* results:
*************************************************************/
static void
gdk_event_queue_append (GdkEvent *event)
{
queued_tail = g_list_append (queued_tail, event);
if (!queued_events)
queued_events = queued_tail;
else
queued_tail = queued_tail->next;
}
void
gdk_events_init (void)
{
@ -232,13 +137,6 @@ gdk_events_init (void)
g_main_add_poll (&event_poll_fd, GDK_PRIORITY_EVENTS);
button_click_time[0] = 0;
button_click_time[1] = 0;
button_window[0] = NULL;
button_window[1] = NULL;
button_number[0] = -1;
button_number[1] = -1;
gdk_add_client_message_filter (gdk_wm_protocols,
gdk_wm_protocols_filter, NULL);
}
@ -525,410 +423,6 @@ gdk_compress_exposures (XEvent *xevent,
xevent->xexpose.height = rect1.height;
}
/*************************************************************
* gdk_event_handler_set:
*
* arguments:
* func: Callback function to be called for each event.
* data: Data supplied to the function
* notify: function called when function is no longer needed
*
* results:
*************************************************************/
void
gdk_event_handler_set (GdkEventFunc func,
gpointer data,
GDestroyNotify notify)
{
if (event_notify)
(*event_notify) (event_data);
event_func = func;
event_data = data;
event_notify = notify;
}
/*
*--------------------------------------------------------------
* gdk_event_get
*
* Gets the next event.
*
* Arguments:
*
* Results:
* If an event is waiting that we care about, returns
* a pointer to that event, to be freed with gdk_event_free.
* Otherwise, returns NULL.
*
* Side effects:
*
*--------------------------------------------------------------
*/
GdkEvent*
gdk_event_get (void)
{
gdk_events_queue ();
return gdk_event_unqueue ();
}
/*
*--------------------------------------------------------------
* gdk_event_peek
*
* Gets the next event.
*
* Arguments:
*
* Results:
* If an event is waiting that we care about, returns
* a copy of that event, but does not remove it from
* the queue. The pointer is to be freed with gdk_event_free.
* Otherwise, returns NULL.
*
* Side effects:
*
*--------------------------------------------------------------
*/
GdkEvent*
gdk_event_peek (void)
{
GList *tmp_list;
tmp_list = gdk_event_queue_find_first ();
if (tmp_list)
return gdk_event_copy (tmp_list->data);
else
return NULL;
}
void
gdk_event_put (GdkEvent *event)
{
GdkEvent *new_event;
g_return_if_fail (event != NULL);
new_event = gdk_event_copy (event);
gdk_event_queue_append (new_event);
}
/*
*--------------------------------------------------------------
* gdk_event_copy
*
* Copy a event structure into new storage.
*
* Arguments:
* "event" is the event struct to copy.
*
* Results:
* A new event structure. Free it with gdk_event_free.
*
* Side effects:
* The reference count of the window in the event is increased.
*
*--------------------------------------------------------------
*/
static GMemChunk *event_chunk = NULL;
static GdkEvent*
gdk_event_new (void)
{
GdkEventPrivate *new_event;
if (event_chunk == NULL)
event_chunk = g_mem_chunk_new ("events",
sizeof (GdkEventPrivate),
4096,
G_ALLOC_AND_FREE);
new_event = g_chunk_new (GdkEventPrivate, event_chunk);
new_event->flags = 0;
return (GdkEvent*) new_event;
}
GdkEvent*
gdk_event_copy (GdkEvent *event)
{
GdkEvent *new_event;
g_return_val_if_fail (event != NULL, NULL);
new_event = gdk_event_new ();
*new_event = *event;
gdk_window_ref (new_event->any.window);
switch (event->any.type)
{
case GDK_KEY_PRESS:
case GDK_KEY_RELEASE:
new_event->key.string = g_strdup (event->key.string);
break;
case GDK_ENTER_NOTIFY:
case GDK_LEAVE_NOTIFY:
if (event->crossing.subwindow != NULL)
gdk_window_ref (event->crossing.subwindow);
break;
case GDK_DRAG_ENTER:
case GDK_DRAG_LEAVE:
case GDK_DRAG_MOTION:
case GDK_DRAG_STATUS:
case GDK_DROP_START:
case GDK_DROP_FINISHED:
gdk_drag_context_ref (event->dnd.context);
break;
default:
break;
}
return new_event;
}
/*
*--------------------------------------------------------------
* gdk_event_free
*
* Free a event structure obtained from gdk_event_copy. Do not use
* with other event structures.
*
* Arguments:
* "event" is the event struct to free.
*
* Results:
*
* Side effects:
* The reference count of the window in the event is decreased and
* might be freed, too.
*
*-------------------------------------------------------------- */
void
gdk_event_free (GdkEvent *event)
{
g_return_if_fail (event != NULL);
g_assert (event_chunk != NULL); /* paranoid */
if (event->any.window)
gdk_window_unref (event->any.window);
switch (event->any.type)
{
case GDK_KEY_PRESS:
case GDK_KEY_RELEASE:
g_free (event->key.string);
break;
case GDK_ENTER_NOTIFY:
case GDK_LEAVE_NOTIFY:
if (event->crossing.subwindow != NULL)
gdk_window_unref (event->crossing.subwindow);
break;
case GDK_DRAG_ENTER:
case GDK_DRAG_LEAVE:
case GDK_DRAG_MOTION:
case GDK_DRAG_STATUS:
case GDK_DROP_START:
case GDK_DROP_FINISHED:
gdk_drag_context_unref (event->dnd.context);
break;
default:
break;
}
g_mem_chunk_free (event_chunk, event);
}
/*
*--------------------------------------------------------------
* gdk_event_get_time:
* Get the timestamp from an event.
* arguments:
* event:
* results:
* The event's time stamp, if it has one, otherwise
* GDK_CURRENT_TIME.
*--------------------------------------------------------------
*/
guint32
gdk_event_get_time (GdkEvent *event)
{
if (event)
switch (event->type)
{
case GDK_MOTION_NOTIFY:
return event->motion.time;
case GDK_BUTTON_PRESS:
case GDK_2BUTTON_PRESS:
case GDK_3BUTTON_PRESS:
case GDK_BUTTON_RELEASE:
return event->button.time;
case GDK_KEY_PRESS:
case GDK_KEY_RELEASE:
return event->key.time;
case GDK_ENTER_NOTIFY:
case GDK_LEAVE_NOTIFY:
return event->crossing.time;
case GDK_PROPERTY_NOTIFY:
return event->property.time;
case GDK_SELECTION_CLEAR:
case GDK_SELECTION_REQUEST:
case GDK_SELECTION_NOTIFY:
return event->selection.time;
case GDK_PROXIMITY_IN:
case GDK_PROXIMITY_OUT:
return event->proximity.time;
case GDK_DRAG_ENTER:
case GDK_DRAG_LEAVE:
case GDK_DRAG_MOTION:
case GDK_DRAG_STATUS:
case GDK_DROP_START:
case GDK_DROP_FINISHED:
return event->dnd.time;
default: /* use current time */
break;
}
return GDK_CURRENT_TIME;
}
/*
*--------------------------------------------------------------
* gdk_set_show_events
*
* Turns on/off the showing of events.
*
* Arguments:
* "show_events" is a boolean describing whether or
* not to show the events gdk receives.
*
* Results:
*
* Side effects:
* When "show_events" is TRUE, calls to "gdk_event_get"
* will output debugging informatin regarding the event
* received to stdout.
*
*--------------------------------------------------------------
*/
void
gdk_set_show_events (gint show_events)
{
if (show_events)
gdk_debug_flags |= GDK_DEBUG_EVENTS;
else
gdk_debug_flags &= ~GDK_DEBUG_EVENTS;
}
gint
gdk_get_show_events (void)
{
return gdk_debug_flags & GDK_DEBUG_EVENTS;
}
static void
gdk_io_destroy (gpointer data)
{
GdkIOClosure *closure = data;
if (closure->notify)
closure->notify (closure->data);
g_free (closure);
}
/* What do we do with G_IO_NVAL?
*/
#define READ_CONDITION (G_IO_IN | G_IO_HUP | G_IO_ERR)
#define WRITE_CONDITION (G_IO_OUT | G_IO_ERR)
#define EXCEPTION_CONDITION (G_IO_PRI)
static gboolean
gdk_io_invoke (GIOChannel *source,
GIOCondition condition,
gpointer data)
{
GdkIOClosure *closure = data;
GdkInputCondition gdk_cond = 0;
if (condition & READ_CONDITION)
gdk_cond |= GDK_INPUT_READ;
if (condition & WRITE_CONDITION)
gdk_cond |= GDK_INPUT_WRITE;
if (condition & EXCEPTION_CONDITION)
gdk_cond |= GDK_INPUT_EXCEPTION;
if (closure->condition & gdk_cond)
closure->function (closure->data, g_io_channel_unix_get_fd (source), gdk_cond);
return TRUE;
}
gint
gdk_input_add_full (gint source,
GdkInputCondition condition,
GdkInputFunction function,
gpointer data,
GdkDestroyNotify destroy)
{
guint result;
GdkIOClosure *closure = g_new (GdkIOClosure, 1);
GIOChannel *channel;
GIOCondition cond = 0;
closure->function = function;
closure->condition = condition;
closure->notify = destroy;
closure->data = data;
if (condition & GDK_INPUT_READ)
cond |= READ_CONDITION;
if (condition & GDK_INPUT_WRITE)
cond |= WRITE_CONDITION;
if (condition & GDK_INPUT_EXCEPTION)
cond |= EXCEPTION_CONDITION;
channel = g_io_channel_unix_new (source);
result = g_io_add_watch_full (channel, G_PRIORITY_DEFAULT, cond,
gdk_io_invoke,
closure, gdk_io_destroy);
g_io_channel_unref (channel);
return result;
}
gint
gdk_input_add (gint source,
GdkInputCondition condition,
GdkInputFunction function,
gpointer data)
{
return gdk_input_add_full (source, condition, function, data, NULL);
}
void
gdk_input_remove (gint tag)
{
g_source_remove (tag);
}
static gint
gdk_event_apply_filters (XEvent *xevent,
GdkEvent *event,
@ -1221,41 +715,7 @@ gdk_event_translate (GdkEvent *event,
event->button.source = GDK_SOURCE_MOUSE;
event->button.deviceid = GDK_CORE_POINTER;
if ((event->button.time < (button_click_time[1] + TRIPLE_CLICK_TIME)) &&
(event->button.window == button_window[1]) &&
(event->button.button == button_number[1]))
{
gdk_synthesize_click (event, 3);
button_click_time[1] = 0;
button_click_time[0] = 0;
button_window[1] = NULL;
button_window[0] = 0;
button_number[1] = -1;
button_number[0] = -1;
}
else if ((event->button.time < (button_click_time[0] + DOUBLE_CLICK_TIME)) &&
(event->button.window == button_window[0]) &&
(event->button.button == button_number[0]))
{
gdk_synthesize_click (event, 2);
button_click_time[1] = button_click_time[0];
button_click_time[0] = event->button.time;
button_window[1] = button_window[0];
button_window[0] = event->button.window;
button_number[1] = button_number[0];
button_number[0] = event->button.button;
}
else
{
button_click_time[1] = 0;
button_click_time[0] = event->button.time;
button_window[1] = NULL;
button_window[0] = event->button.window;
button_number[1] = -1;
button_number[0] = event->button.button;
}
gdk_event_button_generate (event);
break;
@ -1972,7 +1432,7 @@ gdk_event_get_type (Display *display,
}
#endif
static void
void
gdk_events_queue (void)
{
GList *node;
@ -2011,7 +1471,7 @@ gdk_events_queue (void)
((GdkEventPrivate *)event)->flags |= GDK_EVENT_PENDING;
gdk_event_queue_append (event);
node = queued_tail;
node = gdk_queued_tail;
if (gdk_event_translate (event, &xevent))
{
@ -2064,24 +1524,6 @@ gdk_event_check (gpointer source_data,
return retval;
}
static GdkEvent*
gdk_event_unqueue (void)
{
GdkEvent *event = NULL;
GList *tmp_list;
tmp_list = gdk_event_queue_find_first ();
if (tmp_list)
{
event = tmp_list->data;
gdk_event_queue_remove_link (tmp_list);
g_list_free_1 (tmp_list);
}
return event;
}
static gboolean
gdk_event_dispatch (gpointer source_data,
GTimeVal *current_time,
@ -2096,8 +1538,8 @@ gdk_event_dispatch (gpointer source_data,
if (event)
{
if (event_func)
(*event_func) (event, event_data);
if (gdk_event_func)
(*gdk_event_func) (event, gdk_event_data);
gdk_event_free (event);
}
@ -2107,20 +1549,6 @@ gdk_event_dispatch (gpointer source_data,
return TRUE;
}
static void
gdk_synthesize_click (GdkEvent *event,
gint nclicks)
{
GdkEvent temp_event;
g_return_if_fail (event != NULL);
temp_event = *event;
temp_event.type = (nclicks == 2) ? GDK_2BUTTON_PRESS : GDK_3BUTTON_PRESS;
gdk_event_put (&temp_event);
}
/* Sends a ClientMessage to all toplevel client windows */
gboolean
gdk_event_send_client_message (GdkEvent *event, guint32 xid)

View File

@ -27,7 +27,7 @@
#include <X11/Xlib.h>
#include <X11/Xos.h>
#include "gdkfont.h"
#include "gdkprivate.h"
#include "gdkx.h"
static GHashTable *font_name_hash = NULL;
static GHashTable *fontset_name_hash = NULL;
@ -35,7 +35,7 @@ static GHashTable *fontset_name_hash = NULL;
static void
gdk_font_hash_insert (GdkFontType type, GdkFont *font, const gchar *font_name)
{
GdkFontPrivate *private = (GdkFontPrivate *)font;
GdkFontPrivateX *private = (GdkFontPrivateX *)font;
GHashTable **hashp = (type == GDK_FONT_FONT) ?
&font_name_hash : &fontset_name_hash;
@ -49,7 +49,7 @@ gdk_font_hash_insert (GdkFontType type, GdkFont *font, const gchar *font_name)
static void
gdk_font_hash_remove (GdkFontType type, GdkFont *font)
{
GdkFontPrivate *private = (GdkFontPrivate *)font;
GdkFontPrivateX *private = (GdkFontPrivateX *)font;
GSList *tmp_list;
GHashTable *hash = (type == GDK_FONT_FONT) ?
font_name_hash : fontset_name_hash;
@ -90,7 +90,7 @@ GdkFont*
gdk_font_load (const gchar *font_name)
{
GdkFont *font;
GdkFontPrivate *private;
GdkFontPrivateX *private;
XFontStruct *xfont;
g_return_val_if_fail (font_name != NULL, NULL);
@ -106,7 +106,7 @@ gdk_font_load (const gchar *font_name)
font = gdk_font_lookup (xfont->fid);
if (font != NULL)
{
private = (GdkFontPrivate *) font;
private = (GdkFontPrivateX *) font;
if (xfont != private->xfont)
XFreeFont (gdk_display, xfont);
@ -114,10 +114,10 @@ gdk_font_load (const gchar *font_name)
}
else
{
private = g_new (GdkFontPrivate, 1);
private = g_new (GdkFontPrivateX, 1);
private->xdisplay = gdk_display;
private->xfont = xfont;
private->ref_count = 1;
private->base.ref_count = 1;
private->names = NULL;
font = (GdkFont*) private;
@ -137,7 +137,7 @@ GdkFont*
gdk_fontset_load (gchar *fontset_name)
{
GdkFont *font;
GdkFontPrivate *private;
GdkFontPrivateX *private;
XFontSet fontset;
gint missing_charset_count;
gchar **missing_charset_list;
@ -147,7 +147,7 @@ gdk_fontset_load (gchar *fontset_name)
if (font)
return font;
private = g_new (GdkFontPrivate, 1);
private = g_new (GdkFontPrivateX, 1);
font = (GdkFont*) private;
private->xdisplay = gdk_display;
@ -164,7 +164,7 @@ gdk_fontset_load (gchar *fontset_name)
XFreeStringList (missing_charset_list);
}
private->ref_count = 1;
private->base.ref_count = 1;
if (!fontset)
{
@ -197,30 +197,11 @@ gdk_fontset_load (gchar *fontset_name)
}
}
GdkFont*
gdk_font_ref (GdkFont *font)
{
GdkFontPrivate *private;
g_return_val_if_fail (font != NULL, NULL);
private = (GdkFontPrivate*) font;
private->ref_count += 1;
return font;
}
void
gdk_font_unref (GdkFont *font)
_gdk_font_destroy (GdkFont *font)
{
GdkFontPrivate *private;
private = (GdkFontPrivate*) font;
GdkFontPrivateX *private = (GdkFontPrivateX *)font;
g_return_if_fail (font != NULL);
g_return_if_fail (private->ref_count > 0);
private->ref_count -= 1;
if (private->ref_count == 0)
{
gdk_font_hash_remove (font->type, font);
switch (font->type)
@ -238,16 +219,52 @@ gdk_font_unref (GdkFont *font)
}
g_free (font);
}
gint
_gdk_font_strlen (GdkFont *font,
const gchar *str)
{
GdkFontPrivateX *font_private;
gint length = 0;
g_return_val_if_fail (font != NULL, -1);
g_return_val_if_fail (str != NULL, -1);
font_private = (GdkFontPrivateX*) font;
if (font->type == GDK_FONT_FONT)
{
XFontStruct *xfont = (XFontStruct *) font_private->xfont;
if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))
{
length = strlen (str);
}
else
{
guint16 *string_2b = (guint16 *)str;
while (*(string_2b++))
length++;
}
}
else if (font->type == GDK_FONT_FONTSET)
{
length = strlen (str);
}
else
g_error("undefined font type\n");
return length;
}
gint
gdk_font_id (const GdkFont *font)
{
const GdkFontPrivate *font_private;
const GdkFontPrivateX *font_private;
g_return_val_if_fail (font != NULL, 0);
font_private = (const GdkFontPrivate*) font;
font_private = (const GdkFontPrivateX*) font;
if (font->type == GDK_FONT_FONT)
{
@ -263,14 +280,14 @@ gint
gdk_font_equal (const GdkFont *fonta,
const GdkFont *fontb)
{
const GdkFontPrivate *privatea;
const GdkFontPrivate *privateb;
const GdkFontPrivateX *privatea;
const GdkFontPrivateX *privateb;
g_return_val_if_fail (fonta != NULL, FALSE);
g_return_val_if_fail (fontb != NULL, FALSE);
privatea = (const GdkFontPrivate*) fonta;
privateb = (const GdkFontPrivate*) fontb;
privatea = (const GdkFontPrivateX*) fonta;
privateb = (const GdkFontPrivateX*) fontb;
if (fonta->type == GDK_FONT_FONT && fontb->type == GDK_FONT_FONT)
{
@ -291,50 +308,12 @@ gdk_font_equal (const GdkFont *fonta,
return 0;
}
gint
gdk_string_width (GdkFont *font,
const gchar *string)
{
GdkFontPrivate *font_private;
gint width;
XFontStruct *xfont;
XFontSet fontset;
g_return_val_if_fail (font != NULL, -1);
g_return_val_if_fail (string != NULL, -1);
font_private = (GdkFontPrivate*) font;
switch (font->type)
{
case GDK_FONT_FONT:
xfont = (XFontStruct *) font_private->xfont;
if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))
{
width = XTextWidth (xfont, string, strlen (string));
}
else
{
width = XTextWidth16 (xfont, (XChar2b *) string, strlen (string) / 2);
}
break;
case GDK_FONT_FONTSET:
fontset = (XFontSet) font_private->xfont;
width = XmbTextEscapement (fontset, string, strlen(string));
break;
default:
width = 0;
}
return width;
}
gint
gdk_text_width (GdkFont *font,
const gchar *text,
gint text_length)
{
GdkFontPrivate *private;
GdkFontPrivateX *private;
gint width;
XFontStruct *xfont;
XFontSet fontset;
@ -342,7 +321,7 @@ gdk_text_width (GdkFont *font,
g_return_val_if_fail (font != NULL, -1);
g_return_val_if_fail (text != NULL, -1);
private = (GdkFontPrivate*) font;
private = (GdkFontPrivateX*) font;
switch (font->type)
{
@ -372,7 +351,7 @@ gdk_text_width_wc (GdkFont *font,
const GdkWChar *text,
gint text_length)
{
GdkFontPrivate *private;
GdkFontPrivateX *private;
gint width;
XFontStruct *xfont;
XFontSet fontset;
@ -380,7 +359,7 @@ gdk_text_width_wc (GdkFont *font,
g_return_val_if_fail (font != NULL, -1);
g_return_val_if_fail (text != NULL, -1);
private = (GdkFontPrivate*) font;
private = (GdkFontPrivateX*) font;
switch (font->type)
{
@ -423,113 +402,6 @@ gdk_text_width_wc (GdkFont *font,
return width;
}
/* Problem: What if a character is a 16 bits character ?? */
gint
gdk_char_width (GdkFont *font,
gchar character)
{
GdkFontPrivate *private;
XCharStruct *chars;
gint width;
guint ch = character & 0xff; /* get rid of sign-extension */
XFontStruct *xfont;
XFontSet fontset;
g_return_val_if_fail (font != NULL, -1);
private = (GdkFontPrivate*) font;
switch (font->type)
{
case GDK_FONT_FONT:
/* only 8 bits characters are considered here */
xfont = (XFontStruct *) private->xfont;
if ((xfont->min_byte1 == 0) &&
(xfont->max_byte1 == 0) &&
(ch >= xfont->min_char_or_byte2) &&
(ch <= xfont->max_char_or_byte2))
{
chars = xfont->per_char;
if (chars)
width = chars[ch - xfont->min_char_or_byte2].width;
else
width = xfont->min_bounds.width;
}
else
{
width = XTextWidth (xfont, &character, 1);
}
break;
case GDK_FONT_FONTSET:
fontset = (XFontSet) private->xfont;
width = XmbTextEscapement (fontset, &character, 1) ;
break;
default:
width = 0;
}
return width;
}
gint
gdk_char_width_wc (GdkFont *font,
GdkWChar character)
{
GdkFontPrivate *private;
XCharStruct *chars;
gint width;
guint ch = character & 0xff; /* get rid of sign-extension */
XFontStruct *xfont;
XFontSet fontset;
g_return_val_if_fail (font != NULL, -1);
private = (GdkFontPrivate*) font;
switch (font->type)
{
case GDK_FONT_FONT:
/* only 8 bits characters are considered here */
xfont = (XFontStruct *) private->xfont;
if ((xfont->min_byte1 == 0) &&
(xfont->max_byte1 == 0) &&
(ch >= xfont->min_char_or_byte2) &&
(ch <= xfont->max_char_or_byte2))
{
chars = xfont->per_char;
if (chars)
width = chars[ch - xfont->min_char_or_byte2].width;
else
width = xfont->min_bounds.width;
}
else
{
char ch2 = character;
width = XTextWidth (xfont, &ch2, 1);
}
break;
case GDK_FONT_FONTSET:
fontset = (XFontSet) private->xfont;
{
wchar_t char_wc = character;
width = XwcTextEscapement (fontset, &char_wc, 1) ;
}
break;
default:
width = 0;
}
return width;
}
gint
gdk_string_measure (GdkFont *font,
const gchar *string)
{
g_return_val_if_fail (font != NULL, -1);
g_return_val_if_fail (string != NULL, -1);
return gdk_text_measure (font, string, strlen (string));
}
void
gdk_text_extents (GdkFont *font,
const gchar *text,
@ -540,7 +412,7 @@ gdk_text_extents (GdkFont *font,
gint *ascent,
gint *descent)
{
GdkFontPrivate *private;
GdkFontPrivateX *private;
XCharStruct overall;
XFontStruct *xfont;
XFontSet fontset;
@ -552,7 +424,7 @@ gdk_text_extents (GdkFont *font,
g_return_if_fail (font != NULL);
g_return_if_fail (text != NULL);
private = (GdkFontPrivate*) font;
private = (GdkFontPrivateX*) font;
switch (font->type)
{
@ -609,7 +481,7 @@ gdk_text_extents_wc (GdkFont *font,
gint *ascent,
gint *descent)
{
GdkFontPrivate *private;
GdkFontPrivateX *private;
XCharStruct overall;
XFontStruct *xfont;
XFontSet fontset;
@ -621,7 +493,7 @@ gdk_text_extents_wc (GdkFont *font,
g_return_if_fail (font != NULL);
g_return_if_fail (text != NULL);
private = (GdkFontPrivate*) font;
private = (GdkFontPrivateX*) font;
switch (font->type)
{
@ -684,146 +556,3 @@ gdk_text_extents_wc (GdkFont *font,
}
}
void
gdk_string_extents (GdkFont *font,
const gchar *string,
gint *lbearing,
gint *rbearing,
gint *width,
gint *ascent,
gint *descent)
{
g_return_if_fail (font != NULL);
g_return_if_fail (string != NULL);
gdk_text_extents (font, string, strlen (string),
lbearing, rbearing, width, ascent, descent);
}
gint
gdk_text_measure (GdkFont *font,
const gchar *text,
gint text_length)
{
GdkFontPrivate *private;
XCharStruct overall;
XFontStruct *xfont;
XFontSet fontset;
XRectangle ink, log;
int direction;
int font_ascent;
int font_descent;
gint width;
g_return_val_if_fail (font != NULL, -1);
g_return_val_if_fail (text != NULL, -1);
private = (GdkFontPrivate*) font;
switch (font->type)
{
case GDK_FONT_FONT:
xfont = (XFontStruct *) private->xfont;
if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))
{
XTextExtents (xfont, text, text_length,
&direction, &font_ascent, &font_descent,
&overall);
}
else
{
XTextExtents16 (xfont, (XChar2b *) text, text_length / 2,
&direction, &font_ascent, &font_descent,
&overall);
}
width = overall.rbearing;
break;
case GDK_FONT_FONTSET:
fontset = (XFontSet) private->xfont;
XmbTextExtents (fontset, text, text_length, &ink, &log);
width = ink.x + ink.width;
break;
default:
width = 0;
}
return width;
}
gint
gdk_char_measure (GdkFont *font,
gchar character)
{
g_return_val_if_fail (font != NULL, -1);
return gdk_text_measure (font, &character, 1);
}
gint
gdk_string_height (GdkFont *font,
const gchar *string)
{
g_return_val_if_fail (font != NULL, -1);
g_return_val_if_fail (string != NULL, -1);
return gdk_text_height (font, string, strlen (string));
}
gint
gdk_text_height (GdkFont *font,
const gchar *text,
gint text_length)
{
GdkFontPrivate *private;
XCharStruct overall;
XFontStruct *xfont;
XFontSet fontset;
XRectangle ink, log;
int direction;
int font_ascent;
int font_descent;
gint height;
g_return_val_if_fail (font != NULL, -1);
g_return_val_if_fail (text != NULL, -1);
private = (GdkFontPrivate*) font;
switch (font->type)
{
case GDK_FONT_FONT:
xfont = (XFontStruct *) private->xfont;
if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))
{
XTextExtents (xfont, text, text_length,
&direction, &font_ascent, &font_descent,
&overall);
}
else
{
XTextExtents16 (xfont, (XChar2b *) text, text_length / 2,
&direction, &font_ascent, &font_descent,
&overall);
}
height = overall.ascent + overall.descent;
break;
case GDK_FONT_FONTSET:
fontset = (XFontSet) private->xfont;
XmbTextExtents (fontset, text, text_length, &ink, &log);
height = log.height;
break;
default:
height = 0;
}
return height;
}
gint
gdk_char_height (GdkFont *font,
gchar character)
{
g_return_val_if_fail (font != NULL, -1);
return gdk_text_height (font, &character, 1);
}

505
gdk/x11/gdkgc-x11.c Normal file
View File

@ -0,0 +1,505 @@
#include "gdkgc.h"
#include "gdkx.h"
static void gdk_x11_gc_values_to_xvalues (GdkGCValues *values,
GdkGCValuesMask mask,
XGCValues *xvalues,
unsigned long *xvalues_mask);
static void gdk_x11_gc_destroy (GdkGC *gc);
static void gdk_x11_gc_get_values (GdkGC *gc,
GdkGCValues *values);
static void gdk_x11_gc_set_values (GdkGC *gc,
GdkGCValues *values,
GdkGCValuesMask values_mask);
static void gdk_x11_gc_set_dashes (GdkGC *gc,
gint dash_offset,
gchar dash_list[],
gint n);
static GdkGCClass gdk_x11_gc_class = {
gdk_x11_gc_destroy,
gdk_x11_gc_get_values,
gdk_x11_gc_set_values,
gdk_x11_gc_set_dashes
};
GdkGC *
_gdk_x11_gc_new (GdkDrawable *drawable,
GdkGCValues *values,
GdkGCValuesMask values_mask)
{
GdkGC *gc;
GdkGCPrivate *private;
XGCValues xvalues;
unsigned long xvalues_mask;
gc = gdk_gc_alloc ();
private = (GdkGCPrivate *)gc;
private->klass = &gdk_x11_gc_class;
private->klass_data = g_new (GdkGCXData, 1);
GDK_GC_XDATA (gc)->xdisplay = GDK_DRAWABLE_XDISPLAY (drawable);
xvalues.function = GXcopy;
xvalues.fill_style = FillSolid;
xvalues.arc_mode = ArcPieSlice;
xvalues.subwindow_mode = ClipByChildren;
xvalues.graphics_exposures = True;
xvalues_mask = GCFunction | GCFillStyle | GCArcMode | GCSubwindowMode | GCGraphicsExposures;
gdk_x11_gc_values_to_xvalues (values, values_mask, &xvalues, &xvalues_mask);
GDK_GC_XDATA (gc)->xgc = XCreateGC (GDK_GC_XDISPLAY (gc),
GDK_DRAWABLE_XID (drawable),
xvalues_mask, &xvalues);
return gc;
}
static void
gdk_x11_gc_destroy (GdkGC *gc)
{
XFreeGC (GDK_GC_XDISPLAY (gc), GDK_GC_XGC (gc));
g_free (GDK_GC_XDATA (gc));
}
static void
gdk_x11_gc_get_values (GdkGC *gc,
GdkGCValues *values)
{
XGCValues xvalues;
if (XGetGCValues (GDK_GC_XDISPLAY (gc), GDK_GC_XGC (gc),
GCForeground | GCBackground | GCFont |
GCFunction | GCTile | GCStipple | /* GCClipMask | */
GCSubwindowMode | GCGraphicsExposures |
GCTileStipXOrigin | GCTileStipYOrigin |
GCClipXOrigin | GCClipYOrigin |
GCLineWidth | GCLineStyle | GCCapStyle |
GCFillStyle | GCJoinStyle, &xvalues))
{
values->foreground.pixel = xvalues.foreground;
values->background.pixel = xvalues.background;
values->font = gdk_font_lookup (xvalues.font);
switch (xvalues.function)
{
case GXcopy:
values->function = GDK_COPY;
break;
case GXinvert:
values->function = GDK_INVERT;
break;
case GXxor:
values->function = GDK_XOR;
break;
case GXclear:
values->function = GDK_CLEAR;
break;
case GXand:
values->function = GDK_AND;
break;
case GXandReverse:
values->function = GDK_AND_REVERSE;
break;
case GXandInverted:
values->function = GDK_AND_INVERT;
break;
case GXnoop:
values->function = GDK_NOOP;
break;
case GXor:
values->function = GDK_OR;
break;
case GXequiv:
values->function = GDK_EQUIV;
break;
case GXorReverse:
values->function = GDK_OR_REVERSE;
break;
case GXcopyInverted:
values->function =GDK_COPY_INVERT;
break;
case GXorInverted:
values->function = GDK_OR_INVERT;
break;
case GXnand:
values->function = GDK_NAND;
break;
case GXset:
values->function = GDK_SET;
break;
}
switch (xvalues.fill_style)
{
case FillSolid:
values->fill = GDK_SOLID;
break;
case FillTiled:
values->fill = GDK_TILED;
break;
case FillStippled:
values->fill = GDK_STIPPLED;
break;
case FillOpaqueStippled:
values->fill = GDK_OPAQUE_STIPPLED;
break;
}
values->tile = gdk_pixmap_lookup (xvalues.tile);
values->stipple = gdk_pixmap_lookup (xvalues.stipple);
values->clip_mask = NULL;
values->subwindow_mode = xvalues.subwindow_mode;
values->ts_x_origin = xvalues.ts_x_origin;
values->ts_y_origin = xvalues.ts_y_origin;
values->clip_x_origin = xvalues.clip_x_origin;
values->clip_y_origin = xvalues.clip_y_origin;
values->graphics_exposures = xvalues.graphics_exposures;
values->line_width = xvalues.line_width;
switch (xvalues.line_style)
{
case LineSolid:
values->line_style = GDK_LINE_SOLID;
break;
case LineOnOffDash:
values->line_style = GDK_LINE_ON_OFF_DASH;
break;
case LineDoubleDash:
values->line_style = GDK_LINE_DOUBLE_DASH;
break;
}
switch (xvalues.cap_style)
{
case CapNotLast:
values->cap_style = GDK_CAP_NOT_LAST;
break;
case CapButt:
values->cap_style = GDK_CAP_BUTT;
break;
case CapRound:
values->cap_style = GDK_CAP_ROUND;
break;
case CapProjecting:
values->cap_style = GDK_CAP_PROJECTING;
break;
}
switch (xvalues.join_style)
{
case JoinMiter:
values->join_style = GDK_JOIN_MITER;
break;
case JoinRound:
values->join_style = GDK_JOIN_ROUND;
break;
case JoinBevel:
values->join_style = GDK_JOIN_BEVEL;
break;
}
}
else
{
memset (values, 0, sizeof (GdkGCValues));
}
}
static void
gdk_x11_gc_set_values (GdkGC *gc,
GdkGCValues *values,
GdkGCValuesMask values_mask)
{
XGCValues xvalues;
unsigned long xvalues_mask = 0;
gdk_x11_gc_values_to_xvalues (values, values_mask, &xvalues, &xvalues_mask);
XChangeGC (GDK_GC_XDISPLAY (gc),
GDK_GC_XGC (gc),
xvalues_mask,
&xvalues);
}
static void
gdk_x11_gc_set_dashes (GdkGC *gc,
gint dash_offset,
gchar dash_list[],
gint n)
{
g_return_if_fail (gc != NULL);
g_return_if_fail (dash_list != NULL);
XSetDashes (GDK_GC_XDISPLAY (gc), GDK_GC_XGC (gc),
dash_offset, dash_list, n);
}
static void
gdk_x11_gc_values_to_xvalues (GdkGCValues *values,
GdkGCValuesMask mask,
XGCValues *xvalues,
unsigned long *xvalues_mask)
{
if (mask & GDK_GC_FOREGROUND)
{
xvalues->foreground = values->foreground.pixel;
*xvalues_mask |= GCForeground;
}
if (mask & GDK_GC_BACKGROUND)
{
xvalues->background = values->background.pixel;
*xvalues_mask |= GCBackground;
}
if ((mask & GDK_GC_FONT) && (values->font->type == GDK_FONT_FONT))
{
xvalues->font = ((XFontStruct *) (GDK_FONT_XFONT (values->font)))->fid;
*xvalues_mask |= GCFont;
}
if (mask & GDK_GC_FUNCTION)
{
switch (values->function)
{
case GDK_COPY:
xvalues->function = GXcopy;
break;
case GDK_INVERT:
xvalues->function = GXinvert;
break;
case GDK_XOR:
xvalues->function = GXxor;
break;
case GDK_CLEAR:
xvalues->function = GXclear;
break;
case GDK_AND:
xvalues->function = GXand;
break;
case GDK_AND_REVERSE:
xvalues->function = GXandReverse;
break;
case GDK_AND_INVERT:
xvalues->function = GXandInverted;
break;
case GDK_NOOP:
xvalues->function = GXnoop;
break;
case GDK_OR:
xvalues->function = GXor;
break;
case GDK_EQUIV:
xvalues->function = GXequiv;
break;
case GDK_OR_REVERSE:
xvalues->function = GXorReverse;
break;
case GDK_COPY_INVERT:
xvalues->function = GXcopyInverted;
break;
case GDK_OR_INVERT:
xvalues->function = GXorInverted;
break;
case GDK_NAND:
xvalues->function = GXnand;
break;
case GDK_SET:
xvalues->function = GXset;
break;
}
*xvalues_mask |= GCFunction;
}
if (mask & GDK_GC_FILL)
{
switch (values->fill)
{
case GDK_SOLID:
xvalues->fill_style = FillSolid;
break;
case GDK_TILED:
xvalues->fill_style = FillTiled;
break;
case GDK_STIPPLED:
xvalues->fill_style = FillStippled;
break;
case GDK_OPAQUE_STIPPLED:
xvalues->fill_style = FillOpaqueStippled;
break;
}
*xvalues_mask |= GCFillStyle;
}
if (mask & GDK_GC_TILE)
{
if (values->tile)
xvalues->tile = GDK_DRAWABLE_XID (values->tile);
else
xvalues->tile = None;
*xvalues_mask |= GCTile;
}
if (mask & GDK_GC_STIPPLE)
{
if (values->stipple)
xvalues->stipple = GDK_DRAWABLE_XID (values->stipple);
else
xvalues->stipple = None;
*xvalues_mask |= GCStipple;
}
if (mask & GDK_GC_CLIP_MASK)
{
if (values->clip_mask)
xvalues->clip_mask = GDK_DRAWABLE_XID (values->clip_mask);
else
xvalues->clip_mask = None;
*xvalues_mask |= GCClipMask;
}
if (mask & GDK_GC_SUBWINDOW)
{
xvalues->subwindow_mode = values->subwindow_mode;
*xvalues_mask |= GCSubwindowMode;
}
if (mask & GDK_GC_TS_X_ORIGIN)
{
xvalues->ts_x_origin = values->ts_x_origin;
*xvalues_mask |= GCTileStipXOrigin;
}
if (mask & GDK_GC_TS_Y_ORIGIN)
{
xvalues->ts_y_origin = values->ts_y_origin;
*xvalues_mask |= GCTileStipYOrigin;
}
if (mask & GDK_GC_CLIP_X_ORIGIN)
{
xvalues->clip_x_origin = values->clip_x_origin;
*xvalues_mask |= GCClipXOrigin;
}
if (mask & GDK_GC_CLIP_Y_ORIGIN)
{
xvalues->clip_y_origin = values->clip_y_origin;
*xvalues_mask |= GCClipYOrigin;
}
if (mask & GDK_GC_EXPOSURES)
xvalues->graphics_exposures = values->graphics_exposures;
else
xvalues->graphics_exposures = False;
*xvalues_mask |= GCGraphicsExposures;
if (mask & GDK_GC_LINE_WIDTH)
{
xvalues->line_width = values->line_width;
*xvalues_mask |= GCLineWidth;
}
if (mask & GDK_GC_LINE_STYLE)
{
switch (values->line_style)
{
case GDK_LINE_SOLID:
xvalues->line_style = LineSolid;
break;
case GDK_LINE_ON_OFF_DASH:
xvalues->line_style = LineOnOffDash;
break;
case GDK_LINE_DOUBLE_DASH:
xvalues->line_style = LineDoubleDash;
break;
}
*xvalues_mask |= GCLineStyle;
}
if (mask & GDK_GC_CAP_STYLE)
{
switch (values->cap_style)
{
case GDK_CAP_NOT_LAST:
xvalues->cap_style = CapNotLast;
break;
case GDK_CAP_BUTT:
xvalues->cap_style = CapButt;
break;
case GDK_CAP_ROUND:
xvalues->cap_style = CapRound;
break;
case GDK_CAP_PROJECTING:
xvalues->cap_style = CapProjecting;
break;
}
*xvalues_mask |= GCCapStyle;
}
if (mask & GDK_GC_JOIN_STYLE)
{
switch (values->join_style)
{
case GDK_JOIN_MITER:
xvalues->join_style = JoinMiter;
break;
case GDK_JOIN_ROUND:
xvalues->join_style = JoinRound;
break;
case GDK_JOIN_BEVEL:
xvalues->join_style = JoinBevel;
break;
}
*xvalues_mask |= GCJoinStyle;
}
}
void
gdk_gc_set_clip_rectangle (GdkGC *gc,
GdkRectangle *rectangle)
{
XRectangle xrectangle;
g_return_if_fail (gc != NULL);
if (rectangle)
{
xrectangle.x = rectangle->x;
xrectangle.y = rectangle->y;
xrectangle.width = rectangle->width;
xrectangle.height = rectangle->height;
XSetClipRectangles (GDK_GC_XDISPLAY (gc), GDK_GC_XGC (gc), 0, 0,
&xrectangle, 1, Unsorted);
}
else
XSetClipMask (GDK_GC_XDISPLAY (gc), GDK_GC_XGC (gc), None);
}
void
gdk_gc_set_clip_region (GdkGC *gc,
GdkRegion *region)
{
GdkGCPrivate *private;
g_return_if_fail (gc != NULL);
private = (GdkGCPrivate*) gc;
if (region)
{
GdkRegionPrivate *region_private;
region_private = (GdkRegionPrivate*) region;
XSetRegion (GDK_GC_XDISPLAY (gc), GDK_GC_XGC (gc), region_private->xregion);
}
else
XSetClipMask (GDK_GC_XDISPLAY (gc), GDK_GC_XGC (gc), None);
}
void
gdk_gc_copy (GdkGC *dst_gc, GdkGC *src_gc)
{
g_return_if_fail (dst_gc != NULL);
g_return_if_fail (src_gc != NULL);
XCopyGC (GDK_GC_XDISPLAY (src_gc), GDK_GC_XGC (src_gc), ~((~1) << GCLastBit),
GDK_GC_XGC (dst_gc));
}

View File

@ -25,42 +25,24 @@
*/
#include <stdio.h>
#include <X11/Xlib.h>
#include "gdktypes.h"
#include "gdkprivate.h"
#include "gdkprivate-x11.h"
#include "config.h"
guint gdk_debug_flags = 0;
gint gdk_use_xshm = TRUE;
gboolean gdk_use_xshm = TRUE;
gchar *gdk_display_name = NULL;
Display *gdk_display = NULL;
gint gdk_screen;
Window gdk_root_window;
Window gdk_leader_window;
GdkWindowPrivate gdk_root_parent = { { NULL, }, NULL, };
Atom gdk_wm_delete_window;
Atom gdk_wm_take_focus;
Atom gdk_wm_protocols;
Atom gdk_wm_window_protocols[2];
Atom gdk_selection_property;
GdkDndCursorInfo gdk_dnd_cursorinfo = {None, None, NULL, NULL,
{0,0}, {0,0}, NULL};
GdkDndGlobals gdk_dnd = {None,None,None,
None,None,None,
None,
&gdk_dnd_cursorinfo,
NULL,
0,
FALSE, FALSE, FALSE,
None,
{0,0},
{0,0}, {0,0},
{0,0,0,0}, NULL, None, 0};
gchar *gdk_progclass = NULL;
gint gdk_error_code = 0;
gint gdk_error_warnings = TRUE;
gint gdk_null_window_warnings = TRUE;
GList *gdk_default_filters = NULL;
gboolean gdk_null_window_warnings = TRUE;
gboolean gdk_xim_using; /* using XIM Protocol if TRUE */
#ifdef USE_XIM
@ -71,11 +53,3 @@ GdkWindow *gdk_xim_window; /* currently using Widow */
GdkWindowPrivate *gdk_xgrab_window = NULL; /* Window that currently holds the
* x pointer grab
*/
GMutex *gdk_threads_mutex = NULL; /* Global GDK lock */
#ifdef USE_XIM
GdkICPrivate *gdk_xim_ic; /* currently using IC */
GdkWindow *gdk_xim_window; /* currently using Window */
#endif

View File

@ -58,19 +58,19 @@
#include "gdkprivate.h"
#include "gdkx.h"
static void gdk_image_put_normal (GdkDrawable *drawable,
static void gdk_x11_image_destroy (GdkImage *image);
static void gdk_image_put_normal (GdkImage *image,
GdkDrawable *drawable,
GdkGC *gc,
GdkImage *image,
gint xsrc,
gint ysrc,
gint xdest,
gint ydest,
gint width,
gint height);
static void gdk_image_put_shared (GdkDrawable *drawable,
static void gdk_image_put_shared (GdkImage *image,
GdkDrawable *drawable,
GdkGC *gc,
GdkImage *image,
gint xsrc,
gint ysrc,
gint xdest,
@ -78,6 +78,15 @@ static void gdk_image_put_shared (GdkDrawable *drawable,
gint width,
gint height);
static GdkImageClass image_class_normal = {
gdk_x11_image_destroy,
gdk_image_put_normal
};
static GdkImageClass image_class_shared = {
gdk_x11_image_destroy,
gdk_image_put_shared
};
static GList *image_list = NULL;
@ -90,7 +99,7 @@ gdk_image_exit (void)
while (image_list)
{
image = image_list->data;
gdk_image_destroy (image);
gdk_x11_image_destroy (image);
}
}
@ -102,11 +111,12 @@ gdk_image_new_bitmap(GdkVisual *visual, gpointer data, gint w, gint h)
{
Visual *xvisual;
GdkImage *image;
GdkImagePrivate *private;
private = g_new(GdkImagePrivate, 1);
GdkImagePrivateX *private;
private = g_new(GdkImagePrivateX, 1);
image = (GdkImage *) private;
private->xdisplay = gdk_display;
private->image_put = gdk_image_put_normal;
private->base.ref_count = 1;
private->base.klass = &image_class_normal;
image->type = GDK_IMAGE_NORMAL;
image->visual = visual;
image->width = w;
@ -168,7 +178,7 @@ gdk_image_new (GdkImageType type,
gint height)
{
GdkImage *image;
GdkImagePrivate *private;
GdkImagePrivateX *private;
#ifdef USE_SHM
XShmSegmentInfo *x_shm_info;
#endif /* USE_SHM */
@ -184,11 +194,11 @@ gdk_image_new (GdkImageType type,
break;
default:
private = g_new (GdkImagePrivate, 1);
private = g_new (GdkImagePrivateX, 1);
image = (GdkImage*) private;
private->base.ref_count = 1;
private->xdisplay = gdk_display;
private->image_put = NULL;
image->type = type;
image->visual = visual;
@ -204,7 +214,7 @@ gdk_image_new (GdkImageType type,
#ifdef USE_SHM
if (gdk_use_xshm)
{
private->image_put = gdk_image_put_shared;
private->base.klass = &image_class_shared;
private->x_shm_info = g_new (XShmSegmentInfo, 1);
x_shm_info = private->x_shm_info;
@ -295,7 +305,7 @@ gdk_image_new (GdkImageType type,
return NULL;
#endif /* USE_SHM */
case GDK_IMAGE_NORMAL:
private->image_put = gdk_image_put_normal;
private->base.klass = &image_class_normal;
private->ximage = XCreateImage (private->xdisplay, xvisual, visual->depth,
ZPixmap, 0, 0, width, height, 32, 0);
@ -308,6 +318,7 @@ gdk_image_new (GdkImageType type,
break;
case GDK_IMAGE_FASTEST:
case GDK_IMAGE_SHARED_PIXMAP:
g_assert_not_reached ();
}
@ -331,18 +342,19 @@ gdk_image_get (GdkWindow *window,
gint height)
{
GdkImage *image;
GdkImagePrivate *private;
GdkImagePrivateX *private;
g_return_val_if_fail (window != NULL, NULL);
if (GDK_DRAWABLE_DESTROYED (window))
return NULL;
private = g_new (GdkImagePrivate, 1);
private = g_new (GdkImagePrivateX, 1);
image = (GdkImage*) private;
private->base.ref_count = 1;
private->base.klass = &image_class_normal;
private->xdisplay = gdk_display;
private->image_put = gdk_image_put_normal;
private->ximage = XGetImage (private->xdisplay,
GDK_DRAWABLE_XID (window),
x, y, width, height,
@ -375,11 +387,11 @@ gdk_image_get_pixel (GdkImage *image,
gint y)
{
guint32 pixel;
GdkImagePrivate *private;
GdkImagePrivateX *private;
g_return_val_if_fail (image != NULL, 0);
private = (GdkImagePrivate *) image;
private = (GdkImagePrivateX *) image;
pixel = XGetPixel (private->ximage, x, y);
@ -392,26 +404,26 @@ gdk_image_put_pixel (GdkImage *image,
gint y,
guint32 pixel)
{
GdkImagePrivate *private;
GdkImagePrivateX *private;
g_return_if_fail (image != NULL);
private = (GdkImagePrivate *) image;
private = (GdkImagePrivateX *) image;
pixel = XPutPixel (private->ximage, x, y, pixel);
}
void
gdk_image_destroy (GdkImage *image)
static void
gdk_x11_image_destroy (GdkImage *image)
{
GdkImagePrivate *private;
GdkImagePrivateX *private;
#ifdef USE_SHM
XShmSegmentInfo *x_shm_info;
#endif /* USE_SHM */
g_return_if_fail (image != NULL);
private = (GdkImagePrivate*) image;
private = (GdkImagePrivateX*) image;
switch (image->type)
{
case GDK_IMAGE_NORMAL:
@ -437,6 +449,7 @@ gdk_image_destroy (GdkImage *image)
break;
case GDK_IMAGE_FASTEST:
case GDK_IMAGE_SHARED_PIXMAP:
g_assert_not_reached ();
}
@ -444,9 +457,9 @@ gdk_image_destroy (GdkImage *image)
}
static void
gdk_image_put_normal (GdkDrawable *drawable,
gdk_image_put_normal (GdkImage *image,
GdkDrawable *drawable,
GdkGC *gc,
GdkImage *image,
gint xsrc,
gint ysrc,
gint xdest,
@ -454,8 +467,7 @@ gdk_image_put_normal (GdkDrawable *drawable,
gint width,
gint height)
{
GdkImagePrivate *image_private;
GdkGCPrivate *gc_private;
GdkImagePrivateX *image_private;
g_return_if_fail (drawable != NULL);
g_return_if_fail (image != NULL);
@ -463,20 +475,19 @@ gdk_image_put_normal (GdkDrawable *drawable,
if (GDK_DRAWABLE_DESTROYED (drawable))
return;
image_private = (GdkImagePrivate*) image;
gc_private = (GdkGCPrivate*) gc;
image_private = (GdkImagePrivateX*) image;
g_return_if_fail (image->type == GDK_IMAGE_NORMAL);
XPutImage (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
gc_private->xgc, image_private->ximage,
GDK_GC_XGC (gc), image_private->ximage,
xsrc, ysrc, xdest, ydest, width, height);
}
static void
gdk_image_put_shared (GdkDrawable *drawable,
gdk_image_put_shared (GdkImage *image,
GdkDrawable *drawable,
GdkGC *gc,
GdkImage *image,
gint xsrc,
gint ysrc,
gint xdest,
@ -485,8 +496,7 @@ gdk_image_put_shared (GdkDrawable *drawable,
gint height)
{
#ifdef USE_SHM
GdkImagePrivate *image_private;
GdkGCPrivate *gc_private;
GdkImagePrivateX *image_private;
g_return_if_fail (drawable != NULL);
g_return_if_fail (image != NULL);
@ -494,13 +504,12 @@ gdk_image_put_shared (GdkDrawable *drawable,
if (GDK_DRAWABLE_DESTROYED (drawable))
return;
image_private = (GdkImagePrivate*) image;
gc_private = (GdkGCPrivate*) gc;
image_private = (GdkImagePrivateX*) image;
g_return_if_fail (image->type == GDK_IMAGE_SHARED);
XShmPutImage (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
gc_private->xgc, image_private->ximage,
GDK_GC_XGC (gc), image_private->ximage,
xsrc, ysrc, xdest, ydest, width, height, False);
#else /* USE_SHM */
g_error ("trying to draw shared memory image when gdk was compiled without shared memory support");

View File

@ -24,8 +24,6 @@
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#ifdef XINPUT_GXI
/* #define DEBUG_SWITCHING */
#include <gxid_lib.h>
@ -645,5 +643,3 @@ gdk_input_gxi_ungrab_pointer (guint32 time)
tmp_list = tmp_list->next;
}
}
#endif /* XINPUT_GXI */

View File

@ -24,8 +24,6 @@
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#ifdef XINPUT_NONE
static void gdk_input_none_get_pointer (GdkWindow *window,
guint32 deviceid,
gdouble *x,
@ -77,5 +75,3 @@ gdk_input_none_get_pointer (GdkWindow *window,
if (xtilt) *xtilt = 0;
if (ytilt) *ytilt = 0;
}
#endif /* XINPUT_NONE */

View File

@ -24,22 +24,12 @@
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#if defined(XINPUT_GXI) || defined(XINPUT_XFREE)
#include "gdkinputprivate.h"
#include "gdkx.h"
/* Forward declarations */
static void gdk_input_get_root_relative_geometry (Display *dpy, Window w,
int *x_ret, int *y_ret,
int *width_ret,
int *height_ret);
static GdkDevicePrivate *gdk_input_device_new(XDeviceInfo *device,
gint include_core);
static void gdk_input_common_find_events(GdkWindow *window,
GdkDevicePrivate *gdkdev,
gint mask,
XEventClass *classes,
int *num_classes);
static void gdk_input_common_select_events(GdkWindow *window,
GdkDevicePrivate *gdkdev);
static void gdk_input_translate_coordinates(GdkDevicePrivate *gdkdev,
GdkInputWindow *input_window,
gint *axis_data,
@ -47,18 +37,7 @@ static void gdk_input_translate_coordinates(GdkDevicePrivate *gdkdev,
gdouble *pressure,
gdouble *xtilt, gdouble *ytilt);
static guint gdk_input_translate_state(guint state, guint device_state);
static gint gdk_input_common_init(gint include_core);
static gint gdk_input_common_other_event (GdkEvent *event,
XEvent *xevent,
GdkInputWindow *input_window,
GdkDevicePrivate *gdkdev);
static void gdk_input_common_set_axes (guint32 deviceid, GdkAxisUse *axes);
static GdkTimeCoord * gdk_input_common_motion_events (GdkWindow *window,
guint32 deviceid,
guint32 start,
guint32 stop,
gint *nevents_return);
static void gdk_input_common_get_pointer (GdkWindow *window,
void gdk_input_common_get_pointer (GdkWindow *window,
guint32 deviceid,
gdouble *x,
gdouble *y,
@ -67,14 +46,12 @@ static void gdk_input_common_get_pointer (GdkWindow *window,
gdouble *ytilt,
GdkModifierType *mask);
#define GDK_MAX_DEVICE_CLASSES 13
/* Global variables */
static gint gdk_input_root_width;
static gint gdk_input_root_height;
static void
void
gdk_input_get_root_relative_geometry(Display *dpy, Window w, int *x_ret, int *y_ret,
int *width_ret, int *height_ret)
{
@ -301,7 +278,7 @@ gdk_input_device_new(XDeviceInfo *device, gint include_core)
return gdkdev;
}
static void
void
gdk_input_common_find_events(GdkWindow *window,
GdkDevicePrivate *gdkdev,
gint mask,
@ -403,7 +380,7 @@ gdk_input_common_find_events(GdkWindow *window,
*num_classes = i;
}
static void
void
gdk_input_common_select_events(GdkWindow *window,
GdkDevicePrivate *gdkdev)
{
@ -460,7 +437,7 @@ gdk_input_common_init(gint include_core)
XFreeDeviceList(devices);
}
gdk_input_devices = g_list_append (gdk_input_devices, &gdk_input_core_info);
gdk_input_devices = g_list_append (gdk_input_devices, (gpointer)&gdk_input_core_info);
return TRUE;
}
@ -581,7 +558,8 @@ gdk_input_translate_state(guint state, guint device_state)
return device_state | (state & 0xFF);
}
static gint
gint
gdk_input_common_other_event (GdkEvent *event,
XEvent *xevent,
GdkInputWindow *input_window,
@ -736,7 +714,7 @@ gdk_input_common_other_event (GdkEvent *event,
return -1; /* wasn't one of our event types */
}
static void
void
gdk_input_common_set_axes (guint32 deviceid, GdkAxisUse *axes)
{
int i;
@ -755,7 +733,8 @@ gdk_input_common_set_axes (guint32 deviceid, GdkAxisUse *axes)
}
}
void gdk_input_common_set_key (guint32 deviceid,
void
gdk_input_common_set_key (guint32 deviceid,
guint index,
guint keyval,
GdkModifierType modifiers)
@ -770,7 +749,7 @@ void gdk_input_common_set_key (guint32 deviceid,
gdkdev->info.keys[index].modifiers = modifiers;
}
static GdkTimeCoord *
GdkTimeCoord *
gdk_input_common_motion_events (GdkWindow *window,
guint32 deviceid,
guint32 start,
@ -819,7 +798,7 @@ gdk_input_common_motion_events (GdkWindow *window,
return NULL;
}
static void
void
gdk_input_common_get_pointer (GdkWindow *window,
guint32 deviceid,
gdouble *x,
@ -888,5 +867,3 @@ gdk_input_common_get_pointer (GdkWindow *window,
}
}
}
#endif

View File

@ -17,6 +17,9 @@
* Boston, MA 02111-1307, USA.
*/
#include "gdkinputprivate.h"
#include "gdkx.h"
/*
* 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
@ -24,8 +27,6 @@
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#ifdef XINPUT_XFREE
/* forward declarations */
static gint gdk_input_xfree_set_mode (guint32 deviceid, GdkInputMode mode);
@ -370,5 +371,3 @@ gdk_input_xfree_ungrab_pointer (guint32 time)
}
}
}
#endif /* XINPUT_XFREE */

View File

@ -34,21 +34,9 @@
#include "gdkprivate.h"
#include "gdkinputprivate.h"
/* Forward declarations */
static gint gdk_input_enable_window (GdkWindow *window,
GdkDevicePrivate *gdkdev);
static gint gdk_input_disable_window (GdkWindow *window,
GdkDevicePrivate *gdkdev);
static GdkInputWindow *gdk_input_window_find (GdkWindow *window);
static GdkDevicePrivate *gdk_input_find_device (guint32 id);
/* Incorporate the specific routines depending on compilation options */
static const GdkAxisUse gdk_input_core_axes[] = { GDK_AXIS_X, GDK_AXIS_Y };
static const GdkDeviceInfo gdk_input_core_info =
const GdkDeviceInfo gdk_input_core_info =
{
GDK_CORE_POINTER,
"Core Pointer",
@ -67,15 +55,8 @@ gchar *gdk_input_gxid_host;
gint gdk_input_gxid_port;
gint gdk_input_ignore_core;
/* Local variables */
static GList *gdk_input_devices;
static GList *gdk_input_windows;
#include "gdkinputnone.h"
#include "gdkinputcommon.h"
#include "gdkinputxfree.h"
#include "gdkinputgxi.h"
GList *gdk_input_devices;
GList *gdk_input_windows;
GList *
gdk_input_list_devices (void)
@ -178,7 +159,7 @@ gdk_input_motion_events (GdkWindow *window,
}
}
static gint
gint
gdk_input_enable_window (GdkWindow *window, GdkDevicePrivate *gdkdev)
{
if (gdk_input_vtable.enable_window)
@ -187,7 +168,7 @@ gdk_input_enable_window (GdkWindow *window, GdkDevicePrivate *gdkdev)
return TRUE;
}
static gint
gint
gdk_input_disable_window (GdkWindow *window, GdkDevicePrivate *gdkdev)
{
if (gdk_input_vtable.disable_window)
@ -197,7 +178,7 @@ gdk_input_disable_window (GdkWindow *window, GdkDevicePrivate *gdkdev)
}
static GdkInputWindow *
GdkInputWindow *
gdk_input_window_find(GdkWindow *window)
{
GList *tmp_list;
@ -324,7 +305,7 @@ gdk_input_exit (void)
g_list_free(gdk_input_windows);
}
static GdkDevicePrivate *
GdkDevicePrivate *
gdk_input_find_device(guint32 id)
{
GList *tmp_list = gdk_input_devices;

View File

@ -27,6 +27,10 @@
#ifndef __GDK_INPUTPRIVATE_H__
#define __GDK_INPUTPRIVATE_H__
#include "config.h"
#include "gdkinput.h"
#include "gdkevents.h"
#ifndef XINPUT_NONE
#include <X11/extensions/XInput.h>
#endif
@ -147,6 +151,10 @@ struct _GdkInputWindow
/* Global data */
extern const GdkDeviceInfo gdk_input_core_info;
extern GList *gdk_input_devices;
extern GList *gdk_input_windows;
extern GdkInputVTable gdk_input_vtable;
/* information about network port and host for gxid daemon */
extern gchar *gdk_input_gxid_host;
@ -155,8 +163,63 @@ extern gint gdk_input_ignore_core;
/* Function declarations */
GdkDevicePrivate * gdk_input_find_device (guint32 id);
GdkInputWindow * gdk_input_window_find (GdkWindow *window);
void gdk_input_window_destroy (GdkWindow *window);
void gdk_input_init (void);
void gdk_input_exit (void);
gint gdk_input_enable_window (GdkWindow *window,
GdkDevicePrivate *gdkdev);
gint gdk_input_disable_window (GdkWindow *window,
GdkDevicePrivate *gdkdev);
#ifndef XINPUT_NONE
#define GDK_MAX_DEVICE_CLASSES 13
gint gdk_input_common_init (gint include_core);
void gdk_input_get_root_relative_geometry (Display *dpy,
Window w,
int *x_ret,
int *y_ret,
int *width_ret,
int *height_ret);
void gdk_input_common_find_events (GdkWindow *window,
GdkDevicePrivate *gdkdev,
gint mask,
XEventClass *classes,
int *num_classes);
void gdk_input_common_select_events (GdkWindow *window,
GdkDevicePrivate *gdkdev);
gint gdk_input_common_other_event (GdkEvent *event,
XEvent *xevent,
GdkInputWindow *input_window,
GdkDevicePrivate *gdkdev);
void gdk_input_common_get_pointer (GdkWindow *window,
guint32 deviceid,
gdouble *x,
gdouble *y,
gdouble *pressure,
gdouble *xtilt,
gdouble *ytilt,
GdkModifierType *mask);
void gdk_input_common_set_key (guint32 deviceid,
guint index,
guint keyval,
GdkModifierType modifiers);
void gdk_input_common_set_axes (guint32 deviceid,
GdkAxisUse *axes);
GdkTimeCoord * gdk_input_common_motion_events (GdkWindow *window,
guint32 deviceid,
guint32 start,
guint32 stop,
gint *nevents_return);
#endif /* !XINPUT_NONE */
GdkDevicePrivate *gdk_input_find_device (guint32 id);
GdkInputWindow *gdk_input_window_find (GdkWindow *window);
void gdk_input_window_destroy (GdkWindow *window);
void gdk_input_exit (void);
#endif /* __GDK_INPUTPRIVATE_H__ */

View File

@ -77,15 +77,10 @@ static void gdkx_XConvertCase (KeySym symbol,
#define XConvertCase gdkx_XConvertCase
#endif
static void gdk_exit_func (void);
static int gdk_x_error (Display *display,
XErrorEvent *error);
static int gdk_x_io_error (Display *display);
GdkFilterReturn gdk_wm_protocols_filter (GdkXEvent *xev,
GdkEvent *event,
gpointer data);
/* Private variable declarations
*/
static int gdk_initialized = 0; /* 1 if the library is initialized,
@ -93,9 +88,7 @@ static int gdk_initialized = 0; /* 1 if the library is initialized,
*/
static gint autorepeat;
static GSList *gdk_error_traps = NULL; /* List of error traps */
static GSList *gdk_error_trap_free_list = NULL; /* Free list */
static gboolean gdk_synchronize = FALSE;
#ifdef G_ENABLE_DEBUG
static const GDebugKey gdk_debug_keys[] = {
@ -110,258 +103,60 @@ static const int gdk_ndebug_keys = sizeof(gdk_debug_keys)/sizeof(GDebugKey);
#endif /* G_ENABLE_DEBUG */
/*
*--------------------------------------------------------------
* gdk_init_heck
*
* Initialize the library for use.
*
* Arguments:
* "argc" is the number of arguments.
* "argv" is an array of strings.
*
* Results:
* "argc" and "argv" are modified to reflect any arguments
* which were not handled. (Such arguments should either
* be handled by the application or dismissed). If initialization
* fails, returns FALSE, otherwise TRUE.
*
* Side effects:
* The library is initialized.
*
*--------------------------------------------------------------
*/
gboolean
gdk_init_check (int *argc,
char ***argv)
static void
gdk_arg_xim_preedit_cb (const gchar *arg, const gchar *value, gpointer cb_data)
{
XKeyboardState keyboard_state;
gint synchronize;
gint i, j, k;
XClassHint *class_hint;
gchar **argv_orig = NULL;
gint argc_orig = 0;
if (gdk_initialized)
return TRUE;
if (g_thread_supported ())
gdk_threads_mutex = g_mutex_new ();
if (argc && argv)
{
argc_orig = *argc;
argv_orig = g_malloc ((argc_orig + 1) * sizeof (char*));
for (i = 0; i < argc_orig; i++)
argv_orig[i] = g_strdup ((*argv)[i]);
argv_orig[argc_orig] = NULL;
if (strcmp ("none", value) == 0)
gdk_im_set_best_style (GDK_IM_PREEDIT_NONE);
else if (strcmp ("nothing", value) == 0)
gdk_im_set_best_style (GDK_IM_PREEDIT_NOTHING);
else if (strcmp ("area", value) == 0)
gdk_im_set_best_style (GDK_IM_PREEDIT_AREA);
else if (strcmp ("position", value) == 0)
gdk_im_set_best_style (GDK_IM_PREEDIT_POSITION);
else if (strcmp ("callbacks", value) == 0)
gdk_im_set_best_style (GDK_IM_PREEDIT_CALLBACKS);
}
gdk_display_name = NULL;
static void
gdk_arg_xim_status_cb (const gchar *arg, const gchar *value, gpointer cb_data)
{
if (strcmp ("none", value) == 0)
gdk_im_set_best_style (GDK_IM_STATUS_NONE);
else if (strcmp ("nothing", value) == 0)
gdk_im_set_best_style (GDK_IM_STATUS_NOTHING);
else if (strcmp ("area", value) == 0)
gdk_im_set_best_style (GDK_IM_STATUS_AREA);
else if (strcmp ("callbacks", value) == 0)
gdk_im_set_best_style (GDK_IM_STATUS_CALLBACKS);
}
GdkArgDesc _gdk_windowing_args[] = {
{ "display", GDK_ARG_STRING, &gdk_display_name, (GdkArgFunc)NULL },
{ "sync", GDK_ARG_BOOL, &gdk_synchronize, (GdkArgFunc)NULL },
{ "no-xshm", GDK_ARG_NOBOOL, &gdk_use_xshm, (GdkArgFunc)NULL },
{ "class", GDK_ARG_STRING, &gdk_progclass, (GdkArgFunc)NULL },
{ "gxid-host", GDK_ARG_STRING, &gdk_input_gxid_host, (GdkArgFunc)NULL },
{ "gxid-port", GDK_ARG_INT, &gdk_input_gxid_port, (GdkArgFunc)NULL },
{ "xim-preedit", GDK_ARG_CALLBACK, NULL, gdk_arg_xim_preedit_cb },
{ "xim-status", GDK_ARG_CALLBACK, NULL, gdk_arg_xim_status_cb },
{ NULL }
};
gboolean
_gdk_windowing_init_check (int argc, char **argv)
{
XKeyboardState keyboard_state;
XClassHint *class_hint;
XSetErrorHandler (gdk_x_error);
XSetIOErrorHandler (gdk_x_io_error);
synchronize = FALSE;
#ifdef G_ENABLE_DEBUG
{
gchar *debug_string = getenv("GDK_DEBUG");
if (debug_string != NULL)
gdk_debug_flags = g_parse_debug_string (debug_string,
(GDebugKey *) gdk_debug_keys,
gdk_ndebug_keys);
}
#endif /* G_ENABLE_DEBUG */
if (argc && argv)
{
if (*argc > 0)
{
gchar *d;
d = strrchr((*argv)[0],'/');
if (d != NULL)
g_set_prgname (d + 1);
else
g_set_prgname ((*argv)[0]);
}
for (i = 1; i < *argc;)
{
#ifdef G_ENABLE_DEBUG
if ((strcmp ("--gdk-debug", (*argv)[i]) == 0) ||
(strncmp ("--gdk-debug=", (*argv)[i], 12) == 0))
{
gchar *equal_pos = strchr ((*argv)[i], '=');
if (equal_pos != NULL)
{
gdk_debug_flags |= g_parse_debug_string (equal_pos+1,
(GDebugKey *) gdk_debug_keys,
gdk_ndebug_keys);
}
else if ((i + 1) < *argc && (*argv)[i + 1])
{
gdk_debug_flags |= g_parse_debug_string ((*argv)[i+1],
(GDebugKey *) gdk_debug_keys,
gdk_ndebug_keys);
(*argv)[i] = NULL;
i += 1;
}
(*argv)[i] = NULL;
}
else if ((strcmp ("--gdk-no-debug", (*argv)[i]) == 0) ||
(strncmp ("--gdk-no-debug=", (*argv)[i], 15) == 0))
{
gchar *equal_pos = strchr ((*argv)[i], '=');
if (equal_pos != NULL)
{
gdk_debug_flags &= ~g_parse_debug_string (equal_pos+1,
(GDebugKey *) gdk_debug_keys,
gdk_ndebug_keys);
}
else if ((i + 1) < *argc && (*argv)[i + 1])
{
gdk_debug_flags &= ~g_parse_debug_string ((*argv)[i+1],
(GDebugKey *) gdk_debug_keys,
gdk_ndebug_keys);
(*argv)[i] = NULL;
i += 1;
}
(*argv)[i] = NULL;
}
else
#endif /* G_ENABLE_DEBUG */
if (strcmp ("--display", (*argv)[i]) == 0)
{
(*argv)[i] = NULL;
if ((i + 1) < *argc && (*argv)[i + 1])
{
gdk_display_name = g_strdup ((*argv)[i + 1]);
(*argv)[i + 1] = NULL;
i += 1;
}
}
else if (strcmp ("--sync", (*argv)[i]) == 0)
{
(*argv)[i] = NULL;
synchronize = TRUE;
}
else if (strcmp ("--no-xshm", (*argv)[i]) == 0)
{
(*argv)[i] = NULL;
gdk_use_xshm = FALSE;
}
else if (strcmp ("--name", (*argv)[i]) == 0)
{
if ((i + 1) < *argc && (*argv)[i + 1])
{
(*argv)[i++] = NULL;
g_set_prgname ((*argv)[i]);
(*argv)[i] = NULL;
}
}
else if (strcmp ("--class", (*argv)[i]) == 0)
{
if ((i + 1) < *argc && (*argv)[i + 1])
{
(*argv)[i++] = NULL;
gdk_progclass = (*argv)[i];
(*argv)[i] = NULL;
}
}
#ifdef XINPUT_GXI
else if (strcmp ("--gxid_host", (*argv)[i]) == 0)
{
if ((i + 1) < *argc && (*argv)[i + 1])
{
(*argv)[i++] = NULL;
gdk_input_gxid_host = ((*argv)[i]);
(*argv)[i] = NULL;
}
}
else if (strcmp ("--gxid_port", (*argv)[i]) == 0)
{
if ((i + 1) < *argc && (*argv)[i + 1])
{
(*argv)[i++] = NULL;
gdk_input_gxid_port = atoi ((*argv)[i]);
(*argv)[i] = NULL;
}
}
#endif
#ifdef USE_XIM
else if (strcmp ("--xim-preedit", (*argv)[i]) == 0)
{
if ((i + 1) < *argc && (*argv)[i + 1])
{
(*argv)[i++] = NULL;
if (strcmp ("none", (*argv)[i]) == 0)
gdk_im_set_best_style (GDK_IM_PREEDIT_NONE);
else if (strcmp ("nothing", (*argv)[i]) == 0)
gdk_im_set_best_style (GDK_IM_PREEDIT_NOTHING);
else if (strcmp ("area", (*argv)[i]) == 0)
gdk_im_set_best_style (GDK_IM_PREEDIT_AREA);
else if (strcmp ("position", (*argv)[i]) == 0)
gdk_im_set_best_style (GDK_IM_PREEDIT_POSITION);
else if (strcmp ("callbacks", (*argv)[i]) == 0)
gdk_im_set_best_style (GDK_IM_PREEDIT_CALLBACKS);
(*argv)[i] = NULL;
}
}
else if (strcmp ("--xim-status", (*argv)[i]) == 0)
{
if ((i + 1) < *argc && (*argv)[i + 1])
{
(*argv)[i++] = NULL;
if (strcmp ("none", (*argv)[i]) == 0)
gdk_im_set_best_style (GDK_IM_STATUS_NONE);
else if (strcmp ("nothing", (*argv)[i]) == 0)
gdk_im_set_best_style (GDK_IM_STATUS_NOTHING);
else if (strcmp ("area", (*argv)[i]) == 0)
gdk_im_set_best_style (GDK_IM_STATUS_AREA);
else if (strcmp ("callbacks", (*argv)[i]) == 0)
gdk_im_set_best_style (GDK_IM_STATUS_CALLBACKS);
(*argv)[i] = NULL;
}
}
#endif
i += 1;
}
for (i = 1; i < *argc; i++)
{
for (k = i; k < *argc; k++)
if ((*argv)[k] != NULL)
break;
if (k > i)
{
k -= i;
for (j = i + k; j < *argc; j++)
(*argv)[j-k] = (*argv)[j];
*argc -= k;
}
}
}
else
{
g_set_prgname ("<unknown>");
}
GDK_NOTE (MISC, g_message ("progname: \"%s\"", g_get_prgname ()));
gdk_display = XOpenDisplay (gdk_display_name);
if (!gdk_display)
return FALSE;
if (synchronize)
if (gdk_synchronize)
XSynchronize (gdk_display, True);
gdk_screen = DefaultScreen (gdk_display);
@ -378,14 +173,10 @@ gdk_init_check (int *argc,
}
class_hint->res_class = gdk_progclass;
XmbSetWMProperties (gdk_display, gdk_leader_window,
NULL, NULL, argv_orig, argc_orig,
NULL, NULL, argv, argc,
NULL, NULL, class_hint);
XFree (class_hint);
for (i = 0; i < argc_orig; i++)
g_free(argv_orig[i]);
g_free(argv_orig);
gdk_wm_delete_window = XInternAtom (gdk_display, "WM_DELETE_WINDOW", False);
gdk_wm_take_focus = XInternAtom (gdk_display, "WM_TAKE_FOCUS", False);
gdk_wm_protocols = XInternAtom (gdk_display, "WM_PROTOCOLS", False);
@ -396,61 +187,9 @@ gdk_init_check (int *argc,
XGetKeyboardControl (gdk_display, &keyboard_state);
autorepeat = keyboard_state.global_auto_repeat;
g_atexit (gdk_exit_func);
gdk_events_init ();
gdk_visual_init ();
gdk_window_init ();
gdk_image_init ();
gdk_input_init ();
gdk_dnd_init ();
#ifdef USE_XIM
gdk_im_open ();
#endif
gdk_initialized = 1;
return TRUE;
}
void
gdk_init (int *argc, char ***argv)
{
if (!gdk_init_check (argc, argv))
{
g_warning ("cannot open display: %s", gdk_get_display ());
exit(1);
}
}
/*
*--------------------------------------------------------------
* gdk_exit
*
* Restores the library to an un-itialized state and exits
* the program using the "exit" system call.
*
* Arguments:
* "errorcode" is the error value to pass to "exit".
*
* Results:
* Allocated structures are freed and the program exits
* cleanly.
*
* Side effects:
*
*--------------------------------------------------------------
*/
void
gdk_exit (gint errorcode)
{
/* de-initialisation is done by the gdk_exit_funct(),
no need to do this here (Alex J.) */
exit (errorcode);
}
void
gdk_set_use_xshm (gint use_xshm)
{
@ -822,50 +561,10 @@ gdk_beep (void)
XBell(gdk_display, 0);
}
/*
*--------------------------------------------------------------
* gdk_exit_func
*
* This is the "atexit" function that makes sure the
* library gets a chance to cleanup.
*
* Arguments:
*
* Results:
*
* Side effects:
* The library is un-initialized and the program exits.
*
*--------------------------------------------------------------
*/
static void
gdk_exit_func (void)
void
gdk_windowing_exit (void)
{
static gboolean in_gdk_exit_func = FALSE;
/* This is to avoid an infinite loop if a program segfaults in
an atexit() handler (and yes, it does happen, especially if a program
has trounced over memory too badly for even g_message to work) */
if (in_gdk_exit_func == TRUE)
return;
in_gdk_exit_func = TRUE;
if (gdk_initialized)
{
#ifdef USE_XIM
/* cleanup IC */
gdk_ic_cleanup ();
/* close IM */
gdk_im_close ();
#endif
gdk_image_exit ();
gdk_input_exit ();
gdk_key_repeat_restore ();
XCloseDisplay (gdk_display);
gdk_initialized = 0;
}
}
/*
@ -977,77 +676,6 @@ gdk_get_display (void)
return (gchar *)XDisplayName (gdk_display_name);
}
/*************************************************************
* gdk_error_trap_push:
* Push an error trap. X errors will be trapped until
* the corresponding gdk_error_pop(), which will return
* the error code, if any.
* arguments:
*
* results:
*************************************************************/
void
gdk_error_trap_push (void)
{
GSList *node;
GdkErrorTrap *trap;
if (gdk_error_trap_free_list)
{
node = gdk_error_trap_free_list;
gdk_error_trap_free_list = gdk_error_trap_free_list->next;
}
else
{
node = g_slist_alloc ();
node->data = g_new (GdkErrorTrap, 1);
}
node->next = gdk_error_traps;
gdk_error_traps = node;
trap = node->data;
trap->error_code = gdk_error_code;
trap->error_warnings = gdk_error_warnings;
gdk_error_code = 0;
gdk_error_warnings = 0;
}
/*************************************************************
* gdk_error_trap_pop:
* Pop an error trap added with gdk_error_push()
* arguments:
*
* results:
* 0, if no error occured, otherwise the error code.
*************************************************************/
gint
gdk_error_trap_pop (void)
{
GSList *node;
GdkErrorTrap *trap;
gint result;
g_return_val_if_fail (gdk_error_traps != NULL, 0);
node = gdk_error_traps;
gdk_error_traps = gdk_error_traps->next;
node->next = gdk_error_trap_free_list;
gdk_error_trap_free_list = node;
result = gdk_error_code;
trap = node->data;
gdk_error_code = trap->error_code;
gdk_error_warnings = trap->error_warnings;
return result;
}
gint
gdk_send_xevent (Window window, gboolean propagate, glong event_mask,
XEvent *event_send)
@ -1065,138 +693,6 @@ gdk_send_xevent (Window window, gboolean propagate, glong event_mask,
return result && !gdk_error_code;
}
#ifndef HAVE_XCONVERTCASE
/* compatibility function from X11R6.3, since XConvertCase is not
* supplied by X11R5.
*/
static void
gdkx_XConvertCase (KeySym symbol,
KeySym *lower,
KeySym *upper)
{
register KeySym sym = symbol;
g_return_if_fail (lower != NULL);
g_return_if_fail (upper != NULL);
*lower = sym;
*upper = sym;
switch (sym >> 8)
{
#if defined (GDK_A) && defined (GDK_Ooblique)
case 0: /* Latin 1 */
if ((sym >= GDK_A) && (sym <= GDK_Z))
*lower += (GDK_a - GDK_A);
else if ((sym >= GDK_a) && (sym <= GDK_z))
*upper -= (GDK_a - GDK_A);
else if ((sym >= GDK_Agrave) && (sym <= GDK_Odiaeresis))
*lower += (GDK_agrave - GDK_Agrave);
else if ((sym >= GDK_agrave) && (sym <= GDK_odiaeresis))
*upper -= (GDK_agrave - GDK_Agrave);
else if ((sym >= GDK_Ooblique) && (sym <= GDK_Thorn))
*lower += (GDK_oslash - GDK_Ooblique);
else if ((sym >= GDK_oslash) && (sym <= GDK_thorn))
*upper -= (GDK_oslash - GDK_Ooblique);
break;
#endif /* LATIN1 */
#if defined (GDK_Aogonek) && defined (GDK_tcedilla)
case 1: /* Latin 2 */
/* Assume the KeySym is a legal value (ignore discontinuities) */
if (sym == GDK_Aogonek)
*lower = GDK_aogonek;
else if (sym >= GDK_Lstroke && sym <= GDK_Sacute)
*lower += (GDK_lstroke - GDK_Lstroke);
else if (sym >= GDK_Scaron && sym <= GDK_Zacute)
*lower += (GDK_scaron - GDK_Scaron);
else if (sym >= GDK_Zcaron && sym <= GDK_Zabovedot)
*lower += (GDK_zcaron - GDK_Zcaron);
else if (sym == GDK_aogonek)
*upper = GDK_Aogonek;
else if (sym >= GDK_lstroke && sym <= GDK_sacute)
*upper -= (GDK_lstroke - GDK_Lstroke);
else if (sym >= GDK_scaron && sym <= GDK_zacute)
*upper -= (GDK_scaron - GDK_Scaron);
else if (sym >= GDK_zcaron && sym <= GDK_zabovedot)
*upper -= (GDK_zcaron - GDK_Zcaron);
else if (sym >= GDK_Racute && sym <= GDK_Tcedilla)
*lower += (GDK_racute - GDK_Racute);
else if (sym >= GDK_racute && sym <= GDK_tcedilla)
*upper -= (GDK_racute - GDK_Racute);
break;
#endif /* LATIN2 */
#if defined (GDK_Hstroke) && defined (GDK_Cabovedot)
case 2: /* Latin 3 */
/* Assume the KeySym is a legal value (ignore discontinuities) */
if (sym >= GDK_Hstroke && sym <= GDK_Hcircumflex)
*lower += (GDK_hstroke - GDK_Hstroke);
else if (sym >= GDK_Gbreve && sym <= GDK_Jcircumflex)
*lower += (GDK_gbreve - GDK_Gbreve);
else if (sym >= GDK_hstroke && sym <= GDK_hcircumflex)
*upper -= (GDK_hstroke - GDK_Hstroke);
else if (sym >= GDK_gbreve && sym <= GDK_jcircumflex)
*upper -= (GDK_gbreve - GDK_Gbreve);
else if (sym >= GDK_Cabovedot && sym <= GDK_Scircumflex)
*lower += (GDK_cabovedot - GDK_Cabovedot);
else if (sym >= GDK_cabovedot && sym <= GDK_scircumflex)
*upper -= (GDK_cabovedot - GDK_Cabovedot);
break;
#endif /* LATIN3 */
#if defined (GDK_Rcedilla) && defined (GDK_Amacron)
case 3: /* Latin 4 */
/* Assume the KeySym is a legal value (ignore discontinuities) */
if (sym >= GDK_Rcedilla && sym <= GDK_Tslash)
*lower += (GDK_rcedilla - GDK_Rcedilla);
else if (sym >= GDK_rcedilla && sym <= GDK_tslash)
*upper -= (GDK_rcedilla - GDK_Rcedilla);
else if (sym == GDK_ENG)
*lower = GDK_eng;
else if (sym == GDK_eng)
*upper = GDK_ENG;
else if (sym >= GDK_Amacron && sym <= GDK_Umacron)
*lower += (GDK_amacron - GDK_Amacron);
else if (sym >= GDK_amacron && sym <= GDK_umacron)
*upper -= (GDK_amacron - GDK_Amacron);
break;
#endif /* LATIN4 */
#if defined (GDK_Serbian_DJE) && defined (GDK_Cyrillic_yu)
case 6: /* Cyrillic */
/* Assume the KeySym is a legal value (ignore discontinuities) */
if (sym >= GDK_Serbian_DJE && sym <= GDK_Serbian_DZE)
*lower -= (GDK_Serbian_DJE - GDK_Serbian_dje);
else if (sym >= GDK_Serbian_dje && sym <= GDK_Serbian_dze)
*upper += (GDK_Serbian_DJE - GDK_Serbian_dje);
else if (sym >= GDK_Cyrillic_YU && sym <= GDK_Cyrillic_HARDSIGN)
*lower -= (GDK_Cyrillic_YU - GDK_Cyrillic_yu);
else if (sym >= GDK_Cyrillic_yu && sym <= GDK_Cyrillic_hardsign)
*upper += (GDK_Cyrillic_YU - GDK_Cyrillic_yu);
break;
#endif /* CYRILLIC */
#if defined (GDK_Greek_ALPHAaccent) && defined (GDK_Greek_finalsmallsigma)
case 7: /* Greek */
/* Assume the KeySym is a legal value (ignore discontinuities) */
if (sym >= GDK_Greek_ALPHAaccent && sym <= GDK_Greek_OMEGAaccent)
*lower += (GDK_Greek_alphaaccent - GDK_Greek_ALPHAaccent);
else if (sym >= GDK_Greek_alphaaccent && sym <= GDK_Greek_omegaaccent &&
sym != GDK_Greek_iotaaccentdieresis &&
sym != GDK_Greek_upsilonaccentdieresis)
*upper -= (GDK_Greek_alphaaccent - GDK_Greek_ALPHAaccent);
else if (sym >= GDK_Greek_ALPHA && sym <= GDK_Greek_OMEGA)
*lower += (GDK_Greek_alpha - GDK_Greek_ALPHA);
else if (sym >= GDK_Greek_alpha && sym <= GDK_Greek_omega &&
sym != GDK_Greek_finalsmallsigma)
*upper -= (GDK_Greek_alpha - GDK_Greek_ALPHA);
break;
#endif /* GREEK */
}
}
#endif
gchar*
gdk_keyval_name (guint keyval)
{
@ -1211,71 +707,21 @@ gdk_keyval_from_name (const gchar *keyval_name)
return XStringToKeysym (keyval_name);
}
guint
gdk_keyval_to_upper (guint keyval)
{
if (keyval)
{
KeySym lower_val = 0;
KeySym upper_val = 0;
XConvertCase (keyval, &lower_val, &upper_val);
return upper_val;
}
return 0;
}
guint
gdk_keyval_to_lower (guint keyval)
{
if (keyval)
{
KeySym lower_val = 0;
KeySym upper_val = 0;
XConvertCase (keyval, &lower_val, &upper_val);
return lower_val;
}
return 0;
}
gboolean
gdk_keyval_is_upper (guint keyval)
{
if (keyval)
{
KeySym lower_val = 0;
KeySym upper_val = 0;
XConvertCase (keyval, &lower_val, &upper_val);
return upper_val == keyval;
}
return TRUE;
}
gboolean
gdk_keyval_is_lower (guint keyval)
{
if (keyval)
{
KeySym lower_val = 0;
KeySym upper_val = 0;
XConvertCase (keyval, &lower_val, &upper_val);
return lower_val == keyval;
}
return TRUE;
}
#ifdef HAVE_XCONVERTCASE
void
gdk_threads_enter ()
gdk_keyval_convert_case (guint symbol,
guint *lower,
guint *upper)
{
GDK_THREADS_ENTER ();
}
KeySym xlower = 0;
KeySym xupper = 0;
void
gdk_threads_leave ()
{
GDK_THREADS_LEAVE ();
}
if (symbol)
XConvertCase (symbol, &xlower, &xupper);
if (lower)
*lower = xlower;
if (upper)
*upper = xupper;
}
#endif HAVE_XCONVERTCASE

View File

@ -50,6 +50,44 @@ typedef struct
gulong pixels[1];
} _GdkPixmapInfo;
GdkDrawableClass _gdk_x11_pixmap_class;
static void
gdk_x11_pixmap_destroy (GdkPixmap *pixmap)
{
XFreePixmap (GDK_DRAWABLE_XDISPLAY (pixmap), GDK_DRAWABLE_XID (pixmap));
gdk_xid_table_remove (GDK_DRAWABLE_XID (pixmap));
g_free (GDK_DRAWABLE_XDATA (pixmap));
}
static GdkDrawable *
gdk_x11_pixmap_alloc (void)
{
GdkDrawable *drawable;
GdkDrawablePrivate *private;
static GdkDrawableClass klass;
static gboolean initialized = FALSE;
if (!initialized)
{
initialized = TRUE;
klass = _gdk_x11_drawable_class;
klass.destroy = gdk_x11_pixmap_destroy;
}
drawable = gdk_drawable_alloc ();
private = (GdkDrawablePrivate *)drawable;
private->klass = &klass;
private->klass_data = g_new (GdkDrawableXData, 1);
private->window_type = GDK_DRAWABLE_PIXMAP;
return drawable;
}
GdkPixmap*
gdk_pixmap_new (GdkWindow *window,
gint width,
@ -64,7 +102,7 @@ gdk_pixmap_new (GdkWindow *window,
g_return_val_if_fail ((width != 0) && (height != 0), NULL);
if (!window)
window = (GdkWindow*) &gdk_root_parent;
window = gdk_parent_root;
if (GDK_DRAWABLE_DESTROYED (window))
return NULL;
@ -72,21 +110,17 @@ gdk_pixmap_new (GdkWindow *window,
if (depth == -1)
depth = gdk_drawable_get_visual (window)->depth;
private = g_new0 (GdkDrawablePrivate, 1);
pixmap = (GdkPixmap*) private;
pixmap = gdk_x11_pixmap_alloc ();
private = (GdkDrawablePrivate *)pixmap;
private->xdisplay = GDK_DRAWABLE_XDISPLAY (window);
private->window_type = GDK_DRAWABLE_PIXMAP;
private->xwindow = XCreatePixmap (private->xdisplay,
GDK_DRAWABLE_XDATA (private)->xdisplay = GDK_DRAWABLE_XDISPLAY (window);
GDK_DRAWABLE_XDATA (private)->xid = XCreatePixmap (GDK_DRAWABLE_XDISPLAY (pixmap),
GDK_DRAWABLE_XID (window),
width, height, depth);
private->colormap = NULL;
private->width = width;
private->height = height;
private->ref_count = 1;
private->destroyed = 0;
gdk_xid_table_insert (&private->xwindow, pixmap);
gdk_xid_table_insert (&GDK_DRAWABLE_XID (pixmap), pixmap);
return pixmap;
}
@ -105,26 +139,23 @@ gdk_bitmap_create_from_data (GdkWindow *window,
g_return_val_if_fail (window == NULL || GDK_IS_WINDOW (window), NULL);
if (!window)
window = (GdkWindow*) &gdk_root_parent;
window = gdk_parent_root;
if (GDK_DRAWABLE_DESTROYED (window))
return NULL;
private = g_new0 (GdkDrawablePrivate, 1);
pixmap = (GdkPixmap*) private;
pixmap = gdk_x11_pixmap_alloc ();
private = (GdkDrawablePrivate *)pixmap;
private->xdisplay = GDK_DRAWABLE_XDISPLAY (window);
private->window_type = GDK_DRAWABLE_PIXMAP;
private->width = width;
private->height = height;
private->ref_count = 1;
private->destroyed = FALSE;
private->xwindow = XCreateBitmapFromData (private->xdisplay,
GDK_DRAWABLE_XDATA (private)->xdisplay = GDK_DRAWABLE_XDISPLAY (window);
GDK_DRAWABLE_XDATA (private)->xid = XCreateBitmapFromData (GDK_DRAWABLE_XDISPLAY (window),
GDK_DRAWABLE_XID (window),
(char *)data, width, height);
gdk_xid_table_insert (&private->xwindow, pixmap);
gdk_xid_table_insert (&GDK_DRAWABLE_XID (pixmap), pixmap);
return pixmap;
}
@ -149,7 +180,7 @@ gdk_pixmap_create_from_data (GdkWindow *window,
g_return_val_if_fail ((width != 0) && (height != 0), NULL);
if (!window)
window = (GdkWindow*) &gdk_root_parent;
window = gdk_parent_root;
if (GDK_DRAWABLE_DESTROYED (window))
return NULL;
@ -157,22 +188,19 @@ gdk_pixmap_create_from_data (GdkWindow *window,
if (depth == -1)
depth = gdk_drawable_get_visual (window)->depth;
private = g_new0 (GdkDrawablePrivate, 1);
pixmap = (GdkPixmap*) private;
pixmap = gdk_x11_pixmap_alloc ();
private = (GdkDrawablePrivate *)pixmap;
private->xdisplay = GDK_DRAWABLE_XDISPLAY (window);
private->window_type = GDK_DRAWABLE_PIXMAP;
private->width = width;
private->height = height;
private->ref_count = 1;
private->destroyed = FALSE;
private->xwindow = XCreatePixmapFromBitmapData (private->xdisplay,
GDK_DRAWABLE_XDATA (private)->xdisplay = GDK_DRAWABLE_XDISPLAY (window);
GDK_DRAWABLE_XDATA (private)->xid = XCreatePixmapFromBitmapData (GDK_DRAWABLE_XDISPLAY (window),
GDK_DRAWABLE_XID (window),
(char *)data, width, height,
fg->pixel, bg->pixel, depth);
gdk_xid_table_insert (&private->xwindow, pixmap);
gdk_xid_table_insert (&GDK_DRAWABLE_XID (pixmap), pixmap);
return pixmap;
}
@ -443,7 +471,7 @@ _gdk_pixmap_create_from_xpm (GdkWindow *window,
g_warning ("Creating pixmap from xpm with NULL window and colormap");
if (window == NULL)
window = (GdkWindow *)&gdk_root_parent;
window = gdk_parent_root;
if (colormap == NULL)
{
@ -588,7 +616,7 @@ _gdk_pixmap_create_from_xpm (GdkWindow *window,
error:
if (mask)
gdk_gc_destroy (gc);
gdk_gc_unref (gc);
if (image != NULL)
{
@ -601,8 +629,8 @@ _gdk_pixmap_create_from_xpm (GdkWindow *window,
gc = gdk_gc_new (pixmap);
gdk_gc_set_foreground (gc, transparent_color);
gdk_draw_image (pixmap, gc, image, 0, 0, 0, 0, image->width, image->height);
gdk_gc_destroy (gc);
gdk_image_destroy (image);
gdk_gc_unref (gc);
gdk_image_unref (image);
}
else if (color_info)
gdk_xpm_destroy_notify (color_info);
@ -766,61 +794,16 @@ gdk_pixmap_foreign_new (guint32 anid)
&x_ret, &y_ret, &w_ret, &h_ret, &bw_ret, &depth_ret))
return NULL;
/* allocate a new gdk pixmap */
private = g_new(GdkDrawablePrivate, 1);
pixmap = (GdkPixmap *)private;
pixmap = gdk_x11_pixmap_alloc ();
private = (GdkDrawablePrivate *)pixmap;
GDK_DRAWABLE_XDATA (private)->xdisplay = GDK_DISPLAY ();
GDK_DRAWABLE_XDATA (private)->xid = xpixmap;
private->xdisplay = GDK_DISPLAY();
private->window_type = GDK_DRAWABLE_PIXMAP;
private->xwindow = xpixmap;
private->colormap = NULL;
private->width = w_ret;
private->height = h_ret;
private->ref_count = 1;
private->destroyed = 0;
gdk_xid_table_insert(&private->xwindow, pixmap);
gdk_xid_table_insert(&GDK_DRAWABLE_XID (pixmap), pixmap);
return pixmap;
}
GdkPixmap*
gdk_pixmap_ref (GdkPixmap *pixmap)
{
GdkDrawablePrivate *private = (GdkDrawablePrivate *)pixmap;
g_return_val_if_fail (pixmap != NULL, NULL);
g_return_val_if_fail (GDK_IS_PIXMAP (private), NULL);
private->ref_count += 1;
return pixmap;
}
void
gdk_pixmap_unref (GdkPixmap *pixmap)
{
GdkDrawablePrivate *private = (GdkDrawablePrivate *)pixmap;
g_return_if_fail (pixmap != NULL);
g_return_if_fail (GDK_IS_PIXMAP (private));
g_return_if_fail (private->ref_count > 0);
private->ref_count -= 1;
if (private->ref_count == 0)
{
XFreePixmap (private->xdisplay, private->xwindow);
gdk_xid_table_remove (private->xwindow);
g_dataset_destroy (private);
g_free (private);
}
}
GdkBitmap *
gdk_bitmap_ref (GdkBitmap *bitmap)
{
return (GdkBitmap *)gdk_pixmap_ref ((GdkPixmap *)bitmap);
}
void
gdk_bitmap_unref (GdkBitmap *bitmap)
{
gdk_pixmap_unref ((GdkPixmap *)bitmap);
}

158
gdk/x11/gdkprivate-x11.h Normal file
View File

@ -0,0 +1,158 @@
#ifndef __GDK_PRIVATE_X11_H__
#define __GDK_PRIVATE_X11_H__
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <gdk/gdkfont.h>
#include <gdk/gdkprivate.h>
#include <gdk/gdkcursor.h>
typedef struct _GdkGCXData GdkGCXData;
typedef struct _GdkDrawableXData GdkDrawableXData;
typedef struct _GdkColormapPrivateX GdkColormapPrivateX;
typedef struct _GdkCursorPrivate GdkCursorPrivate;
typedef struct _GdkFontPrivateX GdkFontPrivateX;
typedef struct _GdkImagePrivateX GdkImagePrivateX;
typedef struct _GdkVisualPrivate GdkVisualPrivate;
typedef struct _GdkRegionPrivate GdkRegionPrivate;
#ifdef USE_XIM
typedef struct _GdkICPrivate GdkICPrivate;
#endif /* USE_XIM */
#define GDK_DRAWABLE_XDATA(win) ((GdkDrawableXData *)(((GdkDrawablePrivate*)(win))->klass_data))
#define GDK_GC_XDATA(gc) ((GdkGCXData *)(((GdkGCPrivate*)(gc))->klass_data))
struct _GdkGCXData
{
GC xgc;
Display *xdisplay;
};
struct _GdkDrawableXData
{
Window xid;
Display *xdisplay;
};
struct _GdkCursorPrivate
{
GdkCursor cursor;
Cursor xcursor;
Display *xdisplay;
};
struct _GdkFontPrivateX
{
GdkFontPrivate base;
/* XFontStruct *xfont; */
/* generic pointer point to XFontStruct or XFontSet */
gpointer xfont;
Display *xdisplay;
GSList *names;
};
struct _GdkVisualPrivate
{
GdkVisual visual;
Visual *xvisual;
};
struct _GdkColormapPrivateX
{
GdkColormapPrivate base;
Colormap xcolormap;
Display *xdisplay;
gint private_val;
GHashTable *hash;
GdkColorInfo *info;
time_t last_sync_time;
};
struct _GdkImagePrivateX
{
GdkImagePrivate base;
XImage *ximage;
Display *xdisplay;
gpointer x_shm_info;
};
struct _GdkRegionPrivate
{
GdkRegion region;
Region xregion;
};
#ifdef USE_XIM
struct _GdkICPrivate
{
XIC xic;
GdkICAttr *attr;
GdkICAttributesType mask;
};
#endif /* USE_XIM */
void gdk_xid_table_insert (XID *xid,
gpointer data);
void gdk_xid_table_remove (XID xid);
gpointer gdk_xid_table_lookup (XID xid);
gint gdk_send_xevent (Window window,
gboolean propagate,
glong event_mask,
XEvent *event_send);
GdkGC * _gdk_x11_gc_new (GdkDrawable *drawable,
GdkGCValues *values,
GdkGCValuesMask values_mask);
GdkColormap * gdk_colormap_lookup (Colormap xcolormap);
GdkVisual * gdk_visual_lookup (Visual *xvisual);
/* Please see gdkwindow.c for comments on how to use */
Window gdk_window_xid_at (Window base,
gint bx,
gint by,
gint x,
gint y,
GList *excludes,
gboolean excl_child);
Window gdk_window_xid_at_coords (gint x,
gint y,
GList *excludes,
gboolean excl_child);
extern GdkDrawableClass _gdk_x11_drawable_class;
extern gboolean gdk_use_xshm;
extern gchar *gdk_display_name;
extern Display *gdk_display;
extern Window gdk_root_window;
extern Window gdk_leader_window;
extern Atom gdk_wm_delete_window;
extern Atom gdk_wm_take_focus;
extern Atom gdk_wm_protocols;
extern Atom gdk_wm_window_protocols[];
extern Atom gdk_selection_property;
extern GdkWindow *selection_owner[];
extern gchar *gdk_progclass;
extern gboolean gdk_null_window_warnings;
extern const int gdk_nevent_masks;
extern const int gdk_event_mask_table[];
extern GdkWindowPrivate *gdk_xgrab_window; /* Window that currently holds the
* x pointer grab
*/
#ifdef USE_XIM
extern GdkICPrivate *gdk_xim_ic; /* currently using IC */
extern GdkWindow *gdk_xim_window; /* currently using Window */
#endif /* USE_XIM */
#endif /* __GDK_PRIVATE_X11_H__ */

View File

@ -39,6 +39,8 @@ gdk_atom_intern (const gchar *atom_name,
GdkAtom retval;
static GHashTable *atom_hash = NULL;
g_return_val_if_fail (atom_name != NULL, GDK_NONE);
if (!atom_hash)
atom_hash = g_hash_table_new (g_str_hash, g_str_equal);
@ -110,13 +112,16 @@ gdk_property_get (GdkWindow *window,
gulong ret_length;
guchar *ret_data;
g_return_val_if_fail (window != NULL, FALSE);
g_return_val_if_fail (!GDK_IS_WINDOW (window), FALSE);
if (window)
{
if (GDK_DRAWABLE_DESTROYED (window))
return FALSE;
xdisplay = GDK_WINDOW_XDISPLAY (window);
xwindow = GDK_WINDOW_XWINDOW (window);
xdisplay = GDK_DRAWABLE_XDISPLAY (window);
xwindow = GDK_DRAWABLE_XID (window);
}
else
{
@ -196,13 +201,16 @@ gdk_property_change (GdkWindow *window,
Display *xdisplay;
Window xwindow;
g_return_if_fail (window != NULL);
g_return_if_fail (!GDK_IS_WINDOW (window));
if (window)
{
if (GDK_DRAWABLE_DESTROYED (window))
return;
xdisplay = GDK_WINDOW_XDISPLAY (window);
xwindow = GDK_WINDOW_XWINDOW (window);
xdisplay = GDK_DRAWABLE_XDISPLAY (window);
xwindow = GDK_DRAWABLE_XID (window);
}
else
{
@ -221,13 +229,16 @@ gdk_property_delete (GdkWindow *window,
Display *xdisplay;
Window xwindow;
g_return_if_fail (window != NULL);
g_return_if_fail (!GDK_IS_WINDOW (window));
if (window)
{
if (GDK_DRAWABLE_DESTROYED (window))
return;
xdisplay = GDK_WINDOW_XDISPLAY (window);
xwindow = GDK_WINDOW_XWINDOW (window);
xdisplay = GDK_DRAWABLE_XDISPLAY (window);
xwindow = GDK_DRAWABLE_XID (window);
}
else
{

View File

@ -26,11 +26,7 @@
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include "gdk.h"
#include "gdkprivate.h"
#include "gdkprivate-x11.h"
GdkRegion*
gdk_region_new (void)

View File

@ -28,7 +28,7 @@
#include <X11/Xutil.h>
#include "gdkvisual.h"
#include "gdkprivate.h"
#include "gdkprivate-x11.h"
static void gdk_visual_add (GdkVisual *visual);
static void gdk_visual_decompose_mask (gulong mask,

View File

@ -33,7 +33,7 @@
#include "gdkwindow.h"
#include "gdkinputprivate.h"
#include "gdkprivate.h"
#include "gdkprivate-x11.h"
#include "gdkx.h"
#include "MwmUtil.h"
@ -77,144 +77,50 @@ static void gdk_window_set_static_win_gravity (GdkWindow *window,
gboolean on);
static gboolean gdk_window_have_shape_ext (void);
/* internal function created for and used by gdk_window_xid_at_coords */
Window
gdk_window_xid_at (Window base,
gint bx,
gint by,
gint x,
gint y,
GList *excludes,
gboolean excl_child)
static void
gdk_x11_window_destroy (GdkDrawable *drawable)
{
GdkWindow *window;
GdkDrawablePrivate *private;
Display *disp;
Window *list = NULL;
Window child = 0, parent_win = 0, root_win = 0;
int i;
unsigned int ww, wh, wb, wd, num;
int wx, wy;
window = (GdkWindow*) &gdk_root_parent;
private = (GdkDrawablePrivate*) window;
disp = private->xdisplay;
if (!XGetGeometry (disp, base, &root_win, &wx, &wy, &ww, &wh, &wb, &wd))
return 0;
wx += bx;
wy += by;
if (!((x >= wx) &&
(y >= wy) &&
(x < (int) (wx + ww)) &&
(y < (int) (wy + wh))))
return 0;
if (!XQueryTree (disp, base, &root_win, &parent_win, &list, &num))
return base;
if (list)
if (!GDK_DRAWABLE_DESTROYED (drawable))
{
for (i = num - 1; ; i--)
{
if ((!excl_child) || (!g_list_find (excludes, (gpointer *) list[i])))
{
if ((child = gdk_window_xid_at (list[i], wx, wy, x, y, excludes, excl_child)) != 0)
{
XFree (list);
return child;
}
}
if (!i)
break;
}
XFree (list);
}
return base;
}
/*
* The following fucntion by The Rasterman <raster@redhat.com>
* This function returns the X Window ID in which the x y location is in
* (x and y being relative to the root window), excluding any windows listed
* in the GList excludes (this is a list of X Window ID's - gpointer being
* the Window ID).
*
* This is primarily designed for internal gdk use - for DND for example
* when using a shaped icon window as the drag object - you exclude the
* X Window ID of the "icon" (perhaps more if excludes may be needed) and
* You can get back an X Window ID as to what X Window ID is infact under
* those X,Y co-ordinates.
*/
Window
gdk_window_xid_at_coords (gint x,
gint y,
GList *excludes,
gboolean excl_child)
{
GdkWindow *window;
GdkDrawablePrivate *private;
Display *disp;
Window *list = NULL;
Window root, child = 0, parent_win = 0, root_win = 0;
unsigned int num;
int i;
window = (GdkWindow*) &gdk_root_parent;
private = (GdkDrawablePrivate*) window;
disp = private->xdisplay;
root = private->xwindow;
num = g_list_length (excludes);
XGrabServer (disp);
if (!XQueryTree (disp, root, &root_win, &parent_win, &list, &num))
{
XUngrabServer (disp);
return root;
}
if (list)
{
i = num - 1;
do
{
XWindowAttributes xwa;
XGetWindowAttributes (disp, list [i], &xwa);
if (xwa.map_state != IsViewable)
continue;
if (excl_child && g_list_find (excludes, (gpointer *) list[i]))
continue;
if ((child = gdk_window_xid_at (list[i], 0, 0, x, y, excludes, excl_child)) == 0)
continue;
if (excludes)
{
if (!g_list_find (excludes, (gpointer *) child))
{
XFree (list);
XUngrabServer (disp);
return child;
}
}
if (GDK_DRAWABLE_TYPE (drawable) == GDK_WINDOW_FOREIGN)
gdk_xid_table_remove (GDK_DRAWABLE_XID (drawable));
else
g_warning ("losing last reference to undestroyed window\n");
}
g_free (GDK_DRAWABLE_XDATA (drawable));
}
static GdkWindow *
gdk_x11_window_alloc (void)
{
XFree (list);
XUngrabServer (disp);
return child;
GdkWindow *window;
GdkWindowPrivate *private;
static GdkDrawableClass klass;
static gboolean initialized = FALSE;
if (!initialized)
{
initialized = TRUE;
klass = _gdk_x11_drawable_class;
klass.destroy = gdk_x11_window_destroy;
}
} while (--i > 0);
XFree (list);
}
XUngrabServer (disp);
return root;
window = _gdk_window_alloc ();
private = (GdkWindowPrivate *)window;
private->drawable.klass = &klass;
private->drawable.klass_data = g_new (GdkDrawableXData, 1);
return window;
}
void
gdk_window_init (void)
{
GdkWindowPrivate *private;
XWindowAttributes xattributes;
unsigned int width;
unsigned int height;
@ -226,17 +132,17 @@ gdk_window_init (void)
&x, &y, &width, &height, &border_width, &depth);
XGetWindowAttributes (gdk_display, gdk_root_window, &xattributes);
gdk_root_parent.drawable.xwindow = gdk_root_window;
gdk_root_parent.drawable.xdisplay = gdk_display;
gdk_root_parent.drawable.window_type = GDK_WINDOW_ROOT;
gdk_root_parent.drawable.drawable.user_data = NULL;
gdk_root_parent.drawable.width = width;
gdk_root_parent.drawable.height = height;
gdk_root_parent.children = NULL;
gdk_root_parent.drawable.colormap = NULL;
gdk_root_parent.drawable.ref_count = 1;
gdk_parent_root = gdk_x11_window_alloc ();
private = (GdkWindowPrivate *)gdk_parent_root;
gdk_xid_table_insert (&gdk_root_window, &gdk_root_parent);
GDK_DRAWABLE_XDATA (gdk_parent_root)->xdisplay = gdk_display;
GDK_DRAWABLE_XDATA (gdk_parent_root)->xid = gdk_root_window;
private->drawable.window_type = GDK_WINDOW_ROOT;
private->drawable.width = width;
private->drawable.height = height;
gdk_xid_table_insert (&gdk_root_window, gdk_parent_root);
}
static GdkAtom wm_client_leader_atom = GDK_NONE;
@ -249,16 +155,18 @@ gdk_window_new (GdkWindow *parent,
GdkWindow *window;
GdkWindowPrivate *private;
GdkWindowPrivate *parent_private;
GdkVisual *visual;
Display *parent_display;
Window xparent;
Visual *xvisual;
XSetWindowAttributes xattributes;
long xattributes_mask;
XSizeHints size_hints;
XWMHints wm_hints;
XClassHint *class_hint;
int x, y, depth;
unsigned int class;
char *title;
int i;
@ -266,26 +174,21 @@ gdk_window_new (GdkWindow *parent,
g_return_val_if_fail (attributes != NULL, NULL);
if (!parent)
parent = (GdkWindow*) &gdk_root_parent;
parent = gdk_parent_root;
parent_private = (GdkWindowPrivate*) parent;
if (GDK_DRAWABLE_DESTROYED (parent))
return NULL;
xparent = parent_private->drawable.xwindow;
parent_display = parent_private->drawable.xdisplay;
xparent = GDK_DRAWABLE_XID (parent);
private = g_new (GdkWindowPrivate, 1);
window = (GdkWindow*) private;
window = gdk_x11_window_alloc ();
private = (GdkWindowPrivate *)window;
GDK_DRAWABLE_XDATA (window)->xdisplay = GDK_DRAWABLE_XDISPLAY (parent);
private->parent = parent;
private->drawable.xdisplay = parent_display;
private->drawable.destroyed = FALSE;
private->mapped = FALSE;
private->guffaw_gravity = FALSE;
private->resize_count = 0;
private->drawable.ref_count = 1;
xattributes_mask = 0;
if (attributes_mask & GDK_WA_X)
@ -303,12 +206,6 @@ gdk_window_new (GdkWindow *parent,
private->drawable.width = (attributes->width > 1) ? (attributes->width) : (1);
private->drawable.height = (attributes->height > 1) ? (attributes->height) : (1);
private->drawable.window_type = attributes->window_type;
private->extension_events = FALSE;
private->filters = NULL;
private->children = NULL;
window->user_data = NULL;
if (attributes_mask & GDK_WA_VISUAL)
visual = attributes->visual;
@ -363,26 +260,26 @@ gdk_window_new (GdkWindow *parent,
switch (private->drawable.window_type)
{
case GDK_WINDOW_TOPLEVEL:
xattributes.colormap = ((GdkColormapPrivate*) private->drawable.colormap)->xcolormap;
xattributes.colormap = GDK_COLORMAP_XCOLORMAP (private->drawable.colormap);
xattributes_mask |= CWColormap;
xparent = gdk_root_window;
break;
case GDK_WINDOW_CHILD:
xattributes.colormap = ((GdkColormapPrivate*) private->drawable.colormap)->xcolormap;
xattributes.colormap = GDK_COLORMAP_XCOLORMAP (private->drawable.colormap);
xattributes_mask |= CWColormap;
break;
case GDK_WINDOW_DIALOG:
xattributes.colormap = ((GdkColormapPrivate*) private->drawable.colormap)->xcolormap;
xattributes.colormap = GDK_COLORMAP_XCOLORMAP (private->drawable.colormap);
xattributes_mask |= CWColormap;
xparent = gdk_root_window;
break;
case GDK_WINDOW_TEMP:
xattributes.colormap = ((GdkColormapPrivate*) private->drawable.colormap)->xcolormap;
xattributes.colormap = GDK_COLORMAP_XCOLORMAP (private->drawable.colormap);
xattributes_mask |= CWColormap;
xparent = gdk_root_window;
@ -407,12 +304,13 @@ gdk_window_new (GdkWindow *parent,
private->drawable.colormap = NULL;
}
private->drawable.xwindow = XCreateWindow (private->drawable.xdisplay, xparent,
GDK_DRAWABLE_XDATA (private)->xid = XCreateWindow (GDK_DRAWABLE_XDISPLAY (parent),
xparent,
x, y, private->drawable.width, private->drawable.height,
0, depth, class, xvisual,
xattributes_mask, &xattributes);
gdk_window_ref (window);
gdk_xid_table_insert (&private->drawable.xwindow, window);
gdk_drawable_ref (window);
gdk_xid_table_insert (&GDK_DRAWABLE_XID (window), window);
if (private->drawable.colormap)
gdk_colormap_ref (private->drawable.colormap);
@ -427,10 +325,14 @@ gdk_window_new (GdkWindow *parent,
switch (private->drawable.window_type)
{
case GDK_WINDOW_DIALOG:
XSetTransientForHint (private->drawable.xdisplay, private->drawable.xwindow, xparent);
XSetTransientForHint (GDK_DRAWABLE_XDISPLAY (window),
GDK_DRAWABLE_XID (window),
xparent);
case GDK_WINDOW_TOPLEVEL:
case GDK_WINDOW_TEMP:
XSetWMProtocols (private->drawable.xdisplay, private->drawable.xwindow, gdk_wm_window_protocols, 2);
XSetWMProtocols (GDK_DRAWABLE_XDISPLAY (window),
GDK_DRAWABLE_XID (window),
gdk_wm_window_protocols, 2);
break;
case GDK_WINDOW_CHILD:
if ((attributes->wclass == GDK_INPUT_OUTPUT) &&
@ -460,14 +362,19 @@ gdk_window_new (GdkWindow *parent,
* attention to PSize, and even if they do, is this the
* correct value???
*/
XSetWMNormalHints (private->drawable.xdisplay, private->drawable.xwindow, &size_hints);
XSetWMNormalHints (GDK_DRAWABLE_XDISPLAY (window),
GDK_DRAWABLE_XID (window),
&size_hints);
XSetWMHints (private->drawable.xdisplay, private->drawable.xwindow, &wm_hints);
XSetWMHints (GDK_DRAWABLE_XDISPLAY (window),
GDK_DRAWABLE_XID (window),
&wm_hints);
if (!wm_client_leader_atom)
wm_client_leader_atom = gdk_atom_intern ("WM_CLIENT_LEADER", FALSE);
XChangeProperty (private->drawable.xdisplay, private->drawable.xwindow,
XChangeProperty (GDK_DRAWABLE_XDISPLAY (window),
GDK_DRAWABLE_XID (window),
wm_client_leader_atom,
XA_WINDOW, 32, PropModeReplace,
(guchar*) &gdk_leader_window, 1);
@ -477,7 +384,8 @@ gdk_window_new (GdkWindow *parent,
else
title = g_get_prgname ();
XmbSetWMProperties (private->drawable.xdisplay, private->drawable.xwindow,
XmbSetWMProperties (GDK_DRAWABLE_XDISPLAY (window),
GDK_DRAWABLE_XID (window),
title, title,
NULL, 0,
NULL, NULL, NULL);
@ -487,11 +395,12 @@ gdk_window_new (GdkWindow *parent,
class_hint = XAllocClassHint ();
class_hint->res_name = attributes->wmclass_name;
class_hint->res_class = attributes->wmclass_class;
XSetClassHint (private->drawable.xdisplay, private->drawable.xwindow, class_hint);
XSetClassHint (GDK_DRAWABLE_XDISPLAY (window),
GDK_DRAWABLE_XID (window),
class_hint);
XFree (class_hint);
}
return window;
}
@ -519,11 +428,12 @@ gdk_window_foreign_new (guint32 anid)
if (gdk_error_trap_pop () || !result)
return NULL;
private = g_new (GdkWindowPrivate, 1);
window = (GdkWindow*) private;
if (children)
XFree (children);
window = gdk_x11_window_alloc ();
private = (GdkWindowPrivate *)window;
private->parent = gdk_xid_table_lookup (parent);
parent_private = (GdkWindowPrivate *)private->parent;
@ -531,29 +441,19 @@ gdk_window_foreign_new (guint32 anid)
if (parent_private)
parent_private->children = g_list_prepend (parent_private->children, window);
private->drawable.xwindow = anid;
private->drawable.xdisplay = gdk_display;
GDK_DRAWABLE_XDATA (window)->xid = anid;
GDK_DRAWABLE_XDATA (window)->xdisplay = GDK_DRAWABLE_XDISPLAY (parent);
private->x = attrs.x;
private->y = attrs.y;
private->drawable.width = attrs.width;
private->drawable.height = attrs.height;
private->resize_count = 0;
private->drawable.ref_count = 1;
private->drawable.window_type = GDK_WINDOW_FOREIGN;
private->drawable.destroyed = FALSE;
private->mapped = (attrs.map_state != IsUnmapped);
private->guffaw_gravity = FALSE;
private->extension_events = 0;
private->drawable.colormap = NULL;
private->filters = NULL;
private->children = NULL;
window->user_data = NULL;
gdk_window_ref (window);
gdk_xid_table_insert (&private->drawable.xwindow, window);
gdk_drawable_ref (window);
gdk_xid_table_insert (&GDK_DRAWABLE_XID (window), window);
return window;
}
@ -646,20 +546,22 @@ gdk_window_internal_destroy (GdkWindow *window,
gdk_window_reparent (window, NULL, 0, 0);
xevent.type = ClientMessage;
xevent.window = private->drawable.xwindow;
xevent.window = GDK_DRAWABLE_XID (window);
xevent.message_type = gdk_wm_protocols;
xevent.format = 32;
xevent.data.l[0] = gdk_wm_delete_window;
xevent.data.l[1] = CurrentTime;
XSendEvent (private->drawable.xdisplay, private->drawable.xwindow,
XSendEvent (GDK_DRAWABLE_XDISPLAY (window),
GDK_DRAWABLE_XID (window),
False, 0, (XEvent *)&xevent);
gdk_flush ();
gdk_error_trap_pop ();
}
}
else if (xdestroy)
XDestroyWindow (private->drawable.xdisplay, private->drawable.xwindow);
XDestroyWindow (GDK_DRAWABLE_XDISPLAY (window),
GDK_DRAWABLE_XID (window));
if (private->drawable.colormap)
gdk_colormap_unref (private->drawable.colormap);
@ -686,7 +588,7 @@ void
gdk_window_destroy (GdkWindow *window)
{
gdk_window_internal_destroy (window, TRUE, TRUE);
gdk_window_unref (window);
gdk_drawable_unref (window);
}
/* This function is called when the XWindow is really gone. */
@ -705,38 +607,7 @@ gdk_window_destroy_notify (GdkWindow *window)
}
gdk_xid_table_remove (GDK_DRAWABLE_XID (window));
gdk_window_unref (window);
}
GdkWindow*
gdk_window_ref (GdkWindow *window)
{
GdkWindowPrivate *private = (GdkWindowPrivate *)window;
g_return_val_if_fail (window != NULL, NULL);
private->drawable.ref_count += 1;
return window;
}
void
gdk_window_unref (GdkWindow *window)
{
GdkWindowPrivate *private = (GdkWindowPrivate *)window;
g_return_if_fail (window != NULL);
private->drawable.ref_count -= 1;
if (private->drawable.ref_count == 0)
{
if (!private->drawable.destroyed)
{
if (private->drawable.window_type == GDK_WINDOW_FOREIGN)
gdk_xid_table_remove (private->drawable.xwindow);
else
g_warning ("losing last reference to undestroyed window\n");
}
g_dataset_destroy (window);
g_free (window);
}
gdk_drawable_unref (window);
}
void
@ -750,8 +621,10 @@ gdk_window_show (GdkWindow *window)
if (!private->drawable.destroyed)
{
private->mapped = TRUE;
XRaiseWindow (private->drawable.xdisplay, private->drawable.xwindow);
XMapWindow (private->drawable.xdisplay, private->drawable.xwindow);
XRaiseWindow (GDK_DRAWABLE_XDISPLAY (window),
GDK_DRAWABLE_XID (window));
XMapWindow (GDK_DRAWABLE_XDISPLAY (window),
GDK_DRAWABLE_XID (window));
}
}
@ -766,7 +639,8 @@ gdk_window_hide (GdkWindow *window)
if (!private->drawable.destroyed)
{
private->mapped = FALSE;
XUnmapWindow (private->drawable.xdisplay, private->drawable.xwindow);
XUnmapWindow (GDK_DRAWABLE_XDISPLAY (window),
GDK_DRAWABLE_XID (window));
}
}
@ -779,7 +653,8 @@ gdk_window_withdraw (GdkWindow *window)
private = (GdkWindowPrivate*) window;
if (!private->drawable.destroyed)
XWithdrawWindow (private->drawable.xdisplay, private->drawable.xwindow, 0);
XWithdrawWindow (GDK_DRAWABLE_XDISPLAY (window),
GDK_DRAWABLE_XID (window), 0);
}
void
@ -794,7 +669,9 @@ gdk_window_move (GdkWindow *window,
private = (GdkWindowPrivate*) window;
if (!private->drawable.destroyed)
{
XMoveWindow (private->drawable.xdisplay, private->drawable.xwindow, x, y);
XMoveWindow (GDK_DRAWABLE_XDISPLAY (window),
GDK_DRAWABLE_XID (window),
x, y);
if (private->drawable.window_type == GDK_WINDOW_CHILD)
{
@ -904,7 +781,7 @@ gdk_window_reparent (GdkWindow *window,
g_return_if_fail (GDK_IS_WINDOW (new_parent));
if (!new_parent)
new_parent = (GdkWindow*) &gdk_root_parent;
new_parent = gdk_parent_root;
window_private = (GdkWindowPrivate*) window;
old_parent_private = (GdkWindowPrivate*)window_private->parent;
@ -989,15 +866,6 @@ gdk_window_lower (GdkWindow *window)
XLowerWindow (GDK_DRAWABLE_XDISPLAY (window), GDK_DRAWABLE_XID (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_set_hints (GdkWindow *window,
gint x,
@ -1243,15 +1111,6 @@ gdk_window_set_cursor (GdkWindow *window,
xcursor);
}
void
gdk_window_get_user_data (GdkWindow *window,
gpointer *data)
{
g_return_if_fail (window != NULL);
*data = window->user_data;
}
void
gdk_window_get_geometry (GdkWindow *window,
gint *x,
@ -1271,7 +1130,7 @@ gdk_window_get_geometry (GdkWindow *window,
g_return_if_fail (window == NULL || GDK_IS_WINDOW (window));
if (!window)
window = (GdkWindow *) &gdk_root_parent;
window = gdk_parent_root;
if (!GDK_DRAWABLE_DESTROYED (window))
{
@ -1292,24 +1151,6 @@ gdk_window_get_geometry (GdkWindow *window,
}
}
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;
}
gint
gdk_window_get_origin (GdkWindow *window,
gint *x,
@ -1481,7 +1322,7 @@ gdk_window_get_pointer (GdkWindow *window,
g_return_val_if_fail (window == NULL || GDK_IS_WINDOW (window), NULL);
if (!window)
window = (GdkWindow*) &gdk_root_parent;
window = gdk_parent_root;
return_val = NULL;
if (!GDK_DRAWABLE_DESTROYED (window) &&
@ -1507,31 +1348,29 @@ GdkWindow*
gdk_window_at_pointer (gint *win_x,
gint *win_y)
{
GdkWindowPrivate *private;
GdkWindow *window;
Window root;
Window xwindow;
Window xwindow_last = 0;
Display *xdisplay;
int rootx = -1, rooty = -1;
int winx, winy;
unsigned int xmask;
private = &gdk_root_parent;
xwindow = GDK_ROOT_WINDOW ();
xdisplay = GDK_DISPLAY ();
xwindow = private->drawable.xwindow;
XGrabServer (private->drawable.xdisplay);
XGrabServer (xdisplay);
while (xwindow)
{
xwindow_last = xwindow;
XQueryPointer (private->drawable.xdisplay,
xwindow,
XQueryPointer (xdisplay, xwindow,
&root, &xwindow,
&rootx, &rooty,
&winx, &winy,
&xmask);
}
XUngrabServer (private->drawable.xdisplay);
XUngrabServer (xdisplay);
window = gdk_window_lookup (xwindow_last);
@ -1543,30 +1382,6 @@ gdk_window_at_pointer (gint *win_x,
return window;
}
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;
}
GList*
gdk_window_get_children (GdkWindow *window)
{
@ -1765,84 +1580,6 @@ gdk_window_shape_combine_mask (GdkWindow *window,
#endif /* HAVE_SHAPE_EXT */
}
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;
}
}
}
void
gdk_window_set_override_redirect (GdkWindow *window,
gboolean override_redirect)
@ -2038,29 +1775,12 @@ gdk_window_set_functions (GdkWindow *window,
gdk_window_set_mwm_hints (window, &hints);
}
GList *
gdk_window_get_toplevels (void)
{
GList *new_list = NULL;
GList *tmp_list;
tmp_list = gdk_root_parent.children;
while (tmp_list)
{
new_list = g_list_prepend (new_list, tmp_list->data);
tmp_list = tmp_list->next;
}
return new_list;
}
/*
* propagate the shapes from all child windows of a GDK window to the parent
* window. Shamelessly ripped from Enlightenment's code
*
* - Raster
*/
struct _gdk_span
{
gint start;
@ -2395,59 +2115,6 @@ gdk_window_merge_child_shapes (GdkWindow *window)
#endif
}
/*************************************************************
* 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 != &gdk_root_parent) &&
(private->drawable.window_type != GDK_WINDOW_FOREIGN))
{
if (!private->mapped)
return FALSE;
private = (GdkWindowPrivate *)private->parent;
}
return TRUE;
}
/* Support for windows that can be guffaw-scrolled
* (See http://www.gtk.org/~otaylor/whitepapers/guffaw-scrolling.txt)
*/
@ -2581,3 +2248,135 @@ gdk_window_set_static_gravities (GdkWindow *window,
return TRUE;
}
/* internal function created for and used by gdk_window_xid_at_coords */
Window
gdk_window_xid_at (Window base,
gint bx,
gint by,
gint x,
gint y,
GList *excludes,
gboolean excl_child)
{
Display *xdisplay;
Window *list = NULL;
Window child = 0, parent_win = 0, root_win = 0;
int i;
unsigned int ww, wh, wb, wd, num;
int wx, wy;
xdisplay = GDK_DISPLAY ();
if (!XGetGeometry (xdisplay, base, &root_win, &wx, &wy, &ww, &wh, &wb, &wd))
return 0;
wx += bx;
wy += by;
if (!((x >= wx) &&
(y >= wy) &&
(x < (int) (wx + ww)) &&
(y < (int) (wy + wh))))
return 0;
if (!XQueryTree (xdisplay, base, &root_win, &parent_win, &list, &num))
return base;
if (list)
{
for (i = num - 1; ; i--)
{
if ((!excl_child) || (!g_list_find (excludes, (gpointer *) list[i])))
{
if ((child = gdk_window_xid_at (list[i], wx, wy, x, y, excludes, excl_child)) != 0)
{
XFree (list);
return child;
}
}
if (!i)
break;
}
XFree (list);
}
return base;
}
/*
* The following fucntion by The Rasterman <raster@redhat.com>
* This function returns the X Window ID in which the x y location is in
* (x and y being relative to the root window), excluding any windows listed
* in the GList excludes (this is a list of X Window ID's - gpointer being
* the Window ID).
*
* This is primarily designed for internal gdk use - for DND for example
* when using a shaped icon window as the drag object - you exclude the
* X Window ID of the "icon" (perhaps more if excludes may be needed) and
* You can get back an X Window ID as to what X Window ID is infact under
* those X,Y co-ordinates.
*/
Window
gdk_window_xid_at_coords (gint x,
gint y,
GList *excludes,
gboolean excl_child)
{
GdkWindow *window;
GdkDrawablePrivate *private;
Display *xdisplay;
Window *list = NULL;
Window root, child = 0, parent_win = 0, root_win = 0;
unsigned int num;
int i;
window = gdk_parent_root;
private = (GdkDrawablePrivate*) window;
xdisplay = GDK_DRAWABLE_XDISPLAY (private);
root = GDK_DRAWABLE_XID (private);
num = g_list_length (excludes);
XGrabServer (xdisplay);
if (!XQueryTree (xdisplay, root, &root_win, &parent_win, &list, &num))
{
XUngrabServer (xdisplay);
return root;
}
if (list)
{
i = num - 1;
do
{
XWindowAttributes xwa;
XGetWindowAttributes (xdisplay, list [i], &xwa);
if (xwa.map_state != IsViewable)
continue;
if (excl_child && g_list_find (excludes, (gpointer *) list[i]))
continue;
if ((child = gdk_window_xid_at (list[i], 0, 0, x, y, excludes, excl_child)) == 0)
continue;
if (excludes)
{
if (!g_list_find (excludes, (gpointer *) child))
{
XFree (list);
XUngrabServer (xdisplay);
return child;
}
}
else
{
XFree (list);
XUngrabServer (xdisplay);
return child;
}
} while (--i > 0);
XFree (list);
}
XUngrabServer (xdisplay);
return root;
}

View File

@ -27,26 +27,25 @@
#ifndef __GDK_X_H__
#define __GDK_X_H__
#include <gdk/gdkprivate.h>
#include <gdk/x11/gdkprivate-x11.h>
#define GDK_ROOT_WINDOW() gdk_root_window
#define GDK_ROOT_PARENT() ((GdkWindow *)&gdk_root_parent)
#define GDK_ROOT_PARENT() ((GdkWindow *)&gdk_parent_root)
#define GDK_DISPLAY() gdk_display
#define GDK_DRAWABLE_XDISPLAY(win) (((GdkDrawablePrivate*) win)->xdisplay)
#define GDK_DRAWABLE_XID(win) (((GdkDrawablePrivate*) win)->xwindow)
#define GDK_WINDOW_XDISPLAY GDK_DRAWABLE_XDISPLAY
#define GDK_WINDOW_XWINDOW GDK_DRAWABLE_XID
#define GDK_DRAWABLE_XDISPLAY(win) (GDK_DRAWABLE_XDATA(win)->xdisplay)
#define GDK_DRAWABLE_XID(win) (GDK_DRAWABLE_XDATA(win)->xid)
#define GDK_IMAGE_XDISPLAY(image) (((GdkImagePrivate*) image)->xdisplay)
#define GDK_IMAGE_XIMAGE(image) (((GdkImagePrivate*) image)->ximage)
#define GDK_GC_XDISPLAY(gc) (((GdkGCPrivate*) gc)->xdisplay)
#define GDK_GC_XGC(gc) (((GdkGCPrivate*) gc)->xgc)
#define GDK_COLORMAP_XDISPLAY(cmap) (((GdkColormapPrivate*) cmap)->xdisplay)
#define GDK_COLORMAP_XCOLORMAP(cmap) (((GdkColormapPrivate*) cmap)->xcolormap)
#define GDK_GC_XDISPLAY(gc) (GDK_GC_XDATA(gc)->xdisplay)
#define GDK_GC_XGC(gc) (GDK_GC_XDATA(gc)->xgc)
#define GDK_COLORMAP_XDISPLAY(cmap) (((GdkColormapPrivateX *)cmap)->xdisplay)
#define GDK_COLORMAP_XCOLORMAP(cmap) (((GdkColormapPrivateX *)cmap)->xcolormap)
#define GDK_VISUAL_XVISUAL(vis) (((GdkVisualPrivate*) vis)->xvisual)
#define GDK_FONT_XDISPLAY(font) (((GdkFontPrivate*) font)->xdisplay)
#define GDK_FONT_XFONT(font) (((GdkFontPrivate*) font)->xfont)
#define GDK_FONT_XFONT(font) (((GdkFontPrivateX *)font)->xfont)
#define GDK_WINDOW_XWINDOW GDK_DRAWABLE_XID
#define GDK_WINDOW_XDISPLAY GDK_DRAWABLE_XDISPLAY
GdkVisual* gdkx_visual_get (VisualID xvisualid);
/* XXX: Do not use this function until it is fixed. An X Colormap

View File

@ -24,7 +24,7 @@
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#include "gdkprivate.h"
#include "gdkprivate-x11.h"
#include <stdio.h>
static guint gdk_xid_hash (XID *xid);

View File

@ -418,6 +418,7 @@ INCLUDES = \
-DGTK_LOCALEDIR=\"$(gtklocaledir)\" \
-I$(top_srcdir) -I../gdk \
-I$(top_srcdir)/gdk \
-I$(top_srcdir)/gdk/x11 \
@GTK_DEBUG_FLAGS@ \
@GTK_XIM_FLAGS@ \
@GTK_LOCALE_FLAGS@ \

View File

@ -411,7 +411,6 @@ struct _GtkWidgetShapeInfo
GdkBitmap *shape_mask;
};
GtkType gtk_widget_get_type (void);
GtkWidget* gtk_widget_new (GtkType type,
const gchar *first_arg_name,

View File

@ -14,7 +14,8 @@ main (int argc, char *argv[])
GtkWidget *window;
GtkWidget *button;
gdk_progclass = g_strdup ("XTerm");
/* FIXME: This is not allowable - what is this supposed to be? */
/* gdk_progclass = g_strdup ("XTerm"); */
gtk_init (&argc, &argv);
window = gtk_widget_new (gtk_window_get_type (),

View File

@ -14,7 +14,8 @@ main (int argc, char *argv[])
GtkWidget *window;
GtkWidget *button;
gdk_progclass = g_strdup ("XTerm");
/* FIXME: This is not allowable - what is this supposed to be? */
/* gdk_progclass = g_strdup ("XTerm"); */
gtk_init (&argc, &argv);
window = gtk_widget_new (gtk_window_get_type (),