Ticket #9785: 0001-Terminal-work-around-missing-out-of-order-modifiers-.patch

File 0001-Terminal-work-around-missing-out-of-order-modifiers-.patch, 3.7 KB (added by bonefish, 11 years ago)
  • src/apps/terminal/TermView.cpp

    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  
    11561156TermView::AttachedToWindow()
    11571157{
    11581158    fMouseButtons = 0;
    1159     fModifiers = modifiers();
     1159
     1160    _UpdateModifiers();
    11601161
    11611162    // update the terminal size because it may have changed while the TermView
    11621163    // was detached from the window. On such conditions FrameResized was not
    TermView::WindowActivated(bool active)  
    13801381            _Deactivate();
    13811382    }
    13821383
    1383     fActiveState->WindowActivated(active);
     1384    _UpdateModifiers();
    13841385
    1385     if (active) {
    1386         int32 oldModifiers = fModifiers;
    1387         fModifiers = modifiers();
    1388         if (fModifiers != oldModifiers)
    1389             fActiveState->ModifiersChanged(oldModifiers, fModifiers);
    1390     }
     1386    fActiveState->WindowActivated(active);
    13911387}
    13921388
    13931389
    TermView::MakeFocus(bool focusState)  
    14091405void
    14101406TermView::KeyDown(const char *bytes, int32 numBytes)
    14111407{
     1408    _UpdateModifiers();
     1409
    14121410    fActiveState->KeyDown(bytes, numBytes);
    14131411}
    14141412
    TermView::MessageReceived(BMessage *msg)  
    16011599
    16021600        case B_MODIFIERS_CHANGED:
    16031601        {
    1604             int32 oldModifiers = fModifiers;
    1605             fModifiers = msg->GetInt32("modifiers", 0);
    1606             if (fModifiers != oldModifiers)
    1607                 fActiveState->ModifiersChanged(oldModifiers, fModifiers);
     1602            _UpdateModifiers();
    16081603            break;
    16091604        }
    16101605
    TermView::MouseDown(BPoint where)  
    23762371    if (!IsFocus())
    23772372        MakeFocus();
    23782373
     2374    _UpdateModifiers();
     2375
    23792376    BMessage* currentMessage = Window()->CurrentMessage();
    23802377    int32 buttons = currentMessage->GetInt32("buttons", 0);
    23812378
    TermView::MouseDown(BPoint where)  
    23892386void
    23902387TermView::MouseMoved(BPoint where, uint32 transit, const BMessage *message)
    23912388{
     2389    _UpdateModifiers();
     2390
    23922391    fActiveState->MouseMoved(where, transit, message, fModifiers);
    23932392}
    23942393
    TermView::MouseMoved(BPoint where, uint32 transit, const BMessage *message)  
    23962395void
    23972396TermView::MouseUp(BPoint where)
    23982397{
     2398    _UpdateModifiers();
     2399
    23992400    int32 buttons = Window()->CurrentMessage()->GetInt32("buttons", 0);
    24002401
    24012402    fActiveState->MouseUp(where, buttons);
    TermView::_CancelInputMethod()  
    29762977
    29772978
    29782979void
     2980TermView::_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
     2992void
    29792993TermView::_NextState(State* state)
    29802994{
    29812995    if (state != fActiveState) {
  • src/apps/terminal/TermView.h

    diff --git a/src/apps/terminal/TermView.h b/src/apps/terminal/TermView.h
    index a1ab24e..53f7e70 100644
    a b private:  
    251251            void                _HandleInputMethodLocationRequest();
    252252            void                _CancelInputMethod();
    253253
     254            void                _UpdateModifiers();
     255
    254256            void                _NextState(State* state);
    255257
    256258private: