summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorlouiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13>2010-10-05 00:14:13 +0000
committerlouiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13>2010-10-05 00:14:13 +0000
commit0dfd8366e1c4a750c24949b2aeed7666162af528 (patch)
tree5ddb36a9691a5321cf5aee5b26c88f8321486f6d /src
parent53a5536cf12cbe8474f37b1c8e31b60489b2b62f (diff)
downloadpoezio-0dfd8366e1c4a750c24949b2aeed7666162af528.tar.gz
poezio-0dfd8366e1c4a750c24949b2aeed7666162af528.tar.bz2
poezio-0dfd8366e1c4a750c24949b2aeed7666162af528.tar.xz
poezio-0dfd8366e1c4a750c24949b2aeed7666162af528.zip
use a timer to refresh only after a short delay. Limit the useless software refresh.
Diffstat (limited to 'src')
-rw-r--r--src/gui.py31
1 files changed, 27 insertions, 4 deletions
diff --git a/src/gui.py b/src/gui.py
index a35dfd96..574368d1 100644
--- a/src/gui.py
+++ b/src/gui.py
@@ -25,6 +25,7 @@ import re
import sys
import shlex
import curses
+import threading
import webbrowser
from datetime import datetime
@@ -65,6 +66,9 @@ SHOW_NAME = {
'chat': _('chatty'),
'': _('available')
}
+
+resize_lock = threading.Lock()
+
def doupdate():
curses.doupdate()
@@ -86,6 +90,7 @@ class Gui(object):
self.information_buffer = TextBuffer()
self.information_win_size = 2 # Todo, get this from config
self.ignores = {}
+ self.resize_timer = None
self.commands = {
'help': (self.command_help, '\_o< KOIN KOIN KOIN'),
@@ -129,7 +134,7 @@ class Gui(object):
"KEY_F(7)": self.shrink_information_win,
"KEY_F(8)": self.grow_information_win,
"^N": self.rotate_rooms_right,
- "KEY_RESIZE": self.resize_window,
+ "KEY_RESIZE": self.call_for_resize,
'^X': self.go_to_important_room,
'^V': self.move_separator,
}
@@ -486,13 +491,31 @@ class Gui(object):
# TODO refresh roster_win only
self.refresh_window()
+ def call_for_resize(self):
+ """
+ Starts a very short timer. If no other terminal resize
+ occured in this delay then poezio is REALLY resize.
+ This is to avoid multiple unnecessary software resizes (this
+ can be heavy on resource on slow computers or networks)
+ """
+ with resize_lock:
+ if self.resize_timer:
+ # a recent terminal resize occured.
+ # Cancel the programmed software resize
+ self.resize_timer.cancel()
+ # add the new timer
+ self.resize_timer = threading.Timer(0.15, self.resize_window)
+ self.resize_timer.start()
+
def resize_window(self):
"""
Resize the whole screen
"""
- for tab in self.tabs:
- tab.resize(self.stdscr)
- self.refresh_window()
+ with resize_lock:
+ self.resize_timer = None
+ for tab in self.tabs:
+ tab.resize(self.stdscr)
+ self.refresh_window()
def main_loop(self):
"""