[sugar] Capturing all mouse events

Erik Blankinship erikb
Fri May 30 22:47:57 EDT 2008


This is what we did in Record to remove extra buttons when a child hasn't
moved the mouse in a while... (
http://mediamods.com/public-svn/camera-activity/tags/54/ui.py)  But this has
a very low sample rate:

This code might benefit from improvements.  Suggestions?

	def resetWidgetFadeTimer( self ):
		#only show the clutter when the mouse moves
		self.mx = -1
		self.my = -1
		self.hideWidgetsTimer = time.time()
		if (self.hiddenWidgets):
			self.showWidgets()
			self.hiddenWidgets = False

		#remove, then add
		self.doMouseListener( False )
		if (self.HIDE_WIDGET_TIMEOUT_ID != 0):
			gobject.source_remove( self.HIDE_WIDGET_TIMEOUT_ID )

		self.HIDE_WIDGET_TIMEOUT_ID = gobject.timeout_add( 500,
self._mouseMightaMovedCb )


	def doMouseListener( self, listen ):
		if (listen):
			self.resetWidgetFadeTimer()
		else:
			if (self.HIDE_WIDGET_TIMEOUT_ID != None):
				if (self.HIDE_WIDGET_TIMEOUT_ID != 0):
					gobject.source_remove( self.HIDE_WIDGET_TIMEOUT_ID )



	def _mouseMightaMovedCb( self ):
		x, y = self.ca.get_pointer()
		passedTime = 0

		if (x != self.mx or y != self.my):
			self.hideWidgetsTimer = time.time()
			if (self.hiddenWidgets):
				self.showWidgets()
				self.hiddenWidgets = False
		else:
			passedTime = time.time() - self.hideWidgetsTimer

		if (self.ca.m.RECORDING):
			self.hideWidgetsTimer = time.time()
			passedTime = 0

		if (passedTime >= 3):
			if (not self.hiddenWidgets):
				if (self.mouseInWidget(x,y)):
					self.hideWidgetsTimer = time.time()
				elif (self.RECD_INFO_ON):
					self.hideWidgetsTimer = time.time()
				elif (self.UPDATE_TIMER_ID != 0):
					self.hideWidgetsTimer = time.time()
				else:
					self.hideWidgets()
					self.hiddenWidgets = True

		self.mx = x
		self.my = y
		return True




On Fri, May 30, 2008 at 9:38 PM, Benjamin M. Schwartz <
bmschwar at fas.harvard.edu> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Does anyone know how to capture all mouse events?  I am trying to get all
> mouse button up/down events, and maybe even all motion events.  I have
> tried using gdk to listen to all events on the root window, but it doesn't
> seem to capture mouse events.
>
> It seems like the right way might be to use Xlib, or to hook into the
> window manager, or the X driver, or just listen to /dev/input/mouse0.  I
> don't know much about any of these.  What would you do?
>
> - --Ben
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v2.0.9 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iEYEARECAAYFAkhArB8ACgkQUJT6e6HFtqSRSQCfatqMr9Ksdn204nEtaH89dV8r
> kp8AnAxkPIq/bqnUJENnBze/GFMSgkXt
> =IdMQ
> -----END PGP SIGNATURE-----
> _______________________________________________
> Sugar mailing list
> Sugar at lists.laptop.org
> http://lists.laptop.org/listinfo/sugar
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.laptop.org/pipermail/sugar/attachments/20080530/9448694f/attachment.htm 



More information about the Sugar-devel mailing list