fix: correctly enable and disable windows on Windows and Linux (backport: 3-0-x) (#15255)

* fix: correctly enable and disable windows

* Move has_child_modal_ to NativeWindowViews

* Track modal children as an int instead of a bool

* Use correct types

* Move Increment/DecrementChildModals to NativeWindowViews

* Use parent() in NativeWindowViews

* Add test for not enabling disabled parent when modal child closes
This commit is contained in:
trop[bot] 2018-10-19 17:30:55 -07:00 committed by Shelley Vohr
parent 1c42715e1d
commit 9349b0a273
3 changed files with 54 additions and 17 deletions

View file

@ -129,6 +129,9 @@ class NativeWindowViews : public NativeWindow,
void UpdateDraggableRegions(std::unique_ptr<SkRegion> region);
void IncrementChildModals();
void DecrementChildModals();
#if defined(OS_WIN)
void SetIcon(HICON small_icon, HICON app_icon);
#elif defined(USE_X11)
@ -185,6 +188,10 @@ class NativeWindowViews : public NativeWindow,
LPARAM l_param);
#endif
// Enable/disable:
bool ShouldBeEnabled();
void SetEnabledInternal(bool enabled);
// NativeWindow:
void HandleKeyboardEvent(
content::WebContents*,
@ -268,8 +275,11 @@ class NativeWindowViews : public NativeWindow,
// has to been explicitly provided.
std::unique_ptr<SkRegion> draggable_region_; // used in custom drag.
// How many times the Disable has been called.
int disable_count_ = 0;
// Whether the window should be enabled based on user calls to SetEnabled()
bool is_enabled_ = true;
// How many modal children this window has;
// used to determine enabled state
unsigned int num_modal_children_ = 0;
bool use_content_size_ = false;
bool movable_ = true;