Skip to content
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

fixing: Use Unicode version of WndProc to get correct input under Windows UTF-8 code page. #7174

Closed
wants to merge 2 commits into from

Conversation

kimidaisuki22
Copy link
Contributor

default code page.
default-code-page
UTF-8 code page
under-utf-8

UTF-8 manifest file: (need Windows 10 1903 or newer)

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
  <assemblyIdentity type="win32" name="..." version="6.0.0.0"/>
  <application>
    <windowsSettings>
      <activeCodePage xmlns="http://schemas.microsoft.com/SMI/2019/WindowsSettings">UTF-8</activeCodePage>
    </windowsSettings>
  </application>
</assembly>

@PathogenDavid
Copy link
Contributor

These two should be changed to explicit W as well:

::SetWindowLongPtr((HWND)main_viewport->PlatformHandleRaw, GWLP_WNDPROC, (LONG_PTR)bd->GlfwWndProc);

return ::CallWindowProc(bd->GlfwWndProc, hWnd, msg, wParam, lParam);

(I'm actually surprised your fix works without the last one.)

Since GLFW explicitly uses W functions, we should do so as well since using A functions with resources associated with a W window class can be problematic. (Ideally we'd just #define UNICODE in this file, but that'd cause issues for unity builds.)

@kimidaisuki22
Copy link
Contributor Author

These two should be changed to explicit W as well:

::SetWindowLongPtr((HWND)main_viewport->PlatformHandleRaw, GWLP_WNDPROC, (LONG_PTR)bd->GlfwWndProc);

return ::CallWindowProc(bd->GlfwWndProc, hWnd, msg, wParam, lParam);

(I'm actually surprised your fix works without the last one.)

Since GLFW explicitly uses W functions, we should do so as well since using A functions with resources associated with a W window class can be problematic. (Ideally we'd just #define UNICODE in this file, but that'd cause issues for unity builds.)

msg, wParam and lParam are from the Unicode version, so the problem is solved even CallWindowProcA is called here.

Thank you, I changed them to the 'W' version.

ocornut pushed a commit that referenced this pull request Dec 29, 2023
… input for text in utf-8 code page. (#7174)

Similar to #6785, #6782, #5725, #5961 for for GLFW backend.
@ocornut
Copy link
Owner

ocornut commented Dec 29, 2023

Merged as 240ab58, thank you very much !

@ocornut ocornut closed this Dec 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants