Skip to content

Commit 7131beb

Browse files
committed
Added cursor hiding, Fixed fullscreen sync, fixed ui resizing, Updated gotk3
Now during periods of inactivity, while in fullscreen, the mouse cursor will be hidden along with the HUD. The idea is to reduce distractions in fullscreen. Fixed fullscreen state sometimes getting out-of-sync. This could happen if your Window Manager has a mechanism (like a hot-key) for making a window fullscreen. Internally the toggleFullscreen message was replaced with setFullscreen. A new window-state-event was added and cbxv commands now just set the window to Fullscreen or non-Fullscreen. The change in ui state, regardless of the cause, is caught in the window-state-event and the setFullscreen message is sent internally to update the model's fullscreen state. Fixed ui (header and nav) refusing to resize when no book was open. This was mainly cosmetic as there's almost nothing for these components to do when no book is open, but it was ugly. Updated gotk3 dependency to get the latest improvements.
1 parent 95ed0a9 commit 7131beb

File tree

6 files changed

+20
-17
lines changed

6 files changed

+20
-17
lines changed

cmd/cbxv/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func update(m *model.Model, u *ui.UI, msgChan chan util.Message, msgHandlers *Me
2828
(msg.TypeName != "quit" &&
2929
msg.TypeName != "openFile" &&
3030
msg.TypeName != "openFileResult" &&
31-
msg.TypeName != "toggleFullscreen") {
31+
msg.TypeName != "setFullscreen") {
3232
continue
3333
}
3434

cmd/cbxv/messagehandlers.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,11 @@ func NewMessageHandlers(m *model.Model, u *ui.UI) *MessageHandlerList {
120120
handlers.List["leftPage"] = r
121121
}
122122

123-
handlers.List["toggleFullscreen"] = func(data string) {
124-
if m.Fullscreen == true {
125-
m.Fullscreen = false
126-
} else {
123+
handlers.List["setFullscreen"] = func(data string) {
124+
if data == "true" {
127125
m.Fullscreen = true
126+
} else {
127+
m.Fullscreen = false
128128
}
129129
}
130130

internal/ui/commands.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ func NewCommands(m *model.Model, u *UI) *CommandList {
129129
} else {
130130
u.MainWindow.Fullscreen()
131131
}
132-
u.SendMessage(util.Message{TypeName: "toggleFullscreen"})
133132
}))
134133

135134
AddCommand(cmds, NewCommand("openFile", "Open File",

internal/ui/pageview.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ func (v *PageView) initRenderer(m *model.Model) {
131131
util.Log("w:%d,h:%d\n", int64(x2-x1), int64(y2-y1))
132132
cr.Rectangle(x1, y1, x2, y2)
133133
cr.Fill()
134+
w := v.hud.GetAllocatedWidth() - 40
135+
v.hdrControl.container.SetSizeRequest(w, 8)
136+
v.navControl.container.SetSizeRequest(w, 8)
134137
if m.Spreads == nil {
135138
return false
136139
}
@@ -145,9 +148,6 @@ func (v *PageView) initRenderer(m *model.Model) {
145148
renderOnePageSpread(s)
146149
}
147150
}
148-
w := v.hud.GetAllocatedWidth() - 40
149-
v.hdrControl.container.SetSizeRequest(w, 8)
150-
v.navControl.container.SetSizeRequest(w, 8)
151151
return true
152152
})
153153

internal/ui/pageviewnavcontrol.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,6 @@ func NewNavControl(m *model.Model, u *UI) *PageViewNavControl {
109109
})
110110

111111
fsc.Connect("clicked", func() {
112-
if m.Fullscreen {
113-
u.MainWindow.Unfullscreen()
114-
} else {
115-
u.MainWindow.Fullscreen()
116-
}
117112
u.Commands.Names["toggleFullscreen"].Execute()
118113
})
119114

@@ -181,10 +176,9 @@ func (c *PageViewNavControl) Render(m *model.Model) {
181176
}
182177

183178
if m.Fullscreen {
184-
c.container.SetSizeRequest(1400, 8)
185-
c.fullscreenControl.SetLabel(util.FullscreenIcon())
186-
} else {
187179
c.fullscreenControl.SetLabel(util.RestoreIcon())
180+
} else {
181+
c.fullscreenControl.SetLabel(util.FullscreenIcon())
188182
}
189183

190184
c.rightPageNum.SetLabel("")

internal/ui/ui.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@ func NewUI(m *model.Model, messenger util.Messenger) *UI {
3737
u.Commands.Names["quit"].Execute()
3838
return true
3939
})
40+
u.MainWindow.Connect("window-state-event", func(w *gtk.Window, event *gdk.Event) bool {
41+
ev := gdk.EventWindowStateNewFromEvent(event)
42+
if ev.ChangedMask() & ev.NewWindowState() == gdk.WINDOW_STATE_FULLSCREEN {
43+
u.SendMessage(util.Message{TypeName: "setFullscreen", Data: "true"})
44+
} else {
45+
u.SendMessage(util.Message{TypeName: "setFullscreen", Data: "false"})
46+
}
47+
return true
48+
})
49+
4050
u.MainWindow.SetDefaultSize(1024, 768)
4151

4252
iPath := util.AppIconPath()

0 commit comments

Comments
 (0)