{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)

'GI.Gtk.Objects.Gesture.Gesture' is the base object for gesture recognition, although this
object is quite generalized to serve as a base for multi-touch gestures,
it is suitable to implement single-touch and pointer-based gestures (using
the special 'Nothing' 'GI.Gdk.Structs.EventSequence.EventSequence' value for these).

The number of touches that a 'GI.Gtk.Objects.Gesture.Gesture' need to be recognized is controlled
by the 'GI.Gtk.Objects.Gesture.Gesture':@/n-points/@ property, if a gesture is keeping track of less
or more than that number of sequences, it won\'t check wether the gesture
is recognized.

As soon as the gesture has the expected number of touches, the gesture will
run the 'GI.Gtk.Objects.Gesture.Gesture'::@/check/@ signal regularly on input events until the gesture
is recognized, the criteria to consider a gesture as \"recognized\" is left to
'GI.Gtk.Objects.Gesture.Gesture' subclasses.

A recognized gesture will then emit the following signals:

* 'GI.Gtk.Objects.Gesture.Gesture'::@/begin/@ when the gesture is recognized.
* A number of 'GI.Gtk.Objects.Gesture.Gesture'::@/update/@, whenever an input event is processed.
* 'GI.Gtk.Objects.Gesture.Gesture'::@/end/@ when the gesture is no longer recognized.


== Event propagation

In order to receive events, a gesture needs to either set a propagation phase
through 'GI.Gtk.Objects.EventController.eventControllerSetPropagationPhase', or feed those manually
through 'GI.Gtk.Objects.EventController.eventControllerHandleEvent'.

In the capture phase, events are propagated from the toplevel down to the
target widget, and gestures that are attached to containers above the widget
get a chance to interact with the event before it reaches the target.

After the capture phase, GTK+ emits the traditional 'GI.Gtk.Objects.Widget.Widget'::@/button-press-event/@,
'GI.Gtk.Objects.Widget.Widget'::@/button-release-event/@, 'GI.Gtk.Objects.Widget.Widget'::@/touch-event/@, etc signals. Gestures
with the 'GI.Gtk.Enums.PropagationPhaseTarget' phase are fed events from the default 'GI.Gtk.Objects.Widget.Widget'::@/event/@
handlers.

In the bubble phase, events are propagated up from the target widget to the
toplevel, and gestures that are attached to containers above the widget get
a chance to interact with events that have not been handled yet.

## States of a sequence # {@/touch/@-sequence-states}

Whenever input interaction happens, a single event may trigger a cascade of
@/GtkGestures/@, both across the parents of the widget receiving the event and
in parallel within an individual widget. It is a responsibility of the
widgets using those gestures to set the state of touch sequences accordingly
in order to enable cooperation of gestures around the @/GdkEventSequences/@
triggering those.

Within a widget, gestures can be grouped through 'GI.Gtk.Objects.Gesture.gestureGroup',
grouped gestures synchronize the state of sequences, so calling
'GI.Gtk.Objects.Gesture.gestureSetSequenceState' on one will effectively propagate
the state throughout the group.

By default, all sequences start out in the @/GTK_EVENT_SEQUENCE_NONE/@ state,
sequences in this state trigger the gesture event handler, but event
propagation will continue unstopped by gestures.

If a sequence enters into the @/GTK_EVENT_SEQUENCE_DENIED/@ state, the gesture
group will effectively ignore the sequence, letting events go unstopped
through the gesture, but the \"slot\" will still remain occupied while
the touch is active.

If a sequence enters in the @/GTK_EVENT_SEQUENCE_CLAIMED/@ state, the gesture
group will grab all interaction on the sequence, by:

* Setting the same sequence to @/GTK_EVENT_SEQUENCE_DENIED/@ on every other gesture
group within the widget, and every gesture on parent widgets in the propagation
chain.
* calling 'GI.Gtk.Objects.Gesture.Gesture'::@/cancel/@ on every gesture in widgets underneath in the
propagation chain.
* Stopping event propagation after the gesture group handles the event.


Note: if a sequence is set early to @/GTK_EVENT_SEQUENCE_CLAIMED/@ on
@/GDK_TOUCH_BEGIN/@\/@/GDK_BUTTON_PRESS/@ (so those events are captured before
reaching the event widget, this implies @/GTK_PHASE_CAPTURE/@), one similar
event will emulated if the sequence changes to @/GTK_EVENT_SEQUENCE_DENIED/@.
This way event coherence is preserved before event propagation is unstopped
again.

Sequence states can\'t be changed freely, see 'GI.Gtk.Objects.Gesture.gestureSetSequenceState'
to know about the possible lifetimes of a 'GI.Gdk.Structs.EventSequence.EventSequence'.

== Touchpad gestures

On the platforms that support it, 'GI.Gtk.Objects.Gesture.Gesture' will handle transparently
touchpad gesture events. The only precautions users of 'GI.Gtk.Objects.Gesture.Gesture' should do
to enable this support are:

* Enabling 'GI.Gdk.Flags.EventMaskTouchpadGestureMask' on their @/GdkWindows/@
* If the gesture has 'GI.Gtk.Enums.PropagationPhaseNone', ensuring events of type
'GI.Gdk.Enums.EventTypeTouchpadSwipe' and 'GI.Gdk.Enums.EventTypeTouchpadPinch' are handled by the 'GI.Gtk.Objects.Gesture.Gesture'

-}

module GI.Gtk.Objects.Gesture
    ( 

-- * Exported types
    Gesture(..)                             ,
    IsGesture                               ,
    toGesture                               ,
    noGesture                               ,


 -- * Methods
-- ** getBoundingBox #method:getBoundingBox#
    GestureGetBoundingBoxMethodInfo         ,
    gestureGetBoundingBox                   ,


-- ** getBoundingBoxCenter #method:getBoundingBoxCenter#
    GestureGetBoundingBoxCenterMethodInfo   ,
    gestureGetBoundingBoxCenter             ,


-- ** getDevice #method:getDevice#
    GestureGetDeviceMethodInfo              ,
    gestureGetDevice                        ,


-- ** getGroup #method:getGroup#
    GestureGetGroupMethodInfo               ,
    gestureGetGroup                         ,


-- ** getLastEvent #method:getLastEvent#
    GestureGetLastEventMethodInfo           ,
    gestureGetLastEvent                     ,


-- ** getLastUpdatedSequence #method:getLastUpdatedSequence#
    GestureGetLastUpdatedSequenceMethodInfo ,
    gestureGetLastUpdatedSequence           ,


-- ** getPoint #method:getPoint#
    GestureGetPointMethodInfo               ,
    gestureGetPoint                         ,


-- ** getSequenceState #method:getSequenceState#
    GestureGetSequenceStateMethodInfo       ,
    gestureGetSequenceState                 ,


-- ** getSequences #method:getSequences#
    GestureGetSequencesMethodInfo           ,
    gestureGetSequences                     ,


-- ** getWindow #method:getWindow#
    GestureGetWindowMethodInfo              ,
    gestureGetWindow                        ,


-- ** group #method:group#
    GestureGroupMethodInfo                  ,
    gestureGroup                            ,


-- ** handlesSequence #method:handlesSequence#
    GestureHandlesSequenceMethodInfo        ,
    gestureHandlesSequence                  ,


-- ** isActive #method:isActive#
    GestureIsActiveMethodInfo               ,
    gestureIsActive                         ,


-- ** isGroupedWith #method:isGroupedWith#
    GestureIsGroupedWithMethodInfo          ,
    gestureIsGroupedWith                    ,


-- ** isRecognized #method:isRecognized#
    GestureIsRecognizedMethodInfo           ,
    gestureIsRecognized                     ,


-- ** setSequenceState #method:setSequenceState#
    GestureSetSequenceStateMethodInfo       ,
    gestureSetSequenceState                 ,


-- ** setState #method:setState#
    GestureSetStateMethodInfo               ,
    gestureSetState                         ,


-- ** setWindow #method:setWindow#
    GestureSetWindowMethodInfo              ,
    gestureSetWindow                        ,


-- ** ungroup #method:ungroup#
    GestureUngroupMethodInfo                ,
    gestureUngroup                          ,




 -- * Properties
-- ** nPoints #attr:nPoints#
    GestureNPointsPropertyInfo              ,
    constructGestureNPoints                 ,
    gestureNPoints                          ,
    getGestureNPoints                       ,


-- ** window #attr:window#
    GestureWindowPropertyInfo               ,
    clearGestureWindow                      ,
    constructGestureWindow                  ,
    gestureWindow                           ,
    getGestureWindow                        ,
    setGestureWindow                        ,




 -- * Signals
-- ** begin #signal:begin#
    C_GestureBeginCallback                  ,
    GestureBeginCallback                    ,
    GestureBeginSignalInfo                  ,
    afterGestureBegin                       ,
    genClosure_GestureBegin                 ,
    mk_GestureBeginCallback                 ,
    noGestureBeginCallback                  ,
    onGestureBegin                          ,
    wrap_GestureBeginCallback               ,


-- ** cancel #signal:cancel#
    C_GestureCancelCallback                 ,
    GestureCancelCallback                   ,
    GestureCancelSignalInfo                 ,
    afterGestureCancel                      ,
    genClosure_GestureCancel                ,
    mk_GestureCancelCallback                ,
    noGestureCancelCallback                 ,
    onGestureCancel                         ,
    wrap_GestureCancelCallback              ,


-- ** end #signal:end#
    C_GestureEndCallback                    ,
    GestureEndCallback                      ,
    GestureEndSignalInfo                    ,
    afterGestureEnd                         ,
    genClosure_GestureEnd                   ,
    mk_GestureEndCallback                   ,
    noGestureEndCallback                    ,
    onGestureEnd                            ,
    wrap_GestureEndCallback                 ,


-- ** sequenceStateChanged #signal:sequenceStateChanged#
    C_GestureSequenceStateChangedCallback   ,
    GestureSequenceStateChangedCallback     ,
    GestureSequenceStateChangedSignalInfo   ,
    afterGestureSequenceStateChanged        ,
    genClosure_GestureSequenceStateChanged  ,
    mk_GestureSequenceStateChangedCallback  ,
    noGestureSequenceStateChangedCallback   ,
    onGestureSequenceStateChanged           ,
    wrap_GestureSequenceStateChangedCallback,


-- ** update #signal:update#
    C_GestureUpdateCallback                 ,
    GestureUpdateCallback                   ,
    GestureUpdateSignalInfo                 ,
    afterGestureUpdate                      ,
    genClosure_GestureUpdate                ,
    mk_GestureUpdateCallback                ,
    noGestureUpdateCallback                 ,
    onGestureUpdate                         ,
    wrap_GestureUpdateCallback              ,




    ) where

