Skip to content

Commit

Permalink
frame key double press consistency
Browse files Browse the repository at this point in the history
When the frame key is pressed rapidly, some presses are ignored, because
the animation position is used to determine if the frame is visible.

To fix,

- remove class _KeyListener as it is not required, see also 3e28f56,

- add a flag for whether the frame is wanted or not, self._wanted,

- add a toggle() method, which calls show() or hide() according to last
  known wanted state, and call it from the mouse enter corner or frame
  key press methods,

- do not test frame visibility in show() or hide(), depend on _wanted,

- in the gesture handler, use toggle() instead of show() or hide(),

Test case:

	xdotool key F6 key F6 key F6

should be equivalent in final effect to

	xdotool key F6

Fixes #4806 https://bugs.sugarlabs.org/ticket/4806
  • Loading branch information
quozl committed Nov 17, 2015
1 parent 65926ce commit 41fae0b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 24 deletions.
36 changes: 16 additions & 20 deletions src/jarabe/frame/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,6 @@ def next_frame(self, current):
self._frame.move(current)


class _KeyListener(object):
def __init__(self, frame):
self._frame = frame

def key_press(self):
if self._frame.visible:
self._frame.hide()
else:
self._frame.show()


class Frame(object):
def __init__(self):
logging.debug('STARTUP: Loading the frame')
Expand All @@ -76,6 +65,7 @@ def __init__(self):
self._top_panel = None
self._bottom_panel = None

self._wanted = False
self.current_position = 0.0
self._animator = None

Expand All @@ -91,8 +81,6 @@ def __init__(self):
screen = Gdk.Screen.get_default()
screen.connect('size-changed', self._size_changed_cb)

self._key_listener = _KeyListener(self)

self._notif_by_icon = {}

notification_service = notifications.get_service()
Expand All @@ -106,10 +94,18 @@ def is_visible(self):

visible = property(is_visible, None)

def toggle(self):
if not self._wanted:
self.show()
else:
self.hide()

def hide(self):
if not self.visible:
if not self._wanted:
return

self._wanted = False

if self._animator:
self._animator.stop()

Expand All @@ -119,8 +115,11 @@ def hide(self):
self._animator.start()

def show(self):
if self.visible:
if self._wanted:
return

self._wanted = True

if self._animator:
self._animator.stop()

Expand Down Expand Up @@ -207,13 +206,10 @@ def _size_changed_cb(self, screen):
self._update_position()

def _enter_corner_cb(self, event_area):
if self.visible:
self.hide()
else:
self.show()
self.toggle()

def notify_key_press(self):
self._key_listener.key_press()
self.toggle()

def add_notification(self, icon, corner=Gtk.CornerType.TOP_LEFT,
duration=_NOTIFICATION_DURATION):
Expand Down
5 changes: 1 addition & 4 deletions src/jarabe/view/gesturehandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,7 @@ def _track_gesture_for_area(self, directions, x, y, width, height):
self._controller.append(swipe)

def __swipe_ended_cb(self, controller, event_direction):
if self._frame.is_visible():
self._frame.hide()
else:
self._frame.show()
self._frame.toggle()


def setup(frame):
Expand Down

0 comments on commit 41fae0b

Please sign in to comment.