From c94ae1aff5de9e29a69a26eb93c37f4ba917f847 Mon Sep 17 00:00:00 2001
From: Ingo Weinhold <ingo_weinhold@gmx.de>
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 610208e..393f0a1 100644
a
|
b
|
void
|
1156 | 1156 | TermView::AttachedToWindow() |
1157 | 1157 | { |
1158 | 1158 | fMouseButtons = 0; |
1159 | | fModifiers = modifiers(); |
| 1159 | |
| 1160 | _UpdateModifiers(); |
1160 | 1161 | |
1161 | 1162 | // update the terminal size because it may have changed while the TermView |
1162 | 1163 | // was detached from the window. On such conditions FrameResized was not |
… |
… |
TermView::WindowActivated(bool active)
|
1380 | 1381 | _Deactivate(); |
1381 | 1382 | } |
1382 | 1383 | |
1383 | | fActiveState->WindowActivated(active); |
| 1384 | _UpdateModifiers(); |
1384 | 1385 | |
1385 | | if (active) { |
1386 | | int32 oldModifiers = fModifiers; |
1387 | | fModifiers = modifiers(); |
1388 | | if (fModifiers != oldModifiers) |
1389 | | fActiveState->ModifiersChanged(oldModifiers, fModifiers); |
1390 | | } |
| 1386 | fActiveState->WindowActivated(active); |
1391 | 1387 | } |
1392 | 1388 | |
1393 | 1389 | |
… |
… |
TermView::MakeFocus(bool focusState)
|
1409 | 1405 | void |
1410 | 1406 | TermView::KeyDown(const char *bytes, int32 numBytes) |
1411 | 1407 | { |
| 1408 | _UpdateModifiers(); |
| 1409 | |
1412 | 1410 | fActiveState->KeyDown(bytes, numBytes); |
1413 | 1411 | } |
1414 | 1412 | |
… |
… |
TermView::MessageReceived(BMessage *msg)
|
1601 | 1599 | |
1602 | 1600 | case B_MODIFIERS_CHANGED: |
1603 | 1601 | { |
1604 | | int32 oldModifiers = fModifiers; |
1605 | | fModifiers = msg->GetInt32("modifiers", 0); |
1606 | | if (fModifiers != oldModifiers) |
1607 | | fActiveState->ModifiersChanged(oldModifiers, fModifiers); |
| 1602 | _UpdateModifiers(); |
1608 | 1603 | break; |
1609 | 1604 | } |
1610 | 1605 | |
… |
… |
TermView::MouseDown(BPoint where)
|
2376 | 2371 | if (!IsFocus()) |
2377 | 2372 | MakeFocus(); |
2378 | 2373 | |
| 2374 | _UpdateModifiers(); |
| 2375 | |
2379 | 2376 | BMessage* currentMessage = Window()->CurrentMessage(); |
2380 | 2377 | int32 buttons = currentMessage->GetInt32("buttons", 0); |
2381 | 2378 | |
… |
… |
TermView::MouseDown(BPoint where)
|
2389 | 2386 | void |
2390 | 2387 | TermView::MouseMoved(BPoint where, uint32 transit, const BMessage *message) |
2391 | 2388 | { |
| 2389 | _UpdateModifiers(); |
| 2390 | |
2392 | 2391 | fActiveState->MouseMoved(where, transit, message, fModifiers); |
2393 | 2392 | } |
2394 | 2393 | |
… |
… |
TermView::MouseMoved(BPoint where, uint32 transit, const BMessage *message)
|
2396 | 2395 | void |
2397 | 2396 | TermView::MouseUp(BPoint where) |
2398 | 2397 | { |
| 2398 | _UpdateModifiers(); |
| 2399 | |
2399 | 2400 | int32 buttons = Window()->CurrentMessage()->GetInt32("buttons", 0); |
2400 | 2401 | |
2401 | 2402 | fActiveState->MouseUp(where, buttons); |
… |
… |
TermView::_CancelInputMethod()
|
2976 | 2977 | |
2977 | 2978 | |
2978 | 2979 | void |
| 2980 | TermView::_UpdateModifiers() |
| 2981 | { |
| 2982 | // TODO: This method is a general work-around for missing or out-of-order |
| 2983 | // B_MODIFIERS_CHANGED messages. This should really be fixed where it is |
| 2984 | // broken (app server?). |
| 2985 | int32 oldModifiers = fModifiers; |
| 2986 | fModifiers = modifiers(); |
| 2987 | if (fModifiers != oldModifiers && fActiveState != NULL) |
| 2988 | fActiveState->ModifiersChanged(oldModifiers, fModifiers); |
| 2989 | } |
| 2990 | |
| 2991 | |
| 2992 | void |
2979 | 2993 | TermView::_NextState(State* state) |
2980 | 2994 | { |
2981 | 2995 | if (state != fActiveState) { |
diff --git a/src/apps/terminal/TermView.h b/src/apps/terminal/TermView.h
index a1ab24e..53f7e70 100644
a
|
b
|
private:
|
251 | 251 | void _HandleInputMethodLocationRequest(); |
252 | 252 | void _CancelInputMethod(); |
253 | 253 | |
| 254 | void _UpdateModifiers(); |
| 255 | |
254 | 256 | void _NextState(State* state); |
255 | 257 | |
256 | 258 | private: |