-
Notifications
You must be signed in to change notification settings - Fork 461
Add the WM_CLASS property to the BizHawk window #4782
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
base: master
Are you sure you want to change the base?
Changes from 5 commits
2c6763f
95028e8
5171202
d9a09eb
86ef7f8
8cb4922
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -292,5 +292,35 @@ public static string SimpleSubshell(string cmd, string args, string noOutputMsg) | |
| if (stdout.EndOfStream) throw new Exception($"{noOutputMsg} ({cmd} wrote nothing to stdout)"); | ||
| return stdout.ReadLine()!; | ||
| } | ||
|
|
||
| public static void SetWMClass(IntPtr x11Display, string className) | ||
|
Leopardly marked this conversation as resolved.
Outdated
|
||
| { | ||
| //Setup the ClassHint | ||
| var wmSet = new XlibImports.XClassHint{res_name = Marshal.StringToCoTaskMemAnsi("BizHawk"), res_class = Marshal.StringToCoTaskMemAnsi(className)}; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you explain why the same string needs to be passed twice?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The WM_CLASS property is made up of two parts (name and class) - both need to be provided - they can be different/unique however it is somewhat common to see application name used in both fields (as I have here as the default behaviour).
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Incidentally, I saw this in Mono's issue tracker: https://gitlab.winehq.org/mono/mono/-/work_items/32
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interesting, I can't say I'd seen that happening (although I'm just on whatever mono is in Cachy's repos) - Picking through Keepass's implementation it looks like their is a neater way to be picking up the Window frame to assign WM_CLASS to - so I may take a look at that next week (away all weekend) |
||
| IntPtr point = XlibImports.XAllocClassHint(); | ||
| Marshal.StructureToPtr(wmSet, point, true); | ||
|
|
||
| //To find the window we must query twice, once to get the array length and the second to populate | ||
| XlibImports.XQueryTree(x11Display, XlibImports.XDefaultRootWindow(x11Display), out _, out _, out _, out int windowCount); | ||
| IntPtr[] windowList = new IntPtr[windowCount]; | ||
| XlibImports.XQueryTree(x11Display, XlibImports.XDefaultRootWindow(x11Display), out _, out _, out windowList, out windowCount); | ||
| for(int windowIterator = 0; windowIterator < windowCount; windowIterator++) | ||
| { | ||
| XlibImports.XFetchName(x11Display, windowList[windowIterator], out string name); | ||
| if(name?.Contains("BizHawk") == true) | ||
| { | ||
| //Interogate if a WM_CLASS is already set | ||
| XlibImports.XGetClassHint(x11Display, windowList[windowIterator], out var classHint); | ||
| if(classHint == IntPtr.Zero) | ||
| { | ||
| //Assign+Retrieve - doesn't seem to set properly without retrieving it after) | ||
| XlibImports.XSetClassHint(x11Display, windowList[windowIterator], point); | ||
| XlibImports.XGetClassHint(x11Display, windowList[windowIterator],out _); | ||
| } | ||
| //Reset classHint after checking, doesn't seem to overwrite otherwise. | ||
| classHint = IntPtr.Zero; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
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.
Why is this a CLI flag? When should a user be changing it? If it's for vendoring, we already have
VersionInfo.CustomBuildString.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.
My initial reasoning for looking into adding WM_CLASS was to help improve BizHawk's integration with the DE (I use KDE). By defining a WM_CLASS we can hint StartupWMClass for example in .desktop files.
In allowing WM_CLASS to be set in a CLI arg it is then feasible to distinguish between different installs of Bizhawk (for example, a Kaizo Ironmon setup and a regular Bizhawk install)
This comment was marked as resolved.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as resolved.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
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.
Hmm I should really get around to making a textbox to set the window title thing. Then you could pull from that, and your
.desktopfiles could pass--config. Or maybe it could use the rom name and you wouldn't need any extra flags?edit: fbdb128