-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Qt scrollbar grippers 1.0 #836
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// ==WindhawkMod== | ||
// @id fix-qt-scrollbar-grippers | ||
// @name Fix Qt scrollbar grippers | ||
// @description Fixes scrollbar grippers in Qt 6.1+ | ||
// @version 1.0 | ||
// @author kawapure | ||
// @github https://github.com/kawapure | ||
// @twitter https://twitter.com/kawaipure | ||
Check warning on line 8 in mods/fix-qt-scrollbar-grippers.wh.cpp GitHub Actions / Test changed files
|
||
// @homepage https://kawapure.github.io | ||
// @include ida64.exe | ||
// @compilerOptions -lcomdlg32 -luxtheme | ||
// ==/WindhawkMod== | ||
|
||
// ==WindhawkModReadme== | ||
/* | ||
# Fix Qt scrollbar grippers | ||
|
||
![Preview](https://raw.githubusercontent.com/kawapure/images/main/fix-qt-scrollbar-grippers.png) | ||
|
||
Qt applications compiled after 2021 (against Qt 6.1+) lack the scrollbar grippers (the lines in the middle), | ||
visible on custom visual styles, because the responsible drawing code was removed. Here is a lazy hack around | ||
that. | ||
|
||
These were removed in Qt [because the developers thought that these changes wouldn't affect Windows 10](https://github.com/qt/qtbase/commit/5f5c342924a0d9a2856b2f2d6db373e25723f2b0). | ||
They were wrong. | ||
*/ | ||
// ==/WindhawkModReadme== | ||
|
||
#include <windhawk_api.h> | ||
#include <windhawk_utils.h> | ||
#include <uxtheme.h> | ||
#include <vsstyle.h> | ||
|
||
using DrawThemeBackgroundEx_t = decltype(&DrawThemeBackgroundEx); | ||
DrawThemeBackgroundEx_t DrawThemeBackgroundEx_orig; | ||
HRESULT WINAPI DrawThemeBackgroundEx_hook(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, LPCRECT pRect, const DTBGOPTS *pOptions) | ||
{ | ||
HRESULT result = DrawThemeBackgroundEx_orig(hTheme, hdc, iPartId, iStateId, pRect, pOptions); | ||
|
||
if (iPartId == SBP_THUMBBTNHORZ || iPartId == SBP_THUMBBTNVERT) | ||
{ | ||
if (iPartId == SBP_THUMBBTNHORZ) | ||
Wh_Log(L"dtb: is SBP_THUMBBTNHORZ"); | ||
else if (iPartId == SBP_THUMBBTNVERT) | ||
Wh_Log(L"dtb: is SBP_THUMBBTNVERT"); | ||
|
||
int gripperPart = iPartId == SBP_THUMBBTNHORZ | ||
? SBP_GRIPPERHORZ | ||
: SBP_GRIPPERVERT; | ||
|
||
SIZE gripperSize = { 0 }; | ||
GetThemePartSize(hTheme, hdc, gripperPart, iStateId, nullptr, TS_TRUE, &gripperSize); | ||
|
||
if ( | ||
(iPartId == SBP_THUMBBTNVERT && (pRect->bottom - pRect->top) > gripperSize.cy) || | ||
(iPartId == SBP_THUMBBTNHORZ && (pRect->right - pRect->left) > gripperSize.cx) | ||
) | ||
{ | ||
Wh_Log(L"drawing gripper"); | ||
|
||
DrawThemeBackground(hTheme, hdc, gripperPart, iStateId, pRect, nullptr); | ||
} | ||
} | ||
|
||
return result; | ||
} | ||
|
||
// The mod is being initialized, load settings, hook functions, and do other | ||
// initialization stuff if required. | ||
BOOL Wh_ModInit() | ||
{ | ||
Wh_Log(L"Init"); | ||
|
||
Wh_SetFunctionHook( | ||
(void *)DrawThemeBackgroundEx, | ||
(void *)DrawThemeBackgroundEx_hook, | ||
(void **)&DrawThemeBackgroundEx_orig | ||
); | ||
|
||
return TRUE; | ||
} | ||
|
||
// The mod is being unloaded, free all allocated resources. | ||
void Wh_ModUninit() | ||
{ | ||
Wh_Log(L"Uninit"); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was it meant to only target IDA?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IDA was the application that I tested against, but it should work for any Qt 6.1+ application using native theme scrollbar controls. I thought that it would be obvious to any end user to specify custom targets. Should this be clarified in the README?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, better clarify it, something like:
windhawk-mods/mods/ignore-focus-loss.wh.cpp
Lines 20 to 23 in a480102
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I copied that clarification.