mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-12 06:59:30 +08:00
[v3 linux] correct bug in getScreenByIndex
This commit is contained in:
parent
eae73dfa18
commit
53ea6511fc
@ -560,23 +560,31 @@ func getScreenByIndex(display *C.struct__GdkDisplay, index int) *Screen {
|
|||||||
if C.gdk_monitor_is_primary(monitor) == 1 {
|
if C.gdk_monitor_is_primary(monitor) == 1 {
|
||||||
primary = true
|
primary = true
|
||||||
}
|
}
|
||||||
|
|
||||||
return &Screen{
|
return &Screen{
|
||||||
|
ID: fmt.Sprintf("%d", index),
|
||||||
|
Name: fmt.Sprintf("Screen %d", index),
|
||||||
IsPrimary: primary,
|
IsPrimary: primary,
|
||||||
Scale: 1.0,
|
Scale: float32(C.gdk_monitor_get_scale_factor(monitor)),
|
||||||
X: int(geometry.x),
|
X: int(geometry.x),
|
||||||
Y: int(geometry.y),
|
Y: int(geometry.y),
|
||||||
Size: Size{
|
Size: Size{
|
||||||
Height: int(geometry.height),
|
Height: int(geometry.height),
|
||||||
Width: int(geometry.width),
|
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) {
|
func getScreens(app pointer) ([]*Screen, error) {
|
||||||
var screens []*Screen
|
var screens []*Screen
|
||||||
window := C.gtk_application_get_active_window((*C.GtkApplication)(app))
|
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)
|
count := C.gdk_display_get_n_monitors(display)
|
||||||
for i := 0; i < int(count); i++ {
|
for i := 0; i < int(count); i++ {
|
||||||
screens = append(screens, getScreenByIndex(display, i))
|
screens = append(screens, getScreenByIndex(display, i))
|
||||||
|
Loading…
Reference in New Issue
Block a user