Transfer the Mac SDK bockbuild profiles & resources inside the Mono repository.
[mono.git] / bockbuild / mac-sdk / patches / gtk / gtk-imquartz-defer-signals-in-output_result.patch
1 diff --git a/modules/input/imquartz.c b/modules/input/imquartz.c
2 index 67c7d6c..a8ebd02 100644
3 --- a/modules/input/imquartz.c
4 +++ b/modules/input/imquartz.c
5 @@ -132,6 +132,8 @@ output_result (GtkIMContext *context,
6    GtkIMContextQuartz *qc = GTK_IM_CONTEXT_QUARTZ (context);
7    gboolean retval = FALSE;
8    gchar *fixed_str, *marked_str;
9 +  gboolean needs_commit = FALSE;
10 +  gboolean needs_preedit_change = FALSE;
11
12    fixed_str = g_object_get_data (G_OBJECT (win), TIC_INSERT_TEXT);
13    marked_str = g_object_get_data (G_OBJECT (win), TIC_MARKED_TEXT);
14 @@ -141,8 +143,8 @@ output_result (GtkIMContext *context,
15        g_free (qc->preedit_str);
16        qc->preedit_str = NULL;
17        g_object_set_data (G_OBJECT (win), TIC_INSERT_TEXT, NULL);
18 -      g_signal_emit_by_name (context, "commit", fixed_str);
19 -      g_signal_emit_by_name (context, "preedit_changed");
20 +      needs_commit = TRUE;
21 +      needs_preedit_change = TRUE;
22
23        unsigned int filtered =
24            GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (win),
25 @@ -162,10 +164,11 @@ output_result (GtkIMContext *context,
26        qc->selected_len =
27            GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (win),
28                                                 TIC_SELECTED_LEN));
29 -      g_free (qc->preedit_str);
30 +      if (qc->preedit_str)
31 +        g_free (qc->preedit_str);
32        qc->preedit_str = g_strdup (marked_str);
33        g_object_set_data (G_OBJECT (win), TIC_MARKED_TEXT, NULL);
34 -      g_signal_emit_by_name (context, "preedit_changed");
35 +      needs_preedit_change = TRUE;
36        retval = TRUE;
37      }
38    if (!fixed_str && !marked_str)
39 @@ -174,8 +177,15 @@ output_result (GtkIMContext *context,
40          retval = TRUE;
41      }
42
43 -  g_free (fixed_str);
44 -  g_free (marked_str);
45 +  if (needs_commit)
46 +    g_signal_emit_by_name (context, "commit", fixed_str);
47 +  if (needs_preedit_change)
48 +    g_signal_emit_by_name (context, "preedit-changed");
49 +
50 +  if (fixed_str)
51 +    g_free (fixed_str);
52 +  if (marked_str)
53 +    g_free (marked_str);
54
55    return retval;
56  }
57 @@ -261,8 +271,6 @@ discard_preedit (GtkIMContext *context)
58
59    if (qc->preedit_str && strlen (qc->preedit_str) > 0)
60      {
61 -      g_signal_emit_by_name (context, "commit", qc->preedit_str);
62 -
63        g_free (qc->preedit_str);
64        qc->preedit_str = NULL;
65        g_signal_emit_by_name (context, "preedit_changed");