StEntry: add a hook to set the cursor from libgnome-shell
We need to call into MetaScreen to set the cursor, but we can't do that from libst, so add a hook that libgnome-shell can fill, and remove more ClutterX11 usage. https://bugzilla.gnome.org/show_bug.cgi?id=707467
This commit is contained in:
parent
ba9c1d98f6
commit
8ae0f1a9dc
@ -828,6 +828,16 @@ gnome_shell_gdk_event_handler (GdkEvent *event_gdk,
|
|||||||
gtk_main_do_event (event_gdk);
|
gtk_main_do_event (event_gdk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
entry_cursor_func (StEntry *entry,
|
||||||
|
gboolean use_ibeam,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
ShellGlobal *global = user_data;
|
||||||
|
|
||||||
|
meta_screen_set_cursor (global->meta_screen, use_ibeam ? META_CURSOR_IBEAM : META_CURSOR_DEFAULT);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_shell_global_set_plugin (ShellGlobal *global,
|
_shell_global_set_plugin (ShellGlobal *global,
|
||||||
MetaPlugin *plugin)
|
MetaPlugin *plugin)
|
||||||
@ -878,6 +888,7 @@ _shell_global_set_plugin (ShellGlobal *global,
|
|||||||
}
|
}
|
||||||
|
|
||||||
st_im_text_set_event_window (global->ibus_window);
|
st_im_text_set_event_window (global->ibus_window);
|
||||||
|
st_entry_set_cursor_func (entry_cursor_func, global);
|
||||||
|
|
||||||
g_signal_connect (global->stage, "notify::width",
|
g_signal_connect (global->stage, "notify::width",
|
||||||
G_CALLBACK (global_stage_notify_width), global);
|
G_CALLBACK (global_stage_notify_width), global);
|
||||||
|
@ -65,10 +65,6 @@
|
|||||||
#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)
|
||||||
@ -681,33 +677,28 @@ st_entry_key_focus_in (ClutterActor *actor)
|
|||||||
clutter_actor_grab_key_focus (priv->entry);
|
clutter_actor_grab_key_focus (priv->entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static StEntryCursorFunc cursor_func;
|
||||||
|
static gpointer cursor_func_data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* st_entry_set_cursor_func: (skip)
|
||||||
|
*
|
||||||
|
* This function is for private use by libgnome-shell.
|
||||||
|
* Do not ever use.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
st_entry_set_cursor_func (StEntryCursorFunc func,
|
||||||
|
gpointer data)
|
||||||
|
{
|
||||||
|
cursor_func = func;
|
||||||
|
cursor_func_data = data;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
st_entry_set_cursor (StEntry *entry,
|
st_entry_set_cursor (StEntry *entry,
|
||||||
gboolean use_ibeam)
|
gboolean use_ibeam)
|
||||||
{
|
{
|
||||||
Display *dpy;
|
cursor_func (entry, use_ibeam, cursor_func_data);
|
||||||
ClutterActor *stage, *actor = CLUTTER_ACTOR (entry);
|
|
||||||
Window wid;
|
|
||||||
static Cursor ibeam = None;
|
|
||||||
|
|
||||||
dpy = clutter_x11_get_default_display ();
|
|
||||||
stage = clutter_actor_get_stage (actor);
|
|
||||||
|
|
||||||
if (stage == NULL)
|
|
||||||
{
|
|
||||||
g_warn_if_fail (!entry->priv->has_ibeam);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
entry->priv->has_ibeam = use_ibeam;
|
entry->priv->has_ibeam = use_ibeam;
|
||||||
}
|
}
|
||||||
|
@ -86,6 +86,10 @@ void st_entry_set_primary_icon (StEntry *entry,
|
|||||||
void st_entry_set_secondary_icon (StEntry *entry,
|
void st_entry_set_secondary_icon (StEntry *entry,
|
||||||
ClutterActor *icon);
|
ClutterActor *icon);
|
||||||
|
|
||||||
|
typedef void (*StEntryCursorFunc) (StEntry *entry, gboolean use_ibeam, gpointer data);
|
||||||
|
void st_entry_set_cursor_func (StEntryCursorFunc func,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __ST_ENTRY_H__ */
|
#endif /* __ST_ENTRY_H__ */
|
||||||
|
Loading…
Reference in New Issue
Block a user