import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP

import qualified GI.GObject.Objects.Object as GObject.Object
import qualified GI.Gdk.Objects.Device as Gdk.Device
import qualified GI.Gdk.Objects.Window as Gdk.Window
import qualified GI.Gdk.Structs.EventSequence as Gdk.EventSequence
import qualified GI.Gdk.Structs.Rectangle as Gdk.Rectangle
import qualified GI.Gdk.Unions.Event as Gdk.Event
import {-# SOURCE #-} qualified GI.Gtk.Enums as Gtk.Enums
import {-# SOURCE #-} qualified GI.Gtk.Objects.EventController as Gtk.EventController

newtype Gesture = Gesture (ManagedPtr Gesture)
foreign import ccall "gtk_gesture_get_type"
    c_gtk_gesture_get_type :: IO GType

instance GObject Gesture where
    gobjectType _ = c_gtk_gesture_get_type
    

class GObject o => IsGesture o
#if MIN_VERSION_base(4,9,0)
instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError Gesture a) =>
    IsGesture a
#endif
instance IsGesture Gesture
instance Gtk.EventController.IsEventController Gesture
instance GObject.Object.IsObject Gesture

toGesture :: IsGesture o => o -> IO Gesture
toGesture = unsafeCastTo Gesture

noGesture :: Maybe Gesture
noGesture = Nothing

type family ResolveGestureMethod (t :: Symbol) (o :: *) :: * where
    ResolveGestureMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveGestureMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveGestureMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveGestureMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveGestureMethod "group" o = GestureGroupMethodInfo
    ResolveGestureMethod "handleEvent" o = Gtk.EventController.EventControllerHandleEventMethodInfo
    ResolveGestureMethod "handlesSequence" o = GestureHandlesSequenceMethodInfo
    ResolveGestureMethod "isActive" o = GestureIsActiveMethodInfo
    ResolveGestureMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveGestureMethod "isGroupedWith" o = GestureIsGroupedWithMethodInfo
    ResolveGestureMethod "isRecognized" o = GestureIsRecognizedMethodInfo
    ResolveGestureMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveGestureMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveGestureMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveGestureMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveGestureMethod "replaceData" o = GObject.Object.ObjectReplaceDataMethodInfo
    ResolveGestureMethod "replaceQdata" o = GObject.Object.ObjectReplaceQdataMethodInfo
    ResolveGestureMethod "reset" o = Gtk.EventController.EventControllerResetMethodInfo
    ResolveGestureMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveGestureMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveGestureMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveGestureMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveGestureMethod "ungroup" o = GestureUngroupMethodInfo
    ResolveGestureMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveGestureMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveGestureMethod "getBoundingBox" o = GestureGetBoundingBoxMethodInfo
    ResolveGestureMethod "getBoundingBoxCenter" o = GestureGetBoundingBoxCenterMethodInfo
    ResolveGestureMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveGestureMethod "getDevice" o = GestureGetDeviceMethodInfo
    ResolveGestureMethod "getGroup" o = GestureGetGroupMethodInfo
    ResolveGestureMethod "getLastEvent" o = GestureGetLastEventMethodInfo
    ResolveGestureMethod "getLastUpdatedSequence" o = GestureGetLastUpdatedSequenceMethodInfo
    ResolveGestureMethod "getPoint" o = GestureGetPointMethodInfo
    ResolveGestureMethod "getPropagationPhase" o = Gtk.EventController.EventControllerGetPropagationPhaseMethodInfo
    ResolveGestureMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveGestureMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveGestureMethod "getSequenceState" o = GestureGetSequenceStateMethodInfo
    ResolveGestureMethod "getSequences" o = GestureGetSequencesMethodInfo
    ResolveGestureMethod "getWidget" o = Gtk.EventController.EventControllerGetWidgetMethodInfo
    ResolveGestureMethod "getWindow" o = GestureGetWindowMethodInfo
    ResolveGestureMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveGestureMethod "setPropagationPhase" o = Gtk.EventController.EventControllerSetPropagationPhaseMethodInfo
    ResolveGestureMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveGestureMethod "setSequenceState" o = GestureSetSequenceStateMethodInfo
    ResolveGestureMethod "setState" o = GestureSetStateMethodInfo
    ResolveGestureMethod "setWindow" o = GestureSetWindowMethodInfo
    ResolveGestureMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveGestureMethod t Gesture, O.MethodInfo info Gesture p) => O.IsLabelProxy t (Gesture -> p) where
    fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveGestureMethod t Gesture, O.MethodInfo info Gesture p) => O.IsLabel t (Gesture -> p) where
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif

-- signal Gesture::begin
type GestureBeginCallback =
    Gdk.EventSequence.EventSequence ->
    IO ()

noGestureBeginCallback :: Maybe GestureBeginCallback
noGestureBeginCallback = Nothing

type C_GestureBeginCallback =
    Ptr () ->                               -- object
    Ptr Gdk.EventSequence.EventSequence ->
    Ptr () ->                               -- user_data
    IO ()

foreign import ccall "wrapper"
    mk_GestureBeginCallback :: C_GestureBeginCallback -> IO (FunPtr C_GestureBeginCallback)

genClosure_GestureBegin :: GestureBeginCallback -> IO Closure
genClosure_GestureBegin cb = do
    let cb' = wrap_GestureBeginCallback cb
    mk_GestureBeginCallback cb' >>= newCClosure


wrap_GestureBeginCallback ::
    GestureBeginCallback ->
    Ptr () ->
    Ptr Gdk.EventSequence.EventSequence ->
    Ptr () ->
    IO ()
wrap_GestureBeginCallback _cb _ sequence _ = do
    sequence' <- (newBoxed Gdk.EventSequence.EventSequence) sequence
    _cb  sequence'


onGestureBegin :: (GObject a, MonadIO m) => a -> GestureBeginCallback -> m SignalHandlerId
onGestureBegin obj cb = liftIO $ connectGestureBegin obj cb SignalConnectBefore
afterGestureBegin :: (GObject a, MonadIO m) => a -> GestureBeginCallback -> m SignalHandlerId
afterGestureBegin obj cb = connectGestureBegin obj cb SignalConnectAfter

