FLTK logo

[master] 4d88fb6 - Fix focus box drawing on X11 (partial fix for issue #156)

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.commit  ]
 
Previous Message ]Next Message ]

[master] 4d88fb6 - Fix focus box drawing on X11 (partial fix for issue #156) "Albrecht Schlosser" Oct 27, 2021  
 
commit 4d88fb6fbc4e5a931ad2ae4d0488bfae27629899
Author:     Albrecht Schlosser <albrechts.fltk@online.de>
AuthorDate: Wed Oct 27 21:05:28 2021 +0200
Commit:     Albrecht Schlosser <albrechts.fltk@online.de>
CommitDate: Wed Oct 27 21:05:28 2021 +0200

    Fix focus box drawing on X11 (partial fix for issue #156)
    
    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.

 src/drivers/Xlib/Fl_Xlib_Graphics_Driver_rect.cxx | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git src/drivers/Xlib/Fl_Xlib_Graphics_Driver_rect.cxx src/drivers/Xlib/Fl_Xlib_Graphics_Driver_rect.cxx
index df29a5d..a72fe9d 100644
--- src/drivers/Xlib/Fl_Xlib_Graphics_Driver_rect.cxx
+++ src/drivers/Xlib/Fl_Xlib_Graphics_Driver_rect.cxx
@@ -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);
   }
 }
 
Direct Link to Message ]
 
     
Previous Message ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.