Commit 8439956a authored by Tor Lillqvist's avatar Tor Lillqvist Committed by Tor Lillqvist
Browse files

Set _gdk_input_ignore_wintab to FALSE, thus enabling tablet input by

2004-10-01  Tor Lillqvist  <tml@iki.fi>

	* gdk/win32/gdkglobals-win32.c: Set _gdk_input_ignore_wintab to
	FALSE, thus enabling tablet input by default.

	* gdk/win32/gdkmain-win32.c (_gdk_windowing_args): Accept the
	--use-wintab option again (but without effect, as this is now the
	default, see above). (#153788)

	* modules/input/gtkimcontextime.c: Numerous changes.

	Remove the ifdef UNICODE conditionals. Always use the
	wide-character Imm* API. It is present also in Windows 98 and
	Me. (Not Windows 95, but I think we don't care about that.) Using
	the multibyte API wouldn't work anyway on systems where the system
	codepage doesn't support the language the user uses an IME for, so
	for instance I wouldn't be able to test this module on my English
	Windows 2000 although I do have C, J and K IMEs available.

	Guard against IMM not being active, always check ImmGetContext()
	returning NULL. Work to some extent even without any IME. Fixes
	#153800 at least partially.

	* modules/input/imime.c (ime_info): Rename to "ime" to match the
	naming pattern of other input modules. Make it default for
	ja:ko:zh only.
parent 49174ac1
2004-10-01 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkglobals-win32.c: Set _gdk_input_ignore_wintab to
FALSE, thus enabling tablet input by default.
* gdk/win32/gdkmain-win32.c (_gdk_windowing_args): Accept the
--use-wintab option again (but without effect, as this is now the
default, see above). (#153788)
* modules/input/gtkimcontextime.c: Numerous changes.
Remove the ifdef UNICODE conditionals. Always use the
wide-character Imm* API. It is present also in Windows 98 and
Me. (Not Windows 95, but I think we don't care about that.) Using
the multibyte API wouldn't work anyway on systems where the system
codepage doesn't support the language the user uses an IME for, so
for instance I wouldn't be able to test this module on my English
Windows 2000 although I do have C, J and K IMEs available.
Guard against IMM not being active, always check ImmGetContext()
returning NULL. Work to some extent even without any IME. Fixes
#153800 at least partially.
* modules/input/imime.c (ime_info): Rename to "ime" to match the
naming pattern of other input modules. Make it default for
ja:ko:zh only.
2004-10-01 Matthias Clasen <mclasen@redhat.com> 2004-10-01 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkcombobox.c (gtk_combo_box_set_model): Add a comment regarding * gtk/gtkcombobox.c (gtk_combo_box_set_model): Add a comment regarding
......
2004-10-01 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkglobals-win32.c: Set _gdk_input_ignore_wintab to
FALSE, thus enabling tablet input by default.
* gdk/win32/gdkmain-win32.c (_gdk_windowing_args): Accept the
--use-wintab option again (but without effect, as this is now the
default, see above). (#153788)
* modules/input/gtkimcontextime.c: Numerous changes.
Remove the ifdef UNICODE conditionals. Always use the
wide-character Imm* API. It is present also in Windows 98 and
Me. (Not Windows 95, but I think we don't care about that.) Using
the multibyte API wouldn't work anyway on systems where the system
codepage doesn't support the language the user uses an IME for, so
for instance I wouldn't be able to test this module on my English
Windows 2000 although I do have C, J and K IMEs available.
Guard against IMM not being active, always check ImmGetContext()
returning NULL. Work to some extent even without any IME. Fixes
#153800 at least partially.
* modules/input/imime.c (ime_info): Rename to "ime" to match the
naming pattern of other input modules. Make it default for
ja:ko:zh only.
2004-10-01 Matthias Clasen <mclasen@redhat.com> 2004-10-01 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkcombobox.c (gtk_combo_box_set_model): Add a comment regarding * gtk/gtkcombobox.c (gtk_combo_box_set_model): Add a comment regarding
......
2004-10-01 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkglobals-win32.c: Set _gdk_input_ignore_wintab to
FALSE, thus enabling tablet input by default.
* gdk/win32/gdkmain-win32.c (_gdk_windowing_args): Accept the
--use-wintab option again (but without effect, as this is now the
default, see above). (#153788)
* modules/input/gtkimcontextime.c: Numerous changes.
Remove the ifdef UNICODE conditionals. Always use the
wide-character Imm* API. It is present also in Windows 98 and
Me. (Not Windows 95, but I think we don't care about that.) Using
the multibyte API wouldn't work anyway on systems where the system
codepage doesn't support the language the user uses an IME for, so
for instance I wouldn't be able to test this module on my English
Windows 2000 although I do have C, J and K IMEs available.
Guard against IMM not being active, always check ImmGetContext()
returning NULL. Work to some extent even without any IME. Fixes
#153800 at least partially.
* modules/input/imime.c (ime_info): Rename to "ime" to match the
naming pattern of other input modules. Make it default for
ja:ko:zh only.
2004-10-01 Matthias Clasen <mclasen@redhat.com> 2004-10-01 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkcombobox.c (gtk_combo_box_set_model): Add a comment regarding * gtk/gtkcombobox.c (gtk_combo_box_set_model): Add a comment regarding
......
2004-10-01 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkglobals-win32.c: Set _gdk_input_ignore_wintab to
FALSE, thus enabling tablet input by default.
* gdk/win32/gdkmain-win32.c (_gdk_windowing_args): Accept the
--use-wintab option again (but without effect, as this is now the
default, see above). (#153788)
* modules/input/gtkimcontextime.c: Numerous changes.
Remove the ifdef UNICODE conditionals. Always use the
wide-character Imm* API. It is present also in Windows 98 and
Me. (Not Windows 95, but I think we don't care about that.) Using
the multibyte API wouldn't work anyway on systems where the system
codepage doesn't support the language the user uses an IME for, so
for instance I wouldn't be able to test this module on my English
Windows 2000 although I do have C, J and K IMEs available.
Guard against IMM not being active, always check ImmGetContext()
returning NULL. Work to some extent even without any IME. Fixes
#153800 at least partially.
* modules/input/imime.c (ime_info): Rename to "ime" to match the
naming pattern of other input modules. Make it default for
ja:ko:zh only.
2004-10-01 Matthias Clasen <mclasen@redhat.com> 2004-10-01 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkcombobox.c (gtk_combo_box_set_model): Add a comment regarding * gtk/gtkcombobox.c (gtk_combo_box_set_model): Add a comment regarding
......
...@@ -64,7 +64,7 @@ GdkAtom _wm_transient_for; ...@@ -64,7 +64,7 @@ GdkAtom _wm_transient_for;
DWORD _windows_version; DWORD _windows_version;
gint _gdk_input_ignore_wintab = TRUE; gint _gdk_input_ignore_wintab = FALSE;
gint _gdk_max_colors = 0; gint _gdk_max_colors = 0;
gboolean _sizemove_in_progress = FALSE; gboolean _sizemove_in_progress = FALSE;
...@@ -53,16 +53,17 @@ ...@@ -53,16 +53,17 @@
static gboolean gdk_synchronize = FALSE; static gboolean gdk_synchronize = FALSE;
static gboolean dummy;
GOptionEntry _gdk_windowing_args[] = { GOptionEntry _gdk_windowing_args[] = {
{ "sync", 0, 0, G_OPTION_ARG_NONE, &gdk_synchronize, { "sync", 0, 0, G_OPTION_ARG_NONE, &gdk_synchronize,
/* Description of --sync in --help output */ N_("Don't batch GDI requests"), NULL }, /* Description of --sync in --help output */ N_("Don't batch GDI requests"), NULL },
{ "no-wintab", 0, 0, G_OPTION_ARG_NONE, &_gdk_input_ignore_wintab, { "no-wintab", 0, 0, G_OPTION_ARG_NONE, &_gdk_input_ignore_wintab,
/* Description of --no-wintab in --help output */ N_("Don't use the Wintab API for tablet support [default]"), NULL }, /* Description of --no-wintab in --help output */ N_("Don't use the Wintab API for tablet support"), NULL },
{ "ignore-wintab", 0, 0, G_OPTION_ARG_NONE, &_gdk_input_ignore_wintab, { "ignore-wintab", 0, 0, G_OPTION_ARG_NONE, &_gdk_input_ignore_wintab,
/* Description of --ignore-wintab in --help output */ N_("Same as --no-wintab"), NULL }, /* Description of --ignore-wintab in --help output */ N_("Same as --no-wintab"), NULL },
#if 0 { "use-wintab", 0, 0, G_OPTION_ARG_NONE, &dummy,
{ "use-wintab", 0, 0, G_OPTION_ARG_NONE, &_gdk_input_ignore_wintab, NULL, NULL }, /* Description of --use-wintab in --help output */ N_("Do use the Wintab API [default]"), NULL },
#endif
{ "max-colors", 0, 0, G_OPTION_ARG_INT, &_gdk_max_colors, { "max-colors", 0, 0, G_OPTION_ARG_INT, &_gdk_max_colors,
/* Description of --max-colors=COLORS in --help output */ N_("Size of the palette in 8 bit mode"), /* Description of --max-colors=COLORS in --help output */ N_("Size of the palette in 8 bit mode"),
/* Placeholder in --max-colors=COLORS in --help output */ N_("COLORS") }, /* Placeholder in --max-colors=COLORS in --help output */ N_("COLORS") },
......
/* /*
* gtkimmoduleime * gtkimcontextime.c
* Copyright (C) 2003 Takuro Ashie * Copyright (C) 2003 Takuro Ashie
* Copyright (C) 2003-2004 Kazuki IWAMOTO * Copyright (C) 2003-2004 Kazuki IWAMOTO
* *
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA. * Boston, MA 02111-1307, USA.
* *
* $Id$
*/ */
/* /*
...@@ -34,6 +33,8 @@ ...@@ -34,6 +33,8 @@
#include "gdk/gdkkeysyms.h" #include "gdk/gdkkeysyms.h"
#include "gtk/gtkwidget.h" #include "gtk/gtkwidget.h"
#include <pango/pango-utils.h>
/* avoid warning */ /* avoid warning */
#ifdef STRICT #ifdef STRICT
# undef STRICT # undef STRICT
...@@ -104,10 +105,10 @@ static void gtk_im_context_ime_set_use_preedit (GtkIMContext *context, ...@@ -104,10 +105,10 @@ static void gtk_im_context_ime_set_use_preedit (GtkIMContext *context,
gboolean use_preedit); gboolean use_preedit);
/* GtkIMContextIME's private functions */ /* GtkIMContextIME's private functions */
static void gtk_im_context_ime_set_preedit_font (GtkIMContext *context, static void gtk_im_context_ime_set_preedit_font (GtkIMContext *context);
PangoFont *font);
static GdkFilterReturn static GdkFilterReturn
gtk_im_context_ime_message_filter (GdkXEvent *xevent, gtk_im_context_ime_message_filter (GdkXEvent *xevent,
GdkEvent *event, GdkEvent *event,
gpointer data); gpointer data);
static void get_window_position (GdkWindow *win, static void get_window_position (GdkWindow *win,
...@@ -268,7 +269,6 @@ gtk_im_context_ime_set_client_window (GtkIMContext *context, ...@@ -268,7 +269,6 @@ gtk_im_context_ime_set_client_window (GtkIMContext *context,
GdkWindow *client_window) GdkWindow *client_window)
{ {
GtkIMContextIME *context_ime; GtkIMContextIME *context_ime;
HWND hwnd = NULL;
g_return_if_fail (GTK_IS_IM_CONTEXT_IME (context)); g_return_if_fail (GTK_IS_IM_CONTEXT_IME (context));
context_ime = GTK_IM_CONTEXT_IME (context); context_ime = GTK_IM_CONTEXT_IME (context);
...@@ -276,17 +276,18 @@ gtk_im_context_ime_set_client_window (GtkIMContext *context, ...@@ -276,17 +276,18 @@ gtk_im_context_ime_set_client_window (GtkIMContext *context,
if (client_window) if (client_window)
{ {
HIMC himc; HIMC himc;
HWND hwnd;
hwnd = GDK_WINDOW_HWND (client_window); hwnd = GDK_WINDOW_HWND (client_window);
/* get default ime context */
himc = ImmGetContext (hwnd); himc = ImmGetContext (hwnd);
context_ime->opened = ImmGetOpenStatus (himc); if (himc)
ImmGetConversionStatus (himc, {
&context_ime->priv->conversion_mode, context_ime->opened = ImmGetOpenStatus (himc);
&context_ime->priv->sentence_mode); ImmGetConversionStatus (himc,
ImmReleaseContext (hwnd, himc); &context_ime->priv->conversion_mode,
&context_ime->priv->sentence_mode);
ImmReleaseContext (hwnd, himc);
}
} }
else if (context_ime->focus) else if (context_ime->focus)
{ {
...@@ -302,36 +303,34 @@ gtk_im_context_ime_filter_keypress (GtkIMContext *context, ...@@ -302,36 +303,34 @@ gtk_im_context_ime_filter_keypress (GtkIMContext *context,
GdkEventKey *event) GdkEventKey *event)
{ {
GtkIMContextIME *context_ime; GtkIMContextIME *context_ime;
HWND hwnd;
HIMC himc;
gboolean retval = FALSE; gboolean retval = FALSE;
guint32 c;
g_return_val_if_fail (GTK_IS_IM_CONTEXT_IME (context), FALSE); g_return_val_if_fail (GTK_IS_IM_CONTEXT_IME (context), FALSE);
g_return_val_if_fail (event, FALSE); g_return_val_if_fail (event, FALSE);
if (event->type == GDK_KEY_RELEASE) if (event->type == GDK_KEY_RELEASE)
return retval; return FALSE;
context_ime = GTK_IM_CONTEXT_IME (context); context_ime = GTK_IM_CONTEXT_IME (context);
if (!context_ime->focus) if (!context_ime->focus)
return FALSE; return FALSE;
if (!GDK_IS_WINDOW (context_ime->client_window)) if (!GDK_IS_WINDOW (context_ime->client_window))
return FALSE; return FALSE;
hwnd = GDK_WINDOW_HWND (context_ime->client_window); c = gdk_keyval_to_unicode (event->keyval);
himc = ImmGetContext (hwnd); if (c)
/* FIXME!! event->string is deprecated */
if (event->string && *event->string
&& !g_unichar_iscntrl (g_utf8_get_char_validated (event->string,
strlen (event->string))))
{ {
g_signal_emit_by_name (G_OBJECT (context_ime), "commit", event->string); guchar utf8[10];
int len = g_unichar_to_utf8 (c, utf8);
utf8[len] = 0;
g_signal_emit_by_name (G_OBJECT (context_ime), "commit", utf8);
retval = TRUE; retval = TRUE;
} }
ImmReleaseContext (hwnd, himc);
return retval; return retval;
} }
...@@ -369,100 +368,41 @@ get_utf8_preedit_string (GtkIMContextIME *context_ime, gint *pos_ret) ...@@ -369,100 +368,41 @@ get_utf8_preedit_string (GtkIMContextIME *context_ime, gint *pos_ret)
if (pos_ret) if (pos_ret)
*pos_ret = 0; *pos_ret = 0;
/*
g_return_val_if_fail (GTK_IS_IM_CONTEXT_IME (context_ime),
g_strdup (""));
*/
hwnd = GDK_WINDOW_HWND (context_ime->client_window); hwnd = GDK_WINDOW_HWND (context_ime->client_window);
himc = ImmGetContext (hwnd); himc = ImmGetContext (hwnd);
if (!himc)
/* shouldn't return NULL */ return g_strdup ("");
g_return_val_if_fail (himc, g_strdup (""));
if (context_ime->preediting) if (context_ime->preediting)
{ {
gpointer buf;
glong len; glong len;
GError *error = NULL;
#ifdef UNICODE
len = ImmGetCompositionString (himc, GCS_COMPSTR, NULL, 0);
buf = g_malloc (len);
if (len > 0 && buf)
{
ImmGetCompositionString (himc, GCS_COMPSTR, buf, len);
len /= sizeof (gunichar2);
utf8str = g_utf16_to_utf8 (buf, len, NULL, NULL, &error);
if (error)
{
g_warning ("%s", error->message);
g_error_free (error);
}
if (pos_ret)
{
pos = ImmGetCompositionString (himc, GCS_CURSORPOS, NULL, 0);
if (pos < 0 || len < pos)
{
g_warning ("ImmGetCompositionString: "
"Invalid cursor position!");
pos = 0;
}
}
g_free (buf);
}
#else /* not UNICODE */
len = ImmGetCompositionString (himc, GCS_COMPSTR, NULL, 0);
buf = g_malloc (len);
if (len > 0 && buf)
{
ImmGetCompositionString (himc, GCS_COMPSTR, buf, len);
utf8str = g_locale_to_utf8 (buf, len, NULL, NULL, &error);
if (error)
{
g_warning ("%s", error->message);
g_error_free (error);
}
if (pos_ret) len = ImmGetCompositionStringW (himc, GCS_COMPSTR, NULL, 0);
{ if (len > 0)
pos = ImmGetCompositionString (himc, GCS_CURSORPOS, NULL, 0); {
/* get cursor position by offset */ GError *error = NULL;
if (pos < len && utf8str) gpointer buf = g_alloca (len);
{
gchar *tmpstr; ImmGetCompositionStringW (himc, GCS_COMPSTR, buf, len);
len /= 2;
tmpstr = g_locale_to_utf8 (buf, pos, NULL, NULL, &error); utf8str = g_utf16_to_utf8 (buf, len, NULL, NULL, &error);
if (error) if (error)
{ {
g_warning ("%s", error->message); g_warning ("%s", error->message);
g_error_free (error); g_error_free (error);
} }
if (tmpstr)
{ if (pos_ret)
pos = g_utf8_strlen (tmpstr, -1); {
} pos = ImmGetCompositionStringW (himc, GCS_CURSORPOS, NULL, 0);
else if (pos < 0 || len < pos)
{ {
pos = 0; g_warning ("ImmGetCompositionString: "
} "Invalid cursor position!");
g_free (tmpstr); pos = 0;
} }
else if (pos == len && utf8str) }
{ }
pos = g_utf8_strlen (utf8str, -1);
}
else
{
g_warning ("ImmGetCompositionString: "
"Invalid cursor position!");
pos = 0;
}
}
g_free (buf);
}
#endif /* not UNICODE */
} }
if (!utf8str) if (!utf8str)
...@@ -487,12 +427,10 @@ get_pango_attr_list (GtkIMContextIME *context_ime, const gchar *utf8str) ...@@ -487,12 +427,10 @@ get_pango_attr_list (GtkIMContextIME *context_ime, const gchar *utf8str)
HWND hwnd; HWND hwnd;
HIMC himc; HIMC himc;
/* g_return_val_if_fail (GTK_IS_IM_CONTEXT_IME (context_ime), attr); */
hwnd = GDK_WINDOW_HWND (context_ime->client_window); hwnd = GDK_WINDOW_HWND (context_ime->client_window);
himc = ImmGetContext (hwnd); himc = ImmGetContext (hwnd);
if (!himc)
g_return_val_if_fail (himc, attrs); return attrs;
if (context_ime->preediting) if (context_ime->preediting)
{ {
...@@ -505,9 +443,9 @@ get_pango_attr_list (GtkIMContextIME *context_ime, const gchar *utf8str) ...@@ -505,9 +443,9 @@ get_pango_attr_list (GtkIMContextIME *context_ime, const gchar *utf8str)
/* /*
* get attributes list of IME. * get attributes list of IME.
*/ */
len = ImmGetCompositionString (himc, GCS_COMPATTR, NULL, 0); len = ImmGetCompositionStringA (himc, GCS_COMPATTR, NULL, 0);
buf = g_malloc (len); buf = g_alloca (len);
ImmGetCompositionString (himc, GCS_COMPATTR, buf, len); ImmGetCompositionStringA (himc, GCS_COMPATTR, buf, len);
/* /*
* schr and echr are pointer in utf8str. * schr and echr are pointer in utf8str.
...@@ -518,30 +456,10 @@ get_pango_attr_list (GtkIMContextIME *context_ime, const gchar *utf8str) ...@@ -518,30 +456,10 @@ get_pango_attr_list (GtkIMContextIME *context_ime, const gchar *utf8str)
/* /*
* spos and epos are buf(attributes list of IME) position by * spos and epos are buf(attributes list of IME) position by
* bytes. * bytes.
* If UNICODE is defined, this value is same with UTF-8 offset. * Using the wide-char API, this value is same with UTF-8 offset.
* If it's not defined, this value is same with bytes position
* of locale encoded preedit string.
*
*/ */
#ifdef UNICODE epos = g_utf8_pointer_to_offset (utf8str, echr);
epos = g_utf8_pointer_to_offset (utf8str, echr);
#else /* not UNICODE */
gchar *tmpstr;
GError *error = NULL;
epos = spos;
tmpstr = g_locale_from_utf8 (schr, echr - schr, NULL, NULL, &error);
if (error)
{
g_warning ("%s", error->message);
g_error_free (error);
}
if (tmpstr)
{
epos += strlen (tmpstr);
g_free (tmpstr);
}
#endif /* not UNICODE */
/* /*
* sidx and eidx are positions in utf8str by bytes. * sidx and eidx are positions in utf8str by bytes.
*/ */
...@@ -592,7 +510,6 @@ get_pango_attr_list (GtkIMContextIME *context_ime, const gchar *utf8str) ...@@ -592,7 +510,6 @@ get_pango_attr_list (GtkIMContextIME *context_ime, const gchar *utf8str)
sidx = eidx; sidx = eidx;
} }
} }
g_free (buf);
} }
ImmReleaseContext (hwnd, himc); ImmReleaseContext (hwnd, himc);
...@@ -645,6 +562,9 @@ gtk_im_context_ime_focus_in (GtkIMContext *context) ...@@ -645,6 +562,9 @@ gtk_im_context_ime_focus_in (GtkIMContext *context)
if (!GDK_IS_WINDOW (context_ime->client_window)) if (!GDK_IS_WINDOW (context_ime->client_window))
return; return;
/* swtich current context */
context_ime->focus = TRUE;
hwnd = GDK_WINDOW_HWND (context_ime->client_window); hwnd = GDK_WINDOW_HWND (context_ime->client_window);
himc = ImmGetContext (hwnd); himc = ImmGetContext (hwnd);
if (!himc) if (!himc)
...@@ -679,9 +599,6 @@ gtk_im_context_ime_focus_in (GtkIMContext *context) ...@@ -679,9 +599,6 @@ gtk_im_context_ime_focus_in (GtkIMContext *context)
/* warning? */ /* warning? */
} }
/* swtich current context */
context_ime->focus = TRUE;
/* restore preedit context */ /* restore preedit context */
ImmSetConversionStatus (himc, ImmSetConversionStatus (himc,
context_ime->priv->conversion_mode, context_ime->priv->conversion_mode,
...@@ -693,10 +610,10 @@ gtk_im_context_ime_focus_in (GtkIMContext *context) ...@@ -693,10 +610,10 @@ gtk_im_context_ime_focus_in (GtkIMContext *context)
ImmSetOpenStatus (himc, TRUE); ImmSetOpenStatus (himc, TRUE);
if (context_ime->preediting) if (context_ime->preediting)
{ {
ImmSetCompositionString (himc, ImmSetCompositionStringW (himc,
SCS_SETSTR, SCS_SETSTR,
context_ime->priv->comp_str, context_ime->priv->comp_str,
context_ime->priv->comp_str_len, NULL, 0); context_ime->priv->comp_str_len, NULL, 0);
FREE_PREEDIT_BUFFER (context_ime); FREE_PREEDIT_BUFFER (context_ime);
} }