Esempio n. 1
0
)

var surface_impl = C.struct_wl_surface_interface{
	destroy: cPtr(surface_destroy.CPtr()),
	attach:  cPtr(attach.CPtr()),
	damage:  cPtr(damage.CPtr()),
	frame:   cPtr(frame.CPtr()),
	commit:  cPtr(commit.CPtr()),
}

var create_surface = cfn.CreateFunc(
	func(client *C.struct_wl_client,
		resource *C.struct_wl_resource, id C.uint32_t) {

		surface_res := C.wl_resource_create(client, &C.wl_surface_interface,
			C.wl_resource_get_version(resource), id)

		compositor := compositors[client]

		surface := new(Surface)

		compositor.Surfaces[surface_res] = surface

		C.wl_resource_set_implementation(surface_res,
			(unsafe.Pointer)(&surface_impl),
			(unsafe.Pointer)(surface), nil)

		C.wl_signal_emit(&new_surface_signal, (unsafe.Pointer)(surface_res))
	},
)
Esempio n. 2
0
	mmap_ptr, err := syscall.Mmap(
		int(fd), 0,
		int(size),
		syscall.PROT_READ|syscall.PROT_WRITE,
		syscall.MAP_SHARED,
	)

	if err != nil {
		fmt.Println(err)
		// TODO: should send error
	}

	pool_res := C.wl_resource_create(
		client,
		&C.wl_shm_pool_interface,
		(C.wl_resource_get_version(resource)),
		id,
	)

	pool := Pool{
		client: client,
		id:     int(id),
		fd:     int(fd),
		ptr:    mmap_ptr,
	}

	pools[int(id)] = &pool

	// C.wl_resource_set_implementation(pool_res,
	// 	(unsafe.Pointer)(&shm_pool_impl),
	// 	unsafe.Pointer(&pool),