[vte/wip/egmont/bidi: 101/104] pause on unmap
- From: Egmont Koblinger <egmontkob src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte/wip/egmont/bidi: 101/104] pause on unmap
- Date: Wed, 29 May 2019 08:42:11 +0000 (UTC)
commit 4c45ff8662349568cb509ba8fecdcf3bc6b831bd
Author: Egmont Koblinger <egmont gmail com>
Date: Sat May 25 14:29:22 2019 +0200
pause on unmap
src/ringview.cc | 23 +++++++++++++++++------
src/ringview.hh | 2 +-
src/vte.cc | 6 ++++++
src/vteinternal.hh | 1 +
src/widget.cc | 2 ++
5 files changed, 27 insertions(+), 7 deletions(-)
---
diff --git a/src/ringview.cc b/src/ringview.cc
index 82c428db..f875ab40 100644
--- a/src/ringview.cc
+++ b/src/ringview.cc
@@ -49,7 +49,7 @@ RingView::~RingView()
* in the near future, e.g. the widget is unmapped. Not to be called too frequently,
* in order to avoid memory fragmentation.
*
- * The RingView is unpaused automatically on demand.
+ * The RingView is resumed automatically on demand.
*/
void RingView::pause()
{
@@ -58,6 +58,9 @@ void RingView::pause()
if (m_paused)
return;
+ _vte_debug_print (VTE_DEBUG_RINGVIEW, "Ringview: pause, freeing %d rows, %d bidirows.\n",
+ m_rows_alloc_len, m_bidirows_alloc_len);
+
for (i = 0; i < m_rows_alloc_len; i++) {
_vte_row_data_fini(m_rows[i]);
g_free (m_rows[i]);
@@ -76,7 +79,7 @@ void RingView::pause()
}
/* Allocate (again) the required memory. */
-void RingView::unpause()
+void RingView::resume()
{
g_assert_cmpint (m_len, >=, 1);
@@ -93,6 +96,9 @@ void RingView::unpause()
m_bidirows[i] = new BidiRow();
}
+ _vte_debug_print (VTE_DEBUG_RINGVIEW, "Ringview: resume, allocating %d rows, %d bidirows\n",
+ m_rows_alloc_len, m_bidirows_alloc_len);
+
m_paused = false;
}
@@ -129,6 +135,8 @@ void RingView::set_rows(vte::grid::row_t start, vte::grid::row_t len)
while (len > m_bidirows_alloc_len) {
m_bidirows_alloc_len *= 1.25 /* whatever */;
}
+ _vte_debug_print (VTE_DEBUG_RINGVIEW, "Ringview: reallocate to %d bidirows\n",
+ m_bidirows_alloc_len);
m_bidirows = (BidiRow **) g_realloc (m_bidirows, sizeof (BidiRow *) * m_bidirows_alloc_len);
for (; i < m_bidirows_alloc_len; i++) {
m_bidirows[i] = new BidiRow();
@@ -152,7 +160,7 @@ void RingView::update()
if (!m_invalid)
return;
if (m_paused)
- unpause();
+ resume();
/* Find the beginning of the topmost paragraph.
*
@@ -164,7 +172,7 @@ void RingView::update()
vte::grid::row_t row = m_start;
const VteRowData *row_data;
- _vte_debug_print (VTE_DEBUG_RINGVIEW, "Updating ringview for [%ld..%ld] (%ld rows).\n",
+ _vte_debug_print (VTE_DEBUG_RINGVIEW, "Ringview: updating for [%ld..%ld] (%ld rows).\n",
m_start, m_start + m_len - 1, m_len);
int i = VTE_RINGVIEW_PARAGRAPH_LENGTH_MAX;
@@ -190,6 +198,8 @@ void RingView::update()
while (row < m_start + m_len + VTE_RINGVIEW_PARAGRAPH_LENGTH_MAX) {
if (m_rows_len == m_rows_alloc_len) {
m_rows_alloc_len *= 1.25 /* whatever */;
+ _vte_debug_print (VTE_DEBUG_RINGVIEW, "Ringview: reallocate to %d rows\n",
+ m_rows_alloc_len);
m_rows = (VteRowData **) g_realloc (m_rows, sizeof (VteRowData *) *
m_rows_alloc_len);
for (int j = m_rows_len; j < m_rows_alloc_len; j++) {
m_rows[j] = (VteRowData *) g_malloc (sizeof (VteRowData));
@@ -211,8 +221,9 @@ void RingView::update()
break;
}
- _vte_debug_print (VTE_DEBUG_RINGVIEW, "Extracted %ld more rows at top, %ld more rows at bottom.\n",
- m_start - m_top, (m_top + m_rows_len) - (m_start + m_len));
+ _vte_debug_print (VTE_DEBUG_RINGVIEW, "Ringview: extracted %ld+%ld context lines: [%ld..%ld] (%d
rows).\n",
+ m_start - m_top, (m_top + m_rows_len) - (m_start + m_len),
+ m_top, m_top + m_rows_len - 1, m_rows_len);
/* Loop through paragraphs of the extracted text, and do whatever we need to do on each paragraph. */
auto top = m_top;
diff --git a/src/ringview.hh b/src/ringview.hh
index 77bac334..1149da7a 100644
--- a/src/ringview.hh
+++ b/src/ringview.hh
@@ -100,7 +100,7 @@ private:
bool m_invalid;
bool m_paused;
- void unpause();
+ void resume();
};
}; /* namespace base */
diff --git a/src/vte.cc b/src/vte.cc
index 01a09ad3..56cb03d6 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -8218,6 +8218,12 @@ Terminal::widget_size_allocate(GtkAllocation *allocation)
}
}
+void
+Terminal::widget_unmap()
+{
+ m_ringview.pause();
+}
+
void
Terminal::widget_unrealize()
{
diff --git a/src/vteinternal.hh b/src/vteinternal.hh
index b94be4d1..84d3b482 100644
--- a/src/vteinternal.hh
+++ b/src/vteinternal.hh
@@ -734,6 +734,7 @@ public:
void widget_constructed();
void widget_realize();
void widget_unrealize();
+ void widget_unmap();
void widget_style_updated();
void widget_focus_in(GdkEventFocus *event);
void widget_focus_out(GdkEventFocus *event);
diff --git a/src/widget.cc b/src/widget.cc
index 331ddba9..5af5d47c 100644
--- a/src/widget.cc
+++ b/src/widget.cc
@@ -334,6 +334,8 @@ Widget::size_allocate(GtkAllocation* allocation) noexcept
void
Widget::unmap() noexcept
{
+ m_terminal->widget_unmap();
+
if (m_event_window)
gdk_window_hide(m_event_window);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]