2013-05-20 17:48:32 +00:00
|
|
|
/*
|
|
|
|
* gtkimmodulequartz
|
|
|
|
* Copyright (C) 2011 Hiroyuki Yamamoto
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2014-01-12 12:56:49 +00:00
|
|
|
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
2013-05-20 17:48:32 +00:00
|
|
|
*
|
|
|
|
* $Id:$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include <string.h>
|
|
|
|
|
2018-02-23 19:59:49 +00:00
|
|
|
#include "gtk/gtkimcontextquartz.h"
|
2013-05-20 17:48:32 +00:00
|
|
|
#include "gtk/gtkintl.h"
|
2018-03-09 07:13:13 +00:00
|
|
|
#include "gtk/gtkimmoduleprivate.h"
|
2013-05-20 17:48:32 +00:00
|
|
|
|
2020-10-10 03:08:23 +00:00
|
|
|
#include "gdk/macos/gdkmacos.h"
|
|
|
|
#include "gdk/macos/gdkmacosdisplay-private.h"
|
|
|
|
#include "gdk/macos/gdkmacossurface-private.h"
|
2021-10-10 20:16:49 +00:00
|
|
|
#include "gdk/gdksurfaceprivate.h"
|
2013-05-20 17:48:32 +00:00
|
|
|
|
2020-10-10 03:08:23 +00:00
|
|
|
#import "gdk/macos/GdkMacosBaseView.h"
|
|
|
|
|
|
|
|
#define GTK_IM_CONTEXT_TYPE_QUARTZ (gtk_im_context_quartz_get_type())
|
2013-05-20 17:48:32 +00:00
|
|
|
#define GTK_IM_CONTEXT_QUARTZ(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_IM_CONTEXT_TYPE_QUARTZ, GtkIMContextQuartz))
|
|
|
|
#define GTK_IM_CONTEXT_QUARTZ_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_IM_CONTEXT_TYPE_QUARTZ, GtkIMContextQuartzClass))
|
|
|
|
|
2018-02-19 23:29:00 +00:00
|
|
|
|
2013-05-20 17:48:32 +00:00
|
|
|
typedef struct _GtkIMContextQuartz
|
|
|
|
{
|
|
|
|
GtkIMContext parent;
|
2020-06-18 16:33:30 +00:00
|
|
|
GtkIMContext *helper;
|
2018-03-21 10:49:14 +00:00
|
|
|
GdkSurface *client_surface;
|
2021-06-21 23:20:53 +00:00
|
|
|
GtkWidget *client_widget;
|
2020-07-24 18:40:36 +00:00
|
|
|
char *preedit_str;
|
2013-05-20 17:48:32 +00:00
|
|
|
unsigned int cursor_index;
|
|
|
|
unsigned int selected_len;
|
|
|
|
GdkRectangle *cursor_rect;
|
|
|
|
gboolean focused;
|
|
|
|
} GtkIMContextQuartz;
|
|
|
|
|
|
|
|
typedef struct _GtkIMContextQuartzClass
|
|
|
|
{
|
|
|
|
GtkIMContextClass parent_class;
|
|
|
|
} GtkIMContextQuartzClass;
|
|
|
|
|
2018-02-23 19:59:49 +00:00
|
|
|
G_DEFINE_TYPE_WITH_CODE (GtkIMContextQuartz, gtk_im_context_quartz, GTK_TYPE_IM_CONTEXT,
|
2018-03-09 07:13:13 +00:00
|
|
|
gtk_im_module_ensure_extension_point ();
|
2018-02-23 19:59:49 +00:00
|
|
|
g_io_extension_point_implement (GTK_IM_MODULE_EXTENSION_POINT_NAME,
|
|
|
|
g_define_type_id,
|
|
|
|
"quartz",
|
2019-01-20 23:47:30 +00:00
|
|
|
0))
|
2013-05-20 17:48:32 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
quartz_get_preedit_string (GtkIMContext *context,
|
2020-07-24 18:40:36 +00:00
|
|
|
char **str,
|
2013-05-20 17:48:32 +00:00
|
|
|
PangoAttrList **attrs,
|
2020-07-24 13:54:49 +00:00
|
|
|
int *cursor_pos)
|
2013-05-20 17:48:32 +00:00
|
|
|
{
|
|
|
|
GtkIMContextQuartz *qc = GTK_IM_CONTEXT_QUARTZ (context);
|
|
|
|
|
2020-10-10 03:08:23 +00:00
|
|
|
GTK_NOTE (MODULES, g_print ("quartz_get_preedit_string\n"));
|
2013-05-20 17:48:32 +00:00
|
|
|
|
|
|
|
if (str)
|
|
|
|
*str = qc->preedit_str ? g_strdup (qc->preedit_str) : g_strdup ("");
|
|
|
|
|
|
|
|
if (attrs)
|
|
|
|
{
|
|
|
|
*attrs = pango_attr_list_new ();
|
|
|
|
int len = g_utf8_strlen (*str, -1);
|
2020-07-24 18:40:36 +00:00
|
|
|
char *ch = *str;
|
2013-05-20 17:48:32 +00:00
|
|
|
if (len > 0)
|
|
|
|
{
|
|
|
|
PangoAttribute *attr;
|
|
|
|
int i = 0;
|
|
|
|
for (;;)
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
char *s = ch;
|
2013-05-20 17:48:32 +00:00
|
|
|
ch = g_utf8_next_char (ch);
|
|
|
|
|
|
|
|
if (i >= qc->cursor_index &&
|
|
|
|
i < qc->cursor_index + qc->selected_len)
|
|
|
|
attr = pango_attr_underline_new (PANGO_UNDERLINE_DOUBLE);
|
|
|
|
else
|
|
|
|
attr = pango_attr_underline_new (PANGO_UNDERLINE_SINGLE);
|
|
|
|
|
|
|
|
attr->start_index = s - *str;
|
|
|
|
if (!*ch)
|
|
|
|
attr->end_index = attr->start_index + strlen (s);
|
|
|
|
else
|
|
|
|
attr->end_index = ch - *str;
|
|
|
|
|
|
|
|
pango_attr_list_change (*attrs, attr);
|
|
|
|
|
|
|
|
if (!*ch)
|
|
|
|
break;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (cursor_pos)
|
|
|
|
*cursor_pos = qc->cursor_index;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2013-08-16 16:54:34 +00:00
|
|
|
output_result (GtkIMContext *context,
|
2018-03-21 10:49:14 +00:00
|
|
|
GdkSurface *surface)
|
2013-05-20 17:48:32 +00:00
|
|
|
{
|
|
|
|
GtkIMContextQuartz *qc = GTK_IM_CONTEXT_QUARTZ (context);
|
|
|
|
gboolean retval = FALSE;
|
2020-07-24 18:40:36 +00:00
|
|
|
char *fixed_str, *marked_str;
|
2013-05-20 17:48:32 +00:00
|
|
|
|
2018-03-21 10:49:14 +00:00
|
|
|
fixed_str = g_strdup (g_object_get_data (G_OBJECT (surface), TIC_INSERT_TEXT));
|
|
|
|
marked_str = g_strdup (g_object_get_data (G_OBJECT (surface), TIC_MARKED_TEXT));
|
2013-05-20 17:48:32 +00:00
|
|
|
if (fixed_str)
|
|
|
|
{
|
2020-10-10 03:08:23 +00:00
|
|
|
GTK_NOTE (MODULES, g_print ("tic-insert-text: %s\n", fixed_str));
|
2013-05-20 17:48:32 +00:00
|
|
|
g_free (qc->preedit_str);
|
|
|
|
qc->preedit_str = NULL;
|
2018-03-21 10:49:14 +00:00
|
|
|
g_object_set_data (G_OBJECT (surface), TIC_INSERT_TEXT, NULL);
|
2013-05-20 17:48:32 +00:00
|
|
|
g_signal_emit_by_name (context, "commit", fixed_str);
|
|
|
|
g_signal_emit_by_name (context, "preedit_changed");
|
|
|
|
|
|
|
|
unsigned int filtered =
|
2018-03-21 10:49:14 +00:00
|
|
|
GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (surface),
|
2013-05-20 17:48:32 +00:00
|
|
|
GIC_FILTER_KEY));
|
2020-10-10 03:08:23 +00:00
|
|
|
GTK_NOTE (MODULES, g_print ("filtered, %d\n", filtered));
|
2013-05-20 17:48:32 +00:00
|
|
|
if (filtered)
|
|
|
|
retval = TRUE;
|
|
|
|
else
|
|
|
|
retval = FALSE;
|
|
|
|
}
|
|
|
|
if (marked_str)
|
|
|
|
{
|
2020-10-10 03:08:23 +00:00
|
|
|
GTK_NOTE (MODULES, g_print ("tic-marked-text: %s\n", marked_str));
|
2013-05-20 17:48:32 +00:00
|
|
|
qc->cursor_index =
|
2018-03-21 10:49:14 +00:00
|
|
|
GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (surface),
|
2013-05-20 17:48:32 +00:00
|
|
|
TIC_SELECTED_POS));
|
|
|
|
qc->selected_len =
|
2018-03-21 10:49:14 +00:00
|
|
|
GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (surface),
|
2013-05-20 17:48:32 +00:00
|
|
|
TIC_SELECTED_LEN));
|
|
|
|
g_free (qc->preedit_str);
|
|
|
|
qc->preedit_str = g_strdup (marked_str);
|
2018-03-21 10:49:14 +00:00
|
|
|
g_object_set_data (G_OBJECT (surface), TIC_MARKED_TEXT, NULL);
|
2013-05-20 17:48:32 +00:00
|
|
|
g_signal_emit_by_name (context, "preedit_changed");
|
|
|
|
retval = TRUE;
|
|
|
|
}
|
2013-08-29 21:12:09 +00:00
|
|
|
if (!fixed_str && !marked_str)
|
2013-08-16 16:54:34 +00:00
|
|
|
{
|
|
|
|
if (qc->preedit_str && strlen (qc->preedit_str) > 0)
|
|
|
|
retval = TRUE;
|
|
|
|
}
|
2017-08-08 20:15:46 +00:00
|
|
|
g_free (fixed_str);
|
|
|
|
g_free (marked_str);
|
2013-08-16 16:54:34 +00:00
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
quartz_filter_keypress (GtkIMContext *context,
|
2020-02-21 02:21:08 +00:00
|
|
|
GdkEvent *event)
|
2013-08-16 16:54:34 +00:00
|
|
|
{
|
|
|
|
GtkIMContextQuartz *qc = GTK_IM_CONTEXT_QUARTZ (context);
|
2020-10-10 03:08:23 +00:00
|
|
|
GdkEventType event_type;
|
2013-08-16 16:54:34 +00:00
|
|
|
gboolean retval;
|
2020-10-10 03:08:23 +00:00
|
|
|
guint keyval;
|
|
|
|
guint keycode;
|
2013-08-16 16:54:34 +00:00
|
|
|
|
2020-10-10 03:08:23 +00:00
|
|
|
GTK_NOTE (MODULES, g_print ("quartz_filter_keypress\n"));
|
2013-08-16 16:54:34 +00:00
|
|
|
|
2020-10-10 03:08:23 +00:00
|
|
|
if (!GDK_IS_MACOS_SURFACE (qc->client_surface))
|
2013-08-16 16:54:34 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2020-10-10 03:08:23 +00:00
|
|
|
event_type = gdk_event_get_event_type (event);
|
|
|
|
keyval = gdk_key_event_get_keyval (event);
|
|
|
|
keycode = gdk_key_event_get_keycode (event);
|
2013-08-16 16:54:34 +00:00
|
|
|
|
2020-10-10 03:08:23 +00:00
|
|
|
NSEvent *nsevent = _gdk_macos_display_get_nsevent ((GdkEvent *)event);
|
2013-08-16 16:54:34 +00:00
|
|
|
|
|
|
|
if (!nsevent)
|
|
|
|
{
|
2020-10-10 03:08:23 +00:00
|
|
|
if (keycode == 0 && keyval == 0xffffff)
|
2013-08-16 16:54:34 +00:00
|
|
|
/* update text input changes by mouse events */
|
2020-10-10 03:08:23 +00:00
|
|
|
return output_result (context, qc->client_surface);
|
2013-08-16 16:54:34 +00:00
|
|
|
else
|
2020-06-18 16:33:30 +00:00
|
|
|
return gtk_im_context_filter_keypress (qc->helper, event);
|
2013-08-16 16:54:34 +00:00
|
|
|
}
|
|
|
|
|
2020-10-10 03:08:23 +00:00
|
|
|
if (event_type == GDK_KEY_RELEASE)
|
2013-08-16 16:54:34 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2020-10-10 03:08:23 +00:00
|
|
|
if (keycode == 55) /* Command */
|
2013-08-16 16:54:34 +00:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
NSEventType etype = [nsevent type];
|
2020-10-10 03:08:23 +00:00
|
|
|
if (etype == NSEventTypeKeyDown)
|
2013-08-16 16:54:34 +00:00
|
|
|
{
|
2020-10-10 03:08:23 +00:00
|
|
|
NSView *nsview = _gdk_macos_surface_get_view (GDK_MACOS_SURFACE (qc->client_surface));
|
|
|
|
g_object_set_data (G_OBJECT (qc->client_surface),
|
|
|
|
TIC_IN_KEY_DOWN,
|
|
|
|
GUINT_TO_POINTER (TRUE));
|
|
|
|
[nsview keyDown: nsevent];
|
2013-08-16 16:54:34 +00:00
|
|
|
}
|
|
|
|
/* JIS_Eisu || JIS_Kana */
|
2020-10-10 03:08:23 +00:00
|
|
|
if (keycode == 102 || keycode == 104)
|
2013-08-16 16:54:34 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2020-10-10 03:08:23 +00:00
|
|
|
retval = output_result(context, qc->client_surface);
|
|
|
|
g_object_set_data (G_OBJECT (qc->client_surface),
|
|
|
|
TIC_IN_KEY_DOWN,
|
|
|
|
GUINT_TO_POINTER (FALSE));
|
|
|
|
GTK_NOTE (MODULES, g_print ("quartz_filter_keypress done\n"));
|
2013-08-16 16:54:34 +00:00
|
|
|
|
2013-05-20 17:48:32 +00:00
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2013-08-15 16:44:02 +00:00
|
|
|
static void
|
|
|
|
discard_preedit (GtkIMContext *context)
|
|
|
|
{
|
|
|
|
GtkIMContextQuartz *qc = GTK_IM_CONTEXT_QUARTZ (context);
|
|
|
|
|
2018-03-21 10:49:14 +00:00
|
|
|
if (!qc->client_surface)
|
2013-08-15 16:44:02 +00:00
|
|
|
return;
|
|
|
|
|
2020-10-10 03:08:23 +00:00
|
|
|
if (!GDK_IS_MACOS_SURFACE (qc->client_surface))
|
2013-08-15 16:44:02 +00:00
|
|
|
return;
|
|
|
|
|
2020-10-10 03:08:23 +00:00
|
|
|
NSView *nsview = _gdk_macos_surface_get_view (GDK_MACOS_SURFACE (qc->client_surface));
|
2015-09-18 22:12:24 +00:00
|
|
|
if (!nsview)
|
2013-08-15 16:44:02 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* reset any partial input for this NSView */
|
2020-10-10 03:08:23 +00:00
|
|
|
[(GdkMacosBaseView *)nsview unmarkText];
|
2021-06-06 15:39:43 +00:00
|
|
|
[[NSTextInputContext currentInputContext] discardMarkedText];
|
2013-08-15 16:44:02 +00:00
|
|
|
|
2013-08-15 20:08:34 +00:00
|
|
|
if (qc->preedit_str && strlen (qc->preedit_str) > 0)
|
2013-08-15 16:44:02 +00:00
|
|
|
{
|
|
|
|
g_signal_emit_by_name (context, "commit", qc->preedit_str);
|
|
|
|
|
|
|
|
g_free (qc->preedit_str);
|
|
|
|
qc->preedit_str = NULL;
|
|
|
|
g_signal_emit_by_name (context, "preedit_changed");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-20 17:48:32 +00:00
|
|
|
static void
|
|
|
|
quartz_reset (GtkIMContext *context)
|
|
|
|
{
|
2020-10-10 03:08:23 +00:00
|
|
|
GTK_NOTE (MODULES, g_print ("quartz_reset\n"));
|
2013-08-15 16:44:02 +00:00
|
|
|
discard_preedit (context);
|
2013-05-20 17:48:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2020-10-10 03:08:23 +00:00
|
|
|
quartz_set_client_surface (GtkIMContext *context,
|
|
|
|
GtkWidget *widget)
|
2013-05-20 17:48:32 +00:00
|
|
|
{
|
|
|
|
GtkIMContextQuartz *qc = GTK_IM_CONTEXT_QUARTZ (context);
|
|
|
|
|
2020-10-10 03:08:23 +00:00
|
|
|
GTK_NOTE (MODULES, g_print ("quartz_set_client_surface: %p\n", widget));
|
|
|
|
|
2021-06-21 23:20:53 +00:00
|
|
|
qc->client_widget = widget;
|
2020-10-10 03:08:23 +00:00
|
|
|
qc->client_surface = NULL;
|
2013-05-20 17:48:32 +00:00
|
|
|
|
2020-10-10 03:08:23 +00:00
|
|
|
if (widget != NULL)
|
|
|
|
{
|
|
|
|
GtkNative *native = gtk_widget_get_native (widget);
|
|
|
|
|
|
|
|
if (native != NULL)
|
|
|
|
qc->client_surface = gtk_native_get_surface (native);
|
|
|
|
}
|
2013-05-20 17:48:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
quartz_focus_in (GtkIMContext *context)
|
|
|
|
{
|
2020-10-10 03:08:23 +00:00
|
|
|
GTK_NOTE (MODULES, g_print ("quartz_focus_in\n"));
|
2013-05-20 17:48:32 +00:00
|
|
|
|
|
|
|
GtkIMContextQuartz *qc = GTK_IM_CONTEXT_QUARTZ (context);
|
|
|
|
qc->focused = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
quartz_focus_out (GtkIMContext *context)
|
|
|
|
{
|
2020-10-10 03:08:23 +00:00
|
|
|
GTK_NOTE (MODULES, g_print ("quartz_focus_out\n"));
|
2013-05-20 17:48:32 +00:00
|
|
|
|
|
|
|
GtkIMContextQuartz *qc = GTK_IM_CONTEXT_QUARTZ (context);
|
|
|
|
qc->focused = FALSE;
|
2013-08-15 16:44:02 +00:00
|
|
|
|
2020-09-12 16:01:04 +00:00
|
|
|
/* Commit any partially built strings or it'll mess up other widgets in the window */
|
2013-08-15 16:44:02 +00:00
|
|
|
discard_preedit (context);
|
2013-05-20 17:48:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
quartz_set_cursor_location (GtkIMContext *context, GdkRectangle *area)
|
|
|
|
{
|
|
|
|
GtkIMContextQuartz *qc = GTK_IM_CONTEXT_QUARTZ (context);
|
2021-12-09 20:26:33 +00:00
|
|
|
GtkWidget* surface_widget;
|
2021-06-21 23:20:53 +00:00
|
|
|
int sx, sy;
|
|
|
|
double wx, wy;
|
2013-05-20 17:48:32 +00:00
|
|
|
|
2020-10-10 03:08:23 +00:00
|
|
|
GTK_NOTE (MODULES, g_print ("quartz_set_cursor_location\n"));
|
2013-05-20 17:48:32 +00:00
|
|
|
|
2021-06-21 23:20:53 +00:00
|
|
|
if (!qc->client_surface || !qc->client_widget)
|
2013-05-20 17:48:32 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (!qc->focused)
|
|
|
|
return;
|
|
|
|
|
2021-12-09 20:26:33 +00:00
|
|
|
surface_widget = GTK_WIDGET (gdk_surface_get_widget (qc->client_surface));
|
|
|
|
|
|
|
|
if (!surface_widget)
|
|
|
|
return;
|
|
|
|
|
2021-06-21 23:20:53 +00:00
|
|
|
gdk_surface_get_origin (qc->client_surface, &sx, &sy);
|
2021-10-10 20:16:49 +00:00
|
|
|
gtk_widget_translate_coordinates(qc->client_widget, surface_widget,
|
|
|
|
area->x, area->y, &wx, &wy);
|
|
|
|
|
2021-06-21 23:20:53 +00:00
|
|
|
qc->cursor_rect->x = sx + (int) wx;
|
|
|
|
qc->cursor_rect->y = sy + (int) wy;
|
2013-05-20 17:48:32 +00:00
|
|
|
qc->cursor_rect->width = area->width;
|
|
|
|
qc->cursor_rect->height = area->height;
|
|
|
|
|
2020-10-10 03:08:23 +00:00
|
|
|
if (!GDK_IS_MACOS_SURFACE (qc->client_surface))
|
2013-05-20 17:48:32 +00:00
|
|
|
return;
|
|
|
|
|
2020-10-10 03:08:23 +00:00
|
|
|
g_object_set_data (G_OBJECT (qc->client_surface), GIC_CURSOR_RECT, qc->cursor_rect);
|
2013-05-20 17:48:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
quartz_set_use_preedit (GtkIMContext *context, gboolean use_preedit)
|
|
|
|
{
|
2020-10-10 03:08:23 +00:00
|
|
|
GTK_NOTE (MODULES, g_print ("quartz_set_use_preedit: %d\n", use_preedit));
|
2013-05-20 17:48:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2020-07-24 18:40:36 +00:00
|
|
|
commit_cb (GtkIMContext *context, const char *str, GtkIMContextQuartz *qc)
|
2013-05-20 17:48:32 +00:00
|
|
|
{
|
|
|
|
g_signal_emit_by_name (qc, "commit", str);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
imquartz_finalize (GObject *obj)
|
|
|
|
{
|
2020-10-10 03:08:23 +00:00
|
|
|
GTK_NOTE (MODULES, g_print ("imquartz_finalize\n"));
|
2013-05-20 17:48:32 +00:00
|
|
|
|
|
|
|
GtkIMContextQuartz *qc = GTK_IM_CONTEXT_QUARTZ (obj);
|
|
|
|
g_free (qc->preedit_str);
|
|
|
|
qc->preedit_str = NULL;
|
|
|
|
g_free (qc->cursor_rect);
|
|
|
|
qc->cursor_rect = NULL;
|
|
|
|
|
2020-06-18 16:33:30 +00:00
|
|
|
g_signal_handlers_disconnect_by_func (qc->helper, (gpointer)commit_cb, qc);
|
|
|
|
g_object_unref (qc->helper);
|
2013-05-20 17:48:32 +00:00
|
|
|
|
2020-10-10 03:08:23 +00:00
|
|
|
G_OBJECT_CLASS (gtk_im_context_quartz_parent_class)->finalize (obj);
|
2013-05-20 17:48:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-02-19 23:29:00 +00:00
|
|
|
gtk_im_context_quartz_class_init (GtkIMContextQuartzClass *class)
|
2013-05-20 17:48:32 +00:00
|
|
|
{
|
2020-10-10 03:08:23 +00:00
|
|
|
GTK_NOTE (MODULES, g_print ("gtk_im_context_quartz_class_init\n"));
|
2013-05-20 17:48:32 +00:00
|
|
|
|
2018-02-19 23:29:00 +00:00
|
|
|
GtkIMContextClass *klass = GTK_IM_CONTEXT_CLASS (class);
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
2013-05-20 17:48:32 +00:00
|
|
|
|
|
|
|
klass->get_preedit_string = quartz_get_preedit_string;
|
|
|
|
klass->filter_keypress = quartz_filter_keypress;
|
|
|
|
klass->reset = quartz_reset;
|
2018-03-21 10:49:14 +00:00
|
|
|
klass->set_client_widget = quartz_set_client_surface;
|
2013-05-20 17:48:32 +00:00
|
|
|
klass->focus_in = quartz_focus_in;
|
|
|
|
klass->focus_out = quartz_focus_out;
|
|
|
|
klass->set_cursor_location = quartz_set_cursor_location;
|
|
|
|
klass->set_use_preedit = quartz_set_use_preedit;
|
|
|
|
|
|
|
|
object_class->finalize = imquartz_finalize;
|
|
|
|
}
|
|
|
|
|
2018-02-19 23:29:00 +00:00
|
|
|
static void
|
|
|
|
gtk_im_context_quartz_init (GtkIMContextQuartz *qc)
|
2013-05-20 17:48:32 +00:00
|
|
|
{
|
2020-10-10 03:08:23 +00:00
|
|
|
GTK_NOTE (MODULES, g_print ("gtk_im_context_quartz_init\n"));
|
2013-05-20 17:48:32 +00:00
|
|
|
|
|
|
|
qc->preedit_str = g_strdup ("");
|
|
|
|
qc->cursor_index = 0;
|
|
|
|
qc->selected_len = 0;
|
|
|
|
qc->cursor_rect = g_malloc (sizeof (GdkRectangle));
|
|
|
|
qc->focused = FALSE;
|
|
|
|
|
2020-06-18 16:33:30 +00:00
|
|
|
qc->helper = g_object_new (GTK_TYPE_IM_CONTEXT_SIMPLE, NULL);
|
|
|
|
g_signal_connect (G_OBJECT (qc->helper), "commit", G_CALLBACK (commit_cb), qc);
|
2013-05-20 17:48:32 +00:00
|
|
|
}
|