76 lines
2.4 KiB
Go
76 lines
2.4 KiB
Go
// SPDX-License-Identifier: Unlicense OR MIT
|
|
|
|
//go:build linux
|
|
// +build linux
|
|
|
|
package app
|
|
|
|
import (
|
|
"errors"
|
|
"unsafe"
|
|
|
|
"github.com/mleku/fromage/io/pointer"
|
|
)
|
|
|
|
type X11ViewEvent struct {
|
|
// Display is a pointer to the X11 Display created by XOpenDisplay.
|
|
Display unsafe.Pointer
|
|
// Window is the X11 window ID as returned by XCreateWindow.
|
|
Window uintptr
|
|
}
|
|
|
|
func (X11ViewEvent) implementsViewEvent() {}
|
|
func (X11ViewEvent) ImplementsEvent() {}
|
|
func (x X11ViewEvent) Valid() bool {
|
|
return x != (X11ViewEvent{})
|
|
}
|
|
|
|
func osMain() {
|
|
select {}
|
|
}
|
|
|
|
type windowDriver func(*callbacks, []Option) error
|
|
|
|
// Only X11 driver is supported
|
|
var x11Driver windowDriver
|
|
|
|
func newWindow(window *callbacks, options []Option) {
|
|
if x11Driver == nil {
|
|
window.ProcessEvent(DestroyEvent{Err: errors.New("app: no window driver available")})
|
|
return
|
|
}
|
|
if err := x11Driver(window, options); err != nil {
|
|
window.ProcessEvent(DestroyEvent{Err: err})
|
|
}
|
|
}
|
|
|
|
// xCursor contains mapping from pointer.Cursor to XCursor.
|
|
var xCursor = [...]string{
|
|
pointer.CursorDefault: "left_ptr",
|
|
pointer.CursorNone: "",
|
|
pointer.CursorText: "xterm",
|
|
pointer.CursorVerticalText: "vertical-text",
|
|
pointer.CursorPointer: "hand2",
|
|
pointer.CursorCrosshair: "crosshair",
|
|
pointer.CursorAllScroll: "fleur",
|
|
pointer.CursorColResize: "sb_h_double_arrow",
|
|
pointer.CursorRowResize: "sb_v_double_arrow",
|
|
pointer.CursorGrab: "hand1",
|
|
pointer.CursorGrabbing: "move",
|
|
pointer.CursorNotAllowed: "crossed_circle",
|
|
pointer.CursorWait: "watch",
|
|
pointer.CursorProgress: "left_ptr_watch",
|
|
pointer.CursorNorthWestResize: "top_left_corner",
|
|
pointer.CursorNorthEastResize: "top_right_corner",
|
|
pointer.CursorSouthWestResize: "bottom_left_corner",
|
|
pointer.CursorSouthEastResize: "bottom_right_corner",
|
|
pointer.CursorNorthSouthResize: "sb_v_double_arrow",
|
|
pointer.CursorEastWestResize: "sb_h_double_arrow",
|
|
pointer.CursorWestResize: "left_side",
|
|
pointer.CursorEastResize: "right_side",
|
|
pointer.CursorNorthResize: "top_side",
|
|
pointer.CursorSouthResize: "bottom_side",
|
|
pointer.CursorNorthEastSouthWestResize: "fd_double_arrow",
|
|
pointer.CursorNorthWestSouthEastResize: "bd_double_arrow",
|
|
}
|