ConfigDialog: fix ButtonProgressWidget and some refreshes#4793
Conversation
This internal ButtonProgressWidget widget was behaving differently from all others (OptionTextItem, OptionIconItem and ToggleSwitch) by duplicating some code from ConfigDialog:onConfigChoose() instead of calling it directly. While making it similar to others, I noticed that onConfigChoose() did a full repaint, which was necessary for some settings to be applied (ie: Contrast). On CreDocument, this full repaint may cause some double drawing on config changes (ie: Margins, drawing once after margin changes, and then re-positionning to previous xpointer). So, make the need for full repaint a condition on KoptOptions.
|
|
And it's indeed generally overkill, if you want to enforce an eInk refresh without repainting anything, you're better off doing a Since the widget is NULL, it'll just enqueue an eInk refresh to your liking ;). The refresh settings should generally be passed as a function in this instance, to make sure it gets a chance to get merged with other queued refreshes, instead of enforcing one right now. |
But then: koreader/frontend/ui/uimanager.lua Line 539 in f637555 with refreshtype / mode = nil (and no dither), this would return early:koreader/frontend/ui/uimanager.lua Lines 778 to 786 in f637555 so, not doing any refresh? Or may be this call without mode would just flag the widgets as dirty, exiting there early without any refresh. And a later setDirty (possibly smaller and localized) would see all the previously set dirty widgets, and deal with them at this point? (which could explain the async'ness I see and can't explain :) |
|
@poire-z : Yep, I'd forgotten that extra-quirkiness of not passing a refreshfunc at all in this case, but, yeah, you're right ;). I tried to clean most of those up, because they're indeed unintuitive and weird and generally not the right thing to do, but I guess I missed those ;). |
|
TL;DR: On paper, your change looks like the perfect way to handle that ;). (Assuming KOpt really needs to repaint both the ConfigDialog and ReaderUI, but I'm trusting you on that front ;)). (I'm assuming you're using a 600x610 emulator window, right?) |
Right (on a small laptop screen, 1366x768).
That surprised me, but I see that with some settings (contrast, line spacing), not with others (margins, font size).
No worry with the logs and the 3 |
|
or not ... i'm confused by the order of things or how to read them: Is that a single action: or is it that: |
|
Yeah, not quite sure where that first full-screen partial is from... onTapSelect & onConfigChoose don't do a partial via func... Only onCloseWidget does :? The double refresh at the end looks normal for a "all", "partial" with two top-level widgets open, though ;). |
|
Oh, just discovered verbose mode (which does not work as an option to kodev run?). So, it shows somethings that actually looks good to me ! Right ?
So, if I get that right:
But I don't really get how/why the: |
|
(They're hidden behind verbose mode because of the table pretty-printing feature, IIRC). |
|
And the answer to all your questions is the _refresh_stack in UIManager and how _refresh() manages it ;). |
|
Oh, and I remember why I was confused by that initial partial: it's because the logs are inverted (for... Lua reasons) between setDirty and _refresh when refreshtype is not a function ;). i.e., That _refresh is the setDirty("all", "partial"). The other final two are the ones enqueued by ReaderUI & ConfigDialog's dirty flags following that ;). |
|
OK, that now makes more sense :) Thanks for the time and explanation. |
|
I guess we not need to worry about the numerous things like this I see with verbose mode (with the changes from this PR reverted): |
|
Yeah, that's the debug guard firing for some real reasons, but mostly on a
widget's first showing when it's not yet in the top-level list ;).
…On Thu, Mar 14, 2019, 18:44 poire-z ***@***.***> wrote:
I guess we not need to worry about the numerous things like this I see
with verbose mode (with the changes from this PR reverted):
03/14/19-18:39:00 DEBUG setDirty full from widget ReaderUI w/ NO region
# 03/14/19-18:39:00 INFO: invalid widget for setDirty() stack traceback:
frontend/ui/uimanager.lua:560: in function 'post_guard'
frontend/dbg.lua:45: in function 'setDirty'
frontend/apps/reader/modules/readerview.lua:709: in function 'onSetScreenMode'
frontend/apps/reader/modules/readerview.lua:754: in function 'handleEvent'
frontend/ui/widget/container/widgetcontainer.lua:88: in function 'propagateEvent'
frontend/ui/widget/container/widgetcontainer.lua:106: in function 'handleEvent'
frontend/apps/reader/readerui.lua:382: in function 'init'
frontend/ui/widget/widget.lua:48: in function 'new'
frontend/apps/reader/readerui.lua:515: in function 'doShowReader'
frontend/apps/reader/readerui.lua:475: in function <frontend/apps/reader/readerui.lua:474>
03/14/19-18:39:00 DEBUG _refresh: Enqueued full update for region 0 0 600 610
03/14/19-18:39:00 DEBUG setDirty partial from widget ReaderUI w/ NO region
# 03/14/19-18:39:00 INFO: invalid widget for setDirty() stack traceback:
frontend/ui/uimanager.lua:560: in function 'post_guard'
frontend/dbg.lua:45: in function 'setDirty'
frontend/apps/reader/modules/readerview.lua:603: in function 'recalculate'
frontend/apps/reader/modules/readerview.lua:723: in function 'handleEvent'
frontend/ui/widget/container/widgetcontainer.lua:88: in function 'propagateEvent'
frontend/ui/widget/container/widgetcontainer.lua:106: in function 'handleEvent'
frontend/apps/reader/modules/readerview.lua:711: in function 'onSetScreenMode'
03/14/19-18:43:48 DEBUG setDirty via a func from widget table: 0x403c6070
# 03/14/19-18:43:48 INFO: invalid widget for setDirty() stack traceback:
frontend/ui/uimanager.lua:560: in function 'post_guard'
frontend/dbg.lua:45: in function 'setDirty'
frontend/ui/widget/buttonprogresswidget.lua:90: in function 'update'
frontend/ui/widget/buttonprogresswidget.lua:97: in function 'setPosition'
frontend/ui/widget/configdialog.lua:526: in function 'init'
frontend/ui/widget/widget.lua:48: in function 'new'
frontend/ui/widget/configdialog.lua:570: in function 'init'
frontend/ui/widget/widget.lua:48: in function 'new'
frontend/ui/widget/configdialog.lua:768: in function 'update'
frontend/ui/widget/configdialog.lua:799: in function 'onShowConfigPanel'
frontend/apps/reader/modules/readerconfig.lua:84: in function 'onShowConfigMenu'
frontend/apps/reader/modules/readerconfig.lua:92: in function 'handler'
frontend/ui/widget/container/inputcontainer.lua:248: in function 'handleEvent'
frontend/ui/uimanager.lua:632: in function 'sendEvent'
frontend/ui/uimanager.lua:46: in function '__default__'
frontend/ui/uimanager.lua:966: in function 'handleInputEvent'
frontend/ui/uimanager.lua:1027: in function 'handleInput'
frontend/ui/uimanager.lua:1071: in function 'run'
./reader.lua:216: in main chunk
[C]: at 0x560d1e6dd0c0
03/14/19-18:43:48 DEBUG setDirty via a func from widget table: 0x403c6070
# 03/14/19-18:43:48 INFO: invalid widget for setDirty() stack traceback:
frontend/ui/uimanager.lua:560: in function 'post_guard'
frontend/dbg.lua:45: in function 'setDirty'
frontend/ui/widget/configdialog.lua:802: in function 'onShowConfigPanel'
frontend/apps/reader/modules/readerconfig.lua:84: in function 'onShowConfigMenu'
frontend/apps/reader/modules/readerconfig.lua:92: in function 'handler'
frontend/ui/widget/container/inputcontainer.lua:248: in function 'handleEvent'
frontend/ui/uimanager.lua:632: in function 'sendEvent'
frontend/ui/uimanager.lua:46: in function '__default__'
frontend/ui/uimanager.lua:966: in function 'handleInputEvent'
frontend/ui/uimanager.lua:1027: in function 'handleInput'
frontend/ui/uimanager.lua:1071: in function 'run'
./reader.lua:216: in main chunk
[C]: at 0x560d1e6dd0c0
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#4793 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAG1ZijO9h_e1Hm-pkvd7DK-TFV8oFznks5vWoqKgaJpZM4b0aS8>
.
|
|
Even in cases where set Dirty really is called on a widget that isn't top
level (there's quite a bit of calls like that left), I added the same basic
check to the runtime code, so it's not fantastically bad, just bad practice
;).
…On Thu, Mar 14, 2019, 19:38 NiLuJe ***@***.***> wrote:
Yeah, that's the debug guard firing for some real reasons, but mostly on a
widget's first showing when it's not yet in the top-level list ;).
On Thu, Mar 14, 2019, 18:44 poire-z ***@***.***> wrote:
> I guess we not need to worry about the numerous things like this I see
> with verbose mode (with the changes from this PR reverted):
>
> 03/14/19-18:39:00 DEBUG setDirty full from widget ReaderUI w/ NO region
> # 03/14/19-18:39:00 INFO: invalid widget for setDirty() stack traceback:
> frontend/ui/uimanager.lua:560: in function 'post_guard'
> frontend/dbg.lua:45: in function 'setDirty'
> frontend/apps/reader/modules/readerview.lua:709: in function 'onSetScreenMode'
> frontend/apps/reader/modules/readerview.lua:754: in function 'handleEvent'
> frontend/ui/widget/container/widgetcontainer.lua:88: in function 'propagateEvent'
> frontend/ui/widget/container/widgetcontainer.lua:106: in function 'handleEvent'
> frontend/apps/reader/readerui.lua:382: in function 'init'
> frontend/ui/widget/widget.lua:48: in function 'new'
> frontend/apps/reader/readerui.lua:515: in function 'doShowReader'
> frontend/apps/reader/readerui.lua:475: in function <frontend/apps/reader/readerui.lua:474>
> 03/14/19-18:39:00 DEBUG _refresh: Enqueued full update for region 0 0 600 610
> 03/14/19-18:39:00 DEBUG setDirty partial from widget ReaderUI w/ NO region
> # 03/14/19-18:39:00 INFO: invalid widget for setDirty() stack traceback:
> frontend/ui/uimanager.lua:560: in function 'post_guard'
> frontend/dbg.lua:45: in function 'setDirty'
> frontend/apps/reader/modules/readerview.lua:603: in function 'recalculate'
> frontend/apps/reader/modules/readerview.lua:723: in function 'handleEvent'
> frontend/ui/widget/container/widgetcontainer.lua:88: in function 'propagateEvent'
> frontend/ui/widget/container/widgetcontainer.lua:106: in function 'handleEvent'
> frontend/apps/reader/modules/readerview.lua:711: in function 'onSetScreenMode'
>
> 03/14/19-18:43:48 DEBUG setDirty via a func from widget table: 0x403c6070
> # 03/14/19-18:43:48 INFO: invalid widget for setDirty() stack traceback:
> frontend/ui/uimanager.lua:560: in function 'post_guard'
> frontend/dbg.lua:45: in function 'setDirty'
> frontend/ui/widget/buttonprogresswidget.lua:90: in function 'update'
> frontend/ui/widget/buttonprogresswidget.lua:97: in function 'setPosition'
> frontend/ui/widget/configdialog.lua:526: in function 'init'
> frontend/ui/widget/widget.lua:48: in function 'new'
> frontend/ui/widget/configdialog.lua:570: in function 'init'
> frontend/ui/widget/widget.lua:48: in function 'new'
> frontend/ui/widget/configdialog.lua:768: in function 'update'
> frontend/ui/widget/configdialog.lua:799: in function 'onShowConfigPanel'
> frontend/apps/reader/modules/readerconfig.lua:84: in function 'onShowConfigMenu'
> frontend/apps/reader/modules/readerconfig.lua:92: in function 'handler'
> frontend/ui/widget/container/inputcontainer.lua:248: in function 'handleEvent'
> frontend/ui/uimanager.lua:632: in function 'sendEvent'
> frontend/ui/uimanager.lua:46: in function '__default__'
> frontend/ui/uimanager.lua:966: in function 'handleInputEvent'
> frontend/ui/uimanager.lua:1027: in function 'handleInput'
> frontend/ui/uimanager.lua:1071: in function 'run'
> ./reader.lua:216: in main chunk
> [C]: at 0x560d1e6dd0c0
> 03/14/19-18:43:48 DEBUG setDirty via a func from widget table: 0x403c6070
> # 03/14/19-18:43:48 INFO: invalid widget for setDirty() stack traceback:
> frontend/ui/uimanager.lua:560: in function 'post_guard'
> frontend/dbg.lua:45: in function 'setDirty'
> frontend/ui/widget/configdialog.lua:802: in function 'onShowConfigPanel'
> frontend/apps/reader/modules/readerconfig.lua:84: in function 'onShowConfigMenu'
> frontend/apps/reader/modules/readerconfig.lua:92: in function 'handler'
> frontend/ui/widget/container/inputcontainer.lua:248: in function 'handleEvent'
> frontend/ui/uimanager.lua:632: in function 'sendEvent'
> frontend/ui/uimanager.lua:46: in function '__default__'
> frontend/ui/uimanager.lua:966: in function 'handleInputEvent'
> frontend/ui/uimanager.lua:1027: in function 'handleInput'
> frontend/ui/uimanager.lua:1071: in function 'run'
> ./reader.lua:216: in main chunk
> [C]: at 0x560d1e6dd0c0
>
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#4793 (comment)>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AAG1ZijO9h_e1Hm-pkvd7DK-TFV8oFznks5vWoqKgaJpZM4b0aS8>
> .
>
|
|
Looks all good on my device. So, merging. |
) This internal ButtonProgressWidget widget was behaving differently from all others (OptionTextItem, OptionIconItem and ToggleSwitch) by duplicating some code from ConfigDialog:onConfigChoose() instead of calling it directly. While making it similar to others, I noticed that onConfigChoose() did a full repaint, which was necessary for some settings to be applied (ie: Contrast). On CreDocument, this full repaint may cause some double drawing on config changes (ie: Margins, drawing once after margin changes, and then re-positionning to previous xpointer). So, make the need for full repaint a condition on KoptOptions.
) This internal ButtonProgressWidget widget was behaving differently from all others (OptionTextItem, OptionIconItem and ToggleSwitch) by duplicating some code from ConfigDialog:onConfigChoose() instead of calling it directly. While making it similar to others, I noticed that onConfigChoose() did a full repaint, which was necessary for some settings to be applied (ie: Contrast). On CreDocument, this full repaint may cause some double drawing on config changes (ie: Margins, drawing once after margin changes, and then re-positionning to previous xpointer). So, make the need for full repaint a condition on KoptOptions.
This internal ButtonProgressWidget widget was behaving differently from all others (OptionTextItem, OptionIconItem and ToggleSwitch) by duplicating some code from ConfigDialog:onConfigChoose() instead of calling it directly. So, similar to:
koreader/frontend/ui/widget/toggleswitch.lua
Lines 191 to 208 in f637555
While making it similar to others, I noticed that onConfigChoose() did a full repaint, which was necessary for some settings to be applied (ie: Contrast) - or may be not, see below, but I don't know what did that then...
On CreDocument, this full repaint may cause some double drawing on config changes (ie: Margins, since #4691, drawing once after margin changes,and then re-positionning to previous xpointer).
So, make the need for full repaint a condition on KoptOptions.
These changes seem to make PDF and CRE settings behave all correctly. I'll still have to check on my Kobo.
But I'm still puzzled, mostly about how it works/worked with PDF.
Previously, we had a call in that ButtonProgressWidget:
UIManager:setDirty("all"). It looks to me this is actually a no-op from UIManager point of view (where there is no mode provided like "full" or "ui") ! Or may be not in some situations?So I don't know why removing it, or replacing it with a more localized
UIManager:setDirty(self.config, function() return "ui", widget.diment)made contrast no more applied...I'm pretty confident these change are fine for CreDocument, a bit less for PDF.
Changing contrast leads to the following log:
Previously:
So, 3 instead of 1 "Enqueued partial update for region 0 0 600 610" - dunno if that means 3 EInk screen refreshes...
Pinging @NiLuJe for opinion.