Window: show unfullscreen button on button and touch events

We did track mouse motion events so far to show the unfullscreen
button. This adds the tracking of button events (left, middle, right
click) and touch tap.

Signed-off-by: Simon Schampijer <simon@laptop.org>
Acked-by: Manuel Quiñones <manuq@laptop.org>
This commit is contained in:
Simon Schampijer 2012-10-23 09:24:56 +02:00
parent 1224ab1451
commit 20ef297526

View File

@ -112,9 +112,12 @@ class Window(Gtk.Window):
self.__vbox.pack_start(self.__hbox, True, True, 0) self.__vbox.pack_start(self.__hbox, True, True, 0)
self.__hbox.show() self.__hbox.show()
self.add_events(Gdk.EventMask.POINTER_MOTION_HINT_MASK self.add_events(Gdk.EventMask.POINTER_MOTION_HINT_MASK |
| Gdk.EventMask.POINTER_MOTION_MASK) Gdk.EventMask.POINTER_MOTION_MASK |
Gdk.EventMask.BUTTON_RELEASE_MASK |
Gdk.EventMask.TOUCH_MASK)
self.connect('motion-notify-event', self.__motion_notify_cb) self.connect('motion-notify-event', self.__motion_notify_cb)
self.connect('button-release-event', self.__button_press_event_cb)
self.add(self.__vbox) self.add(self.__vbox)
self.__vbox.show() self.__vbox.show()
@ -264,21 +267,28 @@ class Window(Gtk.Window):
def __unfullscreen_button_clicked(self, button): def __unfullscreen_button_clicked(self, button):
self.unfullscreen() self.unfullscreen()
def __button_press_event_cb(self, widget, event):
self._show_unfullscreen_button()
return False
def __motion_notify_cb(self, widget, event): def __motion_notify_cb(self, widget, event):
self._show_unfullscreen_button()
return False
def _show_unfullscreen_button(self):
if self._is_fullscreen and self.props.enable_fullscreen_mode: if self._is_fullscreen and self.props.enable_fullscreen_mode:
if not self._unfullscreen_button.props.visible: if not self._unfullscreen_button.props.visible:
self._unfullscreen_button.show() self._unfullscreen_button.show()
else:
# Reset the timer
if self._unfullscreen_button_timeout_id is not None:
GObject.source_remove(self._unfullscreen_button_timeout_id)
self._unfullscreen_button_timeout_id = None
self._unfullscreen_button_timeout_id = \ # Reset the timer
GObject.timeout_add_seconds( \ if self._unfullscreen_button_timeout_id is not None:
_UNFULLSCREEN_BUTTON_VISIBILITY_TIMEOUT, \ GObject.source_remove(self._unfullscreen_button_timeout_id)
self.__unfullscreen_button_timeout_cb) self._unfullscreen_button_timeout_id = None
return False
self._unfullscreen_button_timeout_id = \
GObject.timeout_add_seconds( \
_UNFULLSCREEN_BUTTON_VISIBILITY_TIMEOUT, \
self.__unfullscreen_button_timeout_cb)
def __unfullscreen_button_timeout_cb(self): def __unfullscreen_button_timeout_cb(self):
self._unfullscreen_button.hide() self._unfullscreen_button.hide()