From a55079bdcea7f3bbaae726166890841eb1ad1c2f Mon Sep 17 00:00:00 2001 From: Neil Hodgson Date: Tue, 28 Feb 2023 16:42:55 +1100 Subject: Cache client rectangle when view resized. That makes it safer to access from secondary threads. --- gtk/ScintillaGTK.cxx | 8 +++++++- gtk/ScintillaGTK.h | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/gtk/ScintillaGTK.cxx b/gtk/ScintillaGTK.cxx index fb852e637..ab415e743 100755 --- a/gtk/ScintillaGTK.cxx +++ b/gtk/ScintillaGTK.cxx @@ -402,6 +402,7 @@ void ScintillaGTK::MapThis() { wMain.SetCursor(Window::Cursor::arrow); scrollbarv.SetCursor(Window::Cursor::arrow); scrollbarh.SetCursor(Window::Cursor::arrow); + SetClientRectangle(); ChangeSize(); gdk_window_show(PWindow(wMain)); } catch (...) { @@ -1061,8 +1062,12 @@ void ScintillaGTK::FullPaint() { wText.InvalidateAll(); } +void ScintillaGTK::SetClientRectangle() { + rectangleClient = wMain.GetClientPosition(); +} + PRectangle ScintillaGTK::GetClientRectangle() const { - PRectangle rc = wMain.GetClientPosition(); + PRectangle rc = rectangleClient; if (verticalScrollBarVisible) rc.right -= verticalScrollBarWidth; if (horizontalScrollBarVisible && !Wrapping()) @@ -1788,6 +1793,7 @@ void ScintillaGTK::Resize(int width, int height) { gtk_widget_hide(GTK_WIDGET(PWidget(scrollbarv))); verticalScrollBarWidth = 0; } + SetClientRectangle(); if (IS_WIDGET_MAPPED(PWidget(wMain))) { ChangeSize(); } else { diff --git a/gtk/ScintillaGTK.h b/gtk/ScintillaGTK.h index a1ce05969..7c9b165cb 100755 --- a/gtk/ScintillaGTK.h +++ b/gtk/ScintillaGTK.h @@ -33,6 +33,8 @@ class ScintillaGTK : public ScintillaBase { int verticalScrollBarWidth; int horizontalScrollBarHeight; + PRectangle rectangleClient; + SelectionText primary; SelectionPosition posPrimary; @@ -128,6 +130,7 @@ private: bool HaveMouseCapture() override; bool PaintContains(PRectangle rc) override; void FullPaint(); + void SetClientRectangle(); PRectangle GetClientRectangle() const override; void ScrollText(Sci::Line linesToMove) override; void SetVerticalScrollPos() override; -- cgit v1.2.3