From f6d2ba651bc22b59488ac4be658f0d725296e2fc Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Mon, 27 Nov 2023 10:02:59 +0100 Subject: [PATCH 1/8] Cairo graphics driver: Improve drawing of Fl_Pixmap and Fl_Bitmap --- FL/Fl_Bitmap.H | 2 ++ FL/Fl_Image.H | 2 ++ FL/Fl_Pixmap.H | 2 ++ src/drivers/Cairo/Fl_Cairo_Graphics_Driver.H | 2 +- src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx | 18 ++++++++++++------ 5 files changed, 19 insertions(+), 7 deletions(-) diff --git a/FL/Fl_Bitmap.H b/FL/Fl_Bitmap.H index 7fde10f5b..677af7db4 100644 --- a/FL/Fl_Bitmap.H +++ b/FL/Fl_Bitmap.H @@ -61,6 +61,8 @@ public: void label(Fl_Widget*w) FL_OVERRIDE; void label(Fl_Menu_Item*m) FL_OVERRIDE; void uncache() FL_OVERRIDE; + int cache_w() {return cache_w_;} + int cache_h() {return cache_h_;} }; #endif diff --git a/FL/Fl_Image.H b/FL/Fl_Image.H index eb7aef3c6..a8f514f36 100644 --- a/FL/Fl_Image.H +++ b/FL/Fl_Image.H @@ -369,6 +369,8 @@ public: void label(Fl_Widget*w) FL_OVERRIDE; void label(Fl_Menu_Item*m) FL_OVERRIDE; void uncache() FL_OVERRIDE; + int cache_w() {return cache_w_;} + int cache_h() {return cache_h_;} /** Sets the maximum allowed image size in bytes when creating an Fl_RGB_Image object. The image size in bytes of an Fl_RGB_Image object is the value of the product w() * h() * d(). diff --git a/FL/Fl_Pixmap.H b/FL/Fl_Pixmap.H index ddf996fba..0efdb84c7 100644 --- a/FL/Fl_Pixmap.H +++ b/FL/Fl_Pixmap.H @@ -72,6 +72,8 @@ public: void label(Fl_Widget*w) FL_OVERRIDE; void label(Fl_Menu_Item*m) FL_OVERRIDE; void uncache() FL_OVERRIDE; + int cache_w() {return cache_w_;} + int cache_h() {return cache_h_;} }; #endif diff --git a/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.H b/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.H index b965e0afa..8677a920f 100644 --- a/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.H +++ b/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.H @@ -153,7 +153,7 @@ public: void ps_translate(int, int); void ps_untranslate(); - void draw_cached_pattern_(Fl_Image *img, cairo_pattern_t *pat, int X, int Y, int W, int H, int cx, int cy); + void draw_cached_pattern_(Fl_Image *img, cairo_pattern_t *pat, int X, int Y, int W, int H, int cx, int cy, int cache_w, int cache_h); void draw_image(const uchar *data, int ix, int iy, int iw, int ih, int D, int LD) FL_OVERRIDE; void draw_rgb(Fl_RGB_Image *rgb,int XP, int YP, int WP, int HP, int cx, int cy) FL_OVERRIDE; void cache(Fl_RGB_Image *rgb) FL_OVERRIDE; diff --git a/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx b/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx index be189f7bf..3f80cbd89 100644 --- a/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx +++ b/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx @@ -783,7 +783,7 @@ void Fl_Cairo_Graphics_Driver::overlay_rect(int x, int y, int w , int h) { } -void Fl_Cairo_Graphics_Driver::draw_cached_pattern_(Fl_Image *img, cairo_pattern_t *pat, int X, int Y, int W, int H, int cx, int cy) { +void Fl_Cairo_Graphics_Driver::draw_cached_pattern_(Fl_Image *img, cairo_pattern_t *pat, int X, int Y, int W, int H, int cx, int cy, int cache_w, int cache_h) { // compute size of output image in drawing units cairo_matrix_t matrix; cairo_get_matrix(cairo_, &matrix); @@ -794,7 +794,7 @@ void Fl_Cairo_Graphics_Driver::draw_cached_pattern_(Fl_Image *img, cairo_pattern int Hs = Fl_Scalable_Graphics_Driver::floor(Y - cy + img->h(), s) - Ys; if (Ws == 0 || Hs == 0) return; cairo_save(cairo_); - bool need_extend = (img->data_w() != Ws || img->data_h() != Hs || (W >= 2 && H >= 2)); + bool need_extend = (cache_w != Ws || cache_h != Hs || (W >= 2 && H >= 2)); if (need_extend || cx || cy || W < img->w() || H < img->h()) { // clip when necessary cairo_rectangle(cairo_, X - 0.5, Y - 0.5, W + 0.5, H + 0.5); cairo_clip(cairo_); @@ -809,7 +809,7 @@ void Fl_Cairo_Graphics_Driver::draw_cached_pattern_(Fl_Image *img, cairo_pattern CAIRO_FILTER_GOOD : CAIRO_FILTER_FAST); cairo_pattern_set_extend(pat, CAIRO_EXTEND_PAD); } - cairo_matrix_init_scale(&matrix, double(img->data_w())/Ws, double(img->data_h())/Hs); + cairo_matrix_init_scale(&matrix, double(cache_w)/Ws, double(cache_h)/Hs); cairo_matrix_translate(&matrix, -Xs , -Ys ); cairo_pattern_set_matrix(pat, &matrix); if (img->d() > 1) cairo_paint(cairo_); @@ -834,7 +834,7 @@ void Fl_Cairo_Graphics_Driver::draw_rgb(Fl_RGB_Image *rgb,int XP, int YP, int WP cache(rgb); pat = (cairo_pattern_t*)*Fl_Graphics_Driver::id(rgb); } - draw_cached_pattern_(rgb, pat, X, Y, W, H, cx, cy); + draw_cached_pattern_(rgb, pat, X, Y, W, H, cx, cy, rgb->cache_w(), rgb->cache_h()); } @@ -927,7 +927,10 @@ void Fl_Cairo_Graphics_Driver::draw_fixed(Fl_Bitmap *bm,int XP, int YP, int WP, } else { pat = (cairo_pattern_t*)*Fl_Graphics_Driver::id(bm); color(color()); - draw_cached_pattern_(bm, pat, XP, YP, WP, HP, cx, cy); + int old_w = bm->w(), old_h = bm->h(); + bm->scale(bm->cache_w(), bm->cache_h(), 0, 1); // transiently + draw_cached_pattern_(bm, pat, XP, YP, WP, HP, cx, cy, bm->cache_w(), bm->cache_h()); + bm->scale(old_w, old_h, 0, 1); // back } cairo_set_matrix(cairo_, &matrix); } @@ -1013,7 +1016,10 @@ void Fl_Cairo_Graphics_Driver::draw_fixed(Fl_Pixmap *pxm,int XP, int YP, int WP, Fl_Graphics_Driver::draw_empty(pxm, XP, YP); } else { pat = (cairo_pattern_t*)*Fl_Graphics_Driver::id(pxm); - draw_cached_pattern_(pxm, pat, XP, YP, WP, HP, cx, cy); + int old_w = pxm->w(), old_h = pxm->h(); + pxm->scale(pxm->cache_w(), pxm->cache_h(), 0, 1); // transiently + draw_cached_pattern_(pxm, pat, XP, YP, WP, HP, cx, cy, pxm->cache_w(), pxm->cache_h()); + pxm->scale(old_w, old_h, 0, 1); // back } cairo_set_matrix(cairo_, &matrix); } From 6ea31316fb64f64d346dc4a3a30984048f5df4cd Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Mon, 27 Nov 2023 12:15:21 +0100 Subject: [PATCH 2/8] Cairo graphics driver: Improve drawing of Fl_Pixmap and Fl_Bitmap --- src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx b/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx index 3f80cbd89..1de6822e1 100644 --- a/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx +++ b/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx @@ -805,8 +805,9 @@ void Fl_Cairo_Graphics_Driver::draw_cached_pattern_(Fl_Image *img, cairo_pattern cairo_set_matrix(cairo_, &matrix); if (img->d() >= 1) cairo_set_source(cairo_, pat); if (need_extend) { - cairo_pattern_set_filter(pat, Fl_RGB_Image::scaling_algorithm() == FL_RGB_SCALING_BILINEAR ? - CAIRO_FILTER_GOOD : CAIRO_FILTER_FAST); + bool condition = Fl_RGB_Image::scaling_algorithm() == FL_RGB_SCALING_BILINEAR && + (fabs(Ws/float(cache_w) - 1) > 0.02 || fabs(Hs/float(cache_h) - 1) > 0.02); + cairo_pattern_set_filter(pat, condition ? CAIRO_FILTER_GOOD : CAIRO_FILTER_FAST); cairo_pattern_set_extend(pat, CAIRO_EXTEND_PAD); } cairo_matrix_init_scale(&matrix, double(cache_w)/Ws, double(cache_h)/Hs); From 57371365d8933542ebe7c78651f621e1273733cf Mon Sep 17 00:00:00 2001 From: Albrecht Schlosser Date: Mon, 27 Nov 2023 15:33:53 +0100 Subject: [PATCH 3/8] Fix compiler warning, dependencies, and trailing whitespace MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The benign warning was: ‘Fl_Browser_::hscrollbar’ will be initialized after [-Wreorder] ‘int Fl_Browser_::linespacing_’ ... --- FL/Fl_Text_Display.H | 2 +- fluid/factory.cxx | 2 +- fluid/makedepend | 18 +++++++++--------- fluid/sourceview_panel.cxx | 2 +- fluid/template_panel.cxx | 2 +- fluid/template_panel.fl | 2 +- src/Fl_Browser_.cxx | 4 ++-- src/Fl_Tile.cxx | 6 +++--- src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx | 4 ++-- src/makedepend | 4 ++++ test/makedepend | 15 +++++++++++++++ 11 files changed, 40 insertions(+), 21 deletions(-) diff --git a/FL/Fl_Text_Display.H b/FL/Fl_Text_Display.H index 2d2d2d565..c736db1e0 100644 --- a/FL/Fl_Text_Display.H +++ b/FL/Fl_Text_Display.H @@ -498,7 +498,7 @@ protected: int leftClip, int rightClip) const; int handle_rmb(int readonly); - + void draw_line_numbers(bool clearAll); void clear_rect(int style, int x, int y, int width, int height) const; diff --git a/fluid/factory.cxx b/fluid/factory.cxx index 3a433748d..a60717e30 100644 --- a/fluid/factory.cxx +++ b/fluid/factory.cxx @@ -868,7 +868,7 @@ public: int tsize_; Fl_Color tcolor_; Fl_Batchmode_Terminal(int x, int y, int w, int h, const char *l=NULL) - : Fl_Group(x, y, w, h, l) + : Fl_Group(x, y, w, h, l) { // set the defaults that Fl_Terminal would set box(FL_DOWN_BOX); color(FL_FOREGROUND_COLOR); diff --git a/fluid/makedepend b/fluid/makedepend index 6eedbd947..88d7b722b 100644 --- a/fluid/makedepend +++ b/fluid/makedepend @@ -74,11 +74,11 @@ alignment_panel.o: ../FL/Fl_Scheme.H alignment_panel.o: ../FL/Fl_Scheme_Choice.H alignment_panel.o: ../FL/Fl_Scrollbar.H alignment_panel.o: ../FL/Fl_Shortcut_Button.H -alignment_panel.o: ../FL/Fl_Simple_Terminal.H alignment_panel.o: ../FL/Fl_Slider.H alignment_panel.o: ../FL/Fl_Spinner.H alignment_panel.o: ../FL/fl_string_functions.h alignment_panel.o: ../FL/Fl_Tabs.H +alignment_panel.o: ../FL/Fl_Terminal.H alignment_panel.o: ../FL/Fl_Text_Buffer.H alignment_panel.o: ../FL/Fl_Text_Display.H alignment_panel.o: ../FL/Fl_Text_Editor.H @@ -363,10 +363,10 @@ factory.o: ../FL/Fl_Repeat_Button.H factory.o: ../FL/Fl_RGB_Image.H factory.o: ../FL/Fl_Roller.H factory.o: ../FL/Fl_Scrollbar.H -factory.o: ../FL/Fl_Simple_Terminal.H factory.o: ../FL/Fl_Slider.H factory.o: ../FL/Fl_Spinner.H factory.o: ../FL/Fl_Tabs.H +factory.o: ../FL/Fl_Terminal.H factory.o: ../FL/Fl_Text_Buffer.H factory.o: ../FL/Fl_Text_Display.H factory.o: ../FL/Fl_Text_Editor.H @@ -448,11 +448,11 @@ Fd_Snap_Action.o: ../FL/Fl_Scheme.H Fd_Snap_Action.o: ../FL/Fl_Scheme_Choice.H Fd_Snap_Action.o: ../FL/Fl_Scrollbar.H Fd_Snap_Action.o: ../FL/Fl_Shortcut_Button.H -Fd_Snap_Action.o: ../FL/Fl_Simple_Terminal.H Fd_Snap_Action.o: ../FL/Fl_Slider.H Fd_Snap_Action.o: ../FL/Fl_Spinner.H Fd_Snap_Action.o: ../FL/fl_string_functions.h Fd_Snap_Action.o: ../FL/Fl_Tabs.H +Fd_Snap_Action.o: ../FL/Fl_Terminal.H Fd_Snap_Action.o: ../FL/Fl_Text_Buffer.H Fd_Snap_Action.o: ../FL/Fl_Text_Display.H Fd_Snap_Action.o: ../FL/Fl_Text_Editor.H @@ -530,11 +530,11 @@ file.o: ../FL/Fl_Scheme_Choice.H file.o: ../FL/Fl_Scrollbar.H file.o: ../FL/Fl_Shared_Image.H file.o: ../FL/Fl_Shortcut_Button.H -file.o: ../FL/Fl_Simple_Terminal.H file.o: ../FL/Fl_Slider.H file.o: ../FL/Fl_Spinner.H file.o: ../FL/fl_string_functions.h file.o: ../FL/Fl_Tabs.H +file.o: ../FL/Fl_Terminal.H file.o: ../FL/Fl_Text_Buffer.H file.o: ../FL/Fl_Text_Display.H file.o: ../FL/Fl_Text_Editor.H @@ -623,11 +623,11 @@ fluid.o: ../FL/Fl_Scheme_Choice.H fluid.o: ../FL/Fl_Scrollbar.H fluid.o: ../FL/Fl_Shared_Image.H fluid.o: ../FL/Fl_Shortcut_Button.H -fluid.o: ../FL/Fl_Simple_Terminal.H fluid.o: ../FL/Fl_Slider.H fluid.o: ../FL/Fl_Spinner.H fluid.o: ../FL/fl_string_functions.h fluid.o: ../FL/Fl_Tabs.H +fluid.o: ../FL/Fl_Terminal.H fluid.o: ../FL/Fl_Text_Buffer.H fluid.o: ../FL/Fl_Text_Display.H fluid.o: ../FL/Fl_Text_Editor.H @@ -869,6 +869,7 @@ Fl_Function_Type.o: Fl_Window_Type.h Fl_Function_Type.o: function_panel.h Fl_Function_Type.o: mergeback.h Fl_Function_Type.o: StyleParse.h +Fl_Function_Type.o: undo.h Fl_Function_Type.o: widget_browser.h Fl_Grid_Type.o: ../config.h Fl_Grid_Type.o: ../FL/Enumerations.H @@ -1149,12 +1150,12 @@ Fl_Widget_Type.o: ../FL/Fl_Scrollbar.H Fl_Widget_Type.o: ../FL/Fl_Shared_Image.H Fl_Widget_Type.o: ../FL/Fl_Shortcut_Button.H Fl_Widget_Type.o: ../FL/fl_show_colormap.H -Fl_Widget_Type.o: ../FL/Fl_Simple_Terminal.H Fl_Widget_Type.o: ../FL/Fl_Slider.H Fl_Widget_Type.o: ../FL/Fl_Spinner.H Fl_Widget_Type.o: ../FL/fl_string_functions.h Fl_Widget_Type.o: ../FL/Fl_Table.H Fl_Widget_Type.o: ../FL/Fl_Tabs.H +Fl_Widget_Type.o: ../FL/Fl_Terminal.H Fl_Widget_Type.o: ../FL/Fl_Text_Buffer.H Fl_Widget_Type.o: ../FL/Fl_Text_Display.H Fl_Widget_Type.o: ../FL/Fl_Text_Editor.H @@ -1247,11 +1248,11 @@ Fl_Window_Type.o: ../FL/Fl_Scheme_Choice.H Fl_Window_Type.o: ../FL/Fl_Scrollbar.H Fl_Window_Type.o: ../FL/Fl_Shared_Image.H Fl_Window_Type.o: ../FL/Fl_Shortcut_Button.H -Fl_Window_Type.o: ../FL/Fl_Simple_Terminal.H Fl_Window_Type.o: ../FL/Fl_Slider.H Fl_Window_Type.o: ../FL/Fl_Spinner.H Fl_Window_Type.o: ../FL/fl_string_functions.h Fl_Window_Type.o: ../FL/Fl_Tabs.H +Fl_Window_Type.o: ../FL/Fl_Terminal.H Fl_Window_Type.o: ../FL/Fl_Text_Buffer.H Fl_Window_Type.o: ../FL/Fl_Text_Display.H Fl_Window_Type.o: ../FL/Fl_Text_Editor.H @@ -1299,7 +1300,6 @@ function_panel.o: ../FL/Fl_Browser_.H function_panel.o: ../FL/Fl_Button.H function_panel.o: ../FL/Fl_Cairo.H function_panel.o: ../FL/fl_casts.H -function_panel.o: ../FL/Fl_Check_Button.H function_panel.o: ../FL/Fl_Choice.H function_panel.o: ../FL/fl_config.h function_panel.o: ../FL/Fl_Device.H @@ -1478,11 +1478,11 @@ shell_command.o: ../FL/Fl_Scheme.H shell_command.o: ../FL/Fl_Scheme_Choice.H shell_command.o: ../FL/Fl_Scrollbar.H shell_command.o: ../FL/Fl_Shortcut_Button.H -shell_command.o: ../FL/Fl_Simple_Terminal.H shell_command.o: ../FL/Fl_Slider.H shell_command.o: ../FL/Fl_Spinner.H shell_command.o: ../FL/fl_string_functions.h shell_command.o: ../FL/Fl_Tabs.H +shell_command.o: ../FL/Fl_Terminal.H shell_command.o: ../FL/Fl_Text_Buffer.H shell_command.o: ../FL/Fl_Text_Display.H shell_command.o: ../FL/Fl_Text_Editor.H diff --git a/fluid/sourceview_panel.cxx b/fluid/sourceview_panel.cxx index b32f01498..0b7c52306 100644 --- a/fluid/sourceview_panel.cxx +++ b/fluid/sourceview_panel.cxx @@ -32,7 +32,7 @@ extern void reveal_in_browser(Fl_Type *t); /** Update the header and source code highlighting depending on the currently selected object - + The Source View system offers an immediate preview of the code files that will be generated by FLUID. It also marks the code generated for the last selected item in the header and the source diff --git a/fluid/template_panel.cxx b/fluid/template_panel.cxx index 0911deb7e..33f2cabea 100644 --- a/fluid/template_panel.cxx +++ b/fluid/template_panel.cxx @@ -307,7 +307,7 @@ void template_load() { "er\n}\n", f); fclose(f); } - + template_install(path, "/FLTK_License.fl", tmpl_FLTK_License_fl, sizeof(tmpl_FLTK_License_fl), tmpl_FLTK_License_fl_size); template_install(path, "/1of7GUIs.fl", tmpl_1of7GUIs_fl, sizeof(tmpl_1of7GUIs_fl), tmpl_1of7GUIs_fl_size); sample_templates_generated = 2; diff --git a/fluid/template_panel.fl b/fluid/template_panel.fl index 2a98219b0..790702edc 100644 --- a/fluid/template_panel.fl +++ b/fluid/template_panel.fl @@ -265,7 +265,7 @@ if (sample_templates_generated < 2) { "er\\n}\\n", f); fclose(f); } - + template_install(path, "/FLTK_License.fl", tmpl_FLTK_License_fl, sizeof(tmpl_FLTK_License_fl), tmpl_FLTK_License_fl_size); template_install(path, "/1of7GUIs.fl", tmpl_1of7GUIs_fl, sizeof(tmpl_1of7GUIs_fl), tmpl_1of7GUIs_fl_size); sample_templates_generated = 2; diff --git a/src/Fl_Browser_.cxx b/src/Fl_Browser_.cxx index b05772aea..56b751415 100644 --- a/src/Fl_Browser_.cxx +++ b/src/Fl_Browser_.cxx @@ -953,9 +953,9 @@ J1: */ Fl_Browser_::Fl_Browser_(int X, int Y, int W, int H, const char* L) : Fl_Group(X, Y, W, H, L), + linespacing_(0), scrollbar(0, 0, 0, 0, 0), // they will be resized by draw() - hscrollbar(0, 0, 0, 0, 0), - linespacing_(0) + hscrollbar(0, 0, 0, 0, 0) { box(FL_NO_BOX); align(FL_ALIGN_BOTTOM); diff --git a/src/Fl_Tile.cxx b/src/Fl_Tile.cxx index e1e2d85cc..c37f2da89 100644 --- a/src/Fl_Tile.cxx +++ b/src/Fl_Tile.cxx @@ -56,7 +56,7 @@ In this mode, the child that is marked resizable() will behave as it would in a regular Fl_Group widget. When dragging edges or intersections with the mouse, Fl_Tile will ensure that - none of the children shrinks to a size that is smaller than requested. + none of the children shrinks to a size that is smaller than requested. When resizing the Fl_Tile group, size ranges are not enforced by the tile. Instead, the size range of the enclosing window should be limited to a valid range. @@ -155,7 +155,7 @@ static Fl_Cursor Fl_Tile_cursors[4] = { static int fl_min(int a, int b) { return ab ? a : b; } -/** +/** Request for children to change their layout. drag_intersection requests that all children with the left edge at old_l to @@ -695,7 +695,7 @@ int Fl_Tile::handle(int event) { // if (damage()) return 1; // don't fall behind case FL_RELEASE: { if (!sdrag) break; - Fl_Widget* r = resizable(); + Fl_Widget* r = resizable(); if (size_range_ || !r) r = this; int newx; if (sdrag&DRAGH) { diff --git a/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx b/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx index 1de6822e1..cda328c17 100644 --- a/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx +++ b/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx @@ -910,7 +910,7 @@ void Fl_Cairo_Graphics_Driver::uncache(Fl_RGB_Image *img, fl_uintptr_t &id_, fl_ } -void Fl_Cairo_Graphics_Driver::draw_fixed(Fl_Bitmap *bm,int XP, int YP, int WP, int HP, +void Fl_Cairo_Graphics_Driver::draw_fixed(Fl_Bitmap *bm,int XP, int YP, int WP, int HP, int cx, int cy) { cairo_pattern_t *pat = NULL; float s = wld_scale * scale(); @@ -999,7 +999,7 @@ void Fl_Cairo_Graphics_Driver::cache(Fl_Bitmap *bm) { } -void Fl_Cairo_Graphics_Driver::draw_fixed(Fl_Pixmap *pxm,int XP, int YP, int WP, int HP, +void Fl_Cairo_Graphics_Driver::draw_fixed(Fl_Pixmap *pxm,int XP, int YP, int WP, int HP, int cx, int cy) { cairo_pattern_t *pat = NULL; float s = wld_scale * scale(); diff --git a/src/makedepend b/src/makedepend index 0199f9d96..a7cf18d19 100644 --- a/src/makedepend +++ b/src/makedepend @@ -2439,6 +2439,7 @@ Fl_Input.o: ../FL/Fl_Image.H Fl_Input.o: ../FL/Fl_Input.H Fl_Input.o: ../FL/Fl_Input_.H Fl_Input.o: ../FL/Fl_Int_Input.H +Fl_Input.o: ../FL/Fl_Menu_Item.H Fl_Input.o: ../FL/Fl_Multiline_Input.H Fl_Input.o: ../FL/Fl_Multiline_Output.H Fl_Input.o: ../FL/Fl_Output.H @@ -3929,6 +3930,9 @@ Fl_Text_Display.o: ../FL/Fl_Export.H Fl_Text_Display.o: ../FL/Fl_Graphics_Driver.H Fl_Text_Display.o: ../FL/Fl_Group.H Fl_Text_Display.o: ../FL/Fl_Image.H +Fl_Text_Display.o: ../FL/Fl_Input.H +Fl_Text_Display.o: ../FL/Fl_Input_.H +Fl_Text_Display.o: ../FL/Fl_Menu_Item.H Fl_Text_Display.o: ../FL/Fl_Pixmap.H Fl_Text_Display.o: ../FL/Fl_Plugin.H Fl_Text_Display.o: ../FL/Fl_Preferences.H diff --git a/test/makedepend b/test/makedepend index 2a0a8da55..73ac5d0db 100644 --- a/test/makedepend +++ b/test/makedepend @@ -3149,3 +3149,18 @@ windowfocus.o: ../FL/fl_utf8.h windowfocus.o: ../FL/Fl_Widget.H windowfocus.o: ../FL/Fl_Window.H windowfocus.o: ../FL/platform_types.h +wizard.o: ../FL/Enumerations.H +wizard.o: ../FL/Fl.H +wizard.o: ../FL/fl_attr.h +wizard.o: ../FL/Fl_Button.H +wizard.o: ../FL/Fl_Cairo.H +wizard.o: ../FL/fl_casts.H +wizard.o: ../FL/fl_config.h +wizard.o: ../FL/Fl_Export.H +wizard.o: ../FL/Fl_Group.H +wizard.o: ../FL/fl_types.h +wizard.o: ../FL/fl_utf8.h +wizard.o: ../FL/Fl_Widget.H +wizard.o: ../FL/Fl_Window.H +wizard.o: ../FL/Fl_Wizard.H +wizard.o: ../FL/platform_types.h From 12af9dad3e004de7fc5ff7da358377ae29ee1f68 Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Tue, 28 Nov 2023 09:06:17 +0100 Subject: [PATCH 4/8] Remove PostScript graphics driver code redundant with Cairo driver --- .../Fl_PostScript_Graphics_Driver.H | 7 +- .../PostScript/Fl_PostScript_image.cxx | 116 +----------------- 2 files changed, 3 insertions(+), 120 deletions(-) diff --git a/src/drivers/PostScript/Fl_PostScript_Graphics_Driver.H b/src/drivers/PostScript/Fl_PostScript_Graphics_Driver.H index fef8ded71..0c0ec1aaf 100644 --- a/src/drivers/PostScript/Fl_PostScript_Graphics_Driver.H +++ b/src/drivers/PostScript/Fl_PostScript_Graphics_Driver.H @@ -1,7 +1,7 @@ // // Support for graphics output to PostScript file for the Fast Light Tool Kit (FLTK). // -// Copyright 2010-2022 by Bill Spitzak and others. +// Copyright 2010-2023 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -80,11 +80,6 @@ public: int not_clipped(int x, int y, int w, int h) FL_OVERRIDE; int clip_box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H) FL_OVERRIDE; virtual int has_feature(driver_feature feature_mask) FL_OVERRIDE { return feature_mask & PRINTER; } - // draw image classes without caching them - void draw_rgb_bitmap_(Fl_Image *img,int XP, int YP, int WP, int HP, int cx, int cy); - void draw_pixmap(Fl_Pixmap * pxm,int XP, int YP, int WP, int HP, int cx, int cy) FL_OVERRIDE; - void draw_bitmap(Fl_Bitmap * bitmap,int XP, int YP, int WP, int HP, int cx, int cy) FL_OVERRIDE; - void draw_rgb(Fl_RGB_Image * rgb,int XP, int YP, int WP, int HP, int cx, int cy) FL_OVERRIDE; }; #else // ! USE_PANGO diff --git a/src/drivers/PostScript/Fl_PostScript_image.cxx b/src/drivers/PostScript/Fl_PostScript_image.cxx index 64f9972bf..0ae56609a 100644 --- a/src/drivers/PostScript/Fl_PostScript_image.cxx +++ b/src/drivers/PostScript/Fl_PostScript_image.cxx @@ -1,7 +1,7 @@ // // Postscript image drawing implementation for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2022 by Bill Spitzak and others. +// Copyright 1998-2023 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -68,119 +68,7 @@ void Fl_PostScript_Graphics_Driver::draw_image(const uchar *data, int ix, int iy draw_image(draw_image_cb, &cb_data, ix, iy, iw, ih, abs(D)); } -#if USE_PANGO - -static void destroy_BGRA(void *data) { - delete[] (uchar*)data; -} - - -void Fl_PostScript_Graphics_Driver::draw_pixmap(Fl_Pixmap *pxm,int XP, int YP, int WP, int HP, int cx, int cy) { - Fl_RGB_Image *rgb = new Fl_RGB_Image(pxm); - draw_rgb_bitmap_(rgb, XP, YP, WP, HP, cx, cy); - delete rgb; -} - - -void Fl_PostScript_Graphics_Driver::draw_rgb(Fl_RGB_Image *rgb,int XP, int YP, int WP, int HP, int cx, int cy) { - draw_rgb_bitmap_(rgb, XP, YP, WP, HP, cx, cy); -} - - -void Fl_PostScript_Graphics_Driver::draw_bitmap(Fl_Bitmap *bitmap,int XP, int YP, int WP, int HP, int cx, int cy) { - draw_rgb_bitmap_(bitmap, XP, YP, WP, HP, cx, cy); -} - - -void Fl_PostScript_Graphics_Driver::draw_rgb_bitmap_(Fl_Image *img,int XP, int YP, int WP, int HP, int cx, int cy) -{ - cairo_surface_t *surf; - cairo_format_t format = (img->d() >= 1 ? CAIRO_FORMAT_ARGB32 : CAIRO_FORMAT_A1); - int stride = cairo_format_stride_for_width(format, img->data_w()); - uchar *BGRA = new uchar[stride * img->data_h()]; - memset(BGRA, 0, stride * img->data_h()); - if (img->d() >= 1) { // process Fl_RGB_Image of all depths - Fl_RGB_Image *rgb = (Fl_RGB_Image*)img; - int lrgb = rgb->ld() ? rgb->ld() : rgb->data_w() * rgb->d(); - uchar A = 0xff, R,G,B, *q; - const uchar *r; - float f = 1; - if (rgb->d() >= 3) { // color images - for (int j = 0; j < rgb->data_h(); j++) { - r = rgb->array + j * lrgb; - q = BGRA + j * stride; - for (int i = 0; i < rgb->data_w(); i++) { - R = *r; - G = *(r+1); - B = *(r+2); - if (rgb->d() == 4) { - A = *(r+3); - f = float(A)/0xff; - } - *q = B * f; - *(q+1) = G * f; - *(q+2) = R * f; - *(q+3) = A; - r += rgb->d(); q += 4; - } - } - } else if (rgb->d() == 1 || rgb->d() == 2) { // B&W - for (int j = 0; j < rgb->data_h(); j++) { - r = rgb->array + j * lrgb; - q = BGRA + j * stride; - for (int i = 0; i < rgb->data_w(); i++) { - G = *r; - if (rgb->d() == 2) { - A = *(r+1); - f = float(A)/0xff; - } - *(q) = G * f; - *(q+1) = G * f; - *(q+2) = G * f; - *(q+3) = A; - r += rgb->d(); q += 4; - } - } - } - } else { - Fl_Bitmap *bm = (Fl_Bitmap*)img; - uchar *r, p; - unsigned *q; - for (int j = 0; j < bm->data_h(); j++) { - r = (uchar*)bm->array + j * ((bm->data_w() + 7)/8); - q = (unsigned*)(BGRA + j * stride); - unsigned k = 0, mask32 = 1; - p = *r; - for (int i = 0; i < bm->data_w(); i++) { - if (p&1) (*q) |= mask32; - k++; - if (k % 8 != 0) p >>= 1; else p = *(++r); - if (k % 32 != 0) mask32 <<= 1; else {q++; mask32 = 1;} - } - } - } - surf = cairo_image_surface_create_for_data(BGRA, format, img->data_w(), img->data_h(), stride); - if (cairo_surface_status(surf) == CAIRO_STATUS_SUCCESS) { - static cairo_user_data_key_t key = {}; - (void)cairo_surface_set_user_data(surf, &key, BGRA, destroy_BGRA); - cairo_pattern_t *pat = cairo_pattern_create_for_surface(surf); - cairo_save(cairo_); - cairo_rectangle(cairo_, XP-0.5, YP-0.5, WP+1, HP+1); - cairo_clip(cairo_); - if (img->d() >= 1) cairo_set_source(cairo_, pat); - cairo_matrix_t matrix; - cairo_matrix_init_scale(&matrix, double(img->data_w())/(img->w()+1), double(img->data_h())/(img->h()+1)); - cairo_matrix_translate(&matrix, -XP+0.5+cx, -YP+0.5+cy); - cairo_pattern_set_matrix(pat, &matrix); - cairo_mask(cairo_, pat); - cairo_pattern_destroy(pat); - cairo_surface_destroy(surf); - cairo_restore(cairo_); - check_status(); - } -} - -#else // USE_PANGO +#if ! USE_PANGO // // Implementation of the /ASCII85Encode PostScript filter From 59bdb455668a896d9989f08446e24313f5de48d6 Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Tue, 28 Nov 2023 15:05:58 +0100 Subject: [PATCH 5/8] Rearrange PostScript graphics driver code redundant with Cairo driver --- src/drivers/PostScript/Fl_PostScript.cxx | 9 +- .../Fl_PostScript_Graphics_Driver.H | 8 +- .../PostScript/Fl_PostScript_image.cxx | 118 +++++++++++++++++- 3 files changed, 128 insertions(+), 7 deletions(-) diff --git a/src/drivers/PostScript/Fl_PostScript.cxx b/src/drivers/PostScript/Fl_PostScript.cxx index 4ce3f67b9..f5d8f8f11 100644 --- a/src/drivers/PostScript/Fl_PostScript.cxx +++ b/src/drivers/PostScript/Fl_PostScript.cxx @@ -145,12 +145,11 @@ Fl_PostScript_Graphics_Driver::Fl_PostScript_Graphics_Driver(void) //lang_level_ = 3; lang_level_ = 2; mask = 0; -#endif - ps_filename_ = NULL; - scale_x = scale_y = 1.; bg_r = bg_g = bg_b = 255; clip_ = NULL; - what = NONE; + scale_x = scale_y = 1.; +#endif + ps_filename_ = NULL; } /** \brief The destructor. */ @@ -1750,9 +1749,9 @@ Fl_EPS_File_Surface::Fl_EPS_File_Surface(int width, int height, FILE *eps, Fl_Co if (s != 1) { ps->clocale_printf("GR GR GS %f %f SC GS\n", s, s); } + Fl::get_color(background, ps->bg_r, ps->bg_g, ps->bg_b); #endif ps->scale_x = ps->scale_y = s; - Fl::get_color(background, ps->bg_r, ps->bg_g, ps->bg_b); } } diff --git a/src/drivers/PostScript/Fl_PostScript_Graphics_Driver.H b/src/drivers/PostScript/Fl_PostScript_Graphics_Driver.H index 0c0ec1aaf..904644f42 100644 --- a/src/drivers/PostScript/Fl_PostScript_Graphics_Driver.H +++ b/src/drivers/PostScript/Fl_PostScript_Graphics_Driver.H @@ -49,7 +49,6 @@ public: char *ps_filename_; int nPages; double pw_, ph_; - uchar bg_r, bg_g, bg_b; Fl_PostScript_Graphics_Driver(); ~Fl_PostScript_Graphics_Driver(); @@ -80,6 +79,13 @@ public: int not_clipped(int x, int y, int w, int h) FL_OVERRIDE; int clip_box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H) FL_OVERRIDE; virtual int has_feature(driver_feature feature_mask) FL_OVERRIDE { return feature_mask & PRINTER; } +#if !FLTK_USE_CAIRO + // draw image classes without caching them + void draw_rgb_bitmap_(Fl_Image *img,int XP, int YP, int WP, int HP, int cx, int cy); + void draw_pixmap(Fl_Pixmap * pxm,int XP, int YP, int WP, int HP, int cx, int cy) FL_OVERRIDE; + void draw_bitmap(Fl_Bitmap * bitmap,int XP, int YP, int WP, int HP, int cx, int cy) FL_OVERRIDE; + void draw_rgb(Fl_RGB_Image * rgb,int XP, int YP, int WP, int HP, int cx, int cy) FL_OVERRIDE; +#endif // !FLTK_USE_CAIRO }; #else // ! USE_PANGO diff --git a/src/drivers/PostScript/Fl_PostScript_image.cxx b/src/drivers/PostScript/Fl_PostScript_image.cxx index 0ae56609a..c78627727 100644 --- a/src/drivers/PostScript/Fl_PostScript_image.cxx +++ b/src/drivers/PostScript/Fl_PostScript_image.cxx @@ -68,7 +68,123 @@ void Fl_PostScript_Graphics_Driver::draw_image(const uchar *data, int ix, int iy draw_image(draw_image_cb, &cb_data, ix, iy, iw, ih, abs(D)); } -#if ! USE_PANGO +#if USE_PANGO + +#if !FLTK_USE_CAIRO + +static void destroy_BGRA(void *data) { + delete[] (uchar*)data; +} + + +void Fl_PostScript_Graphics_Driver::draw_pixmap(Fl_Pixmap *pxm,int XP, int YP, int WP, int HP, int cx, int cy) { + Fl_RGB_Image *rgb = new Fl_RGB_Image(pxm); + draw_rgb_bitmap_(rgb, XP, YP, WP, HP, cx, cy); + delete rgb; +} + + +void Fl_PostScript_Graphics_Driver::draw_rgb(Fl_RGB_Image *rgb,int XP, int YP, int WP, int HP, int cx, int cy) { + draw_rgb_bitmap_(rgb, XP, YP, WP, HP, cx, cy); +} + + +void Fl_PostScript_Graphics_Driver::draw_bitmap(Fl_Bitmap *bitmap,int XP, int YP, int WP, int HP, int cx, int cy) { + draw_rgb_bitmap_(bitmap, XP, YP, WP, HP, cx, cy); +} + + +void Fl_PostScript_Graphics_Driver::draw_rgb_bitmap_(Fl_Image *img,int XP, int YP, int WP, int HP, int cx, int cy) +{ + cairo_surface_t *surf; + cairo_format_t format = (img->d() >= 1 ? CAIRO_FORMAT_ARGB32 : CAIRO_FORMAT_A1); + int stride = cairo_format_stride_for_width(format, img->data_w()); + uchar *BGRA = new uchar[stride * img->data_h()]; + memset(BGRA, 0, stride * img->data_h()); + if (img->d() >= 1) { // process Fl_RGB_Image of all depths + Fl_RGB_Image *rgb = (Fl_RGB_Image*)img; + int lrgb = rgb->ld() ? rgb->ld() : rgb->data_w() * rgb->d(); + uchar A = 0xff, R,G,B, *q; + const uchar *r; + float f = 1; + if (rgb->d() >= 3) { // color images + for (int j = 0; j < rgb->data_h(); j++) { + r = rgb->array + j * lrgb; + q = BGRA + j * stride; + for (int i = 0; i < rgb->data_w(); i++) { + R = *r; + G = *(r+1); + B = *(r+2); + if (rgb->d() == 4) { + A = *(r+3); + f = float(A)/0xff; + } + *q = B * f; + *(q+1) = G * f; + *(q+2) = R * f; + *(q+3) = A; + r += rgb->d(); q += 4; + } + } + } else if (rgb->d() == 1 || rgb->d() == 2) { // B&W + for (int j = 0; j < rgb->data_h(); j++) { + r = rgb->array + j * lrgb; + q = BGRA + j * stride; + for (int i = 0; i < rgb->data_w(); i++) { + G = *r; + if (rgb->d() == 2) { + A = *(r+1); + f = float(A)/0xff; + } + *(q) = G * f; + *(q+1) = G * f; + *(q+2) = G * f; + *(q+3) = A; + r += rgb->d(); q += 4; + } + } + } + } else { + Fl_Bitmap *bm = (Fl_Bitmap*)img; + uchar *r, p; + unsigned *q; + for (int j = 0; j < bm->data_h(); j++) { + r = (uchar*)bm->array + j * ((bm->data_w() + 7)/8); + q = (unsigned*)(BGRA + j * stride); + unsigned k = 0, mask32 = 1; + p = *r; + for (int i = 0; i < bm->data_w(); i++) { + if (p&1) (*q) |= mask32; + k++; + if (k % 8 != 0) p >>= 1; else p = *(++r); + if (k % 32 != 0) mask32 <<= 1; else {q++; mask32 = 1;} + } + } + } + surf = cairo_image_surface_create_for_data(BGRA, format, img->data_w(), img->data_h(), stride); + if (cairo_surface_status(surf) == CAIRO_STATUS_SUCCESS) { + static cairo_user_data_key_t key = {}; + (void)cairo_surface_set_user_data(surf, &key, BGRA, destroy_BGRA); + cairo_pattern_t *pat = cairo_pattern_create_for_surface(surf); + cairo_save(cairo_); + cairo_rectangle(cairo_, XP-0.5, YP-0.5, WP+1, HP+1); + cairo_clip(cairo_); + if (img->d() >= 1) cairo_set_source(cairo_, pat); + cairo_matrix_t matrix; + cairo_matrix_init_scale(&matrix, double(img->data_w())/(img->w()+1), double(img->data_h())/(img->h()+1)); + cairo_matrix_translate(&matrix, -XP+0.5+cx, -YP+0.5+cy); + cairo_pattern_set_matrix(pat, &matrix); + cairo_mask(cairo_, pat); + cairo_pattern_destroy(pat); + cairo_surface_destroy(surf); + cairo_restore(cairo_); + check_status(); + } +} + +#endif // !FLTK_USE_CAIRO + +#else // ! USE_PANGO // // Implementation of the /ASCII85Encode PostScript filter From 82e838f1fdadd7dd346f4bce51c6ebdd1e26dd35 Mon Sep 17 00:00:00 2001 From: Matthias Melcher Date: Tue, 28 Nov 2023 16:35:39 +0100 Subject: [PATCH 6/8] Adds OpenGL swap_interval for Wayland and X11. --- .../Wayland/Fl_Wayland_Gl_Window_Driver.H | 2 + .../Wayland/Fl_Wayland_Gl_Window_Driver.cxx | 18 ++++ src/drivers/X11/Fl_X11_Gl_Window_Driver.cxx | 87 +++++++++++++++---- 3 files changed, 88 insertions(+), 19 deletions(-) diff --git a/src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.H b/src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.H index 83b13e155..df321fc10 100644 --- a/src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.H +++ b/src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.H @@ -46,6 +46,8 @@ private: void swap_buffers() FL_OVERRIDE; void resize(int is_a_resize, int w, int h) FL_OVERRIDE; char swap_type() FL_OVERRIDE; + void swap_interval(int) FL_OVERRIDE; + int swap_interval() const FL_OVERRIDE; Fl_Gl_Choice *find(int m, const int *alistp) FL_OVERRIDE; GLContext create_gl_context(Fl_Window* window, const Fl_Gl_Choice* g) FL_OVERRIDE; void set_gl_context(Fl_Window* w, GLContext context) FL_OVERRIDE; diff --git a/src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx index 4553c1a0e..ac625fe6f 100644 --- a/src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx +++ b/src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx @@ -63,6 +63,9 @@ struct gl_start_support { // to support use of gl_start / gl_finish static EGLConfig wld_egl_conf = NULL; +static EGLint swap_interval_ = 1; +static EGLint max_swap_interval = 1000; +static EGLint min_swap_interval = 0; EGLDisplay Fl_Wayland_Gl_Window_Driver::egl_display = EGL_NO_DISPLAY; @@ -170,6 +173,9 @@ Fl_Gl_Choice *Fl_Wayland_Gl_Window_Driver::find(int m, const int *alistp) Fl::fatal("failed to choose an EGL config\n"); } + eglGetConfigAttrib(egl_display, g->egl_conf, EGL_MAX_SWAP_INTERVAL, &max_swap_interval); + eglGetConfigAttrib(egl_display, g->egl_conf, EGL_MIN_SWAP_INTERVAL, &min_swap_interval); + first = g; return g; } @@ -431,6 +437,18 @@ void Fl_Wayland_Gl_Window_Driver::gl_start() { glClear(GL_COLOR_BUFFER_BIT); } +void Fl_Wayland_Gl_Window_Driver::swap_interval(int interval) { + if (interval < min_swap_interval) interval = min_swap_interval; + if (interval > max_swap_interval) interval = max_swap_interval; + if (egl_display && eglSwapInterval(egl_display, interval)) + swap_interval_ = interval; + // printf("swap_interval_=%d\n",swap_interval_); +} + + +int Fl_Wayland_Gl_Window_Driver::swap_interval() const { + return swap_interval_; +} FL_EXPORT EGLContext fl_wl_glcontext(GLContext rc) { return (EGLContext)rc; } diff --git a/src/drivers/X11/Fl_X11_Gl_Window_Driver.cxx b/src/drivers/X11/Fl_X11_Gl_Window_Driver.cxx index fd07308fa..c2611e739 100644 --- a/src/drivers/X11/Fl_X11_Gl_Window_Driver.cxx +++ b/src/drivers/X11/Fl_X11_Gl_Window_Driver.cxx @@ -397,41 +397,90 @@ char Fl_X11_Gl_Window_Driver::swap_type() { return copy; } -typedef void (*SWAPINTERVALPROC) (Display *dpy, GLXDrawable drawable, int interval); -static SWAPINTERVALPROC glXSwapIntervalEXT = NULL; -static bool glXSwapIntervalChecked = false; -static void checkGlxXSwapInterval() { - if (!glXSwapIntervalChecked) { - glXSwapIntervalChecked = true; - glXSwapIntervalEXT = (SWAPINTERVALPROC)glXGetProcAddressARB((const GLubyte*)"glXSwapIntervalEXT"); + +// Start of swap_interval implementation in the three possibel ways for X11 + +// -1 = not yet initialized, 0 = none found, 1 = GLX, 2 = MESA, 3 = SGI +static signed char swap_interval_type = -1; + +typedef void (*GLX_Set_Swap_Iterval_Proc) (Display *dpy, GLXDrawable drawable, int interval); +typedef int (*MESA_Set_Swap_Iterval_Proc) (unsigned int interval); +typedef int (*MESA_Get_Swap_Iterval_Proc) (); +typedef int (*SGI_Set_Swap_Iterval_Proc) (int interval); + +static union { + GLX_Set_Swap_Iterval_Proc glXSwapIntervalEXT = NULL; + MESA_Set_Swap_Iterval_Proc glXSwapIntervalMESA; + SGI_Set_Swap_Iterval_Proc glXSwapIntervalSGI; +}; + +static MESA_Get_Swap_Iterval_Proc glXGetSwapIntervalMESA = NULL; + +static void init_swap_interval() { + if (swap_interval_type != -1) return; + int major = 1, minor = 0; + glXQueryVersion(fl_display, &major, &minor); + swap_interval_type = 0; + const char *extensions = glXQueryExtensionsString(fl_display, fl_screen); + if (strstr(extensions, "GLX_EXT_swap_control") && ((major > 1) || (minor >= 3))) { + glXSwapIntervalEXT = (GLX_Set_Swap_Iterval_Proc)glXGetProcAddressARB((const GLubyte*)"glXSwapIntervalEXT"); + swap_interval_type = 1; + } else if (strstr(extensions, "GLX_MESA_swap_control")) { + glXSwapIntervalMESA = (MESA_Set_Swap_Iterval_Proc)glXGetProcAddressARB((const GLubyte*)"glXSwapIntervalMESA"); + glXGetSwapIntervalMESA = (MESA_Get_Swap_Iterval_Proc)glXGetProcAddressARB((const GLubyte*)"glXGetSwapIntervalMESA"); + swap_interval_type = 2; + } else if (strstr(extensions, "GLX_SGI_swap_control")) { + glXSwapIntervalSGI = (SGI_Set_Swap_Iterval_Proc)glXGetProcAddressARB((const GLubyte*)"glXSwapIntervalSGI"); + swap_interval_type = 3; } } void Fl_X11_Gl_Window_Driver::swap_interval(int interval) { if (!fl_xid(pWindow)) return; - if (!glXSwapIntervalChecked) checkGlxXSwapInterval(); - if (glXSwapIntervalEXT) { - glXSwapIntervalEXT(fl_display, fl_xid(pWindow), interval); + if (swap_interval_type == -1) + init_swap_interval(); + switch (swap_interval_type) { + case 1: + if (glXSwapIntervalEXT) + glXSwapIntervalEXT(fl_display, fl_xid(pWindow), interval); + break; + case 2: + if (glXSwapIntervalMESA) + glXSwapIntervalMESA((unsigned int)interval); + break; + case 3: + if (glXSwapIntervalSGI) + glXSwapIntervalSGI(interval); + break; } } int Fl_X11_Gl_Window_Driver::swap_interval() const { if (!fl_xid(pWindow)) return -1; - if (!glXSwapIntervalChecked) checkGlxXSwapInterval(); - if (!glXSwapIntervalEXT) return -1; - static bool ext_checked = false, ext_exists = false; - if (!ext_checked) { - ext_checked = true; - ext_exists = (strstr(glXQueryExtensionsString(fl_display, fl_screen), "GLX_EXT_swap_control") != NULL); + if (swap_interval_type == -1) + init_swap_interval(); + int interval = -1; + switch (swap_interval_type) { + case 1: { + unsigned int val = 0; + glXQueryDrawable(fl_display, fl_xid(pWindow), 0x20F1 /*GLX_SWAP_INTERVAL_EXT*/, &val); + interval = (int)val; + break; } + case 2: + if (glXGetSwapIntervalMESA) + interval = glXGetSwapIntervalMESA(); + break; + case 3: + // not available + break; } - if (!ext_exists) return -1; - unsigned int interval = -1; - glXQueryDrawable(fl_display, fl_xid(pWindow), 0x20F1 /*GLX_SWAP_INTERVAL_EXT*/, &interval); return interval; } +// end of swap_interval implementation + void Fl_X11_Gl_Window_Driver::waitGL() { glXWaitGL(); } From 6bcce462e9dfb5b1a49befb796527505b6f60f59 Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Wed, 29 Nov 2023 09:57:23 +0100 Subject: [PATCH 7/8] Update libdecor to commit cc58dd2a dated 2-nov-2023 --- libdecor/src/cursor-settings.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libdecor/src/cursor-settings.c b/libdecor/src/cursor-settings.c index 225034cdd..e7082e25e 100644 --- a/libdecor/src/cursor-settings.c +++ b/libdecor/src/cursor-settings.c @@ -42,8 +42,6 @@ get_setting_sync(DBusConnection *const connection, DBusMessage *message; DBusMessage *reply; - dbus_error_init(&error); - message = dbus_message_new_method_call( "org.freedesktop.portal.Desktop", "/org/freedesktop/portal/desktop", @@ -58,6 +56,8 @@ get_setting_sync(DBusConnection *const connection, if (!success) return NULL; + dbus_error_init(&error); + reply = dbus_connection_send_with_reply_and_block( connection, message, @@ -66,9 +66,12 @@ get_setting_sync(DBusConnection *const connection, dbus_message_unref(message); - if (dbus_error_is_set(&error)) + if (dbus_error_is_set(&error)) { + dbus_error_free(&error); return NULL; + } + dbus_error_free(&error); return reply; } From 44b845cc42b9a0326b6aa3438462bcd1b77ddeb4 Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Wed, 29 Nov 2023 10:03:14 +0100 Subject: [PATCH 8/8] Change type of member variables Fl_Graphics_Driver::ascent + descent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Type short is too small for Fl_Cairo_Graphics_Driver and font sizes ≥ 110. --- FL/Fl_Graphics_Driver.H | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FL/Fl_Graphics_Driver.H b/FL/Fl_Graphics_Driver.H index 1d7c3d702..49d6d4fc4 100644 --- a/FL/Fl_Graphics_Driver.H +++ b/FL/Fl_Graphics_Driver.H @@ -383,7 +383,7 @@ public: Fl_Fontsize size; /**< font size */ Fl_Font_Descriptor(const char* fontname, Fl_Fontsize size); virtual FL_EXPORT ~Fl_Font_Descriptor() {} - short ascent, descent; + int ascent, descent; unsigned int listbase;// base of display list, 0 = none };