Skip to content

Commit

Permalink
Also focus when clicking on the current tab
Browse files Browse the repository at this point in the history
Fixes issue #71
  • Loading branch information
iamsergio committed Sep 14, 2020
1 parent 5293943 commit 85cb289
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
6 changes: 6 additions & 0 deletions src/private/widgets/TabBarWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ void TabBarWidget::mousePressEvent(QMouseEvent *e)
{
onMousePress(e->pos());
QTabBar::mousePressEvent(e);

if ((Config::self().flags() & Config::Flag_TitleBarIsFocusable) && !frame()->isFocused()) {
// User clicked on a tab which was already focused
// A tab changing also counts as a change of scope
frame()->FocusScope::focus(Qt::MouseFocusReason);
}
}

void TabBarWidget::mouseMoveEvent(QMouseEvent *e)
Expand Down
8 changes: 1 addition & 7 deletions src/private/widgets/TabWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,5 @@ void TabWidget::onTabRemoved()

void TabWidget::onCurrentTabChanged(int index)
{
if (index < 0 || !(Config::self().flags() & Config::Flag_TitleBarIsFocusable) )
return;

// A tab changing also counts as a change of scope
if (!m_frame->isFocused()) {
m_frame->FocusScope::focus(Qt::MouseFocusReason);
}
Q_UNUSED(index);
}
2 changes: 0 additions & 2 deletions tests/tst_docks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5884,9 +5884,7 @@ void TestDocks::tst_titleBarFocusedWhenTabsChange()
QVERIFY(!dock2->titleBar()->isFocused());

Tests::clickOn(globalPos, tabBar);
QEXPECT_FAIL("", "Fix pending", Continue);
QVERIFY(!dock1->titleBar()->isFocused());
QEXPECT_FAIL("", "Fix pending", Continue);
QVERIFY(dock2->titleBar()->isFocused());
}

Expand Down

0 comments on commit 85cb289

Please sign in to comment.