// Package gdk was automatically generated by github.com/bnema/puregotk DO NOT EDIT package gdk import ( "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" ) var xSetAllowedBackends func(string) // Sets a list of backends that GDK should try to use. // // This can be useful if your application does not // work with certain GDK backends. // // By default, GDK tries all included backends. // // For example: // // ```c // gdk_set_allowed_backends ("wayland,macos,*"); // ``` // // instructs GDK to try the Wayland backend first, followed by the // MacOs backend, and then all others. // // If the `GDK_BACKEND` environment variable is set, it determines // what backends are tried in what order, while still respecting the // set of allowed backends that are specified by this function. // // The possible backend names are: // // - `broadway` // - `macos` // - `wayland`. // - `win32` // - `x11` // // You can also include a `*` in the list to try all remaining backends. // // This call must happen prior to functions that open a display, such // as [func@Gdk.Display.open], `gtk_init()`, or `gtk_init_check()` // in order to take effect. func SetAllowedBackends(BackendsVar string) { xSetAllowedBackends(BackendsVar) } // Offers notification when displays appear or disappear. // // `GdkDisplayManager` is a singleton object. // // You can use [func@Gdk.DisplayManager.get] to obtain the `GdkDisplayManager` // singleton, but that should be rarely necessary. Typically, initializing // GTK opens a display that you can work with without ever accessing the // `GdkDisplayManager`. // // The GDK library can be built with support for multiple backends. // The `GdkDisplayManager` object determines which backend is used // at runtime. // // In the rare case that you need to influence which of the backends // is being used, you can use [func@Gdk.set_allowed_backends]. Note // that you need to call this function before initializing GTK. // // ## Backend-specific code // // When writing backend-specific code that is supposed to work with // multiple GDK backends, you have to consider both compile time and // runtime. At compile time, use the `GDK_WINDOWING_X11`, `GDK_WINDOWING_WIN32` // macros, etc. to find out which backends are present in the GDK library // you are building your application against. At runtime, use type-check // macros like GDK_IS_X11_DISPLAY() to find out which backend is in use: // // ```c // #ifdef GDK_WINDOWING_X11 // // if (GDK_IS_X11_DISPLAY (display)) // { // // make X11-specific calls here // } // else // // #endif // #ifdef GDK_WINDOWING_MACOS // // if (GDK_IS_MACOS_DISPLAY (display)) // { // // make Quartz-specific calls here // } // else // // #endif // // g_error ("Unsupported GDK backend"); // // ``` type DisplayManager struct { gobject.Object } var xDisplayManagerGLibType func() types.GType func DisplayManagerGLibType() types.GType { return xDisplayManagerGLibType() } func DisplayManagerNewFromInternalPtr(ptr uintptr) *DisplayManager { cls := &DisplayManager{} cls.Ptr = ptr return cls } var xDisplayManagerGetDefaultDisplay func(uintptr) uintptr // Gets the default `GdkDisplay`. func (x *DisplayManager) GetDefaultDisplay() *Display { var cls *Display cret := xDisplayManagerGetDefaultDisplay(x.GoPointer()) if cret == 0 { return nil } gobject.IncreaseRef(cret) cls = &Display{} cls.Ptr = cret return cls } var xDisplayManagerListDisplays func(uintptr) *glib.SList // List all currently open displays. func (x *DisplayManager) ListDisplays() *glib.SList { cret := xDisplayManagerListDisplays(x.GoPointer()) return cret } var xDisplayManagerOpenDisplay func(uintptr, uintptr) uintptr // Opens a display. func (x *DisplayManager) OpenDisplay(NameVar *string) *Display { var cls *Display NameVarPtr := core.GStrdupNullable(NameVar) defer core.GFreeNullable(NameVarPtr) cret := xDisplayManagerOpenDisplay(x.GoPointer(), NameVarPtr) if cret == 0 { return nil } gobject.IncreaseRef(cret) cls = &Display{} cls.Ptr = cret return cls } var xDisplayManagerSetDefaultDisplay func(uintptr, uintptr) // Sets @display as the default display. func (x *DisplayManager) SetDefaultDisplay(DisplayVar *Display) { xDisplayManagerSetDefaultDisplay(x.GoPointer(), DisplayVar.GoPointer()) } func (c *DisplayManager) GoPointer() uintptr { if c == nil { return 0 } return c.Ptr } func (c *DisplayManager) SetGoPointer(ptr uintptr) { c.Ptr = ptr } // Emitted when a display is opened. func (x *DisplayManager) ConnectDisplayOpened(cb *func(DisplayManager, uintptr)) uint { cbPtr := uintptr(unsafe.Pointer(cb)) if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { handlerID := gobject.SignalConnect(x.GoPointer(), "display-opened", cbRefPtr) glib.SaveHandlerMapping(handlerID, cbPtr) return handlerID } fcb := func(clsPtr uintptr, DisplayVarp uintptr) { fa := DisplayManager{} fa.Ptr = clsPtr cbFn := *cb cbFn(fa, DisplayVarp) } cbRefPtr := purego.NewCallback(fcb) glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb) handlerID := gobject.SignalConnect(x.GoPointer(), "display-opened", cbRefPtr) glib.SaveHandlerMapping(handlerID, cbPtr) return handlerID } var xDisplayManagerGet func() uintptr // Gets the singleton `GdkDisplayManager` object. // // When called for the first time, this function consults the // `GDK_BACKEND` environment variable to find out which of the // supported GDK backends to use (in case GDK has been compiled // with multiple backends). // // Applications can use [func@set_allowed_backends] to limit what // backends will be used. func DisplayManagerGet() *DisplayManager { var cls *DisplayManager cret := xDisplayManagerGet() if cret == 0 { return nil } gobject.IncreaseRef(cret) cls = &DisplayManager{} cls.Ptr = cret return cls } 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(&xSetAllowedBackends, libs, "gdk_set_allowed_backends") core.PuregoSafeRegister(&xDisplayManagerGLibType, libs, "gdk_display_manager_get_type") core.PuregoSafeRegister(&xDisplayManagerGetDefaultDisplay, libs, "gdk_display_manager_get_default_display") core.PuregoSafeRegister(&xDisplayManagerListDisplays, libs, "gdk_display_manager_list_displays") core.PuregoSafeRegister(&xDisplayManagerOpenDisplay, libs, "gdk_display_manager_open_display") core.PuregoSafeRegister(&xDisplayManagerSetDefaultDisplay, libs, "gdk_display_manager_set_default_display") core.PuregoSafeRegister(&xDisplayManagerGet, libs, "gdk_display_manager_get") }