diff --git a/v3/pkg/events/events.go b/v3/pkg/events/events.go index 72162dfd3..15c231bf1 100644 --- a/v3/pkg/events/events.go +++ b/v3/pkg/events/events.go @@ -53,6 +53,18 @@ func newCommonEvents() commonEvents { } } +var Linux = newLinuxEvents() + +type linuxEvents struct { + SystemThemeChanged ApplicationEventType +} + +func newLinuxEvents() linuxEvents { + return linuxEvents{ + SystemThemeChanged: 1193, + } +} + var Mac = newMacEvents() type macEvents struct { @@ -545,4 +557,5 @@ var eventToJS = map[uint]string{ 1190: "common:WindowDPIChanged", 1191: "common:WindowFilesDropped", 1192: "common:ThemeChanged", + 1193: "linux:SystemThemeChanged", } diff --git a/v3/pkg/events/events.txt b/v3/pkg/events/events.txt index 73c52bff2..ff57ffbe9 100644 --- a/v3/pkg/events/events.txt +++ b/v3/pkg/events/events.txt @@ -1,3 +1,4 @@ +linux:SystemThemeChanged mac:ApplicationDidBecomeActive mac:ApplicationDidChangeBackingProperties mac:ApplicationDidChangeEffectiveAppearance @@ -167,3 +168,4 @@ common:WindowHide common:WindowDPIChanged common:WindowFilesDropped common:ThemeChanged + diff --git a/v3/tasks/events/generate.go b/v3/tasks/events/generate.go index aade6d266..2044f1c70 100644 --- a/v3/tasks/events/generate.go +++ b/v3/tasks/events/generate.go @@ -22,6 +22,16 @@ func newCommonEvents() commonEvents { $$COMMONEVENTSVALUES } } +var Linux = newLinuxEvents() + +type linuxEvents struct { +$$LINUXEVENTSDECL} + +func newLinuxEvents() linuxEvents { + return linuxEvents{ +$$LINUXEVENTSVALUES } +} + var Mac = newMacEvents() type macEvents struct { @@ -81,6 +91,9 @@ func main() { panic(err) } + linuxEventsDecl := bytes.NewBufferString("") + linuxEventsValues := bytes.NewBufferString("") + macEventsDecl := bytes.NewBufferString("") macEventsValues := bytes.NewBufferString("") cHeaderEvents := bytes.NewBufferString("") @@ -94,6 +107,7 @@ func main() { commonEventsDecl := bytes.NewBufferString("") commonEventsValues := bytes.NewBufferString("") + linuxJSEvents := bytes.NewBufferString("") macJSEvents := bytes.NewBufferString("") windowsJSEvents := bytes.NewBufferString("") commonJSEvents := bytes.NewBufferString("") @@ -101,6 +115,7 @@ func main() { eventToJS := bytes.NewBufferString("") var id int + // var maxLinuxEvents int var maxMacEvents int var line []byte // Loop over each line in the file @@ -131,6 +146,19 @@ func main() { // Add to buffer switch platform { + case "linux": + eventType := "ApplicationEventType" + if strings.HasPrefix(event, "Window") { + eventType = "WindowEventType" + } + if strings.HasPrefix(event, "WebView") { + eventType = "WindowEventType" + } + linuxEventsDecl.WriteString("\t" + eventTitle + " " + eventType + "\n") + linuxEventsValues.WriteString("\t\t" + event + ": " + strconv.Itoa(id) + ",\n") + linuxJSEvents.WriteString("\t\t" + event + ": \"" + strings.TrimSpace(string(line)) + "\",\n") + eventToJS.WriteString("\t" + strconv.Itoa(id) + ": \"" + strings.TrimSpace(string(line)) + "\",\n") + //maxLinuxEvents = id case "mac": eventType := "ApplicationEventType" if strings.HasPrefix(event, "Window") { @@ -209,8 +237,11 @@ func main() { cHeaderEvents.WriteString("\n#define MAX_EVENTS " + strconv.Itoa(maxMacEvents+1) + "\n") // Save the eventsGo template substituting the values and decls - templateToWrite := strings.ReplaceAll(eventsGo, "$$MACEVENTSDECL", macEventsDecl.String()) + templateToWrite := strings.ReplaceAll(eventsGo, "$$LINUXEVENTSDECL", linuxEventsDecl.String()) + templateToWrite = strings.ReplaceAll(templateToWrite, "$$LINUXEVENTSVALUES", linuxEventsValues.String()) + templateToWrite = strings.ReplaceAll(templateToWrite, "$$MACEVENTSDECL", macEventsDecl.String()) templateToWrite = strings.ReplaceAll(templateToWrite, "$$MACEVENTSVALUES", macEventsValues.String()) + templateToWrite = strings.ReplaceAll(templateToWrite, "$$WINDOWSEVENTSDECL", windowsEventsDecl.String()) templateToWrite = strings.ReplaceAll(templateToWrite, "$$WINDOWSEVENTSVALUES", windowsEventsValues.String()) templateToWrite = strings.ReplaceAll(templateToWrite, "$$COMMONEVENTSDECL", commonEventsDecl.String())