Add Fl_Cairo_Graphics_Driver::focus_rect() override

This allows to bypass what looks like a Cairo bug:
FLTK_SCALING_FACTOR=1.7   bin/test/tabs
click on tab2
---> crash

But no crash with other scaling factor values (e.g., 1.8).
This commit is contained in:
ManoloFLTK 2023-03-25 15:31:30 +01:00
parent 9d7e680925
commit 9aa62f4492
2 changed files with 17 additions and 0 deletions

View File

@ -197,6 +197,7 @@ public:
void restore_scale(float) FL_OVERRIDE;
void antialias(int state) FL_OVERRIDE;
int antialias() FL_OVERRIDE;
void focus_rect(int x, int y, int w, int h) FL_OVERRIDE;
};
#endif // FL_CAIRO_GRAPHICS_DRIVER_H

View File

@ -1422,4 +1422,20 @@ int Fl_Cairo_Graphics_Driver::antialias() {
return (cairo_get_antialias(cairo_) != CAIRO_ANTIALIAS_NONE);
}
void Fl_Cairo_Graphics_Driver::focus_rect(int x, int y, int w, int h)
{
cairo_save(cairo_);
cairo_set_line_width(cairo_, 1);
cairo_set_line_cap(cairo_, CAIRO_LINE_CAP_BUTT);
cairo_set_line_join(cairo_, CAIRO_LINE_JOIN_MITER);
static double dots[2] = {1., 1.};
cairo_set_dash(cairo_, dots, 2, 1);
cairo_set_antialias(cairo_, CAIRO_ANTIALIAS_NONE);
cairo_rectangle(cairo_, x, y, w-1, h-1);
cairo_stroke(cairo_);
cairo_restore(cairo_);
surface_needs_commit();
}
#endif // USE_PANGO