Skip to content

Commit

Permalink
fancyzones unity3d crash fix (#1914)
Browse files Browse the repository at this point in the history
* fancyzones unity3d crash fix

* intelisence warning fix, and review issue fix

* Fix for review comment
  • Loading branch information
PrzemyslawTusinski committed Apr 3, 2020
1 parent 75f3a30 commit 2806c38
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions src/modules/fancyzones/lib/ZoneWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,12 @@ struct ZoneWindow : public winrt::implements<ZoneWindow, IZoneWindow>
static const UINT m_showAnimationDuration = 200; // ms
static const UINT m_flashDuration = 700; // ms

HWND draggedWindow;
BYTE draggedWindowInitialAlpha;
HWND draggedWindow = nullptr;
long draggedWindowExstyle = 0;
COLORREF draggedWindowCrKey = RGB(0, 0, 0);
DWORD draggedWindowDwFlags = 0;
BYTE draggedWindowInitialAlpha = 0;

ULONG_PTR gdiplusToken;
};

Expand Down Expand Up @@ -335,21 +339,26 @@ bool ZoneWindow::Init(IZoneWindowHost* host, HINSTANCE hinstance, HMONITOR monit

IFACEMETHODIMP ZoneWindow::MoveSizeEnter(HWND window, bool dragEnabled) noexcept
{
if (m_windowMoveSize)
{
return E_INVALIDARG;
}

if (m_host->isMakeDraggedWindowTransparentActive())
{
RestoreOrginalTransparency();

draggedWindowExstyle = GetWindowLong(window, GWL_EXSTYLE);

draggedWindow = window;
SetWindowLong(window,
GWL_EXSTYLE,
GetWindowLong(window, GWL_EXSTYLE) | WS_EX_LAYERED);
draggedWindowExstyle | WS_EX_LAYERED);

GetLayeredWindowAttributes(window, 0, &draggedWindowInitialAlpha, 0);
GetLayeredWindowAttributes(window, &draggedWindowCrKey, &draggedWindowInitialAlpha, &draggedWindowDwFlags);

SetLayeredWindowAttributes(window, 0, (255 * 50) / 100, LWA_ALPHA);
}
if (m_windowMoveSize)
{
return E_INVALIDARG;
}

m_dragEnabled = dragEnabled;
m_windowMoveSize = window;
Expand Down Expand Up @@ -415,10 +424,8 @@ ZoneWindow::RestoreOrginalTransparency() noexcept
{
if (m_host->isMakeDraggedWindowTransparentActive() && draggedWindow != nullptr)
{
SetLayeredWindowAttributes(draggedWindow,
0,
draggedWindowInitialAlpha == 0 ? 255 : draggedWindowInitialAlpha,
LWA_ALPHA);
SetLayeredWindowAttributes(draggedWindow, draggedWindowCrKey, draggedWindowInitialAlpha, draggedWindowDwFlags);
SetWindowLong(draggedWindow, GWL_EXSTYLE, draggedWindowExstyle);
draggedWindow = nullptr;
}
}
Expand Down Expand Up @@ -738,7 +745,10 @@ void ZoneWindow::CycleActiveZoneSetInternal(DWORD wparam, Trace::ZoneWindow::Inp
void ZoneWindow::FlashZones() noexcept
{
// "Turning FLASHING_ZONE option off"
if(true) return;
if (true)
{
return;
}

m_flashMode = true;

Expand Down

0 comments on commit 2806c38

Please sign in to comment.