diff --git a/internal/desktop/xevent.go b/internal/desktop/xevent.go index 3e4f5942..4d67905f 100644 --- a/internal/desktop/xevent.go +++ b/internal/desktop/xevent.go @@ -5,21 +5,31 @@ import ( ) func (manager *DesktopManagerCtx) OnCursorChanged(listener func(serial uint64)) { - xevent.OnCursorChanged(listener) + xevent.Emmiter.On("cursor-changed", func(payload ...interface{}) { + listener(payload[0].(uint64)) + }) } func (manager *DesktopManagerCtx) OnClipboardUpdated(listener func()) { - xevent.OnClipboardUpdated(listener) + xevent.Emmiter.On("clipboard-updated", func(payload ...interface{}) { + listener() + }) } func (manager *DesktopManagerCtx) OnFileChooserDialogOpened(listener func()) { - xevent.OnFileChooserDialogOpened(listener) + xevent.Emmiter.On("file-chooser-dialog-opened", func(payload ...interface{}) { + listener() + }) } func (manager *DesktopManagerCtx) OnFileChooserDialogClosed(listener func()) { - xevent.OnFileChooserDialogClosed(listener) + xevent.Emmiter.On("file-chooser-dialog-closed", func(payload ...interface{}) { + listener() + }) } func (manager *DesktopManagerCtx) OnEventError(listener func(error_code uint8, message string, request_code uint8, minor_code uint8)) { - xevent.OnEventError(listener) + xevent.Emmiter.On("event-error", func(payload ...interface{}) { + listener(payload[0].(uint8), payload[1].(string), payload[2].(uint8), payload[3].(uint8)) + }) } diff --git a/internal/desktop/xevent/xevent.go b/internal/desktop/xevent/xevent.go index 42decebb..461e79c5 100644 --- a/internal/desktop/xevent/xevent.go +++ b/internal/desktop/xevent/xevent.go @@ -15,11 +15,11 @@ import ( "github.com/kataras/go-events" ) -var emmiter events.EventEmmiter +var Emmiter events.EventEmmiter var file_chooser_dialog_window uint32 = 0 func init() { - emmiter = events.New() + Emmiter = events.New() } func EventLoop(display string) { @@ -29,44 +29,14 @@ func EventLoop(display string) { C.XEventLoop(displayUnsafe) } -func OnCursorChanged(listener func(serial uint64)) { - emmiter.On("cursor-changed", func(payload ...interface{}) { - listener(payload[0].(uint64)) - }) -} - -func OnClipboardUpdated(listener func()) { - emmiter.On("clipboard-updated", func(payload ...interface{}) { - listener() - }) -} - -func OnFileChooserDialogOpened(listener func()) { - emmiter.On("file-chooser-dialog-opened", func(payload ...interface{}) { - listener() - }) -} - -func OnFileChooserDialogClosed(listener func()) { - emmiter.On("file-chooser-dialog-closed", func(payload ...interface{}) { - listener() - }) -} - -func OnEventError(listener func(error_code uint8, message string, request_code uint8, minor_code uint8)) { - emmiter.On("event-error", func(payload ...interface{}) { - listener(payload[0].(uint8), payload[1].(string), payload[2].(uint8), payload[3].(uint8)) - }) -} - //export goXEventCursorChanged func goXEventCursorChanged(event C.XFixesCursorNotifyEvent) { - emmiter.Emit("cursor-changed", uint64(event.cursor_serial)) + Emmiter.Emit("cursor-changed", uint64(event.cursor_serial)) } //export goXEventClipboardUpdated func goXEventClipboardUpdated() { - emmiter.Emit("clipboard-updated") + Emmiter.Emit("clipboard-updated") } //export goXEventConfigureNotify @@ -89,7 +59,7 @@ func goXEventConfigureNotify(display *C.Display, window C.Window, name *C.char, if file_chooser_dialog_window == 0 { file_chooser_dialog_window = uint32(window) - emmiter.Emit("file-chooser-dialog-opened") + Emmiter.Emit("file-chooser-dialog-opened") } } @@ -100,12 +70,12 @@ func goXEventUnmapNotify(window C.Window) { } file_chooser_dialog_window = 0 - emmiter.Emit("file-chooser-dialog-closed") + Emmiter.Emit("file-chooser-dialog-closed") } //export goXEventError func goXEventError(event *C.XErrorEvent, message *C.char) { - emmiter.Emit("event-error", uint8(event.error_code), C.GoString(message), uint8(event.request_code), uint8(event.minor_code)) + Emmiter.Emit("event-error", uint8(event.error_code), C.GoString(message), uint8(event.request_code), uint8(event.minor_code)) } //export goXEventActive