5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-08 07:21:46 +08:00

[v3 linux] correct bug in getScreenByIndex

This commit is contained in:
Travis McLane 2023-11-09 21:11:35 -06:00
parent eae73dfa18
commit 53ea6511fc

View File

@ -560,23 +560,31 @@ func getScreenByIndex(display *C.struct__GdkDisplay, index int) *Screen {
if C.gdk_monitor_is_primary(monitor) == 1 {
primary = true
}
return &Screen{
ID: fmt.Sprintf("%d", index),
Name: fmt.Sprintf("Screen %d", index),
IsPrimary: primary,
Scale: 1.0,
Scale: float32(C.gdk_monitor_get_scale_factor(monitor)),
X: int(geometry.x),
Y: int(geometry.y),
Size: Size{
Height: int(geometry.height),
Width: int(geometry.width),
},
Bounds: Rect{
X: int(geometry.x),
Y: int(geometry.y),
Height: int(geometry.height),
Width: int(geometry.width),
},
}
}
func getScreens(app pointer) ([]*Screen, error) {
var screens []*Screen
window := C.gtk_application_get_active_window((*C.GtkApplication)(app))
display := C.gdk_window_get_display((*C.GdkWindow)(unsafe.Pointer(window)))
gdkWindow := C.gtk_widget_get_window((*C.GtkWidget)(unsafe.Pointer(window)))
display := C.gdk_window_get_display(gdkWindow)
count := C.gdk_display_get_n_monitors(display)
for i := 0; i < int(count); i++ {
screens = append(screens, getScreenByIndex(display, i))