Skip to content

Commit

Permalink
fixed support for HiDPI for fullscreen screenshots
Browse files Browse the repository at this point in the history
  • Loading branch information
KrystianD committed Nov 24, 2020
1 parent db39071 commit 386e900
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions xwindows.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,32 +58,36 @@ func XPropGetPropertyLRTB(xu *xgbutil.XUtil, win xproto.Window, atomName string)
return true, left, right, top, bottom
}

func getCurrentToplevelWindows() []DesktopWindow {
var windows []DesktopWindow

X, err := xgbutil.NewConn()
func getScaleFactor() int {
device, err := gdk.DisplayGetDefault()
if err != nil {
log.Fatal(err)
}

clientIds, err := ewmh.ClientListStackingGet(X)
m, err := device.GetPrimaryMonitor()
if err != nil {
log.Fatal(err)
}

curDesktop, _ := ewmh.CurrentDesktopGet(X)
return m.GetScaleFactor()
}

device, err := gdk.DisplayGetDefault()
func getCurrentToplevelWindows() []DesktopWindow {
var windows []DesktopWindow

X, err := xgbutil.NewConn()
if err != nil {
log.Fatal(err)
}

m, err := device.GetPrimaryMonitor()
clientIds, err := ewmh.ClientListStackingGet(X)
if err != nil {
log.Fatal(err)
}

scale := m.GetScaleFactor()
curDesktop, _ := ewmh.CurrentDesktopGet(X)

scale := getScaleFactor()

for _, clientId := range clientIds {
win := xwindow.New(X, clientId)
Expand Down Expand Up @@ -154,7 +158,9 @@ func getRootWindowRect() Rectangle {
log.Fatal(err)
}

return NewRectangleFromXYWH(0, 0, rootWindow.WindowGetWidth(), rootWindow.WindowGetHeight())
scale := getScaleFactor()

return NewRectangleFromXYWH(0, 0, rootWindow.WindowGetWidth()/scale, rootWindow.WindowGetHeight()/scale)
}

func getMousePosition() Point {
Expand Down

0 comments on commit 386e900

Please sign in to comment.