Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self.show_pointer = False
for slide_widget in [self.p_da_cur, self.c_da]:
ww, wh = slide_widget.get_allocated_width(), slide_widget.get_allocated_height()
if max(ww, wh) == 1:
continue
pointer_coordinates = slide_widget.get_window().get_pointer()
if 0 < pointer_coordinates.x < ww and 0 < pointer_coordinates.y < wh \
and self.pointer_mode == PointerMode.CONTINUOUS:
# Laser activated right away
self.pointer_pos = (pointer_coordinates.x / ww, pointer_coordinates.y / wh)
self.show_pointer = True
extras.Cursor.set_cursor(slide_widget, 'invisible')
else:
extras.Cursor.set_cursor(slide_widget, 'parent')
self.redraw_current_slide()
It is switched on again when the mouse reenters the slide.
Args:
widget (:class:`~Gtk.Widget`): the widget which has received the event.
event (:class:`~Gdk.Event`): the GTK event.
Returns:
`bool`: whether the event was consumed
"""
# Only handle enter/leave events on one of the current slides
if self.pointer_mode != PointerMode.CONTINUOUS or widget not in [self.c_da, self.p_da_cur]:
return False
if event.type == Gdk.EventType.ENTER_NOTIFY:
self.show_pointer = True
extras.Cursor.set_cursor(widget, 'invisible')
elif event.type == Gdk.EventType.LEAVE_NOTIFY:
self.show_pointer = False
extras.Cursor.set_cursor(widget, 'parent')
self.redraw_current_slide()
return True
if event.type != Gdk.EventType.MOTION_NOTIFY:
return False
# Where did the event occur?
if widget is self.p_da_next:
page = self.doc.next_page()
if page is None:
return
else:
page = self.doc.current_page()
x, y = self.zoom.get_slide_point(widget, event)
page_mode = self.notes_mode if widget is self.p_da_notes else self.notes_mode.complement()
if page.get_link_at(x, y, page_mode):
extras.Cursor.set_cursor(widget, 'pointer')
return False
else:
extras.Cursor.set_cursor(widget, 'parent')
return True
Args:
widget (:class:`~Gtk.Widget`): the widget which has received the event.
event (:class:`~Gdk.Event`): the GTK event.
Returns:
`bool`: whether the event was consumed
"""
if self.pointer_mode in {PointerMode.DISABLED, PointerMode.CONTINUOUS}:
return False
ctrl_pressed = event.get_state() & Gdk.ModifierType.CONTROL_MASK
if ctrl_pressed and event.type == Gdk.EventType.BUTTON_PRESS:
self.show_pointer = True
extras.Cursor.set_cursor(widget, 'invisible')
# Immediately place & draw the pointer
return self.track_pointer(widget, event)
elif self.show_pointer and event.type == Gdk.EventType.BUTTON_RELEASE:
self.show_pointer = False
extras.Cursor.set_cursor(widget, 'parent')
self.redraw_current_slide()
return True
else:
return False