Beispiel #1
0
func New() *Window {
	xWnd := C.XCreateWindow(
		dpy,
		root,
		0,
		0,
		500,
		500,
		0,
		C.XDefaultDepth(dpy, 0),
		C.InputOutput,
		C.XDefaultVisual(dpy, 0),
		C.CWBackPixel,
		&attributes,
	)
	wdw := C.CString("WM_DELETE_WINDOW")
	wmDelete := C.XInternAtom(dpy, wdw, 1)
	C.free(unsafe.Pointer(wdw))
	fmt.Println(wmDelete)
	C.XSetWMProtocols(dpy, xWnd, &wmDelete, 1)
	C.XSelectInput(dpy, xWnd, C.ExposureMask|C.KeyPressMask)
	C.XMapWindow(dpy, xWnd)

	wnd := &Window{
		id: uintptr(xWnd),
	}

	wndMap[wnd.id] = wnd
	return wnd
}
Beispiel #2
0
func Screen() (C.uint, C.uint, C.uint) {
	//
	d := C.CString(dspl)
	defer C.free(unsafe.Pointer(d))
	display = C.XOpenDisplay(d)
	if display == nil {
		panic("display == nil") /* Terminate (); */ os.Exit(1)
	}
	window0 = C.XDefaultRootWindow(display)
	screen = C.XDefaultScreen(display)
	return C.uint(C.XDisplayWidth(display, screen)),
		C.uint(C.XDisplayHeight(display, screen)),
		C.uint(C.XDefaultDepth(display, screen))
}