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

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

To test:
1. Run `cefclient --use-views --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-10-28 14:17:18 -04:00
parent 09bb643ef6
commit 882bc19fdd
18 changed files with 511 additions and 65 deletions

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=2ecdf3e890e54e962286430f350c5b49249a9a9e$
// $hash=9657432e6ca2ba72aeeb1ced5c8cf5ee71cf7221$
//
#include "libcef_dll/cpptoc/views/window_delegate_cpptoc.h"
@ -41,6 +41,26 @@ window_delegate_on_window_created(struct _cef_window_delegate_t* self,
CefWindowCToCpp::Wrap(window));
}
void CEF_CALLBACK
window_delegate_on_window_closing(struct _cef_window_delegate_t* self,
cef_window_t* window) {
shutdown_checker::AssertNotShutdown();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Verify param: window; type: refptr_diff
DCHECK(window);
if (!window)
return;
// Execute
CefWindowDelegateCppToC::Get(self)->OnWindowClosing(
CefWindowCToCpp::Wrap(window));
}
void CEF_CALLBACK
window_delegate_on_window_destroyed(struct _cef_window_delegate_t* self,
cef_window_t* window) {
@ -82,6 +102,34 @@ void CEF_CALLBACK window_delegate_on_window_activation_changed(
CefWindowCToCpp::Wrap(window), active ? true : false);
}
void CEF_CALLBACK
window_delegate_on_window_bounds_changed(struct _cef_window_delegate_t* self,
cef_window_t* window,
const cef_rect_t* new_bounds) {
shutdown_checker::AssertNotShutdown();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Verify param: window; type: refptr_diff
DCHECK(window);
if (!window)
return;
// Verify param: new_bounds; type: simple_byref_const
DCHECK(new_bounds);
if (!new_bounds)
return;
// Translate param: new_bounds; type: simple_byref_const
CefRect new_boundsVal = new_bounds ? *new_bounds : CefRect();
// Execute
CefWindowDelegateCppToC::Get(self)->OnWindowBoundsChanged(
CefWindowCToCpp::Wrap(window), new_boundsVal);
}
cef_window_t* CEF_CALLBACK
window_delegate_get_parent_window(struct _cef_window_delegate_t* self,
cef_window_t* window,
@ -588,9 +636,12 @@ void CEF_CALLBACK window_delegate_on_blur(struct _cef_view_delegate_t* self,
CefWindowDelegateCppToC::CefWindowDelegateCppToC() {
GetStruct()->on_window_created = window_delegate_on_window_created;
GetStruct()->on_window_closing = window_delegate_on_window_closing;
GetStruct()->on_window_destroyed = window_delegate_on_window_destroyed;
GetStruct()->on_window_activation_changed =
window_delegate_on_window_activation_changed;
GetStruct()->on_window_bounds_changed =
window_delegate_on_window_bounds_changed;
GetStruct()->get_parent_window = window_delegate_get_parent_window;
GetStruct()->get_initial_bounds = window_delegate_get_initial_bounds;
GetStruct()->get_initial_show_state = window_delegate_get_initial_show_state;