Skip to content

Commit

Permalink
Scroll across multiple monitors
Browse files Browse the repository at this point in the history
Use the virtual space extents instead of primary screen.
  • Loading branch information
andydotxyz committed Jan 14, 2024
1 parent a9d9cca commit 6458c7b
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 5 deletions.
1 change: 1 addition & 0 deletions desk.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ type Desktop interface {
RecentApps() []AppData
Settings() DeskSettings
ContentBoundsPixels(*Screen) (x, y, w, h uint32)
RootSizePixels() (w, h uint32)
Screens() ScreenList

IconProvider() ApplicationProvider
Expand Down
23 changes: 21 additions & 2 deletions internal/ui/desk.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,17 @@ func (l *desktop) SetDesktop(id int) {
diff := id - l.desk
l.desk = id

display := l.Screens().Primary() // TODO need to iterate/find full virtual height
off := float32(diff*-display.Height) / display.Scale
_, height := l.RootSizePixels()
offPix := float32(diff * -int(height))
wins := l.wm.Windows()

starts := make([]fyne.Position, len(wins))
deltas := make([]fyne.Delta, len(wins))
for i, win := range wins {
starts[i] = win.Position()

display := l.Screens().ScreenForWindow(win)
off := offPix / display.Scale
deltas[i] = fyne.NewDelta(0, off)
}

Expand Down Expand Up @@ -193,6 +196,22 @@ func (l *desktop) ContentBoundsPixels(screen *fynedesk.Screen) (x, y, w, h uint3
return 0, 0, screenW, screenH
}

func (l *desktop) RootSizePixels() (w, h uint32) {
for _, screen := range l.Screens().Screens() {
right := uint32(screen.X + screen.Width)
bottom := uint32(screen.Y + screen.Height)

if right > w {
w = right
}
if bottom > h {
h = bottom
}
}

return w, h
}

func (l *desktop) IconProvider() fynedesk.ApplicationProvider {
return l.icons
}
Expand Down
6 changes: 4 additions & 2 deletions internal/x11/win/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,10 @@ func (c *client) SetDesktop(id int) {
diff := id - c.desk
c.desk = id

display := d.Screens().Primary() // TODO need to iterate/find full virtual height
off := float32(diff*display.Height) / display.Scale
_, height := d.RootSizePixels()
offPix := float32(diff * -int(height))
display := d.Screens().ScreenForWindow(c)
off := offPix / display.Scale

start := c.Position()
fyne.NewAnimation(canvas.DurationStandard, func(f float32) {
Expand Down
6 changes: 5 additions & 1 deletion test/desktop.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ func (*Desktop) Capture() image.Image {

// ContentBoundsPixels returns a default value for how much space maximised apps should use
func (*Desktop) ContentBoundsPixels(_ *fynedesk.Screen) (x, y, w, h uint32) {
return 0, 0, uint32(320), uint32(240)
return 0, 0, 320, 240
}

func (*Desktop) RootSizePixels() (w, h uint32) {

Check failure on line 51 in test/desktop.go

View workflow job for this annotation

GitHub Actions / checks

exported method Desktop.RootSizePixels should have comment or be unexported
return 320, 240
}

// Desktop returns the index of the current desktop (in test this is always 0)
Expand Down

0 comments on commit 6458c7b

Please sign in to comment.