1// Package gdk was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package gdk
3
4import (
5 "unsafe"
6
7 "github.com/ebitengine/purego"
8
9 "github.com/bnema/puregotk/pkg/core"
10 "github.com/bnema/puregotk/v4/glib"
11 "github.com/bnema/puregotk/v4/gobject"
12 "github.com/bnema/puregotk/v4/gobject/types"
13)
14
15// Flags describing the seat capabilities.
16type SeatCapabilities int
17
18var xSeatCapabilitiesGLibType func() types.GType
19
20func SeatCapabilitiesGLibType() types.GType {
21 return xSeatCapabilitiesGLibType()
22}
23
24const (
25
26 // No input capabilities
27 SeatCapabilityNoneValue SeatCapabilities = 0
28 // The seat has a pointer (e.g. mouse)
29 SeatCapabilityPointerValue SeatCapabilities = 1
30 // The seat has touchscreen(s) attached
31 SeatCapabilityTouchValue SeatCapabilities = 2
32 // The seat has drawing tablet(s) attached
33 SeatCapabilityTabletStylusValue SeatCapabilities = 4
34 // The seat has keyboard(s) attached
35 SeatCapabilityKeyboardValue SeatCapabilities = 8
36 // The seat has drawing tablet pad(s) attached
37 SeatCapabilityTabletPadValue SeatCapabilities = 16
38 // The union of all pointing capabilities
39 SeatCapabilityAllPointingValue SeatCapabilities = 7
40 // The union of all capabilities
41 SeatCapabilityAllValue SeatCapabilities = 31
42)
43
44// Represents a collection of input devices that belong to a user.
45type Seat struct {
46 gobject.Object
47}
48
49var xSeatGLibType func() types.GType
50
51func SeatGLibType() types.GType {
52 return xSeatGLibType()
53}
54
55func SeatNewFromInternalPtr(ptr uintptr) *Seat {
56 cls := &Seat{}
57 cls.Ptr = ptr
58 return cls
59}
60
61var xSeatGetCapabilities func(uintptr) SeatCapabilities
62
63// Returns the capabilities this `GdkSeat` currently has.
64func (x *Seat) GetCapabilities() SeatCapabilities {
65
66 cret := xSeatGetCapabilities(x.GoPointer())
67 return cret
68}
69
70var xSeatGetDevices func(uintptr, SeatCapabilities) *glib.List
71
72// Returns the devices that match the given capabilities.
73func (x *Seat) GetDevices(CapabilitiesVar SeatCapabilities) *glib.List {
74
75 cret := xSeatGetDevices(x.GoPointer(), CapabilitiesVar)
76 return cret
77}
78
79var xSeatGetDisplay func(uintptr) uintptr
80
81// Returns the `GdkDisplay` this seat belongs to.
82func (x *Seat) GetDisplay() *Display {
83 var cls *Display
84
85 cret := xSeatGetDisplay(x.GoPointer())
86
87 if cret == 0 {
88 return nil
89 }
90 gobject.IncreaseRef(cret)
91 cls = &Display{}
92 cls.Ptr = cret
93 return cls
94}
95
96var xSeatGetKeyboard func(uintptr) uintptr
97
98// Returns the device that routes keyboard events.
99func (x *Seat) GetKeyboard() *Device {
100 var cls *Device
101
102 cret := xSeatGetKeyboard(x.GoPointer())
103
104 if cret == 0 {
105 return nil
106 }
107 gobject.IncreaseRef(cret)
108 cls = &Device{}
109 cls.Ptr = cret
110 return cls
111}
112
113var xSeatGetPointer func(uintptr) uintptr
114
115// Returns the device that routes pointer events.
116func (x *Seat) GetPointer() *Device {
117 var cls *Device
118
119 cret := xSeatGetPointer(x.GoPointer())
120
121 if cret == 0 {
122 return nil
123 }
124 gobject.IncreaseRef(cret)
125 cls = &Device{}
126 cls.Ptr = cret
127 return cls
128}
129
130var xSeatGetTools func(uintptr) *glib.List
131
132// Returns all `GdkDeviceTools` that are known to the application.
133func (x *Seat) GetTools() *glib.List {
134
135 cret := xSeatGetTools(x.GoPointer())
136 return cret
137}
138
139func (c *Seat) GoPointer() uintptr {
140 if c == nil {
141 return 0
142 }
143 return c.Ptr
144}
145
146func (c *Seat) SetGoPointer(ptr uintptr) {
147 c.Ptr = ptr
148}
149
150// Emitted when a new input device is related to this seat.
151func (x *Seat) ConnectDeviceAdded(cb *func(Seat, uintptr)) uint {
152 cbPtr := uintptr(unsafe.Pointer(cb))
153 if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
154 handlerID := gobject.SignalConnect(x.GoPointer(), "device-added", cbRefPtr)
155 glib.SaveHandlerMapping(handlerID, cbPtr)
156 return handlerID
157 }
158
159 fcb := func(clsPtr uintptr, DeviceVarp uintptr) {
160 fa := Seat{}
161 fa.Ptr = clsPtr
162 cbFn := *cb
163
164 cbFn(fa, DeviceVarp)
165
166 }
167 cbRefPtr := purego.NewCallback(fcb)
168 glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
169 handlerID := gobject.SignalConnect(x.GoPointer(), "device-added", cbRefPtr)
170 glib.SaveHandlerMapping(handlerID, cbPtr)
171 return handlerID
172}
173
174// Emitted when an input device is removed (e.g. unplugged).
175func (x *Seat) ConnectDeviceRemoved(cb *func(Seat, uintptr)) uint {
176 cbPtr := uintptr(unsafe.Pointer(cb))
177 if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
178 handlerID := gobject.SignalConnect(x.GoPointer(), "device-removed", cbRefPtr)
179 glib.SaveHandlerMapping(handlerID, cbPtr)
180 return handlerID
181 }
182
183 fcb := func(clsPtr uintptr, DeviceVarp uintptr) {
184 fa := Seat{}
185 fa.Ptr = clsPtr
186 cbFn := *cb
187
188 cbFn(fa, DeviceVarp)
189
190 }
191 cbRefPtr := purego.NewCallback(fcb)
192 glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
193 handlerID := gobject.SignalConnect(x.GoPointer(), "device-removed", cbRefPtr)
194 glib.SaveHandlerMapping(handlerID, cbPtr)
195 return handlerID
196}
197
198// Emitted whenever a new tool is made known to the seat.
199//
200// The tool may later be assigned to a device (i.e. on
201// proximity with a tablet). The device will emit the
202// [signal@Gdk.Device::tool-changed] signal accordingly.
203//
204// A same tool may be used by several devices.
205func (x *Seat) ConnectToolAdded(cb *func(Seat, uintptr)) uint {
206 cbPtr := uintptr(unsafe.Pointer(cb))
207 if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
208 handlerID := gobject.SignalConnect(x.GoPointer(), "tool-added", cbRefPtr)
209 glib.SaveHandlerMapping(handlerID, cbPtr)
210 return handlerID
211 }
212
213 fcb := func(clsPtr uintptr, ToolVarp uintptr) {
214 fa := Seat{}
215 fa.Ptr = clsPtr
216 cbFn := *cb
217
218 cbFn(fa, ToolVarp)
219
220 }
221 cbRefPtr := purego.NewCallback(fcb)
222 glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
223 handlerID := gobject.SignalConnect(x.GoPointer(), "tool-added", cbRefPtr)
224 glib.SaveHandlerMapping(handlerID, cbPtr)
225 return handlerID
226}
227
228// Emitted whenever a tool is no longer known to this @seat.
229func (x *Seat) ConnectToolRemoved(cb *func(Seat, uintptr)) uint {
230 cbPtr := uintptr(unsafe.Pointer(cb))
231 if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
232 handlerID := gobject.SignalConnect(x.GoPointer(), "tool-removed", cbRefPtr)
233 glib.SaveHandlerMapping(handlerID, cbPtr)
234 return handlerID
235 }
236
237 fcb := func(clsPtr uintptr, ToolVarp uintptr) {
238 fa := Seat{}
239 fa.Ptr = clsPtr
240 cbFn := *cb
241
242 cbFn(fa, ToolVarp)
243
244 }
245 cbRefPtr := purego.NewCallback(fcb)
246 glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
247 handlerID := gobject.SignalConnect(x.GoPointer(), "tool-removed", cbRefPtr)
248 glib.SaveHandlerMapping(handlerID, cbPtr)
249 return handlerID
250}
251
252func init() {
253 core.SetPackageName("GDK", "gtk4")
254 core.SetSharedLibraries("GDK", []string{"libgtk-4.so.1"})
255 var libs []uintptr
256 for _, libPath := range core.GetPaths("GDK") {
257 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
258 if err != nil {
259 panic(err)
260 }
261 libs = append(libs, lib)
262 }
263
264 core.PuregoSafeRegister(&xSeatCapabilitiesGLibType, libs, "gdk_seat_capabilities_get_type")
265
266 core.PuregoSafeRegister(&xSeatGLibType, libs, "gdk_seat_get_type")
267
268 core.PuregoSafeRegister(&xSeatGetCapabilities, libs, "gdk_seat_get_capabilities")
269 core.PuregoSafeRegister(&xSeatGetDevices, libs, "gdk_seat_get_devices")
270 core.PuregoSafeRegister(&xSeatGetDisplay, libs, "gdk_seat_get_display")
271 core.PuregoSafeRegister(&xSeatGetKeyboard, libs, "gdk_seat_get_keyboard")
272 core.PuregoSafeRegister(&xSeatGetPointer, libs, "gdk_seat_get_pointer")
273 core.PuregoSafeRegister(&xSeatGetTools, libs, "gdk_seat_get_tools")
274
275}