Ticket #4013: 0001-Window-show-unfullscreen-button-on-button-and-touch-.patch

File 0001-Window-show-unfullscreen-button-on-button-and-touch-.patch, 3.0 KB (added by erikos, 12 years ago)

Window: show unfullscreen button on button and touch events

  • src/sugar3/graphics/window.py

    From 71bd78150cfc845f70d162b8bb49bc394584f0fe Mon Sep 17 00:00:00 2001
    From: Simon Schampijer <simon@laptop.org>
    Date: Tue, 23 Oct 2012 09:24:56 +0200
    Subject: [PATCH toolkit-gtk3] Window: show unfullscreen button on button and
     touch events
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    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>
    ---
     src/sugar3/graphics/window.py | 25 ++++++++++++++++---------
     1 file changed, 16 insertions(+), 9 deletions(-)
    
    diff --git a/src/sugar3/graphics/window.py b/src/sugar3/graphics/window.py
    index 1d45210..74b3b04 100644
    a b class Window(Gtk.Window): 
    112112        self.__vbox.pack_start(self.__hbox, True, True, 0)
    113113        self.__hbox.show()
    114114
    115         self.add_events(Gdk.EventMask.POINTER_MOTION_HINT_MASK
    116                         | Gdk.EventMask.POINTER_MOTION_MASK)
     115        self.add_events(Gdk.EventMask.POINTER_MOTION_HINT_MASK |
     116                        Gdk.EventMask.POINTER_MOTION_MASK |
     117                        Gdk.EventMask.BUTTON_RELEASE_MASK |
     118                        Gdk.EventMask.TOUCH_MASK)
    117119        self.connect('motion-notify-event', self.__motion_notify_cb)
     120        self.connect('button-release-event', self.__button_press_event_cb)
    118121
    119122        self.add(self.__vbox)
    120123        self.__vbox.show()
    class Window(Gtk.Window): 
    264267    def __unfullscreen_button_clicked(self, button):
    265268        self.unfullscreen()
    266269
     270    def __button_press_event_cb(self, widget, event):
     271        self._show_unfullscreen_button()
     272        return False
     273
    267274    def __motion_notify_cb(self, widget, event):
     275        self._show_unfullscreen_button()
     276        return False
     277
     278    def _show_unfullscreen_button(self):
    268279        if self._is_fullscreen and self.props.enable_fullscreen_mode:
    269280            if not self._unfullscreen_button.props.visible:
    270281                self._unfullscreen_button.show()
    271             else:
    272                 # Reset the timer
    273                 if self._unfullscreen_button_timeout_id is not None:
    274                     GObject.source_remove(self._unfullscreen_button_timeout_id)
    275                     self._unfullscreen_button_timeout_id = None
    276282
     283            if self._unfullscreen_button_timeout_id is None:
    277284                self._unfullscreen_button_timeout_id = \
    278285                    GObject.timeout_add_seconds( \
    279                         _UNFULLSCREEN_BUTTON_VISIBILITY_TIMEOUT, \
     286                    _UNFULLSCREEN_BUTTON_VISIBILITY_TIMEOUT, \
    280287                        self.__unfullscreen_button_timeout_cb)
    281         return False
    282288
    283289    def __unfullscreen_button_timeout_cb(self):
    284290        self._unfullscreen_button.hide()
     291        GObject.source_remove(self._unfullscreen_button_timeout_id)
    285292        self._unfullscreen_button_timeout_id = None
    286293        return False
    287294