mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 849647 Get rid of message order optimization on Windows r=jimm
This commit is contained in:
parent
bdd72ba9e1
commit
23d8060cd8
@ -71,19 +71,6 @@ IMEHandler::GetNativeData(uint32_t aDataType)
|
||||
#endif // #ifdef NS_ENABLE_TSF #else
|
||||
}
|
||||
|
||||
// static
|
||||
bool
|
||||
IMEHandler::CanOptimizeKeyAndIMEMessages()
|
||||
{
|
||||
#ifdef NS_ENABLE_TSF
|
||||
if (IsTSFAvailable()) {
|
||||
return nsTextStore::CanOptimizeKeyAndIMEMessages();
|
||||
}
|
||||
#endif // #ifdef NS_ENABLE_TSF
|
||||
|
||||
return nsIMM32Handler::CanOptimizeKeyAndIMEMessages();
|
||||
}
|
||||
|
||||
// static
|
||||
bool
|
||||
IMEHandler::IsIMEEnabled(const InputContext& aInputContext)
|
||||
|
@ -36,12 +36,6 @@ public:
|
||||
*/
|
||||
static void* GetNativeData(uint32_t aDataType);
|
||||
|
||||
/**
|
||||
* Returns true if our message loop can optimize the message order for
|
||||
* a key message or an IME message. Otherwise, false.
|
||||
*/
|
||||
static bool CanOptimizeKeyAndIMEMessages();
|
||||
|
||||
/**
|
||||
* Returns true if the context or IME state is enabled. Otherwise, false.
|
||||
*/
|
||||
|
@ -40,54 +40,6 @@ using mozilla::crashreporter::LSPAnnotate;
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
static bool PeekUIMessage(MSG* aMsg)
|
||||
{
|
||||
// For avoiding deadlock between our process and plugin process by
|
||||
// mouse wheel messages, we're handling actually when we receive one of
|
||||
// following internal messages which is posted by native mouse wheel message
|
||||
// handler. Any other events, especially native modifier key events, should
|
||||
// not be handled between native message and posted internal message because
|
||||
// it may make different modifier key state or mouse cursor position between
|
||||
// them.
|
||||
if (mozilla::widget::MouseScrollHandler::IsWaitingInternalMessage() &&
|
||||
WinUtils::PeekMessage(aMsg, NULL, MOZ_WM_MOUSEWHEEL_FIRST,
|
||||
MOZ_WM_MOUSEWHEEL_LAST, PM_REMOVE)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
MSG keyMsg, imeMsg, mouseMsg, *pMsg = 0;
|
||||
bool haveKeyMsg, haveIMEMsg, haveMouseMsg;
|
||||
|
||||
haveKeyMsg = WinUtils::PeekMessage(&keyMsg, NULL, WM_KEYFIRST,
|
||||
WM_IME_KEYLAST, PM_NOREMOVE);
|
||||
haveIMEMsg = WinUtils::PeekMessage(&imeMsg, NULL, NS_WM_IMEFIRST,
|
||||
NS_WM_IMELAST, PM_NOREMOVE);
|
||||
haveMouseMsg = WinUtils::PeekMessage(&mouseMsg, NULL, WM_MOUSEFIRST,
|
||||
WM_MOUSELAST, PM_NOREMOVE);
|
||||
|
||||
if (haveKeyMsg) {
|
||||
pMsg = &keyMsg;
|
||||
}
|
||||
if (haveIMEMsg && (!pMsg || imeMsg.time < pMsg->time)) {
|
||||
pMsg = &imeMsg;
|
||||
}
|
||||
|
||||
if (pMsg && !mozilla::widget::IMEHandler::CanOptimizeKeyAndIMEMessages()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (haveMouseMsg && (!pMsg || mouseMsg.time < pMsg->time)) {
|
||||
pMsg = &mouseMsg;
|
||||
}
|
||||
|
||||
if (!pMsg) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return WinUtils::PeekMessage(aMsg, NULL, pMsg->message,
|
||||
pMsg->message, PM_REMOVE);
|
||||
}
|
||||
|
||||
/*static*/ LRESULT CALLBACK
|
||||
nsAppShell::EventWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
@ -226,12 +178,32 @@ nsAppShell::ProcessNextNativeEvent(bool mayWait)
|
||||
|
||||
do {
|
||||
MSG msg;
|
||||
bool uiMessage = PeekUIMessage(&msg);
|
||||
bool uiMessage = false;
|
||||
|
||||
// Give priority to keyboard and mouse messages.
|
||||
if (uiMessage ||
|
||||
WinUtils::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
|
||||
gotMessage = true;
|
||||
// For avoiding deadlock between our process and plugin process by
|
||||
// mouse wheel messages, we're handling actually when we receive one of
|
||||
// following internal messages which is posted by native mouse wheel
|
||||
// message handler. Any other events, especially native modifier key
|
||||
// events, should not be handled between native message and posted
|
||||
// internal message because it may make different modifier key state or
|
||||
// mouse cursor position between them.
|
||||
if (mozilla::widget::MouseScrollHandler::IsWaitingInternalMessage()) {
|
||||
gotMessage = WinUtils::PeekMessage(&msg, NULL, MOZ_WM_MOUSEWHEEL_FIRST,
|
||||
MOZ_WM_MOUSEWHEEL_LAST, PM_REMOVE);
|
||||
NS_ASSERTION(gotMessage,
|
||||
"waiting internal wheel message, but it has not come");
|
||||
uiMessage = gotMessage;
|
||||
}
|
||||
|
||||
if (!gotMessage) {
|
||||
gotMessage = WinUtils::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE);
|
||||
uiMessage =
|
||||
(msg.message >= WM_KEYFIRST && msg.message <= WM_IME_KEYLAST) ||
|
||||
(msg.message >= NS_WM_IMEFIRST && msg.message <= NS_WM_IMELAST) ||
|
||||
(msg.message >= WM_MOUSEFIRST && msg.message <= WM_MOUSELAST);
|
||||
}
|
||||
|
||||
if (gotMessage) {
|
||||
if (msg.message == WM_QUIT) {
|
||||
::PostQuitMessage(msg.wParam);
|
||||
Exit();
|
||||
|
@ -41,9 +41,6 @@ static UINT sWM_MSIME_MOUSE = 0; // mouse message for MSIME 98/2000
|
||||
#define IMEMOUSE_WUP 0x10 // wheel up
|
||||
#define IMEMOUSE_WDOWN 0x20 // wheel down
|
||||
|
||||
bool nsIMM32Handler::sIsIME = true;
|
||||
bool nsIMM32Handler::sIsIMEOpening = false;
|
||||
|
||||
UINT nsIMM32Handler::sCodePage = 0;
|
||||
DWORD nsIMM32Handler::sIMEProperty = 0;
|
||||
|
||||
@ -124,10 +121,10 @@ nsIMM32Handler::InitKeyboardLayout(HKL aKeyboardLayout)
|
||||
LOCALE_IDEFAULTANSICODEPAGE | LOCALE_RETURN_NUMBER,
|
||||
(PWSTR)&sCodePage, sizeof(sCodePage) / sizeof(WCHAR));
|
||||
sIMEProperty = ::ImmGetProperty(aKeyboardLayout, IGP_PROPERTY);
|
||||
sIsIME = ::ImmIsIME(aKeyboardLayout);
|
||||
PR_LOG(gIMM32Log, PR_LOG_ALWAYS,
|
||||
("IMM32: InitKeyboardLayout, aKeyboardLayout=%08x, sCodePage=%lu, sIMEProperty=%08x sIsIME=%s\n",
|
||||
aKeyboardLayout, sCodePage, sIMEProperty, sIsIME ? "TRUE" : "FALSE"));
|
||||
("IMM32: InitKeyboardLayout, aKeyboardLayout=%08x, sCodePage=%lu, "
|
||||
"sIMEProperty=%08x",
|
||||
aKeyboardLayout, sCodePage, sIMEProperty));
|
||||
}
|
||||
|
||||
/* static */ UINT
|
||||
@ -136,18 +133,6 @@ nsIMM32Handler::GetKeyboardCodePage()
|
||||
return sCodePage;
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
nsIMM32Handler::CanOptimizeKeyAndIMEMessages()
|
||||
{
|
||||
// If IME is opening right now, we shouldn't optimize the key and IME message
|
||||
// order because ATOK (Japanese IME of third party) has some problem with the
|
||||
// optimization. When it finishes opening completely, it eats all key
|
||||
// messages in the message queue. And it causes starting composition. So,
|
||||
// we shouldn't eat the key messages before ATOK.
|
||||
return !sIsIMEOpening;
|
||||
}
|
||||
|
||||
|
||||
// used for checking the lParam of WM_IME_COMPOSITION
|
||||
#define IS_COMPOSING_LPARAM(lParam) \
|
||||
((lParam) & (GCS_COMPSTR | GCS_COMPATTR | GCS_COMPCLAUSE | GCS_CURSORPOS))
|
||||
@ -292,21 +277,6 @@ nsIMM32Handler::ProcessMessage(nsWindow* aWindow, UINT msg,
|
||||
// if the new window handle is not focused, probably, we should not start
|
||||
// the composition, however, such case should not be, it's just bad scenario.
|
||||
|
||||
if (sIsIMEOpening) {
|
||||
switch (msg) {
|
||||
case WM_INPUTLANGCHANGE:
|
||||
case WM_IME_STARTCOMPOSITION:
|
||||
case WM_IME_COMPOSITION:
|
||||
case WM_IME_ENDCOMPOSITION:
|
||||
case WM_IME_CHAR:
|
||||
case WM_IME_SELECT:
|
||||
case WM_IME_SETCONTEXT:
|
||||
// For safety, we should reset sIsIMEOpening when we receive unexpected
|
||||
// message.
|
||||
sIsIMEOpening = false;
|
||||
}
|
||||
}
|
||||
|
||||
// When a plug-in has focus or compsition, we should dispatch the IME events
|
||||
// to the plug-in.
|
||||
if (aWindow->PluginHasFocus() || IsComposingOnPlugin()) {
|
||||
@ -416,20 +386,6 @@ nsIMM32Handler::ProcessMessageForPlugin(nsWindow* aWindow, UINT msg,
|
||||
case WM_IME_SETCONTEXT:
|
||||
aEatMessage = OnIMESetContextOnPlugin(aWindow, wParam, lParam, aRetValue);
|
||||
return true;
|
||||
case WM_IME_NOTIFY:
|
||||
if (wParam == IMN_SETOPENSTATUS) {
|
||||
// finished being opening
|
||||
sIsIMEOpening = false;
|
||||
}
|
||||
return false;
|
||||
case WM_KEYDOWN:
|
||||
if (wParam == VK_PROCESSKEY) {
|
||||
// If we receive when IME isn't open, it means IME is opening right now.
|
||||
nsIMEContext IMEContext(aWindow->GetWindowHandle());
|
||||
sIsIMEOpening = IMEContext.IsValid() &&
|
||||
::ImmGetOpenStatus(IMEContext.get());
|
||||
}
|
||||
return false;
|
||||
case WM_CHAR:
|
||||
if (!gIMM32Handler) {
|
||||
return false;
|
||||
@ -645,7 +601,6 @@ nsIMM32Handler::OnIMENotify(nsWindow* aWindow,
|
||||
aWindow->GetWindowHandle()));
|
||||
break;
|
||||
case IMN_SETOPENSTATUS:
|
||||
sIsIMEOpening = false;
|
||||
PR_LOG(gIMM32Log, PR_LOG_ALWAYS,
|
||||
("IMM32: OnIMENotify, hWnd=%08x, IMN_SETOPENSTATUS\n",
|
||||
aWindow->GetWindowHandle()));
|
||||
@ -2058,14 +2013,6 @@ nsIMM32Handler::OnKeyDownEvent(nsWindow* aWindow, WPARAM wParam, LPARAM lParam,
|
||||
aWindow->GetWindowHandle(), wParam, lParam));
|
||||
aEatMessage = false;
|
||||
switch (wParam) {
|
||||
case VK_PROCESSKEY:
|
||||
// If we receive when IME isn't open, it means IME is opening right now.
|
||||
if (sIsIME) {
|
||||
nsIMEContext IMEContext(aWindow->GetWindowHandle());
|
||||
sIsIMEOpening =
|
||||
IMEContext.IsValid() && !::ImmGetOpenStatus(IMEContext.get());
|
||||
}
|
||||
return false;
|
||||
case VK_TAB:
|
||||
case VK_PRIOR:
|
||||
case VK_NEXT:
|
||||
|
@ -122,14 +122,12 @@ public:
|
||||
return IsComposing() && IsComposingWindow(aWindow);
|
||||
}
|
||||
|
||||
static bool CanOptimizeKeyAndIMEMessages();
|
||||
|
||||
#ifdef DEBUG
|
||||
/**
|
||||
* IsIMEAvailable() returns TRUE when current keyboard layout has IME.
|
||||
* Otherwise, FALSE.
|
||||
*/
|
||||
static bool IsIMEAvailable() { return sIsIME; }
|
||||
static bool IsIMEAvailable() { return !!::ImmIsIME(::GetKeyboardLayout(0)); }
|
||||
#endif
|
||||
|
||||
// If aForce is TRUE, these methods doesn't check whether we have composition
|
||||
@ -326,9 +324,6 @@ protected:
|
||||
bool mIsComposingOnPlugin;
|
||||
bool mNativeCaretIsCreated;
|
||||
|
||||
static bool sIsIME;
|
||||
static bool sIsIMEOpening;
|
||||
|
||||
static UINT sCodePage;
|
||||
static DWORD sIMEProperty;
|
||||
};
|
||||
|
@ -142,12 +142,6 @@ public:
|
||||
|
||||
static nsIMEUpdatePreference GetIMEUpdatePreference();
|
||||
|
||||
static bool CanOptimizeKeyAndIMEMessages()
|
||||
{
|
||||
// TODO: We need to implement this for ATOK.
|
||||
return true;
|
||||
}
|
||||
|
||||
// Returns the address of the pointer so that the TSF automatic test can
|
||||
// replace the system object with a custom implementation for testing.
|
||||
static void* GetNativeData(uint32_t aDataType)
|
||||
|
Loading…
Reference in New Issue
Block a user