Commit d39afa60 authored by Carlos Garnacho's avatar Carlos Garnacho
Browse files

imcontext: Remove API dependency on GdkWindow

There is now a set_client_widget() to hint the IM about positioning
and whatnot.
parent 5836beee
......@@ -3109,7 +3109,7 @@ gtk_entry_realize (GtkWidget *widget)
gtk_widget_register_window (widget, priv->text_area);
gtk_im_context_set_client_window (priv->im_context, priv->text_area);
gtk_im_context_set_client_widget (priv->im_context, widget);
gtk_entry_adjust_scroll (entry);
gtk_entry_update_primary_selection (entry);
......@@ -3139,7 +3139,7 @@ gtk_entry_unrealize (GtkWidget *widget)
gtk_entry_reset_layout (entry);
gtk_im_context_set_client_window (priv->im_context, NULL);
gtk_im_context_set_client_widget (priv->im_context, NULL);
clipboard = gtk_widget_get_clipboard (widget, GDK_SELECTION_PRIMARY);
if (gtk_clipboard_get_owner (clipboard) == G_OBJECT (entry))
......
......@@ -159,7 +159,7 @@ G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GtkIMContext, gtk_im_context, G_TYPE_OBJECT
* #GtkIMContext::retrieve-surrounding signal.
* @delete_surrounding: Default handler of the
* #GtkIMContext::delete-surrounding signal.
* @set_client_window: Called via gtk_im_context_set_client_window() when the
* @set_client_widget: Called via gtk_im_context_set_client_widget() when the
* input window where the entered text will appear changes. Override this to
* keep track of the current input window, for instance for the purpose of
* positioning a status display of your input method.
......@@ -437,27 +437,27 @@ gtk_im_context_real_get_surrounding (GtkIMContext *context,
}
/**
* gtk_im_context_set_client_window:
* gtk_im_context_set_client_widget:
* @context: a #GtkIMContext
* @window: (allow-none): the client window. This may be %NULL to indicate
* that the previous client window no longer exists.
* @widget: (allow-none): the client widget. This may be %NULL to indicate
* that the previous client widget no longer exists.
*
* Set the client window for the input context; this is the
* #GdkWindow in which the input appears. This window is
* #GtkWidget holding the input focus. This widget is
* used in order to correctly position status windows, and may
* also be used for purposes internal to the input method.
**/
void
gtk_im_context_set_client_window (GtkIMContext *context,
GdkWindow *window)
gtk_im_context_set_client_widget (GtkIMContext *context,
GtkWidget *widget)
{
GtkIMContextClass *klass;
g_return_if_fail (GTK_IS_IM_CONTEXT (context));
klass = GTK_IM_CONTEXT_GET_CLASS (context);
if (klass->set_client_window)
klass->set_client_window (context, window);
if (klass->set_client_widget)
klass->set_client_widget (context, widget);
}
/**
......
......@@ -23,7 +23,7 @@
#error "Only <gtk/gtk.h> can be included directly."
#endif
#include <gdk/gdk.h>
#include <gtk/gtkwidget.h>
G_BEGIN_DECLS
......@@ -61,8 +61,8 @@ struct _GtkIMContextClass
gint n_chars);
/* Virtual functions */
void (*set_client_window) (GtkIMContext *context,
GdkWindow *window);
void (*set_client_widget) (GtkIMContext *context,
GtkWidget *widget);
void (*get_preedit_string) (GtkIMContext *context,
gchar **str,
PangoAttrList **attrs,
......@@ -97,8 +97,8 @@ GDK_AVAILABLE_IN_ALL
GType gtk_im_context_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
void gtk_im_context_set_client_window (GtkIMContext *context,
GdkWindow *window);
void gtk_im_context_set_client_widget (GtkIMContext *context,
GtkWidget *widget);
GDK_AVAILABLE_IN_ALL
void gtk_im_context_get_preedit_string (GtkIMContext *context,
gchar **str,
......
......@@ -117,8 +117,8 @@ static void gtk_im_context_simple_get_preedit_string (GtkIMContext
gchar **str,
PangoAttrList **attrs,
gint *cursor_pos);
static void gtk_im_context_simple_set_client_window (GtkIMContext *context,
GdkWindow *window);
static void gtk_im_context_simple_set_client_widget (GtkIMContext *context,
GtkWidget *widget);
G_DEFINE_TYPE_WITH_PRIVATE (GtkIMContextSimple, gtk_im_context_simple, GTK_TYPE_IM_CONTEXT)
......@@ -131,7 +131,7 @@ gtk_im_context_simple_class_init (GtkIMContextSimpleClass *class)
im_context_class->filter_keypress = gtk_im_context_simple_filter_keypress;
im_context_class->reset = gtk_im_context_simple_reset;
im_context_class->get_preedit_string = gtk_im_context_simple_get_preedit_string;
im_context_class->set_client_window = gtk_im_context_simple_set_client_window;
im_context_class->set_client_widget = gtk_im_context_simple_set_client_widget;
gobject_class->finalize = gtk_im_context_simple_finalize;
}
......@@ -1390,22 +1390,22 @@ gtk_im_context_simple_get_preedit_string (GtkIMContext *context,
}
static void
gtk_im_context_simple_set_client_window (GtkIMContext *context,
GdkWindow *window)
gtk_im_context_simple_set_client_widget (GtkIMContext *context,
GtkWidget *widget)
{
GtkIMContextSimple *im_context_simple = GTK_IM_CONTEXT_SIMPLE (context);
gboolean run_compose_table = FALSE;
if (!window)
if (!widget)
return;
/* Load compose table for X11 or Wayland. */
#ifdef GDK_WINDOWING_X11
if (GDK_IS_X11_DISPLAY (gdk_window_get_display (window)))
if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (widget)))
run_compose_table = TRUE;
#endif
#ifdef GDK_WINDOWING_WAYLAND
if (GDK_IS_WAYLAND_DISPLAY (gdk_window_get_display (window)))
if (GDK_IS_WAYLAND_DISPLAY (gtk_widget_get_display (widget)))
run_compose_table = TRUE;
#endif
......
......@@ -42,7 +42,7 @@ struct _GtkIMMulticontextPrivate
{
GtkIMContext *slave;
GdkWindow *client_window;
GtkWidget *client_widget;
GdkRectangle cursor_location;
gchar *context_id;
......@@ -61,8 +61,8 @@ static void gtk_im_multicontext_set_slave (GtkIMMulticontext
GtkIMContext *slave,
gboolean finalizing);
static void gtk_im_multicontext_set_client_window (GtkIMContext *context,
GdkWindow *window);
static void gtk_im_multicontext_set_client_widget (GtkIMContext *context,
GtkWidget *widget);
static void gtk_im_multicontext_get_preedit_string (GtkIMContext *context,
gchar **str,
PangoAttrList **attrs,
......@@ -114,7 +114,7 @@ gtk_im_multicontext_class_init (GtkIMMulticontextClass *class)
gobject_class->notify = gtk_im_multicontext_notify;
im_context_class->set_client_window = gtk_im_multicontext_set_client_window;
im_context_class->set_client_widget = gtk_im_multicontext_set_client_widget;
im_context_class->get_preedit_string = gtk_im_multicontext_get_preedit_string;
im_context_class->filter_keypress = gtk_im_multicontext_filter_keypress;
im_context_class->focus_in = gtk_im_multicontext_focus_in;
......@@ -230,8 +230,8 @@ gtk_im_multicontext_set_slave (GtkIMMulticontext *multicontext,
if (!priv->use_preedit) /* Default is TRUE */
gtk_im_context_set_use_preedit (slave, FALSE);
if (priv->client_window)
gtk_im_context_set_client_window (slave, priv->client_window);
if (priv->client_widget)
gtk_im_context_set_client_widget (slave, priv->client_widget);
if (priv->have_cursor_location)
gtk_im_context_set_cursor_location (slave, &priv->cursor_location);
if (priv->focus_in)
......@@ -292,8 +292,8 @@ im_module_setting_changed (GtkSettings *settings,
static void
gtk_im_multicontext_set_client_window (GtkIMContext *context,
GdkWindow *window)
gtk_im_multicontext_set_client_widget (GtkIMContext *context,
GtkWidget *widget)
{
GtkIMMulticontext *multicontext = GTK_IM_MULTICONTEXT (context);
GtkIMMulticontextPrivate *priv = multicontext->priv;
......@@ -302,11 +302,11 @@ gtk_im_multicontext_set_client_window (GtkIMContext *context,
GtkSettings *settings;
gboolean connected;
priv->client_window = window;
priv->client_widget = widget;
if (window)
if (widget)
{
screen = gdk_window_get_screen (window);
screen = gtk_widget_get_screen (widget);
settings = gtk_settings_get_for_screen (screen);
connected = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (settings),
......@@ -324,7 +324,7 @@ gtk_im_multicontext_set_client_window (GtkIMContext *context,
slave = gtk_im_multicontext_get_slave (multicontext);
if (slave)
gtk_im_context_set_client_window (slave, window);
gtk_im_context_set_client_widget (slave, widget);
}
static void
......
......@@ -9808,8 +9808,8 @@ text_window_realize (GtkTextWindow *win,
g_clear_object (&cursor);
}
gtk_im_context_set_client_window (GTK_TEXT_VIEW (widget)->priv->im_context,
win->window);
gtk_im_context_set_client_widget (GTK_TEXT_VIEW (widget)->priv->im_context,
widget);
break;
default:
break;
......@@ -9829,7 +9829,7 @@ text_window_unrealize (GtkTextWindow *win)
{
if (win->type == GTK_TEXT_WINDOW_TEXT)
{
gtk_im_context_set_client_window (GTK_TEXT_VIEW (win->widget)->priv->im_context,
gtk_im_context_set_client_widget (GTK_TEXT_VIEW (win->widget)->priv->im_context,
NULL);
}
......
......@@ -106,8 +106,8 @@ struct _StatusWindow
static void gtk_im_context_xim_class_init (GtkIMContextXIMClass *class);
static void gtk_im_context_xim_init (GtkIMContextXIM *im_context_xim);
static void gtk_im_context_xim_finalize (GObject *obj);
static void gtk_im_context_xim_set_client_window (GtkIMContext *context,
GdkWindow *client_window);
static void gtk_im_context_xim_set_client_widget (GtkIMContext *context,
GtkWidget *widget);
static gboolean gtk_im_context_xim_filter_keypress (GtkIMContext *context,
GdkEventKey *key);
static void gtk_im_context_xim_reset (GtkIMContext *context);
......@@ -478,7 +478,7 @@ gtk_im_context_xim_class_init (GtkIMContextXIMClass *class)
parent_class = g_type_class_peek_parent (class);
im_context_class->set_client_window = gtk_im_context_xim_set_client_window;
im_context_class->set_client_widget = gtk_im_context_xim_set_client_widget;
im_context_class->filter_keypress = gtk_im_context_xim_filter_keypress;
im_context_class->reset = gtk_im_context_xim_reset;
im_context_class->get_preedit_string = gtk_im_context_xim_get_preedit_string;
......@@ -596,12 +596,13 @@ set_ic_client_window (GtkIMContextXIM *context_xim,
}
static void
gtk_im_context_xim_set_client_window (GtkIMContext *context,
GdkWindow *client_window)
gtk_im_context_xim_set_client_widget (GtkIMContext *context,
GtkWidget *widget)
{
GtkIMContextXIM *context_xim = GTK_IM_CONTEXT_XIM (context);
GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
set_ic_client_window (context_xim, client_window);
set_ic_client_window (context_xim, gtk_widget_get_window (toplevel));
}
GtkIMContext *
......
......@@ -34,7 +34,7 @@
typedef struct _GtkIMContextBroadway
{
GtkIMContextSimple parent;
GdkWindow *client_window;
GtkWidget *client_widget;
} GtkIMContextBroadway;
typedef struct _GtkIMContextBroadwayClass
......@@ -66,11 +66,11 @@ static const GtkIMContextInfo *info_list[] =
#endif
static void
broadway_set_client_window (GtkIMContext *context, GdkWindow *window)
broadway_set_client_widget (GtkIMContext *context, GtkWidget *widget)
{
GtkIMContextBroadway *bw = GTK_IM_CONTEXT_BROADWAY (context);
bw->client_window = window;
bw->client_widget = widget;
}
static void
......@@ -79,9 +79,9 @@ broadway_focus_in (GtkIMContext *context)
GtkIMContextBroadway *bw = GTK_IM_CONTEXT_BROADWAY (context);
GdkDisplay *display;
if (bw->client_window)
if (bw->client_widget)
{
display = gdk_window_get_display (bw->client_window);
display = gtk_widget_get_display (bw->client_widget);
gdk_broadway_display_show_keyboard (GDK_BROADWAY_DISPLAY (display));
}
}
......@@ -92,9 +92,9 @@ broadway_focus_out (GtkIMContext *context)
GtkIMContextBroadway *bw = GTK_IM_CONTEXT_BROADWAY (context);
GdkDisplay *display;
if (bw->client_window)
if (bw->client_widget)
{
display = gdk_window_get_display (bw->client_window);
display = gtk_widget_get_display (bw->client_widget);
gdk_broadway_display_hide_keyboard (GDK_BROADWAY_DISPLAY (display));
}
}
......@@ -106,7 +106,7 @@ gtk_im_context_broadway_class_init (GtkIMContextClass *klass)
klass->focus_in = broadway_focus_in;
klass->focus_out = broadway_focus_out;
klass->set_client_window = broadway_set_client_window;
klass->set_client_widget = broadway_set_client_widget;
}
static void
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment