From 95ed0a9e4a8976e1a8dcaa927dad9d8134588f60 Mon Sep 17 00:00:00 2001 From: mftb0 Date: Thu, 15 Feb 2024 11:09:05 -0800 Subject: [PATCH] Add cursor hiding Update gotk3 dep When in fullscreen the cursor will now hide when the hud hides Updated gotk3 to get the latest changes --- cmd/cbxv/main.go | 2 +- go.mod | 2 +- go.sum | 4 ++-- internal/ui/pageview.go | 7 +++++++ internal/ui/stripview.go | 6 ++++++ internal/ui/ui.go | 20 ++++++++++++++++++++ 6 files changed, 37 insertions(+), 4 deletions(-) diff --git a/cmd/cbxv/main.go b/cmd/cbxv/main.go index bffbfb2..78fd64e 100644 --- a/cmd/cbxv/main.go +++ b/cmd/cbxv/main.go @@ -13,7 +13,7 @@ import ( const ( NAME = "cbxv" - VERSION = "0.5.1" + VERSION = "0.5.2" ) // Update listens for messages on the message channel and diff --git a/go.mod b/go.mod index 01783ae..cbc7d10 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( github.com/gen2brain/go-unarr v0.2.0 - github.com/gotk3/gotk3 v0.6.2 + github.com/gotk3/gotk3 v0.6.3 github.com/pdfcpu/pdfcpu v0.6.0 ) diff --git a/go.sum b/go.sum index 9b0bce6..c577970 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,7 @@ github.com/gen2brain/go-unarr v0.2.0 h1:sYKSjbeNSuZgudd59iGAbMbr113XRFoA7Rt9XWA+QVE= github.com/gen2brain/go-unarr v0.2.0/go.mod h1:hoHheVuf0KT8/hfvkEL7GMwj2h7fq0lF72NdyySdr3c= -github.com/gotk3/gotk3 v0.6.2 h1:sx/PjaKfKULJPTPq8p2kn2ZbcNFxpOJqi4VLzMbEOO8= -github.com/gotk3/gotk3 v0.6.2/go.mod h1:/hqFpkNa9T3JgNAE2fLvCdov7c5bw//FHNZrZ3Uv9/Q= +github.com/gotk3/gotk3 v0.6.3 h1:+Ke4WkM1TQUNOlM2TZH6szqknqo+zNbX3BZWVXjSHYw= +github.com/gotk3/gotk3 v0.6.3/go.mod h1:/hqFpkNa9T3JgNAE2fLvCdov7c5bw//FHNZrZ3Uv9/Q= github.com/hhrutter/lzw v1.0.0 h1:laL89Llp86W3rRs83LvKbwYRx6INE8gDn0XNb1oXtm0= github.com/hhrutter/lzw v1.0.0/go.mod h1:2HC6DJSn/n6iAZfgM3Pg+cP1KxeWc3ezG8bBqW5+WEo= github.com/hhrutter/tiff v1.0.1 h1:MIus8caHU5U6823gx7C6jrfoEvfSTGtEFRiM8/LOzC0= diff --git a/internal/ui/pageview.go b/internal/ui/pageview.go index f85fa7e..cd2bcca 100644 --- a/internal/ui/pageview.go +++ b/internal/ui/pageview.go @@ -58,6 +58,9 @@ func NewPageView(m *model.Model, u *UI, messenger util.Messenger) View { if !v.hudHidden && !v.hudKeepAlive { v.hdrControl.container.Hide() v.navControl.container.Hide() + if m.Fullscreen { + v.ui.HideCursor() + } u.MainWindow.QueueDraw() v.hudHidden = true } else { @@ -82,6 +85,7 @@ func (v *PageView) newHUD(m *model.Model, u *UI) *gtk.Overlay { v.navControl = NewNavControl(m, u) o.AddOverlay(v.hdrControl.container) o.AddOverlay(v.navControl.container) + v.ui.ShowCursor() v.hudHidden = false return o @@ -103,6 +107,7 @@ func (v *PageView) Connect(m *model.Model, u *UI) { } v.hud.ShowAll() + v.ui.ShowCursor() v.hudHidden = false v.hudKeepAlive = true return true @@ -153,6 +158,7 @@ func (v *PageView) initRenderer(m *model.Model) { //reset the hud hiding v.hdrControl.container.Show() v.navControl.container.Show() + v.ui.ShowCursor() v.hudHidden = false v.hudKeepAlive = true } @@ -173,6 +179,7 @@ func (v *PageView) initRenderer(m *model.Model) { } //reset the hud hiding v.hud.ShowAll() + v.ui.ShowCursor() v.hudHidden = false v.hudKeepAlive = true return r diff --git a/internal/ui/stripview.go b/internal/ui/stripview.go index 4c0c40f..8d1e1be 100644 --- a/internal/ui/stripview.go +++ b/internal/ui/stripview.go @@ -44,6 +44,7 @@ func NewStripView(m *model.Model, u *UI) View { v.scrollbars.Connect("scroll-event", func() { v.hud.ShowAll() + v.ui.ShowCursor() v.hudHidden = false v.hudKeepAlive = true }) @@ -63,6 +64,9 @@ func NewStripView(m *model.Model, u *UI) View { v.hdrControl.container.Hide() v.navControl.container.Hide() u.MainWindow.QueueDraw() + if m.Fullscreen { + u.HideCursor() + } v.hudHidden = true } else { v.hudKeepAlive = false @@ -84,6 +88,7 @@ func (v *StripView) Connect(m *model.Model, u *UI) { } v.hud.ShowAll() + u.ShowCursor() v.hudHidden = false v.hudKeepAlive = true }) @@ -142,6 +147,7 @@ func (v *StripView) newHUD(m *model.Model, u *UI) *gtk.Overlay { v.navControl = NewStripViewNavControl(m, u) o.AddOverlay(v.hdrControl.container) o.AddOverlay(v.navControl.container) + u.ShowCursor() v.hudHidden = false return o diff --git a/internal/ui/ui.go b/internal/ui/ui.go index 6006d25..c974f8c 100644 --- a/internal/ui/ui.go +++ b/internal/ui/ui.go @@ -87,6 +87,26 @@ func (u *UI) DisplayErrorDlg(message string) { dlg.Run() } +func (u *UI) ShowCursor() { + d, _ := gdk.DisplayGetDefault() + c, _ := gdk.CursorNewFromName(d, "default") + w, err := u.MainWindow.GetWindow() + if err != nil { + return + } + w.SetCursor(c) +} + +func (u *UI) HideCursor() { + d, _ := gdk.DisplayGetDefault() + c, _ := gdk.CursorNewFromName(d, "none") + w, err := u.MainWindow.GetWindow() + if err != nil { + return + } + w.SetCursor(c) +} + func (u *UI) Render(m *model.Model) { glib.IdleAdd(func() { u.View.Render(m)