summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2009-12-13 00:42:19 +0100
committerhut <hut@lavabit.com>2009-12-13 00:42:19 +0100
commite657119b4881cec409f42b738f073f5b8e43bc2a (patch)
tree5c99df7561b0fb0953bf3d302fa8b111c43d254b /ranger
parent49ae0dd10749a312f20d006a927408201e710d53 (diff)
downloadranger-e657119b4881cec409f42b738f073f5b8e43bc2a.tar.gz
fixed issues with scrolling/invalid mouse bstates
Diffstat (limited to 'ranger')
-rw-r--r--ranger/gui/ui.py13
-rw-r--r--ranger/gui/widgets/filelist.py3
2 files changed, 13 insertions, 3 deletions
diff --git a/ranger/gui/ui.py b/ranger/gui/ui.py
index c1764546..7b7230fb 100644
--- a/ranger/gui/ui.py
+++ b/ranger/gui/ui.py
@@ -6,6 +6,7 @@ from ranger.container import CommandList
 
 class UI(DisplayableContainer):
 	is_set_up = False
+	mousemask = curses.ALL_MOUSE_EVENTS | curses.REPORT_MOUSE_POSITION
 	def __init__(self, commandlist = None):
 		import os
 		os.environ['ESCDELAY'] = '25' # don't know a cleaner way
@@ -31,10 +32,16 @@ class UI(DisplayableContainer):
 		curses.start_color()
 		curses.use_default_colors()
 
+		curses.mousemask(self.mousemask)
 		curses.mouseinterval(0)
-		mask = curses.ALL_MOUSE_EVENTS | curses.REPORT_MOUSE_POSITION
-		avail, old = curses.mousemask(mask)
-		curses.mousemask(avail)
+		
+		## this line solves this problem:
+		## If an action, following a mouse click, includes the
+		## destruction and re-initializion of the ui (e.g. running a
+		## file by clicking on its preview) and the next key is another
+		## mouse click, the bstate of this mouse event will be invalid.
+		## (atm, invalid bstates are recognized as scroll-down)
+		curses.ungetmouse(0,0,0,0,0)
 
 		if not self.is_set_up:
 			self.is_set_up = True
diff --git a/ranger/gui/widgets/filelist.py b/ranger/gui/widgets/filelist.py
index 48c6c284..e8138e51 100644
--- a/ranger/gui/widgets/filelist.py
+++ b/ranger/gui/widgets/filelist.py
@@ -14,6 +14,9 @@ class FileList(Widget):
 		"""Handle a MouseEvent"""
 		from ranger.fsobject.fsobject import T_DIRECTORY
 
+		if not (event.pressed(1) or event.pressed(3)):
+			return False
+
 		if self.target is None:
 			pass