fix: white window flicker on window creation (#47022)
This commit is contained in:
parent
2493e530d0
commit
7ab032f594
3 changed files with 19 additions and 0 deletions
|
|
@ -37,6 +37,7 @@
|
||||||
#include "shell/common/options_switches.h"
|
#include "shell/common/options_switches.h"
|
||||||
#include "ui/aura/window_tree_host.h"
|
#include "ui/aura/window_tree_host.h"
|
||||||
#include "ui/base/hit_test.h"
|
#include "ui/base/hit_test.h"
|
||||||
|
#include "ui/compositor/compositor.h"
|
||||||
#include "ui/display/screen.h"
|
#include "ui/display/screen.h"
|
||||||
#include "ui/gfx/image/image.h"
|
#include "ui/gfx/image/image.h"
|
||||||
#include "ui/gfx/native_widget_types.h"
|
#include "ui/gfx/native_widget_types.h"
|
||||||
|
|
@ -1224,6 +1225,7 @@ void NativeWindowViews::SetBackgroundColor(SkColor background_color) {
|
||||||
DeleteObject((HBRUSH)previous_brush);
|
DeleteObject((HBRUSH)previous_brush);
|
||||||
InvalidateRect(GetAcceleratedWidget(), nullptr, 1);
|
InvalidateRect(GetAcceleratedWidget(), nullptr, 1);
|
||||||
#endif
|
#endif
|
||||||
|
GetWidget()->GetCompositor()->SetBackgroundColor(background_color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindowViews::SetHasShadow(bool has_shadow) {
|
void NativeWindowViews::SetHasShadow(bool has_shadow) {
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,20 @@ ElectronDesktopWindowTreeHostWin::ElectronDesktopWindowTreeHostWin(
|
||||||
|
|
||||||
ElectronDesktopWindowTreeHostWin::~ElectronDesktopWindowTreeHostWin() = default;
|
ElectronDesktopWindowTreeHostWin::~ElectronDesktopWindowTreeHostWin() = default;
|
||||||
|
|
||||||
|
bool ElectronDesktopWindowTreeHostWin::ShouldUpdateWindowTransparency() const {
|
||||||
|
// If transparency is updated for an opaque window before widget init is
|
||||||
|
// completed, the window flickers white before the background color is applied
|
||||||
|
// and we don't want that. We do, however, want translucent windows to be
|
||||||
|
// properly transparent, so ensure it gets updated in that case.
|
||||||
|
if (!widget_init_done_ && !native_window_view_->IsTranslucent())
|
||||||
|
return false;
|
||||||
|
return views::DesktopWindowTreeHostWin::ShouldUpdateWindowTransparency();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ElectronDesktopWindowTreeHostWin::OnWidgetInitDone() {
|
||||||
|
widget_init_done_ = true;
|
||||||
|
}
|
||||||
|
|
||||||
bool ElectronDesktopWindowTreeHostWin::PreHandleMSG(UINT message,
|
bool ElectronDesktopWindowTreeHostWin::PreHandleMSG(UINT message,
|
||||||
WPARAM w_param,
|
WPARAM w_param,
|
||||||
LPARAM l_param,
|
LPARAM l_param,
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,8 @@ class ElectronDesktopWindowTreeHostWin : public views::DesktopWindowTreeHostWin,
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// views::DesktopWindowTreeHostWin:
|
// views::DesktopWindowTreeHostWin:
|
||||||
|
void OnWidgetInitDone() override;
|
||||||
|
bool ShouldUpdateWindowTransparency() const override;
|
||||||
bool PreHandleMSG(UINT message,
|
bool PreHandleMSG(UINT message,
|
||||||
WPARAM w_param,
|
WPARAM w_param,
|
||||||
LPARAM l_param,
|
LPARAM l_param,
|
||||||
|
|
@ -51,6 +53,7 @@ class ElectronDesktopWindowTreeHostWin : public views::DesktopWindowTreeHostWin,
|
||||||
private:
|
private:
|
||||||
raw_ptr<NativeWindowViews> native_window_view_; // weak ref
|
raw_ptr<NativeWindowViews> native_window_view_; // weak ref
|
||||||
std::optional<bool> force_should_paint_as_active_;
|
std::optional<bool> force_should_paint_as_active_;
|
||||||
|
bool widget_init_done_ = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace electron
|
} // namespace electron
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue