From 1ea45780dfbb6c88d108ef47ceaad702bce003ff Mon Sep 17 00:00:00 2001 From: Jay Kamat Date: Fri, 21 Sep 2018 00:15:02 -0700 Subject: [PATCH] Only repaint tabs when they are needed --- qutebrowser/mainwindow/tabwidget.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py index 94e88ea71..535732254 100644 --- a/qutebrowser/mainwindow/tabwidget.py +++ b/qutebrowser/mainwindow/tabwidget.py @@ -644,11 +644,15 @@ class TabBar(QTabBar): qtutils.ensure_valid(size) return size - def paintEvent(self, _e): + def paintEvent(self, event): """Override paintEvent to draw the tabs like we want to.""" p = QStylePainter(self) selected = self.currentIndex() for idx in range(self.count()): + if not event.region().intersects(self.tabRect(idx)): + # Don't repaint if we are outside the requested region + continue + tab = QStyleOptionTab() self.initStyleOption(tab, idx) @@ -664,10 +668,6 @@ class TabBar(QTabBar): indicator_color = self.tab_indicator_color(idx) tab.palette.setColor(QPalette.Base, indicator_color) - if tab.rect.right() < 0 or tab.rect.left() > self.width(): - # Don't bother drawing a tab if the entire tab is outside of - # the visible tab bar. - continue p.drawControl(QStyle.CE_TabBarTab, tab) def tabInserted(self, idx):