@@ -640,29 +640,76 @@ pyset_borders_rects(PyObject *self UNUSED, PyObject *args) {
640640}
641641
642642
643+ static unsigned
644+ vertical_tab_bar_cols (const OSWindow * os_window , long margin_outer , long margin_inner ) {
645+ unsigned cell_width = MAX (1u , os_window -> fonts_data -> fcm .cell_width );
646+ long available_width = (long )os_window -> viewport_width - margin_outer - margin_inner ;
647+ if (available_width <= 0 ) return 0 ;
648+ unsigned available_cols = MAX (1u , (unsigned )available_width / cell_width );
649+ unsigned title_cols = OPT (tab_title_max_length ) > 0 ? (unsigned )OPT (tab_title_max_length ) : 20u ;
650+ unsigned desired_cols = title_cols + 8u ;
651+ unsigned soft_max = available_cols / 3u ;
652+ if (soft_max < 6u ) soft_max = available_cols ;
653+ return MAX (1u , MIN (available_cols , MIN (desired_cols , MAX (1u , soft_max ))));
654+ }
655+
643656void
644657os_window_regions (const OSWindow * os_window , Region * central , Region * tab_bar ) {
645658 if (!OPT (tab_bar_hidden ) && os_window -> num_tabs && !os_window -> has_too_few_tabs ) {
646659 long margin_outer = pt_to_px_for_os_window (OPT (tab_bar_margin_height .outer ), os_window );
647660 long margin_inner = pt_to_px_for_os_window (OPT (tab_bar_margin_height .inner ), os_window );
648661 central -> left = 0 ; central -> right = os_window -> viewport_width ;
649- unsigned tab_bar_height = os_window -> fonts_data -> fcm . cell_height + margin_inner + margin_outer ;
662+ central -> top = 0 ; central -> bottom = os_window -> viewport_height ;
650663 switch (OPT (tab_bar_edge )) {
651- case TOP_EDGE :
664+ case TOP_EDGE : {
665+ unsigned tab_bar_height = os_window -> fonts_data -> fcm .cell_height + margin_inner + margin_outer ;
652666 central -> top = tab_bar_height ;
653667 central -> bottom = os_window -> viewport_height ;
654668 central -> top = MIN (central -> top , central -> bottom );
655669 tab_bar -> top = margin_outer ;
670+ tab_bar -> left = central -> left ; tab_bar -> right = central -> right ;
671+ tab_bar -> bottom = tab_bar -> top + os_window -> fonts_data -> fcm .cell_height ;
672+ break ;
673+ }
674+ case LEFT_EDGE : {
675+ unsigned left_cols = vertical_tab_bar_cols (os_window , margin_outer , margin_inner );
676+ if (!left_cols ) {
677+ zero_at_ptr (tab_bar );
678+ return ;
679+ }
680+ unsigned left_width = left_cols * os_window -> fonts_data -> fcm .cell_width ;
681+ central -> left = MIN ((long )(left_width + margin_inner + margin_outer ), (long )central -> right );
682+ tab_bar -> left = margin_outer ;
683+ tab_bar -> right = tab_bar -> left + left_width ;
684+ tab_bar -> top = central -> top ;
685+ tab_bar -> bottom = central -> bottom ;
656686 break ;
657- default :
687+ }
688+ case RIGHT_EDGE : {
689+ unsigned right_cols = vertical_tab_bar_cols (os_window , margin_outer , margin_inner );
690+ if (!right_cols ) {
691+ zero_at_ptr (tab_bar );
692+ return ;
693+ }
694+ unsigned right_width = right_cols * os_window -> fonts_data -> fcm .cell_width ;
695+ central -> right = MAX (0 , (long )os_window -> viewport_width - (long )(right_width + margin_inner + margin_outer ));
696+ tab_bar -> left = central -> right + margin_inner ;
697+ tab_bar -> right = tab_bar -> left + right_width ;
698+ tab_bar -> top = central -> top ;
699+ tab_bar -> bottom = central -> bottom ;
700+ break ;
701+ }
702+ default : {
703+ unsigned tab_bar_height = os_window -> fonts_data -> fcm .cell_height + margin_inner + margin_outer ;
658704 central -> top = 0 ;
659705 long bottom = os_window -> viewport_height - tab_bar_height ;
660706 central -> bottom = MAX (0 , bottom );
661707 tab_bar -> top = central -> bottom + margin_inner ;
708+ tab_bar -> left = central -> left ; tab_bar -> right = central -> right ;
709+ tab_bar -> bottom = tab_bar -> top + os_window -> fonts_data -> fcm .cell_height ;
662710 break ;
711+ }
663712 }
664- tab_bar -> left = central -> left ; tab_bar -> right = central -> right ;
665- tab_bar -> bottom = tab_bar -> top + os_window -> fonts_data -> fcm .cell_height ;
666713 } else {
667714 zero_at_ptr (tab_bar );
668715 central -> left = 0 ; central -> top = 0 ; central -> right = os_window -> viewport_width ;
0 commit comments