// Package gdk was automatically generated by github.com/bnema/puregotk DO NOT EDIT package gdk import ( "structs" "unsafe" "github.com/ebitengine/purego" "github.com/bnema/puregotk/pkg/core" "github.com/bnema/puregotk/v4/glib" "github.com/bnema/puregotk/v4/gobject" "github.com/bnema/puregotk/v4/gobject/types" "github.com/bnema/puregotk/v4/pango" ) // Stores a single event in a motion history. // // To check whether an axis is present, check whether the corresponding // flag from the [flags@Gdk.AxisFlags] enumeration is set in the @flags // To access individual axis values, use the values of the values of // the [enum@Gdk.AxisUse] enumerations as indices. type TimeCoord struct { _ structs.HostLayout Time uint32 Flags AxisFlags Axes [12]float64 } func (x *TimeCoord) GoPointer() uintptr { return uintptr(unsafe.Pointer(x)) } // An enumeration describing the type of an input device in general terms. type InputSource int var xInputSourceGLibType func() types.GType func InputSourceGLibType() types.GType { return xInputSourceGLibType() } const ( // the device is a mouse. (This will be reported for the core // pointer, even if it is something else, such as a trackball.) SourceMouseValue InputSource = 0 // the device is a stylus of a graphics tablet or similar device. SourcePenValue InputSource = 1 // the device is a keyboard. SourceKeyboardValue InputSource = 2 // the device is a direct-input touch device, such // as a touchscreen or tablet SourceTouchscreenValue InputSource = 3 // the device is an indirect touch device, such // as a touchpad SourceTouchpadValue InputSource = 4 // the device is a trackpoint SourceTrackpointValue InputSource = 5 // the device is a "pad", a collection of buttons, // rings and strips found in drawing tablets SourceTabletPadValue InputSource = 6 ) // Represents an input device, such as a keyboard, mouse or touchpad. // // See the [class@Gdk.Seat] documentation for more information // about the various kinds of devices, and their relationships. type Device struct { gobject.Object } var xDeviceGLibType func() types.GType func DeviceGLibType() types.GType { return xDeviceGLibType() } func DeviceNewFromInternalPtr(ptr uintptr) *Device { cls := &Device{} cls.Ptr = ptr return cls } var xDeviceGetActiveLayoutIndex func(uintptr) int // Retrieves the index of the active layout of the keyboard. // // If there is no valid active layout for the `GdkDevice`, this function will // return -1; // // This is only relevant for keyboard devices. func (x *Device) GetActiveLayoutIndex() int { cret := xDeviceGetActiveLayoutIndex(x.GoPointer()) return cret } var xDeviceGetCapsLockState func(uintptr) bool // Retrieves whether the Caps Lock modifier of the keyboard is locked. // // This is only relevant for keyboard devices. func (x *Device) GetCapsLockState() bool { cret := xDeviceGetCapsLockState(x.GoPointer()) return cret } var xDeviceGetDeviceTool func(uintptr) uintptr // Retrieves the current tool for @device. func (x *Device) GetDeviceTool() *DeviceTool { var cls *DeviceTool cret := xDeviceGetDeviceTool(x.GoPointer()) if cret == 0 { return nil } gobject.IncreaseRef(cret) cls = &DeviceTool{} cls.Ptr = cret return cls } var xDeviceGetDirection func(uintptr) pango.Direction // Returns the direction of effective layout of the keyboard. // // This is only relevant for keyboard devices. // // The direction of a layout is the direction of the majority // of its symbols. See [func@Pango.unichar_direction]. func (x *Device) GetDirection() pango.Direction { cret := xDeviceGetDirection(x.GoPointer()) return cret } var xDeviceGetDisplay func(uintptr) uintptr // Returns the `GdkDisplay` to which @device pertains. func (x *Device) GetDisplay() *Display { var cls *Display cret := xDeviceGetDisplay(x.GoPointer()) if cret == 0 { return nil } gobject.IncreaseRef(cret) cls = &Display{} cls.Ptr = cret return cls } var xDeviceGetHasCursor func(uintptr) bool // Determines whether the pointer follows device motion. // // This is not meaningful for keyboard devices, which // don't have a pointer. func (x *Device) GetHasCursor() bool { cret := xDeviceGetHasCursor(x.GoPointer()) return cret } var xDeviceGetLayoutNames func(uintptr) []string // Retrieves the names of the layouts of the keyboard. // // This is only relevant for keyboard devices. func (x *Device) GetLayoutNames() []string { cret := xDeviceGetLayoutNames(x.GoPointer()) return cret } var xDeviceGetModifierState func(uintptr) ModifierType // Retrieves the current modifier state of the keyboard. // // This is only relevant for keyboard devices. func (x *Device) GetModifierState() ModifierType { cret := xDeviceGetModifierState(x.GoPointer()) return cret } var xDeviceGetName func(uintptr) string // The name of the device, suitable for showing in a user interface. func (x *Device) GetName() string { cret := xDeviceGetName(x.GoPointer()) return cret } var xDeviceGetNumLockState func(uintptr) bool // Retrieves whether the Num Lock modifier of the keyboard is locked. // // This is only relevant for keyboard devices. func (x *Device) GetNumLockState() bool { cret := xDeviceGetNumLockState(x.GoPointer()) return cret } var xDeviceGetNumTouches func(uintptr) uint // Retrieves the number of touch points associated to @device. func (x *Device) GetNumTouches() uint { cret := xDeviceGetNumTouches(x.GoPointer()) return cret } var xDeviceGetProductId func(uintptr) string // Returns the product ID of this device. // // This ID is retrieved from the device, and does not change. // See [method@Gdk.Device.get_vendor_id] for more information. func (x *Device) GetProductId() string { cret := xDeviceGetProductId(x.GoPointer()) return cret } var xDeviceGetScrollLockState func(uintptr) bool // Retrieves whether the Scroll Lock modifier of the keyboard is locked. // // This is only relevant for keyboard devices. func (x *Device) GetScrollLockState() bool { cret := xDeviceGetScrollLockState(x.GoPointer()) return cret } var xDeviceGetSeat func(uintptr) uintptr // Returns the `GdkSeat` the device belongs to. func (x *Device) GetSeat() *Seat { var cls *Seat cret := xDeviceGetSeat(x.GoPointer()) if cret == 0 { return nil } gobject.IncreaseRef(cret) cls = &Seat{} cls.Ptr = cret return cls } var xDeviceGetSource func(uintptr) InputSource // Determines the type of the device. func (x *Device) GetSource() InputSource { cret := xDeviceGetSource(x.GoPointer()) return cret } var xDeviceGetSurfaceAtPosition func(uintptr, *float64, *float64) uintptr // Obtains the surface underneath @device, returning the location of the // device in @win_x and @win_y. // // Returns %NULL if the surface tree under @device is not known to GDK // (for example, belongs to another application). func (x *Device) GetSurfaceAtPosition(WinXVar *float64, WinYVar *float64) *Surface { var cls *Surface cret := xDeviceGetSurfaceAtPosition(x.GoPointer(), WinXVar, WinYVar) if cret == 0 { return nil } gobject.IncreaseRef(cret) cls = &Surface{} cls.Ptr = cret return cls } var xDeviceGetTimestamp func(uintptr) uint32 // Returns the timestamp of the last activity for this device. // // In practice, this means the timestamp of the last event that was // received from the OS for this device. (GTK may occasionally produce // events for a device that are not received from the OS, and will not // update the timestamp). func (x *Device) GetTimestamp() uint32 { cret := xDeviceGetTimestamp(x.GoPointer()) return cret } var xDeviceGetVendorId func(uintptr) string // Returns the vendor ID of this device. // // This ID is retrieved from the device, and does not change. // // This function, together with [method@Gdk.Device.get_product_id], // can be used to eg. compose `GSettings` paths to store settings // for this device. // // ```c // // static GSettings * // get_device_settings (GdkDevice *device) // { // const char *vendor, *product; // GSettings *settings; // GdkDevice *device; // char *path; // // vendor = gdk_device_get_vendor_id (device); // product = gdk_device_get_product_id (device); // // path = g_strdup_printf ("/org/example/app/devices/%s:%s/", vendor, product); // settings = g_settings_new_with_path (DEVICE_SCHEMA, path); // g_free (path); // // return settings; // } // // ``` func (x *Device) GetVendorId() string { cret := xDeviceGetVendorId(x.GoPointer()) return cret } var xDeviceHasBidiLayouts func(uintptr) bool // Determines if layouts for both right-to-left and // left-to-right languages are in use on the keyboard. // // This is only relevant for keyboard devices. func (x *Device) HasBidiLayouts() bool { cret := xDeviceHasBidiLayouts(x.GoPointer()) return cret } func (c *Device) GoPointer() uintptr { if c == nil { return 0 } return c.Ptr } func (c *Device) SetGoPointer(ptr uintptr) { c.Ptr = ptr } // GetPropertyActiveLayoutIndex gets the "active-layout-index" property. // The index of the keyboard active layout of a `GdkDevice`. // // Will be -1 if there is no valid active layout. // // This is only relevant for keyboard devices. func (x *Device) GetPropertyActiveLayoutIndex() int { var v gobject.Value x.GetProperty("active-layout-index", &v) return v.GetInt() } // GetPropertyCapsLockState gets the "caps-lock-state" property. // Whether Caps Lock is on. // // This is only relevant for keyboard devices. func (x *Device) GetPropertyCapsLockState() bool { var v gobject.Value x.GetProperty("caps-lock-state", &v) return v.GetBoolean() } // GetPropertyHasBidiLayouts gets the "has-bidi-layouts" property. // Whether the device has both right-to-left and left-to-right layouts. // // This is only relevant for keyboard devices. func (x *Device) GetPropertyHasBidiLayouts() bool { var v gobject.Value x.GetProperty("has-bidi-layouts", &v) return v.GetBoolean() } // SetPropertyHasCursor sets the "has-cursor" property. // Whether the device is represented by a cursor on the screen. func (x *Device) SetPropertyHasCursor(value bool) { var v gobject.Value v.Init(gobject.TypeBooleanVal) v.SetBoolean(value) x.SetProperty("has-cursor", &v) } // GetPropertyHasCursor gets the "has-cursor" property. // Whether the device is represented by a cursor on the screen. func (x *Device) GetPropertyHasCursor() bool { var v gobject.Value x.GetProperty("has-cursor", &v) return v.GetBoolean() } // GetPropertyLayoutNames gets the "layout-names" property. // The names of the keyboard layouts of a `GdkDevice`. // // This is only relevant for keyboard devices. func (x *Device) GetPropertyLayoutNames() []string { var v gobject.Value x.GetProperty("layout-names", &v) return core.GoStringSlice(v.GetBoxed()) } // GetPropertyNAxes gets the "n-axes" property. // Number of axes in the device. func (x *Device) GetPropertyNAxes() uint { var v gobject.Value x.GetProperty("n-axes", &v) return v.GetUint() } // SetPropertyName sets the "name" property. // The device name. func (x *Device) SetPropertyName(value string) { var v gobject.Value v.Init(gobject.TypeStringVal) v.SetString(&value) x.SetProperty("name", &v) } // GetPropertyName gets the "name" property. // The device name. func (x *Device) GetPropertyName() string { var v gobject.Value x.GetProperty("name", &v) return v.GetString() } // GetPropertyNumLockState gets the "num-lock-state" property. // Whether Num Lock is on. // // This is only relevant for keyboard devices. func (x *Device) GetPropertyNumLockState() bool { var v gobject.Value x.GetProperty("num-lock-state", &v) return v.GetBoolean() } // SetPropertyNumTouches sets the "num-touches" property. // The maximal number of concurrent touches on a touch device. // // Will be 0 if the device is not a touch device or if the number // of touches is unknown. func (x *Device) SetPropertyNumTouches(value uint) { var v gobject.Value v.Init(gobject.TypeUintVal) v.SetUint(value) x.SetProperty("num-touches", &v) } // GetPropertyNumTouches gets the "num-touches" property. // The maximal number of concurrent touches on a touch device. // // Will be 0 if the device is not a touch device or if the number // of touches is unknown. func (x *Device) GetPropertyNumTouches() uint { var v gobject.Value x.GetProperty("num-touches", &v) return v.GetUint() } // SetPropertyProductId sets the "product-id" property. // Product ID of this device. // // See [method@Gdk.Device.get_product_id]. func (x *Device) SetPropertyProductId(value string) { var v gobject.Value v.Init(gobject.TypeStringVal) v.SetString(&value) x.SetProperty("product-id", &v) } // GetPropertyProductId gets the "product-id" property. // Product ID of this device. // // See [method@Gdk.Device.get_product_id]. func (x *Device) GetPropertyProductId() string { var v gobject.Value x.GetProperty("product-id", &v) return v.GetString() } // GetPropertyScrollLockState gets the "scroll-lock-state" property. // Whether Scroll Lock is on. // // This is only relevant for keyboard devices. func (x *Device) GetPropertyScrollLockState() bool { var v gobject.Value x.GetProperty("scroll-lock-state", &v) return v.GetBoolean() } // SetPropertyVendorId sets the "vendor-id" property. // Vendor ID of this device. // // See [method@Gdk.Device.get_vendor_id]. func (x *Device) SetPropertyVendorId(value string) { var v gobject.Value v.Init(gobject.TypeStringVal) v.SetString(&value) x.SetProperty("vendor-id", &v) } // GetPropertyVendorId gets the "vendor-id" property. // Vendor ID of this device. // // See [method@Gdk.Device.get_vendor_id]. func (x *Device) GetPropertyVendorId() string { var v gobject.Value x.GetProperty("vendor-id", &v) return v.GetString() } // Emitted either when the number of either axes or keys changes. // // On X11 this will normally happen when the physical device // routing events through the logical device changes (for // example, user switches from the USB mouse to a tablet); in // that case the logical device will change to reflect the axes // and keys on the new physical device. func (x *Device) ConnectChanged(cb *func(Device)) uint { cbPtr := uintptr(unsafe.Pointer(cb)) if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { handlerID := gobject.SignalConnect(x.GoPointer(), "changed", cbRefPtr) glib.SaveHandlerMapping(handlerID, cbPtr) return handlerID } fcb := func(clsPtr uintptr) { fa := Device{} fa.Ptr = clsPtr cbFn := *cb cbFn(fa) } cbRefPtr := purego.NewCallback(fcb) glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb) handlerID := gobject.SignalConnect(x.GoPointer(), "changed", cbRefPtr) glib.SaveHandlerMapping(handlerID, cbPtr) return handlerID } // Emitted on pen/eraser devices whenever tools enter or leave proximity. func (x *Device) ConnectToolChanged(cb *func(Device, uintptr)) uint { cbPtr := uintptr(unsafe.Pointer(cb)) if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { handlerID := gobject.SignalConnect(x.GoPointer(), "tool-changed", cbRefPtr) glib.SaveHandlerMapping(handlerID, cbPtr) return handlerID } fcb := func(clsPtr uintptr, ToolVarp uintptr) { fa := Device{} fa.Ptr = clsPtr cbFn := *cb cbFn(fa, ToolVarp) } cbRefPtr := purego.NewCallback(fcb) glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb) handlerID := gobject.SignalConnect(x.GoPointer(), "tool-changed", cbRefPtr) glib.SaveHandlerMapping(handlerID, cbPtr) return handlerID } func init() { core.SetPackageName("GDK", "gtk4") core.SetSharedLibraries("GDK", []string{"libgtk-4.so.1"}) var libs []uintptr for _, libPath := range core.GetPaths("GDK") { lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL) if err != nil { panic(err) } libs = append(libs, lib) } core.PuregoSafeRegister(&xInputSourceGLibType, libs, "gdk_input_source_get_type") core.PuregoSafeRegister(&xDeviceGLibType, libs, "gdk_device_get_type") core.PuregoSafeRegister(&xDeviceGetActiveLayoutIndex, libs, "gdk_device_get_active_layout_index") core.PuregoSafeRegister(&xDeviceGetCapsLockState, libs, "gdk_device_get_caps_lock_state") core.PuregoSafeRegister(&xDeviceGetDeviceTool, libs, "gdk_device_get_device_tool") core.PuregoSafeRegister(&xDeviceGetDirection, libs, "gdk_device_get_direction") core.PuregoSafeRegister(&xDeviceGetDisplay, libs, "gdk_device_get_display") core.PuregoSafeRegister(&xDeviceGetHasCursor, libs, "gdk_device_get_has_cursor") core.PuregoSafeRegister(&xDeviceGetLayoutNames, libs, "gdk_device_get_layout_names") core.PuregoSafeRegister(&xDeviceGetModifierState, libs, "gdk_device_get_modifier_state") core.PuregoSafeRegister(&xDeviceGetName, libs, "gdk_device_get_name") core.PuregoSafeRegister(&xDeviceGetNumLockState, libs, "gdk_device_get_num_lock_state") core.PuregoSafeRegister(&xDeviceGetNumTouches, libs, "gdk_device_get_num_touches") core.PuregoSafeRegister(&xDeviceGetProductId, libs, "gdk_device_get_product_id") core.PuregoSafeRegister(&xDeviceGetScrollLockState, libs, "gdk_device_get_scroll_lock_state") core.PuregoSafeRegister(&xDeviceGetSeat, libs, "gdk_device_get_seat") core.PuregoSafeRegister(&xDeviceGetSource, libs, "gdk_device_get_source") core.PuregoSafeRegister(&xDeviceGetSurfaceAtPosition, libs, "gdk_device_get_surface_at_position") core.PuregoSafeRegister(&xDeviceGetTimestamp, libs, "gdk_device_get_timestamp") core.PuregoSafeRegister(&xDeviceGetVendorId, libs, "gdk_device_get_vendor_id") core.PuregoSafeRegister(&xDeviceHasBidiLayouts, libs, "gdk_device_has_bidi_layouts") }