From e675df1803fbf3241d8ba36910f91d754e182c63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20H=C3=B6rist?= Date: Sun, 16 Jul 2017 23:58:54 +0200 Subject: [PATCH] Fix activity timers for groupchat - Dont add timers when we autojoin minimized - Remove timers when the chatcontrol gets minimized - Send inactive chatstate when the chatcontrol gets minimized - Add timers when the chatcontrol gets maximized --- gajim/chat_control_base.py | 10 +++++++--- gajim/groupchat_control.py | 4 ++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/gajim/chat_control_base.py b/gajim/chat_control_base.py index f6a2252d0..f609b3592 100644 --- a/gajim/chat_control_base.py +++ b/gajim/chat_control_base.py @@ -376,7 +376,8 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): # chatstate timers and state self.reset_kbd_mouse_timeout_vars() - self._schedule_activity_timers() + self.possible_paused_timeout_id = None + self.possible_inactive_timeout_id = None message_tv_buffer = self.msg_textview.get_buffer() id_ = message_tv_buffer.connect('changed', self._on_message_tv_buffer_changed) @@ -385,6 +386,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): id_ = parent_win.window.connect('motion-notify-event', self._on_window_motion_notify) self.handlers[id_] = parent_win.window + self._schedule_activity_timers() self.encryption = self.get_encryption_state() if self.parent_win: @@ -836,6 +838,10 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): return True # loop forever def _schedule_activity_timers(self): + if self.possible_paused_timeout_id: + GLib.source_remove(self.possible_paused_timeout_id) + if self.possible_inactive_timeout_id: + GLib.source_remove(self.possible_inactive_timeout_id) self.possible_paused_timeout_id = GLib.timeout_add_seconds(5, self.check_for_possible_paused_chatstate, None) self.possible_inactive_timeout_id = GLib.timeout_add_seconds(30, @@ -1143,8 +1149,6 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): else: self.send_chatstate('active', self.contact) self.reset_kbd_mouse_timeout_vars() - GLib.source_remove(self.possible_paused_timeout_id) - GLib.source_remove(self.possible_inactive_timeout_id) self._schedule_activity_timers() else: self.send_chatstate('inactive', self.contact) diff --git a/gajim/groupchat_control.py b/gajim/groupchat_control.py index d6580c66d..b101af8c6 100644 --- a/gajim/groupchat_control.py +++ b/gajim/groupchat_control.py @@ -529,6 +529,7 @@ class GroupchatControl(ChatControlBase): self.set_tooltip() self.add_window_actions() self.set_lock_image() + self._schedule_activity_timers() def set_tooltip(self): widget = self.xml.get_object('list_treeview') @@ -2085,8 +2086,11 @@ class GroupchatControl(ChatControlBase): control = win.notebook.get_nth_page(ctrl_page) win.notebook.remove_page(ctrl_page) + GLib.source_remove(self.possible_paused_timeout_id) + GLib.source_remove(self.possible_inactive_timeout_id) control.unparent() ctrl.parent_win = None + self.send_chatstate('inactive', self.contact) gajim.interface.roster.add_groupchat(self.contact.jid, self.account, status = self.subject)