### ----------------------------------------------------
### -- Gnome::Gdk3
### -- Licenses: Artistic-2.0
### -- Authors: Marcel Timmerman
### -- File: lib/Gnome/Gdk3/Events.rakumod
### ----------------------------------------------------
### -- Chunk 1 of 4
#TL:1:Gnome::Gdk3::Events:

use v6;
#-------------------------------------------------------------------------------
=begin pod

=head1 Gnome::Gdk3::Events

Functions for handling events from the window system

=head1 Description

This section describes functions dealing with events from the window system.

In GTK+ applications the events are handled automatically in C<gtk_main_do_event()> and passed on to the appropriate widgets, so these functions are rarely needed. Though some of the fields in the gdk event structures are useful.

=head1 Synopsis
=head2 Declaration

  unit class Gnome::Gdk3::Events;
  also is Gnome::N::TopLevelClassSupport;

=head2 Example

  my Gnome::Gtk3::Window $top-window .= new;
  $top-window.set-title('Hello GTK!');
  # ... etcetera ...

  # Define a handler method
  method handle-keypress ( N-GdkEvent() $event, :$widget ) {
    if $event.event-any.type ~~ GDK_KEY_PRESS {
      my N-GdkEventKey() $event-key = $event;
      if Buf.new($event.event-key.keyval).decode eq 's' {
        # key 's' pressed, stop process ...
      }
    }
  }

  # And register the signal handler for a window event
  $top-window.register-signal( self, 'handle-keypress', 'key-press-event');

If the handler handles only one event type, the method can also be defined as

  method handle-keypress ( N-GdkEventKey() $event-key, :$widget ) {
    if $event-key.type ~~ GDK_KEY_PRESS and
      Buf.new($event-key.keyval).decode eq 's' {
      # key 's' pressed, stop process ...
    }
  }

=end pod
#-------------------------------------------------------------------------------
use NativeCall;

use Gnome::N::X:api<1>;
use Gnome::N::NativeLib:api<1>;
use Gnome::N::N-GObject:api<1>;
use Gnome::N::TopLevelClassSupport:api<1>;
use Gnome::N::GlibToRakuTypes:api<1>;

use Gnome::Gdk3::Types:api<1>;

use Gnome::Cairo::Types:api<1>;

#-------------------------------------------------------------------------------
# https://developer.gnome.org/gdk3/stable/gdk3-Event-Structures.html
# https://developer.gnome.org/gdk3/stable/gdk3-Events.html
unit class Gnome::Gdk3::Events:auth<github:MARTIMM>:api<1>;
also is Gnome::N::TopLevelClassSupport;

#-------------------------------------------------------------------------------
=begin pod
=head1 Types
=end pod

#-------------------------------------------------------------------------------
=begin pod
=head2 enum GdkCrossingMode

Specifies the crossing mode for B<N-GdkEventCrossing>.

=item GDK_CROSSING_NORMAL: crossing because of pointer motion.
=item GDK_CROSSING_GRAB: crossing because a grab is activated.
=item GDK_CROSSING_UNGRAB: crossing because a grab is deactivated.
=item GDK_CROSSING_GTK_GRAB: crossing because a GTK+ grab is activated.
=item GDK_CROSSING_GTK_UNGRAB: crossing because a GTK+ grab is deactivated.
=item GDK_CROSSING_STATE_CHANGED: crossing because a GTK+ widget changed state (e.g. sensitivity).
=item GDK_CROSSING_TOUCH_BEGIN: crossing because a touch sequence has begun, this event is synthetic as the pointer might have not left the window.
=item GDK_CROSSING_TOUCH_END: crossing because a touch sequence has ended, this event is synthetic as the pointer might have not left the window.
=item GDK_CROSSING_DEVICE_SWITCH: crossing because of a device switch (i.e. a mouse taking control of the pointer after a touch device), this event is synthetic as the pointer didn’t leave the window.

=end pod

#TE:0:GdkCrossingMode:
enum GdkCrossingMode is export (
  'GDK_CROSSING_NORMAL',
  'GDK_CROSSING_GRAB',
  'GDK_CROSSING_UNGRAB',
  'GDK_CROSSING_GTK_GRAB',
  'GDK_CROSSING_GTK_UNGRAB',
  'GDK_CROSSING_STATE_CHANGED',
  'GDK_CROSSING_TOUCH_BEGIN',
  'GDK_CROSSING_TOUCH_END',
  'GDK_CROSSING_DEVICE_SWITCH'
);

#-------------------------------------------------------------------------------
=begin pod
=head2 enum GdkEventType

Specifies the type of the event.

Do not confuse these events with the signals that GTK+ widgets emit. Although many of these events result in corresponding signals being emitted, the events are often transformed or filtered along the way.

