1
0
mirror of https://github.com/narzoul/DDrawCompat synced 2024-12-30 08:55:36 +01:00

Removed unnecessary GDI redraws

This commit is contained in:
narzoul 2016-04-06 20:57:15 +02:00
parent bb83780f0a
commit f12b95ec9f
3 changed files with 24 additions and 45 deletions

View File

@ -2,6 +2,7 @@
#include "CompatGdiDc.h"
#include "CompatGdiPaintHandlers.h"
#include "CompatGdiScrollBar.h"
#include "CompatGdiScrollFunctions.h"
#include "CompatGdiTitleBar.h"
#include "CompatPaletteConverter.h"
#include "CompatPrimarySurface.h"
@ -81,7 +82,12 @@ namespace
LRESULT WINAPI editWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
return defPaintProc(hwnd, msg, wParam, lParam, g_origEditWndProc, "editWndProc");
LRESULT result = defPaintProc(hwnd, msg, wParam, lParam, g_origEditWndProc, "editWndProc");
if (0 == result && (WM_HSCROLL == msg || WM_VSCROLL == msg))
{
CompatGdiScrollFunctions::updateScrolledWindow(hwnd);
}
return result;
}
LRESULT WINAPI listBoxWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)

View File

@ -1,5 +1,6 @@
#include "CompatGdi.h"
#include "CompatGdiScrollFunctions.h"
#include "DDrawLog.h"
#include "Hook.h"
namespace
@ -11,8 +12,13 @@ namespace
_In_ const RECT *lpRect,
_In_ const RECT *lpClipRect)
{
Compat::LogEnter("scrollWindow", hWnd, XAmount, YAmount, lpRect, lpClipRect);
BOOL result = CALL_ORIG_FUNC(ScrollWindow)(hWnd, XAmount, YAmount, lpRect, lpClipRect);
CompatGdiScrollFunctions::updateScrolledWindow(hWnd);
if (result)
{
CompatGdiScrollFunctions::updateScrolledWindow(hWnd);
}
Compat::LogLeave("scrollWindow", hWnd, XAmount, YAmount, lpRect, lpClipRect) << result;
return result;
}
@ -26,9 +32,16 @@ namespace
_Out_ LPRECT prcUpdate,
_In_ UINT flags)
{
Compat::LogEnter("scrollWindowEx",
hWnd, dx, dy, prcScroll, prcClip, hrgnUpdate, prcUpdate, flags);
int result = CALL_ORIG_FUNC(ScrollWindowEx)(
hWnd, dx, dy, prcScroll, prcClip, hrgnUpdate, prcUpdate, flags);
CompatGdiScrollFunctions::updateScrolledWindow(hWnd);
if (ERROR != result)
{
CompatGdiScrollFunctions::updateScrolledWindow(hWnd);
}
Compat::LogLeave("scrollWindowEx",
hWnd, dx, dy, prcScroll, prcClip, hrgnUpdate, prcUpdate, flags) << result;
return result;
}
}
@ -45,6 +58,6 @@ namespace CompatGdiScrollFunctions
void updateScrolledWindow(HWND hwnd)
{
RedrawWindow(hwnd, nullptr, nullptr, RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_ALLCHILDREN);
RedrawWindow(hwnd, nullptr, nullptr, RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_NOCHILDREN);
}
}

View File

@ -19,7 +19,6 @@ namespace
void disableDwmAttributes(HWND hwnd);
void onMenuSelect();
void onScroll(HWND hwnd, HWND scrollBar);
void onWindowPosChanged(HWND hwnd);
void removeDropShadow(HWND hwnd);
@ -44,15 +43,10 @@ namespace
{
onWindowPosChanged(ret->hwnd);
}
else if (WM_VSCROLL == ret->message || WM_HSCROLL == ret->message)
{
onScroll(ret->hwnd, reinterpret_cast<HWND>(ret->lParam));
}
else if (WM_COMMAND == ret->message)
{
auto msgSource = LOWORD(ret->wParam);
auto notifCode = HIWORD(ret->wParam);
if (0 != msgSource && 1 != msgSource && (EN_HSCROLL == notifCode || EN_VSCROLL == notifCode))
if (ret->lParam && (EN_HSCROLL == notifCode || EN_VSCROLL == notifCode))
{
CompatGdiScrollFunctions::updateScrolledWindow(reinterpret_cast<HWND>(ret->lParam));
}
@ -61,10 +55,6 @@ namespace
{
onMenuSelect();
}
else if (BM_SETSTYLE == ret->message)
{
RedrawWindow(ret->hwnd, nullptr, nullptr, RDW_ERASE | RDW_FRAME | RDW_INVALIDATE);
}
}
LRESULT result = CallNextHookEx(nullptr, nCode, wParam, lParam);
@ -83,20 +73,6 @@ namespace
&disableTransitions, sizeof(disableTransitions));
}
LRESULT CALLBACK mouseProc(int nCode, WPARAM wParam, LPARAM lParam)
{
if (HC_ACTION == nCode)
{
auto mhs = reinterpret_cast<MOUSEHOOKSTRUCT*>(lParam);
if (WM_MOUSEWHEEL == wParam || WM_MOUSEHWHEEL == wParam)
{
CompatGdiScrollFunctions::updateScrolledWindow(mhs->hwnd);
}
}
return CallNextHookEx(nullptr, nCode, wParam, lParam);
}
void CALLBACK objectStateChangeEvent(
HWINEVENTHOOK /*hWinEventHook*/,
DWORD /*event*/,
@ -147,21 +123,6 @@ namespace
}
}
void onScroll(HWND hwnd, HWND scrollBar)
{
if (scrollBar)
{
UpdateWindow(scrollBar);
}
CompatGdiScrollFunctions::updateScrolledWindow(hwnd);
if (scrollBar)
{
ValidateRect(scrollBar, nullptr);
}
}
void onWindowPosChanged(HWND hwnd)
{
CompatGdi::GdiScopedThreadLock lock;
@ -199,7 +160,6 @@ namespace CompatGdiWinProc
{
const DWORD threadId = GetCurrentThreadId();
SetWindowsHookEx(WH_CALLWNDPROCRET, callWndRetProc, nullptr, threadId);
SetWindowsHookEx(WH_MOUSE, &mouseProc, nullptr, threadId);
SetWinEventHook(EVENT_OBJECT_STATECHANGE, EVENT_OBJECT_STATECHANGE,
nullptr, &objectStateChangeEvent, 0, threadId, WINEVENT_OUTOFCONTEXT);
}