예제 #1
0
func seatInit(display *C.struct_wl_display) {

	seat = cfn.CreateFunc(bind_seat)

	C.wl_global_create(display,
		C.WL_seat_interface,
		3,
		nil,
		cPtr(seat.CPtr()))
}
예제 #2
0
func (pool *Pool) get_destroy_func() unsafe.Pointer {
	if pool.destroyFn == nil {
		pool.destroyFn = cfn.CreateFunc(
			func(resource *C.struct_wl_resource) {
				id := C.wl_resource_get_id(resource)
				delete(pools, int(id))
			},
		)
	}

	return pool.destroyFn.CPtr()
}
예제 #3
0
func once_func(f interface{}) *cfn.CFn {

	var wrapperFn interface{}

	wrapperFn = reflect.MakeFunc(
		reflect.TypeOf(f),
		func(args []reflect.Value) (results []reflect.Value) {
			results = reflect.ValueOf(f).Call(args)

			if &wrapperFn != nil {
				delete(once_funcs, &wrapperFn)
			}

			return
		},
	).Interface()

	cfn := cfn.CreateFunc(wrapperFn)

	once_funcs[&wrapperFn] = cfn

	return cfn
}
예제 #4
0
	pendingBuffer *C.struct_wl_resource
	frame_cbs     []*C.struct_wl_resource
	CommitBuffer  []byte
}

type Compositor struct {
	Pid      int
	Surfaces map[*C.struct_wl_resource]*Surface
}

var new_surface_signal C.struct_wl_signal

var surface_destroy = cfn.CreateFunc(
	func(client *C.struct_wl_client,
		resource *C.struct_wl_resource) {
		log.Info("surface_destroy")
		C.wl_resource_destroy(resource)
	},
)

var attach = cfn.CreateFunc(
	func(client *C.struct_wl_client,
		resource *C.struct_wl_resource,
		buffer *C.struct_wl_resource,
		x C.int32_t,
		y C.int32_t) {

		log.Info("attach")

		surface := compositors[client].Surfaces[resource]
		surface.pendingBuffer = buffer
예제 #5
0
#cgo pkg-config: wayland-server

#include <wayland-server.h>
#include "wayland-fix.h"
*/
import "C"

import (
	"github.com/fangyuanziti/wayland-html/cfn"
	"unsafe"
)

type shell_surface_interface C.struct_wl_shell_surface_interface

var pong = cfn.CreateFunc(
	get_echo("pong"),
)
var move = cfn.CreateFunc(
	get_echo("move"),
)
var shell_resize = cfn.CreateFunc(
	get_echo("shell_resize"),
)
var set_toplevel = cfn.CreateFunc(
	get_echo("set_toplevel"),
)

var set_transient = cfn.CreateFunc(
	get_echo("set_transient"),
)
var set_fullscreen = cfn.CreateFunc(
예제 #6
0
var shm_create_pool = cfn.CreateFunc(func(
	client *C.struct_wl_client,
	resource *C.struct_wl_resource,
	id C.uint32_t,
	fd C.int32_t,
	size C.int32_t) {

	println("creata_pool")

	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),
	// 	cPtr(pool.get_destroy_func()))
	C.wl_resource_set_implementation(pool_res,
		(unsafe.Pointer)(&shm_pool_impl),
		unsafe.Pointer(&pool),
		nil)

})
예제 #7
0
package main

/*
#include "wayland-fix.h"
*/
import "C"

import (
	"github.com/fangyuanziti/wayland-html/cfn"
	"unsafe"
)

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

		println("xdg_surface_destroy")
		C.wl_resource_destroy(resource)
	},
)

var xdg_surface_set_transient_for = cfn.CreateFunc(
	func(client *C.struct_wl_client,
		resource *C.struct_wl_resource,
		parent *C.struct_wl_resource) {

		println("xdg_surface_transient")
	},
)

var xdg_surface_set_margin = cfn.CreateFunc(
	func(client *C.struct_wl_client,