=comment In some language bindings, the values C<GDK-2BUTTON-PRESS> and C<GDK-3BUTTON-PRESS> would translate into something syntactically invalid (eg `Gdk.EventType.2ButtonPress`, where a symbol is not allowed to start with a number). In that case, the aliases C<GDK-DOUBLE-BUTTON-PRESS> and C<GDK-TRIPLE-BUTTON-PRESS> can be used instead.

=item GDK_NOTHING: a special code to indicate a null event.
=item GDK_DELETE: the window manager has requested that the toplevel window be hidden or destroyed, usually when the user clicks on a special icon in the title bar.
=item GDK_DESTROY: the window has been destroyed.
=item GDK_EXPOSE: all or part of the window has become visible and needs to be redrawn.
=item GDK_MOTION_NOTIFY: the pointer (usually a mouse) has moved.
=item GDK_BUTTON_PRESS: a mouse button has been pressed.
=item GDK_2BUTTON_PRESS: a mouse button has been double-clicked (clicked twice within a short period of time). Note that each click also generates a C<GDK_BUTTON_PRESS> event.
=item GDK_DOUBLE_BUTTON_PRESS: alias for C<GDK_2BUTTON_PRESS>.
=item GDK_3BUTTON_PRESS: a mouse button has been clicked 3 times in a short period of time. Note that each click also generates a C<GDK_BUTTON_PRESS> event.
=item GDK_TRIPLE_BUTTON_PRESS: alias for C<GDK_3BUTTON_PRESS>.
=item GDK_BUTTON_RELEASE: a mouse button has been released.
=item GDK_KEY_PRESS: a key has been pressed.
=item GDK_KEY_RELEASE: a key has been released.
=item GDK_ENTER_NOTIFY: the pointer has entered the window.
=item GDK_LEAVE_NOTIFY: the pointer has left the window.
=item GDK_FOCUS_CHANGE: the keyboard focus has entered or left the window.
=item GDK_CONFIGURE: the size, position or stacking order of the window has changed. Note that GTK+ discards these events for C<GDK_WINDOW_CHILD> windows.
=item GDK_MAP: the window has been mapped.
=item GDK_UNMAP: the window has been unmapped.
=item GDK_PROPERTY_NOTIFY: a property on the window has been changed or deleted.
=item GDK_SELECTION_CLEAR: the application has lost ownership of a selection.
=item GDK_SELECTION_REQUEST: another application has requested a selection.
=item GDK_SELECTION_NOTIFY: a selection has been received.
=item GDK_PROXIMITY_IN: an input device has moved into contact with a sensing surface (e.g. a touchscreen or graphics tablet).
=item GDK_PROXIMITY_OUT: an input device has moved out of contact with a sensing surface.
=item GDK_DRAG_ENTER: the mouse has entered the window while a drag is in progress.
=item GDK_DRAG_LEAVE: the mouse has left the window while a drag is in progress.
=item GDK_DRAG_MOTION: the mouse has moved in the window while a drag is in progress.
=item GDK_DRAG_STATUS: the status of the drag operation initiated by the window has changed.
=item GDK_DROP_START: a drop operation onto the window has started.
=item GDK_DROP_FINISHED: the drop operation initiated by the window has completed.
=item GDK_CLIENT_EVENT: a message has been received from another application.
=item GDK_VISIBILITY_NOTIFY: the window visibility status has changed.
=item GDK_SCROLL: the scroll wheel was turned
=item GDK_WINDOW_STATE: the state of a window has changed. See B<Gnome::Gdk3::WindowState> for the possible window states
=item GDK_SETTING: a setting has been modified.
=item GDK_OWNER_CHANGE: the owner of a selection has changed. This event type was added in 2.6
=item GDK_GRAB_BROKEN: a pointer or keyboard grab was broken. This event type was added in 2.8.
=item GDK_DAMAGE: the content of the window has been changed. This event type was added in 2.14.
=item GDK_TOUCH_BEGIN: A new touch event sequence has just started. This event type was added in 3.4.
=item GDK_TOUCH_UPDATE: A touch event sequence has been updated. This event type was added in 3.4.
=item GDK_TOUCH_END: A touch event sequence has finished. This event type was added in 3.4.
=item GDK_TOUCH_CANCEL: A touch event sequence has been canceled. This event type was added in 3.4.
=item GDK_TOUCHPAD_SWIPE: A touchpad swipe gesture event, the current state is determined by its phase field.
=item GDK_TOUCHPAD_PINCH: A touchpad pinch gesture event, the current state is determined by its phase field.
=item GDK_PAD_BUTTON_PRESS: A tablet pad button press event.
=item GDK_PAD_BUTTON_RELEASE: A tablet pad button release event
=item GDK_PAD_RING: A tablet pad axis event from a "ring".
=item GDK_PAD_STRIP: A tablet pad axis event from a "strip".
=item GDK_PAD_GROUP_MODE: A tablet pad group mode change.
=item GDK_EVENT_LAST: marks the end of the GdkEventType enumeration.

