Example #1
0
// GetSubsurfaces returns a list of subsurfaces for a surface.
func (s Resource) GetSubsurfaces() []Resource {
	var len C.size_t
	resouces := C.wlc_surface_get_subsurfaces(C.wlc_resource(s), &len)
	subsurfaces := make([]Resource, int(len))
	size := int(unsafe.Sizeof(*resouces))
	for i := 0; i < int(len); i++ {
		ptr := unsafe.Pointer(uintptr(unsafe.Pointer(resouces)) + uintptr(size*i))
		subsurfaces[i] = *(*Resource)(ptr)
	}
	return subsurfaces
}
Example #2
0
// ViewFromSurface turns wl_surface into a wlc view. Returns 0 on failure.
// This will also trigger view.created callback as any view would.
func ViewFromSurface(surface Resource, client *C.struct_wl_client, interf *C.struct_wl_interface, implementation unsafe.Pointer, version, id uint32, userdata unsafe.Pointer) View {
	return View(
		C.wlc_view_from_surface(
			C.wlc_resource(surface),
			client,
			interf,
			implementation,
			C.uint32_t(version),
			C.uint32_t(id),
			userdata,
		))
}
Example #3
0
// GetTextures returns an array with the textures of a surface. Returns error
// if surface is invalid. Note that these are not only OpenGL textures but
// rather render-specific.
func (s Resource) GetTextures() ([3]uint32, SurfaceFormat, error) {
	var outTextures [3]C.uint32_t
	var format C.enum_wlc_surface_format
	val := bool(C.wlc_surface_get_textures(C.wlc_resource(s), &outTextures[0], &format))
	if val {
		var textures [3]uint32
		for i, t := range outTextures {
			textures[i] = uint32(t)
		}
		return textures, SurfaceFormat(format), nil
	}

	return [3]uint32{}, 0, fmt.Errorf("invalid surface")
}
Example #4
0
// FlushFrameCallbacks adds frame callbacks of the given surface for the next
// output frame.  It applies recursively to all subsurfaces.  Useful when the
// compositor creates custom animations which require disabling internal
// rendering, but still need to update the surface textures (for ex. video
// players).
func (s Resource) FlushFrameCallbacks() {
	C.wlc_surface_flush_frame_callbacks(C.wlc_resource(s))
}
Example #5
0
// Render renders surfaces inside post / pre render hooks.
func (s Resource) Render(geometry Geometry) {
	cgeometry := geometry.c()
	defer C.free(unsafe.Pointer(cgeometry))
	C.wlc_surface_render(C.wlc_resource(s), cgeometry)
}
Example #6
0
// GetSubsurfaceGeometry returns the size of a subsurface and its position
// relative to parent surface.
func (s Resource) GetSubsurfaceGeometry() Geometry {
	cgeometry := C.struct_wlc_geometry{}
	C.wlc_get_subsurface_geometry(C.wlc_resource(s), &cgeometry)
	return *geometryCtoGo(&Geometry{}, &cgeometry)
}
Example #7
0
// SurfaceGetWLResource returns wl_surface resource from internal wlc surface.
func SurfaceGetWLResource(surface Resource) *C.struct_wl_resource {
	return C.wlc_surface_get_wl_resource(C.wlc_resource(surface))
}
Example #8
0
// SurfaceGetSize gets surface size.
func SurfaceGetSize(surface Resource) *Size {
	csize := C.wlc_surface_get_size(C.wlc_resource(surface))
	return sizeCtoGo(csize)
}