mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
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:
@@ -50,6 +50,11 @@ class RootWindowWin : public RootWindow, public BrowserWindow::Delegate {
|
||||
bool WithExtension() const override;
|
||||
|
||||
private:
|
||||
void ContinueInitOnUIThread(std::unique_ptr<RootWindowConfig> config,
|
||||
const CefBrowserSettings& settings);
|
||||
void ContinueInitOnMainThread(std::unique_ptr<RootWindowConfig> config,
|
||||
const CefBrowserSettings& settings);
|
||||
|
||||
void CreateBrowserWindow(const std::string& startup_url);
|
||||
void CreateRootWindow(const CefBrowserSettings& settings,
|
||||
bool initially_hidden);
|
||||
@@ -109,54 +114,57 @@ class RootWindowWin : public RootWindow, public BrowserWindow::Delegate {
|
||||
|
||||
void NotifyDestroyedIfDone();
|
||||
|
||||
static void SaveWindowRestoreOnUIThread(const WINDOWPLACEMENT& placement);
|
||||
|
||||
// After initialization all members are only accessed on the main thread.
|
||||
// Members set during initialization.
|
||||
bool with_controls_;
|
||||
bool always_on_top_;
|
||||
bool with_osr_;
|
||||
bool with_extension_;
|
||||
bool is_popup_;
|
||||
RECT start_rect_;
|
||||
bool with_controls_ = false;
|
||||
bool always_on_top_ = false;
|
||||
bool with_osr_ = false;
|
||||
bool with_extension_ = false;
|
||||
bool is_popup_ = false;
|
||||
CefRect initial_bounds_;
|
||||
cef_show_state_t initial_show_state_ = CEF_SHOW_STATE_NORMAL;
|
||||
std::unique_ptr<BrowserWindow> browser_window_;
|
||||
CefBrowserSettings browser_settings_;
|
||||
bool initialized_;
|
||||
bool initialized_ = false;
|
||||
|
||||
// Main window.
|
||||
HWND hwnd_;
|
||||
HWND hwnd_ = nullptr;
|
||||
|
||||
// Draggable region.
|
||||
HRGN draggable_region_;
|
||||
HRGN draggable_region_ = nullptr;
|
||||
|
||||
// Font for buttons and text fields.
|
||||
HFONT font_;
|
||||
int font_height_;
|
||||
HFONT font_ = nullptr;
|
||||
int font_height_ = 0;
|
||||
|
||||
// Buttons.
|
||||
HWND back_hwnd_;
|
||||
HWND forward_hwnd_;
|
||||
HWND reload_hwnd_;
|
||||
HWND stop_hwnd_;
|
||||
HWND back_hwnd_ = nullptr;
|
||||
HWND forward_hwnd_ = nullptr;
|
||||
HWND reload_hwnd_ = nullptr;
|
||||
HWND stop_hwnd_ = nullptr;
|
||||
|
||||
// URL text field.
|
||||
HWND edit_hwnd_;
|
||||
WNDPROC edit_wndproc_old_;
|
||||
HWND edit_hwnd_ = nullptr;
|
||||
WNDPROC edit_wndproc_old_ = nullptr;
|
||||
|
||||
// Find dialog.
|
||||
HWND find_hwnd_;
|
||||
UINT find_message_id_;
|
||||
WNDPROC find_wndproc_old_;
|
||||
HWND find_hwnd_ = nullptr;
|
||||
UINT find_message_id_ = 0;
|
||||
WNDPROC find_wndproc_old_ = nullptr;
|
||||
|
||||
// Find dialog state.
|
||||
FINDREPLACE find_state_;
|
||||
WCHAR find_buff_[80];
|
||||
FINDREPLACE find_state_ = {0};
|
||||
WCHAR find_buff_[80] = {0};
|
||||
std::wstring find_what_last_;
|
||||
bool find_next_;
|
||||
bool find_match_case_last_;
|
||||
bool find_next_ = false;
|
||||
bool find_match_case_last_ = false;
|
||||
|
||||
bool window_destroyed_;
|
||||
bool browser_destroyed_;
|
||||
bool window_destroyed_ = false;
|
||||
bool browser_destroyed_ = false;
|
||||
|
||||
bool called_enable_non_client_dpi_scaling_;
|
||||
bool called_enable_non_client_dpi_scaling_ = false;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(RootWindowWin);
|
||||
};
|
||||
|
Reference in New Issue
Block a user