=end pod

#TE:4:GdkEventType:
enum GdkEventType is export (
  'GDK_NOTHING'		=> -1,
  'GDK_DELETE'		=> 0,
  'GDK_DESTROY'		=> 1,
  'GDK_EXPOSE'		=> 2,
  'GDK_MOTION_NOTIFY'	=> 3,
  'GDK_BUTTON_PRESS'	=> 4,
  'GDK_2BUTTON_PRESS'	=> 5,
  'GDK_DOUBLE_BUTTON_PRESS' => 5,   # = GDK_2BUTTON_PRESS,
  'GDK_3BUTTON_PRESS'	=> 6,
  'GDK_TRIPLE_BUTTON_PRESS' => 6,   # = GDK_3BUTTON_PRESS,
  'GDK_BUTTON_RELEASE'	=> 7,
  'GDK_KEY_PRESS'		=> 8,
  'GDK_KEY_RELEASE'	=> 9,
  'GDK_ENTER_NOTIFY'	=> 10,
  'GDK_LEAVE_NOTIFY'	=> 11,
  'GDK_FOCUS_CHANGE'	=> 12,
  'GDK_CONFIGURE'		=> 13,
  'GDK_MAP'		=> 14,
  'GDK_UNMAP'		=> 15,
  'GDK_PROPERTY_NOTIFY'	=> 16,
  'GDK_SELECTION_CLEAR'	=> 17,
  'GDK_SELECTION_REQUEST' => 18,
  'GDK_SELECTION_NOTIFY'	=> 19,
  'GDK_PROXIMITY_IN'	=> 20,
  'GDK_PROXIMITY_OUT'	=> 21,
  'GDK_DRAG_ENTER'        => 22,
  'GDK_DRAG_LEAVE'        => 23,
  'GDK_DRAG_MOTION'       => 24,
  'GDK_DRAG_STATUS'       => 25,
  'GDK_DROP_START'        => 26,
  'GDK_DROP_FINISHED'     => 27,
  'GDK_CLIENT_EVENT'	=> 28,
  'GDK_VISIBILITY_NOTIFY' => 29,
  'GDK_SCROLL'            => 31,
  'GDK_WINDOW_STATE'      => 32,
  'GDK_SETTING'           => 33,
  'GDK_OWNER_CHANGE'      => 34,
  'GDK_GRAB_BROKEN'       => 35,
  'GDK_DAMAGE'            => 36,
  'GDK_TOUCH_BEGIN'       => 37,
  'GDK_TOUCH_UPDATE'      => 38,
  'GDK_TOUCH_END'         => 39,
  'GDK_TOUCH_CANCEL'      => 40,
  'GDK_TOUCHPAD_SWIPE'    => 41,
  'GDK_TOUCHPAD_PINCH'    => 42,
  'GDK_PAD_BUTTON_PRESS'  => 43,
  'GDK_PAD_BUTTON_RELEASE' => 44,
  'GDK_PAD_RING'          => 45,
  'GDK_PAD_STRIP'         => 46,
  'GDK_PAD_GROUP_MODE'    => 47,
  'GDK_EVENT_LAST'        # helper variable for decls
);

#`{{
#-------------------------------------------------------------------------------
=begin pod
=head2 enum GdkFilterReturn

Specifies the result of applying a B<Gnome::Gdk3::FilterFunc> to a native event.

=item GDK_FILTER_CONTINUE: event not handled, continue processing.
=item GDK_FILTER_TRANSLATE: native event translated into a GDK event and stored in the `event` structure that was passed in.
=item GDK_FILTER_REMOVE: event handled, terminate processing.


=end pod

#TE:0:GdkFilterReturn:
enum GdkFilterReturn is export (
  GDK_FILTER_CONTINUE GDK_FILTER_TRANSLATE GDK_FILTER_REMOVE
);
}}

#-------------------------------------------------------------------------------
=begin pod
=head2 enum GdkNotifyType

Specifies the kind of crossing for B<N-GdkEventCrossing>.

See the X11 protocol specification of LeaveNotify for full details of crossing event generation.

