st-entry: Change the pointer cursor on enter/leave events
Change the pointer cursor to an i-beam when it is inside the ClutterText. https://bugzilla.gnome.org/show_bug.cgi?id=687130
This commit is contained in:
parent
4ebf396cf5
commit
2d763bd033
@ -65,6 +65,10 @@
|
|||||||
#include "st-clipboard.h"
|
#include "st-clipboard.h"
|
||||||
#include "st-private.h"
|
#include "st-private.h"
|
||||||
|
|
||||||
|
#include <clutter/x11/clutter-x11.h>
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
#include <X11/cursorfont.h>
|
||||||
|
|
||||||
#include "st-widget-accessible.h"
|
#include "st-widget-accessible.h"
|
||||||
|
|
||||||
#define HAS_FOCUS(actor) (clutter_actor_get_stage (actor) && clutter_stage_get_key_focus ((ClutterStage *) clutter_actor_get_stage (actor)) == actor)
|
#define HAS_FOCUS(actor) (clutter_actor_get_stage (actor) && clutter_stage_get_key_focus ((ClutterStage *) clutter_actor_get_stage (actor)) == actor)
|
||||||
@ -613,6 +617,38 @@ st_entry_key_focus_in (ClutterActor *actor)
|
|||||||
clutter_actor_grab_key_focus (priv->entry);
|
clutter_actor_grab_key_focus (priv->entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
st_entry_set_cursor (StEntry *entry,
|
||||||
|
gboolean use_ibeam)
|
||||||
|
{
|
||||||
|
Display *dpy;
|
||||||
|
ClutterActor *stage, *actor = CLUTTER_ACTOR (entry);
|
||||||
|
Window wid;
|
||||||
|
static Cursor ibeam = None;
|
||||||
|
|
||||||
|
dpy = clutter_x11_get_default_display ();
|
||||||
|
stage = clutter_actor_get_stage (actor);
|
||||||
|
wid = clutter_x11_get_stage_window (CLUTTER_STAGE (stage));
|
||||||
|
|
||||||
|
if (ibeam == None)
|
||||||
|
ibeam = XCreateFontCursor (dpy, XC_xterm);
|
||||||
|
|
||||||
|
if (use_ibeam)
|
||||||
|
XDefineCursor (dpy, wid, ibeam);
|
||||||
|
else
|
||||||
|
XUndefineCursor (dpy, wid);
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
st_entry_crossing_event (ClutterActor *actor,
|
||||||
|
ClutterCrossingEvent *event)
|
||||||
|
{
|
||||||
|
if (event->source == ST_ENTRY (actor)->priv->entry && event->related != NULL)
|
||||||
|
st_entry_set_cursor (ST_ENTRY (actor), (event->type == CLUTTER_ENTER));
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
st_entry_class_init (StEntryClass *klass)
|
st_entry_class_init (StEntryClass *klass)
|
||||||
{
|
{
|
||||||
@ -635,6 +671,9 @@ st_entry_class_init (StEntryClass *klass)
|
|||||||
actor_class->key_press_event = st_entry_key_press_event;
|
actor_class->key_press_event = st_entry_key_press_event;
|
||||||
actor_class->key_focus_in = st_entry_key_focus_in;
|
actor_class->key_focus_in = st_entry_key_focus_in;
|
||||||
|
|
||||||
|
actor_class->enter_event = st_entry_crossing_event;
|
||||||
|
actor_class->leave_event = st_entry_crossing_event;
|
||||||
|
|
||||||
widget_class->style_changed = st_entry_style_changed;
|
widget_class->style_changed = st_entry_style_changed;
|
||||||
widget_class->navigate_focus = st_entry_navigate_focus;
|
widget_class->navigate_focus = st_entry_navigate_focus;
|
||||||
widget_class->get_accessible_type = st_entry_accessible_get_type;
|
widget_class->get_accessible_type = st_entry_accessible_get_type;
|
||||||
|
Loading…
Reference in New Issue
Block a user