[gnote] Fix wrong selection after backgrounding



commit 2e56d4a82176b69af308238dc15d4125e459b67b
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Sun Feb 13 21:35:54 2022 +0200

    Fix wrong selection after backgrounding

 src/note.cpp | 24 +++---------------------
 src/note.hpp |  3 +--
 2 files changed, 4 insertions(+), 23 deletions(-)
---
diff --git a/src/note.cpp b/src/note.cpp
index e96cf480..5f7668b7 100644
--- a/src/note.cpp
+++ b/src/note.cpp
@@ -1,7 +1,7 @@
  /*
  * gnote
  *
- * Copyright (C) 2010-2017,2019-2021 Aurimas Cernius
+ * Copyright (C) 2010-2017,2019-2022 Aurimas Cernius
  * Copyright (C) 2009 Hubert Figuiere
  *
  * This program is free software: you can redistribute it and/or modify
@@ -403,31 +403,15 @@ namespace gnote {
       m_data.data().set_cursor_position(start.get_offset());
       m_data.data().set_selection_bound_position(end.get_offset());
     }
-    else if(insert->get_name() == "insert") {
+    else if(insert == insert_mark) {
       m_data.data().set_cursor_position(iter.get_offset());
+      m_data.data().set_selection_bound_position(NoteData::s_noPosition);
     }
 
     DBG_OUT("OnBufferSetMark queueing save");
     queue_save(NO_CHANGE);
   }
 
-  void Note::on_buffer_mark_deleted(const Glib::RefPtr<Gtk::TextBuffer::Mark> & mark)
-  {
-    if(mark != get_buffer()->get_selection_bound()) {
-      return;
-    }
-
-    Gtk::TextIter start, end;
-    if(m_data.data().selection_bound_position() != m_data.data().cursor_position()
-       && !m_buffer->get_selection_bounds(start, end)) {
-      DBG_OUT("selection removed");
-      m_data.data().set_cursor_position(m_buffer->get_insert()->get_iter().get_offset());
-      m_data.data().set_selection_bound_position(NoteData::s_noPosition);
-      queue_save(NO_CHANGE);
-    }
-  }
-
-
   bool Note::on_window_destroyed(GdkEventAny * /*ev*/)
   {
     m_window = NULL;
@@ -710,8 +694,6 @@ namespace gnote {
         sigc::mem_fun(*this, &Note::on_buffer_tag_removed));
       m_mark_set_conn = m_buffer->signal_mark_set().connect(
         sigc::mem_fun(*this, &Note::on_buffer_mark_set));
-      m_mark_deleted_conn = m_buffer->signal_mark_deleted().connect(
-        sigc::mem_fun(*this, &Note::on_buffer_mark_deleted));
     }
     return m_buffer;
   }
diff --git a/src/note.hpp b/src/note.hpp
index 9b63a46a..945352d5 100644
--- a/src/note.hpp
+++ b/src/note.hpp
@@ -1,7 +1,7 @@
 /*
  * gnote
  *
- * Copyright (C) 2011-2015,2017,2019-2020 Aurimas Cernius
+ * Copyright (C) 2011-2015,2017,2019-2020,2022 Aurimas Cernius
  * Copyright (C) 2009 Hubert Figuiere
  *
  * This program is free software: you can redistribute it and/or modify
@@ -176,7 +176,6 @@ private:
                              const Gtk::TextBuffer::iterator &);
   void on_buffer_mark_set(const Gtk::TextBuffer::iterator & iter,
                           const Glib::RefPtr<Gtk::TextBuffer::Mark> & insert);
-  void on_buffer_mark_deleted(const Glib::RefPtr<Gtk::TextBuffer::Mark> & mark);
   bool on_window_destroyed(GdkEventAny *ev);
   void on_save_timeout();
   void process_child_widget_queue();


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]