Commit Graph

2894 Commits

Author SHA1 Message Date
Daijiro Fukuda
0ba4b36557 Add caret position to preedit-callback
- Win32: This works fine.
- macOS: The caret is always at the last of the preedit text.
- X11:
  - over-the-spot: The callback is not used.
  - on-the-spot: In IBus, the caret is always at the last of the preedit
    text, although the actual position can be changed. On-the-spot on X11
    has many other unstable behaviors, so allow this problem for now.
2022-05-30 14:42:41 +09:00
Takuro Ashie
7563d1bce0 Win32: Include imm.h to support input methods 2022-05-24 15:48:20 +09:00
Takuro Ashie
0f8780dcc0 Fix indent 2022-05-24 14:20:47 +09:00
Daijiro Fukuda
6ec3c85aee Fix preeditCusorPos init timing to align with other parameters 2022-05-24 14:19:06 +09:00
Daijiro Fukuda
bf4d8aec54 Remove needless diffs 2022-05-24 14:14:57 +09:00
Takuro Ashie
b061c0fabc Remove needless spaces 2022-05-24 14:14:57 +09:00
Daijiro Fukuda
0759632788 Win32: Revert an unneeded fix
This fix is not needed.

https://docs.microsoft.com/en-us/windows/win32/inputdev/wm-unichar
> An application should return zero if it processes this message.
2022-05-24 14:14:57 +09:00
Daijiro Fukuda
52f0ca1ab6 Add comments and reshape codes 2022-05-24 14:14:57 +09:00
Daijiro Fukuda
89c7e252f9 Win32: Use GLFWbool 2022-05-24 14:14:57 +09:00
Daijiro Fukuda
dc953898cc X11: Use GLFW_X11_ONTHESPOT of glfwInitHint to change on-the-spot
GLFW has the function `glfwInitHint` for setting initialization parameters.
So use this instead of environmental variable.
2022-05-24 14:14:57 +09:00
Daijiro Fukuda
6c6f5d712f Windows: Use UTF-32 for preedit text encoding
The char stream of GLFW API must be UTF-32.
2022-05-24 14:14:57 +09:00
Daijiro Fukuda
68c977ee4d macOS: Use UTF-32 for preedit text encoding
The char stream of GLFW API must be UTF-32.
2022-05-24 14:14:57 +09:00
Daijiro Fukuda
dcfde1a0db macOS: Suppress _glfwInputKey during preediting
During preediting, the following keys

- arrow keys
- enter key
- backspace key
- ...

should not be passed to an application.
2022-05-24 14:14:57 +09:00
Daijiro Fukuda
1c7e52faf8 Enable glfwSetPreeditCursorPos API to apply the change immediately
In Windows and X11, the changes were applied at the time of the preedit
callback. This has been removed and make them applied immediately.

In macOS, the position callback is provided, so do nothing and leave
this to it.
2022-05-24 14:14:57 +09:00
Daijiro Fukuda
09d51dcd84 Move new platform APIs to _GLFWplatform
The following APIs should be generalized to _GLFWplatform.

* _glfwPlatformResetPreeditText
* _glfwPlatformSetIMEStatus
* _glfwPlatformGetIMEStatus
2022-05-24 14:14:57 +09:00
Daijiro Fukuda
86b2c3b579 macOS: Enable to clear preedit after commit input. 2022-05-24 14:14:57 +09:00
Daijiro Fukuda
c2923ac577 macOS: Apply preeditCursor to position of candidate window 2022-05-24 14:14:57 +09:00
Daijiro Fukuda
2e976c01ed macOS: Fix coding style
* brace position
* space
* length of one line
2022-05-24 14:14:57 +09:00
Daijiro Fukuda
28ea48ea38 X11: Change default style to over-the-spot
In over-the-spot mode, almost all APIs are disabled.
Applications only need to specify the candidate window position by
`glfwSetPreeditCursorPos`.

We can change style to on-the-spot by setting "on-the-spot" to the
environmental variable `IM_STYLE`.

However on-the-spot mode of X11 has the following problems:

* Status APIs don't work because status callbacks don't work
  (at least in my ibus environment)
* Can't specify the candidate window position
2022-05-24 14:14:57 +09:00
Takuro Ashie
a5a3cbe5c0 X11: Fix coding style 2022-05-24 14:14:57 +09:00
Daijiro Fukuda
3ad6cd187d X11: Fix transplanting oversight
There was a oversight in transplanting shibukawa's fix:
* https://github.com/glfw/glfw/pull/658
* d36a164423

