Skip to content

Commit

Permalink
Fix focus box drawing on X11 (partial fix for issue #156)
Browse files Browse the repository at this point in the history
This fixes focus box drawing on X11 for some broken graphics
drivers with line width zero as discussed on issue #156 titled
"Incorrect rendering on Alpine Linux".

This title is not entirely correct. The issue has been observed on
other Linux distros as well if the "modesetting" driver is in effect.

This does not fix rectangle drawing (missing pixels) in general which
is obviously caused by a similar or the same driver issue.
  • Loading branch information
Albrecht Schlosser committed Oct 27, 2021
1 parent 14f8427 commit 4d88fb6
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/drivers/Xlib/Fl_Xlib_Graphics_Driver_rect.cxx
Expand Up @@ -208,16 +208,22 @@ void Fl_Xlib_Graphics_Driver::XDestroyRegion(Fl_Region r) {

// --- line and polygon drawing

void Fl_Xlib_Graphics_Driver::focus_rect(int x, int y, int w, int h)
{
void Fl_Xlib_Graphics_Driver::focus_rect(int x, int y, int w, int h) {
w = this->floor(x + w) - this->floor(x);
h = this->floor(y + h) - this->floor(y);
x = this->floor(x) + floor(offset_x_);
y = this->floor(y) + floor(offset_y_);
if (!clip_rect(x, y, w, h)) {
line_style(FL_DOT);
int lw_save = line_width_; // preserve current line_width
if (line_width_ == 0)
line_style(FL_DOT, 1);
else
line_style(FL_DOT);
XDrawRectangle(fl_display, fl_window, gc_, x, y, w, h);
line_style(FL_SOLID);
if (lw_save == 0)
line_style(FL_SOLID, 0); // restore line type and width
else
line_style(FL_SOLID);
}
}

Expand Down

0 comments on commit 4d88fb6

Please sign in to comment.