Skip to content

Commit

Permalink
fixes FreeCAD#9364: WM_INPUTLANGCHANGEREQUEST seems to freeze FreeCAD
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed May 3, 2023
1 parent b626caf commit be87f69
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/Mod/Web/Gui/AppWebGui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
# include <QUrl>
#endif

#include <QAbstractNativeEventFilter>
#ifdef Q_OS_WIN32
#include <Windows.h>
#endif

#include <Base/Console.h>
#include <Base/Interpreter.h>
#include <Base/PyObjectBase.h>
Expand Down Expand Up @@ -151,6 +156,27 @@ PyObject* initModule()
return Base::Interpreter().addModule(new Module);
}

class NativeEventFilter : public QAbstractNativeEventFilter
{
public:
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
bool nativeEventFilter(const QByteArray& eventType, void* message, qintptr* result) override
#else
bool nativeEventFilter(const QByteArray& eventType, void* message, long* result) override
#endif
{
// Fixes bug #9364: WM_INPUTLANGCHANGEREQUEST seems to freeze FreeCAD
#ifdef Q_OS_WIN32
MSG* msg = (MSG*)(message);
if (msg->message == WM_INPUTLANGCHANGEREQUEST) {
Base::Console().Log("Ignore WM_INPUTLANGCHANGEREQUEST\n");
return true;
}
#endif
return false;
}
};

} // namespace WebGui


Expand All @@ -170,6 +196,10 @@ PyMOD_INIT_FUNC(WebGui)
WebGui::BrowserView::init();
WebGui::Workbench::init();

#ifdef Q_OS_WIN32
qApp->installNativeEventFilter(new WebGui::NativeEventFilter);
#endif

// add resources and reloads the translators
loadWebResource();

Expand Down

0 comments on commit be87f69

Please sign in to comment.