This made preedit callbacks not being called.
2022-05-24 14:14:57 +09:00
Daijiro Fukuda
59e192be6d Win32: Use dynamic load for imm32 2022-05-24 14:14:57 +09:00
Daijiro Fukuda
15a64185b0 Win32: Rename commit function
The data to commit is a result-string rather than preedit.
2022-05-24 14:14:57 +09:00
Daijiro Fukuda
4cdabc29f2 Win32: Add preedit commit logic
Make committed preedit data output to `character` callback,
which is set at `glfwSetCharCallback`.
2022-05-24 14:14:57 +09:00
Takuro Ashie
9b22e781ca Win32: Remove needless cast 2022-05-24 14:14:57 +09:00
Takuro Ashie
b9223f114d Win32: Plug potential memory leaks 2022-05-24 14:14:57 +09:00
Takuro Ashie
3e99fcc865 Win32: Cosmetic changes
* Remove a needless local variable
* Shorten long lines
2022-05-24 14:14:57 +09:00
Takuro Ashie
4fd32183f8 Win32: Extract retrieving preedit text as a function 2022-05-24 14:14:57 +09:00
Takuro Ashie
3a4d7eb85a Win32: Use ImmGetCompositionStringW() explicitly
ImmGetCompositionString() is ambiguous.
2022-05-24 14:14:57 +09:00
Takuro Ashie
599a1a98ec Win32: Fix style
* Remove needless braces
* Add spaces
* Use C89 style variable declarations
2022-05-24 14:14:57 +09:00
Takuro Ashie
169da05c53 Fix too long buffer for ImmGetCompositionStringW()
It return's byte size, not string length. So that multiplying by
sizeof(WCHAR) isn't needed.
2022-05-24 14:14:57 +09:00
Daijiro Fukuda
ffce1503cc Apply sibukawa's fix of GLFW for MacOS
This fix is based on shibukawa's fix:
  https://github.com/glfw/glfw/pull/658
  d36a164423
2022-05-24 14:14:57 +09:00
Takuro Ashie
8a02ec2702 X11: Revive inputContextDestroyCallback()
XCreateIC() has vararg so that both XNStatusAttributes and
XNDestroyCallback are acceptable.
2022-05-24 14:14:57 +09:00
Takuro Ashie
2130afeb02 Win32: Fix coding style
* brace position
* add missing spaces
2022-05-24 14:14:57 +09:00
Takuro Ashie
e4c4c7343c Win32: Plug potential memory leaks 2022-05-24 14:14:57 +09:00
Takuro Ashie
d97e954aa3 Win32: Link imm32 on building examples and tests 2022-05-24 14:14:57 +09:00
Takuro Ashie
d808d1d274 Load missing XIM related function symbols
* XSetICValues
* XVaCreateNestedList
* XmbResetIC
2022-05-24 14:14:57 +09:00
daipom
a2c18d6c2f Apply shibukawa's fix of GLFW for X11
This fix is based on shibukawa's fix:
  https://github.com/glfw/glfw/pull/658

The differences is the following.

* Remove `X_HAVE_UTF8_STRING` branching since the current logic doesn't use it
* Replace `XNDestroyCallback` for `XNPreeditAttributes` in `XCreateIC`
2022-05-24 14:14:57 +09:00
daipom
fad44068e5 Apply shibukawa's fix of GLFW for Windows
This fix is based on shibukawa's fix:
  https://github.com/glfw/glfw/pull/658
  d36a164423

Some minor coding style changes are made, but not yet follow glfw's one,
and some comments doesn't follow recent changes. So further work is
needed.
2022-05-24 14:14:57 +09:00
Camilla Löwy
62e175ef9f Win32: Add comment clarifying use of ToUnicode
Fixes #2100
2022-05-06 19:19:25 +02:00
Camilla Löwy
7dfd84c458 Win32: Make monitor area retrieval more consistent
The rest of this file uses GetMonitorInfoW to retrieve this information.
2022-04-28 21:58:44 +02:00
Camilla Löwy
09653b8c54 Move last bits of window setup to platform code
This avoids glfwCreateWindow emitting GLFW_FEATURE_UNAVAILABLE or
GLFW_FEATURE_UNIMPLEMENTED on Wayland because shared code was calling
unimplemented or unavailable platform functions during final setup.

It also makes it consistent with the final setup of full screen windows.
2022-04-28 21:58:06 +02:00
Camilla Löwy
72642ea0d1 Simplify struct stitching for sync primitives
There will not currently be more than one set of threading or timer APIs
selected regardless of how many window systems are enabled, so there is
no need for this extra complexity.
2022-04-28 21:54:25 +02:00
Camilla Löwy
8f050b5655 Wayland: Add support for older wayland-scanner
Versions of wayland-scanner prior to 1.17.91 named every global array of
wl_interface pointers 'types', making it impossible to combine several
unmodified private-code files into a single compilation unit.

This overrides that name with a macro for each file, allowing them to
coexist.

Fixes #2016
Closes #2032
2022-04-28 21:54:24 +02:00
Camilla Löwy
acf0c10e7a Win32: Fix message reported by VS 2022 2022-04-28 21:54:24 +02:00
Camilla Löwy
80e31ce9e1 Win32: Remove superfluous cast 2022-04-28 21:54:24 +02:00
Camilla Löwy
23e6e8e4b7 X11: Fix segfault on malformed INCR response
The code assumed that at least some data would be received via the INCR
mechanism and that, as a result, the string buffer would be allocated.

Bug found by Clang static analysis.
2022-04-28 21:19:08 +02:00
Camilla Löwy
f60547ac80 X11: Fix returned clipboard string freed too early
The clipboard string should not be freed on SelectionClear.  The user
may have received it from glfwGetClipboardString and it should remain
valid until the next call to a public clipboard string function.
2022-04-28 21:18:49 +02:00
Camilla Löwy
a8d8b760fb X11: Fix OSMesa library not being unloaded 2022-04-28 21:17:39 +02:00
Camilla Löwy
2d281d7928 Wayland: Fix OSMesa library not being unloaded 2022-04-28 21:16:06 +02:00