summaryrefslogtreecommitdiffstats
path: root/widget/gtk/IMContextWrapper.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:33 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:33 +0000
commit086c044dc34dfc0f74fbe41f4ecb402b2cd34884 (patch)
treea4f824bd33cb075dd5aa3eb5a0a94af221bbe83a /widget/gtk/IMContextWrapper.cpp
parentAdding debian version 124.0.1-1. (diff)
downloadfirefox-086c044dc34dfc0f74fbe41f4ecb402b2cd34884.tar.xz
firefox-086c044dc34dfc0f74fbe41f4ecb402b2cd34884.zip
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'widget/gtk/IMContextWrapper.cpp')
-rw-r--r--widget/gtk/IMContextWrapper.cpp38
1 files changed, 20 insertions, 18 deletions
diff --git a/widget/gtk/IMContextWrapper.cpp b/widget/gtk/IMContextWrapper.cpp
index fc87acbf86..2e438bbc5c 100644
--- a/widget/gtk/IMContextWrapper.cpp
+++ b/widget/gtk/IMContextWrapper.cpp
@@ -232,11 +232,18 @@ class SelectionStyleProvider final {
sHasShutDown = true;
}
- // mContainer associated with an IM context.
- void AttachTo(MozContainer* aContainer) {
- gtk_style_context_add_provider(
- gtk_widget_get_style_context(GTK_WIDGET(aContainer)),
- GTK_STYLE_PROVIDER(mProvider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+ // aGDKWindow is a GTK window which will be associated with an IM context.
+ void AttachTo(GdkWindow* aGDKWindow) {
+ GtkWidget* widget = nullptr;
+ // gdk_window_get_user_data() typically returns pointer to widget that
+ // window belongs to. If it's widget, fcitx retrieves selection colors
+ // of them. So, we need to overwrite its style.
+ gdk_window_get_user_data(aGDKWindow, (gpointer*)&widget);
+ if (GTK_IS_WIDGET(widget)) {
+ gtk_style_context_add_provider(gtk_widget_get_style_context(widget),
+ GTK_STYLE_PROVIDER(mProvider),
+ GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+ }
}
void OnThemeChanged() {
@@ -410,17 +417,21 @@ nsDependentCSubstring IMContextWrapper::GetIMName() const {
}
void IMContextWrapper::Init() {
+ MozContainer* container = mOwnerWindow->GetMozContainer();
+ MOZ_ASSERT(container, "container is null");
+ GdkWindow* gdkWindow = gtk_widget_get_window(GTK_WIDGET(container));
+
// Overwrite selection colors of the window before associating the window
// with IM context since IME may look up selection colors via IM context
// to support any colored widgets.
- SelectionStyleProvider::GetInstance()->AttachTo(
- mOwnerWindow->GetMozContainer());
+ SelectionStyleProvider::GetInstance()->AttachTo(gdkWindow);
// NOTE: gtk_im_*_new() abort (kill) the whole process when it fails.
// So, we don't need to check the result.
// Normal context.
mContext = gtk_im_multicontext_new();
+ gtk_im_context_set_client_window(mContext, gdkWindow);
g_signal_connect(mContext, "preedit_changed",
G_CALLBACK(IMContextWrapper::OnChangeCompositionCallback),
this);
@@ -492,6 +503,7 @@ void IMContextWrapper::Init() {
// Simple context
if (sUseSimpleContext) {
mSimpleContext = gtk_im_context_simple_new();
+ gtk_im_context_set_client_window(mSimpleContext, gdkWindow);
g_signal_connect(mSimpleContext, "preedit_changed",
G_CALLBACK(&IMContextWrapper::OnChangeCompositionCallback),
this);
@@ -514,6 +526,7 @@ void IMContextWrapper::Init() {
// Dummy context
mDummyContext = gtk_im_multicontext_new();
+ gtk_im_context_set_client_window(mDummyContext, gdkWindow);
MOZ_LOG(gIMELog, LogLevel::Info,
("0x%p Init(), mOwnerWindow=%p, mContext=%p (im=\"%s\"), "
@@ -540,17 +553,6 @@ IMContextWrapper::~IMContextWrapper() {
MOZ_LOG(gIMELog, LogLevel::Info, ("0x%p ~IMContextWrapper()", this));
}
-void IMContextWrapper::SetGdkWindow(GdkWindow* aGdkWindow) {
- MOZ_LOG(gIMELog, LogLevel::Info,
- ("0x%p GdkWindowChanged(%p)", this, aGdkWindow));
- MOZ_ASSERT(!aGdkWindow || mOwnerWindow->GetGdkWindow() == aGdkWindow);
- gtk_im_context_set_client_window(mContext, aGdkWindow);
- if (mSimpleContext) {
- gtk_im_context_set_client_window(mSimpleContext, aGdkWindow);
- }
- gtk_im_context_set_client_window(mDummyContext, aGdkWindow);
-}
-
NS_IMETHODIMP
IMContextWrapper::NotifyIME(TextEventDispatcher* aTextEventDispatcher,
const IMENotification& aNotification) {