From 09c123e89a2411bd4181d2be42322c7d8aaade1b Mon Sep 17 00:00:00 2001 From: Maxie Dion Schmidt Date: Wed, 1 Jun 2022 20:00:38 -0400 Subject: [PATCH] Initial attempt to fix #105: My Big Sur system still minimizes the window, so the issue is not completely reproduced locally --- src/DiagramWindow.cpp | 14 +++++++++++++- src/DiagramWindow.h | 5 +++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/DiagramWindow.cpp b/src/DiagramWindow.cpp index c5ea0e9..9f9f262 100644 --- a/src/DiagramWindow.cpp +++ b/src/DiagramWindow.cpp @@ -90,6 +90,7 @@ void DiagramWindow::Construct(int w, int h, const std::vector &structures) size_range(w, h, w, h); box(FL_NO_BOX); iconize(); + make_current(); title = (char *) malloc(128 * sizeof(char)); SetStructures(structures); @@ -116,8 +117,19 @@ void DiagramWindow::Construct(int w, int h, const std::vector &structures) cairo_fill(crZoom); set_draw_cb(Draw); + redraw_full(this); show(); - wait_for_expose(); + /* It can take some time from the time show() is called until the + * point when the user should see it on screen. This leads to buggy + * behavior on recent MacOS platforms (>= Big Sur) as seen in issue #105. + * The strategy is to wait until the user sees the window, call show() again, + * and then redraw everything within the window after that happens: + */ + while(!shown() || !visible()) { + Fl::wait(0.5); + } + show(); + redraw_full(this); } diff --git a/src/DiagramWindow.h b/src/DiagramWindow.h index 7793d81..860cf32 100644 --- a/src/DiagramWindow.h +++ b/src/DiagramWindow.h @@ -111,6 +111,11 @@ class DiagramWindow : public Fl_Cairo_Window, public RadialLayoutWindowCallbackI */ bool computeDrawKeyParams(RNAStructure **sequences, int *numToDraw, int *keyA, int *keyB); void drawWidgets(cairo_t *crDraw); + static inline void redraw_full(DiagramWindow *thisWin) { + thisWin->m_redrawStructures = true; + thisWin->drawWidgets(NULL); + thisWin->redraw(); + } static void Draw(Fl_Cairo_Window *thisCairoWindow, cairo_t *cr, bool drawWidgets); static inline void Draw(Fl_Cairo_Window *thisCairoWindow, cairo_t *cr) { DiagramWindow::Draw(thisCairoWindow, cr, true); }