Compare commits

...

3 Commits

Author SHA1 Message Date
Matthias Clasen
b8d7777cc4 xim: Stop using gdk_surface_get_user_data
Use gtk_root_get_for_surface instead.
2019-02-23 22:01:58 -05:00
Matthias Clasen
c4edc28542 ime: Stop using gdk_surface_get_user_data
Use gtk_root_get_for_surface instead.
2019-02-23 22:01:50 -05:00
Matthias Clasen
b4e0bae7dc Add gtk_root_get_for_surface
This is a replacement for gdk_surface_get_user_data.
2019-02-23 21:56:47 -05:00
4 changed files with 29 additions and 23 deletions

View File

@@ -29,6 +29,7 @@
#include "gtkimcontextime.h"
#include "gtkimmoduleprivate.h"
#include "gtkroot.h"
#include "imm-extra.h"
@@ -878,9 +879,9 @@ gtk_im_context_ime_set_preedit_font (GtkIMContext *context)
if (!context_ime->client_surface)
return;
gdk_surface_get_user_data (context_ime->client_surface, (gpointer) &widget);
if (!GTK_IS_WIDGET (widget))
return;
widget = gtk_root_get_for_surface (context_ime->client_surface);
if (!widget)
return
hwnd = gdk_win32_surface_get_impl_hwnd (context_ime->client_surface);
himc = ImmGetContext (hwnd);

View File

@@ -22,6 +22,7 @@
#include "gtkimcontextxim.h"
#include "gtkimmoduleprivate.h"
#include "gtkroot.h"
#include "gtk/gtkintl.h"
@@ -1526,32 +1527,13 @@ on_client_widget_hierarchy_changed (GtkWidget *widget,
update_in_toplevel (context_xim);
}
/* Finds the GtkWidget that owns the window, or if none, the
* widget owning the nearest parent that has a widget.
*/
static GtkWidget *
widget_for_window (GdkSurface *window)
{
while (window)
{
gpointer user_data;
gdk_surface_get_user_data (window, &user_data);
if (user_data)
return user_data;
window = gdk_surface_get_parent (window);
}
return NULL;
}
/* Called when context_xim->client_surface changes; takes care of
* removing and/or setting up our watches for the toplevel
*/
static void
update_client_widget (GtkIMContextXIM *context_xim)
{
GtkWidget *new_client_widget = widget_for_window (context_xim->client_surface);
GtkWidget *new_client_widget = gtk_root_get_for_surface (context_xim->client_surface);
if (new_client_widget != context_xim->client_widget)
{

View File

@@ -102,3 +102,24 @@ gtk_root_get_surface_transform (GtkRoot *self,
iface = GTK_ROOT_GET_IFACE (self);
return iface->get_surface_transform (self, x, y);
}
/**
* gtk_root_get_for_surface:
* @surface: a #GdkSurface
*
* Finds the GtkRoot associated with the surface.
*
* Returns: (transfer none): the #GtkRoot that is associated with @surface
*/
GtkWidget *
gtk_root_get_for_surface (GdkSurface *surface)
{
gpointer user_data;
gdk_surface_get_user_data (surface, &user_data);
if (user_data && GTK_IS_ROOT (user_data))
return GTK_WIDGET (user_data);
return NULL;
}

View File

@@ -53,6 +53,8 @@ struct _GtkRootInterface
int *y);
};
GDK_AVAILABLE_IN_ALL
GtkWidget * gtk_root_get_for_surface (GdkSurface *surface);
G_END_DECLS