# HG changeset patch # User Goffi # Date 1500301255 -7200 # Node ID b226f545f67e75928251fcb9b977b2d3a894c22c # Parent ca14e1ced3b56c1ff5e304ab3f50d51780680490 primitivus(chat): fixed scroll down (was broken when Primitivus had not the focus and was receiving messages) diff -r ca14e1ced3b5 -r b226f545f67e frontends/src/primitivus/chat.py --- a/frontends/src/primitivus/chat.py Fri Jul 14 09:06:03 2017 +0200 +++ b/frontends/src/primitivus/chat.py Mon Jul 17 16:20:55 2017 +0200 @@ -405,6 +405,14 @@ else: return info_type in quick_chat.ROOM_USER_MOVED + def _scrollDown(self): + """scroll down message only if we are already at the bottom (minus 1)""" + current_focus = self.mess_widgets.focus_position + bottom = len(self.mess_walker) - 1 + if current_focus == bottom - 1: + self.mess_widgets.focus_position = bottom # scroll down + self.host.redraw() # FIXME: should not be necessary + def appendMessage(self, message): """Create a MessageWidget and append it @@ -442,6 +450,7 @@ self.focus_marker = urwid.Divider('—') self.mess_walker.append(self.focus_marker) self.focus_marker_set = True + self._scrollDown() else: if self.focus_marker_set: self.focus_marker_set = False @@ -451,11 +460,7 @@ else: wid = MessageWidget(message) self.mess_walker.append(wid) - current_focus = self.mess_widgets.focus_position - bottom = len(self.mess_walker) - 1 - if current_focus == bottom - 1: - self.mess_widgets.focus_position = bottom # scroll down - self.host.redraw() # FIXME: should not be necessary + self._scrollDown() if self._user_moved(message): return # no notification for moved messages