Skip to content

Commit

Permalink
Merge branch 'develop' into feature/desktopfiles
Browse files Browse the repository at this point in the history
  • Loading branch information
andydotxyz committed Feb 2, 2024
2 parents 9917ffa + 399c17c commit 9cb6b78
Show file tree
Hide file tree
Showing 21 changed files with 355 additions and 83 deletions.
3 changes: 2 additions & 1 deletion AUTHORS
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Andy Williams <[email protected]>
Stephen Houston <[email protected]>
Jacob Alzén <>
Jacob Alzén <tutanota.com>
Tai Groot <[email protected]>
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
6 changes: 6 additions & 0 deletions internal/notify/desktop.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package notify

// DesktopNotify allows modules to be informed when user changes virtual desktop
type DesktopNotify interface {
DesktopChangeNotify(int)
}
4 changes: 2 additions & 2 deletions internal/ui/about.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ func (w *widgetPanel) showAbout() {

title := widget.NewRichTextFromMarkdown("**Version:** " + version())
title.Segments[0].(*widget.TextSegment).Style.Alignment = fyne.TextAlignCenter
authors := widget.NewRichTextFromMarkdown("\n**Authors:**\n\n * Andy Williams\n * Stephen Houston\n * Jacob Alzén\n")
authors := widget.NewRichTextFromMarkdown("\n**Authors:**\n\n * Andy Williams\n * Stephen Houston\n * Jacob Alzén\n * Tai Groot\n")
buttons := container.NewGridWithColumns(3,
newURLButton("Home Page", "https://fyshos.com/fynedesk"),
newURLButton("Report Issue", "https://github.com/fyne-io/fynedesk/issues/new"),
newURLButton("Report Issue", "https://github.com/FyshOS/fynedesk/issues/new"),
newURLButton("Sponsor", "https://github.com/sponsors/fyne-io"),
)

Expand Down
4 changes: 4 additions & 0 deletions internal/ui/bar.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ func (b *bar) WindowAdded(win fynedesk.Window) {
}
}

func (b *bar) WindowMoved(_ fynedesk.Window) {}

func (b *bar) WindowOrderChanged() {}

