Destroy widgets _after_ propagating unrealize signals through the widget

Mon Dec  7 10:27:09 1998  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkwidget.c: Destroy widgets _after_ propagating unrealize
	signals through the widget heirarchy. This is unpleasant, as it
	causes more X traffic, but is necessary, because we have to clean
	up our Input Contexts before destroying the X windows.
	(from matsu-981109-0.patch)

Mon Dec  7 10:18:18 1998  Owen Taylor  <otaylor@redhat.com>

	Applied gtk-a-higuti-981202-0 :
	[ a-higuti@math.sci.hokudai.ac.jp (Akira Higuchi) ]

	* gdk/gdk.h gdk/gdk.c
		(gdk_mbstowcs): New function. Nearly equals to mbstowcs, but
			implemented by a combination of Xlib functions, so
			it works even with X_LOCALE.
		(gdk_wcstombs): New function.
		(g_mbtowc): Removed. No longer needed.

	* gdk/gdk.h gdk/gdkfont.c gdk/gdkdraw.c:
	        Added _wc() variants to gdk_text_width(),
		gdk_char_width(), gdk_draw_text(),

	* gdk/gdki18n.h
		(mblen, mbtowc, wctomb, mbstowcs, wcstombs,
		 wcslen, wcscpy, wcsncpy):
			Removed. No longer needed.
		(iswalnum): Removed.
		(gdk_iswalnum): New macro.
		(gdk_iswspace): New macro.
	* gdk/gdktype.h
		(GdkWChar): New typedef.

	* gtk/gtkentry.h, gtk/gtkentry.c
		There are many changes according to the change of the
		internal representation of text, from multibyte string
		to wide characters.
	* gtk/gtkprivate.h, gtk/gtkmain.c
		Removed the variable gtk_use_mb and related codes.
	* gtk/gtkspinbutton.c
		Some changes according to the change of type of entry->text.
	* gtk/gtktext.h, gtk/gtktext.c
		Changed the internal representation of text. We use GdkWchar
		if a fontset is supplied. If not, we use guchar to save
		memory.
This commit is contained in:
Owen Taylor 1998-12-09 06:36:57 +00:00 committed by Owen Taylor
parent af84227184
commit 207757e70d
35 changed files with 1931 additions and 2297 deletions

View File

@ -1,3 +1,80 @@
Mon Dec 7 10:27:09 1998 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c: Destroy widgets _after_ propagating unrealize
signals through the widget heirarchy. This is unpleasant, as it
causes more X traffic, but is necessary, because we have to clean
up our Input Contexts before destroying the X windows.
(from matsu-981109-0.patch)
Mon Dec 7 10:18:18 1998 Owen Taylor <otaylor@redhat.com>
Applied gtk-a-higuti-981202-0 :
[ a-higuti@math.sci.hokudai.ac.jp (Akira Higuchi) ]
* gdk/gdk.h gdk/gdk.c
(gdk_mbstowcs): New function. Nearly equals to mbstowcs, but
implemented by a combination of Xlib functions, so
it works even with X_LOCALE.
(gdk_wcstombs): New function.
(g_mbtowc): Removed. No longer needed.
* gdk/gdk.h gdk/gdkfont.c gdk/gdkdraw.c:
Added _wc() variants to gdk_text_width(),
gdk_char_width(), gdk_draw_text(),
* gdk/gdki18n.h
(mblen, mbtowc, wctomb, mbstowcs, wcstombs,
wcslen, wcscpy, wcsncpy):
Removed. No longer needed.
(iswalnum): Removed.
(gdk_iswalnum): New macro.
(gdk_iswspace): New macro.
* gdk/gdktype.h
(GdkWChar): New typedef.
* gtk/gtkentry.h, gtk/gtkentry.c
There are many changes according to the change of the
internal representation of text, from multibyte string
to wide characters.
* gtk/gtkprivate.h, gtk/gtkmain.c
Removed the variable gtk_use_mb and related codes.
* gtk/gtkspinbutton.c
Some changes according to the change of type of entry->text.
* gtk/gtktext.h, gtk/gtktext.c
Changed the internal representation of text. We use GdkWchar
if a fontset is supplied. If not, we use guchar to save
memory.
Tue Dec 1 15:20:39 1998 Owen Taylor <otaylor@redhat.com>
* gdk/gdkwindow.c (gdk_window_new): When creating
a window with a specified non-system visual, use
a matching colormap.
Mon Nov 30 11:50:13 1998 Owen Taylor <otaylor@redhat.com>
* gdk/gdk.c gdk/gdkim.c gdk/gdkprivate.h gdk/gdk.h
gdk/gdktypes.h gtk/gtkeditable.c gtk/gtkmain.c
gtk/gtkentry.c gtk/gtktext.c:
Applied matsu-981109-0
[ matsu@arch.comp.kyutech.ac.jp (Takashi Matsuda) ]
- Change system of setting input method values
from varargs to a structure, similar to GC's
or window attributes.
- Various fixes to event handling.
Also:
* gdk/gdkim.c: Split of input method stuff into
a separate source file.
* Remove GdkIM typedef, change everything from
GdkIC to GdkIC * to be consistent with the
rest of GTK.
Wed Dec 9 00:41:41 1998 Owen Taylor <otaylor@redhat.com>
* gtk/gtkrc.c (gtk_rc_add_initial_default_files): Allocate

View File

@ -1,3 +1,80 @@
Mon Dec 7 10:27:09 1998 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c: Destroy widgets _after_ propagating unrealize
signals through the widget heirarchy. This is unpleasant, as it
causes more X traffic, but is necessary, because we have to clean
up our Input Contexts before destroying the X windows.
(from matsu-981109-0.patch)
Mon Dec 7 10:18:18 1998 Owen Taylor <otaylor@redhat.com>
Applied gtk-a-higuti-981202-0 :
[ a-higuti@math.sci.hokudai.ac.jp (Akira Higuchi) ]
* gdk/gdk.h gdk/gdk.c
(gdk_mbstowcs): New function. Nearly equals to mbstowcs, but
implemented by a combination of Xlib functions, so
it works even with X_LOCALE.
(gdk_wcstombs): New function.
(g_mbtowc): Removed. No longer needed.
* gdk/gdk.h gdk/gdkfont.c gdk/gdkdraw.c:
Added _wc() variants to gdk_text_width(),
gdk_char_width(), gdk_draw_text(),
* gdk/gdki18n.h
(mblen, mbtowc, wctomb, mbstowcs, wcstombs,
wcslen, wcscpy, wcsncpy):
Removed. No longer needed.
(iswalnum): Removed.
(gdk_iswalnum): New macro.
(gdk_iswspace): New macro.
* gdk/gdktype.h
(GdkWChar): New typedef.
* gtk/gtkentry.h, gtk/gtkentry.c
There are many changes according to the change of the
internal representation of text, from multibyte string
to wide characters.
* gtk/gtkprivate.h, gtk/gtkmain.c
Removed the variable gtk_use_mb and related codes.
* gtk/gtkspinbutton.c
Some changes according to the change of type of entry->text.
* gtk/gtktext.h, gtk/gtktext.c
Changed the internal representation of text. We use GdkWchar
if a fontset is supplied. If not, we use guchar to save
memory.
Tue Dec 1 15:20:39 1998 Owen Taylor <otaylor@redhat.com>
* gdk/gdkwindow.c (gdk_window_new): When creating
a window with a specified non-system visual, use
a matching colormap.
Mon Nov 30 11:50:13 1998 Owen Taylor <otaylor@redhat.com>
* gdk/gdk.c gdk/gdkim.c gdk/gdkprivate.h gdk/gdk.h
gdk/gdktypes.h gtk/gtkeditable.c gtk/gtkmain.c
gtk/gtkentry.c gtk/gtktext.c:
Applied matsu-981109-0
[ matsu@arch.comp.kyutech.ac.jp (Takashi Matsuda) ]
- Change system of setting input method values
from varargs to a structure, similar to GC's
or window attributes.
- Various fixes to event handling.
Also:
* gdk/gdkim.c: Split of input method stuff into
a separate source file.
* Remove GdkIM typedef, change everything from
GdkIC to GdkIC * to be consistent with the
rest of GTK.
Wed Dec 9 00:41:41 1998 Owen Taylor <otaylor@redhat.com>
* gtk/gtkrc.c (gtk_rc_add_initial_default_files): Allocate

View File

@ -1,3 +1,80 @@
Mon Dec 7 10:27:09 1998 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c: Destroy widgets _after_ propagating unrealize
signals through the widget heirarchy. This is unpleasant, as it
causes more X traffic, but is necessary, because we have to clean
up our Input Contexts before destroying the X windows.
(from matsu-981109-0.patch)
Mon Dec 7 10:18:18 1998 Owen Taylor <otaylor@redhat.com>
Applied gtk-a-higuti-981202-0 :
[ a-higuti@math.sci.hokudai.ac.jp (Akira Higuchi) ]
* gdk/gdk.h gdk/gdk.c
(gdk_mbstowcs): New function. Nearly equals to mbstowcs, but
implemented by a combination of Xlib functions, so
it works even with X_LOCALE.
(gdk_wcstombs): New function.
(g_mbtowc): Removed. No longer needed.
* gdk/gdk.h gdk/gdkfont.c gdk/gdkdraw.c:
Added _wc() variants to gdk_text_width(),
gdk_char_width(), gdk_draw_text(),
* gdk/gdki18n.h
(mblen, mbtowc, wctomb, mbstowcs, wcstombs,
wcslen, wcscpy, wcsncpy):
Removed. No longer needed.
(iswalnum): Removed.
(gdk_iswalnum): New macro.
(gdk_iswspace): New macro.
* gdk/gdktype.h
(GdkWChar): New typedef.
* gtk/gtkentry.h, gtk/gtkentry.c
There are many changes according to the change of the
internal representation of text, from multibyte string
to wide characters.
* gtk/gtkprivate.h, gtk/gtkmain.c
Removed the variable gtk_use_mb and related codes.
* gtk/gtkspinbutton.c
Some changes according to the change of type of entry->text.
* gtk/gtktext.h, gtk/gtktext.c
Changed the internal representation of text. We use GdkWchar
if a fontset is supplied. If not, we use guchar to save
memory.
Tue Dec 1 15:20:39 1998 Owen Taylor <otaylor@redhat.com>
* gdk/gdkwindow.c (gdk_window_new): When creating
a window with a specified non-system visual, use
a matching colormap.
Mon Nov 30 11:50:13 1998 Owen Taylor <otaylor@redhat.com>
* gdk/gdk.c gdk/gdkim.c gdk/gdkprivate.h gdk/gdk.h
gdk/gdktypes.h gtk/gtkeditable.c gtk/gtkmain.c
gtk/gtkentry.c gtk/gtktext.c:
Applied matsu-981109-0
[ matsu@arch.comp.kyutech.ac.jp (Takashi Matsuda) ]
- Change system of setting input method values
from varargs to a structure, similar to GC's
or window attributes.
- Various fixes to event handling.
Also:
* gdk/gdkim.c: Split of input method stuff into
a separate source file.
* Remove GdkIM typedef, change everything from
GdkIC to GdkIC * to be consistent with the
rest of GTK.
Wed Dec 9 00:41:41 1998 Owen Taylor <otaylor@redhat.com>
* gtk/gtkrc.c (gtk_rc_add_initial_default_files): Allocate

View File

@ -1,3 +1,80 @@
Mon Dec 7 10:27:09 1998 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c: Destroy widgets _after_ propagating unrealize
signals through the widget heirarchy. This is unpleasant, as it
causes more X traffic, but is necessary, because we have to clean
up our Input Contexts before destroying the X windows.
(from matsu-981109-0.patch)
Mon Dec 7 10:18:18 1998 Owen Taylor <otaylor@redhat.com>
Applied gtk-a-higuti-981202-0 :
[ a-higuti@math.sci.hokudai.ac.jp (Akira Higuchi) ]
* gdk/gdk.h gdk/gdk.c
(gdk_mbstowcs): New function. Nearly equals to mbstowcs, but
implemented by a combination of Xlib functions, so
it works even with X_LOCALE.
(gdk_wcstombs): New function.
(g_mbtowc): Removed. No longer needed.
* gdk/gdk.h gdk/gdkfont.c gdk/gdkdraw.c:
Added _wc() variants to gdk_text_width(),
gdk_char_width(), gdk_draw_text(),
* gdk/gdki18n.h
(mblen, mbtowc, wctomb, mbstowcs, wcstombs,
wcslen, wcscpy, wcsncpy):
Removed. No longer needed.
(iswalnum): Removed.
(gdk_iswalnum): New macro.
(gdk_iswspace): New macro.
* gdk/gdktype.h
(GdkWChar): New typedef.
* gtk/gtkentry.h, gtk/gtkentry.c
There are many changes according to the change of the
internal representation of text, from multibyte string
to wide characters.
* gtk/gtkprivate.h, gtk/gtkmain.c
Removed the variable gtk_use_mb and related codes.
* gtk/gtkspinbutton.c
Some changes according to the change of type of entry->text.
* gtk/gtktext.h, gtk/gtktext.c
Changed the internal representation of text. We use GdkWchar
if a fontset is supplied. If not, we use guchar to save
memory.
Tue Dec 1 15:20:39 1998 Owen Taylor <otaylor@redhat.com>
* gdk/gdkwindow.c (gdk_window_new): When creating
a window with a specified non-system visual, use
a matching colormap.
Mon Nov 30 11:50:13 1998 Owen Taylor <otaylor@redhat.com>
* gdk/gdk.c gdk/gdkim.c gdk/gdkprivate.h gdk/gdk.h
gdk/gdktypes.h gtk/gtkeditable.c gtk/gtkmain.c
gtk/gtkentry.c gtk/gtktext.c:
Applied matsu-981109-0
[ matsu@arch.comp.kyutech.ac.jp (Takashi Matsuda) ]
- Change system of setting input method values
from varargs to a structure, similar to GC's
or window attributes.
- Various fixes to event handling.
Also:
* gdk/gdkim.c: Split of input method stuff into
a separate source file.
* Remove GdkIM typedef, change everything from
GdkIC to GdkIC * to be consistent with the
rest of GTK.
Wed Dec 9 00:41:41 1998 Owen Taylor <otaylor@redhat.com>
* gtk/gtkrc.c (gtk_rc_add_initial_default_files): Allocate

View File

@ -1,3 +1,80 @@
Mon Dec 7 10:27:09 1998 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c: Destroy widgets _after_ propagating unrealize
signals through the widget heirarchy. This is unpleasant, as it
causes more X traffic, but is necessary, because we have to clean
up our Input Contexts before destroying the X windows.
(from matsu-981109-0.patch)
Mon Dec 7 10:18:18 1998 Owen Taylor <otaylor@redhat.com>
Applied gtk-a-higuti-981202-0 :
[ a-higuti@math.sci.hokudai.ac.jp (Akira Higuchi) ]
* gdk/gdk.h gdk/gdk.c
(gdk_mbstowcs): New function. Nearly equals to mbstowcs, but
implemented by a combination of Xlib functions, so
it works even with X_LOCALE.
(gdk_wcstombs): New function.
(g_mbtowc): Removed. No longer needed.
* gdk/gdk.h gdk/gdkfont.c gdk/gdkdraw.c:
Added _wc() variants to gdk_text_width(),
gdk_char_width(), gdk_draw_text(),
* gdk/gdki18n.h
(mblen, mbtowc, wctomb, mbstowcs, wcstombs,
wcslen, wcscpy, wcsncpy):
Removed. No longer needed.
(iswalnum): Removed.
(gdk_iswalnum): New macro.
(gdk_iswspace): New macro.
* gdk/gdktype.h
(GdkWChar): New typedef.
* gtk/gtkentry.h, gtk/gtkentry.c
There are many changes according to the change of the
internal representation of text, from multibyte string
to wide characters.
* gtk/gtkprivate.h, gtk/gtkmain.c
Removed the variable gtk_use_mb and related codes.
* gtk/gtkspinbutton.c
Some changes according to the change of type of entry->text.
* gtk/gtktext.h, gtk/gtktext.c
Changed the internal representation of text. We use GdkWchar
if a fontset is supplied. If not, we use guchar to save
memory.
Tue Dec 1 15:20:39 1998 Owen Taylor <otaylor@redhat.com>
* gdk/gdkwindow.c (gdk_window_new): When creating
a window with a specified non-system visual, use
a matching colormap.
Mon Nov 30 11:50:13 1998 Owen Taylor <otaylor@redhat.com>
* gdk/gdk.c gdk/gdkim.c gdk/gdkprivate.h gdk/gdk.h
gdk/gdktypes.h gtk/gtkeditable.c gtk/gtkmain.c
gtk/gtkentry.c gtk/gtktext.c:
Applied matsu-981109-0
[ matsu@arch.comp.kyutech.ac.jp (Takashi Matsuda) ]
- Change system of setting input method values
from varargs to a structure, similar to GC's
or window attributes.
- Various fixes to event handling.
Also:
* gdk/gdkim.c: Split of input method stuff into
a separate source file.
* Remove GdkIM typedef, change everything from
GdkIC to GdkIC * to be consistent with the
rest of GTK.
Wed Dec 9 00:41:41 1998 Owen Taylor <otaylor@redhat.com>
* gtk/gtkrc.c (gtk_rc_add_initial_default_files): Allocate

