Skip to content

Commit

Permalink
Merge pull request #254 from andydotxyz/feature/pagericons
Browse files Browse the repository at this point in the history
  • Loading branch information
andydotxyz authored Feb 2, 2024
2 parents 2e11f63 + 3af4cb5 commit 399c17c
Show file tree
Hide file tree
Showing 16 changed files with 179 additions and 44 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]>
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module fyshos.com/fynedesk
go 1.17

require (
fyne.io/fyne/v2 v2.4.4-0.20240107115323-8458aff4b006
fyne.io/fyne/v2 v2.4.3
github.com/BurntSushi/xgb v0.0.0-20201008132610-5f9e7b3c49cd
github.com/BurntSushi/xgbutil v0.0.0-20160919175755-f7c97cef3b4e
github.com/FyshOS/backgrounds v0.0.0-20230616202904-0a8b6ebaa184
Expand Down Expand Up @@ -36,7 +36,6 @@ require (
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
github.com/pkg/errors v0.8.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rymdport/portal v0.0.0-20231123202536-da45518a87bb // indirect
github.com/srwiley/oksvg v0.0.0-20221011165216-be6e8873101c // indirect
github.com/srwiley/rasterx v0.0.0-20220730225603-2ab79fcdd4ef // indirect
github.com/yuin/goldmark v1.5.5 // indirect
Expand All @@ -47,6 +46,7 @@ require (
golang.org/x/text v0.14.0 // indirect
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
honnef.co/go/js/dom v0.0.0-20210725211120-f030747120f2 // indirect
)

replace github.com/BurntSushi/xgbutil => github.com/fyne-io/xgbutil v0.0.0-20191220152344-7d838166824d
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl
cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs=
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
fyne.io/fyne/v2 v2.4.4-0.20240107115323-8458aff4b006 h1:7zQ59DzG2vWbcHvE/ElPhrkP5Qy8CO15fJenSm22v74=
fyne.io/fyne/v2 v2.4.4-0.20240107115323-8458aff4b006/go.mod h1:lcFfOoGu75+eS+ERtXM8OZQy+czyIfHxohlc9wSCslE=
fyne.io/fyne/v2 v2.4.3 h1:v2wncjEAcwXZ8UNmTCWTGL9+sGyPc5RuzBvM96GcC78=
fyne.io/fyne/v2 v2.4.3/go.mod h1:1h3BKxmQYRJlr2g+RGVxedzr6vLVQ/AJmFWcF9CJnoQ=
fyne.io/systray v1.10.1-0.20231230205326-d160fd363db9 h1:E/gHmMVyk8TuI6JIgNIv/Qu1JABMVFBIkQ8lYRa5gkQ=
fyne.io/systray v1.10.1-0.20231230205326-d160fd363db9/go.mod h1:RVwqP9nYMo7h5zViCBHri2FgjXF7H2cub7MAq4NSoLs=
github.com/BurntSushi/freetype-go v0.0.0-20160129220410-b763ddbfe298 h1:1qlsVAQJXZHsaM8b6OLVo6muQUQd4CwkH/D3fnnbHXA=
Expand Down Expand Up @@ -261,8 +261,6 @@ github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6L
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
github.com/rymdport/portal v0.0.0-20231123202536-da45518a87bb h1:ejEomhJX7G4p8dFImv2zcQd2Oa0IpWIeB/FUZRnpQKg=
github.com/rymdport/portal v0.0.0-20231123202536-da45518a87bb/go.mod h1:RYYAnv4sssTQ7ceErKl7UD8auER/0yFV7CgmfS/uAD8=
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
github.com/shurcooL/go v0.0.0-20200502201357-93f07166e636/go.mod h1:TDJrrUr11Vxrven61rcy3hJMUqaf/CLWYhHNPmT14Lk=
github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749/go.mod h1:ZY1cvUeJuFPAdZ/B6v7RHavJWZn2YPVFQ1OSXhCGOkg=
Expand Down Expand Up @@ -661,6 +659,8 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
honnef.co/go/js/dom v0.0.0-20210725211120-f030747120f2 h1:oomkgU6VaQDsV6qZby2uz1Lap0eXmku8+2em3A/l700=
honnef.co/go/js/dom v0.0.0-20210725211120-f030747120f2/go.mod h1:sUMDUKNB2ZcVjt92UnLy3cdGs+wDAcrPdV3JP6sVgA4=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
Expand Down
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
18 changes: 17 additions & 1 deletion internal/x11/win/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,17 @@ func (c *client) SetDesktop(id int) {

start := c.Position()
fyne.NewAnimation(canvas.DurationStandard, func(f float32) {
newY := start.Y + off*f
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()
}

Expand Down Expand Up @@ -309,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
57 changes: 35 additions & 22 deletions internal/x11/win/frame.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ type frame struct {
resizeLeft, resizeRight bool
moveOnly, ignoreDrag bool

borderTop, borderTopRight xproto.Pixmap
borderTopWidth uint16
borderTop, borderTopRight xproto.Pixmap
borderTopGC, borderTopRightGC, rectGC xproto.Gcontext
borderTopWidth uint16

hovered desktop.Hoverable
clickCount int
Expand Down Expand Up @@ -305,6 +306,20 @@ func (f *frame) createPixmaps(depth byte) error {
xproto.Drawable(f.client.wm.X().Screen().Root), rightWidthPix, heightPix)
f.borderTopRight = pid

backR, backG, backB, _ := theme.DisabledButtonColor().RGBA()
if f.client.Focused() {
backR, backG, backB, _ = theme.BackgroundColor().RGBA()
}
bgColor := uint32(uint8(backR))<<16 | uint32(uint8(backG))<<8 | uint32(uint8(backB))

f.rectGC, _ = xproto.NewGcontextId(f.client.wm.Conn())
xproto.CreateGC(f.client.wm.Conn(), f.rectGC, xproto.Drawable(f.client.id), xproto.GcForeground, []uint32{bgColor})

f.borderTopGC, _ = xproto.NewGcontextId(f.client.wm.Conn())
xproto.CreateGC(f.client.wm.Conn(), f.borderTopGC, xproto.Drawable(f.borderTop), xproto.GcForeground, []uint32{bgColor})
f.borderTopRightGC, _ = xproto.NewGcontextId(f.client.wm.Conn())
xproto.CreateGC(f.client.wm.Conn(), f.borderTopRightGC, xproto.Drawable(f.borderTopRight), xproto.GcForeground, []uint32{bgColor})

return nil
}

Expand All @@ -324,35 +339,20 @@ func (f *frame) decorate(force bool) {
refresh = true
}

backR, backG, backB, _ := theme.DisabledButtonColor().RGBA()
if f.client.Focused() {
backR, backG, backB, _ = theme.BackgroundColor().RGBA()
}
bgColor := uint32(uint8(backR))<<16 | uint32(uint8(backG))<<8 | uint32(uint8(backB))

drawTop, _ := xproto.NewGcontextId(f.client.wm.Conn())
xproto.CreateGC(f.client.wm.Conn(), drawTop, xproto.Drawable(f.borderTop), xproto.GcForeground, []uint32{bgColor})
drawTopRight, _ := xproto.NewGcontextId(f.client.wm.Conn())
xproto.CreateGC(f.client.wm.Conn(), drawTopRight, xproto.Drawable(f.borderTopRight), xproto.GcForeground, []uint32{bgColor})

if refresh || f.canvas == nil {
f.drawDecoration(f.borderTop, drawTop, f.borderTopRight, drawTopRight, depth)
f.drawDecoration(f.borderTop, f.borderTopGC, f.borderTopRight, f.borderTopRightGC, depth)
}

heightPix := x11.TitleHeight(x11.XWin(f.client))
draw, _ := xproto.NewGcontextId(f.client.wm.Conn())
xproto.CreateGC(f.client.wm.Conn(), draw, xproto.Drawable(f.client.id), xproto.GcForeground, []uint32{bgColor})
rect := xproto.Rectangle{X: 0, Y: 0, Width: f.width, Height: f.height}
xproto.PolyFillRectangleChecked(f.client.wm.Conn(), xproto.Drawable(f.client.id), draw, []xproto.Rectangle{rect})
xproto.PolyFillRectangleChecked(f.client.wm.Conn(), xproto.Drawable(f.client.id), f.rectGC, []xproto.Rectangle{rect})

rightWidthPix := f.topRightPixelWidth()
rect = xproto.Rectangle{X: 0, Y: 0, Width: f.borderTopWidth, Height: x11.TitleHeight(x11.XWin(f.client))}
xproto.PolyFillRectangleChecked(f.client.wm.Conn(), xproto.Drawable(f.client.id), draw, []xproto.Rectangle{rect})
minWidth := f.canvas.Content().MinSize().Width
widthPix := uint16(minWidth*f.canvas.Scale()) - rightWidthPix
xproto.CopyArea(f.client.wm.Conn(), xproto.Drawable(f.borderTop), xproto.Drawable(f.client.id), drawTop,
xproto.CopyArea(f.client.wm.Conn(), xproto.Drawable(f.borderTop), xproto.Drawable(f.client.id), f.borderTopGC,
0, 0, 0, 0, widthPix, heightPix)
xproto.CopyArea(f.client.wm.Conn(), xproto.Drawable(f.borderTopRight), xproto.Drawable(f.client.id), drawTopRight,
xproto.CopyArea(f.client.wm.Conn(), xproto.Drawable(f.borderTopRight), xproto.Drawable(f.client.id), f.borderTopRightGC,
0, 0, int16(f.width-rightWidthPix), 0, rightWidthPix, heightPix)
}

Expand Down Expand Up @@ -405,6 +405,19 @@ func (f *frame) freePixmaps() {
xproto.FreePixmap(f.client.wm.Conn(), f.borderTopRight)
f.borderTopRight = 0
}

if f.rectGC != 0 {
xproto.FreeGC(f.client.wm.Conn(), f.rectGC)
f.rectGC = 0
}
if f.borderTopGC != 0 {
xproto.FreeGC(f.client.wm.Conn(), f.borderTopGC)
f.borderTopGC = 0
}
if f.borderTopRightGC != 0 {
xproto.FreeGC(f.client.wm.Conn(), f.borderTopRightGC)
f.borderTopRightGC = 0
}
}

func (f *frame) getInnerWindowCoordinates(w uint16, h uint16) (uint32, uint32, uint32, uint32) {
Expand Down Expand Up @@ -819,7 +832,7 @@ func (f *frame) topRightPixelWidth() uint16 {
iconPix := x11.ButtonWidth(x11.XWin(f.client))
iconAndBorderPix := iconPix + x11.BorderWidth(x11.XWin(f.client))*2 + uint16(theme.Padding()*scale)
if fynedesk.Instance().Settings().BorderButtonPosition() == "Right" {
iconAndBorderPix *= 3
iconAndBorderPix = 3*iconAndBorderPix - uint16(theme.Padding()*scale)
}

return iconAndBorderPix - uint16(theme.Padding()*scale)
Expand Down
6 changes: 6 additions & 0 deletions internal/x11/wm/desk.go
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,12 @@ func (x *x11WM) RootID() xproto.Window {
return x.rootID
}

func (x *x11WM) NotifyWindowMoved(win fynedesk.Window) {
for _, l := range x.listeners {
go l.WindowMoved(win)
}
}

func (x *x11WM) hideWindow(win xproto.Window) {
c := x.clientForWin(win)
if c == nil || win == c.FrameID() {
Expand Down
9 changes: 9 additions & 0 deletions internal/x11/wm/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ func (x *x11WM) handleMouseMotion(ev xproto.MotionNotifyEvent) {
}
if ev.State&xproto.ButtonMask1 != 0 {
c.(x11.XWin).NotifyMouseDrag(ev.RootX, ev.RootY)
x.NotifyWindowMoved(c)
} else {
c.(x11.XWin).NotifyMouseMotion(ev.RootX, ev.RootY)
}
Expand Down Expand Up @@ -335,6 +336,12 @@ func (x *x11WM) handleStateActionRequest(ev xproto.ClientMessageEvent, removeSta
addState()
}
}
for _, c := range x.clients {
if c.(x11.XWin).ChildID() == ev.Window {
x.NotifyWindowMoved(c)
break
}
}
}

func (x *x11WM) handleVisibilityChange(ev xproto.VisibilityNotifyEvent) {
Expand Down Expand Up @@ -426,4 +433,6 @@ func (x *x11WM) moveResize(moveX, moveY int16, c x11.XWin) {
x.moveResizingLastX = moveX
x.moveResizingLastY = moveY
c.QueueMoveResizeGeometry(x.moveResizingX, x.moveResizingY, uint(w), uint(h))

x.NotifyWindowMoved(c)
}
7 changes: 6 additions & 1 deletion internal/x11/wm/stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
package wm

import (
"fyne.io/fyne/v2"
"github.com/BurntSushi/xgb/xproto"
"github.com/BurntSushi/xgbutil/ewmh"

"fyne.io/fyne/v2"

"fyshos.com/fynedesk"
"fyshos.com/fynedesk/internal/x11"
)
Expand Down Expand Up @@ -46,6 +47,10 @@ func (s *stack) RaiseToTop(win fynedesk.Window) {

wm := fynedesk.Instance().WindowManager().(*x11WM)
windowClientListStackingUpdate(wm)

for _, l := range s.listeners {
l.WindowOrderChanged()
}
}

func (s *stack) RemoveWindow(win fynedesk.Window) {
Expand Down
8 changes: 7 additions & 1 deletion internal/x11/wm/switcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,13 @@ func (x *x11WM) previousAppSwitcher() {
}

func (x *x11WM) showOrSelectAppSwitcher(reverse bool) {
if len(x.clients) <= 1 {
var visible []fynedesk.Window
for _, win := range x.clients {
if win.Desktop() == fynedesk.Instance().Desktop() && !win.Iconic() {
visible = append(visible, win)
}
}
if len(visible) <= 1 {
return
}
xproto.GrabKeyboard(x.x.Conn(), true, x.x.RootWin(), xproto.TimeCurrentTime, xproto.GrabModeAsync, xproto.GrabModeAsync)
Expand Down
9 changes: 6 additions & 3 deletions modules/desktops/desktops.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"strconv"

"fyne.io/fyne/v2"
"fyne.io/fyne/v2/container"

"fyshos.com/fynedesk"
)
Expand All @@ -21,8 +22,9 @@ type desktops struct {
}

func (d *desktops) DesktopChangeNotify(id int) {
oldID := d.current
d.current = id
d.gui.refresh()
d.gui.refreshFrom(oldID)
}

func (d *desktops) Destroy() {
Expand Down Expand Up @@ -58,13 +60,14 @@ func (d *desktops) Shortcuts() map[*fynedesk.Shortcut]func() {
}

func (d *desktops) StatusAreaWidget() fyne.CanvasObject {
return d.gui.ui
return container.NewStack(d.gui.buttons, d.gui.wins, d.gui.labels)
}

func (d *desktops) setDesktop(id int) {
oldID := d.current
d.current = id
fynedesk.Instance().SetDesktop(id)
d.gui.refresh()
d.gui.refreshFrom(oldID)
}

// newDesktops creates a new module that will manage virtual desktops and display a pager widget.
Expand Down
Loading

0 comments on commit 399c17c

Please sign in to comment.