Fix Konqueror's MMB click to close tab option

Review Request #106615 - Created Sept. 27, 2012 and submitted

Information
Dawit Alemayehu
kde-baseapps
origin/KDE/4.9
264058
Reviewers
kde-baseapps
dfaure
The attached patch fixes the bug where clicking on a tab with the MMB while the "Middle-click on a tab to close it" option is checked results in the tab gaining the focus first before being closed instead of being closed in the background. That results in the active tab being changed when a user activates the aforementioned option and clicks on a background tab with the MMB. 

For the record the reason why this really happens is KTabBar's treatment of the MMB clicks when the setMovable is set to TRUE. In addition to emitting a mouseMiddleClick signal which Konqueror currently relies on to close the tab, it also eats the MMB click event and generates a new LMB click event in its place. Apparently that was done for compatibility sake so that the user can move tabs using either the LMB or MMB.  

Anyhow, this patch addresses the problem by installing an event filter to intercept the mouse events from the tabbar and handle MMB clicks on its own when the aforementioned option is checked so that we do not receive unnecessary bogus events.
Check/uncheck the "Middle-click on a tab to close it" option and tested the behavior.

- When the option is unchecked, clicking on a background tab with MMB behaves the same way as it currently does.
- When the option is checked, clicking on a background tab with MMB will immediately close it without changing the current active tab.
David Faure
Dawit Alemayehu
Commit Hook
Dawit Alemayehu
Review request changed

Status: Closed (submitted)

Loading...