View File

@ -1,3 +1,80 @@
Mon Dec 7 10:27:09 1998 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c: Destroy widgets _after_ propagating unrealize
signals through the widget heirarchy. This is unpleasant, as it
causes more X traffic, but is necessary, because we have to clean
up our Input Contexts before destroying the X windows.
(from matsu-981109-0.patch)
Mon Dec 7 10:18:18 1998 Owen Taylor <otaylor@redhat.com>
Applied gtk-a-higuti-981202-0 :
[ a-higuti@math.sci.hokudai.ac.jp (Akira Higuchi) ]
* gdk/gdk.h gdk/gdk.c
(gdk_mbstowcs): New function. Nearly equals to mbstowcs, but
implemented by a combination of Xlib functions, so
it works even with X_LOCALE.
(gdk_wcstombs): New function.
(g_mbtowc): Removed. No longer needed.
* gdk/gdk.h gdk/gdkfont.c gdk/gdkdraw.c:
Added _wc() variants to gdk_text_width(),
gdk_char_width(), gdk_draw_text(),
* gdk/gdki18n.h
(mblen, mbtowc, wctomb, mbstowcs, wcstombs,
wcslen, wcscpy, wcsncpy):
Removed. No longer needed.
(iswalnum): Removed.
(gdk_iswalnum): New macro.
(gdk_iswspace): New macro.
* gdk/gdktype.h
(GdkWChar): New typedef.
* gtk/gtkentry.h, gtk/gtkentry.c
There are many changes according to the change of the
internal representation of text, from multibyte string
to wide characters.
* gtk/gtkprivate.h, gtk/gtkmain.c
Removed the variable gtk_use_mb and related codes.
* gtk/gtkspinbutton.c
Some changes according to the change of type of entry->text.
* gtk/gtktext.h, gtk/gtktext.c
Changed the internal representation of text. We use GdkWchar
if a fontset is supplied. If not, we use guchar to save
memory.
Tue Dec 1 15:20:39 1998 Owen Taylor <otaylor@redhat.com>
* gdk/gdkwindow.c (gdk_window_new): When creating
a window with a specified non-system visual, use
a matching colormap.
Mon Nov 30 11:50:13 1998 Owen Taylor <otaylor@redhat.com>
* gdk/gdk.c gdk/gdkim.c gdk/gdkprivate.h gdk/gdk.h
gdk/gdktypes.h gtk/gtkeditable.c gtk/gtkmain.c
gtk/gtkentry.c gtk/gtktext.c:
Applied matsu-981109-0
[ matsu@arch.comp.kyutech.ac.jp (Takashi Matsuda) ]
- Change system of setting input method values
from varargs to a structure, similar to GC's
or window attributes.
- Various fixes to event handling.
Also:
* gdk/gdkim.c: Split of input method stuff into
a separate source file.
* Remove GdkIM typedef, change everything from
GdkIC to GdkIC * to be consistent with the
rest of GTK.
Wed Dec 9 00:41:41 1998 Owen Taylor <otaylor@redhat.com>
* gtk/gtkrc.c (gtk_rc_add_initial_default_files): Allocate

View File

@ -1,3 +1,80 @@
Mon Dec 7 10:27:09 1998 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c: Destroy widgets _after_ propagating unrealize
signals through the widget heirarchy. This is unpleasant, as it
causes more X traffic, but is necessary, because we have to clean
up our Input Contexts before destroying the X windows.
(from matsu-981109-0.patch)
Mon Dec 7 10:18:18 1998 Owen Taylor <otaylor@redhat.com>
Applied gtk-a-higuti-981202-0 :
[ a-higuti@math.sci.hokudai.ac.jp (Akira Higuchi) ]
* gdk/gdk.h gdk/gdk.c
(gdk_mbstowcs): New function. Nearly equals to mbstowcs, but
implemented by a combination of Xlib functions, so
it works even with X_LOCALE.
(gdk_wcstombs): New function.
(g_mbtowc): Removed. No longer needed.
* gdk/gdk.h gdk/gdkfont.c gdk/gdkdraw.c:
Added _wc() variants to gdk_text_width(),
gdk_char_width(), gdk_draw_text(),
* gdk/gdki18n.h
(mblen, mbtowc, wctomb, mbstowcs, wcstombs,
wcslen, wcscpy, wcsncpy):
Removed. No longer needed.
(iswalnum): Removed.
(gdk_iswalnum): New macro.
(gdk_iswspace): New macro.
* gdk/gdktype.h
(GdkWChar): New typedef.
* gtk/gtkentry.h, gtk/gtkentry.c
There are many changes according to the change of the
internal representation of text, from multibyte string
to wide characters.
* gtk/gtkprivate.h, gtk/gtkmain.c
Removed the variable gtk_use_mb and related codes.
* gtk/gtkspinbutton.c
Some changes according to the change of type of entry->text.
* gtk/gtktext.h, gtk/gtktext.c
Changed the internal representation of text. We use GdkWchar
if a fontset is supplied. If not, we use guchar to save
memory.
Tue Dec 1 15:20:39 1998 Owen Taylor <otaylor@redhat.com>
* gdk/gdkwindow.c (gdk_window_new): When creating
a window with a specified non-system visual, use
a matching colormap.
Mon Nov 30 11:50:13 1998 Owen Taylor <otaylor@redhat.com>
* gdk/gdk.c gdk/gdkim.c gdk/gdkprivate.h gdk/gdk.h
gdk/gdktypes.h gtk/gtkeditable.c gtk/gtkmain.c
gtk/gtkentry.c gtk/gtktext.c:
Applied matsu-981109-0
[ matsu@arch.comp.kyutech.ac.jp (Takashi Matsuda) ]
- Change system of setting input method values
from varargs to a structure, similar to GC's
or window attributes.
- Various fixes to event handling.
Also:
* gdk/gdkim.c: Split of input method stuff into
a separate source file.
* Remove GdkIM typedef, change everything from
GdkIC to GdkIC * to be consistent with the
rest of GTK.
Wed Dec 9 00:41:41 1998 Owen Taylor <otaylor@redhat.com>
* gtk/gtkrc.c (gtk_rc_add_initial_default_files): Allocate

View File

@ -24,6 +24,7 @@ libgdk_la_SOURCES = \
gdkfont.c \
gdkgc.c \
gdkglobals.c \
gdkim.c \
gdkimage.c \
gdkinput.c \
gdkinput.h \
@ -53,7 +54,7 @@ gdkinclude_HEADERS = \
gdk.h \
gdkcursors.h \
gdkrgb.h \
gdki18n.h \
gdki18n.h \
gdkkeysyms.h \
gdkprivate.h \
gdktypes.h \

774
gdk/gdk.c
View File