=item GDK_NOTIFY_ANCESTOR: the window is entered from an ancestor or left towards an ancestor.
=item GDK_NOTIFY_VIRTUAL: the pointer moves between an ancestor and an inferior of the window.
=item GDK_NOTIFY_INFERIOR: the window is entered from an inferior or left towards an inferior.
=item GDK_NOTIFY_NONLINEAR: the window is entered from or left towards a window which is neither an ancestor nor an inferior.
=item GDK_NOTIFY_NONLINEAR_VIRTUAL: the pointer moves between two windows which are not ancestors of each other and the window is part of the ancestor chain between one of these windows and their least common ancestor.
=item GDK_NOTIFY_UNKNOWN: an unknown type of enter/leave event occurred.

=end pod

#TE:0:GdkNotifyType:
enum GdkNotifyType is export (
  'GDK_NOTIFY_ANCESTOR'		=> 0,
  'GDK_NOTIFY_VIRTUAL'		=> 1,
  'GDK_NOTIFY_INFERIOR'		=> 2,
  'GDK_NOTIFY_NONLINEAR'		=> 3,
  'GDK_NOTIFY_NONLINEAR_VIRTUAL'	=> 4,
  'GDK_NOTIFY_UNKNOWN'		=> 5
);

#-------------------------------------------------------------------------------
=begin pod
=head2 enum GdkOwnerChange

Specifies why a selection ownership was changed.

=item GDK_OWNER_CHANGE_NEW_OWNER: some other app claimed the ownership
=item GDK_OWNER_CHANGE_DESTROY: the window was destroyed
=item GDK_OWNER_CHANGE_CLOSE: the client was closed

=end pod

#TE:0:GdkOwnerChange:
enum GdkOwnerChange is export (
  'GDK_OWNER_CHANGE_NEW_OWNER',
  'GDK_OWNER_CHANGE_DESTROY',
  'GDK_OWNER_CHANGE_CLOSE'
);

#-------------------------------------------------------------------------------
=begin pod
=head2 enum GdkPropertyState

Specifies the type of a property change for a B<N-GdkEventProperty>.

=item GDK_PROPERTY_NEW_VALUE: the property value was changed.
=item GDK_PROPERTY_DELETE: the property was deleted.

=end pod

#TE:0:GdkPropertyState:
enum GdkPropertyState is export (
  'GDK_PROPERTY_NEW_VALUE',
  'GDK_PROPERTY_DELETE'
);

#-------------------------------------------------------------------------------
=begin pod
=head2 enum GdkScrollDirection

Specifies the direction for B<N-GdkEventScroll>.

=item GDK_SCROLL_UP: the window is scrolled up.
=item GDK_SCROLL_DOWN: the window is scrolled down.
=item GDK_SCROLL_LEFT: the window is scrolled to the left.
=item GDK_SCROLL_RIGHT: the window is scrolled to the right.
=item GDK_SCROLL_SMOOTH: the scrolling is determined by the delta values in B<N-GdkEventScroll>. See C<gdk_event_get_scroll_deltas()>

=end pod

#TE:0:GdkScrollDirection:
enum GdkScrollDirection is export (
  'GDK_SCROLL_UP',
  'GDK_SCROLL_DOWN',
  'GDK_SCROLL_LEFT',
  'GDK_SCROLL_RIGHT',
  'GDK_SCROLL_SMOOTH'
);

#-------------------------------------------------------------------------------
=begin pod
=head2 enum GdkSettingAction

Specifies the kind of modification applied to a setting in a B<N-GdkEventSetting>.

=item GDK_SETTING_ACTION_NEW: a setting was added.
=item GDK_SETTING_ACTION_CHANGED: a setting was changed.
=item GDK_SETTING_ACTION_DELETED: a setting was deleted.

=end pod

#TE:0:GdkSettingAction:
enum GdkSettingAction is export (
  'GDK_SETTING_ACTION_NEW',
  'GDK_SETTING_ACTION_CHANGED',
  'GDK_SETTING_ACTION_DELETED'
);

#-------------------------------------------------------------------------------
=begin pod
=head2 enum GdkTouchpadGesturePhase

Specifies the current state of a touchpad gesture. All gestures are guaranteed to begin with an event with phase C<GDK_TOUCHPAD_GESTURE_PHASE_BEGIN>, followed by 0 or several events with phase C<GDK_TOUCHPAD_GESTURE_PHASE_UPDATE>.

A finished gesture may have 2 possible outcomes, an event with phase C<GDK_TOUCHPAD_GESTURE_PHASE_END> will be emitted when the gesture is considered successful, this should be used as the hint to perform any permanent changes. Cancelled gestures may be so for a variety of reasons, due to hardware or the compositor, or due to the gesture recognition layers hinting the gesture did not finish resolutely (eg. a 3rd finger being added during a pinch gesture). In these cases, the last event will report the phase C<GDK_TOUCHPAD_GESTURE_PHASE_CANCEL>, this should be used as a hint to undo any visible/permanent changes that were done throughout the progress of the gesture.

