From 0145cf4349fcd01b8daa93c46703d7a03c4c0a47 Mon Sep 17 00:00:00 2001 From: stippi Date: Tue, 6 Apr 2010 01:24:07 +0000 Subject: [PATCH] Remember the currently focused view within a tab in the user data that can be associated with a BWebView and restore the focus when the tab changes. This fixes a number of annoying issues. git-svn-id: http://svn.haiku-os.org/webpositive/webkit/trunk@391 94f232f2-1747-11df-bad5-a5bfde151594 --- src/apps/webpositive/BrowserWindow.cpp | 28 ++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/apps/webpositive/BrowserWindow.cpp b/src/apps/webpositive/BrowserWindow.cpp index 4b7cdc8c4e..5f96f7fa5c 100644 --- a/src/apps/webpositive/BrowserWindow.cpp +++ b/src/apps/webpositive/BrowserWindow.cpp @@ -236,6 +236,24 @@ public: }; +class PageUserData : public BWebView::UserData { +public: + PageUserData(BView* focusedView) + : + fFocusedView(focusedView) + { + } + + BView* FocusedView() const + { + return fFocusedView; + } + +private: + BView* fFocusedView; +}; + + // #pragma mark - BrowserWindow @@ -1173,7 +1191,17 @@ BrowserWindow::_TabChanged(int32 index) BWebView* webView = dynamic_cast(fTabManager->ViewForTab(index)); if (webView == CurrentWebView()) return; + + CurrentWebView()->SetUserData(new PageUserData(CurrentFocus())); + SetCurrentWebView(webView); + + PageUserData* userData = static_cast(webView->GetUserData()); + if (userData) + userData->FocusedView()->MakeFocus(true); + else + webView->MakeFocus(true); + if (webView) _UpdateTitle(webView->MainFrameTitle()); else