summaryrefslogtreecommitdiff
path: root/src/components/chatlist.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/chatlist.hpp')
-rw-r--r--src/components/chatlist.hpp18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/components/chatlist.hpp b/src/components/chatlist.hpp
index e5afb80..783474a 100644
--- a/src/components/chatlist.hpp
+++ b/src/components/chatlist.hpp
@@ -2,6 +2,7 @@
#include <gtkmm.h>
#include <map>
#include <vector>
+#include "discord/message.hpp"
#include "discord/snowflake.hpp"
class ChatList : public Gtk::ScrolledWindow {
@@ -25,7 +26,7 @@ public:
void ActuallyRemoveMessage(Snowflake id); // perhaps not the best method name
private:
- void OnScrollEdgeOvershot(Gtk::PositionType pos);
+ void OnUpperAdjustmentChanged();
void ScrollToBottom();
void RemoveMessageAndHeader(Gtk::Widget *widget);
@@ -52,6 +53,10 @@ private:
bool m_separate_all = false;
+ Glib::Timer m_history_timer;
+ bool m_needs_upper_adjustment = false;
+ double m_old_upper = -1.0;
+
public:
// these are all forwarded by the parent
using type_signal_action_message_edit = sigc::signal<void, Snowflake, Snowflake>;
@@ -88,6 +93,7 @@ private:
template<typename Iter>
inline void ChatList::SetMessages(Iter begin, Iter end) {
+ m_needs_upper_adjustment = false;
Clear();
m_num_rows = 0;
m_num_messages = 0;
@@ -101,15 +107,7 @@ inline void ChatList::SetMessages(Iter begin, Iter end) {
template<typename Iter>
inline void ChatList::PrependMessages(Iter begin, Iter end) {
- const auto old_upper = get_vadjustment()->get_upper();
- const auto old_value = get_vadjustment()->get_value();
+ m_needs_upper_adjustment = true;
for (Iter it = begin; it != end; it++)
ProcessNewMessage(*it, true);
- // force everything to process before getting new values
- while (Gtk::Main::events_pending())
- Gtk::Main::iteration();
- const auto new_upper = get_vadjustment()->get_upper();
- if (old_value == 0.0 && (new_upper - old_upper) > 0.0)
- get_vadjustment()->set_value(new_upper - old_upper);
- // this isn't ideal
}