Font-size css specifiers on GTKToggleButton labels cause inaccurate fullscreen rendering

Using gtk_window_fullscreen_on_monitor() I am able to choose which display to launch the fullscreen application into. However, though I am using monitor 1 (5:4), it appears it is using the measurements or ratio of my other display (16:9), with the end result that it does not go fully full screen, as one can see in the below print screen:

, where a portion of the desktop is still visible underneath the application, and some buttons are cut off at the right end.

Any tips to fix this or is it a bug? It appears to be a problem with the labels, specifically their font-size specifier. They also shape the size of the toggle button instead of the other way around.

The system is Debian bookworm.

My current button creation, the sprintf label command is commented out as that messes up the fullscreen rendering:

static void make_toggles (GtkWidget * window) {
    GtkWidget * stop_box;
    GtkWidget * box_row;
    short i; 

    stop_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 10);
    
    //initialise stops on this panel
    char label[32]; label[0] = '\0'; 
    short curr_row = 0;

    box_row = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2);
    gtk_box_append(GTK_BOX(stop_box), box_row);
    for (i = 0; i< rnum; i++) {
        if (curr_row != rstops[i].grid_y) {
            box_row = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2);
            gtk_box_append(GTK_BOX(stop_box), box_row);
            curr_row += 1;
        }
        //sprintf(label, rstops[i].label);
        sprintf(label, "%d", i);
        stop = gtk_toggle_button_new_with_label(label);
        gtk_widget_set_name(stop, "stop_button");
        gtk_widget_set_margin_start(stop, (rstops[i].margin_left * 4) + 5); 
        g_signal_connect(stop, "toggled", G_CALLBACK(stop_toggle), NULL);
        gtk_box_append(GTK_BOX(box_row), stop);   
    }
    
    gtk_widget_set_name(stop_box, "window_main");
    gtk_window_set_child (GTK_WINDOW (window), stop_box);
}

Update: the issue appears to be the font-size: xx-large property that applies to my buttons. I can remove that variable, but then the font is rather small.
A proper fullscreen once font-size is removed:

I would like to use gtk_label_set_wrap() to help the labels fit inside their buttons, but not sure how to extract a GTKLabel from a GTKToggleButton.

EDIT: I figured it out, just create a label and set is as the child of the GTKButton. My final issue is that the text does not center on multi-line labels.

Final EDIT: the centering can be done with gtk_set_justify().

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.