forked from wailsapp/wails
-
Notifications
You must be signed in to change notification settings - Fork 0
/
messageprocessor_screens.go
49 lines (42 loc) · 1.05 KB
/
messageprocessor_screens.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package application
import (
"net/http"
)
const (
ScreensGetAll = 0
ScreensGetPrimary = 1
ScreensGetCurrent = 2
)
var screensMethodNames = map[int]string{
ScreensGetAll: "GetAll",
ScreensGetPrimary: "GetPrimary",
ScreensGetCurrent: "GetCurrent",
}
func (m *MessageProcessor) processScreensMethod(method int, rw http.ResponseWriter, _ *http.Request, _ Window, _ QueryParams) {
switch method {
case ScreensGetAll:
screens, err := globalApplication.GetScreens()
if err != nil {
m.Error("GetAll: %s", err.Error())
return
}
m.json(rw, screens)
case ScreensGetPrimary:
screen, err := globalApplication.GetPrimaryScreen()
if err != nil {
m.Error("GetPrimary: %s", err.Error())
return
}
m.json(rw, screen)
case ScreensGetCurrent:
screen, err := globalApplication.CurrentWindow().GetScreen()
if err != nil {
m.Error("GetCurrent: %s", err.Error())
return
}
m.json(rw, screen)
default:
m.httpError(rw, "Unknown screens method: %d", method)
}
m.Info("Runtime Call:", "method", "Screens."+screensMethodNames[method])
}