Closed DinkydauSet closed 3 years ago
The solution is to use a nana::detail::bedrock::root_guard. ashbob999 here helped me to use it: https://github.com/cnjinhao/nana/issues/631
The root_guard disabled screen refreshing until it's destroyed. Nana's own event handlers use it, but only sometimes (which is inconsistent).
Something to keep in mind while using root_guard: if you create 2 root guards and one gets destroyed, refreshing gets re-enabled even though the second root_guard is still not destroyed. That means using root_guards doesn't guarantee there won't be any refreshing.
I still have that problem with tab colors. The active tab has a different color:
I now use a root_guard when creating a tab with CTRL+T. During the existence of that root_guard, I do:
bar.append(title, *new_panel);
Here append is a nana function, after which the screen refreshes. I think that's because nana uses a root_guard and destroys it, even though my root_guard still exists. That happens before I change the color of the new tab, so the wrong color is visible for about 1 frame and is then changed immediately. It's a little annoying. It would be nice if there was a way to hard disable refreshing, for example by counting the number of existing root_guards.
I use the windows api message system to send work to the GUI thread, as described here: https://github.com/DinkydauSet/ExploreFractals/issues/23#issuecomment-886596932
This is how keypresses are intercepted. ctrl + T creates a new tab.
Creating a new tab takes about 0,3 seconds which feels slow.
Strangely enough, creating a tab by clicking the new tab button is much faster. It takes only 0,05 seconds.
What I have found:
cout << "CREATE TAB WITH WINDOWS API MESSAGE IN THREAD" << std::this_thread::get_id() << endl;
It's the same thread ID.API::emit_event<arg_click>(event_code::click, fm.newTabButton, arg_click());
Doing that at CTRL+T instead of calling create_fractal_tab directly is also slow.//lock_guard lock(mutex_);
and it's still slow.