diff options
Diffstat (limited to 'gtk/ScintillaGTK.cxx')
-rwxr-xr-x | gtk/ScintillaGTK.cxx | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/gtk/ScintillaGTK.cxx b/gtk/ScintillaGTK.cxx index a1ac3adf8..877b4763a 100755 --- a/gtk/ScintillaGTK.cxx +++ b/gtk/ScintillaGTK.cxx @@ -259,6 +259,10 @@ ScintillaGTK::~ScintillaGTK() { g_source_remove(styleIdleID); styleIdleID = 0; } + if (scrollBarIdleID) { + g_source_remove(scrollBarIdleID); + scrollBarIdleID = 0; + } ClearPrimarySelection(); wPreedit.Destroy(); if (settingsHandlerId) { @@ -1109,6 +1113,7 @@ bool ScintillaGTK::ModifyScrollBars(Sci::Line nMax, Sci::Line nPage) { #if !GTK_CHECK_VERSION(3,18,0) gtk_adjustment_changed(GTK_ADJUSTMENT(adjustmentv)); #endif + gtk_adjustment_set_value(GTK_ADJUSTMENT(adjustmentv), static_cast<gdouble>(topLine)); modified = true; } @@ -1130,6 +1135,7 @@ bool ScintillaGTK::ModifyScrollBars(Sci::Line nMax, Sci::Line nPage) { #if !GTK_CHECK_VERSION(3,18,0) gtk_adjustment_changed(GTK_ADJUSTMENT(adjustmenth)); #endif + gtk_adjustment_set_value(GTK_ADJUSTMENT(adjustmenth), xOffset); modified = true; } if (modified && (paintState == PaintState::painting)) { @@ -1144,6 +1150,27 @@ void ScintillaGTK::ReconfigureScrollBars() { Resize(static_cast<int>(rc.Width()), static_cast<int>(rc.Height())); } +void ScintillaGTK::SetScrollBars() { + if (scrollBarIdleID) { + // Only allow one scroll bar change to be queued + return; + } + constexpr gint priorityScrollBar = GDK_PRIORITY_REDRAW + 5; + // On GTK, unlike other platforms, modifying scrollbars inside some events including + // resizes causes problems. Deferring the modification to a lower priority (125) idle + // event avoids the problems. This code did not always work when the priority was + // higher than GTK's resize (GTK_PRIORITY_RESIZE=110) or redraw + // (GDK_PRIORITY_REDRAW=120) idle tasks. + scrollBarIdleID = gdk_threads_add_idle_full(priorityScrollBar, + [](gpointer pSci) -> gboolean { + ScintillaGTK *sciThis = static_cast<ScintillaGTK *>(pSci); + sciThis->ChangeScrollBars(); + sciThis->scrollBarIdleID = 0; + return FALSE; + }, + this, nullptr); +} + void ScintillaGTK::NotifyChange() { g_signal_emit(G_OBJECT(sci), scintilla_signals[COMMAND_SIGNAL], 0, Platform::LongFromTwoShorts(GetCtrlID(), SCEN_CHANGE), PWidget(wMain)); |