Merge branch 'wip/chergert/fix-macos-crash' into 'main'

macos: fix crash in imcontextquartz

See merge request GNOME/gtk!4226
This commit is contained in:
Matthias Clasen 2021-12-09 23:49:39 +00:00
commit a35c35f849

View File

@ -305,7 +305,7 @@ 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);
GtkWidget* surface_widget = GTK_WIDGET (gdk_surface_get_widget (qc->client_surface)); GtkWidget* surface_widget;
int sx, sy; int sx, sy;
double wx, wy; double wx, wy;
@ -317,6 +317,11 @@ quartz_set_cursor_location (GtkIMContext *context, GdkRectangle *area)
if (!qc->focused) if (!qc->focused)
return; return;
surface_widget = GTK_WIDGET (gdk_surface_get_widget (qc->client_surface));
if (!surface_widget)
return;
gdk_surface_get_origin (qc->client_surface, &sx, &sy); gdk_surface_get_origin (qc->client_surface, &sx, &sy);
gtk_widget_translate_coordinates(qc->client_widget, surface_widget, gtk_widget_translate_coordinates(qc->client_widget, surface_widget,
area->x, area->y, &wx, &wy); area->x, area->y, &wx, &wy);