diff options
| author | Jonas Kümmerlin <jonas@kuemmerlin.eu> | 2020-04-18 17:34:55 +0200 |
|---|---|---|
| committer | Jonas Kümmerlin <jonas@kuemmerlin.eu> | 2020-04-18 17:34:55 +0200 |
| commit | 479d1226faaa937ef6820b14f36099ef3f575883 (patch) | |
| tree | 10e5560fb8bae6c317ca06564c9609c3c498503e /alf/alflayout.cpp | |
| parent | 4054b17c661d2e709895e8235e9dce6edaa61e4f (diff) | |
implement background color
reduce flickering by keeping pixels if we know the background didn't change
panel text is now gone, it would require us to redraw every transparent
widget on top, which is a bad tradeoff since that panel text isn't very
useful anyway.
Diffstat (limited to 'alf/alflayout.cpp')
| -rw-r--r-- | alf/alflayout.cpp | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/alf/alflayout.cpp b/alf/alflayout.cpp index c05d355..73b05a8 100644 --- a/alf/alflayout.cpp +++ b/alf/alflayout.cpp @@ -102,6 +102,18 @@ ALF_Layout_ForwardFont(ALFLayout *layout, HWND window, HFONT font, LPARAM redraw } } +static void +ALF_Layout_ForwardBgColor(ALFLayout *layout, HWND window, WPARAM wparam, LPARAM lparam) +{ + (void)window; + + ALF_FOR_LIST(ALFWidgetPriv, list, &layout->widgets, i) { + if (i->flags & ALF_LAYOUT_INHERITBGCOLOR) { + SendMessage(i->hwnd, ALF_WM_SETBGCOLOR, wparam, lparam); + } + } +} + void ALF_Layout_EnsureRowExists(ALFLayout *layout, int rowno) { @@ -305,6 +317,8 @@ ALF_Layout_Apply(ALFLayout* layout, HWND window) // now apply positions to widgets HDWP hdwp = BeginDeferWindowPos(layout->nColumns * layout->nRows); + ALFColor bgcolor = (ALFColor)SendMessage(window, ALF_WM_GETBGCOLOR, 0, 0); + ALF_FOR_LIST(ALFWidgetPriv, list, &layout->widgets, c) { int col = c->x; int row = c->y; @@ -320,10 +334,15 @@ ALF_Layout_Apply(ALFLayout* layout, HWND window) if (c->flags & ALF_LAYOUT_CUSTOMPOS) { hdwp = (HDWP)SendMessage(c->hwnd, ALF_WM_APPLYSIZE, (WPARAM)hdwp, (LPARAM)&r); } else { + UINT flags = SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOOWNERZORDER; + + if (bgcolor == ALF_COLOR_TRANSPARENT) + flags |= SWP_NOCOPYBITS; + hdwp = DeferWindowPos(hdwp, c->hwnd, 0, r.left, r.top, r.right - r.left, r.bottom - r.top, - SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOCOPYBITS); + flags); } } @@ -349,6 +368,9 @@ ALF_Layout_AddWidget(ALFLayout* layout, HWND window, const ALFAddWidgetParams* p if (w->flags & ALF_LAYOUT_INHERITFONT) { SendMessage(w->hwnd, WM_SETFONT, (WPARAM)SendMessage(window, WM_GETFONT, 0, 0), 0); } + if (w->flags & ALF_LAYOUT_INHERITBGCOLOR) { + SendMessage(w->hwnd, ALF_WM_SETBGCOLOR, (WPARAM)SendMessage(window, ALF_WM_GETBGCOLOR, 0, 0), 0); + } ALF_ListInsert(layout->widgets.prev, &w->list); @@ -502,6 +524,8 @@ ALF_Layout_SetWidgetFlags(ALFLayout *layout, HWND window, HWND needle, DWORD fla if (flags & ALF_LAYOUT_INHERITFONT) SendMessage(w->hwnd, WM_SETFONT, (WPARAM)SendMessage(window, WM_GETFONT, 0, 0), 0); + if (flags & ALF_LAYOUT_INHERITBGCOLOR) + SendMessage(w->hwnd, ALF_WM_SETBGCOLOR, (WPARAM)SendMessage(window, ALF_WM_GETBGCOLOR, 0, 0), 0); ALF_InvalidateLayout(window); @@ -681,6 +705,11 @@ ALF_Layout_HandleMessage(ALFLayout *layout, HWND hwnd, UINT msg, WPARAM wparam, return TRUE; } + if (msg == ALF_WM_SETBGCOLOR) { + ALF_Layout_ForwardBgColor(layout, hwnd, wparam, lparam); + return TRUE; + } + if (msg == ALF_WM_INVALIDATELAYOUT) { ALF_Layout_Invalidate(layout, hwnd); return TRUE; |
