Commit da562f4d authored by Owen Taylor's avatar Owen Taylor Committed by Owen Taylor

Add a direction-changed signal, and gdk_keymap_get_current_direction().

Fri Jun  8 12:03:07 2001  Owen Taylor  <otaylor@redhat.com>

	* gdk/gdkkeys.[ch]: Add a direction-changed signal,
	and gdk_keymap_get_current_direction().

	* gdk/x11/gdkevents-x11.c gdk/x11/gdkkeys-x11.c
	  gdk/x11/gdkmain-x11.c gdk/x11/gdkprivate-x11.h: Track
	the current locked group, use it to set the keymap
	direction.

	* gtk/gtksettings.c: Add a new gtk-split-cursor setting
	to determine whether we draw a split cursor or use
	a jumping cursor based on the current direction.

	* gtk/gtkentry.c gtk/gtktextview.c gtk/gtktextlayout.[ch]:
	Obey the split cursor setting.

Fri Jun  8 11:57:50 2001  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkimmulticontext.c (activate_cb): Only activate
	when toggling on, not when toggling off... (#55906)

Wed Jun  6 10:37:07 2001  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkwidget.c (gtk_widget_set_double_buffered):
	s/gdk_window_begin_paint/gdk_window_begin_paint_region/
	in docs. (#55812, Vitaly Tishkov)
parent 11699349
Fri Jun 8 12:03:07 2001 Owen Taylor <otaylor@redhat.com>
* gdk/gdkkeys.[ch]: Add a direction-changed signal,
and gdk_keymap_get_current_direction().
* gdk/x11/gdkevents-x11.c gdk/x11/gdkkeys-x11.c
gdk/x11/gdkmain-x11.c gdk/x11/gdkprivate-x11.h: Track
the current locked group, use it to set the keymap
direction.
* gtk/gtksettings.c: Add a new gtk-split-cursor setting
to determine whether we draw a split cursor or use
a jumping cursor based on the current direction.
* gtk/gtkentry.c gtk/gtktextview.c gtk/gtktextlayout.[ch]:
Obey the split cursor setting.
Fri Jun 8 11:57:50 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkimmulticontext.c (activate_cb): Only activate
when toggling on, not when toggling off... (#55906)
Wed Jun 6 10:37:07 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_set_double_buffered):
s/gdk_window_begin_paint/gdk_window_begin_paint_region/
in docs. (#55812, Vitaly Tishkov)
2001-06-08 Anders Carlsson <andersca@codefactory.se> 2001-06-08 Anders Carlsson <andersca@codefactory.se>
* demos/gtk-demo/main.c (create_tree): Changed signal name from * demos/gtk-demo/main.c (create_tree): Changed signal name from
......
Fri Jun 8 12:03:07 2001 Owen Taylor <otaylor@redhat.com>
* gdk/gdkkeys.[ch]: Add a direction-changed signal,
and gdk_keymap_get_current_direction().
* gdk/x11/gdkevents-x11.c gdk/x11/gdkkeys-x11.c
gdk/x11/gdkmain-x11.c gdk/x11/gdkprivate-x11.h: Track
the current locked group, use it to set the keymap
direction.
* gtk/gtksettings.c: Add a new gtk-split-cursor setting
to determine whether we draw a split cursor or use
a jumping cursor based on the current direction.
* gtk/gtkentry.c gtk/gtktextview.c gtk/gtktextlayout.[ch]:
Obey the split cursor setting.
Fri Jun 8 11:57:50 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkimmulticontext.c (activate_cb): Only activate
when toggling on, not when toggling off... (#55906)
Wed Jun 6 10:37:07 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_set_double_buffered):
s/gdk_window_begin_paint/gdk_window_begin_paint_region/
in docs. (#55812, Vitaly Tishkov)
2001-06-08 Anders Carlsson <andersca@codefactory.se> 2001-06-08 Anders Carlsson <andersca@codefactory.se>
* demos/gtk-demo/main.c (create_tree): Changed signal name from * demos/gtk-demo/main.c (create_tree): Changed signal name from
......
Fri Jun 8 12:03:07 2001 Owen Taylor <otaylor@redhat.com>
* gdk/gdkkeys.[ch]: Add a direction-changed signal,
and gdk_keymap_get_current_direction().
* gdk/x11/gdkevents-x11.c gdk/x11/gdkkeys-x11.c
gdk/x11/gdkmain-x11.c gdk/x11/gdkprivate-x11.h: Track
the current locked group, use it to set the keymap
direction.
* gtk/gtksettings.c: Add a new gtk-split-cursor setting
to determine whether we draw a split cursor or use
a jumping cursor based on the current direction.
* gtk/gtkentry.c gtk/gtktextview.c gtk/gtktextlayout.[ch]:
Obey the split cursor setting.
Fri Jun 8 11:57:50 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkimmulticontext.c (activate_cb): Only activate
when toggling on, not when toggling off... (#55906)
Wed Jun 6 10:37:07 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_set_double_buffered):
s/gdk_window_begin_paint/gdk_window_begin_paint_region/
in docs. (#55812, Vitaly Tishkov)
2001-06-08 Anders Carlsson <andersca@codefactory.se> 2001-06-08 Anders Carlsson <andersca@codefactory.se>
* demos/gtk-demo/main.c (create_tree): Changed signal name from * demos/gtk-demo/main.c (create_tree): Changed signal name from
......
Fri Jun 8 12:03:07 2001 Owen Taylor <otaylor@redhat.com>
* gdk/gdkkeys.[ch]: Add a direction-changed signal,
and gdk_keymap_get_current_direction().
* gdk/x11/gdkevents-x11.c gdk/x11/gdkkeys-x11.c
gdk/x11/gdkmain-x11.c gdk/x11/gdkprivate-x11.h: Track
the current locked group, use it to set the keymap
direction.
* gtk/gtksettings.c: Add a new gtk-split-cursor setting
to determine whether we draw a split cursor or use
a jumping cursor based on the current direction.
* gtk/gtkentry.c gtk/gtktextview.c gtk/gtktextlayout.[ch]:
Obey the split cursor setting.
Fri Jun 8 11:57:50 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkimmulticontext.c (activate_cb): Only activate
when toggling on, not when toggling off... (#55906)
Wed Jun 6 10:37:07 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_set_double_buffered):
s/gdk_window_begin_paint/gdk_window_begin_paint_region/
in docs. (#55812, Vitaly Tishkov)
2001-06-08 Anders Carlsson <andersca@codefactory.se> 2001-06-08 Anders Carlsson <andersca@codefactory.se>
* demos/gtk-demo/main.c (create_tree): Changed signal name from * demos/gtk-demo/main.c (create_tree): Changed signal name from
......
Fri Jun 8 12:03:07 2001 Owen Taylor <otaylor@redhat.com>
* gdk/gdkkeys.[ch]: Add a direction-changed signal,
and gdk_keymap_get_current_direction().
* gdk/x11/gdkevents-x11.c gdk/x11/gdkkeys-x11.c
gdk/x11/gdkmain-x11.c gdk/x11/gdkprivate-x11.h: Track
the current locked group, use it to set the keymap
direction.
* gtk/gtksettings.c: Add a new gtk-split-cursor setting
to determine whether we draw a split cursor or use
a jumping cursor based on the current direction.
* gtk/gtkentry.c gtk/gtktextview.c gtk/gtktextlayout.[ch]:
Obey the split cursor setting.
Fri Jun 8 11:57:50 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkimmulticontext.c (activate_cb): Only activate
when toggling on, not when toggling off... (#55906)
Wed Jun 6 10:37:07 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_set_double_buffered):
s/gdk_window_begin_paint/gdk_window_begin_paint_region/
in docs. (#55812, Vitaly Tishkov)
2001-06-08 Anders Carlsson <andersca@codefactory.se> 2001-06-08 Anders Carlsson <andersca@codefactory.se>
* demos/gtk-demo/main.c (create_tree): Changed signal name from * demos/gtk-demo/main.c (create_tree): Changed signal name from
......
Fri Jun 8 12:03:07 2001 Owen Taylor <otaylor@redhat.com>
* gdk/gdkkeys.[ch]: Add a direction-changed signal,
and gdk_keymap_get_current_direction().
* gdk/x11/gdkevents-x11.c gdk/x11/gdkkeys-x11.c
gdk/x11/gdkmain-x11.c gdk/x11/gdkprivate-x11.h: Track
the current locked group, use it to set the keymap
direction.
* gtk/gtksettings.c: Add a new gtk-split-cursor setting
to determine whether we draw a split cursor or use
a jumping cursor based on the current direction.
* gtk/gtkentry.c gtk/gtktextview.c gtk/gtktextlayout.[ch]:
Obey the split cursor setting.
Fri Jun 8 11:57:50 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkimmulticontext.c (activate_cb): Only activate
when toggling on, not when toggling off... (#55906)
Wed Jun 6 10:37:07 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_set_double_buffered):
s/gdk_window_begin_paint/gdk_window_begin_paint_region/
in docs. (#55812, Vitaly Tishkov)
2001-06-08 Anders Carlsson <andersca@codefactory.se> 2001-06-08 Anders Carlsson <andersca@codefactory.se>
* demos/gtk-demo/main.c (create_tree): Changed signal name from * demos/gtk-demo/main.c (create_tree): Changed signal name from
......
Fri Jun 8 12:03:07 2001 Owen Taylor <otaylor@redhat.com>
* gdk/gdkkeys.[ch]: Add a direction-changed signal,
and gdk_keymap_get_current_direction().
* gdk/x11/gdkevents-x11.c gdk/x11/gdkkeys-x11.c
gdk/x11/gdkmain-x11.c gdk/x11/gdkprivate-x11.h: Track
the current locked group, use it to set the keymap
direction.
* gtk/gtksettings.c: Add a new gtk-split-cursor setting
to determine whether we draw a split cursor or use
a jumping cursor based on the current direction.
* gtk/gtkentry.c gtk/gtktextview.c gtk/gtktextlayout.[ch]:
Obey the split cursor setting.
Fri Jun 8 11:57:50 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkimmulticontext.c (activate_cb): Only activate
when toggling on, not when toggling off... (#55906)
Wed Jun 6 10:37:07 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_set_double_buffered):
s/gdk_window_begin_paint/gdk_window_begin_paint_region/
in docs. (#55812, Vitaly Tishkov)
2001-06-08 Anders Carlsson <andersca@codefactory.se> 2001-06-08 Anders Carlsson <andersca@codefactory.se>
* demos/gtk-demo/main.c (create_tree): Changed signal name from * demos/gtk-demo/main.c (create_tree): Changed signal name from
......
...@@ -495,7 +495,6 @@ This can later be composited together with other ...@@ -495,7 +495,6 @@ This can later be composited together with other
#GtkRcStyle structures to form a #GtkStyle. #GtkRcStyle structures to form a #GtkStyle.
</para> </para>
@parent_instance:
@name: @name:
@bg_pixmap_name: @bg_pixmap_name:
@font_desc: @font_desc:
......
...@@ -27,12 +27,19 @@ ...@@ -27,12 +27,19 @@
#include "gdkkeys.h" #include "gdkkeys.h"
#include <config.h> #include <config.h>
enum {
DIRECTION_CHANGED,
LAST_SIGNAL
};
static void gdk_keymap_init (GdkKeymap *keymap); static void gdk_keymap_init (GdkKeymap *keymap);
static void gdk_keymap_class_init (GdkKeymapClass *klass); static void gdk_keymap_class_init (GdkKeymapClass *klass);
static void gdk_keymap_finalize (GObject *object); static void gdk_keymap_finalize (GObject *object);
static gpointer parent_class = NULL; static gpointer parent_class = NULL;
static guint signals[LAST_SIGNAL] = { 0 };
GType GType
gdk_keymap_get_type (void) gdk_keymap_get_type (void)
{ {
...@@ -75,6 +82,16 @@ gdk_keymap_class_init (GdkKeymapClass *klass) ...@@ -75,6 +82,16 @@ gdk_keymap_class_init (GdkKeymapClass *klass)
parent_class = g_type_class_peek_parent (klass); parent_class = g_type_class_peek_parent (klass);
object_class->finalize = gdk_keymap_finalize; object_class->finalize = gdk_keymap_finalize;
signals[DIRECTION_CHANGED] =
g_signal_newc ("direction_changed",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GdkKeymapClass, direction_changed),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE,
0);
} }
static void static void
...@@ -85,17 +102,6 @@ gdk_keymap_finalize (GObject *object) ...@@ -85,17 +102,6 @@ gdk_keymap_finalize (GObject *object)
G_OBJECT_CLASS (parent_class)->finalize (object); G_OBJECT_CLASS (parent_class)->finalize (object);
} }
GdkKeymap*
gdk_keymap_get_default (void)
{
static GdkKeymap *keymap = NULL;
if (keymap == NULL)
keymap = g_object_new (gdk_keymap_get_type (), NULL);
return keymap;
}
/* Other key-handling stuff /* Other key-handling stuff
......
...@@ -70,6 +70,8 @@ struct _GdkKeymap ...@@ -70,6 +70,8 @@ struct _GdkKeymap
struct _GdkKeymapClass struct _GdkKeymapClass
{ {
GObjectClass parent_class; GObjectClass parent_class;
void (*direction_changed) (void);
}; };
GType gdk_keymap_get_type (void) G_GNUC_CONST; GType gdk_keymap_get_type (void) G_GNUC_CONST;
...@@ -77,25 +79,26 @@ GType gdk_keymap_get_type (void) G_GNUC_CONST; ...@@ -77,25 +79,26 @@ GType gdk_keymap_get_type (void) G_GNUC_CONST;
GdkKeymap* gdk_keymap_get_default (void); GdkKeymap* gdk_keymap_get_default (void);
guint gdk_keymap_lookup_key (GdkKeymap *keymap, guint gdk_keymap_lookup_key (GdkKeymap *keymap,
const GdkKeymapKey *key); const GdkKeymapKey *key);
gboolean gdk_keymap_translate_keyboard_state (GdkKeymap *keymap, gboolean gdk_keymap_translate_keyboard_state (GdkKeymap *keymap,
guint hardware_keycode, guint hardware_keycode,
GdkModifierType state, GdkModifierType state,
gint group, gint group,
guint *keyval, guint *keyval,
gint *effective_group, gint *effective_group,
gint *level, gint *level,
GdkModifierType *unused_modifiers); GdkModifierType *unused_modifiers);
gboolean gdk_keymap_get_entries_for_keyval (GdkKeymap *keymap, gboolean gdk_keymap_get_entries_for_keyval (GdkKeymap *keymap,
guint keyval, guint keyval,
GdkKeymapKey **keys, GdkKeymapKey **keys,
gint *n_keys); gint *n_keys);
gboolean gdk_keymap_get_entries_for_keycode (GdkKeymap *keymap, gboolean gdk_keymap_get_entries_for_keycode (GdkKeymap *keymap,
guint hardware_keycode, guint hardware_keycode,
GdkKeymapKey **keys, GdkKeymapKey **keys,
guint **keyvals, guint **keyvals,
gint *n_entries); gint *n_entries);
PangoDirection gdk_keymap_get_direction (GdkKeymap *keymap);
/* Key values /* Key values
*/ */
......
...@@ -1428,24 +1428,38 @@ gdk_event_translate (GdkEvent *event, ...@@ -1428,24 +1428,38 @@ gdk_event_translate (GdkEvent *event,
return_val = FALSE; return_val = FALSE;
break; break;
#ifdef HAVE_XKB
case XkbMapNotify:
++_gdk_keymap_serial;
return_val = FALSE;
break;
#endif
default: default:
/* something else - (e.g., a Xinput event) */ #ifdef HAVE_XKB
if (xevent->type == _gdk_xkb_event_type)
if (window_private && {
!GDK_WINDOW_DESTROYED (window_private) && XkbEvent *xkb_event = (XkbEvent *)xevent;
(window_private->extension_events != 0))
return_val = _gdk_input_other_event(event, xevent, window); switch (xkb_event->any.xkb_type)
{
case XkbMapNotify:
++_gdk_keymap_serial;
return_val = FALSE;
break;
case XkbStateNotify:
_gdk_keymap_state_changed ();
break;
}
}
else else
return_val = FALSE; #endif
{
break; /* something else - (e.g., a Xinput event) */
if (window_private &&
!GDK_WINDOW_DESTROYED (window_private) &&
(window_private->extension_events != 0))
return_val = _gdk_input_other_event(event, xevent, window);
else
return_val = FALSE;
break;
}
} }
done: done:
......
...@@ -56,6 +56,7 @@ update_keyrange (void) ...@@ -56,6 +56,7 @@ update_keyrange (void)
#include <X11/XKBlib.h> #include <X11/XKBlib.h>
gboolean _gdk_use_xkb = FALSE; gboolean _gdk_use_xkb = FALSE;
gint _gdk_xkb_event_type;
static XkbDescPtr xkb_desc = NULL; static XkbDescPtr xkb_desc = NULL;
static XkbDescPtr static XkbDescPtr
...@@ -70,10 +71,13 @@ get_xkb (void) ...@@ -70,10 +71,13 @@ get_xkb (void)
xkb_desc = XkbGetMap (gdk_display, XkbKeySymsMask, XkbUseCoreKbd); xkb_desc = XkbGetMap (gdk_display, XkbKeySymsMask, XkbUseCoreKbd);
if (xkb_desc == NULL) if (xkb_desc == NULL)
g_error ("Failed to get keymap"); g_error ("Failed to get keymap");
XkbGetNames (gdk_display, XkbGroupNamesMask, xkb_desc);
} }
else if (current_serial != _gdk_keymap_serial) else if (current_serial != _gdk_keymap_serial)
{ {
XkbGetUpdatedMap (gdk_display, XkbKeySymsMask, xkb_desc); XkbGetUpdatedMap (gdk_display, XkbKeySymsMask, xkb_desc);
XkbGetNames (gdk_display, XkbGroupNamesMask, xkb_desc);
} }
current_serial = _gdk_keymap_serial; current_serial = _gdk_keymap_serial;
...@@ -92,6 +96,18 @@ static KeySym* keymap = NULL; ...@@ -92,6 +96,18 @@ static KeySym* keymap = NULL;
static gint keysyms_per_keycode = 0; static gint keysyms_per_keycode = 0;
static XModifierKeymap* mod_keymap = NULL; static XModifierKeymap* mod_keymap = NULL;
static GdkModifierType group_switch_mask = 0; static GdkModifierType group_switch_mask = 0;
static PangoDirection current_direction;
static gboolean have_direction = FALSE;
static GdkKeymap *default_keymap = NULL;
GdkKeymap*
gdk_keymap_get_default (void)
{
if (default_keymap == NULL)
default_keymap = g_object_new (gdk_keymap_get_type (), NULL);
return default_keymap;
}
static void static void
update_keymaps (void) update_keymaps (void)
...@@ -175,6 +191,60 @@ get_keymap (void) ...@@ -175,6 +191,60 @@ get_keymap (void)
return keymap; return keymap;
} }
#if HAVE_XKB
PangoDirection
get_direction (void)
{
XkbDescRec *xkb = get_xkb ();
char *name;
XkbStateRec state_rec;
PangoDirection result;
XkbGetState (gdk_display, XkbUseCoreKbd, &state_rec);
name = gdk_atom_name (xkb->names->groups[state_rec.locked_group]);
if (g_strcasecmp (name, "arabic") == 0 ||
g_strcasecmp (name, "hebrew") == 0 ||
g_strcasecmp (name, "israelian") == 0)
result = PANGO_DIRECTION_RTL;
else
result = PANGO_DIRECTION_LTR;
g_free (name);
return result;
}
void
_gdk_keymap_state_changed (void)
{
if (default_keymap)
{
PangoDirection new_direction = get_direction ();
if (!have_direction || new_direction != current_direction)
{
have_direction = TRUE;
current_direction = new_direction;
g_signal_emit_by_name (G_OBJECT (default_keymap), "direction_changed");
}
}
}
#endif /* HAVE_XKB */
PangoDirection
gdk_keymap_get_direction (GdkKeymap *keymap)
{
if (!have_direction)
{
current_direction = get_direction ();
have_direction = TRUE;
}
return current_direction;
}
/** /**
* gdk_keymap_get_entries_for_keyval: * gdk_keymap_get_entries_for_keyval:
* @keymap: a #GdkKeymap, or %NULL to use the default keymap * @keymap: a #GdkKeymap, or %NULL to use the default keymap
......
...@@ -170,21 +170,23 @@ _gdk_windowing_init_check (int argc, char **argv) ...@@ -170,21 +170,23 @@ _gdk_windowing_init_check (int argc, char **argv)
{ {
gint xkb_major = XkbMajorVersion; gint xkb_major = XkbMajorVersion;
gint xkb_minor = XkbMinorVersion; gint xkb_minor = XkbMinorVersion;
gint xkb_event_type;
if (XkbLibraryVersion (&xkb_major, &xkb_minor)) if (XkbLibraryVersion (&xkb_major, &xkb_minor))
{ {
xkb_major = XkbMajorVersion; xkb_major = XkbMajorVersion;
xkb_minor = XkbMinorVersion; xkb_minor = XkbMinorVersion;
if (XkbQueryExtension (gdk_display, NULL, NULL, NULL,
if (XkbQueryExtension (gdk_display, NULL, &_gdk_xkb_event_type, NULL,
&xkb_major, &xkb_minor)) &xkb_major, &xkb_minor))
{ {
Bool detectable_autorepeat_supported; Bool detectable_autorepeat_supported;
_gdk_use_xkb = TRUE; _gdk_use_xkb = TRUE;
XkbSelectEvents (gdk_display, XkbSelectEvents (gdk_display,
XkbUseCoreKbd, XkbUseCoreKbd,
XkbMapNotifyMask, XkbMapNotifyMask | XkbStateNotifyMask,
XkbMapNotifyMask); XkbMapNotifyMask | XkbStateNotifyMask);
XkbSetDetectableAutoRepeat (gdk_display, XkbSetDetectableAutoRepeat (gdk_display,
True, True,
......
...@@ -95,6 +95,8 @@ void _gdk_region_get_xrectangles (GdkRegion *region, ...@@ -95,6 +95,8 @@ void _gdk_region_get_xrectangles (GdkRegion *region,
void _gdk_moveresize_handle_event (XEvent *event); void _gdk_moveresize_handle_event (XEvent *event);
void _gdk_moveresize_configure_done (void); void _gdk_moveresize_configure_done (void);
void _gdk_keymap_state_changed (void);
extern GdkDrawableClass _gdk_x11_drawable_class; extern GdkDrawableClass _gdk_x11_drawable_class;
extern gboolean gdk_use_xshm; extern gboolean gdk_use_xshm;
extern Atom gdk_wm_delete_window; extern Atom gdk_wm_delete_window;
...@@ -115,6 +117,7 @@ extern guint _gdk_keymap_serial; ...@@ -115,6 +117,7 @@ extern guint _gdk_keymap_serial;
#ifdef HAVE_XKB #ifdef HAVE_XKB
extern gboolean _gdk_use_xkb; extern gboolean _gdk_use_xkb;
extern gboolean _gdk_have_xkb_autorepeat; extern gboolean _gdk_have_xkb_autorepeat;
extern gint _gdk_xkb_event_type;
#endif #endif
/* Whether we were able to turn on detectable-autorepeat using /* Whether we were able to turn on detectable-autorepeat using
......
...@@ -211,6 +211,8 @@ static void gtk_entry_toggle_overwrite (GtkEntry *entry); ...@@ -211,6 +211,8 @@ static void gtk_entry_toggle_overwrite (GtkEntry *entry);
static void gtk_entry_real_activate (GtkEntry *entry); static void gtk_entry_real_activate (GtkEntry *entry);
static void gtk_entry_popup_menu (GtkWidget *widget); static void gtk_entry_popup_menu (GtkWidget *widget);
static void gtk_entry_keymap_direction_changed (GdkKeymap *keymap,
GtkEntry *entry);
/* IM Context Callbacks /* IM Context Callbacks
*/ */
static void gtk_entry_commit_cb (GtkIMContext *context, static void gtk_entry_commit_cb (GtkIMContext *context,
...@@ -1511,6 +1513,11 @@ gtk_entry_focus_in (GtkWidget *widget, ...@@ -1511,6 +1513,11 @@ gtk_entry_focus_in (GtkWidget *widget,
entry->need_im_reset = TRUE; entry->need_im_reset = TRUE;
gtk_im_context_focus_in (entry->im_context); gtk_im_context_focus_in (entry->im_context);
g_signal_connect_data (gdk_keymap_get_default (),
"direction_changed",
G_CALLBACK (gtk_entry_keymap_direction_changed), entry, NULL,
FALSE, FALSE);
gtk_entry_check_cursor_blink (entry); gtk_entry_check_cursor_blink (entry);
return FALSE; return FALSE;
...@@ -1530,6 +1537,10 @@ gtk_entry_focus_out (GtkWidget *widget, ...@@ -1530,6 +1537,10 @@ gtk_entry_focus_out (GtkWidget *widget,
gtk_entry_check_cursor_blink (entry); gtk_entry_check_cursor_blink (entry);
g_signal_disconnect_by_func (gdk_keymap_get_default (),
gtk_entry_keymap_direction_changed,
entry);
return FALSE; return FALSE;
} }
...@@ -2006,6 +2017,13 @@ gtk_entry_real_activate (GtkEntry *entry) ...@@ -2006,6 +2017,13 @@ gtk_entry_real_activate (GtkEntry *entry)
} }
} }
static void
gtk_entry_keymap_direction_changed (GdkKeymap *keymap,
GtkEntry *entry)
{
gtk_entry_queue_draw (entry);
}
/* IM Context Callbacks /* IM Context Callbacks
*/ */
...@@ -2408,29 +2426,64 @@ static void ...@@ -2408,29 +2426,64 @@ static void
gtk_entry_draw_cursor (GtkEntry *entry, gtk_entry_draw_cursor (GtkEntry *entry,
CursorType type) CursorType type)
{ {
GtkTextDirection keymap_direction =
(gdk_keymap_get_direction (gdk_keymap_get_default ()) == PANGO_DIRECTION_LTR) ?
GTK_TEXT_DIR_LTR : GTK_TEXT_DIR_RTL;
GtkTextDirection widget_direction = gtk_widget_get_direction (GTK_WIDGET (entry));
g_return_if_fail (entry != NULL); g_return_if_fail (entry != NULL);
g_return_if_fail (GTK_IS_ENTRY (entry)); g_return_if_fail (GTK_IS_ENTRY (entry));
if (GTK_WIDGET_DRAWABLE (entry)) if (GTK_WIDGET_DRAWABLE (entry))
{ {
GtkWidget *widget = GTK_WIDGET (entry); GtkWidget *widget = GTK_WIDGET (entry);
gboolean split_cursor;
gint xoffset = INNER_BORDER - entry->scroll_offset; gint xoffset = INNER_BORDER - entry->scroll_offset;
gint strong_x, weak_x; gint strong_x, weak_x;
gint text_area_height; gint text_area_height;
GdkGC *gc1 = NULL;
GdkGC *gc2 = NULL;
gint x1 = 0;
gint x2 = 0;
gdk_window_get_size (entry->text_area, NULL, &text_area_height); gdk_window_get_size (entry->text_area, NULL, &text_area_height);
gtk_entry_get_cursor_locations (entry, type, &strong_x, &weak_x); gtk_entry_get_cursor_locations (entry, type, &strong_x, &weak_x);
g_object_get (gtk_settings_get_global (),
"gtk-split-cursor", &split_cursor,
NULL);
if (split_cursor)
{
gc1 = entry->cursor_gc;
x1 = strong_x;
if (weak_x != strong_x)
{
gc2 = widget->style->text_gc[GTK_STATE_NORMAL];
x2 = weak_x;
}
}
else
{
gc1 = entry->cursor_gc;
if (keymap_direction == widget_direction)