connectGestureBegin :: (GObject a, MonadIO m) =>
                       a -> GestureBeginCallback -> SignalConnectMode -> m SignalHandlerId
connectGestureBegin obj cb after = liftIO $ do
    let cb' = wrap_GestureBeginCallback cb
    cb'' <- mk_GestureBeginCallback cb'
    connectSignalFunPtr obj "begin" cb'' after

-- signal Gesture::cancel
type GestureCancelCallback =
    Gdk.EventSequence.EventSequence ->
    IO ()

noGestureCancelCallback :: Maybe GestureCancelCallback
noGestureCancelCallback = Nothing

type C_GestureCancelCallback =
    Ptr () ->                               -- object
    Ptr Gdk.EventSequence.EventSequence ->
    Ptr () ->                               -- user_data
    IO ()

foreign import ccall "wrapper"
    mk_GestureCancelCallback :: C_GestureCancelCallback -> IO (FunPtr C_GestureCancelCallback)

genClosure_GestureCancel :: GestureCancelCallback -> IO Closure
genClosure_GestureCancel cb = do
    let cb' = wrap_GestureCancelCallback cb
    mk_GestureCancelCallback cb' >>= newCClosure


wrap_GestureCancelCallback ::
    GestureCancelCallback ->
    Ptr () ->
    Ptr Gdk.EventSequence.EventSequence ->
    Ptr () ->
    IO ()
wrap_GestureCancelCallback _cb _ sequence _ = do
    sequence' <- (newBoxed Gdk.EventSequence.EventSequence) sequence
    _cb  sequence'


onGestureCancel :: (GObject a, MonadIO m) => a -> GestureCancelCallback -> m SignalHandlerId
onGestureCancel obj cb = liftIO $ connectGestureCancel obj cb SignalConnectBefore
afterGestureCancel :: (GObject a, MonadIO m) => a -> GestureCancelCallback -> m SignalHandlerId
afterGestureCancel obj cb = connectGestureCancel obj cb SignalConnectAfter

connectGestureCancel :: (GObject a, MonadIO m) =>
                        a -> GestureCancelCallback -> SignalConnectMode -> m SignalHandlerId
connectGestureCancel obj cb after = liftIO $ do
    let cb' = wrap_GestureCancelCallback cb
    cb'' <- mk_GestureCancelCallback cb'
    connectSignalFunPtr obj "cancel" cb'' after

-- signal Gesture::end
type GestureEndCallback =
    Gdk.EventSequence.EventSequence ->
    IO ()

noGestureEndCallback :: Maybe GestureEndCallback
noGestureEndCallback = Nothing

type C_GestureEndCallback =
    Ptr () ->                               -- object
    Ptr Gdk.EventSequence.EventSequence ->
    Ptr () ->                               -- user_data
    IO ()

foreign import ccall "wrapper"
    mk_GestureEndCallback :: C_GestureEndCallback -> IO (FunPtr C_GestureEndCallback)

genClosure_GestureEnd :: GestureEndCallback -> IO Closure
genClosure_GestureEnd cb = do
    let cb' = wrap_GestureEndCallback cb
    mk_GestureEndCallback cb' >>= newCClosure


wrap_GestureEndCallback ::
    GestureEndCallback ->
    Ptr () ->
    Ptr Gdk.EventSequence.EventSequence ->
    Ptr () ->
    IO ()
wrap_GestureEndCallback _cb _ sequence _ = do
    sequence' <- (newBoxed Gdk.EventSequence.EventSequence) sequence
    _cb  sequence'


onGestureEnd :: (GObject a, MonadIO m) => a -> GestureEndCallback -> m SignalHandlerId
onGestureEnd obj cb = liftIO $ connectGestureEnd obj cb SignalConnectBefore
afterGestureEnd :: (GObject a, MonadIO m) => a -> GestureEndCallback -> m SignalHandlerId
afterGestureEnd obj cb = connectGestureEnd obj cb SignalConnectAfter

connectGestureEnd :: (GObject a, MonadIO m) =>
                     a -> GestureEndCallback -> SignalConnectMode -> m SignalHandlerId
connectGestureEnd obj cb after = liftIO $ do
    let cb' = wrap_GestureEndCallback cb
    cb'' <- mk_GestureEndCallback cb'
    connectSignalFunPtr obj "end" cb'' after

-- signal Gesture::sequence-state-changed
type GestureSequenceStateChangedCallback =
    Gdk.EventSequence.EventSequence ->
    Gtk.Enums.EventSequenceState ->
    IO ()

noGestureSequenceStateChangedCallback :: Maybe GestureSequenceStateChangedCallback
noGestureSequenceStateChangedCallback = Nothing

type C_GestureSequenceStateChangedCallback =
    Ptr () ->                               -- object
    Ptr Gdk.EventSequence.EventSequence ->
    CUInt ->
    Ptr () ->                               -- user_data
    IO ()

foreign import ccall "wrapper"
    mk_GestureSequenceStateChangedCallback :: C_GestureSequenceStateChangedCallback -> IO (FunPtr C_GestureSequenceStateChangedCallback)

genClosure_GestureSequenceStateChanged :: GestureSequenceStateChangedCallback -> IO Closure
genClosure_GestureSequenceStateChanged cb = do
    let cb' = wrap_GestureSequenceStateChangedCallback cb
    mk_GestureSequenceStateChangedCallback cb' >>= newCClosure


wrap_GestureSequenceStateChangedCallback ::
    GestureSequenceStateChangedCallback ->
    Ptr () ->
    Ptr Gdk.EventSequence.EventSequence ->
    CUInt ->
    Ptr () ->
    IO ()
wrap_GestureSequenceStateChangedCallback _cb _ sequence state _ = do
    sequence' <- (newBoxed Gdk.EventSequence.EventSequence) sequence
    let state' = (toEnum . fromIntegral) state
    _cb  sequence' state'


onGestureSequenceStateChanged :: (GObject a, MonadIO m) => a -> GestureSequenceStateChangedCallback -> m SignalHandlerId
onGestureSequenceStateChanged obj cb = liftIO $ connectGestureSequenceStateChanged obj cb SignalConnectBefore
afterGestureSequenceStateChanged :: (GObject a, MonadIO m) => a -> GestureSequenceStateChangedCallback -> m SignalHandlerId
afterGestureSequenceStateChanged obj cb = connectGestureSequenceStateChanged obj cb SignalConnectAfter

connectGestureSequenceStateChanged :: (GObject a, MonadIO m) =>
                                      a -> GestureSequenceStateChangedCallback -> SignalConnectMode -> m SignalHandlerId
connectGestureSequenceStateChanged obj cb after = liftIO $ do
    let cb' = wrap_GestureSequenceStateChangedCallback cb
    cb'' <- mk_GestureSequenceStateChangedCallback cb'
    connectSignalFunPtr obj "sequence-state-changed" cb'' after

-- signal Gesture::update
type GestureUpdateCallback =
    Gdk.EventSequence.EventSequence ->
    IO ()

noGestureUpdateCallback :: Maybe GestureUpdateCallback
noGestureUpdateCallback = Nothing

type C_GestureUpdateCallback =
    Ptr () ->                               -- object
    Ptr Gdk.EventSequence.EventSequence ->
    Ptr () ->                               -- user_data
    IO ()

foreign import ccall "wrapper"
    mk_GestureUpdateCallback :: C_GestureUpdateCallback -> IO (FunPtr C_GestureUpdateCallback)

genClosure_GestureUpdate :: GestureUpdateCallback -> IO Closure
genClosure_GestureUpdate cb = do
    let cb' = wrap_GestureUpdateCallback cb
    mk_GestureUpdateCallback cb' >>= newCClosure


wrap_GestureUpdateCallback ::
    GestureUpdateCallback ->
    Ptr () ->
    Ptr Gdk.EventSequence.EventSequence ->
    Ptr () ->
    IO ()
wrap_GestureUpdateCallback _cb _ sequence _ = do
    sequence' <- (newBoxed Gdk.EventSequence.EventSequence) sequence
    _cb  sequence'


onGestureUpdate :: (GObject a, MonadIO m) => a -> GestureUpdateCallback -> m SignalHandlerId
onGestureUpdate obj cb = liftIO $ connectGestureUpdate obj cb SignalConnectBefore
afterGestureUpdate :: (GObject a, MonadIO m) => a -> GestureUpdateCallback -> m SignalHandlerId
afterGestureUpdate obj cb = connectGestureUpdate obj cb SignalConnectAfter