See also B<Gnome::Gdk3::EventTouchpadSwipe> and B<Gnome::Gdk3::EventTouchpadPinch>.

=item GDK_TOUCHPAD_GESTURE_PHASE_BEGIN: The gesture has begun.
=item GDK_TOUCHPAD_GESTURE_PHASE_UPDATE: The gesture has been updated.
=item GDK_TOUCHPAD_GESTURE_PHASE_END: The gesture was finished, changes should be permanently applied.
=item GDK_TOUCHPAD_GESTURE_PHASE_CANCEL: The gesture was cancelled, all changes should be undone.

=end pod

#TE:0:GdkTouchpadGesturePhase:
enum GdkTouchpadGesturePhase is export (
  'GDK_TOUCHPAD_GESTURE_PHASE_BEGIN',
  'GDK_TOUCHPAD_GESTURE_PHASE_UPDATE',
  'GDK_TOUCHPAD_GESTURE_PHASE_END',
  'GDK_TOUCHPAD_GESTURE_PHASE_CANCEL'
);

#-------------------------------------------------------------------------------
=begin pod
=head2 enum GdkVisibilityState

Specifies the visiblity status of a window for a B<Gnome::Gdk3::EventVisibility>.

=item GDK_VISIBILITY_UNOBSCURED: the window is completely visible.
=item GDK_VISIBILITY_PARTIAL: the window is partially visible.
=item GDK_VISIBILITY_FULLY_OBSCURED: the window is not visible at all.

=end pod

#TE:0:GdkVisibilityState:
enum GdkVisibilityState is export (
  'GDK_VISIBILITY_UNOBSCURED',
  'GDK_VISIBILITY_PARTIAL',
  'GDK_VISIBILITY_FULLY_OBSCURED'
);

#-------------------------------------------------------------------------------
=begin pod
=head2 enum GdkWindowState

Specifies the state of a toplevel window.

=item GDK_WINDOW_STATE_WITHDRAWN: the window is not shown.
=item GDK_WINDOW_STATE_ICONIFIED: the window is minimized.
=item GDK_WINDOW_STATE_MAXIMIZED: the window is maximized.
=item GDK_WINDOW_STATE_STICKY: the window is sticky.
=item GDK_WINDOW_STATE_FULLSCREEN: the window is maximized without decorations.
=item GDK_WINDOW_STATE_ABOVE: the window is kept above other windows.
=item GDK_WINDOW_STATE_BELOW: the window is kept below other windows.
=item GDK_WINDOW_STATE_FOCUSED: the window is presented as focused (with active decorations).
=item GDK_WINDOW_STATE_TILED: the window is in a tiled state. Since Gtk version 3.22.23, this is deprecated in favor of per-edge information.
=item GDK_WINDOW_STATE_TOP_TILED: whether the top edge is tiled.
=item GDK_WINDOW_STATE_TOP_RESIZABLE: whether the top edge is resizable.
=item GDK_WINDOW_STATE_RIGHT_TILED: whether the right edge is tiled.
=item GDK_WINDOW_STATE_RIGHT_RESIZABLE: whether the right edge is resizable.
=item GDK_WINDOW_STATE_BOTTOM_TILED: whether the bottom edge is tiled.
=item GDK_WINDOW_STATE_BOTTOM_RESIZABLE: whether the bottom edge is resizable.
=item GDK_WINDOW_STATE_LEFT_TILED: whether the left edge is tiled.
=item GDK_WINDOW_STATE_LEFT_RESIZABLE: whether the left edge is resizable.


=end pod

#TE:0:GdkWindowState:
enum GdkWindowState is export (
  'GDK_WINDOW_STATE_WITHDRAWN'        => 1 +< 0,
  'GDK_WINDOW_STATE_ICONIFIED'        => 1 +< 1,
  'GDK_WINDOW_STATE_MAXIMIZED'        => 1 +< 2,
  'GDK_WINDOW_STATE_STICKY'           => 1 +< 3,
  'GDK_WINDOW_STATE_FULLSCREEN'       => 1 +< 4,
  'GDK_WINDOW_STATE_ABOVE'            => 1 +< 5,
  'GDK_WINDOW_STATE_BELOW'            => 1 +< 6,
  'GDK_WINDOW_STATE_FOCUSED'          => 1 +< 7,
  'GDK_WINDOW_STATE_TILED'            => 1 +< 8,
  'GDK_WINDOW_STATE_TOP_TILED'        => 1 +< 9,
  'GDK_WINDOW_STATE_TOP_RESIZABLE'    => 1 +< 10,
  'GDK_WINDOW_STATE_RIGHT_TILED'      => 1 +< 11,
  'GDK_WINDOW_STATE_RIGHT_RESIZABLE'  => 1 +< 12,
  'GDK_WINDOW_STATE_BOTTOM_TILED'     => 1 +< 13,
  'GDK_WINDOW_STATE_BOTTOM_RESIZABLE' => 1 +< 14,
  'GDK_WINDOW_STATE_LEFT_TILED'       => 1 +< 15,
  'GDK_WINDOW_STATE_LEFT_RESIZABLE'   => 1 +< 16
);

