Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 6b9384e

Browse files
committed
Bug 1593361 - Define UNICODE in vrhost to support sending UTF16 character input r=kip
This change defines UNICODE for building vrhost so that wide chars can be sent from vrhost to Firefox. Differential Revision: https://phabricator.services.mozilla.com/D51470 --HG-- extra : moz-landing-system : lando
1 parent c372471 commit 6b9384e

3 files changed

Lines changed: 27 additions & 14 deletions

File tree

gfx/vr/vrhost/moz.build

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ EXPORTS.vrhost = [
3131
'vrhostex.h'
3232
]
3333

34-
35-
3634
DIRS += [
3735
'testhost'
3836
]
@@ -44,5 +42,9 @@ DEFINES['MOZ_NO_MOZALLOC'] = True
4442
# fixes "STL code can only be used with infallible ::operator new()"
4543
DisableStlWrapping()
4644

45+
# Define UNICODE for default support in this dll
46+
DEFINES['UNICODE'] = True
47+
DEFINES['_UNICODE'] = True
48+
4749
# Use SharedLibrary to generate the dll
4850
SharedLibrary('vrhost')

gfx/vr/vrhost/vrhostapi.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,19 +94,19 @@ struct StartFirefoxParams {
9494

9595
// Helper threadproc function for CreateVRWindow
9696
DWORD StartFirefoxThreadProc(_In_ LPVOID lpParameter) {
97-
char cmd[] = "%sfirefox.exe -wait-for-browser -profile %s --fxr";
97+
wchar_t cmd[] = L"%Sfirefox.exe -wait-for-browser -profile %S --fxr";
9898

9999
StartFirefoxParams* params = static_cast<StartFirefoxParams*>(lpParameter);
100-
char cmdWithPath[MAX_PATH + MAX_PATH] = {0};
101-
int err = sprintf_s(cmdWithPath, ARRAYSIZE(cmdWithPath), cmd,
102-
params->firefoxFolder, params->firefoxProfileFolder);
100+
wchar_t cmdWithPath[MAX_PATH + MAX_PATH] = {0};
101+
int err = swprintf_s(cmdWithPath, ARRAYSIZE(cmdWithPath), cmd,
102+
params->firefoxFolder, params->firefoxProfileFolder);
103103

104104
if (err != -1) {
105105
PROCESS_INFORMATION procFx = {0};
106106
STARTUPINFO startupInfoFx = {0};
107107

108108
#if defined(DEBUG) && defined(NIGHTLY_BUILD)
109-
printf("Starting Firefox via: %s\n", cmdWithPath);
109+
printf("Starting Firefox via: %S\n", cmdWithPath);
110110
#endif
111111

112112
// Start Firefox

gfx/vr/vrhost/vrhosttest.cpp

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ void TestCreateVRWindow() {
264264
char currentDir[MAX_PATH] = {0};
265265
char currentDirProfile[MAX_PATH] = {0};
266266
DWORD currentDirLength =
267-
::GetCurrentDirectory(ARRAYSIZE(currentDir), currentDir);
267+
::GetCurrentDirectoryA(ARRAYSIZE(currentDir), currentDir);
268268
currentDir[currentDirLength] = '\\';
269269

270270
int err = sprintf_s(currentDirProfile, ARRAYSIZE(currentDirProfile),
@@ -286,20 +286,24 @@ void TestCreateVRWindow() {
286286
(void*)fnWaitForVRMsg, 0, &dwTid);
287287

288288
// Wait for Fx to finish launch
289+
#ifdef DEBUG
289290
::Sleep(5000);
291+
#else
292+
::Sleep(2000);
293+
#endif
290294

291295
printf(
292-
"Now, simulating a click on the Home button, which should look "
296+
"1. Simulating a click on the Home button, which should look "
293297
"pressed\n");
294298
POINT pt;
295299
pt.x = 180;
296-
pt.y = 790;
300+
pt.y = 700;
297301
fnSendMsg(windowId, WM_LBUTTONDOWN, 0, POINTTOPOINTS(pt));
298302
::Sleep(3000);
299303
fnSendMsg(windowId, WM_LBUTTONUP, 0, POINTTOPOINTS(pt));
300304

301305
printf(
302-
"Next, simulating hovering across the URL bar, which should turn "
306+
"2. Simulating hovering across the URL bar, which should turn "
303307
"blue\n");
304308
pt.x = 600;
305309
for (int i = 0; i < 100; ++i) {
@@ -309,16 +313,23 @@ void TestCreateVRWindow() {
309313
}
310314

311315
printf(
312-
"Next, simulating clicking inside the URL bar, which should "
316+
"3. Simulating clicking inside the URL bar, which should "
313317
"highlight the text\n");
314318
pt.x = 700;
315-
pt.y = 790;
319+
pt.y = 700;
316320
fnSendMsg(windowId, WM_LBUTTONDOWN, 0, POINTTOPOINTS(pt));
317321
fnSendMsg(windowId, WM_LBUTTONUP, 0, POINTTOPOINTS(pt));
322+
318323
::Sleep(3000);
319324

325+
printf("4. Type some UTF16 characters in the URL bar\n");
326+
fnSendMsg(windowId, WM_CHAR, 0x4E64, 0);
327+
fnSendMsg(windowId, WM_CHAR, 0x312D, 0);
328+
fnSendMsg(windowId, WM_CHAR, 0x0BB9, 0);
329+
fnSendMsg(windowId, WM_CHAR, 0x2745, 0);
330+
320331
printf(
321-
"Finally, simulating clicking outside the URL bar, which should "
332+
"5. Simulating clicking outside the URL bar, which should "
322333
"send a keyboard blur event\n");
323334
pt.x = 80;
324335
fnSendMsg(windowId, WM_LBUTTONDOWN, 0, POINTTOPOINTS(pt));

0 commit comments

Comments
 (0)