connectGestureUpdate :: (GObject a, MonadIO m) =>
                        a -> GestureUpdateCallback -> SignalConnectMode -> m SignalHandlerId
connectGestureUpdate obj cb after = liftIO $ do
    let cb' = wrap_GestureUpdateCallback cb
    cb'' <- mk_GestureUpdateCallback cb'
    connectSignalFunPtr obj "update" cb'' after

-- VVV Prop "n-points"
   -- Type: TBasicType TUInt
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Nothing,Nothing)

getGestureNPoints :: (MonadIO m, IsGesture o) => o -> m Word32
getGestureNPoints obj = liftIO $ getObjectPropertyUInt32 obj "n-points"

constructGestureNPoints :: (IsGesture o) => Word32 -> IO (GValueConstruct o)
constructGestureNPoints val = constructObjectPropertyUInt32 "n-points" val

data GestureNPointsPropertyInfo
instance AttrInfo GestureNPointsPropertyInfo where
    type AttrAllowedOps GestureNPointsPropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint GestureNPointsPropertyInfo = (~) Word32
    type AttrBaseTypeConstraint GestureNPointsPropertyInfo = IsGesture
    type AttrGetType GestureNPointsPropertyInfo = Word32
    type AttrLabel GestureNPointsPropertyInfo = "n-points"
    type AttrOrigin GestureNPointsPropertyInfo = Gesture
    attrGet _ = getGestureNPoints
    attrSet _ = undefined
    attrConstruct _ = constructGestureNPoints
    attrClear _ = undefined

-- VVV Prop "window"
   -- Type: TInterface (Name {namespace = "Gdk", name = "Window"})
   -- Flags: [PropertyReadable,PropertyWritable]
   -- Nullable: (Just True,Just True)

getGestureWindow :: (MonadIO m, IsGesture o) => o -> m (Maybe Gdk.Window.Window)
getGestureWindow obj = liftIO $ getObjectPropertyObject obj "window" Gdk.Window.Window

setGestureWindow :: (MonadIO m, IsGesture o, Gdk.Window.IsWindow a) => o -> a -> m ()
setGestureWindow obj val = liftIO $ setObjectPropertyObject obj "window" (Just val)

constructGestureWindow :: (IsGesture o, Gdk.Window.IsWindow a) => a -> IO (GValueConstruct o)
constructGestureWindow val = constructObjectPropertyObject "window" (Just val)

clearGestureWindow :: (MonadIO m, IsGesture o) => o -> m ()
clearGestureWindow obj = liftIO $ setObjectPropertyObject obj "window" (Nothing :: Maybe Gdk.Window.Window)

data GestureWindowPropertyInfo
instance AttrInfo GestureWindowPropertyInfo where
    type AttrAllowedOps GestureWindowPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint GestureWindowPropertyInfo = Gdk.Window.IsWindow
    type AttrBaseTypeConstraint GestureWindowPropertyInfo = IsGesture
    type AttrGetType GestureWindowPropertyInfo = (Maybe Gdk.Window.Window)
    type AttrLabel GestureWindowPropertyInfo = "window"
    type AttrOrigin GestureWindowPropertyInfo = Gesture
    attrGet _ = getGestureWindow
    attrSet _ = setGestureWindow
    attrConstruct _ = constructGestureWindow
    attrClear _ = clearGestureWindow