#-------------------------------------------------------------------------------
=begin pod
=head2 class N-GdkEventAny

Contains the fields which are common to all event structs. Any event pointer can safely be cast to a pointer to a B<N-GdkEventAny> to access these fields.

=item GdkEventType $.type: the type of the event.
=item N-GObject $.window: the window which received the event.
=item C<Int()> $.send_event: C<True> if the event was sent explicitly.

=end pod

#TT:0:N-GdkEventAny:
class N-GdkEventAny is export is repr('CStruct') {
  has GEnum $.type;
  has N-GObject $.window;
  has gint8 $.send_event;

  method COERCE ( $no --> N-GdkEventAny ) {
    note "Coercing from {$no.^name} to ", self.^name if $Gnome::N::x-debug;
    nativecast( N-GdkEventAny, $no)
  }
}

#`{{TODO cairo_region_t not defined
#-------------------------------------------------------------------------------
=begin pod
=head2 class N-GdkEventExpose

Generated when all or part of a window becomes visible and needs to be redrawn.

=item GdkEventType $.type: the type of the event (C<GDK_EXPOSE> or C<GDK_DAMAGE>).
=item N-GObject $.window: the window which received the event.
=item C<Int()> $.send_event: C<True> if the event was sent explicitly.
=item N-GObject $.area: bounding box of I<region>.
=item cairo_region_t $.region: the region that needs to be redrawn.
=item ___count: the number of contiguous C<GDK_EXPOSE> events following this one. The only use for this is “exposure compression”, i.e. handling all contiguous C<GDK_EXPOSE> events in one go, though GDK performs some exposure compression so this is not normally needed.

=end pod

# TT:0:N-GdkEventExpose:
class N-GdkEventExpose is export is repr('CStruct') {
  has GEnum $.type;
  has N-GObject $.window;
  has gint8 $.send_event;
  has N-GObject $.area;
  has cairo_region_t $.region;
}
}}

#`{{   Deprecated: 3.12
#-------------------------------------------------------------------------------
=begin pod
=head2 class N-GdkEventVisibility

Generated when the window visibility status has changed.

Deprecated: 3.12: Modern composited windowing systems with pervasive transparency make it impossible to track the visibility of a window reliably, so this event can not be guaranteed to provide useful information.

=item GdkEventType $.type: the type of the event (C<GDK_VISIBILITY_NOTIFY>).
=item N-GObject $.window: the window which received the event.
=item C<Int()> $.send_event: C<True> if the event was sent explicitly.
=item GdkVisibilityState $.state: the new visibility state (C<GDK_VISIBILITY_FULLY_OBSCURED>, C<GDK_VISIBILITY_PARTIAL> or C<GDK_VISIBILITY_UNOBSCURED>).

=end pod

# TT:0:N-GdkEventVisibility:
class N-GdkEventVisibility is export is repr('CStruct') {
  has GEnum $.type;
  has N-GObject $.window;
  has gint8 $.send_event;
  has GEnum $.state;
}
}}

#-------------------------------------------------------------------------------
=begin pod
=head2 class N-GdkEventMotion

Generated when the pointer moves.

=item GdkEventType $.type: the type of the event.
=item N-GObject $.window: the window which received the event.
=item C<Int()> $.send_event: C<True> if the event was sent explicitly.
=item UInt $.time: the time of the event in milliseconds.
=item C<Num()> $.x: the x coordinate of the pointer relative to the window.
=item C<Num()> $.y: the y coordinate of the pointer relative to the window.
=item C<Num()> $.axes: I<x>, I<y> translated to the axes of I<device>, or C<undefined> if I<device> is the mouse.
=item UInt $.state: (type GdkModifierType): a bit-mask representing the state of the modifier keys (e.g. Control, Shift and Alt) and the pointer buttons. See B<Gnome::Gdk3::ModifierType>.
=item C<Int()> $.is_hint: set to 1 if this event is just a hint, see the C<GDK_POINTER_MOTION_HINT_MASK> value of B<Gnome::Gdk3::EventMask>.
=item N-GObject $.device: the master device that the event originated from. Use C<gdk_event_get_source_device()> to get the slave device.
=item C<Num()> $.x_root: the x coordinate of the pointer relative to the root of the screen.
=item C<Num()> $.y_root: the y coordinate of the pointer relative to the root of the screen.

=end pod

