Gtk3: Is it possible to shift the mouse motion area for an arbitrary widget?

24 Views Asked by At

I implemented a GtkCellRenderer to draw an arbitrary Widget in the TreeView cell. Among the other quite basic implementation parts my render()


static void my_cell_renderer_render(GtkCellRenderer *cell, cairo_t *ctx,
        GtkWidget *widget, const GdkRectangle *background_area,
        const GdkRectangle *cell_area, GtkCellRendererState state) {
    GdkRectangle allo;
    gint calc_width = 0;
    gint calc_height = 0;

    cairo_save(ctx);

    if (cell) {
        MyCellRenderer *rc = MY_CELL_RENDERER(cell);
        if (GTK_IS_WIDGET(rc->cell)) {
            gtk_widget_get_size_request(rc->cell, &calc_width, &calc_height);
    
            allo.x = MAX(cell_area->x, 0);
            allo.y = MAX(cell_area->y, 0);
            allo.width = calc_width;
            allo.height = calc_height;

            gtk_widget_size_allocate(rc->cell, &allo);
            cairo_translate(ctx, allo.x, allo.y);
            gtk_widget_draw(rc->cell, ctx);
        }
    }
    cairo_restore(ctx);
}

It perfectly works until I enable headers. With the headers the table looks OK, but the mouseover area is shifted one row up, as if there were no header row. The screenshot below shows that the Item #2,2 button is highlighted by a mouse, located a row above it.

enter image description here

Is there a way to shift the mouse motion area for the item cell widgets?

NB: Would also accept a general purpose answer, adapting it to my case myself.

NBB: yes, I need this for the GtkTreeView+GtkCellRenderer combination, and not GtkGrid.

0

There are 0 best solutions below