Input Method support (Win32, MacOS, Linux)

This commit is contained in:
Mirek Fidler 2022-02-26 18:31:33 +01:00
parent 7ec93f4a40
commit 21eebae3db
28 changed files with 523 additions and 52 deletions

View file

@ -18,7 +18,7 @@ void Ctrl::Create(Ctrl *owner, bool popup)
top = new Top;
top->window = gtk_window_new(popup && owner ? GTK_WINDOW_POPUP : GTK_WINDOW_TOPLEVEL);
top->owner = owner;
static int id;
top->id = ++id;
@ -57,7 +57,7 @@ void Ctrl::Create(Ctrl *owner, bool popup)
gtk_window_resize(gtk(), LSC(r.GetWidth()), LSC(r.GetHeight()));
gtk_widget_realize(top->window);
w.gdk = gtk_widget_get_window(top->window);
if(owner && owner->top)
@ -68,20 +68,23 @@ void Ctrl::Create(Ctrl *owner, bool popup)
top->im_context = gtk_im_multicontext_new();
gtk_im_context_set_client_window(top->im_context, gdk());
gtk_im_context_set_use_preedit(top->im_context, false);
gtk_im_context_set_use_preedit(top->im_context, true);
g_signal_connect(top->im_context, "preedit-changed", G_CALLBACK(IMPreedit), (gpointer)(uintptr_t)top->id);
g_signal_connect(top->im_context, "preedit-start", G_CALLBACK(IMPreedit), (gpointer)(uintptr_t)top->id);
g_signal_connect(top->im_context, "preedit-end", G_CALLBACK(IMPreeditEnd), (gpointer)(uintptr_t)top->id);
g_signal_connect(top->im_context, "commit", G_CALLBACK(IMCommit), (gpointer)(uintptr_t)top->id);
WndShow(IsShown());
SweepConfigure(true);
FocusSync();
if(!popup)
SetWndFocus();
activeCtrl = this;
DndInit();
StateH(OPEN);
GdkModifierType mod;
@ -89,7 +92,7 @@ void Ctrl::Create(Ctrl *owner, bool popup)
r = GetWndScreenRect().GetSize();
if(r.Contains(m))
DispatchMouse(MOUSEMOVE, m);
RefreshLayoutDeep();
}
@ -108,7 +111,8 @@ void Ctrl::WndDestroy()
if(HasFocusDeep() || !GetFocusCtrl())
activeCtrl = owner;
}
g_object_unref(top->im_context);
if(top->im_context)
g_object_unref(top->im_context);
gtk_widget_destroy(top->window);
isopen = false;
popup = false;
@ -167,4 +171,4 @@ void Ctrl::PopUp(Ctrl *owner, bool savebits, bool activate, bool, bool)
}
#endif
#endif