#TT:1:N-GdkEventMotion:
class N-GdkEventMotion is export is repr('CStruct') {
  has GEnum $.type;
  has N-GObject $.window;
  has gint8 $.send_event;
  has guint32 $.time;
  has gdouble $.x;
  has gdouble $.y;
  has gdouble $.axes;
  has guint $.state;
  has gint16 $.is_hint;
  has N-GObject $.device;
  has gdouble $.x_root;
  has gdouble $.y_root;

  submethod BUILD (
    Int:D :$type, Int() :$time, Num() :$x, Num() :$y, Num() :$axes,
    UInt() :$state, Bool :$is_hint, Num() :$x_root, Num() :$y_root
  ) {
    $!type = $type.value;
    $!send_event = 1;
    $!time = $time // time;

    $!x = $x // 0e0;
    $!y = $y // 0e0;
    $!axes = $axes // 0e0;
    $!state = $state // 0;
    $!is_hint = $is_hint ?? 1 !! 0;
    $!x_root = $x_root // 0e0;
    $!y_root = $y_root  // 0e0;
  }

  submethod TWEAK ( N-GObject() :$window, N-GObject() :$device ) {
    $!window := $window if ?$window;
    $!device := $device if ?$device;
  }

  method COERCE ( $no --> N-GdkEventMotion ) {
    note "Coercing from {$no.^name} to ", self.^name if $Gnome::N::x-debug;
    nativecast( N-GdkEventMotion, $no)
  }
}

#-------------------------------------------------------------------------------
=begin pod
=head2 class N-GdkEventButton

Used for button press and button release events. The I<type> field will be one of C<GDK_BUTTON_PRESS>, C<GDK_2BUTTON_PRESS>, C<GDK_3BUTTON_PRESS> or C<GDK_BUTTON_RELEASE>,

Double and triple-clicks result in a sequence of events being received. For double-clicks the order of events will be:

- C<GDK_BUTTON_PRESS>
- C<GDK_BUTTON_RELEASE>
- C<GDK_BUTTON_PRESS>
- C<GDK_2BUTTON_PRESS>
- C<GDK_BUTTON_RELEASE>

Note that the first click is received just like a normal button press, while the second click results in a C<GDK_2BUTTON_PRESS> being received just after the C<GDK_BUTTON_PRESS>.

Triple-clicks are very similar to double-clicks, except that C<GDK_3BUTTON_PRESS> is inserted after the third click. The order of the events is:

- C<GDK_BUTTON_PRESS>
- C<GDK_BUTTON_RELEASE>
- C<GDK_BUTTON_PRESS>
- C<GDK_2BUTTON_PRESS>
- C<GDK_BUTTON_RELEASE>
- C<GDK_BUTTON_PRESS>
- C<GDK_3BUTTON_PRESS>
- C<GDK_BUTTON_RELEASE>

For a double click to occur, the second button press must occur within 1/4 of a second of the first. For a triple click to occur, the third button press must also occur within 1/2 second of the first button press.

=item C<GdkEventType> $.type: the type of the event (C<GDK_BUTTON_PRESS>, C<GDK_2BUTTON_PRESS>, C<GDK_3BUTTON_PRESS> or C<GDK_BUTTON_RELEASE>).
=item C<N-GObject> $.window: the window which received the event.
=item C<Int()> $.send_event: C<True> if the event was sent explicitly.
=item C<UInt> $.time: the time of the event in milliseconds.
=item C<Num()> $.x: the x coordinate of the pointer relative to the window.
=item C<Num()> $.y: the y coordinate of the pointer relative to the window.
=item C<Num()> $.axes: I<x>, I<y> translated to the axes of I<device>, or C<undefined> if I<device> is the mouse.
=item C<UInt> $.state: (type GdkModifierType): a bit-mask representing the state of the modifier keys (e.g. Control, Shift and Alt) and the pointer buttons. See B<Gnome::Gdk3::ModifierType>.
=item C<UInt> $.button: the button which was pressed or released, numbered from 1 to 5. Normally button 1 is the left mouse button, 2 is the middle button, and 3 is the right button. On 2-button mice, the middle button can often be simulated by pressing both mouse buttons together.
=item C<N-GObject> $.device: the master device that the event originated from. Use C<gdk_event_get_source_device()> to get the slave device.
=item C<Num()> $.x_root: the x coordinate of the pointer relative to the root of the screen.
=item C<Num()> $.y_root: the y coordinate of the pointer relative to the root of the screen.

=end pod

#TT:1:N-GdkEventButton:
class N-GdkEventButton is export is repr('CStruct') {
  has GEnum $.type;
  has N-GObject $.window;
  has gint8 $.send_event;
  has guint32 $.time;
  has gdouble $.x;
  has gdouble $.y;
  has gdouble $.axes;
  has guint $.state;
  has guint $.button;
  has N-GObject $.device;
  has gdouble $.x_root;
  has gdouble $.y_root;