func (b *bar) WindowRemoved(win fynedesk.Window) {
if win.Properties().SkipTaskbar() || b.desk.Settings().LauncherDisableTaskbar() {
return
Expand Down
58 changes: 49 additions & 9 deletions internal/ui/desk.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ import (
"os/exec"
"strconv"

"fyshos.com/fynedesk"
wmtheme "fyshos.com/fynedesk/theme"
"fyshos.com/fynedesk/wm"

"fyne.io/fyne/v2"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/container"
deskDriver "fyne.io/fyne/v2/driver/desktop"

"fyshos.com/fynedesk"
"fyshos.com/fynedesk/internal/notify"
wmtheme "fyshos.com/fynedesk/theme"
"fyshos.com/fynedesk/wm"
)

const (
Expand Down Expand Up @@ -46,13 +48,35 @@ func (l *desktop) Desktop() int {
}

func (l *desktop) SetDesktop(id int) {
diff := id - l.desk
l.desk = id

for _, item := range l.wm.Windows() {
if item.Desktop() == id {
item.Uniconify()
} else {
item.Iconify()
_, 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)
}

fyne.NewAnimation(canvas.DurationStandard, func(f float32) {
for i, item := range l.wm.Windows() {
newX := starts[i].X + deltas[i].DX*f
newY := starts[i].Y + deltas[i].DY*f

item.Move(fyne.NewPos(newX, newY))
}
}).Start()

for _, m := range l.Modules() {
if desk, ok := m.(notify.DesktopNotify); ok {
desk.DesktopChangeNotify(id)
}
}
}
Expand Down Expand Up @@ -179,6 +203,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
46 changes: 45 additions & 1 deletion internal/ui/menu.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package ui

import (
"image/color"
"os"
"sort"

"fyne.io/fyne/v2"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/container"
deskDriver "fyne.io/fyne/v2/driver/desktop"
"fyne.io/fyne/v2/layout"
"fyne.io/fyne/v2/theme"
"fyne.io/fyne/v2/widget"

Expand Down Expand Up @@ -49,6 +52,47 @@ func (w *widgetPanel) appendAppCategories(acc *widget.Accordion, win fyne.Window
acc.Refresh()
}

func (w *widgetPanel) askLogout() {
win := fyne.CurrentApp().Driver().(deskDriver.Driver).CreateSplashWindow()
logout := widget.NewButtonWithIcon("Logout", theme.LogoutIcon(), func() {
win.Close()
w.desk.WindowManager().Close()
})
logout.Importance = widget.DangerImportance
cancel := widget.NewButton("Cancel", func() {
win.Close()
})

header := widget.NewRichTextFromMarkdown("### Log out")
header.Truncation = fyne.TextTruncateEllipsis
bottomPad := canvas.NewRectangle(color.Transparent)
bottomPad.SetMinSize(fyne.NewSquareSize(10))
content := container.NewBorder(
header,
container.NewVBox(
container.NewHBox(layout.NewSpacer(),
container.NewGridWithColumns(2, cancel, logout),
layout.NewSpacer()), bottomPad),
nil, nil,
widget.NewLabel("Are you sure you want to log out?"))

r, g, b, _ := theme.OverlayBackgroundColor().RGBA()
bgCol := &color.NRGBA{R: uint8(r), G: uint8(g), B: uint8(b), A: 230}

bg := canvas.NewRectangle(bgCol)
icon := canvas.NewImageFromResource(theme.LogoutIcon())
iconBox := container.NewWithoutLayout(icon)
icon.Resize(fyne.NewSize(92, 92))
icon.Move(fyne.NewPos(280-92-theme.Padding(), theme.Padding()))
win.SetContent(container.NewStack(
iconBox, bg,
container.NewPadded(content)))

win.Resize(fyne.NewSize(280, 150))
win.CenterOnScreen()
win.Show()
}

func (w *widgetPanel) showAccountMenu(_ fyne.CanvasObject) {
w2 := fyne.CurrentApp().Driver().(deskDriver.Driver).CreateSplashWindow()
w2.Canvas().SetOnTypedKey(func(k *fyne.KeyEvent) {
Expand All @@ -58,8 +102,8 @@ func (w *widgetPanel) showAccountMenu(_ fyne.CanvasObject) {
})
items1 := []fyne.CanvasObject{
&widget.Button{Icon: theme.LogoutIcon(), Importance: widget.DangerImportance, OnTapped: func() {
w.askLogout()
w2.Close()
w.desk.WindowManager().Close()
}}}
isEmbed := w.desk.(*desktop).root.Title() != RootWindowName
if !isEmbed {
Expand Down
11 changes: 8 additions & 3 deletions internal/ui/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package ui

import (
"os"
"runtime"
"strings"
"sync"

Expand Down Expand Up @@ -234,13 +235,17 @@ func (d *deskSettings) load() {
d.launcherZoomScale = 2.0
}

moduleNames := fyne.CurrentApp().Preferences().StringWithFallback("modulenames", "Battery|Brightness|Compositor|Sound|Launcher: Calculate|Launcher: Open URLs|Network|Virtual Desktops")
defaultModules := "Battery|Brightness|Compositor|Sound|Launcher: Calculate|Launcher: Open URLs|Network|Virtual Desktops|SystemTray"
if runtime.GOOS == "darwin" || runtime.GOOS == "windows" { // testing
defaultModules = "Battery|Brightness|Sound|Launcher: Calculate|Launcher: Open URLs|Network|Virtual Desktops"
}
moduleNames := fyne.CurrentApp().Preferences().StringWithFallback("modulenames", defaultModules)
if moduleNames != "" {
d.moduleNames = strings.Split(moduleNames, "|")
}
d.modifier = fyne.KeyModifier(fyne.CurrentApp().Preferences().IntWithFallback("keyboardmodifier", int(fyne.KeyModifierSuper)))
d.narrowLeftLauncher = fyne.CurrentApp().Preferences().Bool("launchernarrowleft")
d.narrowPanel = fyne.CurrentApp().Preferences().Bool("narrowpanel")
d.narrowLeftLauncher = fyne.CurrentApp().Preferences().BoolWithFallback("launchernarrowleft", true)
d.narrowPanel = fyne.CurrentApp().Preferences().BoolWithFallback("narrowpanel", true)

d.borderButtonPosition = fyne.CurrentApp().Preferences().StringWithFallback("borderbuttonposition", "Left")

Expand Down
5 changes: 5 additions & 0 deletions internal/ui/switcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"image/color"
"time"

wmTheme "fyshos.com/fynedesk/theme"

"fyne.io/fyne/v2"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/container"
Expand Down Expand Up @@ -37,6 +39,9 @@ func (s *switchIcon) CreateRenderer() fyne.WidgetRenderer {
} else {
res = s.win.Properties().Icon()
}
if res == nil {
res = wmTheme.BrokenImageIcon
}

bg := canvas.NewRectangle(color.Transparent)
bg.CornerRadius = theme.InputRadiusSize()
Expand Down
47 changes: 40 additions & 7 deletions internal/x11/win/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ package win
import (
"image"

"fyne.io/fyne/v2"

"github.com/BurntSushi/xgb/xproto"
"github.com/BurntSushi/xgbutil/ewmh"
"github.com/BurntSushi/xgbutil/icccm"
"github.com/BurntSushi/xgbutil/xevent"
"github.com/BurntSushi/xgbutil/xprop"

"fyne.io/fyne/v2"
"fyne.io/fyne/v2/canvas"

"fyshos.com/fynedesk"
"fyshos.com/fynedesk/internal/x11"
"fyshos.com/fynedesk/wm"
Expand Down Expand Up @@ -125,12 +126,28 @@ func (c *client) SetDesktop(id int) {
}

d := fynedesk.Instance()
diff := id - c.desk
c.desk = id
if id == d.Desktop() {
c.Uniconify()
} else {
c.Iconify()
}

_, 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) {
newY := start.Y - off*f

c.Move(fyne.NewPos(start.X, newY))

type moveNotifier interface {
NotifyWindowMoved(win fynedesk.Window)
}
if mover, ok := fynedesk.Instance().WindowManager().(moveNotifier); ok {
mover.NotifyWindowMoved(c)
}

}).Start()
}

func (c *client) Expose() {
Expand Down Expand Up @@ -193,6 +210,14 @@ func (c *client) Maximized() bool {
return c.maximized
}

func (c *client) Move(pos fyne.Position) {
screen := fynedesk.Instance().Screens().ScreenForWindow(c)

targetX := int16(pos.X * screen.CanvasScale())
targetY := int16(pos.Y * screen.CanvasScale())
c.frame.updateGeometry(targetX, targetY, c.frame.width, c.frame.height, false)
}

func (c *client) NotifyBorderChange() {
c.props.refreshCache()
if c.Properties().Decorated() {
Expand Down Expand Up @@ -292,6 +317,14 @@ func (c *client) Position() fyne.Position {
float32(c.frame.y)/screen.CanvasScale())
}

func (c *client) Size() fyne.Size {
screen := fynedesk.Instance().Screens().ScreenForWindow(c)

return fyne.NewSize(
float32(c.frame.width)/screen.CanvasScale(),
float32(c.frame.height)/screen.CanvasScale())
}

func (c *client) QueueMoveResizeGeometry(x int, y int, width uint, height uint) {
c.frame.queueGeometry(int16(x), int16(y), uint16(width), uint16(height), true)
}
Expand Down
Loading

0 comments on commit 9cb6b78

Please sign in to comment.