// CreateWindow creates a window with the specified position, dimensions, and flags.
// (https://wiki.libsdl.org/SDL_CreateWindow)
491298
func CreateWindow(title string, x, y, w, h int32, flags uint32) (*Window, error) {
	var _window = C.SDL_CreateWindow(C.CString(title), C.int(x), C.int(y), C.int(w), C.int(h), C.Uint32(flags))
	if _window == nil {
		return nil, GetError()
	}
	return (*Window)(unsafe.Pointer(_window)), nil
}
896119
func (a *MovAvgAggregation) Window(window int) *MovAvgAggregation {
	a.window = &window
	return a
}
1095340
func (b *PlanBuilder) buildWindowFunctionFrame(spec *ast.WindowSpec, orderByItems []property.Item) (*WindowFrame, error) {
	frameClause := spec.Frame
	if frameClause == nil {
		return nil, nil
	}
	if frameClause.Type == ast.Groups {
		return nil, ErrNotSupportedYet.GenWithStackByArgs("GROUPS")
	}
	frame := &WindowFrame{Type: frameClause.Type}
	start := frameClause.Extent.Start
	if start.Type == ast.Following && start.UnBounded {
		return nil, ErrWindowFrameStartIllegal.GenWithStackByArgs(getWindowName(spec.Name.O))
	}
	var err error
	frame.Start, err = b.buildWindowFunctionFrameBound(spec, orderByItems, &start)
	if err != nil {
		return nil, err
	}

	end := frameClause.Extent.End
	if end.Type == ast.Preceding && end.UnBounded {
		return nil, ErrWindowFrameEndIllegal.GenWithStackByArgs(getWindowName(spec.Name.O))
	}
	frame.End, err = b.buildWindowFunctionFrameBound(spec, orderByItems, &end)
	return frame, err
}
924151
func InitialWindowSize(s int32) ServerOption {
	return newFuncServerOption(func(o *serverOptions) {
		o.initialWindowSize = s
	})
}
1339881
func (window *Window) VulkanCreateSurface(instance interface{}) (surface uintptr, err error) {
	if instance == nil {
		return 0, errors.New("vulkan: instance is nil")
	}
	val := reflect.ValueOf(instance)
	if val.Kind() != reflect.Ptr {
		return 0, errors.New("vulkan: instance is not a VkInstance (expected kind Ptr, got " + val.Kind().String() + ")")
	}
	var vulkanSurface C.VkSurfaceKHR
	if C.SDL_Vulkan_CreateSurface(window.cptr(),
		(C.VkInstance)(unsafe.Pointer(val.Pointer())),
		(*C.VkSurfaceKHR)(unsafe.Pointer(&vulkanSurface))) == C.SDL_FALSE {

		return 0, GetError()
	}
	return uintptr(unsafe.Pointer(&vulkanSurface)), nil
}
865798
func NewWindow(cfg WindowConfig) (*Window, error) {
	bool2int := map[bool]int{
		true:  glfw.True,
		false: glfw.False,
	}

	w := &Window{bounds: cfg.Bounds, cursorVisible: true}

	err := mainthread.CallErr(func() error {
		var err error

		glfw.WindowHint(glfw.ContextVersionMajor, 3)
		glfw.WindowHint(glfw.ContextVersionMinor, 3)
		glfw.WindowHint(glfw.OpenGLProfile, glfw.OpenGLCoreProfile)
		glfw.WindowHint(glfw.OpenGLForwardCompatible, glfw.True)

		glfw.WindowHint(glfw.Resizable, bool2int[cfg.Resizable])
		glfw.WindowHint(glfw.Decorated, bool2int[!cfg.Undecorated])

		var share *glfw.Window
		if currWin != nil {
			share = currWin.window
		}
		_, _, width, height := intBounds(cfg.Bounds)
		w.window, err = glfw.CreateWindow(
			width,
			height,
			cfg.Title,
			nil,
			share,
		)
		if err != nil {
			return err
		}

		// enter the OpenGL context
		w.begin()
		glhf.Init()
		w.end()

		return nil
	})
	if err != nil {
		return nil, errors.Wrap(err, "creating window failed")
	}

	if len(cfg.Icon) > 0 {
		imgs := make([]image.Image, len(cfg.Icon))
		for i, icon := range cfg.Icon {
			pic := pixel.PictureDataFromPicture(icon)
			imgs[i] = pic.Image()
		}
		mainthread.Call(func() {
			w.window.SetIcon(imgs)
		})
	}

	w.SetVSync(cfg.VSync)

	w.initInput()
	w.SetMonitor(cfg.Monitor)

	w.canvas = NewCanvas(cfg.Bounds)
	w.Update()

	runtime.SetFinalizer(w, (*Window).Destroy)

	return w, nil
}
627338
func (window *Window) SetSize(w, h int32) {
	C.SDL_SetWindowSize(window.cptr(), C.int(w), C.int(h))
}
233195
func (a *Astilectron) NewWindowInDisplay(d *Display, url string, o *WindowOptions) (*Window, error) {
	if o.X != nil {
		*o.X += d.Bounds().X
	} else {
		o.X = PtrInt(d.Bounds().X)
	}
	if o.Y != nil {
		*o.Y += d.Bounds().Y
	} else {
		o.Y = PtrInt(d.Bounds().Y)
	}
	return newWindow(a.options, a.Paths(), url, o, a.canceller, a.dispatcher, a.identifier, a.writer)
}
614673
func CreateWindow(title string, width, height int, fullscreen bool, msaa int) {
	CurrentBackEnd = BackEndVulkan
	err := glfw.Init()
	fatalErr(err)

	vk.SetGetInstanceProcAddr(glfw.GetVulkanGetInstanceProcAddress())
	fatalErr(vk.Init())

	if !opts.HeadlessMode {
		cursorArrow = glfw.CreateStandardCursor(int(glfw.ArrowCursor))
		cursorIBeam = glfw.CreateStandardCursor(int(glfw.IBeamCursor))
		cursorCrosshair = glfw.CreateStandardCursor(int(glfw.CrosshairCursor))
		cursorHand = glfw.CreateStandardCursor(int(glfw.HandCursor))
		cursorHResize = glfw.CreateStandardCursor(int(glfw.HResizeCursor))
		cursorVResize = glfw.CreateStandardCursor(int(glfw.VResizeCursor))
	}

	monitor := glfw.GetPrimaryMonitor()

	var mode *glfw.VidMode
	if monitor != nil {
		mode = monitor.GetVideoMode()
	} else {
		// Initialize default values if no monitor is found
		mode = &glfw.VidMode{
			Width:       1,
			Height:      1,
			RedBits:     8,
			GreenBits:   8,
			BlueBits:    8,
			RefreshRate: 60,
		}
	}

	gameWidth = float32(width)
	gameHeight = float32(height)

	if fullscreen {
		width = mode.Width
		height = mode.Height
		glfw.WindowHint(glfw.Decorated, 0)
	} else {
		monitor = nil
	}

	if opts.HeadlessMode {
		glfw.WindowHint(glfw.Visible, glfw.False)
	}
	if opts.NotResizable {
		glfw.WindowHint(glfw.Resizable, glfw.False)
	}

	glfw.WindowHint(glfw.ClientAPI, glfw.NoAPI)

	if opts.HeadlessMode {
		return
	}

	Window, err = glfw.CreateWindow(width, height, title, monitor, nil)
	fatalErr(err)

	if !fullscreen {
		Window.SetPos((mode.Width-width)/2, (mode.Height-height)/2)
	}

	width, height = Window.GetSize()
	windowWidth, windowHeight = float32(width), float32(height)

	fw, fh := Window.GetFramebufferSize()
	canvasWidth, canvasHeight = float32(fw), float32(fh)

	if windowWidth <= canvasWidth && windowHeight <= canvasHeight {
		scale = canvasWidth / windowWidth
	}

	Window.SetFramebufferSizeCallback(func(Window *glfw.Window, w, h int) {
		width, height = Window.GetSize()
		windowWidth, windowHeight = float32(width), float32(width)

		oldCanvasW, oldCanvasH := canvasWidth, canvasHeight

		canvasWidth, canvasHeight = float32(w), float32(h)

		ResizeXOffset += oldCanvasW - canvasWidth
		ResizeYOffset += oldCanvasH - canvasHeight

		if windowWidth <= canvasWidth && windowHeight <= canvasHeight {
			scale = canvasWidth / windowWidth
		}
	})

	Window.SetCursorPosCallback(func(Window *glfw.Window, x, y float64) {
		Input.Mouse.X, Input.Mouse.Y = float32(x)/opts.GlobalScale.X, float32(y)/opts.GlobalScale.Y
		if Input.Mouse.Action != Release && Input.Mouse.Action != Press {
			Input.Mouse.Action = Move
		}
	})

	Window.SetMouseButtonCallback(func(Window *glfw.Window, b glfw.MouseButton, a glfw.Action, m glfw.ModifierKey) {
		x, y := Window.GetCursorPos()
		Input.Mouse.X, Input.Mouse.Y = float32(x)/(opts.GlobalScale.X), float32(y)/(opts.GlobalScale.Y)

		// this is only valid because we use an internal structure that is
		// 100% compatible with glfw3.h
		Input.Mouse.Button = MouseButton(b)
		Input.Mouse.Modifer = Modifier(m)

		if a == glfw.Press {
			Input.Mouse.Action = Press
		} else {
			Input.Mouse.Action = Release
		}
	})

	Window.SetScrollCallback(func(Window *glfw.Window, xoff, yoff float64) {
		Input.Mouse.ScrollX = float32(xoff)
		Input.Mouse.ScrollY = float32(yoff)
	})

	Window.SetKeyCallback(func(Window *glfw.Window, k glfw.Key, s int, a glfw.Action, m glfw.ModifierKey) {
		key := Key(k)
		if a == glfw.Press {
			Input.keys.Set(key, true)
		} else if a == glfw.Release {
			Input.keys.Set(key, false)
		}
	})

	Window.SetSizeCallback(func(w *glfw.Window, widthInt int, heightInt int) {
		message := WindowResizeMessage{
			OldWidth:  int(windowWidth),
			OldHeight: int(windowHeight),
			NewWidth:  widthInt,
			NewHeight: heightInt,
		}

		windowWidth = float32(widthInt)
		windowHeight = float32(heightInt)

		// TODO: verify these for retina displays & verify if needed here
		fw, fh := Window.GetFramebufferSize()
		canvasWidth, canvasHeight = float32(fw), float32(fh)

		if !opts.ScaleOnResize {
			gameWidth, gameHeight = float32(widthInt), float32(heightInt)
		}

		Mailbox.Dispatch(message)
	})

	Window.SetCharCallback(func(Window *glfw.Window, char rune) {
		Mailbox.Dispatch(TextMessage{char})
	})

	Window.SetCloseCallback(func(Window *glfw.Window) {
		Exit()
	})
}
516129
func (w *Window) Create() (err error) {
	if err = w.isActionable(); err != nil {
		return
	}
	_, err = synchronousEvent(w.c, w, w.w, Event{Name: EventNameWindowCmdCreate, SessionID: w.Session.id, TargetID: w.id, URL: w.url.String(), WindowOptions: w.o}, EventNameWindowEventDidFinishLoad)
	return
}
1154275
func WithInitialWindowSize(s int32) DialOption {
	return newFuncDialOption(func(o *dialOptions) {
		o.copts.InitialWindowSize = s
	})
}
914285
func newWindow(X *xgbutil.XUtil, color uint32) *xwindow.Window {
	win, err := xwindow.Generate(X)
	if err != nil {
		log.Fatal(err)
	}

	err = win.CreateChecked(X.RootWin(), 0, 0, 400, 400,
		xproto.CwBackPixel|xproto.CwEventMask,
		color, xproto.EventMaskPointerMotion)
	if err != nil {
		log.Fatal(err)
	}

	win.Map()
	return win
}
940003
func (window *Window) SetMinimumSize(minW, minH int32) {
	C.SDL_SetWindowMinimumSize(window.cptr(), C.int(minW), C.int(minH))
}
1072535
func PropValWindow(reply *xproto.GetPropertyReply,
	err error) (xproto.Window, error) {

	if err != nil {
		return 0, err
	}
	if reply.Format != 32 {
		return 0, fmt.Errorf("PropValId: Expected format 32 but got %d",
			reply.Format)
	}
	return xproto.Window(xgb.Get32(reply.Value)), nil
}
495619
func CreateRGBSurfaceFrom(pixels unsafe.Pointer, width, height int32, depth, pitch int, Rmask, Gmask, Bmask, Amask uint32) (*Surface, error) {
	surface := (*Surface)(unsafe.Pointer(C.SDL_CreateRGBSurfaceFrom(
		pixels,
		C.int(width),
		C.int(height),
		C.int(depth),
		C.int(pitch),
		C.Uint32(Rmask),
		C.Uint32(Gmask),
		C.Uint32(Bmask),
		C.Uint32(Amask))))
	if surface == nil {
		return nil, GetError()
	}
	return surface, nil
}
570240
func CreateRGBSurface(flags uint32, width, height, depth int32, Rmask, Gmask, Bmask, Amask uint32) (*Surface, error) {
	surface := (*Surface)(unsafe.Pointer(C.SDL_CreateRGBSurface(
		C.Uint32(flags),
		C.int(width),
		C.int(height),
		C.int(depth),
		C.Uint32(Rmask),
		C.Uint32(Gmask),
		C.Uint32(Bmask),
		C.Uint32(Amask))))
	if surface == nil {
		return nil, GetError()
	}
	return surface, nil
}
285194
func (d *Driver) Create(id, parent string, opts *graphdriver.CreateOpts) error {
	if opts != nil {
		return d.create(id, parent, opts.MountLabel, true, opts.StorageOpt)
	}
	return d.create(id, parent, "", true, nil)
}