x-backend #2

Merged
sashakoshka merged 34 commits from x-backend into main 2022-11-14 21:40:25 -07:00
4 changed files with 15 additions and 11 deletions
Showing only changes of commit 1d71df180d - Show all commits

View File

@ -42,7 +42,9 @@ func (backend *Backend) handleButtonPress (
event xevent.ButtonPressEvent, event xevent.ButtonPressEvent,
) { ) {
buttonEvent := *event.ButtonPressEvent buttonEvent := *event.ButtonPressEvent
backend.channel <- stone.EventPress(buttonEvent.Detail) backend.channel <- stone.EventPress {
Button: stone.Button(buttonEvent.Detail),
}
} }
func (backend *Backend) handleButtonRelease ( func (backend *Backend) handleButtonRelease (
@ -50,7 +52,9 @@ func (backend *Backend) handleButtonRelease (
event xevent.ButtonReleaseEvent, event xevent.ButtonReleaseEvent,
) { ) {
buttonEvent := *event.ButtonReleaseEvent buttonEvent := *event.ButtonReleaseEvent
backend.channel <- stone.EventRelease(buttonEvent.Detail) backend.channel <- stone.EventRelease {
Button: stone.Button(buttonEvent.Detail),
}
} }
func (backend *Backend) handleKeyPress ( func (backend *Backend) handleKeyPress (
@ -59,7 +63,7 @@ func (backend *Backend) handleKeyPress (
) { ) {
keyEvent := *event.KeyPressEvent keyEvent := *event.KeyPressEvent
button := backend.keycodeToButton(keyEvent.Detail, keyEvent.State) button := backend.keycodeToButton(keyEvent.Detail, keyEvent.State)
backend.channel <- stone.EventPress(button) backend.channel <- stone.EventPress { Button: button }
} }
func (backend *Backend) handleKeyRelease ( func (backend *Backend) handleKeyRelease (
@ -68,7 +72,7 @@ func (backend *Backend) handleKeyRelease (
) { ) {
keyEvent := *event.KeyReleaseEvent keyEvent := *event.KeyReleaseEvent
button := backend.keycodeToButton(keyEvent.Detail, keyEvent.State) button := backend.keycodeToButton(keyEvent.Detail, keyEvent.State)
backend.channel <- stone.EventRelease(button) backend.channel <- stone.EventRelease { Button: button }
} }
func (backend *Backend) handleMotionNotify ( func (backend *Backend) handleMotionNotify (

View File

@ -3,8 +3,8 @@ package stone
type Event interface { } type Event interface { }
type EventQuit struct { } type EventQuit struct { }
type EventPress Button type EventPress struct { Button }
type EventRelease Button type EventRelease struct { Button }
type EventResize struct { } type EventResize struct { }
type EventMouseMove struct { type EventMouseMove struct {
X int X int

View File

@ -38,16 +38,16 @@ func main () {
os.Exit(0) os.Exit(0)
case stone.EventPress: case stone.EventPress:
event := event.(stone.EventPress) button := event.(stone.EventPress).Button
if stone.Button(event) == stone.MouseButtonLeft { if button == stone.MouseButtonLeft {
mousePressed = true mousePressed = true
application.SetRune(0, 0, '+') application.SetRune(0, 0, '+')
application.Draw() application.Draw()
} }
case stone.EventRelease: case stone.EventRelease:
event := event.(stone.EventRelease) button := event.(stone.EventRelease).Button
if stone.Button(event) == stone.MouseButtonLeft { if button == stone.MouseButtonLeft {
mousePressed = false mousePressed = false
application.SetRune(0, 0, 0) application.SetRune(0, 0, 0)
application.Draw() application.Draw()

View File

@ -38,7 +38,7 @@ func main () {
os.Exit(0) os.Exit(0)
case stone.EventPress: case stone.EventPress:
button := stone.Button(event.(stone.EventPress)) button := event.(stone.EventPress).Button
if button.Printable() { if button.Printable() {
application.SetRune(caret, 0, rune(button)) application.SetRune(caret, 0, rune(button))
caret ++ caret ++