internal/restorable: remove 'volatile' attribute when restorable is not used

This commit is contained in:
Hajime Hoshi 2024-09-21 23:24:59 +09:00
parent 4bfcbc878c
commit 9bdc89d40f
4 changed files with 29 additions and 3 deletions

View File

@ -169,9 +169,11 @@ func NewImage(width, height int, imageType ImageType) *Image {
} }
var attribute string var attribute string
switch imageType { if needsRestoration() {
case ImageTypeVolatile: switch imageType {
attribute = "volatile" case ImageTypeVolatile:
attribute = "volatile"
}
} }
i := &Image{ i := &Image{
image: graphicscommand.NewImage(width, height, imageType == ImageTypeScreen, attribute), image: graphicscommand.NewImage(width, height, imageType == ImageTypeScreen, attribute),

View File

@ -43,6 +43,7 @@ type Window interface {
IsClosingHandled() bool IsClosingHandled() bool
SetMousePassthrough(enabled bool) SetMousePassthrough(enabled bool)
IsMousePassthrough() bool IsMousePassthrough() bool
RequestAttention()
} }
type nullWindow struct{} type nullWindow struct{}
@ -128,3 +129,6 @@ func (*nullWindow) SetMousePassthrough(enabled bool) {
func (*nullWindow) IsMousePassthrough() bool { func (*nullWindow) IsMousePassthrough() bool {
return false return false
} }
func (*nullWindow) RequestAttention() {
}

View File

@ -506,3 +506,19 @@ func (w *glfwWindow) IsMousePassthrough() bool {
}) })
return v return v
} }
func (w *glfwWindow) RequestAttention() {
if w.ui.isTerminated() {
return
}
if !w.ui.isRunning() {
// Do nothing
return
}
w.ui.mainThread.Call(func() {
if w.ui.isTerminated() {
return
}
w.ui.window.RequestAttention()
})
}

View File

@ -341,3 +341,7 @@ func SetWindowMousePassthrough(enabled bool) {
func IsWindowMousePassthrough() bool { func IsWindowMousePassthrough() bool {
return ui.Get().Window().IsMousePassthrough() return ui.Get().Window().IsMousePassthrough()
} }
func RequestWindowAttention() {
ui.Get().Window().RequestAttention()
}