comparison dep/animone/src/a11y/win32.cc @ 342:adb79bdde329

dep/animone: fix tons of issues for example, the window ID stuff was just... completely wrong. since we're supporting multiple different window systems, it *has* to be a union rather than just a single integer type. HWND is also not a DWORD, it's a pointer(!), so now it's stored as a std::uintptr_t. (this probably breaks things)
author Paper <paper@paper.us.eu.org>
date Thu, 20 Jun 2024 03:03:05 -0400
parents 052ec053ee37
children 1faa72660932
comparison
equal deleted inserted replaced
341:052ec053ee37 342:adb79bdde329
1 #include <functional> 1 #include <functional>
2 #include <string> 2 #include <string>
3 #include <vector> 3 #include <vector>
4 #include <memory>
4 5
5 #include <windows.h> 6 #include <windows.h>
6 #include <uiautomation.h> 7 #include <uiautomation.h>
7 8
8 #include "animone/a11y.h" 9 #include "animone/a11y.h"
9 #include "animone/a11y/win32.h" 10 #include "animone/a11y/win32.h"
11 #include "animone/util/win32.h"
10 12
11 namespace animone::internal::win32 { 13 namespace animone::internal::win32 {
12 14
13 // Windows Accessibility API reference: 15 // Windows Accessibility API reference:
14 // https://msdn.microsoft.com/en-us/library/windows/desktop/ff486375.aspx 16 // https://msdn.microsoft.com/en-us/library/windows/desktop/ff486375.aspx
23 25
24 /* ------------------------------------------------------------------- */ 26 /* ------------------------------------------------------------------- */
25 27
26 template <typename T> 28 template <typename T>
27 struct ComInterfaceDeleter { 29 struct ComInterfaceDeleter {
28 static_assert(std::is_base_of<IUnknown, T>::value, "Invalid COM interface"); 30 static_assert(std::is_base_of<IUnknown, T>::value, "Invalid COM interface");
29 using pointer = T*; 31 using pointer = T*;
30 void operator()(pointer p) const { if (p) p->Release(); } 32 void operator()(pointer p) const { if (p) p->Release(); }
31 }; 33 };
32 34
33 template <typename T> 35 template <typename T>
34 using ComInterface = std::unique_ptr<T, ComInterfaceDeleter<T>>; 36 using ComInterface = std::unique_ptr<T, ComInterfaceDeleter<T>>;
35 37
232 return false; 234 return false;
233 235
234 if (!InitializeUIAutomation()) 236 if (!InitializeUIAutomation())
235 return false; 237 return false;
236 238
237 ComInterface<Element> parent(GetElementFromHandle(hwnd)); 239 ComInterface<Element> parent(GetElementFromHandle(reinterpret_cast<HWND>(window.id.win32)));
238 if (!parent) 240 if (!parent)
239 return false; 241 return false;
240 242
241 const std::string title = ToUtf8String(GetElementName(*parent)); 243 const std::string title = ToUtf8String(GetElementName(*parent));
242 web_browser_proc({WebBrowserInformationType::Title, title}); 244 web_browser_proc({WebBrowserInformationType::Title, title});