firefox/im-patch.patch
2024-03-25 21:43:22 +01:00

123 lines
5.3 KiB
Diff

diff -up firefox-124.0.1/widget/gtk/IMContextWrapper.cpp.im-patch firefox-124.0.1/widget/gtk/IMContextWrapper.cpp
--- firefox-124.0.1/widget/gtk/IMContextWrapper.cpp.im-patch 2024-03-22 05:00:19.000000000 +0100
+++ firefox-124.0.1/widget/gtk/IMContextWrapper.cpp 2024-03-25 21:39:58.961947576 +0100
@@ -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::
}
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) {
diff -up firefox-124.0.1/widget/gtk/IMContextWrapper.h.im-patch firefox-124.0.1/widget/gtk/IMContextWrapper.h
--- firefox-124.0.1/widget/gtk/IMContextWrapper.h.im-patch 2024-03-22 05:00:19.000000000 +0100
+++ firefox-124.0.1/widget/gtk/IMContextWrapper.h 2024-03-25 21:39:58.961947576 +0100
@@ -117,10 +117,6 @@ class IMContextWrapper final : public Te
void OnUpdateComposition();
void OnLayoutChange();
- // Set GdkWindow associated with IM context.
- // It can be null which disables context operations.
- void SetGdkWindow(GdkWindow* aGdkWindow);
-
TextEventDispatcher* GetTextEventDispatcher();
// TODO: Typically, new IM comes every several years. And now, our code
diff -up firefox-124.0.1/widget/gtk/nsWindow.cpp.im-patch firefox-124.0.1/widget/gtk/nsWindow.cpp
--- firefox-124.0.1/widget/gtk/nsWindow.cpp.im-patch 2024-03-25 21:39:58.959947505 +0100
+++ firefox-124.0.1/widget/gtk/nsWindow.cpp 2024-03-25 21:41:09.178439036 +0100
@@ -5822,9 +5822,6 @@ void nsWindow::EnsureGdkWindow() {
if (!mGdkWindow) {
mGdkWindow = gtk_widget_get_window(GTK_WIDGET(mContainer));
g_object_set_data(G_OBJECT(mGdkWindow), "nsWindow", this);
- if (mIMContext) {
- mIMContext->SetGdkWindow(mGdkWindow);
- }
}
}
@@ -9933,9 +9930,6 @@ void nsWindow::DisableRendering() {
LOG("nsWindow::DisableRendering()");
if (mGdkWindow) {
- if (mIMContext) {
- mIMContext->SetGdkWindow(nullptr);
- }
g_object_set_data(G_OBJECT(mGdkWindow), "nsWindow", nullptr);
mGdkWindow = nullptr;
}