instance O.HasAttributeList Gesture
type instance O.AttributeList Gesture = GestureAttributeList
type GestureAttributeList = ('[ '("nPoints", GestureNPointsPropertyInfo), '("propagationPhase", Gtk.EventController.EventControllerPropagationPhasePropertyInfo), '("widget", Gtk.EventController.EventControllerWidgetPropertyInfo), '("window", GestureWindowPropertyInfo)] :: [(Symbol, *)])

gestureNPoints :: AttrLabelProxy "nPoints"
gestureNPoints = AttrLabelProxy

gestureWindow :: AttrLabelProxy "window"
gestureWindow = AttrLabelProxy

data GestureBeginSignalInfo
instance SignalInfo GestureBeginSignalInfo where
    type HaskellCallbackType GestureBeginSignalInfo = GestureBeginCallback
    connectSignal _ = connectGestureBegin

data GestureCancelSignalInfo
instance SignalInfo GestureCancelSignalInfo where
    type HaskellCallbackType GestureCancelSignalInfo = GestureCancelCallback
    connectSignal _ = connectGestureCancel

data GestureEndSignalInfo
instance SignalInfo GestureEndSignalInfo where
    type HaskellCallbackType GestureEndSignalInfo = GestureEndCallback
    connectSignal _ = connectGestureEnd

data GestureSequenceStateChangedSignalInfo
instance SignalInfo GestureSequenceStateChangedSignalInfo where
    type HaskellCallbackType GestureSequenceStateChangedSignalInfo = GestureSequenceStateChangedCallback
    connectSignal _ = connectGestureSequenceStateChanged

data GestureUpdateSignalInfo
instance SignalInfo GestureUpdateSignalInfo where
    type HaskellCallbackType GestureUpdateSignalInfo = GestureUpdateCallback
    connectSignal _ = connectGestureUpdate

type instance O.SignalList Gesture = GestureSignalList
type GestureSignalList = ('[ '("begin", GestureBeginSignalInfo), '("cancel", GestureCancelSignalInfo), '("end", GestureEndSignalInfo), '("notify", GObject.Object.ObjectNotifySignalInfo), '("sequenceStateChanged", GestureSequenceStateChangedSignalInfo), '("update", GestureUpdateSignalInfo)] :: [(Symbol, *)])

-- method Gesture::get_bounding_box
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "gesture", argType = TInterface (Name {namespace = "Gtk", name = "Gesture"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkGesture", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "rect", argType = TInterface (Name {namespace = "Gdk", name = "Rectangle"}), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "bounding box containing all active touches.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = True, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gtk_gesture_get_bounding_box" gtk_gesture_get_bounding_box :: 
    Ptr Gesture ->                          -- gesture : TInterface (Name {namespace = "Gtk", name = "Gesture"})
    Ptr Gdk.Rectangle.Rectangle ->          -- rect : TInterface (Name {namespace = "Gdk", name = "Rectangle"})
    IO CInt

{- |
If there are touch sequences being currently handled by /@gesture@/,
this function returns 'True' and fills in /@rect@/ with the bounding
box containing all active touches. Otherwise, 'False' will be
returned.

Note: This function will yield unexpected results on touchpad
gestures. Since there is no correlation between physical and
pixel distances, these will look as if constrained in an
infinitely small area, /@rect@/ width and height will thus be 0
regardless of the number of touchpoints.

@since 3.14
-}
gestureGetBoundingBox ::
    (B.CallStack.HasCallStack, MonadIO m, IsGesture a) =>
    a
    {- ^ /@gesture@/: a 'GI.Gtk.Objects.Gesture.Gesture' -}
    -> m (Bool,Gdk.Rectangle.Rectangle)
    {- ^ __Returns:__ 'True' if there are active touches, 'False' otherwise -}
gestureGetBoundingBox gesture = liftIO $ do
    gesture' <- unsafeManagedPtrCastPtr gesture
    rect <- callocBoxedBytes 16 :: IO (Ptr Gdk.Rectangle.Rectangle)
    result <- gtk_gesture_get_bounding_box gesture' rect
    let result' = (/= 0) result
    rect' <- (wrapBoxed Gdk.Rectangle.Rectangle) rect
    touchManagedPtr gesture
    return (result', rect')

data GestureGetBoundingBoxMethodInfo
instance (signature ~ (m (Bool,Gdk.Rectangle.Rectangle)), MonadIO m, IsGesture a) => O.MethodInfo GestureGetBoundingBoxMethodInfo a signature where
    overloadedMethod _ = gestureGetBoundingBox

-- method Gesture::get_bounding_box_center
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "gesture", argType = TInterface (Name {namespace = "Gtk", name = "Gesture"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkGesture", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "x", argType = TBasicType TDouble, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "X coordinate for the bounding box center", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "y", argType = TBasicType TDouble, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Y coordinate for the bounding box center", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gtk_gesture_get_bounding_box_center" gtk_gesture_get_bounding_box_center :: 
    Ptr Gesture ->                          -- gesture : TInterface (Name {namespace = "Gtk", name = "Gesture"})
    Ptr CDouble ->                          -- x : TBasicType TDouble
    Ptr CDouble ->                          -- y : TBasicType TDouble
    IO CInt

{- |
If there are touch sequences being currently handled by /@gesture@/,
this function returns 'True' and fills in /@x@/ and /@y@/ with the center
of the bounding box containing all active touches. Otherwise, 'False'
will be returned.

@since 3.14
-}
gestureGetBoundingBoxCenter ::
    (B.CallStack.HasCallStack, MonadIO m, IsGesture a) =>
    a
    {- ^ /@gesture@/: a 'GI.Gtk.Objects.Gesture.Gesture' -}
    -> m (Bool,Double,Double)
    {- ^ __Returns:__ 'False' if no active touches are present, 'True' otherwise -}
gestureGetBoundingBoxCenter gesture = liftIO $ do
    gesture' <- unsafeManagedPtrCastPtr gesture
    x <- allocMem :: IO (Ptr CDouble)
    y <- allocMem :: IO (Ptr CDouble)
    result <- gtk_gesture_get_bounding_box_center gesture' x y
    let result' = (/= 0) result
    x' <- peek x
    let x'' = realToFrac x'
    y' <- peek y
    let y'' = realToFrac y'
    touchManagedPtr gesture
    freeMem x
    freeMem y
    return (result', x'', y'')

data GestureGetBoundingBoxCenterMethodInfo
instance (signature ~ (m (Bool,Double,Double)), MonadIO m, IsGesture a) => O.MethodInfo GestureGetBoundingBoxCenterMethodInfo a signature where
    overloadedMethod _ = gestureGetBoundingBoxCenter

-- method Gesture::get_device
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "gesture", argType = TInterface (Name {namespace = "Gtk", name = "Gesture"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkGesture", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gdk", name = "Device"}))
-- throws : False
-- Skip return : False

foreign import ccall "gtk_gesture_get_device" gtk_gesture_get_device :: 
    Ptr Gesture ->                          -- gesture : TInterface (Name {namespace = "Gtk", name = "Gesture"})
    IO (Ptr Gdk.Device.Device)

{- |
Returns the master 'GI.Gdk.Objects.Device.Device' that is currently operating
on /@gesture@/, or 'Nothing' if the gesture is not being interacted.

@since 3.14
-}
gestureGetDevice ::
    (B.CallStack.HasCallStack, MonadIO m, IsGesture a) =>
    a
    {- ^ /@gesture@/: a 'GI.Gtk.Objects.Gesture.Gesture' -}
    -> m (Maybe Gdk.Device.Device)
    {- ^ __Returns:__ a 'GI.Gdk.Objects.Device.Device', or 'Nothing' -}
gestureGetDevice gesture = liftIO $ do
    gesture' <- unsafeManagedPtrCastPtr gesture
    result <- gtk_gesture_get_device gesture'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (newObject Gdk.Device.Device) result'
        return result''
    touchManagedPtr gesture
    return maybeResult

data GestureGetDeviceMethodInfo
instance (signature ~ (m (Maybe Gdk.Device.Device)), MonadIO m, IsGesture a) => O.MethodInfo GestureGetDeviceMethodInfo a signature where
    overloadedMethod _ = gestureGetDevice

-- method Gesture::get_group
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "gesture", argType = TInterface (Name {namespace = "Gtk", name = "Gesture"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkGesture", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TGList (TInterface (Name {namespace = "Gtk", name = "Gesture"})))
-- throws : False
-- Skip return : False

foreign import ccall "gtk_gesture_get_group" gtk_gesture_get_group :: 
    Ptr Gesture ->                          -- gesture : TInterface (Name {namespace = "Gtk", name = "Gesture"})
    IO (Ptr (GList (Ptr Gesture)))

{- |
Returns all gestures in the group of /@gesture@/

@since 3.14
-}
gestureGetGroup ::
    (B.CallStack.HasCallStack, MonadIO m, IsGesture a) =>
    a
    {- ^ /@gesture@/: a 'GI.Gtk.Objects.Gesture.Gesture' -}
    -> m [Gesture]
    {- ^ __Returns:__ The list
  of @/GtkGestures/@, free with @/g_list_free()/@ -}
gestureGetGroup gesture = liftIO $ do
    gesture' <- unsafeManagedPtrCastPtr gesture
    result <- gtk_gesture_get_group gesture'
    result' <- unpackGList result
    result'' <- mapM (newObject Gesture) result'
    g_list_free result
    touchManagedPtr gesture
    return result''

data GestureGetGroupMethodInfo
instance (signature ~ (m [Gesture]), MonadIO m, IsGesture a) => O.MethodInfo GestureGetGroupMethodInfo a signature where
    overloadedMethod _ = gestureGetGroup

-- method Gesture::get_last_event
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "gesture", argType = TInterface (Name {namespace = "Gtk", name = "Gesture"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkGesture", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "sequence", argType = TInterface (Name {namespace = "Gdk", name = "EventSequence"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GdkEventSequence", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gdk", name = "Event"}))
-- throws : False
-- Skip return : False

foreign import ccall "gtk_gesture_get_last_event" gtk_gesture_get_last_event :: 
    Ptr Gesture ->                          -- gesture : TInterface (Name {namespace = "Gtk", name = "Gesture"})
    Ptr Gdk.EventSequence.EventSequence ->  -- sequence : TInterface (Name {namespace = "Gdk", name = "EventSequence"})
    IO (Ptr Gdk.Event.Event)

{- |
Returns the last event that was processed for /@sequence@/.

Note that the returned pointer is only valid as long as the /@sequence@/
is still interpreted by the /@gesture@/. If in doubt, you should make
a copy of the event.
-}
gestureGetLastEvent ::
    (B.CallStack.HasCallStack, MonadIO m, IsGesture a) =>
    a
    {- ^ /@gesture@/: a 'GI.Gtk.Objects.Gesture.Gesture' -}
    -> Gdk.EventSequence.EventSequence
    {- ^ /@sequence@/: a 'GI.Gdk.Structs.EventSequence.EventSequence' -}
    -> m (Maybe Gdk.Event.Event)
    {- ^ __Returns:__ The last event from /@sequence@/ -}
gestureGetLastEvent gesture sequence = liftIO $ do
    gesture' <- unsafeManagedPtrCastPtr gesture
    sequence' <- unsafeManagedPtrGetPtr sequence
    result <- gtk_gesture_get_last_event gesture' sequence'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (newBoxed Gdk.Event.Event) result'
        return result''
    touchManagedPtr gesture
    touchManagedPtr sequence
    return maybeResult

data GestureGetLastEventMethodInfo
instance (signature ~ (Gdk.EventSequence.EventSequence -> m (Maybe Gdk.Event.Event)), MonadIO m, IsGesture a) => O.MethodInfo GestureGetLastEventMethodInfo a signature where
    overloadedMethod _ = gestureGetLastEvent

-- method Gesture::get_last_updated_sequence
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "gesture", argType = TInterface (Name {namespace = "Gtk", name = "Gesture"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkGesture", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gdk", name = "EventSequence"}))
-- throws : False
-- Skip return : False

foreign import ccall "gtk_gesture_get_last_updated_sequence" gtk_gesture_get_last_updated_sequence :: 
    Ptr Gesture ->                          -- gesture : TInterface (Name {namespace = "Gtk", name = "Gesture"})
    IO (Ptr Gdk.EventSequence.EventSequence)

{- |
Returns the 'GI.Gdk.Structs.EventSequence.EventSequence' that was last updated on /@gesture@/.

@since 3.14
-}
gestureGetLastUpdatedSequence ::
    (B.CallStack.HasCallStack, MonadIO m, IsGesture a) =>
    a
    {- ^ /@gesture@/: a 'GI.Gtk.Objects.Gesture.Gesture' -}
    -> m (Maybe Gdk.EventSequence.EventSequence)
    {- ^ __Returns:__ The last updated sequence -}
gestureGetLastUpdatedSequence gesture = liftIO $ do
    gesture' <- unsafeManagedPtrCastPtr gesture
    result <- gtk_gesture_get_last_updated_sequence gesture'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (newBoxed Gdk.EventSequence.EventSequence) result'
        return result''
    touchManagedPtr gesture
    return maybeResult

data GestureGetLastUpdatedSequenceMethodInfo
instance (signature ~ (m (Maybe Gdk.EventSequence.EventSequence)), MonadIO m, IsGesture a) => O.MethodInfo GestureGetLastUpdatedSequenceMethodInfo a signature where
    overloadedMethod _ = gestureGetLastUpdatedSequence

-- method Gesture::get_point
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "gesture", argType = TInterface (Name {namespace = "Gtk", name = "Gesture"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkGesture", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "sequence", argType = TInterface (Name {namespace = "Gdk", name = "EventSequence"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GdkEventSequence, or %NULL for pointer events", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "x", argType = TBasicType TDouble, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for X axis of the sequence coordinates", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "y", argType = TBasicType TDouble, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for Y axis of the sequence coordinates", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gtk_gesture_get_point" gtk_gesture_get_point :: 
    Ptr Gesture ->                          -- gesture : TInterface (Name {namespace = "Gtk", name = "Gesture"})
    Ptr Gdk.EventSequence.EventSequence ->  -- sequence : TInterface (Name {namespace = "Gdk", name = "EventSequence"})
    Ptr CDouble ->                          -- x : TBasicType TDouble
    Ptr CDouble ->                          -- y : TBasicType TDouble
    IO CInt

{- |
If /@sequence@/ is currently being interpreted by /@gesture@/, this
function returns 'True' and fills in /@x@/ and /@y@/ with the last coordinates
stored for that event sequence. The coordinates are always relative to the
widget allocation.

@since 3.14
-}
gestureGetPoint ::
    (B.CallStack.HasCallStack, MonadIO m, IsGesture a) =>
    a
    {- ^ /@gesture@/: a 'GI.Gtk.Objects.Gesture.Gesture' -}
    -> Maybe (Gdk.EventSequence.EventSequence)
    {- ^ /@sequence@/: a 'GI.Gdk.Structs.EventSequence.EventSequence', or 'Nothing' for pointer events -}
    -> m (Bool,Double,Double)
    {- ^ __Returns:__ 'True' if /@sequence@/ is currently interpreted -}
gestureGetPoint gesture sequence = liftIO $ do
    gesture' <- unsafeManagedPtrCastPtr gesture
    maybeSequence <- case sequence of
        Nothing -> return nullPtr
        Just jSequence -> do
            jSequence' <- unsafeManagedPtrGetPtr jSequence
            return jSequence'
    x <- allocMem :: IO (Ptr CDouble)
    y <- allocMem :: IO (Ptr CDouble)
    result <- gtk_gesture_get_point gesture' maybeSequence x y
    let result' = (/= 0) result
    x' <- peek x
    let x'' = realToFrac x'
    y' <- peek y
    let y'' = realToFrac y'
    touchManagedPtr gesture
    whenJust sequence touchManagedPtr
    freeMem x
    freeMem y
    return (result', x'', y'')

data GestureGetPointMethodInfo
instance (signature ~ (Maybe (Gdk.EventSequence.EventSequence) -> m (Bool,Double,Double)), MonadIO m, IsGesture a) => O.MethodInfo GestureGetPointMethodInfo a signature where
    overloadedMethod _ = gestureGetPoint

-- method Gesture::get_sequence_state
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "gesture", argType = TInterface (Name {namespace = "Gtk", name = "Gesture"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkGesture", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "sequence", argType = TInterface (Name {namespace = "Gdk", name = "EventSequence"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GdkEventSequence", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gtk", name = "EventSequenceState"}))
-- throws : False
-- Skip return : False

foreign import ccall "gtk_gesture_get_sequence_state" gtk_gesture_get_sequence_state :: 
    Ptr Gesture ->                          -- gesture : TInterface (Name {namespace = "Gtk", name = "Gesture"})
    Ptr Gdk.EventSequence.EventSequence ->  -- sequence : TInterface (Name {namespace = "Gdk", name = "EventSequence"})
    IO CUInt

{- |
Returns the /@sequence@/ state, as seen by /@gesture@/.

@since 3.14
-}
gestureGetSequenceState ::
    (B.CallStack.HasCallStack, MonadIO m, IsGesture a) =>
    a
    {- ^ /@gesture@/: a 'GI.Gtk.Objects.Gesture.Gesture' -}
    -> Gdk.EventSequence.EventSequence
    {- ^ /@sequence@/: a 'GI.Gdk.Structs.EventSequence.EventSequence' -}
    -> m Gtk.Enums.EventSequenceState
    {- ^ __Returns:__ The sequence state in /@gesture@/ -}
gestureGetSequenceState gesture sequence = liftIO $ do
    gesture' <- unsafeManagedPtrCastPtr gesture
    sequence' <- unsafeManagedPtrGetPtr sequence
    result <- gtk_gesture_get_sequence_state gesture' sequence'
    let result' = (toEnum . fromIntegral) result
    touchManagedPtr gesture
    touchManagedPtr sequence
    return result'

data GestureGetSequenceStateMethodInfo
instance (signature ~ (Gdk.EventSequence.EventSequence -> m Gtk.Enums.EventSequenceState), MonadIO m, IsGesture a) => O.MethodInfo GestureGetSequenceStateMethodInfo a signature where
    overloadedMethod _ = gestureGetSequenceState

-- method Gesture::get_sequences
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "gesture", argType = TInterface (Name {namespace = "Gtk", name = "Gesture"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkGesture", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TGList (TInterface (Name {namespace = "Gdk", name = "EventSequence"})))
-- throws : False
-- Skip return : False

foreign import ccall "gtk_gesture_get_sequences" gtk_gesture_get_sequences :: 
    Ptr Gesture ->                          -- gesture : TInterface (Name {namespace = "Gtk", name = "Gesture"})
    IO (Ptr (GList (Ptr Gdk.EventSequence.EventSequence)))

{- |
Returns the list of @/GdkEventSequences/@ currently being interpreted
by /@gesture@/.

@since 3.14
-}
gestureGetSequences ::
    (B.CallStack.HasCallStack, MonadIO m, IsGesture a) =>
    a
    {- ^ /@gesture@/: a 'GI.Gtk.Objects.Gesture.Gesture' -}
    -> m [Gdk.EventSequence.EventSequence]
    {- ^ __Returns:__ A list
         of @/GdkEventSequences/@, the list elements are owned by GTK+
         and must not be freed or modified, the list itself must be deleted
         through @/g_list_free()/@ -}
gestureGetSequences gesture = liftIO $ do
    gesture' <- unsafeManagedPtrCastPtr gesture
    result <- gtk_gesture_get_sequences gesture'
    result' <- unpackGList result
    result'' <- mapM (newBoxed Gdk.EventSequence.EventSequence) result'
    g_list_free result
    touchManagedPtr gesture
    return result''

data GestureGetSequencesMethodInfo
instance (signature ~ (m [Gdk.EventSequence.EventSequence]), MonadIO m, IsGesture a) => O.MethodInfo GestureGetSequencesMethodInfo a signature where
    overloadedMethod _ = gestureGetSequences

-- method Gesture::get_window
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "gesture", argType = TInterface (Name {namespace = "Gtk", name = "Gesture"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkGesture", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gdk", name = "Window"}))
-- throws : False
-- Skip return : False

foreign import ccall "gtk_gesture_get_window" gtk_gesture_get_window :: 
    Ptr Gesture ->                          -- gesture : TInterface (Name {namespace = "Gtk", name = "Gesture"})
    IO (Ptr Gdk.Window.Window)

{- |
Returns the user-defined window that receives the events
handled by /@gesture@/. See 'GI.Gtk.Objects.Gesture.gestureSetWindow' for more
information.

@since 3.14
-}
gestureGetWindow ::
    (B.CallStack.HasCallStack, MonadIO m, IsGesture a) =>
    a
    {- ^ /@gesture@/: a 'GI.Gtk.Objects.Gesture.Gesture' -}
    -> m (Maybe Gdk.Window.Window)
    {- ^ __Returns:__ the user defined window, or 'Nothing' if none -}
gestureGetWindow gesture = liftIO $ do
    gesture' <- unsafeManagedPtrCastPtr gesture
    result <- gtk_gesture_get_window gesture'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (newObject Gdk.Window.Window) result'
        return result''
    touchManagedPtr gesture
    return maybeResult

data GestureGetWindowMethodInfo
instance (signature ~ (m (Maybe Gdk.Window.Window)), MonadIO m, IsGesture a) => O.MethodInfo GestureGetWindowMethodInfo a signature where
    overloadedMethod _ = gestureGetWindow

-- method Gesture::group
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "group_gesture", argType = TInterface (Name {namespace = "Gtk", name = "Gesture"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "#GtkGesture to group @gesture with", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "gesture", argType = TInterface (Name {namespace = "Gtk", name = "Gesture"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkGesture", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gtk_gesture_group" gtk_gesture_group :: 
    Ptr Gesture ->                          -- group_gesture : TInterface (Name {namespace = "Gtk", name = "Gesture"})
    Ptr Gesture ->                          -- gesture : TInterface (Name {namespace = "Gtk", name = "Gesture"})
    IO ()

{- |
Adds /@gesture@/ to the same group than /@groupGesture@/. Gestures
are by default isolated in their own groups.

When gestures are grouped, the state of @/GdkEventSequences/@
is kept in sync for all of those, so calling 'GI.Gtk.Objects.Gesture.gestureSetSequenceState',
on one will transfer the same value to the others.

Groups also perform an \"implicit grabbing\" of sequences, if a
'GI.Gdk.Structs.EventSequence.EventSequence' state is set to @/GTK_EVENT_SEQUENCE_CLAIMED/@ on one group,
every other gesture group attached to the same 'GI.Gtk.Objects.Widget.Widget' will switch the
state for that sequence to @/GTK_EVENT_SEQUENCE_DENIED/@.

@since 3.14
-}
gestureGroup ::
    (B.CallStack.HasCallStack, MonadIO m, IsGesture a, IsGesture b) =>
    a
    {- ^ /@groupGesture@/: 'GI.Gtk.Objects.Gesture.Gesture' to group /@gesture@/ with -}
    -> b
    {- ^ /@gesture@/: a 'GI.Gtk.Objects.Gesture.Gesture' -}
    -> m ()
gestureGroup groupGesture gesture = liftIO $ do
    groupGesture' <- unsafeManagedPtrCastPtr groupGesture
    gesture' <- unsafeManagedPtrCastPtr gesture
    gtk_gesture_group groupGesture' gesture'
    touchManagedPtr groupGesture
    touchManagedPtr gesture
    return ()

data GestureGroupMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsGesture a, IsGesture b) => O.MethodInfo GestureGroupMethodInfo a signature where
    overloadedMethod _ = gestureGroup

-- method Gesture::handles_sequence
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "gesture", argType = TInterface (Name {namespace = "Gtk", name = "Gesture"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkGesture", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "sequence", argType = TInterface (Name {namespace = "Gdk", name = "EventSequence"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GdkEventSequence", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gtk_gesture_handles_sequence" gtk_gesture_handles_sequence :: 
    Ptr Gesture ->                          -- gesture : TInterface (Name {namespace = "Gtk", name = "Gesture"})
    Ptr Gdk.EventSequence.EventSequence ->  -- sequence : TInterface (Name {namespace = "Gdk", name = "EventSequence"})
    IO CInt

{- |
Returns 'True' if /@gesture@/ is currently handling events corresponding to
/@sequence@/.

@since 3.14
-}
gestureHandlesSequence ::
    (B.CallStack.HasCallStack, MonadIO m, IsGesture a) =>
    a
    {- ^ /@gesture@/: a 'GI.Gtk.Objects.Gesture.Gesture' -}
    -> Gdk.EventSequence.EventSequence
    {- ^ /@sequence@/: a 'GI.Gdk.Structs.EventSequence.EventSequence' -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@gesture@/ is handling /@sequence@/ -}
gestureHandlesSequence gesture sequence = liftIO $ do
    gesture' <- unsafeManagedPtrCastPtr gesture
    sequence' <- unsafeManagedPtrGetPtr sequence
    result <- gtk_gesture_handles_sequence gesture' sequence'
    let result' = (/= 0) result
    touchManagedPtr gesture
    touchManagedPtr sequence
    return result'

data GestureHandlesSequenceMethodInfo
instance (signature ~ (Gdk.EventSequence.EventSequence -> m Bool), MonadIO m, IsGesture a) => O.MethodInfo GestureHandlesSequenceMethodInfo a signature where
    overloadedMethod _ = gestureHandlesSequence

-- method Gesture::is_active
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "gesture", argType = TInterface (Name {namespace = "Gtk", name = "Gesture"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkGesture", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gtk_gesture_is_active" gtk_gesture_is_active :: 
    Ptr Gesture ->                          -- gesture : TInterface (Name {namespace = "Gtk", name = "Gesture"})
    IO CInt

{- |
Returns 'True' if the gesture is currently active.
A gesture is active meanwhile there are touch sequences
interacting with it.

@since 3.14
-}
gestureIsActive ::
    (B.CallStack.HasCallStack, MonadIO m, IsGesture a) =>
    a
    {- ^ /@gesture@/: a 'GI.Gtk.Objects.Gesture.Gesture' -}
    -> m Bool
    {- ^ __Returns:__ 'True' if gesture is active -}
gestureIsActive gesture = liftIO $ do
    gesture' <- unsafeManagedPtrCastPtr gesture
    result <- gtk_gesture_is_active gesture'
    let result' = (/= 0) result
    touchManagedPtr gesture
    return result'

data GestureIsActiveMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsGesture a) => O.MethodInfo GestureIsActiveMethodInfo a signature where
    overloadedMethod _ = gestureIsActive

-- method Gesture::is_grouped_with
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "gesture", argType = TInterface (Name {namespace = "Gtk", name = "Gesture"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkGesture", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "other", argType = TInterface (Name {namespace = "Gtk", name = "Gesture"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "another #GtkGesture", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gtk_gesture_is_grouped_with" gtk_gesture_is_grouped_with :: 
    Ptr Gesture ->                          -- gesture : TInterface (Name {namespace = "Gtk", name = "Gesture"})
    Ptr Gesture ->                          -- other : TInterface (Name {namespace = "Gtk", name = "Gesture"})
    IO CInt

{- |
Returns 'True' if both gestures pertain to the same group.

@since 3.14
-}
gestureIsGroupedWith ::
    (B.CallStack.HasCallStack, MonadIO m, IsGesture a, IsGesture b) =>
    a
    {- ^ /@gesture@/: a 'GI.Gtk.Objects.Gesture.Gesture' -}
    -> b
    {- ^ /@other@/: another 'GI.Gtk.Objects.Gesture.Gesture' -}
    -> m Bool
    {- ^ __Returns:__ whether the gestures are grouped -}
gestureIsGroupedWith gesture other = liftIO $ do
    gesture' <- unsafeManagedPtrCastPtr gesture
    other' <- unsafeManagedPtrCastPtr other
    result <- gtk_gesture_is_grouped_with gesture' other'
    let result' = (/= 0) result
    touchManagedPtr gesture
    touchManagedPtr other
    return result'

data GestureIsGroupedWithMethodInfo
instance (signature ~ (b -> m Bool), MonadIO m, IsGesture a, IsGesture b) => O.MethodInfo GestureIsGroupedWithMethodInfo a signature where
    overloadedMethod _ = gestureIsGroupedWith

-- method Gesture::is_recognized
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "gesture", argType = TInterface (Name {namespace = "Gtk", name = "Gesture"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkGesture", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gtk_gesture_is_recognized" gtk_gesture_is_recognized :: 
    Ptr Gesture ->                          -- gesture : TInterface (Name {namespace = "Gtk", name = "Gesture"})
    IO CInt

{- |
Returns 'True' if the gesture is currently recognized.
A gesture is recognized if there are as many interacting
touch sequences as required by /@gesture@/, and 'GI.Gtk.Objects.Gesture.Gesture'::@/check/@
returned 'True' for the sequences being currently interpreted.

@since 3.14
-}
gestureIsRecognized ::
    (B.CallStack.HasCallStack, MonadIO m, IsGesture a) =>
    a
    {- ^ /@gesture@/: a 'GI.Gtk.Objects.Gesture.Gesture' -}
    -> m Bool
    {- ^ __Returns:__ 'True' if gesture is recognized -}
gestureIsRecognized gesture = liftIO $ do
    gesture' <- unsafeManagedPtrCastPtr gesture
    result <- gtk_gesture_is_recognized gesture'
    let result' = (/= 0) result
    touchManagedPtr gesture
    return result'

data GestureIsRecognizedMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsGesture a) => O.MethodInfo GestureIsRecognizedMethodInfo a signature where
    overloadedMethod _ = gestureIsRecognized

-- method Gesture::set_sequence_state
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "gesture", argType = TInterface (Name {namespace = "Gtk", name = "Gesture"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkGesture", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "sequence", argType = TInterface (Name {namespace = "Gdk", name = "EventSequence"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GdkEventSequence", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "state", argType = TInterface (Name {namespace = "Gtk", name = "EventSequenceState"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the sequence state", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gtk_gesture_set_sequence_state" gtk_gesture_set_sequence_state :: 
    Ptr Gesture ->                          -- gesture : TInterface (Name {namespace = "Gtk", name = "Gesture"})
    Ptr Gdk.EventSequence.EventSequence ->  -- sequence : TInterface (Name {namespace = "Gdk", name = "EventSequence"})
    CUInt ->                                -- state : TInterface (Name {namespace = "Gtk", name = "EventSequenceState"})
    IO CInt

{- |
Sets the state of /@sequence@/ in /@gesture@/. Sequences start
in state @/GTK_EVENT_SEQUENCE_NONE/@, and whenever they change
state, they can never go back to that state. Likewise,
sequences in state @/GTK_EVENT_SEQUENCE_DENIED/@ cannot turn
back to a not denied state. With these rules, the lifetime
of an event sequence is constrained to the next four:

* None
* None → Denied
* None → Claimed
* None → Claimed → Denied

Note: Due to event handling ordering, it may be unsafe to
set the state on another gesture within a 'GI.Gtk.Objects.Gesture.Gesture'::@/begin/@
signal handler, as the callback might be executed before
the other gesture knows about the sequence. A safe way to
perform this could be:

>
>static void
>first_gesture_begin_cb (GtkGesture       *first_gesture,
>                        GdkEventSequence *sequence,
>                        gpointer          user_data)
>{
>  gtk_gesture_set_sequence_state (first_gesture, sequence, GTK_EVENT_SEQUENCE_ACCEPTED);
>  gtk_gesture_set_sequence_state (second_gesture, sequence, GTK_EVENT_SEQUENCE_DENIED);
>}
>
>static void
>second_gesture_begin_cb (GtkGesture       *second_gesture,
>                         GdkEventSequence *sequence,
>                         gpointer          user_data)
>{
>  if (gtk_gesture_get_sequence_state (first_gesture, sequence) == GTK_EVENT_SEQUENCE_ACCEPTED)
>    gtk_gesture_set_sequence_state (second_gesture, sequence, GTK_EVENT_SEQUENCE_DENIED);
>}


If both gestures are in the same group, just set the state on
the gesture emitting the event, the sequence will be already
be initialized to the group\'s global state when the second
gesture processes the event.

@since 3.14
-}
gestureSetSequenceState ::
    (B.CallStack.HasCallStack, MonadIO m, IsGesture a) =>
    a
    {- ^ /@gesture@/: a 'GI.Gtk.Objects.Gesture.Gesture' -}
    -> Gdk.EventSequence.EventSequence
    {- ^ /@sequence@/: a 'GI.Gdk.Structs.EventSequence.EventSequence' -}
    -> Gtk.Enums.EventSequenceState
    {- ^ /@state@/: the sequence state -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@sequence@/ is handled by /@gesture@/,
         and the state is changed successfully -}
gestureSetSequenceState gesture sequence state = liftIO $ do
    gesture' <- unsafeManagedPtrCastPtr gesture
    sequence' <- unsafeManagedPtrGetPtr sequence
    let state' = (fromIntegral . fromEnum) state
    result <- gtk_gesture_set_sequence_state gesture' sequence' state'
    let result' = (/= 0) result
    touchManagedPtr gesture
    touchManagedPtr sequence
    return result'

data GestureSetSequenceStateMethodInfo
instance (signature ~ (Gdk.EventSequence.EventSequence -> Gtk.Enums.EventSequenceState -> m Bool), MonadIO m, IsGesture a) => O.MethodInfo GestureSetSequenceStateMethodInfo a signature where
    overloadedMethod _ = gestureSetSequenceState

-- method Gesture::set_state
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "gesture", argType = TInterface (Name {namespace = "Gtk", name = "Gesture"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkGesture", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "state", argType = TInterface (Name {namespace = "Gtk", name = "EventSequenceState"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the sequence state", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gtk_gesture_set_state" gtk_gesture_set_state :: 
    Ptr Gesture ->                          -- gesture : TInterface (Name {namespace = "Gtk", name = "Gesture"})
    CUInt ->                                -- state : TInterface (Name {namespace = "Gtk", name = "EventSequenceState"})
    IO CInt

{- |
Sets the state of all sequences that /@gesture@/ is currently
interacting with. See 'GI.Gtk.Objects.Gesture.gestureSetSequenceState'
for more details on sequence states.

@since 3.14
-}
gestureSetState ::
    (B.CallStack.HasCallStack, MonadIO m, IsGesture a) =>
    a
    {- ^ /@gesture@/: a 'GI.Gtk.Objects.Gesture.Gesture' -}
    -> Gtk.Enums.EventSequenceState
    {- ^ /@state@/: the sequence state -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the state of at least one sequence
    was changed successfully -}
gestureSetState gesture state = liftIO $ do
    gesture' <- unsafeManagedPtrCastPtr gesture
    let state' = (fromIntegral . fromEnum) state
    result <- gtk_gesture_set_state gesture' state'
    let result' = (/= 0) result
    touchManagedPtr gesture
    return result'

data GestureSetStateMethodInfo
instance (signature ~ (Gtk.Enums.EventSequenceState -> m Bool), MonadIO m, IsGesture a) => O.MethodInfo GestureSetStateMethodInfo a signature where
    overloadedMethod _ = gestureSetState

-- method Gesture::set_window
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "gesture", argType = TInterface (Name {namespace = "Gtk", name = "Gesture"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkGesture", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "window", argType = TInterface (Name {namespace = "Gdk", name = "Window"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GdkWindow, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gtk_gesture_set_window" gtk_gesture_set_window :: 
    Ptr Gesture ->                          -- gesture : TInterface (Name {namespace = "Gtk", name = "Gesture"})
    Ptr Gdk.Window.Window ->                -- window : TInterface (Name {namespace = "Gdk", name = "Window"})
    IO ()

{- |
Sets a specific window to receive events about, so /@gesture@/
will effectively handle only events targeting /@window@/, or
a child of it. /@window@/ must pertain to 'GI.Gtk.Objects.EventController.eventControllerGetWidget'.

@since 3.14
-}
gestureSetWindow ::
    (B.CallStack.HasCallStack, MonadIO m, IsGesture a, Gdk.Window.IsWindow b) =>
    a
    {- ^ /@gesture@/: a 'GI.Gtk.Objects.Gesture.Gesture' -}
    -> Maybe (b)
    {- ^ /@window@/: a 'GI.Gdk.Objects.Window.Window', or 'Nothing' -}
    -> m ()
gestureSetWindow gesture window = liftIO $ do
    gesture' <- unsafeManagedPtrCastPtr gesture
    maybeWindow <- case window of
        Nothing -> return nullPtr
        Just jWindow -> do
            jWindow' <- unsafeManagedPtrCastPtr jWindow
            return jWindow'
    gtk_gesture_set_window gesture' maybeWindow
    touchManagedPtr gesture
    whenJust window touchManagedPtr
    return ()

data GestureSetWindowMethodInfo
instance (signature ~ (Maybe (b) -> m ()), MonadIO m, IsGesture a, Gdk.Window.IsWindow b) => O.MethodInfo GestureSetWindowMethodInfo a signature where
    overloadedMethod _ = gestureSetWindow

-- method Gesture::ungroup
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "gesture", argType = TInterface (Name {namespace = "Gtk", name = "Gesture"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkGesture", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gtk_gesture_ungroup" gtk_gesture_ungroup :: 
    Ptr Gesture ->                          -- gesture : TInterface (Name {namespace = "Gtk", name = "Gesture"})
    IO ()

{- |
Separates /@gesture@/ into an isolated group.

@since 3.14
-}
gestureUngroup ::
    (B.CallStack.HasCallStack, MonadIO m, IsGesture a) =>
    a
    {- ^ /@gesture@/: a 'GI.Gtk.Objects.Gesture.Gesture' -}
    -> m ()
gestureUngroup gesture = liftIO $ do
    gesture' <- unsafeManagedPtrCastPtr gesture
    gtk_gesture_ungroup gesture'
    touchManagedPtr gesture
    return ()

data GestureUngroupMethodInfo
instance (signature ~ (m ()), MonadIO m, IsGesture a) => O.MethodInfo GestureUngroupMethodInfo a signature where
    overloadedMethod _ = gestureUngroup