Changeset 58231 in webkit


Ignore:
Timestamp:
Apr 25, 2010 3:03:59 PM (14 years ago)
Author:
kevino@webkit.org
Message:

Reviewed by Kevin Ollivier.

Update focus handling code to match current approaches used by other platforms,
and fix focus handling for corner cases such as when a mouse down pops up a dialog.

https://bugs.webkit.org/show_bug.cgi?id=38086

Location:
trunk/WebKit/wx
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit/wx/ChangeLog

    r57927 r58231  
     12010-04-25  Kevin Watters  <kevinwatters@gmail.com>
     2
     3        Reviewed by Kevin Ollivier.
     4
     5        Update focus handling code to match current approaches used by other platforms,
     6        and fix focus handling for corner cases such as when a mouse down pops up a dialog.
     7       
     8        https://bugs.webkit.org/show_bug.cgi?id=38086
     9
     10        * WebView.cpp:
     11        (wxWebView::Create):
     12        (wxWebView::OnTLWActivated):
     13        (wxWebView::OnPaint):
     14        (wxWebView::OnMouseEvents):
     15        (wxWebView::OnSetFocus):
     16        (wxWebView::OnKillFocus):
     17        * WebView.h:
     18
    1192010-04-20  Adam Barth  <abarth@webkit.org>
    220
  • trunk/WebKit/wx/WebView.cpp

    r56825 r58231  
    341341#endif
    342342
     343    wxWindow* tlw = wxGetTopLevelParent(this);
     344    tlw->Connect(-1, wxEVT_ACTIVATE, wxActivateEventHandler(wxWebView::OnTLWActivated));
     345
    343346    m_isInitialized = true;
    344347
     
    358361    delete m_impl->page;
    359362    m_impl->page = 0;   
     363}
     364
     365void wxWebView::OnTLWActivated(wxActivateEvent& event)
     366{       
     367    if (m_impl && m_impl->page && m_impl->page->focusController())
     368        m_impl->page->focusController()->setActive(event.GetActive());
     369   
     370    event.Skip();
     371   
    360372}
    361373
     
    529541        return;
    530542
    531     // WebView active state is based on TLW active state.
    532     wxTopLevelWindow* tlw = dynamic_cast<wxTopLevelWindow*>(wxGetTopLevelParent(this));
    533     if (tlw && tlw->IsActive())
    534         m_impl->page->focusController()->setActive(true);
    535     else {
    536         m_impl->page->focusController()->setActive(false);
    537     }
    538543    WebCore::Frame* frame = m_mainFrame->GetFrame();
    539544    if (!frame || !frame->view())
     
    621626    }
    622627   
     628    // If an event, such as a right-click event, leads to a focus change (e.g. it
     629    // raises a dialog), WebKit never gets the mouse up event and never relinquishes
     630    // mouse capture. This leads to WebKit handling mouse events, such as modifying
     631    // the selection, while other controls or top level windows have the focus.
     632    // I'm not sure if this is the right place to handle this, but I can't seem to
     633    // find a precedent on how to handle this in other ports.
     634    if (wxWindow::FindFocus() != this) {
     635        while (HasCapture())
     636            ReleaseMouse();
     637
     638        frame->eventHandler()->setMousePressed(false);
     639
     640        return;
     641    }
     642       
    623643    int clickCount = event.ButtonDClick() ? 2 : 1;
    624644
     
    883903void wxWebView::OnSetFocus(wxFocusEvent& event)
    884904{
    885     WebCore::Frame* frame = 0;
    886     if (m_mainFrame)
    887         frame = m_mainFrame->GetFrame();
    888        
    889     if (frame) {
    890         frame->selection()->setFocused(true);
     905    if (m_impl && m_impl->page && m_impl->page->focusController()) {
     906        m_impl->page->focusController()->setFocused(true);
     907        m_impl->page->focusController()->setActive(true);
     908
     909        if (!m_impl->page->focusController()->focusedFrame() && m_mainFrame)
     910            m_impl->page->focusController()->setFocusedFrame(m_mainFrame->GetFrame());
    891911    }
    892 
     912   
    893913    event.Skip();
    894914}
     
    896916void wxWebView::OnKillFocus(wxFocusEvent& event)
    897917{
    898     WebCore::Frame* frame = 0;
    899     if (m_mainFrame)
    900         frame = m_mainFrame->GetFrame();
    901        
    902     if (frame) {
    903         frame->selection()->setFocused(false);
     918    if (m_impl && m_impl->page && m_impl->page->focusController()) {
     919        m_impl->page->focusController()->setFocused(false);
     920
     921        // We also handle active state in OnTLWActivated, but if a user does not
     922        // call event.Skip() in their own EVT_ACTIVATE handler, we won't get those
     923        // callbacks. So we handle active state here as well as a fallback.
     924        wxTopLevelWindow* tlw = dynamic_cast<wxTopLevelWindow*>(wxGetTopLevelParent(this));
     925        if (tlw && tlw->IsActive())
     926            m_impl->page->focusController()->setActive(true);
     927        else
     928            m_impl->page->focusController()->setActive(false);
    904929    }
     930   
     931    while (HasCapture())
     932        ReleaseMouse();
     933   
    905934    event.Skip();
    906935}
  • trunk/WebKit/wx/WebView.h

    r56309 r58231  
    227227    void OnSetFocus(wxFocusEvent& event);
    228228    void OnKillFocus(wxFocusEvent& event);
     229    void OnTLWActivated(wxActivateEvent& event);
    229230   
    230231private:
Note: See TracChangeset for help on using the changeset viewer.