forked from AuroraMiddleware/gtk
macos: fix the position of curosr of input method for macos.
In the refactoring from GdkWindow to GdkSurface, GtkWidget no longer corresponds to a GdkSurface. We have to calculate the relative position from GtkWidget to the GdkSurface. Closes #4063.
This commit is contained in:
parent
9169315cc1
commit
1dbb5188ba
@ -41,6 +41,7 @@ typedef struct _GtkIMContextQuartz
|
|||||||
GtkIMContext parent;
|
GtkIMContext parent;
|
||||||
GtkIMContext *helper;
|
GtkIMContext *helper;
|
||||||
GdkSurface *client_surface;
|
GdkSurface *client_surface;
|
||||||
|
GtkWidget *client_widget;
|
||||||
char *preedit_str;
|
char *preedit_str;
|
||||||
unsigned int cursor_index;
|
unsigned int cursor_index;
|
||||||
unsigned int selected_len;
|
unsigned int selected_len;
|
||||||
@ -266,6 +267,7 @@ quartz_set_client_surface (GtkIMContext *context,
|
|||||||
|
|
||||||
GTK_NOTE (MODULES, g_print ("quartz_set_client_surface: %p\n", widget));
|
GTK_NOTE (MODULES, g_print ("quartz_set_client_surface: %p\n", widget));
|
||||||
|
|
||||||
|
qc->client_widget = widget;
|
||||||
qc->client_surface = NULL;
|
qc->client_surface = NULL;
|
||||||
|
|
||||||
if (widget != NULL)
|
if (widget != NULL)
|
||||||
@ -302,26 +304,25 @@ static void
|
|||||||
quartz_set_cursor_location (GtkIMContext *context, GdkRectangle *area)
|
quartz_set_cursor_location (GtkIMContext *context, GdkRectangle *area)
|
||||||
{
|
{
|
||||||
GtkIMContextQuartz *qc = GTK_IM_CONTEXT_QUARTZ (context);
|
GtkIMContextQuartz *qc = GTK_IM_CONTEXT_QUARTZ (context);
|
||||||
int x, y;
|
int sx, sy;
|
||||||
|
double wx, wy;
|
||||||
|
|
||||||
GTK_NOTE (MODULES, g_print ("quartz_set_cursor_location\n"));
|
GTK_NOTE (MODULES, g_print ("quartz_set_cursor_location\n"));
|
||||||
|
|
||||||
if (!qc->client_surface)
|
if (!qc->client_surface || !qc->client_widget)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!qc->focused)
|
if (!qc->focused)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
qc->cursor_rect->x = area->x;
|
gdk_surface_get_origin (qc->client_surface, &sx, &sy);
|
||||||
qc->cursor_rect->y = area->y;
|
gtk_widget_translate_coordinates(qc->client_widget, qc->client_surface->widget, area->x, area->y, &wx, &wy);
|
||||||
|
|
||||||
|
qc->cursor_rect->x = sx + (int) wx;
|
||||||
|
qc->cursor_rect->y = sy + (int) wy;
|
||||||
qc->cursor_rect->width = area->width;
|
qc->cursor_rect->width = area->width;
|
||||||
qc->cursor_rect->height = area->height;
|
qc->cursor_rect->height = area->height;
|
||||||
|
|
||||||
gdk_surface_get_origin (qc->client_surface, &x, &y);
|
|
||||||
|
|
||||||
qc->cursor_rect->x = area->x + x;
|
|
||||||
qc->cursor_rect->y = area->y + y;
|
|
||||||
|
|
||||||
if (!GDK_IS_MACOS_SURFACE (qc->client_surface))
|
if (!GDK_IS_MACOS_SURFACE (qc->client_surface))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user