cefclient: win: Support window state restore (see issue #3359)

The cefclient sample app on Windows will persist window state across application
restart if run with cache_path and persist_user_references enabled.

To test:
1. Run `cefclient --cache-path=/path/to/cache --persist-user-preferences`
2. Move or resize the window, maximize, minimize, etc.
3. Exit cefclient.
4. Run cefclient again with the same arguments. The previous window state will
   be restored.
This commit is contained in:
Marshall Greenblatt
2022-11-07 15:21:44 -05:00
parent 882bc19fdd
commit e2a9236106
13 changed files with 310 additions and 94 deletions

View File

@@ -75,6 +75,32 @@ CefPoint CefDisplay::ConvertScreenPointFromPixels(const CefPoint& point) {
#endif
}
// static
CefRect CefDisplay::ConvertScreenRectToPixels(const CefRect& rect) {
CEF_REQUIRE_UIT_RETURN(CefRect());
#if BUILDFLAG(IS_WIN)
const gfx::Rect pix_rect = view_util::ConvertRectToPixels(
gfx::Rect(rect.x, rect.y, rect.width, rect.height));
return CefRect(pix_rect.x(), pix_rect.y(), pix_rect.width(),
pix_rect.height());
#else
return rect;
#endif
}
// static
CefRect CefDisplay::ConvertScreenRectFromPixels(const CefRect& rect) {
CEF_REQUIRE_UIT_RETURN(CefRect());
#if BUILDFLAG(IS_WIN)
const gfx::Rect dip_rect = view_util::ConvertRectFromPixels(
gfx::Rect(rect.x, rect.y, rect.width, rect.height));
return CefRect(dip_rect.x(), dip_rect.y(), dip_rect.width(),
dip_rect.height());
#else
return rect;
#endif
}
CefDisplayImpl::CefDisplayImpl(const display::Display& display)
: display_(display) {
CEF_REQUIRE_UIT();