Skip to content

Commit

Permalink
[v3 linux] correct bug in getScreenByIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
tmclane committed Nov 10, 2023
1 parent eae73df commit 53ea651
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions v3/pkg/application/linux_cgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 53ea651

Please sign in to comment.