  submethod BUILD (
    Int:D :$type, Int() :$time,
    Num() :$x, Num() :$y, Num() :$axes,
    UInt() :$state, UInt() :$button,
    Num() :$x_root, Num():$y_root
  ) {
    $!type = $type.value;
    $!send_event = 1;
    $!time = $time // time;
    $!x = $x // 0e0;
    $!y = $y // 0e0;
    $!axes = $axes // 0e0;
    $!state = $state // 0;
    $!button = $button // 0;
    $!x_root = $x_root // 0e0;
    $!y_root = $y_root // 0e0;
  }

  submethod TWEAK ( N-GObject() :$window, N-GObject() :$device ) {
    $!window := $window if ?$window;
    $!device := $device if ?$device;
  }

  method COERCE ( $no --> N-GdkEventButton ) {
    note "Coercing from {$no.^name} to ", self.^name if $Gnome::N::x-debug;
    nativecast( N-GdkEventButton, $no)
  }
}

#`{{
#-------------------------------------------------------------------------------
=begin pod
=head2 class N-GdkEventTouch

Used for touch events.
I<type> field will be one of C<GDK_TOUCH_BEGIN>, C<GDK_TOUCH_UPDATE>,
C<GDK_TOUCH_END> or C<GDK_TOUCH_CANCEL>.

Touch events are grouped into sequences by means of the I<sequence>
field, which can also be obtained with C<gdk_event_get_event_sequence()>.
Each sequence begins with a C<GDK_TOUCH_BEGIN> event, followed by
any number of C<GDK_TOUCH_UPDATE> events, and ends with a C<GDK_TOUCH_END>
(or C<GDK_TOUCH_CANCEL>) event. With multitouch devices, there may be
several active sequences at the same time.


=item GdkEventType $.type: the type of the event (C<GDK_TOUCH_BEGIN>, C<GDK_TOUCH_UPDATE>, C<GDK_TOUCH_END>, C<GDK_TOUCH_CANCEL>)
=item N-GObject $.window: the window which received the event
=item C<Int()> $.send_event: C<True> if the event was sent explicitly.
=item UInt $.time: the time of the event in milliseconds.
=item C<Num()> $.x: the x coordinate of the pointer relative to the window
=item C<Num()> $.y: the y coordinate of the pointer relative to the window
=item C<Num()> $.axes: I<x>, I<y> translated to the axes of I<device>, or C<undefined> if I<device> is the mouse
=item UInt $.state: (type GdkModifierType): a bit-mask representing the state of the modifier keys (e.g. Control, Shift and Alt) and the pointer buttons. See B<Gnome::Gdk3::ModifierType>
=item GdkEventSequence $.sequence: the event sequence that the event belongs to
=item Bool $.emulating_pointer: whether the event should be used for emulating pointer event
=item N-GObject $.device: the master device that the event originated from. Use C<gdk_event_get_source_device()> to get the slave device.
=item C<Num()> $.x_root: the x coordinate of the pointer relative to the root of the screen
=item C<Num()> $.y_root: the y coordinate of the pointer relative to the root of the screen


=end pod

#TT:0:N-GdkEventTouch:
class N-GdkEventTouch is export is repr('CStruct') {
  has GEnum $.type;
  has N-GObject $.window;
  has gint8 $.send_event;
  has guint32 $.time;
  has gdouble $.x;
  has gdouble $.y;
  has gdouble $.axes;
  has guint $.state;
  has GdkEventSequence $.sequence;
  has gboolean $.emulating_pointer;
  has N-GObject $.device;
  has gdouble $.x_root;
  has gdouble $.y_root;
}
}}

#-------------------------------------------------------------------------------
=begin pod
=head2 class N-GdkEventScroll

Generated from button presses for the buttons 4 to 7. Wheel mice are
usually configured to generate button press events for buttons 4 and 5
when the wheel is turned.

Some GDK backends can also generate “smooth” scroll events, which
can be recognized by the C<GDK_SCROLL_SMOOTH> scroll direction. For
these, the scroll deltas can be obtained with
C<gdk_event_get_scroll_deltas()>.


=item GdkEventType $.type: the type of the event (C<GDK_SCROLL>).
=item N-GObject $.window: the window which received the event.
=item C<Int()> $.send_event: C<True> if the event was sent explicitly.
=item UInt $.time: the time of the event in milliseconds.
=item C<Num()> $.x: the x coordinate of the pointer relative to the window.
=item C<Num()> $.y: the y coordinate of the pointer relative to the window.
=item UInt $.state: (type GdkModifierType): a