[FancyZones] Fix deadlocks in ZoneWindowDrawing (#10461)

* Fixed deadlocks in ZoneWindowDrawing

Moved all possibly reentrant or blocking calls to ShowWindow out of critical sections.

* Initialize bools

* Tune flashing visuals

* Address PR comments

* Use  = true; to initialize bools
* Remove tracing from GetAnimationAlpha
* Use member initialization when constructing AnimationInfo

* Refactor rendering

* Whitespace

* Hide window on render failure
This commit is contained in:
Ivan Stošić
2021-03-29 13:39:16 +02:00
committed by GitHub
parent ccc380f11c
commit 31fa9475da
4 changed files with 80 additions and 67 deletions

View File

@@ -25,8 +25,14 @@ class ZoneWindowDrawing
struct AnimationInfo
{
std::chrono::steady_clock::time_point tStart;
unsigned duration;
bool fadeIn;
bool autoHide;
};
enum struct RenderResult
{
Ok,
AnimationEnded,
Failed,
};
HWND m_window = nullptr;
@@ -42,7 +48,7 @@ class ZoneWindowDrawing
static IDWriteFactory* GetWriteFactory();
static D2D1_COLOR_F ConvertColor(COLORREF color);
static D2D1_RECT_F ConvertRect(RECT rect);
void Render();
RenderResult Render();
void RenderLoop();
std::atomic<bool> m_shouldRender = false;
@@ -55,8 +61,8 @@ public:
~ZoneWindowDrawing();
ZoneWindowDrawing(HWND window);
void Hide();
void Show(unsigned animationMillis);
void Flash(unsigned animationMillis);
void Show();
void Flash();
void DrawActiveZoneSet(const IZoneSet::ZonesMap& zones,
const std::vector<size_t>& highlightZones,
winrt::com_ptr<IZoneWindowHost> host);