2013-11-13 11:20:07 +00:00
|
|
|
/*
|
|
|
|
* gtkimmodulebroadway
|
|
|
|
* Copyright (C) 2013 Alexander Larsson
|
|
|
|
*
|
|
|
|
* 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-11-13 11:20:07 +00:00
|
|
|
*
|
|
|
|
* $Id:$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include <string.h>
|
|
|
|
|
2018-02-23 19:59:49 +00:00
|
|
|
#include "gtk/gtkimcontextbroadway.h"
|
2018-03-09 07:13:13 +00:00
|
|
|
#include "gtk/gtkimmoduleprivate.h"
|
2013-11-13 11:20:07 +00:00
|
|
|
|
|
|
|
#include "gdk/broadway/gdkbroadway.h"
|
|
|
|
|
2018-02-19 23:29:00 +00:00
|
|
|
#define GTK_TYPE_IM_CONTEXT_BROADWAY (gtk_im_context_broadway_get_type ())
|
|
|
|
#define GTK_IM_CONTEXT_BROADWAY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_IM_CONTEXT_BROADWAY, GtkIMContextBroadway))
|
|
|
|
#define GTK_IM_CONTEXT_BROADWAY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_IM_CONTEXT_BROADWAY, GtkIMContextBroadwayClass))
|
2013-11-13 11:20:07 +00:00
|
|
|
|
|
|
|
typedef struct _GtkIMContextBroadway
|
|
|
|
{
|
|
|
|
GtkIMContextSimple parent;
|
2017-04-01 21:25:13 +00:00
|
|
|
GtkWidget *client_widget;
|
2013-11-13 11:20:07 +00:00
|
|
|
} GtkIMContextBroadway;
|
|
|
|
|
|
|
|
typedef struct _GtkIMContextBroadwayClass
|
|
|
|
{
|
|
|
|
GtkIMContextSimpleClass parent_class;
|
|
|
|
} GtkIMContextBroadwayClass;
|
|
|
|
|
2018-02-23 19:59:49 +00:00
|
|
|
G_DEFINE_TYPE_WITH_CODE (GtkIMContextBroadway, gtk_im_context_broadway, GTK_TYPE_IM_CONTEXT_SIMPLE,
|
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,
|
|
|
|
"broadway",
|
2019-01-20 23:47:30 +00:00
|
|
|
0))
|
2013-11-13 11:20:07 +00:00
|
|
|
|
|
|
|
static void
|
2017-04-01 21:25:13 +00:00
|
|
|
broadway_set_client_widget (GtkIMContext *context, GtkWidget *widget)
|
2013-11-13 11:20:07 +00:00
|
|
|
{
|
|
|
|
GtkIMContextBroadway *bw = GTK_IM_CONTEXT_BROADWAY (context);
|
|
|
|
|
2017-04-01 21:25:13 +00:00
|
|
|
bw->client_widget = widget;
|
2013-11-13 11:20:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
broadway_focus_in (GtkIMContext *context)
|
|
|
|
{
|
|
|
|
GtkIMContextBroadway *bw = GTK_IM_CONTEXT_BROADWAY (context);
|
|
|
|
GdkDisplay *display;
|
|
|
|
|
2017-04-01 21:25:13 +00:00
|
|
|
if (bw->client_widget)
|
2013-11-13 11:20:07 +00:00
|
|
|
{
|
2017-04-01 21:25:13 +00:00
|
|
|
display = gtk_widget_get_display (bw->client_widget);
|
2013-11-13 11:20:07 +00:00
|
|
|
gdk_broadway_display_show_keyboard (GDK_BROADWAY_DISPLAY (display));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
broadway_focus_out (GtkIMContext *context)
|
|
|
|
{
|
|
|
|
GtkIMContextBroadway *bw = GTK_IM_CONTEXT_BROADWAY (context);
|
|
|
|
GdkDisplay *display;
|
|
|
|
|
2017-04-01 21:25:13 +00:00
|
|
|
if (bw->client_widget)
|
2013-11-13 11:20:07 +00:00
|
|
|
{
|
2017-04-01 21:25:13 +00:00
|
|
|
display = gtk_widget_get_display (bw->client_widget);
|
2013-11-13 11:20:07 +00:00
|
|
|
gdk_broadway_display_hide_keyboard (GDK_BROADWAY_DISPLAY (display));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-02-19 23:29:00 +00:00
|
|
|
gtk_im_context_broadway_class_init (GtkIMContextBroadwayClass *class)
|
2013-11-13 11:20:07 +00:00
|
|
|
{
|
2018-02-19 23:29:00 +00:00
|
|
|
GtkIMContextClass *klass = GTK_IM_CONTEXT_CLASS (class);
|
2013-11-13 11:20:07 +00:00
|
|
|
|
|
|
|
klass->focus_in = broadway_focus_in;
|
|
|
|
klass->focus_out = broadway_focus_out;
|
2017-04-01 21:25:13 +00:00
|
|
|
klass->set_client_widget = broadway_set_client_widget;
|
2013-11-13 11:20:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-02-19 23:29:00 +00:00
|
|
|
gtk_im_context_broadway_init (GtkIMContextBroadway *im_context)
|
2013-11-13 11:20:07 +00:00
|
|
|
{
|
|
|
|
}
|