[gtk+/wip/carlosg/event-delivery: 35/105] imcontext: Remove API dependency on GdkWindow
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/carlosg/event-delivery: 35/105] imcontext: Remove API dependency on GdkWindow
- Date: Sun, 14 May 2017 23:40:23 +0000 (UTC)
commit 89b64858f789bc6a9b3f2ebd872747e65f81a8f7
Author: Carlos Garnacho <carlosg gnome org>
Date: Sat Apr 1 23:25:13 2017 +0200
imcontext: Remove API dependency on GdkWindow
There is now a set_client_widget() to hint the IM about positioning
and whatnot.
gtk/gtkentry.c | 4 ++--
gtk/gtkimcontext.c | 18 +++++++++---------
gtk/gtkimcontext.h | 10 +++++-----
gtk/gtkimcontextsimple.c | 16 ++++++++--------
gtk/gtkimmulticontext.c | 24 ++++++++++++------------
gtk/gtktextview.c | 6 +++---
modules/input/gtkimcontextxim.c | 13 +++++++------
modules/input/imbroadway.c | 16 ++++++++--------
8 files changed, 54 insertions(+), 53 deletions(-)
---
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index dded3b8..fcfce25 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -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))
diff --git a/gtk/gtkimcontext.c b/gtk/gtkimcontext.c
index 5ca199f..1cffd09 100644
--- a/gtk/gtkimcontext.c
+++ b/gtk/gtkimcontext.c
@@ -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);
}
/**
diff --git a/gtk/gtkimcontext.h b/gtk/gtkimcontext.h
index d1acc63..3d77266 100644
--- a/gtk/gtkimcontext.h
+++ b/gtk/gtkimcontext.h
@@ -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,
diff --git a/gtk/gtkimcontextsimple.c b/gtk/gtkimcontextsimple.c
index a4b4a50..5404f0a 100644
--- a/gtk/gtkimcontextsimple.c
+++ b/gtk/gtkimcontextsimple.c
@@ -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
diff --git a/gtk/gtkimmulticontext.c b/gtk/gtkimmulticontext.c
index 32503a3..978f32f 100644
--- a/gtk/gtkimmulticontext.c
+++ b/gtk/gtkimmulticontext.c
@@ -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
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index 300e68d..a0f1ca1 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -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);
}
diff --git a/modules/input/gtkimcontextxim.c b/modules/input/gtkimcontextxim.c
index 886e2e6..58bd3a8 100644
--- a/modules/input/gtkimcontextxim.c
+++ b/modules/input/gtkimcontextxim.c
@@ -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 *
diff --git a/modules/input/imbroadway.c b/modules/input/imbroadway.c
index 140aa0e..6a15999 100644
--- a/modules/input/imbroadway.c
+++ b/modules/input/imbroadway.c
@@ -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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]