mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-21 11:29:29 +08:00
[v3 linux] initial pass at event generation
This commit is contained in:
parent
a773da2651
commit
ca21a3b79d
@ -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",
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
linux:SystemThemeChanged
|
||||
mac:ApplicationDidBecomeActive
|
||||
mac:ApplicationDidChangeBackingProperties
|
||||
mac:ApplicationDidChangeEffectiveAppearance
|
||||
@ -167,3 +168,4 @@ common:WindowHide
|
||||
common:WindowDPIChanged
|
||||
common:WindowFilesDropped
|
||||
common:ThemeChanged
|
||||
|
||||
|
@ -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())
|
||||
|
Loading…
Reference in New Issue
Block a user