Mercurial > minori
comparison dep/animia/src/win/win32.cc @ 202:71832ffe425a
animia: re-add kvm fd source
this is all being merged from my wildly out-of-date laptop. SORRY!
in other news, I edited the CI file to install the wayland client
as well, so the linux CI build might finally get wayland stuff.
| author | Paper <paper@paper.us.eu.org> |
|---|---|
| date | Tue, 02 Jan 2024 06:05:06 -0500 |
| parents | bc1ae1810855 |
| children |
comparison
equal
deleted
inserted
replaced
| 201:8f6f8dd2eb23 | 202:71832ffe425a |
|---|---|
| 1 /* | |
| 2 * win/win32.cc: support for Windows | |
| 3 * | |
| 4 * Surprisingly, this is the one time where Microsoft actually | |
| 5 * does it fairly OK. Everything has a pretty simple API, despite | |
| 6 * the stupid wide string stuff. | |
| 7 */ | |
| 1 #include "animia/win/win32.h" | 8 #include "animia/win/win32.h" |
| 2 #include "animia.h" | 9 #include "animia.h" |
| 3 #include "animia/util/win32.h" | 10 #include "animia/util/win32.h" |
| 4 #include "animia/win.h" | 11 #include "animia/win.h" |
| 5 | 12 |
| 22 buffer.resize(size); | 29 buffer.resize(size); |
| 23 return buffer; | 30 return buffer; |
| 24 } | 31 } |
| 25 | 32 |
| 26 static std::wstring GetWindowText(HWND hwnd) { | 33 static std::wstring GetWindowText(HWND hwnd) { |
| 27 const int estimated_size = ::GetWindowTextLengthW(hwnd); | 34 const auto estimated_size = ::GetWindowTextLengthW(hwnd); |
| 35 std::wstring buffer(estimated_size + 1, L'\0'); | |
| 28 | 36 |
| 29 std::wstring buffer(estimated_size + 1, L'\0'); | |
| 30 const auto size = ::GetWindowTextW(hwnd, &buffer.front(), buffer.length()); | 37 const auto size = ::GetWindowTextW(hwnd, &buffer.front(), buffer.length()); |
| 31 /* GetWindowTextLength docs: | 38 /* GetWindowTextLength docs: |
| 32 "Under certain conditions, the GetWindowTextLength function may return a value | 39 "Under certain conditions, the GetWindowTextLength function may return a value |
| 33 that is larger than the actual length of the text." */ | 40 that is larger than the actual length of the text." */ |
| 34 buffer.resize(size); | 41 buffer.resize(size); |
| 158 return FALSE; | 165 return FALSE; |
| 159 | 166 |
| 160 return TRUE; | 167 return TRUE; |
| 161 } | 168 } |
| 162 | 169 |
| 163 bool Win32WinTools::EnumerateWindows(window_proc_t window_proc) { | 170 bool EnumerateWindows(window_proc_t window_proc) { |
| 164 if (!window_proc) | 171 if (!window_proc) |
| 165 return false; | 172 return false; |
| 166 | 173 |
| 167 const auto param = reinterpret_cast<LPARAM>(&window_proc); | 174 const auto param = reinterpret_cast<LPARAM>(&window_proc); |
| 168 | 175 |
