Classic Theme Explorer: QtTabBar fixes
This commit is contained in:
parent
e290872724
commit
3969dbbb43
1 changed files with 43 additions and 15 deletions
|
@ -116,7 +116,28 @@ HWND GetChildWindow(HWND parent, const wchar_t* className, int index)
|
|||
return data.result;
|
||||
}
|
||||
|
||||
VOID ClassicThemeExplorer(HWND hWnd, WPARAM wParam)
|
||||
// QtTabBar's hooking taints the wParam for some reason, so we strip off the extra bits if needed.
|
||||
BOOL ShouldApply(WPARAM wParam, BOOL fallback, BOOL checkSix) {
|
||||
Wh_Log(L"0x%x, %d", wParam, fallback);
|
||||
if (wParam > 0xffff) {
|
||||
Wh_Log(L"above 0xffff");
|
||||
if ((wParam & 1) == 1) {
|
||||
Wh_Log(L"1 set");
|
||||
return true;
|
||||
} else if (checkSix && (wParam & 6) == 6) {
|
||||
Wh_Log(L"6 set");
|
||||
return true;
|
||||
} else {
|
||||
Wh_Log(L"falling back");
|
||||
return fallback;
|
||||
}
|
||||
} else {
|
||||
Wh_Log(L"falling back");
|
||||
return fallback;
|
||||
}
|
||||
}
|
||||
|
||||
VOID ClassicThemeExplorer(HWND hWnd, UINT uMsg, WPARAM wParam)
|
||||
{
|
||||
wchar_t classNameBuffer[256];
|
||||
wchar_t pathBuffer[MAX_PATH];
|
||||
|
@ -131,7 +152,11 @@ VOID ClassicThemeExplorer(HWND hWnd, WPARAM wParam)
|
|||
HWND ClassicComboBox = GetChildWindow(ClassicAddressBandRoot, L"ComboBoxEx32", 1);
|
||||
HWND ClassicRebar = GetChildWindow((HWND)hWnd, L"ReBarWindow32", 2);
|
||||
|
||||
if (settings.clientEdge && (wParam == 1 || wParam == 6)) {
|
||||
BOOL shouldApply = uMsg == WM_PARENTNOTIFY && ShouldApply(wParam, wParam == 1 || wParam == 6, false);
|
||||
BOOL shouldApply2 = uMsg == WM_PARENTNOTIFY && ShouldApply(wParam, wParam == 1, true);
|
||||
|
||||
if (settings.clientEdge && shouldApply) {
|
||||
Wh_Log(L"applying client edge");
|
||||
HWND TreeView = GetChildWindow((HWND)hWnd, L"SysTreeView32", 1);
|
||||
LONG TreeViewExtendedStyle = GetWindowLongPtrW(TreeView, GWL_EXSTYLE);
|
||||
TreeViewExtendedStyle |= WS_EX_CLIENTEDGE;
|
||||
|
@ -148,27 +173,29 @@ VOID ClassicThemeExplorer(HWND hWnd, WPARAM wParam)
|
|||
SetWindowPos(ShellTabWindowClass, NULL, NULL, NULL, rect.right - rect.left, rect.bottom - rect.top, SWP_NOMOVE | SWP_NOZORDER | SWP_DEFERERASE);
|
||||
}
|
||||
|
||||
if (settings.rebarBorder && (wParam == 1 || wParam == 6)) {
|
||||
if (settings.rebarBorder && shouldApply) {
|
||||
Wh_Log(L"applying rebar border");
|
||||
LONG ClassicRebarStyle = GetWindowLongPtrW(ClassicRebar, GWL_STYLE);
|
||||
ClassicRebarStyle |= RBS_BANDBORDERS;
|
||||
ClassicRebarStyle |= WS_BORDER;
|
||||
SetWindowLongPtrW(ClassicRebar, GWL_STYLE, ClassicRebarStyle);
|
||||
}
|
||||
|
||||
if (settings.rebarFixedHeight && (wParam == 1 || wParam == 6)) {
|
||||
if (settings.rebarFixedHeight && shouldApply) {
|
||||
Wh_Log(L"applying rebar fixed height");
|
||||
LONG ClassicRebarStyle = GetWindowLongPtrW(ClassicRebar, GWL_STYLE);
|
||||
ClassicRebarStyle &= ~RBS_VARHEIGHT;
|
||||
SetWindowLongPtrW(ClassicRebar, GWL_STYLE, ClassicRebarStyle);
|
||||
}
|
||||
|
||||
// Apply bar changes
|
||||
if ((settings.rebarBorder || settings.rebarFixedHeight) && (wParam == 1 || wParam == 6)) {
|
||||
if ((settings.rebarBorder || settings.rebarFixedHeight) && shouldApply) {
|
||||
GetWindowRect(ClassicRebar, &rect);
|
||||
SetWindowPos(ClassicRebar, NULL, NULL, NULL, rect.right - rect.left + 1, rect.bottom - rect.top, SWP_NOMOVE | SWP_NOZORDER | SWP_DEFERERASE);
|
||||
SetWindowPos(ClassicRebar, NULL, NULL, NULL, rect.right - rect.left, rect.bottom - rect.top, SWP_NOMOVE | SWP_NOZORDER | SWP_DEFERERASE);
|
||||
}
|
||||
|
||||
if (settings.hideNavigation && wParam == 1) {
|
||||
if (settings.hideNavigation && shouldApply2) {
|
||||
// Save the location of the Rebar
|
||||
HWND NavBarRebar = GetChildWindow((HWND)hWnd, L"ReBarWindow32", 1);
|
||||
GetWindowRect(NavBarRebar, &rect);
|
||||
|
@ -212,10 +239,11 @@ VOID ClassicThemeExplorer(HWND hWnd, WPARAM wParam)
|
|||
HWND toolbarwindow = GetChildWindow(NavBarAddressBandRoot, L"ToolbarWindow32", 1);
|
||||
GetWindowTextW(toolbarwindow, pathBuffer, MAX_PATH);
|
||||
|
||||
// remove "Address: "
|
||||
// FIXME: locale issues, codecvt deprecated as of c++17
|
||||
// FIXME: codecvt deprecated as of c++17
|
||||
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
|
||||
|
||||
// remove "Address: "
|
||||
// FIXME: support more locales
|
||||
std::wstring _pathStr = pathBuffer;
|
||||
std::string pathStr(_pathStr.begin(), _pathStr.end());
|
||||
pathStr = std::regex_replace(pathStr, std::regex("Address: "), "");
|
||||
|
@ -233,7 +261,7 @@ VOID ClassicThemeExplorer(HWND hWnd, WPARAM wParam)
|
|||
// TODO: figure out how to get and set folder icon
|
||||
}
|
||||
|
||||
if (settings.hideRefresh && (wParam == 1 || wParam == 6)) {
|
||||
if (settings.hideRefresh && shouldApply) {
|
||||
HWND GoButtonToolbar = GetChildWindow(ClassicAddressBandRoot, L"ToolbarWindow32", 1);
|
||||
SendMessageW(GoButtonToolbar, WM_CLOSE, 0, 0);
|
||||
}
|
||||
|
@ -333,14 +361,14 @@ UINT g_subclassRegisteredMsg = RegisterWindowMessage(L"Windhawk_SetWindowSubclas
|
|||
|
||||
LRESULT CALLBACK ClassicThemeExplorerSubClass(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData) {
|
||||
if (uMsg == WM_DESTROY) {
|
||||
//Wh_Log(L"[Destroy] uMsg: 0x%04x, wParam: 0x%x", uMsg, wParam);
|
||||
Wh_Log(L"[Destroy] uMsg: 0x%04x, wParam: 0x%x", uMsg, wParam);
|
||||
RemoveWindowSubclass(hWnd, ClassicThemeExplorerSubClass, 0);
|
||||
} else if (uMsg == g_subclassRegisteredMsg && !wParam) {
|
||||
//Wh_Log(L"[Unsub] uMsg: 0x%04x, wParam: 0x%x", uMsg, wParam);
|
||||
Wh_Log(L"[Unsub] uMsg: 0x%04x, wParam: 0x%x", uMsg, wParam);
|
||||
RemoveWindowSubclass(hWnd, ClassicThemeExplorerSubClass, 0);
|
||||
} else if (uMsg == WM_PARENTNOTIFY || uMsg == WM_SIZE || uMsg == WM_GETICON) {
|
||||
//Wh_Log(L"[Target] uMsg: 0x%04x, wParam: 0x%x", uMsg, wParam);
|
||||
ClassicThemeExplorer(hWnd, wParam);
|
||||
Wh_Log(L"[Target] uMsg: 0x%04x, wParam: 0x%x", uMsg, wParam);
|
||||
ClassicThemeExplorer(hWnd, uMsg, wParam);
|
||||
//} else {
|
||||
//Wh_Log(L"[Unknown] uMsg: 0x%04x, wParam: 0x%x", uMsg, wParam);
|
||||
}
|
||||
|
@ -405,7 +433,7 @@ HWND WINAPI SHCreateWorkerWindowHook(WNDPROC wndProc, HWND hWndParent, DWORD dwE
|
|||
LSTATUS lRes = ERROR_FILE_NOT_FOUND;
|
||||
DWORD dwSize = 0;
|
||||
|
||||
//Wh_Log("g_uiThreadId: %d, GetCurrentThreadId: %d", g_uiThreadId, GetCurrentThreadId());
|
||||
Wh_Log(L"g_uiThreadId: %d, GetCurrentThreadId: %d", g_uiThreadId, GetCurrentThreadId());
|
||||
|
||||
// is this even needed? it changes thread after some time anyways
|
||||
//if (g_uiThreadId && g_uiThreadId != GetCurrentThreadId()) return pOriginalSHCreateWorkerWindow(wndProc, hWndParent, dwExStyle, dwStyle, hMenu, wnd_extra);
|
||||
|
@ -422,7 +450,7 @@ HWND WINAPI SHCreateWorkerWindowHook(WNDPROC wndProc, HWND hWndParent, DWORD dwE
|
|||
|
||||
else result = pOriginalSHCreateWorkerWindow(wndProc, hWndParent, dwExStyle, dwStyle, hMenu, wnd_extra);
|
||||
|
||||
//Wh_Log("dwExStyle: 0x%x, dwStyle: 0x%x, result: 0x%x", dwExStyle, dwStyle, result);
|
||||
Wh_Log(L"dwExStyle: 0x%x, dwStyle: 0x%x, result: 0x%x", dwExStyle, dwStyle, result);
|
||||
|
||||
if (dwExStyle == 0x10000 && dwStyle == 0x46000000 && result) SetWindowSubclassFromAnyThread(hWndParent, ClassicThemeExplorerSubClass, 0, 0);
|
||||
|
||||
|
|
Loading…
Reference in a new issue