From 8a8a325a1e68b83f1eb4960cc9842778554c83bd Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Mon, 20 May 2013 02:30:12 +0200 Subject: [PATCH] Terminal: work-around missing/out-of-order modifiers events ... more aggressively than before: * Only use modifiers(). * Before forwarding any relevant event to the active state, first check whether the modifiers have changed. While the issues should really be fixed where they originate (app server?), this hopefully fixes all situations where the hyperlink mode gets stuck. --- src/apps/terminal/TermView.cpp | 38 +++++++++++++++++++++++----------- src/apps/terminal/TermView.h | 2 ++ 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/src/apps/terminal/TermView.cpp b/src/apps/terminal/TermView.cpp index 610208e931..393f0a1ccd 100644 --- a/src/apps/terminal/TermView.cpp +++ b/src/apps/terminal/TermView.cpp @@ -1156,7 +1156,8 @@ void TermView::AttachedToWindow() { fMouseButtons = 0; - fModifiers = modifiers(); + + _UpdateModifiers(); // update the terminal size because it may have changed while the TermView // was detached from the window. On such conditions FrameResized was not @@ -1380,14 +1381,9 @@ TermView::WindowActivated(bool active) _Deactivate(); } - fActiveState->WindowActivated(active); + _UpdateModifiers(); - if (active) { - int32 oldModifiers = fModifiers; - fModifiers = modifiers(); - if (fModifiers != oldModifiers) - fActiveState->ModifiersChanged(oldModifiers, fModifiers); - } + fActiveState->WindowActivated(active); } @@ -1409,6 +1405,8 @@ TermView::MakeFocus(bool focusState) void TermView::KeyDown(const char *bytes, int32 numBytes) { + _UpdateModifiers(); + fActiveState->KeyDown(bytes, numBytes); } @@ -1601,10 +1599,7 @@ TermView::MessageReceived(BMessage *msg) case B_MODIFIERS_CHANGED: { - int32 oldModifiers = fModifiers; - fModifiers = msg->GetInt32("modifiers", 0); - if (fModifiers != oldModifiers) - fActiveState->ModifiersChanged(oldModifiers, fModifiers); + _UpdateModifiers(); break; } @@ -2376,6 +2371,8 @@ TermView::MouseDown(BPoint where) if (!IsFocus()) MakeFocus(); + _UpdateModifiers(); + BMessage* currentMessage = Window()->CurrentMessage(); int32 buttons = currentMessage->GetInt32("buttons", 0); @@ -2389,6 +2386,8 @@ TermView::MouseDown(BPoint where) void TermView::MouseMoved(BPoint where, uint32 transit, const BMessage *message) { + _UpdateModifiers(); + fActiveState->MouseMoved(where, transit, message, fModifiers); } @@ -2396,6 +2395,8 @@ TermView::MouseMoved(BPoint where, uint32 transit, const BMessage *message) void TermView::MouseUp(BPoint where) { + _UpdateModifiers(); + int32 buttons = Window()->CurrentMessage()->GetInt32("buttons", 0); fActiveState->MouseUp(where, buttons); @@ -2975,6 +2976,19 @@ TermView::_CancelInputMethod() } +void +TermView::_UpdateModifiers() +{ + // TODO: This method is a general work-around for missing or out-of-order + // B_MODIFIERS_CHANGED messages. This should really be fixed where it is + // broken (app server?). + int32 oldModifiers = fModifiers; + fModifiers = modifiers(); + if (fModifiers != oldModifiers && fActiveState != NULL) + fActiveState->ModifiersChanged(oldModifiers, fModifiers); +} + + void TermView::_NextState(State* state) { diff --git a/src/apps/terminal/TermView.h b/src/apps/terminal/TermView.h index a1ab24ed22..53f7e706cc 100644 --- a/src/apps/terminal/TermView.h +++ b/src/apps/terminal/TermView.h @@ -251,6 +251,8 @@ private: void _HandleInputMethodLocationRequest(); void _CancelInputMethod(); + void _UpdateModifiers(); + void _NextState(State* state); private: