1// Package gdk was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package gdk
3
4import (
5 "structs"
6 "unsafe"
7
8 "github.com/ebitengine/purego"
9
10 "github.com/bnema/puregotk/pkg/core"
11 "github.com/bnema/puregotk/v4/glib"
12 "github.com/bnema/puregotk/v4/gobject"
13 "github.com/bnema/puregotk/v4/gobject/types"
14)
15
16type MonitorClass struct {
17 _ structs.HostLayout
18}
19
20func (x *MonitorClass) GoPointer() uintptr {
21 return uintptr(unsafe.Pointer(x))
22}
23
24// This enumeration describes how the red, green and blue components
25// of physical pixels on an output device are laid out.
26type SubpixelLayout int
27
28var xSubpixelLayoutGLibType func() types.GType
29
30func SubpixelLayoutGLibType() types.GType {
31 return xSubpixelLayoutGLibType()
32}
33
34const (
35
36 // The layout is not known
37 SubpixelLayoutUnknownValue SubpixelLayout = 0
38 // Not organized in this way
39 SubpixelLayoutNoneValue SubpixelLayout = 1
40 // The layout is horizontal, the order is RGB
41 SubpixelLayoutHorizontalRgbValue SubpixelLayout = 2
42 // The layout is horizontal, the order is BGR
43 SubpixelLayoutHorizontalBgrValue SubpixelLayout = 3
44 // The layout is vertical, the order is RGB
45 SubpixelLayoutVerticalRgbValue SubpixelLayout = 4
46 // The layout is vertical, the order is BGR
47 SubpixelLayoutVerticalBgrValue SubpixelLayout = 5
48)
49
50// Represents the individual outputs that are associated with a `GdkDisplay`.
51//
52// `GdkDisplay` keeps a `GListModel` to enumerate and monitor
53// monitors with [method@Gdk.Display.get_monitors]. You can use
54// [method@Gdk.Display.get_monitor_at_surface] to find a particular
55// monitor.
56type Monitor struct {
57 gobject.Object
58}
59
60var xMonitorGLibType func() types.GType
61
62func MonitorGLibType() types.GType {
63 return xMonitorGLibType()
64}
65
66func MonitorNewFromInternalPtr(ptr uintptr) *Monitor {
67 cls := &Monitor{}
68 cls.Ptr = ptr
69 return cls
70}
71
72var xMonitorGetConnector func(uintptr) string
73
74// Gets the name of the monitor's connector, if available.
75//
76// These are strings such as "eDP-1", or "HDMI-2". They depend
77// on software and hardware configuration, and should not be
78// relied on as stable identifiers of a specific monitor.
79func (x *Monitor) GetConnector() string {
80
81 cret := xMonitorGetConnector(x.GoPointer())
82 return cret
83}
84
85var xMonitorGetDescription func(uintptr) string
86
87// Gets a string describing the monitor, if available.
88//
89// This can be used to identify a monitor in the UI.
90func (x *Monitor) GetDescription() string {
91
92 cret := xMonitorGetDescription(x.GoPointer())
93 return cret
94}
95
96var xMonitorGetDisplay func(uintptr) uintptr
97
98// Gets the display that this monitor belongs to.
99func (x *Monitor) GetDisplay() *Display {
100 var cls *Display
101
102 cret := xMonitorGetDisplay(x.GoPointer())
103
104 if cret == 0 {
105 return nil
106 }
107 gobject.IncreaseRef(cret)
108 cls = &Display{}
109 cls.Ptr = cret
110 return cls
111}
112
113var xMonitorGetGeometry func(uintptr, *Rectangle)
114
115// Retrieves the size and position of the monitor within the
116// display coordinate space.
117//
118// The returned geometry is in ”application pixels”, not in
119// ”device pixels” (see [method@Gdk.Monitor.get_scale]).
120func (x *Monitor) GetGeometry(GeometryVar *Rectangle) {
121
122 xMonitorGetGeometry(x.GoPointer(), GeometryVar)
123
124}
125
126var xMonitorGetHeightMm func(uintptr) int
127
128// Gets the height in millimeters of the monitor.
129func (x *Monitor) GetHeightMm() int {
130
131 cret := xMonitorGetHeightMm(x.GoPointer())
132 return cret
133}
134
135var xMonitorGetManufacturer func(uintptr) string
136
137// Gets the name or PNP ID of the monitor's manufacturer.
138//
139// Note that this value might also vary depending on actual
140// display backend.
141//
142// The PNP ID registry is located at
143// [https://uefi.org/pnp_id_list](https://uefi.org/pnp_id_list).
144func (x *Monitor) GetManufacturer() string {
145
146 cret := xMonitorGetManufacturer(x.GoPointer())
147 return cret
148}
149
150var xMonitorGetModel func(uintptr) string
151
152// Gets the string identifying the monitor model, if available.
153func (x *Monitor) GetModel() string {
154
155 cret := xMonitorGetModel(x.GoPointer())
156 return cret
157}
158
159var xMonitorGetRefreshRate func(uintptr) int
160
161// Gets the refresh rate of the monitor, if available.
162//
163// The value is in milli-Hertz, so a refresh rate of 60Hz
164// is returned as 60000.
165func (x *Monitor) GetRefreshRate() int {
166
167 cret := xMonitorGetRefreshRate(x.GoPointer())
168 return cret
169}
170
171var xMonitorGetScale func(uintptr) float64
172
173// Gets the internal scale factor that maps from monitor coordinates
174// to device pixels.
175//
176// This can be used if you want to create pixel based data for a
177// particular monitor, but most of the time you’re drawing to a surface
178// where it is better to use [method@Gdk.Surface.get_scale] instead.
179func (x *Monitor) GetScale() float64 {
180
181 cret := xMonitorGetScale(x.GoPointer())
182 return cret
183}
184
185var xMonitorGetScaleFactor func(uintptr) int
186
187// Gets the internal scale factor that maps from monitor coordinates
188// to device pixels.
189//
190// On traditional systems this is 1, but on very high density outputs
191// it can be a higher value (often 2).
192//
193// This can be used if you want to create pixel based data for a
194// particular monitor, but most of the time you’re drawing to a surface
195// where it is better to use [method@Gdk.Surface.get_scale_factor] instead.
196func (x *Monitor) GetScaleFactor() int {
197
198 cret := xMonitorGetScaleFactor(x.GoPointer())
199 return cret
200}
201
202var xMonitorGetSubpixelLayout func(uintptr) SubpixelLayout
203
204// Gets information about the layout of red, green and blue
205// primaries for pixels.
206func (x *Monitor) GetSubpixelLayout() SubpixelLayout {
207
208 cret := xMonitorGetSubpixelLayout(x.GoPointer())
209 return cret
210}
211
212var xMonitorGetWidthMm func(uintptr) int
213
214// Gets the width in millimeters of the monitor.
215func (x *Monitor) GetWidthMm() int {
216
217 cret := xMonitorGetWidthMm(x.GoPointer())
218 return cret
219}
220
221var xMonitorIsValid func(uintptr) bool
222
223// Returns %TRUE if the @monitor object corresponds to a
224// physical monitor.
225//
226// The @monitor becomes invalid when the physical monitor
227// is unplugged or removed.
228func (x *Monitor) IsValid() bool {
229
230 cret := xMonitorIsValid(x.GoPointer())
231 return cret
232}
233
234func (c *Monitor) GoPointer() uintptr {
235 if c == nil {
236 return 0
237 }
238 return c.Ptr
239}
240
241func (c *Monitor) SetGoPointer(ptr uintptr) {
242 c.Ptr = ptr
243}
244
245// GetPropertyConnector gets the "connector" property.
246// The connector name.
247func (x *Monitor) GetPropertyConnector() string {
248 var v gobject.Value
249 x.GetProperty("connector", &v)
250 return v.GetString()
251}
252
253// GetPropertyDescription gets the "description" property.
254// A short description of the monitor, meant for display to the user.
255func (x *Monitor) GetPropertyDescription() string {
256 var v gobject.Value
257 x.GetProperty("description", &v)
258 return v.GetString()
259}
260
261// GetPropertyGeometry gets the "geometry" property.
262// The geometry of the monitor.
263func (x *Monitor) GetPropertyGeometry() uintptr {
264 var v gobject.Value
265 x.GetProperty("geometry", &v)
266 return v.GetPointer()
267}
268
269// GetPropertyHeightMm gets the "height-mm" property.
270// The height of the monitor, in millimeters.
271func (x *Monitor) GetPropertyHeightMm() int {
272 var v gobject.Value
273 x.GetProperty("height-mm", &v)
274 return v.GetInt()
275}
276
277// GetPropertyManufacturer gets the "manufacturer" property.
278// The manufacturer name.
279func (x *Monitor) GetPropertyManufacturer() string {
280 var v gobject.Value
281 x.GetProperty("manufacturer", &v)
282 return v.GetString()
283}
284
285// GetPropertyModel gets the "model" property.
286// The model name.
287func (x *Monitor) GetPropertyModel() string {
288 var v gobject.Value
289 x.GetProperty("model", &v)
290 return v.GetString()
291}
292
293// GetPropertyRefreshRate gets the "refresh-rate" property.
294// The refresh rate, in milli-Hertz.
295func (x *Monitor) GetPropertyRefreshRate() int {
296 var v gobject.Value
297 x.GetProperty("refresh-rate", &v)
298 return v.GetInt()
299}
300
301// GetPropertyScale gets the "scale" property.
302// The scale of the monitor.
303func (x *Monitor) GetPropertyScale() float64 {
304 var v gobject.Value
305 x.GetProperty("scale", &v)
306 return v.GetDouble()
307}
308
309// GetPropertyScaleFactor gets the "scale-factor" property.
310// The scale factor.
311//
312// The scale factor is the next larger integer,
313// compared to [property@Gdk.Surface:scale].
314func (x *Monitor) GetPropertyScaleFactor() int {
315 var v gobject.Value
316 x.GetProperty("scale-factor", &v)
317 return v.GetInt()
318}
319
320// GetPropertyValid gets the "valid" property.
321// Whether the object is still valid.
322func (x *Monitor) GetPropertyValid() bool {
323 var v gobject.Value
324 x.GetProperty("valid", &v)
325 return v.GetBoolean()
326}
327
328// GetPropertyWidthMm gets the "width-mm" property.
329// The width of the monitor, in millimeters.
330func (x *Monitor) GetPropertyWidthMm() int {
331 var v gobject.Value
332 x.GetProperty("width-mm", &v)
333 return v.GetInt()
334}
335
336// Emitted when the output represented by @monitor gets disconnected.
337func (x *Monitor) ConnectInvalidate(cb *func(Monitor)) uint {
338 cbPtr := uintptr(unsafe.Pointer(cb))
339 if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
340 handlerID := gobject.SignalConnect(x.GoPointer(), "invalidate", cbRefPtr)
341 glib.SaveHandlerMapping(handlerID, cbPtr)
342 return handlerID
343 }
344
345 fcb := func(clsPtr uintptr) {
346 fa := Monitor{}
347 fa.Ptr = clsPtr
348 cbFn := *cb
349
350 cbFn(fa)
351
352 }
353 cbRefPtr := purego.NewCallback(fcb)
354 glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
355 handlerID := gobject.SignalConnect(x.GoPointer(), "invalidate", cbRefPtr)
356 glib.SaveHandlerMapping(handlerID, cbPtr)
357 return handlerID
358}
359
360func init() {
361 core.SetPackageName("GDK", "gtk4")
362 core.SetSharedLibraries("GDK", []string{"libgtk-4.so.1"})
363 var libs []uintptr
364 for _, libPath := range core.GetPaths("GDK") {
365 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
366 if err != nil {
367 panic(err)
368 }
369 libs = append(libs, lib)
370 }
371
372 core.PuregoSafeRegister(&xSubpixelLayoutGLibType, libs, "gdk_subpixel_layout_get_type")
373
374 core.PuregoSafeRegister(&xMonitorGLibType, libs, "gdk_monitor_get_type")
375
376 core.PuregoSafeRegister(&xMonitorGetConnector, libs, "gdk_monitor_get_connector")
377 core.PuregoSafeRegister(&xMonitorGetDescription, libs, "gdk_monitor_get_description")
378 core.PuregoSafeRegister(&xMonitorGetDisplay, libs, "gdk_monitor_get_display")
379 core.PuregoSafeRegister(&xMonitorGetGeometry, libs, "gdk_monitor_get_geometry")
380 core.PuregoSafeRegister(&xMonitorGetHeightMm, libs, "gdk_monitor_get_height_mm")
381 core.PuregoSafeRegister(&xMonitorGetManufacturer, libs, "gdk_monitor_get_manufacturer")
382 core.PuregoSafeRegister(&xMonitorGetModel, libs, "gdk_monitor_get_model")
383 core.PuregoSafeRegister(&xMonitorGetRefreshRate, libs, "gdk_monitor_get_refresh_rate")
384 core.PuregoSafeRegister(&xMonitorGetScale, libs, "gdk_monitor_get_scale")
385 core.PuregoSafeRegister(&xMonitorGetScaleFactor, libs, "gdk_monitor_get_scale_factor")
386 core.PuregoSafeRegister(&xMonitorGetSubpixelLayout, libs, "gdk_monitor_get_subpixel_layout")
387 core.PuregoSafeRegister(&xMonitorGetWidthMm, libs, "gdk_monitor_get_width_mm")
388 core.PuregoSafeRegister(&xMonitorIsValid, libs, "gdk_monitor_is_valid")
389
390}