From 0f656938d30f6697095d940618f77173d8f9cb33 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Tue, 13 Nov 2012 16:03:19 +0000 Subject: Grab the WebKit.WebView focus on tab closing #4187 When the current tab is closed the next tab is shown (left one if the current tab was the last, othercase right one). After this the WebKit.WebView of the tab displayed grabs the focus to show the OSK if this tab was showing it. So, switching between tabs and closing them respect the OSK status (shown / hidden). Signed-off-by: Manuel Kaufmann Acked-by: Manuel QuiƱones --- diff --git a/browser.py b/browser.py index 8af7a4a..a97e736 100644 --- a/browser.py +++ b/browser.py @@ -258,6 +258,20 @@ class TabbedView(BrowserNotebook): self.add_tab() def __tab_close_cb(self, label, tab_page): + if tab_page.props.browser == self.props.current_browser: + # Current browser was just closed. The next tab of it has + # to take the focus. + current_page_num = self.page_num(tab_page) + + if self.get_n_pages() - 1 == current_page_num: + # This tab was the last. Grab the left one. + page_to_focus = current_page_num - 1 + else: + # This tab was in the middle. Grab the right one. + page_to_focus = current_page_num + 1 + nth_page = self.get_nth_page(page_to_focus) + nth_page.props.browser.grab_focus() + self.remove_page(self.page_num(tab_page)) tab_page.destroy() -- cgit v0.9.1