@ -28,9 +28,6 @@
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#ifdef USE_XIM
#include <stdarg.h>
#endif
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
@ -42,16 +39,13 @@
#include <X11/Xos.h>
#include <X11/Xutil.h>
#include <X11/Xmu/WinUtil.h>
#ifdef USE_XIM
#include <X11/Xresource.h>
#endif
#include <X11/cursorfont.h>
#include "gdk.h"
#include "gdkprivate.h"
#include "gdkinput.h"
#include "gdki18n.h"
#include "gdkx.h"
#include "gdkkeysyms.h"
#include "gdki18n.h"
#ifndef X_GETTIMEOFDAY
#define X_GETTIMEOFDAY(tv) gettimeofday (tv, NULL)
@ -139,21 +133,6 @@ static int gdk_x_error (Display *display,
static int gdk_x_io_error (Display *display);
static RETSIGTYPE gdk_signal (int signum);
#ifdef USE_XIM
static guint gdk_im_va_count (va_list list);
static XVaNestedList gdk_im_va_to_nested (va_list list,
guint count);
static GdkIM gdk_im_get (void);
static gint gdk_im_open (XrmDatabase db,
gchar* res_name,
gchar* rec_class);
static void gdk_im_close (void);
static void gdk_ic_cleanup (void);
#endif /* USE_XIM */
GdkFilterReturn gdk_wm_protocols_filter (GdkXEvent *xev,
GdkEvent *event,
gpointer data);
@ -212,17 +191,6 @@ static GdkWindowPrivate *xgrab_window = NULL; /* Window that currently holds
static GList *client_filters; /* Filters for client messages */
#ifdef USE_XIM
static gint xim_using; /* using XIM Protocol if TRUE */
static GdkIM xim_im; /* global IM */
static XIMStyles* xim_styles; /* im supports these styles */
static XIMStyle xim_best_allowed_style;
static GdkICPrivate *xim_ic; /* currently using IC */
static GdkWindow* xim_window; /* currently using Widow */
static GList* xim_ic_list;
#endif
static GList *putback_events = NULL;
static gulong base_id;
@ -570,18 +538,7 @@ gdk_init (int *argc,
gdk_wm_protocols_filter, NULL);
#ifdef USE_XIM
/* initialize XIM Protocol variables */
xim_using = FALSE;
xim_im = NULL;
xim_styles = NULL;
if (!(xim_best_allowed_style & GDK_IM_PREEDIT_MASK))
gdk_im_set_best_style (GDK_IM_PREEDIT_CALLBACKS);
if (!(xim_best_allowed_style & GDK_IM_STATUS_MASK))
gdk_im_set_best_style (GDK_IM_STATUS_CALLBACKS);
xim_ic = NULL;
xim_window = (GdkWindow*)NULL;
gdk_im_open (NULL, NULL, NULL);
gdk_im_open ();
#endif
gdk_initialized = 1;
@ -1005,16 +962,22 @@ gdk_event_get (void)
* has occurred. Read it.
*/
#ifdef USE_XIM
gint filter_status;
if (xim_using && xim_window)
do
{ /* don't dispatch events used by IM */
XNextEvent (gdk_display, &xevent);
filter_status = XFilterEvent (&xevent,
GDK_WINDOW_XWINDOW (xim_window));
} while (filter_status == True);
else
XNextEvent (gdk_display, &xevent);
Window w = None;
XNextEvent (gdk_display, &xevent);
if (gdk_xim_window)
switch (xevent.type)
{
case KeyPress:
case KeyRelease:
case ButtonPress:
case ButtonRelease:
w = GDK_WINDOW_XWINDOW (gdk_xim_window);
break;
}
if (XFilterEvent (&xevent, w))
return NULL;
#else
XNextEvent (gdk_display, &xevent);
#endif
@ -2067,13 +2030,6 @@ gdk_event_translate (GdkEvent *event,
if (window != NULL)
gdk_window_ref (window);
#ifdef USE_XIM
else if (XFilterEvent(xevent, None)) /* for xlib XIM handling */
return FALSE;
#endif
else
GDK_NOTE (EVENTS,
g_message ("Got event for unknown window: %#lx\n", xevent->xany.window));
event->any.window = window;
event->any.send_event = xevent->xany.send_event;
@ -2088,17 +2044,46 @@ gdk_event_translate (GdkEvent *event,
/* Check for filters for this window */
GdkFilterReturn result;
#ifdef USE_XIM
if (window == NULL &&
xevent->type == KeyPress &&
gdk_xim_window &&
!((GdkWindowPrivate *) gdk_xim_window)->destroyed)
{
/*
* If user presses a key in Preedit or Status window, keypress event
* is sometimes sent to these windows. These windows are not managed
* by GDK, so we redirect KeyPress event to gdk_xim_window.
*
* If someone want to use the window whitch is not managed by GDK
* and want to get KeyPress event, he/she must register the filter
* function to gdk_default_filters to intercept the event.
*/
window = gdk_xim_window;
window_private = (GdkWindowPrivate *) window;
gdk_window_ref (window);
event->any.window = window;
GDK_NOTE (XIM,
g_message ("KeyPress event is redirected to gdk_xim_window: %#lx",
xevent->xany.window));
}
#endif /* USE_XIM */
result = gdk_event_apply_filters (xevent, event,
window_private
?window_private->filters
:gdk_default_filters);
if (result != GDK_FILTER_CONTINUE)
{
return (result == GDK_FILTER_TRANSLATE) ? TRUE : FALSE;
}
return (result == GDK_FILTER_TRANSLATE) ? TRUE : FALSE;
}
if (window == NULL)
g_message ("Got event for unknown window: %#lx\n", xevent->xany.window);
/* We do a "manual" conversion of the XEvent to a
* GdkEvent. The structures are mostly the same so
* the conversion is fairly straightforward. We also
@ -2121,12 +2106,12 @@ gdk_event_translate (GdkEvent *event,
}
keysym = GDK_VoidSymbol;
if (xim_using == TRUE && xim_ic)
if (gdk_xim_ic && gdk_xim_ic->xic)
{
Status status;
/* Clear keyval. Depending on status, may not be set */
charcount = XmbLookupString(xim_ic->xic,
charcount = XmbLookupString(gdk_xim_ic->xic,
&xevent->xkey, buf, buf_len-1,
&keysym, &status);
if (status == XBufferOverflow)
@ -2139,7 +2124,7 @@ gdk_event_translate (GdkEvent *event,
buf_len *= 2;
buf = (gchar *) g_realloc (buf, buf_len);
charcount = XmbLookupString (xim_ic->xic,
charcount = XmbLookupString (gdk_xim_ic->xic,
&xevent->xkey, buf, buf_len-1,
&keysym, &status);
}
@ -2520,6 +2505,13 @@ gdk_event_translate (GdkEvent *event,
(xevent->xany.type == FocusIn) ? "in" : "out",
xevent->xfocus.window - base_id));
/* gdk_keyboard_grab() causes following events. These events confuse
* the XIM focus, so ignore them.
*/
if (xevent->xfocus.mode == NotifyGrab ||
xevent->xfocus.mode == NotifyUngrab)
break;
event->focus_change.type = GDK_FOCUS_CHANGE;
event->focus_change.window = window;
event->focus_change.in = (xevent->xany.type == FocusIn);
@ -3186,652 +3178,6 @@ gdk_signal (int sig_num)
#endif /* !G_ENABLE_DEBUG */
}
#ifdef USE_XIM
/* The following routines duplicate functionality in Xlib to
* translate from varargs to X's internal opaque XVaNestedList.
*
* If all vendors have stuck close to the reference implementation,
* then we should hopefully be OK.
*/
/* This needs to match XIMArg as defined in Xlcint.h exactly */
typedef struct {
gchar *name;
gpointer value;
} GdkImArg;
/*************************************************************
* gdk_im_va_count:
* Counts the number of name/value pairs in the vararg list
*
* arguments:
*
* results:
*************************************************************/
static guint
gdk_im_va_count (va_list list)
{
gint count = 0;
gchar *name;
name = va_arg (list, gchar *);
while (name)
{
count++;
(void)va_arg (list, gpointer);
name = va_arg (list, gchar *);
}
return count;
}
/*************************************************************
* gdk_im_va_to_nested:
* Given a varargs list and the result of gdk_im_va_count,
* create a XVaNestedList.
*
* arguments:
*
* results:
*************************************************************/
static XVaNestedList
gdk_im_va_to_nested (va_list list, guint count)
{
GdkImArg *result;
GdkImArg *arg;
gchar *name;
if (count == 0)
return NULL;
result = g_new (GdkImArg, count+1);
arg = result;
name = va_arg (list, gchar *);
while (name)
{
arg->name = name;
arg->value = va_arg (list, gpointer);
arg++;
name = va_arg (list, gchar *);
}
arg->name = NULL;
return (XVaNestedList)result;
}
/*
*--------------------------------------------------------------
* gdk_im_begin
*
* Begin using input method with XIM Protocol(X11R6 standard)
*
* Arguments:
* "ic" is the "Input Context" which is created by gtk_ic_new.
* The input area is specified with "window".
*
* Results:
* The gdk's event handling routine is switched to XIM based routine.
* XIM based routine uses XFilterEvent to get rid of events used by IM,
* and uses XmbLookupString instead of XLookupString.
*
* Side effects:
*
*--------------------------------------------------------------
*/
void
gdk_im_begin (GdkIC ic, GdkWindow* window)
{
GdkICPrivate *private;
Window xwin;
g_return_if_fail (ic != NULL);
g_return_if_fail (window);
private = (GdkICPrivate *) ic;
xim_using = TRUE;
xim_ic = private;
xim_window = window;
if (gdk_im_ready())
{
XGetICValues (private->xic, XNFocusWindow, &xwin, NULL);
if (xwin != GDK_WINDOW_XWINDOW(window))
XSetICValues (private->xic, XNFocusWindow,
GDK_WINDOW_XWINDOW(window), NULL);
if (private != xim_ic)
XSetICFocus (private->xic);
}
}
/*
*--------------------------------------------------------------
* gdk_im_end
*
* End using input method with XIM Protocol(X11R6 standard)
*
* Arguments:
*
* Results:
* The gdk's event handling routine is switched to normal routine.
* User should call this function before ic and window will be destroyed.
*
* Side effects:
*
*--------------------------------------------------------------
*/
void
gdk_im_end (void)
{
xim_using = FALSE;
xim_ic = NULL;
xim_window = NULL;
}
static GdkIM
gdk_im_get (void)
{
return xim_im;
}
static GdkIMStyle
gdk_im_choose_better_style (GdkIMStyle style1, GdkIMStyle style2)
{
GdkIMStyle s1, s2, u;
if (style1 == 0) return style2;
if (style2 == 0) return style1;
if ((style1 & (GDK_IM_PREEDIT_MASK | GDK_IM_STATUS_MASK))
== (style2 & (GDK_IM_PREEDIT_MASK | GDK_IM_STATUS_MASK)))
return style1;
s1 = style1 & GDK_IM_PREEDIT_MASK;
s2 = style2 & GDK_IM_PREEDIT_MASK;
u = s1 | s2;
if (s1 != s2) {
if (u & GDK_IM_PREEDIT_CALLBACKS)
return (s1 == GDK_IM_PREEDIT_CALLBACKS)? style1:style2;
else if (u & GDK_IM_PREEDIT_POSITION)
return (s1 == GDK_IM_PREEDIT_POSITION)? style1:style2;
else if (u & GDK_IM_PREEDIT_AREA)
return (s1 == GDK_IM_PREEDIT_AREA)? style1:style2;
else if (u & GDK_IM_PREEDIT_NOTHING)
return (s1 == GDK_IM_PREEDIT_NOTHING)? style1:style2;
} else {
s1 = style1 & GDK_IM_STATUS_MASK;
s2 = style2 & GDK_IM_STATUS_MASK;
u = s1 | s2;
if ( u & GDK_IM_STATUS_CALLBACKS)
return (s1 == GDK_IM_STATUS_CALLBACKS)? style1:style2;
else if ( u & GDK_IM_STATUS_AREA)
return (s1 == GDK_IM_STATUS_AREA)? style1:style2;
else if ( u & GDK_IM_STATUS_NOTHING)
return (s1 == GDK_IM_STATUS_NOTHING)? style1:style2;
else if ( u & GDK_IM_STATUS_NONE)
return (s1 == GDK_IM_STATUS_NONE)? style1:style2;
}
return 0; /* Get rid of stupid warning */
}
GdkIMStyle
gdk_im_decide_style (GdkIMStyle supported_style)
{
gint i;
GdkIMStyle style, tmp;
g_return_val_if_fail (xim_styles != NULL, 0);
style = 0;
for (i=0; i<xim_styles->count_styles; i++)
{
tmp = xim_styles->supported_styles[i];
if (tmp == (tmp & supported_style & xim_best_allowed_style))
style = gdk_im_choose_better_style (style, tmp);
}
return style;
}
GdkIMStyle
gdk_im_set_best_style (GdkIMStyle style)
{
if (style & GDK_IM_PREEDIT_MASK)
{
xim_best_allowed_style &= ~GDK_IM_PREEDIT_MASK;
xim_best_allowed_style |= GDK_IM_PREEDIT_NONE;
if (!(style & GDK_IM_PREEDIT_NONE))
{
xim_best_allowed_style |= GDK_IM_PREEDIT_NOTHING;
if (!(style & GDK_IM_PREEDIT_NOTHING))
{
xim_best_allowed_style |= GDK_IM_PREEDIT_AREA;
if (!(style & GDK_IM_PREEDIT_AREA))
{
xim_best_allowed_style |= GDK_IM_PREEDIT_POSITION;
if (!(style & GDK_IM_PREEDIT_POSITION))
xim_best_allowed_style |= GDK_IM_PREEDIT_CALLBACKS;
}
}
}
}
if (style & GDK_IM_STATUS_MASK)
{
xim_best_allowed_style &= ~GDK_IM_STATUS_MASK;
xim_best_allowed_style |= GDK_IM_STATUS_NONE;
if (!(style & GDK_IM_STATUS_NONE))
{
xim_best_allowed_style |= GDK_IM_STATUS_NOTHING;
if (!(style & GDK_IM_STATUS_NOTHING))
{
xim_best_allowed_style |= GDK_IM_STATUS_AREA;
if (!(style & GDK_IM_STATUS_AREA))
xim_best_allowed_style |= GDK_IM_STATUS_CALLBACKS;
}
}
}
return xim_best_allowed_style;
}
static gint
gdk_im_open (XrmDatabase db, gchar* res_name, gchar* res_class)
{
xim_im = XOpenIM (GDK_DISPLAY(), db, res_name, res_class);
if (xim_im == NULL)
{
GDK_NOTE (XIM, g_warning ("Unable to open open IM."));
return FALSE;
}
XGetIMValues (xim_im, XNQueryInputStyle, &xim_styles, NULL, NULL);
return TRUE;
}
static void
gdk_im_close (void)
{
if (xim_im)
{
XCloseIM (xim_im);
xim_im = NULL;
}
if (xim_styles)
{
XFree (xim_styles);
xim_styles = NULL;
}
}
gint
gdk_im_ready (void)
{
return (xim_im != NULL);
}
GdkIC
gdk_ic_new (GdkWindow* client_window,
GdkWindow* focus_window,
GdkIMStyle style, ...)
{
va_list list;
GdkICPrivate *private;
XVaNestedList preedit_attr = NULL;
guint count;
g_return_val_if_fail (client_window != NULL, NULL);
g_return_val_if_fail (focus_window != NULL, NULL);
g_return_val_if_fail (gdk_im_ready(), NULL);
private = g_new (GdkICPrivate, 1);
va_start (list, style);
count = gdk_im_va_count (list);
va_end (list);
va_start (list, style);
preedit_attr = gdk_im_va_to_nested (list, count);
va_end (list);
private->style = gdk_im_decide_style (style);
if (private->style != style)
{
g_warning ("can not create input context with specified input style.");
g_free (private);
return NULL;
}
private->xic = XCreateIC(gdk_im_get (),
XNInputStyle, style,
XNClientWindow, GDK_WINDOW_XWINDOW (client_window),
XNFocusWindow, GDK_WINDOW_XWINDOW (focus_window),
preedit_attr? XNPreeditAttributes : NULL, preedit_attr,
NULL);
g_free (preedit_attr);
if (!private->xic)
{
g_free (private);
return NULL;
}
xim_ic_list = g_list_append (xim_ic_list, private);
return private;
}
void
gdk_ic_destroy (GdkIC ic)
{
GdkICPrivate *private;
g_return_if_fail (ic != NULL);
private = (GdkICPrivate *) ic;
if (xim_ic == private)
gdk_im_end ();
XDestroyIC (private->xic);
xim_ic_list = g_list_remove (xim_ic_list, private);
g_free (private);
}
GdkIMStyle
gdk_ic_get_style (GdkIC ic)
{
GdkICPrivate *private;
g_return_val_if_fail (ic != NULL, 0);
private = (GdkICPrivate *) ic;
return private->style;
}
void
gdk_ic_set_values (GdkIC ic, ...)
{
va_list list;
XVaNestedList args;
GdkICPrivate *private;
guint count;
g_return_if_fail (ic != NULL);
private = (GdkICPrivate *) ic;
va_start (list, ic);
count = gdk_im_va_count (list);
va_end (list);
va_start (list, ic);
args = gdk_im_va_to_nested (list, count);
va_end (list);
XSetICValues (private->xic, XNVaNestedList, args, NULL);
g_free (args);
}
void
gdk_ic_get_values (GdkIC ic, ...)
{
va_list list;
XVaNestedList args;
GdkICPrivate *private;
guint count;
g_return_if_fail (ic != NULL);
private = (GdkICPrivate *) ic;
va_start (list, ic);
count = gdk_im_va_count (list);
va_end (list);
va_start (list, ic);
args = gdk_im_va_to_nested (list, count);
va_end (list);
XGetICValues (private->xic, XNVaNestedList, args, NULL);
g_free (args);
}
void
gdk_ic_set_attr (GdkIC ic, const char *target, ...)
{
va_list list;
XVaNestedList attr;
GdkICPrivate *private;
guint count;
g_return_if_fail (ic != NULL);
g_return_if_fail (target != NULL);
private = (GdkICPrivate *) ic;
va_start (list, target);
count = gdk_im_va_count (list);
va_end (list);
va_start (list, target);
attr = gdk_im_va_to_nested (list, count);
va_end (list);
XSetICValues (private->xic, target, attr, NULL);
g_free (attr);
}
void
gdk_ic_get_attr (GdkIC ic, const char *target, ...)
{
va_list list;
XVaNestedList attr;
GdkICPrivate *private;
guint count;
g_return_if_fail (ic != NULL);
g_return_if_fail (target != NULL);
private = (GdkICPrivate *) ic;
va_start (list, target);
count = gdk_im_va_count (list);
va_end (list);
va_start (list, target);
attr = gdk_im_va_to_nested (list, count);
va_end (list);
XGetICValues (private->xic, target, attr, NULL);
g_free (attr);
}
GdkEventMask
gdk_ic_get_events (GdkIC ic)
{
GdkEventMask mask;
glong xmask;
glong bit;
GdkICPrivate *private;
gint i;
/* From gdkwindow.c */
extern int nevent_masks;
extern int event_mask_table[];
g_return_val_if_fail (ic != NULL, 0);
private = (GdkICPrivate *) ic;
if (XGetICValues (private->xic, XNFilterEvents, &xmask, NULL) != NULL)
{
GDK_NOTE (XIM, g_warning ("Call to XGetICValues: %s failed", XNFilterEvents));
return 0;
}
mask = 0;
for (i=0, bit=2; i < nevent_masks; i++, bit <<= 1)
if (xmask & event_mask_table [i])
{
mask |= bit;
xmask &= ~ event_mask_table [i];
}
if (xmask)
g_warning ("ic requires events not supported by the application (%#04lx)", xmask);
return mask;
}
static void
gdk_ic_cleanup (void)
{
GList* node;
gint destroyed;
GdkICPrivate *private;
destroyed = 0;
for (node = xim_ic_list; node != NULL; node = node->next)
{
if (node->data)
{
private = (GdkICPrivate *) (node->data);
XDestroyIC (private->xic);
g_free (private);
destroyed++;
}
}
#ifdef G_ENABLE_DEBUG
if ((gdk_debug_flags & GDK_DEBUG_XIM) && destroyed > 0)
{
g_warning ("Cleaned up %i IC(s)\n", destroyed);
}
#endif /* G_ENABLE_DEBUG */
g_list_free(xim_ic_list);
xim_ic_list = NULL;
}
#else /* !USE_XIM */
void
gdk_im_begin (GdkIC ic, GdkWindow* window)
{
}
void
gdk_im_end (void)
{
}
GdkIMStyle
gdk_im_decide_style (GdkIMStyle supported_style)
{
return GDK_IM_PREEDIT_NONE | GDK_IM_STATUS_NONE;
}
GdkIMStyle
gdk_im_set_best_style (GdkIMStyle style)
{
return GDK_IM_PREEDIT_NONE | GDK_IM_STATUS_NONE;
}
gint
gdk_im_ready (void)
{
return FALSE;
}
GdkIC
gdk_ic_new (GdkWindow* client_window,
GdkWindow* focus_window,
GdkIMStyle style, ...)
{
return NULL;
}
void
gdk_ic_destroy (GdkIC ic)
{
}
GdkIMStyle
gdk_ic_get_style (GdkIC ic)
{
return GDK_IM_PREEDIT_NONE | GDK_IM_STATUS_NONE;
}
void
gdk_ic_set_values (GdkIC ic, ...)
{
}
void
gdk_ic_get_values (GdkIC ic, ...)
{
}
void
gdk_ic_set_attr (GdkIC ic, const char *target, ...)
{
}
void
gdk_ic_get_attr (GdkIC ic, const char *target, ...)
{
}
GdkEventMask
gdk_ic_get_events (GdkIC ic)
{
return 0;
}
#endif /* USE_XIM */
#ifdef X_LOCALE
gint
_g_mbtowc (wchar_t *wstr, const char *str, size_t len)
{
static wchar_t wcs[MB_CUR_MAX + 1];
static gchar mbs[MB_CUR_MAX + 1];
wcs[0] = (wchar_t) NULL;
mbs[0] = '\0';
/* The last argument isn't a mistake. The X locale code trims
* the input string to the length of the output string!
*/
len = _Xmbstowcs (wcs, str, (len<MB_CUR_MAX)? len:MB_CUR_MAX);
if (len < 1)
return len;
else if (wcs[0] == (wchar_t) NULL)
return -1;
len = _Xwctomb (mbs, wcs[0]);
if (mbs[0] == '\0')
return -1;
if (wstr)
*wstr = wcs[0];
return len;
}
#endif /* X_LOCALE */
/* Sends a ClientMessage to all toplevel client windows */
gboolean
gdk_event_send_client_message (GdkEvent *event, guint32 xid)

View File

@ -22,7 +22,6 @@
#include <gdk/gdktypes.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
@ -571,8 +570,13 @@ gint gdk_string_width (GdkFont *font,
gint gdk_text_width (GdkFont *font,
const gchar *text,
gint text_length);
gint gdk_text_width_wc (GdkFont *font,
const GdkWChar *text,
gint text_length);
gint gdk_char_width (GdkFont *font,
gchar character);
gint gdk_char_width_wc (GdkFont *font,
GdkWChar character);
gint gdk_string_measure (GdkFont *font,
const gchar *string);
gint gdk_text_measure (GdkFont *font,
@ -642,14 +646,21 @@ void gdk_draw_string (GdkDrawable *drawable,
GdkGC *gc,
gint x,
gint y,
const gchar *string);
const gchar *string);
void gdk_draw_text (GdkDrawable *drawable,
GdkFont *font,
GdkGC *gc,
gint x,
gint y,
const gchar *text,
const gchar *text,
gint text_length);
void gdk_draw_text_wc (GdkDrawable *drawable,
GdkFont *font,
GdkGC *gc,
gint x,
gint y,
const GdkWChar *text,
gint text_length);
void gdk_draw_pixmap (GdkDrawable *drawable,
GdkGC *gc,
GdkDrawable *src,
@ -798,25 +809,35 @@ GdkTimeCoord *gdk_input_motion_events (GdkWindow *window,
gint gdk_im_ready (void);
void gdk_im_begin (GdkIC ic,
GdkWindow* window);
void gdk_im_begin (GdkIC *ic,
GdkWindow *window);
void gdk_im_end (void);
GdkIMStyle gdk_im_decide_style (GdkIMStyle supported_style);
GdkIMStyle gdk_im_set_best_style (GdkIMStyle best_allowed_style);
GdkIC gdk_ic_new (GdkWindow* client_window,
GdkWindow* focus_window,
GdkIMStyle style, ...);
void gdk_ic_destroy (GdkIC ic);
GdkIMStyle gdk_ic_get_style (GdkIC ic);
void gdk_ic_set_values (GdkIC ic,
...);
void gdk_ic_get_values (GdkIC ic,
...);
void gdk_ic_set_attr (GdkIC ic,
const char *target, ...);
void gdk_ic_get_attr (GdkIC ic,
const char *target, ...);
GdkEventMask gdk_ic_get_events (GdkIC ic);
GdkIMStyle gdk_im_decide_style (GdkIMStyle supported_style);
GdkIMStyle gdk_im_set_best_style (GdkIMStyle best_allowed_style);
GdkIC* gdk_ic_new (GdkICAttr *attr,
GdkICAttributesType mask);
void gdk_ic_destroy (GdkIC *ic);
GdkIMStyle gdk_ic_get_style (GdkIC *ic);
GdkEventMask gdk_ic_get_events (GdkIC *ic);
GdkICAttr* gdk_ic_attr_new (void);
void gdk_ic_attr_destroy (GdkICAttr *attr);
GdkICAttributesType gdk_ic_set_attr (GdkIC *ic,
GdkICAttr *attr,
GdkICAttributesType mask);
GdkICAttributesType gdk_ic_get_attr (GdkIC *ic,
GdkICAttr *attr,
GdkICAttributesType mask);
/* Conversion functions between wide char and multibyte strings.
*/
gchar *gdk_wcstombs (const GdkWChar *src);
gint gdk_mbstowcs (GdkWChar *dest,
const gchar *src,
gint dest_max);
/* Color Context */

View File

@ -293,6 +293,66 @@ gdk_draw_text (GdkDrawable *drawable,
g_error("undefined font type\n");
}
void
gdk_draw_text_wc (GdkDrawable *drawable,
GdkFont *font,
GdkGC *gc,
gint x,
gint y,
const GdkWChar *text,
gint text_length)
{
GdkWindowPrivate *drawable_private;
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);
drawable_private = (GdkWindowPrivate*) drawable;
if (drawable_private->destroyed)
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(drawable_private->xdisplay, 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 (drawable_private->xdisplay, drawable_private->xwindow,
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 (drawable_private->xdisplay, drawable_private->xwindow,
(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 (drawable_private->xdisplay, drawable_private->xwindow,
(XFontSet) font_private->xfont,
gc_private->xgc, x, y, text_wchar, text_length);
g_free (text_wchar);
}
}
else
g_error("undefined font type\n");
}
void
gdk_draw_pixmap (GdkDrawable *drawable,
GdkGC *gc,

View File

@ -271,6 +271,62 @@ gdk_text_width (GdkFont *font,
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,
@ -318,6 +374,56 @@ gdk_char_width (GdkFont *font,
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)

View File

@ -62,4 +62,8 @@ gint gdk_threads_pipe[2];
gboolean gdk_select_waiting = FALSE;
#endif
#ifdef USE_XIM
GdkICPrivate *gdk_xim_ic; /* currently using IC */
GdkWindow *gdk_xim_window; /* currently using Window */
#endif

View File

@ -28,124 +28,6 @@
#include <stdlib.h>
#ifdef X_LOCALE
#include <X11/Xfuncproto.h>
#include <X11/Xosdefs.h>
#ifdef __cplusplus
extern "C" {
#endif
_XFUNCPROTOBEGIN
extern int _Xmblen (
#if NeedFunctionPrototypes
const char *s, size_t n
#endif
);
_XFUNCPROTOEND
_XFUNCPROTOBEGIN
extern int _Xmbtowc (
#if NeedFunctionPrototypes
wchar_t *wstr, const char *str, size_t len
#endif
);
_XFUNCPROTOEND
_XFUNCPROTOBEGIN
extern int _Xwctomb (
#if NeedFunctionPrototypes
char *str, wchar_t wc
#endif
);
_XFUNCPROTOEND
_XFUNCPROTOBEGIN
extern size_t _Xmbstowcs (
#if NeedFunctionPrototypes
wchar_t *wstr, const char *str, size_t len
#endif
);
_XFUNCPROTOEND
_XFUNCPROTOBEGIN
extern size_t _Xwcstombs (
#if NeedFunctionPrototypes
char *str, const wchar_t *wstr, size_t len
#endif
);
_XFUNCPROTOEND
_XFUNCPROTOBEGIN
extern size_t _Xwcslen (
#if NeedFunctionPrototypes
const wchar_t *wstr
#endif
);
_XFUNCPROTOEND
_XFUNCPROTOBEGIN
extern wchar_t* _Xwcscpy (
#if NeedFunctionPrototypes
wchar_t *wstr1, const wchar_t *wstr2
#endif
);
_XFUNCPROTOEND
_XFUNCPROTOBEGIN
extern wchar_t* _Xwcsncpy (
#if NeedFunctionPrototypes
wchar_t *wstr1, const wchar_t *wstr2, size_t len
#endif
);
_XFUNCPROTOEND
_XFUNCPROTOBEGIN
extern int _Xwcscmp (
#if NeedFunctionPrototypes
const wchar_t *wstr1, const wchar_t *wstr2
#endif
);
_XFUNCPROTOEND
_XFUNCPROTOBEGIN
extern int _Xwcsncmp (
#if NeedFunctionPrototypes
const wchar_t *wstr1, const wchar_t *wstr2, size_t len
#endif
);
_XFUNCPROTOEND
/*
* mblen, mbtowc, and mbstowcs of the locale "ja_JP.eucJP" are buggy.
*/
#ifdef MB_CUR_MAX
# undef MB_CUR_MAX
#endif
#define MB_CUR_MAX 4
extern int _g_mbtowc (wchar_t *wstr, const char *str, size_t len);
/* #define mblen _Xmblen */
/* #define mbtowc _Xmbtowc */
#define mblen(a,b) _g_mbtowc ((wchar_t *)(NULL), (a), (b))
#define mbtowc(a,b,c) _g_mbtowc ((a),(b),(c))
#define wctomb(a,b) _Xwctomb ((a),(b))
#define mbstowcs(a,b,c) _Xmbstowcs ((a),(b),(c))
#define wcstombs(a,b,c) _Xwcstombs ((a),(b),(c))
#define wcslen(a) _Xwcslen ((a))
#define wcscpy(a,b) _Xwcscpy ((a),(b))
#define wcsncpy(a,b,c) _Xwcsncpy ((a),(b),(c))
#ifdef __cplusplus
}
#endif
#endif /* X_LOCALE */
#if !defined(G_HAVE_BROKEN_WCTYPE) && (defined(G_HAVE_WCTYPE_H) || defined(G_HAVE_WCHAR_H)) && !defined(X_LOCALE)
# ifdef G_HAVE_WCTYPE_H
# include <wctype.h>
@ -154,8 +36,11 @@ extern int _g_mbtowc (wchar_t *wstr, const char *str, size_t len);
# include <wchar.h>
# endif
# endif
# define gdk_iswalnum(c) iswalnum(c)
# define gdk_iswspace(c) iswspace(c)
#else
# define iswalnum(c) ((wchar_t)(c) <= 0xFF && isalnum(c))
# define gdk_iswalnum(c) ((wchar_t)(c) <= 0xFF && isalnum(c))
# define gdk_iswspace(c) ((wchar_t)(c) <= 0xFF && isspace(c))
#endif
#endif /* __GDK_I18N_H__ */

View File

@ -186,14 +186,15 @@ struct _GdkClientFilter {
#ifdef USE_XIM
typedef struct _GdkICPrivate GdkICPrivate;
struct _GdkICPrivate
{
XIC xic;
GdkIMStyle style;
GdkICAttr *attr;
GdkICAttributesType mask;
};
typedef struct _GdkICPrivate GdkICPrivate;
#endif /* USE_XIM */
struct _GdkColorContextPrivate
@ -282,6 +283,16 @@ extern gint gdk_threads_pipe[2];
extern gboolean gdk_select_waiting;
#endif
#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 */
#ifdef G_ENABLE_DEBUG

View File

@ -89,9 +89,11 @@ typedef struct _GdkRegion GdkRegion;
typedef gint (*GdkEventFunc) (GdkEvent *event,
gpointer data);
typedef void* GdkIC;
typedef void* GdkIM;
typedef struct _GdkIC GdkIC;
typedef struct _GdkICAttr GdkICAttr;
typedef guint32 GdkWChar;
/* Types of windows.
* Root: There is only 1 root window and it is initialized
@ -617,6 +619,45 @@ typedef enum /*< flags >*/
GDK_IM_STATUS_MASK = 0x0f00
} GdkIMStyle;
typedef enum
{
GDK_IC_STYLE = 1 << 0,
GDK_IC_CLIENT_WINDOW = 1 << 1,
GDK_IC_FOCUS_WINDOW = 1 << 2,
GDK_IC_FILTER_EVENTS = 1 << 3,
GDK_IC_SPOT_LOCATION = 1 << 4,
GDK_IC_LINE_SPACING = 1 << 5,
GDK_IC_CURSOR = 1 << 6,
GDK_IC_PREEDIT_FONTSET = 1 << 10,
GDK_IC_PREEDIT_AREA = 1 << 11,
GDK_IC_PREEDIT_AREA_NEEDED = 1 << 12,
GDK_IC_PREEDIT_FOREGROUND = 1 << 13,
GDK_IC_PREEDIT_BACKGROUND = 1 << 14,
GDK_IC_PREEDIT_PIXMAP = 1 << 15,
GDK_IC_PREEDIT_COLORMAP = 1 << 16,
GDK_IC_STATUS_FONTSET = 1 << 21,
GDK_IC_STATUS_AREA = 1 << 22,
GDK_IC_STATUS_AREA_NEEDED = 1 << 23,
GDK_IC_STATUS_FOREGROUND = 1 << 24,
GDK_IC_STATUS_BACKGROUND = 1 << 25,
GDK_IC_STATUS_PIXMAP = 1 << 26,
GDK_IC_STATUS_COLORMAP = 1 << 27,
GDK_IC_ALL_REQ = GDK_IC_STYLE |
GDK_IC_CLIENT_WINDOW,
GDK_IC_PREEDIT_AREA_REQ = GDK_IC_PREEDIT_AREA |
GDK_IC_PREEDIT_FONTSET,
GDK_IC_PREEDIT_POSITION_REQ = GDK_IC_PREEDIT_AREA |
GDK_IC_SPOT_LOCATION |
GDK_IC_PREEDIT_FONTSET,
GDK_IC_STATUS_AREA_REQ = GDK_IC_STATUS_AREA |
GDK_IC_STATUS_FONTSET,
} GdkICAttributesType;
/* The next two enumeration values current match the
* Motif constants. If this is changed, the implementation
* of gdk_window_set_decorations/gdk_window_set_functions
@ -1182,7 +1223,32 @@ struct _GdkRegion
gpointer user_data;
};
struct _GdkICAttr
{
GdkIMStyle style;
GdkWindow *client_window;
GdkWindow *focus_window;
GdkEventMask filter_events;
GdkPoint spot_location;
gint line_spacing;
GdkCursor *cursor;
GdkFont *preedit_fontset;
GdkRectangle preedit_area;
GdkRectangle preedit_area_needed;
GdkColor preedit_foreground;
GdkColor preedit_background;
GdkPixmap *preedit_pixmap;
GdkColormap *preedit_colormap;
GdkFont *status_fontset;
GdkRectangle status_area;
GdkRectangle status_area_needed;
GdkColor status_foreground;
GdkColor status_background;
GdkPixmap *status_pixmap;
GdkColormap *status_colormap;
};
#ifdef __cplusplus
}

View File

@ -323,7 +323,12 @@ gdk_window_new (GdkWindow *parent,
if (attributes_mask & GDK_WA_COLORMAP)
private->colormap = attributes->colormap;
else
private->colormap = gdk_colormap_get_system ();
{
if ((((GdkVisualPrivate*)gdk_visual_get_system())->xvisual) == xvisual)
private->colormap = gdk_colormap_get_system ();
else
private->colormap = gdk_colormap_new (visual, False);
}
xattributes.background_pixel = BlackPixel (gdk_display, gdk_screen);
xattributes.border_pixel = BlackPixel (gdk_display, gdk_screen);

View File

@ -271,6 +271,62 @@ gdk_text_width (GdkFont *font,
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,
@ -318,6 +374,56 @@ gdk_char_width (GdkFont *font,
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)

View File

@ -62,4 +62,8 @@ gint gdk_threads_pipe[2];
gboolean gdk_select_waiting = FALSE;
#endif
#ifdef USE_XIM
GdkICPrivate *gdk_xim_ic; /* currently using IC */
GdkWindow *gdk_xim_window; /* currently using Window */
#endif

View File

@ -28,9 +28,6 @@
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#ifdef USE_XIM
#include <stdarg.h>
#endif
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
@ -42,16 +39,13 @@
#include <X11/Xos.h>
#include <X11/Xutil.h>
#include <X11/Xmu/WinUtil.h>
#ifdef USE_XIM
#include <X11/Xresource.h>
#endif
#include <X11/cursorfont.h>
#include "gdk.h"
#include "gdkprivate.h"
#include "gdkinput.h"
#include "gdki18n.h"
#include "gdkx.h"
#include "gdkkeysyms.h"
#include "gdki18n.h"
#ifndef X_GETTIMEOFDAY
#define X_GETTIMEOFDAY(tv) gettimeofday (tv, NULL)
@ -139,21 +133,6 @@ static int gdk_x_error (Display *display,
static int gdk_x_io_error (Display *display);
static RETSIGTYPE gdk_signal (int signum);
#ifdef USE_XIM
static guint gdk_im_va_count (va_list list);
static XVaNestedList gdk_im_va_to_nested (va_list list,
guint count);
static GdkIM gdk_im_get (void);
static gint gdk_im_open (XrmDatabase db,
gchar* res_name,
gchar* rec_class);
static void gdk_im_close (void);
static void gdk_ic_cleanup (void);
#endif /* USE_XIM */
GdkFilterReturn gdk_wm_protocols_filter (GdkXEvent *xev,
GdkEvent *event,
gpointer data);
@ -212,17 +191,6 @@ static GdkWindowPrivate *xgrab_window = NULL; /* Window that currently holds
static GList *client_filters; /* Filters for client messages */
#ifdef USE_XIM
static gint xim_using; /* using XIM Protocol if TRUE */
static GdkIM xim_im; /* global IM */
static XIMStyles* xim_styles; /* im supports these styles */
static XIMStyle xim_best_allowed_style;
static GdkICPrivate *xim_ic; /* currently using IC */
static GdkWindow* xim_window; /* currently using Widow */
static GList* xim_ic_list;
#endif
static GList *putback_events = NULL;
static gulong base_id;
@ -570,18 +538,7 @@ gdk_init (int *argc,
gdk_wm_protocols_filter, NULL);
#ifdef USE_XIM
/* initialize XIM Protocol variables */
xim_using = FALSE;
xim_im = NULL;
xim_styles = NULL;
if (!(xim_best_allowed_style & GDK_IM_PREEDIT_MASK))
gdk_im_set_best_style (GDK_IM_PREEDIT_CALLBACKS);
if (!(xim_best_allowed_style & GDK_IM_STATUS_MASK))
gdk_im_set_best_style (GDK_IM_STATUS_CALLBACKS);
xim_ic = NULL;
xim_window = (GdkWindow*)NULL;
gdk_im_open (NULL, NULL, NULL);
gdk_im_open ();
#endif
gdk_initialized = 1;
@ -1005,16 +962,22 @@ gdk_event_get (void)
* has occurred. Read it.
*/
#ifdef USE_XIM
gint filter_status;
if (xim_using && xim_window)
do
{ /* don't dispatch events used by IM */
XNextEvent (gdk_display, &xevent);
filter_status = XFilterEvent (&xevent,
GDK_WINDOW_XWINDOW (xim_window));
} while (filter_status == True);
else
XNextEvent (gdk_display, &xevent);
Window w = None;
XNextEvent (gdk_display, &xevent);
if (gdk_xim_window)
switch (xevent.type)
{
case KeyPress:
case KeyRelease:
case ButtonPress:
case ButtonRelease:
w = GDK_WINDOW_XWINDOW (gdk_xim_window);
break;
}
if (XFilterEvent (&xevent, w))
return NULL;
#else
XNextEvent (gdk_display, &xevent);
#endif
@ -2067,13 +2030,6 @@ gdk_event_translate (GdkEvent *event,
if (window != NULL)
gdk_window_ref (window);
#ifdef USE_XIM
else if (XFilterEvent(xevent, None)) /* for xlib XIM handling */
return FALSE;
#endif
else
GDK_NOTE (EVENTS,
g_message ("Got event for unknown window: %#lx\n", xevent->xany.window));
event->any.window = window;
event->any.send_event = xevent->xany.send_event;
@ -2088,17 +2044,46 @@ gdk_event_translate (GdkEvent *event,
/* Check for filters for this window */
GdkFilterReturn result;
#ifdef USE_XIM
if (window == NULL &&
xevent->type == KeyPress &&
gdk_xim_window &&
!((GdkWindowPrivate *) gdk_xim_window)->destroyed)
{
/*
* If user presses a key in Preedit or Status window, keypress event
* is sometimes sent to these windows. These windows are not managed
* by GDK, so we redirect KeyPress event to gdk_xim_window.
*
* If someone want to use the window whitch is not managed by GDK
* and want to get KeyPress event, he/she must register the filter
* function to gdk_default_filters to intercept the event.
*/
window = gdk_xim_window;
window_private = (GdkWindowPrivate *) window;
gdk_window_ref (window);
event->any.window = window;
GDK_NOTE (XIM,
g_message ("KeyPress event is redirected to gdk_xim_window: %#lx",
xevent->xany.window));
}
#endif /* USE_XIM */
result = gdk_event_apply_filters (xevent, event,
window_private
?window_private->filters
:gdk_default_filters);
if (result != GDK_FILTER_CONTINUE)
{
return (result == GDK_FILTER_TRANSLATE) ? TRUE : FALSE;
}
return (result == GDK_FILTER_TRANSLATE) ? TRUE : FALSE;
}
if (window == NULL)
g_message ("Got event for unknown window: %#lx\n", xevent->xany.window);
/* We do a "manual" conversion of the XEvent to a
* GdkEvent. The structures are mostly the same so
* the conversion is fairly straightforward. We also
@ -2121,12 +2106,12 @@ gdk_event_translate (GdkEvent *event,
}
keysym = GDK_VoidSymbol;
if (xim_using == TRUE && xim_ic)
if (gdk_xim_ic && gdk_xim_ic->xic)
{
Status status;
/* Clear keyval. Depending on status, may not be set */
charcount = XmbLookupString(xim_ic->xic,
charcount = XmbLookupString(gdk_xim_ic->xic,
&xevent->xkey, buf, buf_len-1,
&keysym, &status);
if (status == XBufferOverflow)
@ -2139,7 +2124,7 @@ gdk_event_translate (GdkEvent *event,
buf_len *= 2;
buf = (gchar *) g_realloc (buf, buf_len);
charcount = XmbLookupString (xim_ic->xic,
charcount = XmbLookupString (gdk_xim_ic->xic,
&xevent->xkey, buf, buf_len-1,
&keysym, &status);
}
@ -2520,6 +2505,13 @@ gdk_event_translate (GdkEvent *event,
(xevent->xany.type == FocusIn) ? "in" : "out",
xevent->xfocus.window - base_id));
/* gdk_keyboard_grab() causes following events. These events confuse
* the XIM focus, so ignore them.
*/
if (xevent->xfocus.mode == NotifyGrab ||
xevent->xfocus.mode == NotifyUngrab)
break;
event->focus_change.type = GDK_FOCUS_CHANGE;
event->focus_change.window = window;
event->focus_change.in = (xevent->xany.type == FocusIn);
@ -3186,652 +3178,6 @@ gdk_signal (int sig_num)
#endif /* !G_ENABLE_DEBUG */
}
#ifdef USE_XIM
/* The following routines duplicate functionality in Xlib to
* translate from varargs to X's internal opaque XVaNestedList.
*
* If all vendors have stuck close to the reference implementation,
* then we should hopefully be OK.
*/
/* This needs to match XIMArg as defined in Xlcint.h exactly */
typedef struct {
gchar *name;
gpointer value;
} GdkImArg;
/*************************************************************
* gdk_im_va_count:
* Counts the number of name/value pairs in the vararg list
*
* arguments:
*
* results:
*************************************************************/
static guint
gdk_im_va_count (va_list list)
{
gint count = 0;
gchar *name;
name = va_arg (list, gchar *);
while (name)
{
count++;
(void)va_arg (list, gpointer);
name = va_arg (list, gchar *);
}
return count;
}
/*************************************************************
* gdk_im_va_to_nested:
* Given a varargs list and the result of gdk_im_va_count,
* create a XVaNestedList.
*
* arguments:
*
* results:
*************************************************************/
static XVaNestedList
gdk_im_va_to_nested (va_list list, guint count)
{
GdkImArg *result;
GdkImArg *arg;
gchar *name;
if (count == 0)
return NULL;
result = g_new (GdkImArg, count+1);
arg = result;
name = va_arg (list, gchar *);
while (name)
{
arg->name = name;
arg->value = va_arg (list, gpointer);
arg++;
name = va_arg (list, gchar *);
}
arg->name = NULL;
return (XVaNestedList)result;
}
/*
*--------------------------------------------------------------
* gdk_im_begin
*
* Begin using input method with XIM Protocol(X11R6 standard)
*
* Arguments:
* "ic" is the "Input Context" which is created by gtk_ic_new.
* The input area is specified with "window".
*
* Results:
* The gdk's event handling routine is switched to XIM based routine.
* XIM based routine uses XFilterEvent to get rid of events used by IM,
* and uses XmbLookupString instead of XLookupString.
*
* Side effects:
*
*--------------------------------------------------------------
*/
void
gdk_im_begin (GdkIC ic, GdkWindow* window)
{
GdkICPrivate *private;
Window xwin;
g_return_if_fail (ic != NULL);
g_return_if_fail (window);
private = (GdkICPrivate *) ic;
xim_using = TRUE;
xim_ic = private;
xim_window = window;
if (gdk_im_ready())
{
XGetICValues (private->xic, XNFocusWindow, &xwin, NULL);
if (xwin != GDK_WINDOW_XWINDOW(window))
XSetICValues (private->xic, XNFocusWindow,
GDK_WINDOW_XWINDOW(window), NULL);
if (private != xim_ic)
XSetICFocus (private->xic);
}
}
/*
*--------------------------------------------------------------
* gdk_im_end
*
* End using input method with XIM Protocol(X11R6 standard)
*
* Arguments:
*
* Results:
* The gdk's event handling routine is switched to normal routine.
* User should call this function before ic and window will be destroyed.
*
* Side effects:
*
*--------------------------------------------------------------
*/
void
gdk_im_end (void)
{
xim_using = FALSE;
xim_ic = NULL;
xim_window = NULL;
}
static GdkIM
gdk_im_get (void)
{
return xim_im;
}
static GdkIMStyle
gdk_im_choose_better_style (GdkIMStyle style1, GdkIMStyle style2)
{
GdkIMStyle s1, s2, u;
if (style1 == 0) return style2;
if (style2 == 0) return style1;
if ((style1 & (GDK_IM_PREEDIT_MASK | GDK_IM_STATUS_MASK))
== (style2 & (GDK_IM_PREEDIT_MASK | GDK_IM_STATUS_MASK)))
return style1;
s1 = style1 & GDK_IM_PREEDIT_MASK;
s2 = style2 & GDK_IM_PREEDIT_MASK;
u = s1 | s2;
if (s1 != s2) {
if (u & GDK_IM_PREEDIT_CALLBACKS)
return (s1 == GDK_IM_PREEDIT_CALLBACKS)? style1:style2;
else if (u & GDK_IM_PREEDIT_POSITION)
return (s1 == GDK_IM_PREEDIT_POSITION)? style1:style2;
else if (u & GDK_IM_PREEDIT_AREA)
return (s1 == GDK_IM_PREEDIT_AREA)? style1:style2;
else if (u & GDK_IM_PREEDIT_NOTHING)
return (s1 == GDK_IM_PREEDIT_NOTHING)? style1:style2;
} else {
s1 = style1 & GDK_IM_STATUS_MASK;
s2 = style2 & GDK_IM_STATUS_MASK;
u = s1 | s2;
if ( u & GDK_IM_STATUS_CALLBACKS)
return (s1 == GDK_IM_STATUS_CALLBACKS)? style1:style2;
else if ( u & GDK_IM_STATUS_AREA)
return (s1 == GDK_IM_STATUS_AREA)? style1:style2;
else if ( u & GDK_IM_STATUS_NOTHING)
return (s1 == GDK_IM_STATUS_NOTHING)? style1:style2;
else if ( u & GDK_IM_STATUS_NONE)
return (s1 == GDK_IM_STATUS_NONE)? style1:style2;
}
return 0; /* Get rid of stupid warning */
}
GdkIMStyle
gdk_im_decide_style (GdkIMStyle supported_style)
{
gint i;
GdkIMStyle style, tmp;
g_return_val_if_fail (xim_styles != NULL, 0);
style = 0;
for (i=0; i<xim_styles->count_styles; i++)
{
tmp = xim_styles->supported_styles[i];
if (tmp == (tmp & supported_style & xim_best_allowed_style))
style = gdk_im_choose_better_style (style, tmp);
}
return style;
}
GdkIMStyle
gdk_im_set_best_style (GdkIMStyle style)
{
if (style & GDK_IM_PREEDIT_MASK)
{
xim_best_allowed_style &= ~GDK_IM_PREEDIT_MASK;
xim_best_allowed_style |= GDK_IM_PREEDIT_NONE;
if (!(style & GDK_IM_PREEDIT_NONE))
{
xim_best_allowed_style |= GDK_IM_PREEDIT_NOTHING;
if (!(style & GDK_IM_PREEDIT_NOTHING))
{
xim_best_allowed_style |= GDK_IM_PREEDIT_AREA;
if (!(style & GDK_IM_PREEDIT_AREA))
{
xim_best_allowed_style |= GDK_IM_PREEDIT_POSITION;
if (!(style & GDK_IM_PREEDIT_POSITION))
xim_best_allowed_style |= GDK_IM_PREEDIT_CALLBACKS;
}
}
}
}
if (style & GDK_IM_STATUS_MASK)
{
xim_best_allowed_style &= ~GDK_IM_STATUS_MASK;
xim_best_allowed_style |= GDK_IM_STATUS_NONE;
if (!(style & GDK_IM_STATUS_NONE))
{
xim_best_allowed_style |= GDK_IM_STATUS_NOTHING;
if (!(style & GDK_IM_STATUS_NOTHING))
{
xim_best_allowed_style |= GDK_IM_STATUS_AREA;
if (!(style & GDK_IM_STATUS_AREA))
xim_best_allowed_style |= GDK_IM_STATUS_CALLBACKS;
}
}
}
return xim_best_allowed_style;
}
static gint
gdk_im_open (XrmDatabase db, gchar* res_name, gchar* res_class)
{
xim_im = XOpenIM (GDK_DISPLAY(), db, res_name, res_class);
if (xim_im == NULL)
{
GDK_NOTE (XIM, g_warning ("Unable to open open IM."));
return FALSE;
}
XGetIMValues (xim_im, XNQueryInputStyle, &xim_styles, NULL, NULL);
return TRUE;
}
static void
gdk_im_close (void)
{
if (xim_im)
{
XCloseIM (xim_im);
xim_im = NULL;
}
if (xim_styles)
{
XFree (xim_styles);
xim_styles = NULL;
}
}
gint
gdk_im_ready (void)
{
return (xim_im != NULL);
}
GdkIC
gdk_ic_new (GdkWindow* client_window,
GdkWindow* focus_window,
GdkIMStyle style, ...)
{
va_list list;
GdkICPrivate *private;
XVaNestedList preedit_attr = NULL;
guint count;
g_return_val_if_fail (client_window != NULL, NULL);
g_return_val_if_fail (focus_window != NULL, NULL);
g_return_val_if_fail (gdk_im_ready(), NULL);
private = g_new (GdkICPrivate, 1);
va_start (list, style);
count = gdk_im_va_count (list);
va_end (list);
va_start (list, style);
preedit_attr = gdk_im_va_to_nested (list, count);
va_end (list);
private->style = gdk_im_decide_style (style);
if (private->style != style)
{
g_warning ("can not create input context with specified input style.");
g_free (private);
return NULL;
}
private->xic = XCreateIC(gdk_im_get (),
XNInputStyle, style,
XNClientWindow, GDK_WINDOW_XWINDOW (client_window),
XNFocusWindow, GDK_WINDOW_XWINDOW (focus_window),
preedit_attr? XNPreeditAttributes : NULL, preedit_attr,
NULL);
g_free (preedit_attr);
if (!private->xic)
{
g_free (private);
return NULL;
}
xim_ic_list = g_list_append (xim_ic_list, private);
return private;
}
void
gdk_ic_destroy (GdkIC ic)
{
GdkICPrivate *private;
g_return_if_fail (ic != NULL);
private = (GdkICPrivate *) ic;
if (xim_ic == private)
gdk_im_end ();
XDestroyIC (private->xic);
xim_ic_list = g_list_remove (xim_ic_list, private);
g_free (private);
}
GdkIMStyle
gdk_ic_get_style (GdkIC ic)
{
GdkICPrivate *private;
g_return_val_if_fail (ic != NULL, 0);
private = (GdkICPrivate *) ic;
return private->style;
}
void
gdk_ic_set_values (GdkIC ic, ...)
{
va_list list;
XVaNestedList args;
GdkICPrivate *private;
guint count;
g_return_if_fail (ic != NULL);
private = (GdkICPrivate *) ic;
va_start (list, ic);
count = gdk_im_va_count (list);
va_end (list);
va_start (list, ic);
args = gdk_im_va_to_nested (list, count);
va_end (list);
XSetICValues (private->xic, XNVaNestedList, args, NULL);
g_free (args);
}
void
gdk_ic_get_values (GdkIC ic, ...)
{
va_list list;
XVaNestedList args;
GdkICPrivate *private;
guint count;
g_return_if_fail (ic != NULL);
private = (GdkICPrivate *) ic;
va_start (list, ic);
count = gdk_im_va_count (list);
va_end (list);
va_start (list, ic);
args = gdk_im_va_to_nested (list, count);
va_end (list);
XGetICValues (private->xic, XNVaNestedList, args, NULL);
g_free (args);
}
void
gdk_ic_set_attr (GdkIC ic, const char *target, ...)
{
va_list list;
XVaNestedList attr;
GdkICPrivate *private;
guint count;
g_return_if_fail (ic != NULL);
g_return_if_fail (target != NULL);
private = (GdkICPrivate *) ic;
va_start (list, target);
count = gdk_im_va_count (list);
va_end (list);
va_start (list, target);
attr = gdk_im_va_to_nested (list, count);
va_end (list);
XSetICValues (private->xic, target, attr, NULL);
g_free (attr);
}
void
gdk_ic_get_attr (GdkIC ic, const char *target, ...)
{
va_list list;
XVaNestedList attr;
GdkICPrivate *private;
guint count;
g_return_if_fail (ic != NULL);
g_return_if_fail (target != NULL);
private = (GdkICPrivate *) ic;
va_start (list, target);
count = gdk_im_va_count (list);
va_end (list);
va_start (list, target);
attr = gdk_im_va_to_nested (list, count);
va_end (list);
XGetICValues (private->xic, target, attr, NULL);
g_free (attr);
}
GdkEventMask
gdk_ic_get_events (GdkIC ic)
{
GdkEventMask mask;
glong xmask;
glong bit;
GdkICPrivate *private;
gint i;
/* From gdkwindow.c */
extern int nevent_masks;
extern int event_mask_table[];
g_return_val_if_fail (ic != NULL, 0);
private = (GdkICPrivate *) ic;
if (XGetICValues (private->xic, XNFilterEvents, &xmask, NULL) != NULL)
{
GDK_NOTE (XIM, g_warning ("Call to XGetICValues: %s failed", XNFilterEvents));
return 0;
}
mask = 0;
for (i=0, bit=2; i < nevent_masks; i++, bit <<= 1)
if (xmask & event_mask_table [i])
{
mask |= bit;
xmask &= ~ event_mask_table [i];
}
if (xmask)
g_warning ("ic requires events not supported by the application (%#04lx)", xmask);
return mask;
}
static void
gdk_ic_cleanup (void)
{
GList* node;
gint destroyed;
GdkICPrivate *private;
destroyed = 0;
for (node = xim_ic_list; node != NULL; node = node->next)
{
if (node->data)
{
private = (GdkICPrivate *) (node->data);
XDestroyIC (private->xic);
g_free (private);
destroyed++;
}
}
#ifdef G_ENABLE_DEBUG
if ((gdk_debug_flags & GDK_DEBUG_XIM) && destroyed > 0)
{
g_warning ("Cleaned up %i IC(s)\n", destroyed);
}
#endif /* G_ENABLE_DEBUG */
g_list_free(xim_ic_list);
xim_ic_list = NULL;
}
#else /* !USE_XIM */
void
gdk_im_begin (GdkIC ic, GdkWindow* window)
{
}
void
gdk_im_end (void)
{
}
GdkIMStyle
gdk_im_decide_style (GdkIMStyle supported_style)
{
return GDK_IM_PREEDIT_NONE | GDK_IM_STATUS_NONE;
}
GdkIMStyle
gdk_im_set_best_style (GdkIMStyle style)
{
return GDK_IM_PREEDIT_NONE | GDK_IM_STATUS_NONE;
}
gint
gdk_im_ready (void)
{
return FALSE;
}
GdkIC
gdk_ic_new (GdkWindow* client_window,
GdkWindow* focus_window,
GdkIMStyle style, ...)
{
return NULL;
}
void
gdk_ic_destroy (GdkIC ic)
{
}
GdkIMStyle
gdk_ic_get_style (GdkIC ic)
{
return GDK_IM_PREEDIT_NONE | GDK_IM_STATUS_NONE;
}
void
gdk_ic_set_values (GdkIC ic, ...)
{
}
void
gdk_ic_get_values (GdkIC ic, ...)
{
}
void
gdk_ic_set_attr (GdkIC ic, const char *target, ...)
{
}
void
gdk_ic_get_attr (GdkIC ic, const char *target, ...)
{
}
GdkEventMask
gdk_ic_get_events (GdkIC ic)
{
return 0;
}
#endif /* USE_XIM */
#ifdef X_LOCALE
gint
_g_mbtowc (wchar_t *wstr, const char *str, size_t len)
{
static wchar_t wcs[MB_CUR_MAX + 1];
static gchar mbs[MB_CUR_MAX + 1];
wcs[0] = (wchar_t) NULL;
mbs[0] = '\0';
/* The last argument isn't a mistake. The X locale code trims
* the input string to the length of the output string!
*/
len = _Xmbstowcs (wcs, str, (len<MB_CUR_MAX)? len:MB_CUR_MAX);
if (len < 1)
return len;
else if (wcs[0] == (wchar_t) NULL)
return -1;
len = _Xwctomb (mbs, wcs[0]);
if (mbs[0] == '\0')
return -1;
if (wstr)
*wstr = wcs[0];
return len;
}
#endif /* X_LOCALE */
/* Sends a ClientMessage to all toplevel client windows */
gboolean
gdk_event_send_client_message (GdkEvent *event, guint32 xid)

View File

@ -323,7 +323,12 @@ gdk_window_new (GdkWindow *parent,
if (attributes_mask & GDK_WA_COLORMAP)
private->colormap = attributes->colormap;
else
private->colormap = gdk_colormap_get_system ();
{
if ((((GdkVisualPrivate*)gdk_visual_get_system())->xvisual) == xvisual)
private->colormap = gdk_colormap_get_system ();
else
private->colormap = gdk_colormap_new (visual, False);
}
xattributes.background_pixel = BlackPixel (gdk_display, gdk_screen);
xattributes.border_pixel = BlackPixel (gdk_display, gdk_screen);

View File

@ -75,7 +75,6 @@ static void gtk_editable_set_arg (GtkObject *object,
static void gtk_editable_get_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
static void gtk_editable_finalize (GtkObject *object);
static gint gtk_editable_selection_clear (GtkWidget *widget,
GdkEventSelection *event);
static void gtk_editable_selection_get (GtkWidget *widget,
@ -96,7 +95,7 @@ static void gtk_editable_real_copy_clipboard (GtkEditable *editable);
static void gtk_editable_real_paste_clipboard (GtkEditable *editable);
static void gtk_editable_real_set_editable (GtkEditable *editable,
gboolean is_editable);
static GtkWidgetClass *parent_class = NULL;
static guint editable_signals[LAST_SIGNAL] = { 0 };
@ -291,7 +290,6 @@ gtk_editable_class_init (GtkEditableClass *class)
object_class->set_arg = gtk_editable_set_arg;
object_class->get_arg = gtk_editable_get_arg;
object_class->finalize = gtk_editable_finalize;
widget_class->selection_clear_event = gtk_editable_selection_clear;
widget_class->selection_received = gtk_editable_selection_received;
@ -399,27 +397,6 @@ gtk_editable_init (GtkEditable *editable)
targets, n_targets);
}
static void
gtk_editable_finalize (GtkObject *object)
{
GtkEditable *editable;
g_return_if_fail (object != NULL);
g_return_if_fail (GTK_IS_EDITABLE (object));
editable = GTK_EDITABLE (object);
#ifdef USE_XIM
if (editable->ic)
{
gdk_ic_destroy (editable->ic);
editable->ic = NULL;
}
#endif
(* GTK_OBJECT_CLASS (parent_class)->finalize) (object);
}
void
gtk_editable_insert_text (GtkEditable *editable,
const gchar *new_text,
@ -594,7 +571,9 @@ gtk_editable_selection_get (GtkWidget *widget,
str = gtk_editable_get_chars(editable,
selection_start_pos,
selection_end_pos);
length = selection_end_pos - selection_start_pos;
if (!str)
return; /* Refuse */
length = strlen (str);
}
else /* CLIPBOARD */
{
@ -938,3 +917,32 @@ gtk_editable_changed (GtkEditable *editable)
gtk_signal_emit (GTK_OBJECT (editable), editable_signals[CHANGED]);
}
#if 0
static void
gtk_editable_parent_set (GtkWidget *widget,
GtkWidget *old_parent,
GtkWidget *editable)
{
GtkWidget *parent;
parent = old_parent;
while (parent)
{
gtk_signal_disconnect_by_func (GTK_OBJECT (parent),
GTK_SIGNAL_FUNC (gtk_editable_parent_set),
editable);
parent = parent->parent;
}
parent = widget->parent;
while (parent)
{
gtk_signal_connect (GTK_OBJECT (parent), "parent_set",
GTK_SIGNAL_FUNC (gtk_editable_parent_set),
editable);
parent = parent->parent;
}
}
#endif

View File

@ -45,13 +45,14 @@ struct _GtkEditable
{
GtkWidget widget;
guint current_pos;
guint current_pos;
guint selection_start_pos;
guint selection_end_pos;
guint has_selection : 1;
guint editable : 1;
GdkIC ic;
guint selection_start_pos;
guint selection_end_pos;
guint has_selection : 1;
guint editable : 1;
GdkIC *ic;
GdkICAttr *ic_attr;
gchar *clipboard_text;
};

File diff suppressed because it is too large Load Diff

View File

@ -46,26 +46,27 @@ struct _GtkEntry
GdkWindow *text_area;
GdkPixmap *backing_pixmap;
GdkCursor *cursor;
gchar *text;
GdkWChar *text;
guint16 text_size;
guint16 text_length;
guint16 text_size; /* allocated size */
guint16 text_length; /* length in use */
guint16 text_max_length;
gint scroll_offset;
guint visible : 1;
guint32 timer;
guint button;
/* The total number of characters (not bytes) in the entry */
guint nchars;
/* The byte offset of each character
* (including the last insertion position) */
guint16 *char_pos;
/* The x-offset of each character (including the last insertion position)
* only valid when the widget is realized */
gint *char_offset;
gint *char_offset;
/* Same as 'text', but in multibyte */
gchar *text_mb;
/* If true, 'text' and 'text_mb' are not coherent */
guint text_mb_dirty : 1;
/* If true, we use the encoding of wchar_t as the encoding of 'text'.
* Otherwise we use the encoding of multi-byte characters instead. */
guint use_wchar : 1;
};
struct _GtkEntryClass
@ -75,7 +76,7 @@ struct _GtkEntryClass
GtkType gtk_entry_get_type (void);
GtkWidget* gtk_entry_new (void);
GtkWidget* gtk_entry_new_with_max_length (guint16 max);
GtkWidget* gtk_entry_new_with_max_length (guint16 max);
void gtk_entry_set_text (GtkEntry *entry,
const gchar *text);
void gtk_entry_append_text (GtkEntry *entry,
@ -84,6 +85,7 @@ void gtk_entry_prepend_text (GtkEntry *entry,
const gchar *text);
void gtk_entry_set_position (GtkEntry *entry,
gint position);
/* returns a reference to the text */
gchar* gtk_entry_get_text (GtkEntry *entry);
void gtk_entry_select_region (GtkEntry *entry,
gint start,

View File

@ -248,15 +248,12 @@ gtk_check_version (guint required_major,
}
gint gtk_use_mb = -1;
void
gtk_init (int *argc,
char ***argv)
{
GSList *gtk_modules = NULL;
GSList *slist;
gchar *current_locale;
gchar *env_string = NULL;
if (gtk_initialized)
@ -397,42 +394,6 @@ gtk_init (int *argc,
}
}
/* Check if there is a good chance the mb functions will handle things
* correctly - set if either mblen("\xc0", MB_CUR_MAX) == 1 in the
* C locale, or we're using X's mb functions. (-DX_LOCALE && locale != C)
*/
current_locale = setlocale (LC_CTYPE, NULL);
#ifdef X_LOCALE
if ((strcmp (current_locale, "C")) && (strcmp (current_locale, "POSIX")))
gtk_use_mb = TRUE;
else
#endif /* X_LOCALE */
{
/* Detect GNU libc, where mb == UTF8. Not useful unless it's
* really a UTF8 locale. The below still probably will
* screw up on Greek, Cyrillic, etc, encoded as UTF8.
*/
wchar_t result;
gtk_use_mb = TRUE;
if ((MB_CUR_MAX == 2) &&
(mbstowcs (&result, "\xdd\xa5", 1) > 0) &&
result == 0x765)
{
if ((strlen (current_locale) < 4) ||
g_strcasecmp (current_locale + strlen(current_locale) - 4, "utf8"))
gtk_use_mb = FALSE;
}
}
GTK_NOTE (MISC,
g_message ("%s multi-byte string functions.",
gtk_use_mb ? "Using" : "Not using"));
/* load gtk modules */
gtk_modules = g_slist_reverse (gtk_modules);
for (slist = gtk_modules; slist; slist = slist->next)

View File

@ -60,12 +60,6 @@ typedef enum
#define GTK_PRIVATE_SET_FLAG(wid,flag) G_STMT_START{ (GTK_PRIVATE_FLAGS (wid) |= (PRIVATE_ ## flag)); }G_STMT_END
#define GTK_PRIVATE_UNSET_FLAG(wid,flag) G_STMT_START{ (GTK_PRIVATE_FLAGS (wid) &= ~(PRIVATE_ ## flag)); }G_STMT_END
/* True if there is a good chance the mb functions will handle things
* correctly - set if either mblen("\xc0", MB_CUR_MAX) == 1 in the
* C locale, or were using X's mb functions. (-DX_LOCALE && locale != C)
*/
extern gint gtk_use_mb;
#ifdef __cplusplus
}
#endif /* __cplusplus */

View File

@ -1182,8 +1182,11 @@ gtk_spin_button_insert_text (GtkEditable *editable,
gboolean sign;
gint dotpos = -1;
gint i;
gchar pos_sign;
gchar neg_sign;
GdkWChar pos_sign;
GdkWChar neg_sign;
guint entry_length;
entry_length = entry->text_length;
lc = localeconv ();
@ -1197,16 +1200,27 @@ gtk_spin_button_insert_text (GtkEditable *editable,
else
pos_sign = '+';
sign = ((strchr (entry->text, neg_sign) != 0) ||
(strchr (entry->text, pos_sign) != 0));
for (sign=0, i=0; i<entry_length; i++)
if ((entry->text[i] == neg_sign) ||
(entry->text[i] == pos_sign))
{
sign = 1;
break;
}
if (sign && !(*position))
return;
dotpos = strchr (entry->text, *(lc->decimal_point)) - entry->text;
for (dotpos=-1, i=0; i<entry_length; i++)
if (entry->text[i] == *(lc->decimal_point))
{
dotpos = i;
break;
}
if (dotpos > -1 && *position > dotpos &&
spin->digits - entry->text_length + dotpos - new_text_length + 1 < 0)
spin->digits - entry_length
+ dotpos - new_text_length + 1 < 0)
return;
for (i = 0; i < new_text_length; i++)
@ -1220,8 +1234,8 @@ gtk_spin_button_insert_text (GtkEditable *editable,
else if (new_text[i] == *(lc->decimal_point))
{
if (!spin->digits || dotpos > -1 ||
(new_text_length - 1 - i + entry->text_length - *position >
spin->digits))
(new_text_length - 1 - i + entry_length
- *position > spin->digits))
return;
dotpos = *position + i;
}

View File

@ -19,9 +19,7 @@
#include <ctype.h>
#include <string.h>
#include "gdk/gdkkeysyms.h"
#ifdef USE_XIM
#include "gdk/gdkx.h"
#endif
#include "gdk/gdki18n.h"
#include "gtkmain.h"
#include "gtkselection.h"
#include "gtksignal.h"
@ -248,7 +246,7 @@ static gint gtk_text_focus_in (GtkWidget *widget,
static gint gtk_text_focus_out (GtkWidget *widget,
GdkEventFocus *event);
static void move_gap_to_point (GtkText* text);
static void move_gap (GtkText* text, guint index);
static void make_forward_space (GtkText* text, guint len);
/* Property management */
@ -674,9 +672,13 @@ gtk_text_init (GtkText *text)
text->line_wrap_bitmap = NULL;
text->line_arrow_bitmap = NULL;
text->text = g_new (guchar, INITIAL_BUFFER_SIZE);
text->use_wchar = FALSE;
text->text.ch = g_new (guchar, INITIAL_BUFFER_SIZE);
text->text_len = INITIAL_BUFFER_SIZE;
text->scratch_buffer.ch = NULL;
text->scratch_buffer_len = 0;
text->freeze_count = 0;
if (!params_mem_chunk)
@ -921,6 +923,7 @@ gtk_text_insert (GtkText *text,
guint old_height = 0;
guint length;
guint i;
gint numwcs;
g_return_if_fail (text != NULL);
g_return_if_fail (GTK_IS_TEXT (text));
@ -943,37 +946,90 @@ gtk_text_insert (GtkText *text,
{
find_line_containing_point (text, text->point.index, TRUE);
old_height = total_line_height (text, text->current_line, 1);
for (i=0; i<length; i++)
if (chars[i] == '\n')
new_line_count++;
}
if (text->point.index < text->first_line_start_index)
text->first_line_start_index += length;
if (text->point.index < editable->selection_start_pos)
editable->selection_start_pos += length;
if (text->point.index < editable->selection_end_pos)
editable->selection_end_pos += length;
/* We'll reset the cursor later anyways if we aren't frozen */
if (text->point.index < text->cursor_mark.index)
text->cursor_mark.index += length;
move_gap_to_point (text);
if ((TEXT_LENGTH (text) == 0) && (text->use_wchar == FALSE))
{
GtkWidget *widget;
widget = GTK_WIDGET (text);
gtk_widget_ensure_style (widget);
if ((widget->style) && (widget->style->font->type == GDK_FONT_FONTSET))
{
text->use_wchar = TRUE;
g_free (text->text.ch);
text->text.wc = g_new (GdkWChar, INITIAL_BUFFER_SIZE);
text->text_len = INITIAL_BUFFER_SIZE;
if (text->scratch_buffer.ch)
g_free (text->scratch_buffer.ch);
text->scratch_buffer.wc = NULL;
text->scratch_buffer_len = 0;
}
}
move_gap (text, text->point.index);
make_forward_space (text, length);
memcpy (text->text + text->gap_position, chars, length);
if (text->use_wchar)
{
char *chars_nt = (char *)chars;
if (nchars > 0)
{
chars_nt = g_new (char, length+1);
memcpy (chars_nt, chars, length);
chars_nt[length] = 0;
}
numwcs = gdk_mbstowcs (text->text.wc + text->gap_position, chars_nt,
length);
if (chars_nt != chars)
g_free(chars_nt);
if (numwcs < 0)
numwcs = 0;
}
else
{
numwcs = length;
memcpy(text->text.ch + text->gap_position, chars, length);
}
if (!text->freeze_count && (text->line_start_cache != NULL))
{
if (text->use_wchar)
{
for (i=0; i<numwcs; i++)
if (text->text.wc[text->gap_position + i] == '\n')
new_line_count++;
}
else
{
for (i=0; i<numwcs; i++)
if (text->text.ch[text->gap_position + i] == '\n')
new_line_count++;
}
}
if (numwcs > 0)
{
insert_text_property (text, font, fore, back, numwcs);
text->gap_size -= numwcs;
text->gap_position += numwcs;
if (text->point.index < text->first_line_start_index)
text->first_line_start_index += numwcs;
if (text->point.index < editable->selection_start_pos)
editable->selection_start_pos += numwcs;
if (text->point.index < editable->selection_end_pos)
editable->selection_end_pos += numwcs;
/* We'll reset the cursor later anyways if we aren't frozen */
if (text->point.index < text->cursor_mark.index)
text->cursor_mark.index += numwcs;
insert_text_property (text, font, fore, back, length);
text->gap_size -= length;
text->gap_position += length;
advance_mark_n (&text->point, length);
if (!text->freeze_count && text->line_start_cache != NULL)
insert_expose (text, old_height, length, new_line_count);
advance_mark_n (&text->point, numwcs);
if (!text->freeze_count && (text->line_start_cache != NULL))
insert_expose (text, old_height, numwcs, new_line_count);
}
if (frozen)
gtk_text_thaw (text);
}
@ -1030,7 +1086,8 @@ gtk_text_forward_delete (GtkText *text,
{
text->first_line_start_index = text->point.index;
while ((text->first_line_start_index > 0) &&
(GTK_TEXT_INDEX (text, text->first_line_start_index - 1) != LINE_DELIM))
(GTK_TEXT_INDEX (text, text->first_line_start_index - 1)
!= LINE_DELIM))
text->first_line_start_index -= 1;
}
@ -1049,7 +1106,7 @@ gtk_text_forward_delete (GtkText *text,
move_mark_n (&text->cursor_mark,
-MIN(nchars, text->cursor_mark.index - text->point.index));
move_gap_to_point (text);
move_gap (text, text->point.index);
text->gap_size += nchars;
@ -1086,10 +1143,8 @@ gtk_text_get_chars (GtkEditable *editable,
gint end_pos)
{
GtkText *text;
gchar *retval;
gchar *p;
guint n, nchars;
g_return_val_if_fail (editable != NULL, NULL);
g_return_val_if_fail (GTK_IS_TEXT (editable), NULL);
@ -1103,31 +1158,26 @@ gtk_text_get_chars (GtkEditable *editable,
(end_pos < start_pos))
return NULL;
nchars = end_pos - start_pos;
retval = g_new (gchar, nchars+1);
p = retval;
if (start_pos < text->gap_position)
move_gap (text, TEXT_LENGTH (text));
make_forward_space (text, 1);
if (text->use_wchar)
{
n = MIN (text->gap_position - start_pos, nchars);
memcpy (p, &text->text[start_pos], n);
p += n;
start_pos += n;
nchars -= n;
GdkWChar ch;
ch = text->text.wc[end_pos];
text->text.wc[end_pos] = 0;
retval = gdk_wcstombs (text->text.wc + start_pos);
text->text.wc[end_pos] = ch;
}
if (start_pos+nchars >= text->gap_position)
else
{
memcpy (p,
text->text + MAX (text->gap_position + text->gap_size,
start_pos + text->gap_size),
nchars);
p += nchars;
guchar ch;
ch = text->text.ch[end_pos];
text->text.ch[end_pos] = 0;
retval = g_strdup (text->text.ch + start_pos);
text->text.ch[end_pos] = ch;
}
*p = 0;
return retval;
}
@ -1169,7 +1219,10 @@ gtk_text_finalize (GtkObject *object)
gtk_object_unref (GTK_OBJECT (text->vadj));
/* Clean up the internal structures */
g_free (text->text);
if (text->use_wchar)
g_free (text->text.wc);
else
g_free (text->text.ch);
free_cache (text);
tmp_list = text->text_properties;
@ -1184,8 +1237,16 @@ gtk_text_finalize (GtkObject *object)
g_list_free (text->text_properties);
if (text->scratch_buffer)
g_free (text->scratch_buffer);
if (text->use_wchar)
{
if (text->scratch_buffer.wc)
g_free (text->scratch_buffer.wc);
}
else
{
if (text->scratch_buffer.ch)
g_free (text->scratch_buffer.ch);
}
g_list_free (text->tab_stops);
@ -1257,12 +1318,13 @@ gtk_text_realize (GtkWidget *widget)
gdk_gc_set_foreground (text->gc, &widget->style->text[GTK_STATE_NORMAL]);
#ifdef USE_XIM
if (gdk_im_ready ())
if (gdk_im_ready () && (editable->ic_attr = gdk_ic_attr_new ()) != NULL)
{
GdkPoint spot;
GdkRectangle rect;
gint width, height;
GdkColormap *colormap;
GdkEventMask mask;
GdkICAttr *attr = editable->ic_attr;
GdkICAttributesType attrmask = GDK_IC_ALL_REQ;
GdkIMStyle style;
GdkIMStyle supported_style = GDK_IM_PREEDIT_NONE |
GDK_IM_PREEDIT_NOTHING |
@ -1273,7 +1335,16 @@ gtk_text_realize (GtkWidget *widget)
if (widget->style && widget->style->font->type != GDK_FONT_FONTSET)
supported_style &= ~GDK_IM_PREEDIT_POSITION;
style = gdk_im_decide_style (supported_style);
attr->style = style = gdk_im_decide_style (supported_style);
attr->client_window = text->text_area;
if ((colormap = gtk_widget_get_colormap (widget)) !=
gtk_widget_get_default_colormap ())
{
attrmask |= GDK_IC_PREEDIT_COLORMAP;
attr->preedit_colormap = colormap;
}
switch (style & GDK_IM_PREEDIT_MASK)
{
case GDK_IM_PREEDIT_POSITION:
@ -1282,43 +1353,31 @@ gtk_text_realize (GtkWidget *widget)
g_warning ("over-the-spot style requires fontset");
break;
}
attrmask |= GDK_IC_PREEDIT_POSITION_REQ;
gdk_window_get_size (text->text_area, &width, &height);
rect.x = 0;
rect.y = 0;
rect.width = width;
rect.height = height;
spot.x = 0;
spot.y = height;
attr->spot_location.x = 0;
attr->spot_location.y = height;
attr->preedit_area.x = 0;
attr->preedit_area.y = 0;
attr->preedit_area.width = width;
attr->preedit_area.height = height;
attr->preedit_fontset = widget->style->font;
editable->ic = gdk_ic_new (text->text_area, text->text_area,
style,
"spotLocation", &spot,
"area", &rect,
"fontSet", GDK_FONT_XFONT (widget->style->font),
NULL);
break;
default:
editable->ic = gdk_ic_new (text->text_area, text->text_area,
style, NULL);
}
editable->ic = gdk_ic_new (attr, attrmask);
if (editable->ic == NULL)
g_warning ("Can't create input context.");
else
{
GdkColormap *colormap;
mask = gdk_window_get_events (text->text_area);
mask |= gdk_ic_get_events (editable->ic);
gdk_window_set_events (text->text_area, mask);
if ((colormap = gtk_widget_get_colormap (widget)) !=
gtk_widget_get_default_colormap ())
{
gdk_ic_set_attr (editable->ic, "preeditAttributes",
"colorMap", GDK_COLORMAP_XCOLORMAP (colormap),
NULL);
}
if (GTK_WIDGET_HAS_FOCUS (widget))
gdk_im_begin (editable->ic, text->text_area);
}
}
#endif
@ -1368,7 +1427,20 @@ gtk_text_unrealize (GtkWidget *widget)
g_return_if_fail (GTK_IS_TEXT (widget));
text = GTK_TEXT (widget);
#ifdef USE_XIM
if (GTK_EDITABLE (widget)->ic)
{
gdk_ic_destroy (GTK_EDITABLE (widget)->ic);
GTK_EDITABLE (widget)->ic = NULL;
}
if (GTK_EDITABLE (widget)->ic_attr)
{
gdk_ic_attr_destroy (GTK_EDITABLE (widget)->ic_attr);
GTK_EDITABLE (widget)->ic_attr = NULL;
}
#endif
gdk_window_set_user_data (text->text_area, NULL);
gdk_window_destroy (text->text_area);
text->text_area = NULL;
@ -1569,14 +1641,13 @@ gtk_text_size_allocate (GtkWidget *widget,
if (editable->ic && (gdk_ic_get_style (editable->ic) & GDK_IM_PREEDIT_POSITION))
{
gint width, height;
GdkRectangle rect;
gdk_window_get_size (text->text_area, &width, &height);
rect.x = 0;
rect.y = 0;
rect.width = width;
rect.height = height;
gdk_ic_set_attr (editable->ic, "preeditAttributes", "area", &rect, NULL);
editable->ic_attr->preedit_area.width = width;
editable->ic_attr->preedit_area.height = height;
gdk_ic_set_attr (editable->ic,
editable->ic_attr, GDK_IC_PREEDIT_AREA);
}
#endif
@ -2095,12 +2166,9 @@ gtk_text_key_press (GtkWidget *widget,
{
extend_selection = FALSE;
if (event->length == 1)
{
gtk_editable_delete_selection (editable);
position = text->point.index;
gtk_editable_insert_text (editable, &(event->string[0]), 1, &position);
}
gtk_editable_delete_selection (editable);
position = text->point.index;
gtk_editable_insert_text (editable, event->string, event->length, &position);
return_val = TRUE;
}
@ -3023,27 +3091,37 @@ destroy_text_property (TextProperty *prop)
/* Flop the memory between the point and the gap around like a
* dead fish. */
static void
move_gap_to_point (GtkText* text)
move_gap (GtkText* text, guint index)
{
if (text->gap_position < text->point.index)
if (text->gap_position < index)
{
gint diff = text->point.index - text->gap_position;
gint diff = index - text->gap_position;
g_memmove (text->text + text->gap_position,
text->text + text->gap_position + text->gap_size,
diff);
if (text->use_wchar)
g_memmove (text->text.wc + text->gap_position,
text->text.wc + text->gap_position + text->gap_size,
diff*sizeof (GdkWChar));
else
g_memmove (text->text.ch + text->gap_position,
text->text.ch + text->gap_position + text->gap_size,
diff);
text->gap_position = text->point.index;
text->gap_position = index;
}
else if (text->gap_position > text->point.index)
else if (text->gap_position > index)
{
gint diff = text->gap_position - text->point.index;
gint diff = text->gap_position - index;
g_memmove (text->text + text->point.index + text->gap_size,
text->text + text->point.index,
diff);
if (text->use_wchar)
g_memmove (text->text.wc + index + text->gap_size,
text->text.wc + index,
diff*sizeof (GdkWChar));
else
g_memmove (text->text.ch + index + text->gap_size,
text->text.ch + index,
diff);
text->gap_position = text->point.index;
text->gap_position = index;
}
}
@ -3061,12 +3139,23 @@ make_forward_space (GtkText* text, guint len)
while (i <= sum) i <<= 1;
text->text = (guchar*)g_realloc(text->text, i);
if (text->use_wchar)
text->text.wc = (GdkWChar *)g_realloc(text->text.wc,
i*sizeof(GdkWChar));
else
text->text.ch = (guchar *)g_realloc(text->text.ch, i);
text->text_len = i;
}
g_memmove (text->text + text->gap_position + text->gap_size + 2*len,
text->text + text->gap_position + text->gap_size,
text->text_end - (text->gap_position + text->gap_size));
if (text->use_wchar)
g_memmove (text->text.wc + text->gap_position + text->gap_size + 2*len,
text->text.wc + text->gap_position + text->gap_size,
(text->text_end - (text->gap_position + text->gap_size))
*sizeof(GdkWChar));
else
g_memmove (text->text.ch + text->gap_position + text->gap_size + 2*len,
text->text.ch + text->gap_position + text->gap_size,
text->text_end - (text->gap_position + text->gap_size));
text->text_end += len*2;
text->gap_size += len*2;
@ -3498,8 +3587,8 @@ find_line_containing_point (GtkText* text, guint point,
( (text->first_cut_pixels == 0) &&
(CACHE_DATA(text->line_start_cache).start.index > point) ) )
{
scroll_int (text, - SCROLL_PIXELS);
g_assert (text->line_start_cache->next);
scroll_int (text, - LINE_HEIGHT(CACHE_DATA(text->line_start_cache->next)));
}
TEXT_SHOW (text);
@ -3567,7 +3656,7 @@ pixel_height_of (GtkText* text, GList* cache_line)
static gint
find_char_width (GtkText* text, const GtkPropertyMark *mark, const TabStopMark *tab_mark)
{
gchar ch;
GdkWChar ch;
gint16* char_widths;
if (LAST_INDEX (text, *mark))
@ -3580,14 +3669,18 @@ find_char_width (GtkText* text, const GtkPropertyMark *mark, const TabStopMark *
{
return tab_mark->to_next_tab * char_widths[' '];
}
else if (ch < 256)
{
return char_widths[ch];
}
else
{
return char_widths[ch & 0xff];
return gdk_char_width_wc(MARK_CURRENT_TEXT_FONT(text, mark)->gdk_font, ch);
}
}
static void
advance_tab_mark (GtkText* text, TabStopMark* tab_mark, gchar ch)
advance_tab_mark (GtkText* text, TabStopMark* tab_mark, GdkWChar ch)
{
if (tab_mark->to_next_tab == 1 || ch == '\t')
{
@ -3618,7 +3711,7 @@ advance_tab_mark_n (GtkText* text, TabStopMark* tab_mark, gint n)
static void
find_cursor_at_line (GtkText* text, const LineParams* start_line, gint pixel_height)
{
gchar ch;
GdkWChar ch;
GtkEditable *editable = (GtkEditable *)text;
GtkPropertyMark mark = start_line->start;
@ -3641,30 +3734,32 @@ find_cursor_at_line (GtkText* text, const LineParams* start_line, gint pixel_hei
ch = LAST_INDEX (text, mark) ?
LINE_DELIM : GTK_TEXT_INDEX (text, mark.index);
if (!isspace(ch))
text->cursor_char = ch;
else
if ((text->use_wchar) ? gdk_iswspace (ch) : isspace (ch))
text->cursor_char = 0;
else
text->cursor_char = ch;
#ifdef USE_XIM
if (gdk_im_ready() && editable->ic &&
gdk_ic_get_style (editable->ic) & GDK_IM_PREEDIT_POSITION)
if (GTK_WIDGET_HAS_FOCUS(text) && gdk_im_ready() && editable->ic &&
(gdk_ic_get_style (editable->ic) & GDK_IM_PREEDIT_POSITION))
{
GdkPoint spot;
spot.x = text->cursor_pos_x;
spot.y = text->cursor_pos_y - text->cursor_char_offset;
GdkICAttributesType mask = GDK_IC_SPOT_LOCATION |
GDK_IC_PREEDIT_FOREGROUND |
GDK_IC_PREEDIT_BACKGROUND;
editable->ic_attr->spot_location.x = text->cursor_pos_x;
editable->ic_attr->spot_location.y
= text->cursor_pos_y - text->cursor_char_offset;
editable->ic_attr->preedit_foreground = *MARK_CURRENT_FORE (text, &mark);
editable->ic_attr->preedit_background = *MARK_CURRENT_BACK (text, &mark);
if (MARK_CURRENT_FONT (text, &mark)->type == GDK_FONT_FONTSET)
gdk_ic_set_attr (editable->ic, "preeditAttributes",
"fontSet", GDK_FONT_XFONT (MARK_CURRENT_FONT (text, &mark)),
NULL);
{
mask |= GDK_IC_PREEDIT_FONTSET;
editable->ic_attr->preedit_fontset = MARK_CURRENT_FONT (text, &mark);
}
gdk_ic_set_attr (editable->ic, "preeditAttributes",
"spotLocation", &spot,
"lineSpace", LINE_HEIGHT (*start_line),
"foreground", MARK_CURRENT_FORE (text, &mark)->pixel,
"background", MARK_CURRENT_BACK (text, &mark)->pixel,
NULL);
gdk_ic_set_attr (editable->ic, editable->ic_attr, mask);
}
#endif
}
@ -3700,7 +3795,7 @@ find_mouse_cursor_at_line (GtkText *text, const LineParams* lp,
for (;;)
{
gchar ch = LAST_INDEX (text, mark) ?
GdkWChar ch = LAST_INDEX (text, mark) ?
LINE_DELIM : GTK_TEXT_INDEX (text, mark.index);
if (button_x < pixel_width || mark.index == lp->end.index)
@ -3709,10 +3804,10 @@ find_mouse_cursor_at_line (GtkText *text, const LineParams* lp,
text->cursor_mark = mark;
text->cursor_char_offset = lp->font_descent;
if (!isspace(ch))
text->cursor_char = ch;
else
if ((text->use_wchar) ? gdk_iswspace (ch) : isspace (ch))
text->cursor_char = 0;
else
text->cursor_char = ch;
break;
}
@ -3872,7 +3967,8 @@ move_cursor_ver (GtkText *text, int count)
}
for (i=0; i < text->cursor_virtual_x; i += 1, advance_mark(&mark))
if (LAST_INDEX(text, mark) || GTK_TEXT_INDEX(text, mark.index) == LINE_DELIM)
if (LAST_INDEX(text, mark) ||
GTK_TEXT_INDEX(text, mark.index) == LINE_DELIM)
break;
undraw_cursor (text, FALSE);
@ -3979,13 +4075,26 @@ gtk_text_move_forward_word (GtkText *text)
undraw_cursor (text, FALSE);
while (!LAST_INDEX (text, text->cursor_mark) &&
!isalnum (GTK_TEXT_INDEX(text, text->cursor_mark.index)))
advance_mark (&text->cursor_mark);
while (!LAST_INDEX (text, text->cursor_mark) &&
isalnum (GTK_TEXT_INDEX(text, text->cursor_mark.index)))
advance_mark (&text->cursor_mark);
if (text->use_wchar)
{
while (!LAST_INDEX (text, text->cursor_mark) &&
!gdk_iswalnum (GTK_TEXT_INDEX(text, text->cursor_mark.index)))
advance_mark (&text->cursor_mark);
while (!LAST_INDEX (text, text->cursor_mark) &&
gdk_iswalnum (GTK_TEXT_INDEX(text, text->cursor_mark.index)))
advance_mark (&text->cursor_mark);
}
else
{
while (!LAST_INDEX (text, text->cursor_mark) &&
!isalnum (GTK_TEXT_INDEX(text, text->cursor_mark.index)))
advance_mark (&text->cursor_mark);
while (!LAST_INDEX (text, text->cursor_mark) &&
isalnum (GTK_TEXT_INDEX(text, text->cursor_mark.index)))
advance_mark (&text->cursor_mark);
}
find_cursor (text, TRUE);
draw_cursor (text, FALSE);
@ -3998,13 +4107,26 @@ gtk_text_move_backward_word (GtkText *text)
undraw_cursor (text, FALSE);
while ((text->cursor_mark.index > 0) &&
!isalnum (GTK_TEXT_INDEX(text, text->cursor_mark.index-1)))
decrement_mark (&text->cursor_mark);
while ((text->cursor_mark.index > 0) &&
isalnum (GTK_TEXT_INDEX(text, text->cursor_mark.index-1)))
decrement_mark (&text->cursor_mark);
if (text->use_wchar)
{
while ((text->cursor_mark.index > 0) &&
!gdk_iswalnum (GTK_TEXT_INDEX(text, text->cursor_mark.index-1)))
decrement_mark (&text->cursor_mark);
while ((text->cursor_mark.index > 0) &&
gdk_iswalnum (GTK_TEXT_INDEX(text, text->cursor_mark.index-1)))
decrement_mark (&text->cursor_mark);
}
else
{
while ((text->cursor_mark.index > 0) &&
!isalnum (GTK_TEXT_INDEX(text, text->cursor_mark.index-1)))
decrement_mark (&text->cursor_mark);
while ((text->cursor_mark.index > 0) &&
isalnum (GTK_TEXT_INDEX(text, text->cursor_mark.index-1)))
decrement_mark (&text->cursor_mark);
}
find_cursor (text, TRUE);
draw_cursor (text, FALSE);
@ -4544,7 +4666,7 @@ find_line_params (GtkText* text,
LineParams lp;
TabStopMark tab_mark = tab_cont->tab_start;
guint max_display_pixels;
gchar ch;
GdkWChar ch;
gint ch_width;
GdkFont *font;
@ -4626,11 +4748,23 @@ find_line_params (GtkText* text,
lp.displayable_chars += 1;
while (!isspace (GTK_TEXT_INDEX (text, lp.end.index)) &&
(lp.end.index > lp.start.index))
if (text->use_wchar)
{
decrement_mark (&lp.end);
lp.displayable_chars -= 1;
while (!gdk_iswspace (GTK_TEXT_INDEX (text, lp.end.index)) &&
(lp.end.index > lp.start.index))
{
decrement_mark (&lp.end);
lp.displayable_chars -= 1;
}
}
else
{
while (!isspace(GTK_TEXT_INDEX (text, lp.end.index)) &&
(lp.end.index > lp.start.index))
{
decrement_mark (&lp.end);
lp.displayable_chars -= 1;
}
}
/* If whole line is one word, revert to char wrapping */
@ -4689,10 +4823,21 @@ expand_scratch_buffer (GtkText* text, guint len)
while (i <= len && i < MIN_GAP_SIZE) i <<= 1;
if (text->scratch_buffer)
text->scratch_buffer = g_new (guchar, i);
if (text->use_wchar)
{
if (text->scratch_buffer.wc)
text->scratch_buffer.wc = g_new (GdkWChar, i);
else
text->scratch_buffer.wc = g_realloc (text->scratch_buffer.wc,
i*sizeof (GdkWChar));
}
else
text->scratch_buffer = g_realloc (text->scratch_buffer, i);
{
if (text->scratch_buffer.ch)
text->scratch_buffer.ch = g_new (guchar, i);
else
text->scratch_buffer.ch = g_realloc (text->scratch_buffer.ch, i);
}
text->scratch_buffer_len = i;
}
@ -4751,7 +4896,7 @@ draw_line (GtkText* text,
gint i;
gint len = 0;
guint running_offset = lp->tab_cont.pixel_offset;
guchar* buffer;
union { GdkWChar *wc; guchar *ch; } buffer;
GdkGC *fg_gc;
GtkEditable *editable = GTK_EDITABLE(text);
@ -4772,17 +4917,35 @@ draw_line (GtkText* text,
{
expand_scratch_buffer (text, chars);
for (i = 0; i < chars; i += 1)
text->scratch_buffer[i] = GTK_TEXT_INDEX(text, mark.index + i);
buffer = text->scratch_buffer;
if (text->use_wchar)
{
for (i = 0; i < chars; i += 1)
text->scratch_buffer.wc[i] = GTK_TEXT_INDEX(text, mark.index + i);
buffer.wc = text->scratch_buffer.wc;
}
else
{
for (i = 0; i < chars; i += 1)
text->scratch_buffer.ch[i] = GTK_TEXT_INDEX(text, mark.index + i);
buffer.ch = text->scratch_buffer.ch;
}
}
else
{
if (mark.index >= text->gap_position)
buffer = text->text + mark.index + text->gap_size;
if (text->use_wchar)
{
if (mark.index >= text->gap_position)
buffer.wc = text->text.wc + mark.index + text->gap_size;
else
buffer.wc = text->text.wc + mark.index;
}
else
buffer = text->text + mark.index;
{
if (mark.index >= text->gap_position)
buffer.ch = text->text.ch + mark.index + text->gap_size;
else
buffer.ch = text->text.ch + mark.index;
}
}
@ -4792,19 +4955,42 @@ draw_line (GtkText* text,
LINE_HEIGHT (*lp), TRUE);
}
for (; chars > 0; chars -= len, buffer += len, len = 0)
while (chars > 0)
{
if (buffer[0] != '\t')
len = 0;
if ((text->use_wchar && buffer.wc[0] != '\t') ||
(!text->use_wchar && buffer.ch[0] != '\t'))
{
guchar* next_tab = memchr (buffer, '\t', chars);
union { GdkWChar *wc; guchar *ch; } next_tab;
gint pixel_width;
GdkFont *font;
next_tab.wc = NULL;
if (text->use_wchar)
for (i=0; i<chars; i++)
{
if (buffer.wc[i] == '\t')
{
next_tab.wc = buffer.wc + i;
break;
}
}
else
next_tab.ch = memchr (buffer.ch, '\t', chars);
len = MIN (MARK_CURRENT_PROPERTY (&mark)->length - mark.offset, chars);
if (next_tab)
len = MIN (len, next_tab - buffer);
if (text->use_wchar)
{
if (next_tab.wc)
len = MIN (len, next_tab.wc - buffer.wc);
}
else
{
if (next_tab.ch)
len = MIN (len, next_tab.ch - buffer.ch);
}
if (mark.index < selection_start_pos)
len = MIN (len, selection_start_pos - mark.index);
else if (mark.index < selection_end_pos)
@ -4815,11 +5001,20 @@ draw_line (GtkText* text,
{
gdk_gc_set_font (text->gc, font);
gdk_gc_get_values (text->gc, &gc_values);
if (text->use_wchar)
pixel_width = gdk_text_width_wc (gc_values.font,
buffer.wc, len);
else
pixel_width = gdk_text_width (gc_values.font,
(gchar*) buffer, len);
buffer.ch, len);
}
else
pixel_width = gdk_text_width (font, (gchar*) buffer, len);
{
if (text->use_wchar)
pixel_width = gdk_text_width_wc (font, buffer.wc, len);
else
pixel_width = gdk_text_width (font, buffer.ch, len);
}
draw_bg_rect (text, &mark, running_offset, pixel_start_height,
pixel_width, LINE_HEIGHT (*lp), TRUE);
@ -4838,12 +5033,20 @@ draw_line (GtkText* text,
fg_gc = text->gc;
}
gdk_draw_text (text->text_area, MARK_CURRENT_FONT (text, &mark),
fg_gc,
running_offset,
pixel_height,
(gchar*) buffer,
len);
if (text->use_wchar)
gdk_draw_text_wc (text->text_area, MARK_CURRENT_FONT (text, &mark),
fg_gc,
running_offset,
pixel_height,
buffer.wc,
len);
else
gdk_draw_text (text->text_area, MARK_CURRENT_FONT (text, &mark),
fg_gc,
running_offset,
pixel_height,
buffer.ch,
len);
running_offset += pixel_width;
@ -4875,6 +5078,11 @@ draw_line (GtkText* text,
}
advance_mark_n (&mark, len);
if (text->use_wchar)
buffer.wc += len;
else
buffer.ch += len;
chars -= len;
}
}
@ -4958,7 +5166,7 @@ undraw_cursor (GtkText* text, gint absolute)
gdk_gc_set_foreground (text->gc, MARK_CURRENT_FORE (text, &text->cursor_mark));
gdk_draw_text (text->text_area, font,
gdk_draw_text_wc (text->text_area, font,
text->gc,
text->cursor_pos_x,
text->cursor_pos_y - text->cursor_char_offset,

View File

@ -70,7 +70,7 @@ struct _GtkText
/* The text, a single segment of text a'la emacs, with a gap
* where insertion occurs. */
guchar* text;
union { GdkWChar *wc; guchar *ch; } text;
/* The allocated length of the text segment. */
guint text_len;
/* The gap position, index into address where a char
@ -94,7 +94,7 @@ struct _GtkText
/* First visible horizontal pixel. */
guint first_onscreen_hor_pixel;
/* First visible vertical pixel. */
guint first_onscreen_ver_pixel;
guint first_onscreen_ver_pixel;
/* FLAGS */
@ -102,6 +102,9 @@ struct _GtkText
* horizontal scrollbar. */
guint line_wrap : 1;
guint word_wrap : 1;
/* If a fontset is supplied for the widget, use_wchar become true,
* and we use GdkWchar as the encoding of text. */
guint use_wchar : 1;
/* Frozen, don't do updates. @@@ fixme */
guint freeze_count;
@ -119,7 +122,7 @@ struct _GtkText
/* SCRATCH AREA */
guchar* scratch_buffer;
union { GdkWChar *wc; guchar *ch; } scratch_buffer;
guint scratch_buffer_len;
/* SCROLLING */
@ -131,7 +134,7 @@ struct _GtkText
gint cursor_pos_x; /* Position of cursor. */
gint cursor_pos_y; /* Baseline of line cursor is drawn on. */
GtkPropertyMark cursor_mark; /* Where it is in the buffer. */
gchar cursor_char; /* Character to redraw. */
GdkWChar cursor_char; /* Character to redraw. */
gchar cursor_char_offset; /* Distance from baseline of the font. */
gint cursor_virtual_x; /* Where it would be if it could be. */
gint cursor_drawn_level; /* How many people have undrawn. */
@ -192,9 +195,11 @@ gint gtk_text_backward_delete (GtkText *text,
gint gtk_text_forward_delete (GtkText *text,
guint nchars);
#define GTK_TEXT_INDEX(t, index) \
((index) < (t)->gap_position ? (t)->text[index] : \
(t)->text[(index) + (t)->gap_size])
#define GTK_TEXT_INDEX(t, index) (((t)->use_wchar) \
? ((index) < (t)->gap_position ? (t)->text.wc[index] : \
(t)->text.wc[(index)+(t)->gap_size]) \
: ((index) < (t)->gap_position ? (t)->text.ch[index] : \
(t)->text.ch[(index)+(t)->gap_size]))
#ifdef __cplusplus
}

View File

@ -4259,14 +4259,25 @@ gtk_widget_real_unrealize (GtkWidget *widget)
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_WIDGET (widget));
if (GTK_WIDGET_NO_WINDOW (widget) && GTK_WIDGET_MAPPED (widget))
if (GTK_WIDGET_MAPPED (widget))
gtk_widget_real_unmap (widget);
GTK_WIDGET_UNSET_FLAGS (widget, GTK_REALIZED | GTK_MAPPED);
GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
/* printf ("unrealizing %s\n", gtk_type_name (GTK_OBJECT(widget)->klass->type));
*/
/* We must do unrealize child widget BEFORE container widget.
* gdk_window_destroy() destroys specified xwindow and it's sub-xwindows.
* So, unrealizing container widget bofore it's children causes the problem
* (for example, gdk_ic_destroy () with destroyed window causes crash. )
*/
if (GTK_IS_CONTAINER (widget))
gtk_container_foreach (GTK_CONTAINER (widget),
(GtkCallback) gtk_widget_unrealize,
NULL);
gtk_style_detach (widget->style);
if (!GTK_WIDGET_NO_WINDOW (widget))
{
@ -4280,12 +4291,7 @@ gtk_widget_real_unrealize (GtkWidget *widget)
widget->window = NULL;
}
/* Unrealize afterwards to improve visual effect */
if (GTK_IS_CONTAINER (widget))
gtk_container_forall (GTK_CONTAINER (widget),
(GtkCallback) gtk_widget_unrealize,
NULL);
GTK_WIDGET_UNSET_FLAGS (widget, GTK_REALIZED);
}
/*****************************************

View File

@ -5750,19 +5750,29 @@ create_text (void)
if (infile)
{
char buffer[1024];
int nchars;
char *buffer;
int nbytes_read, nbytes_alloc;
nbytes_read = 0;
nbytes_alloc = 1024;
buffer = g_new (char, nbytes_alloc);
while (1)
{
nchars = fread(buffer, 1, 1024, infile);
gtk_text_insert (GTK_TEXT (text), NULL, NULL,
NULL, buffer, nchars);
if (nchars < 1024)
int len;
if (nbytes_alloc < nbytes_read + 1024)
{
nbytes_alloc *= 2;
buffer = g_realloc (buffer, nbytes_alloc);
}
len = fread (buffer + nbytes_read, 1, 1024, infile);
nbytes_read += len;
if (len < 1024)
break;
}
gtk_text_insert (GTK_TEXT (text), NULL, NULL,
NULL, buffer, nbytes_read);
g_free(buffer);
fclose (infile);
}

View File

@ -17,8 +17,8 @@ pixmap_path "."
style "defaultfont"
{
# fontset = "-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*,*"
font = "-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*,*"
fontset = "-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*,*"
# font = "-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*,*"
}
# common default

View File

@ -5750,19 +5750,29 @@ create_text (void)
if (infile)
{
char buffer[1024];
int nchars;
char *buffer;
int nbytes_read, nbytes_alloc;
nbytes_read = 0;
nbytes_alloc = 1024;
buffer = g_new (char, nbytes_alloc);
while (1)
{
nchars = fread(buffer, 1, 1024, infile);
gtk_text_insert (GTK_TEXT (text), NULL, NULL,
NULL, buffer, nchars);
if (nchars < 1024)
int len;
if (nbytes_alloc < nbytes_read + 1024)
{
nbytes_alloc *= 2;
buffer = g_realloc (buffer, nbytes_alloc);
}
len = fread (buffer + nbytes_read, 1, 1024, infile);
nbytes_read += len;
if (len < 1024)
break;
}
gtk_text_insert (GTK_TEXT (text), NULL, NULL,
NULL, buffer, nbytes_read);
g_free(buffer);
fclose (infile);
}

View File

@ -17,8 +17,8 @@ pixmap_path "."
style "defaultfont"
{
# fontset = "-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*,*"
font = "-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*,*"
fontset = "-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*,*"
# font = "-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*,*"
}
# common default