How to set document.visibilityState in cef?

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

How to set document.visibilityState in cef?

Postby xtxtqqgqlxxmm » Fri Mar 01, 2024 2:21 am

When tab switched, I want to set document.visibilityState to 'hidden' in old page.
I tried this way:
1. ExecuteJavascript in console,
Code: Select all
document.visibilityState = 'hidden'
it fails as the attribute is readonly.
2. Use
Code: Select all
browser->GetHost()->WasHidden(true);
it no effects. I read the comment,
Notify the browser that it has been hidden or shown. Layouting and CefRenderHandler::OnPaint notification will stop when the browser is hidden. This method is only used when window rendering is disabled.
but I don't know how to disable rendering.
3.Use
Code: Select all
SetWindowPos(hwnd, NULL, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE);
it works, but when tab switch back, use
Code: Select all
ShowWindow(hwnd, SW_SHOW);
and
Code: Select all
MoveWindow(hwnd, rect.x(), rect.y(), rect.width(), rect.height(), true);
to restore, there has a black background show rapidly, then show normal view. The black backgournd is a big problem when switch frequently.

So, what the correct way to set document.visibilityState?
xtxtqqgqlxxmm
Newbie
 
Posts: 5
Joined: Wed May 24, 2023 3:33 am

Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 205 guests