'Fix mouse cursor position to adjust for different tab sizes.'

def _fix_cursor(self, from_index, to_index):

    direction = (abs((to_index - from_index)) / (to_index - from_index))
    tab_width = self.dock_tabbar.tabRect(to_index).width()
    tab_x_min = self.dock_tabbar.tabRect(to_index).x()
    tab_x_max = (tab_x_min + tab_width)
    previous_width = self.dock_tabbar.tabRect((to_index - direction)).width()
    delta = (previous_width - tab_width)
    if (delta > 0):
        delta = (delta * direction)
    else:
        delta = 0
    cursor = QCursor()
    pos = self.dock_tabbar.mapFromGlobal(cursor.pos())
    (x, y) = (pos.x(), pos.y())
    if ((x < tab_x_min) or (x > tab_x_max)):
        new_pos = self.dock_tabbar.mapToGlobal(QPoint((x + delta), y))
        cursor.setPos(new_pos)
