Commit graph

297 commits

Author SHA1 Message Date
Marc Durdin
e664e93de7 fix(windows): Improve refresh reliablilty
This change has three fixes to improve the reliability of notifying
Keyman Engine of updates to settings or keyboard installs:

1. It removes the closure pattern of the refresh thread, because that
   was closing on a variable on a different thread (`RefreshHandle`) and
   that could cause races and/or exceptions in the case of early free.
   What's more, the closure was actually unnecessary as the variable was
   really only used by the refresh thread!

2. It moves responsibility for setting the refresh token to the calling
   thread so that the caller can depend on the token being the one that
   is actually sent, removing a race.

3. Most important, the refresh thread now flushes all messages in its
   queue, as there may be multiple messages relating to the window
   construction that need to be processed before the wm_keyman_refresh
   message can be handled. This greatly improves the chance of the
   notification actually being sent!
2020-12-18 08:06:03 +11:00
Marc Durdin
b561dc4721 fix(windows): Use timer-approach to refresh
Another thought: we could also try refreshing every 125msec for 5
seconds after the first change is detected. It's a bit yuck perf-wise
but would probably be pretty transparent to the user.

In testing, this looks good. It means the changes appear as soon as
ready, without substantial delays or performance issues. Polling this
makes me feel a bit dirty, but I'll just take a shower and be okay.
2020-12-17 13:43:31 +11:00
Marc Durdin
f6872e7919 fix(windows): OSK toolbar sync
As Keyman now monitors the Windows keyboard list from Control Panel, it
is no longer sufficient to refresh the toolbar only when a Keyman
keyboard is updated, as at that point Windows has not refreshed its own
language list in the registry. Instead, we need to monitor changes to
the relevant registry key and then refresh when those changes are
'complete'.

There is a problem: there does not appear to be a good way to monitor
for changes to Windows language settings. WM_SETTINGCHANGE is sent when
a language is added by the user in Settings, but the actual change
happens asynchronously, and we are not notified when the changes are
complete.

We also do not get notifications when languages are added via APIs.

Given the async nature of the language profile changes, this leads to
race conditions when we try to refresh the OSK toolbar. My preferred
solution currently is to monitor the relevant key in a separate thread,
and wait 1 second post-changes to actually do the refresh.
2020-12-17 13:23:05 +11:00
Marc Durdin
f73b2912ef fix(windows): exception handling list error
Fixes #4006.

This fixes the list error exception which was masking the actual cause
of #4006, which is already fixed by #4164.

Related issue #4119 is also fixed by #4164.
2020-12-17 11:54:39 +11:00
Marc Durdin
15d2182255 fix(windows): maintain use of refreshtag 2020-12-17 11:19:13 +11:00
Marc Durdin
cea564a072 fix(windows): Improve refresh performance
When a keyboard is installed, Keyman will now only refresh its internal
state on a given thread when that thread receives focus and/or input,
rather than immediately. This will dramatically reduce the chatter
caused by Keyman Engine when a keyboard is installed or settings are
changed.
2020-12-17 11:13:18 +11:00
Marc Durdin
17b444bff2 fix(windows): Settings refresh management
Fixes #4011.
Fixes #4039.
Fixes #4121.

This change completes the immediate-change model for Keyman
Configuration, by refactoring the refresh of settings out of the render
phase and more appropriately splitting applying and refreshing. It adds
a new message flag for wm_keyman_refresh, KR_SETTINGS_CHANGED, which
uses a random token approach broadcast to all applications on the
desktop to ensure that the refresh is received and multiple
notifications for the same event can be appropriately coalesced.

Most of the files touched are stripping out the refresh flags from the
render phase.

There is one small bug resolved at the same time with the options
properties, which were not reset to default if they had been deleted
from the registry prior to a refresh (see utilkeymanoption.pas).
2020-12-17 10:50:21 +11:00
Marc Durdin
64d618cb58
Merge branch 'beta' into fix/windows/3749-3759-max-transient-languages 2020-12-16 09:32:00 +11:00
Marc Durdin
246cb70840 fix(windows): Warn if we reach maximum transient languages
Fixes #3749.
Fixes #3759.

Adds a warning dialog when user attempts to add a transient language to
a keyboard but the maximum number of transient languages is already
installed.

If this issue arises when a user is installing a keyboard for the first
time, Keyman instead installs the keyboard for the user's default
language. This may be a little confusing, but the error condition is
difficult to explain and non-technical users will probably be stuck
and need to install under their default language in any case. Happy to
receive any pushback on this decision.
2020-12-16 09:09:19 +11:00
Marc Durdin
ad932cdb74 fix(windows): menu scroll positions need reset at popup
Fixes #4012.

If the menu previously was scrollable, then it would potentially show
items at the wrong offset because the offsets were not reset when the
menu popup was called if no scroll was needed.
2020-12-15 11:46:30 +11:00
Marc Durdin
80d8169a4e fix(windows): glitch in keyboard menu
Fixes #4112.

Glitch in keyboard menu from scrollable buttons being drawn at top-left.
2020-12-15 11:44:59 +11:00
Marc Durdin
9e46b555d9 fix(windows): Rename to Keyman
Fixes #4003.

This addresses the majority of locations where we use the name "Keyman
Desktop" in code. There will be some filenames and paths that do not
change at this point -- particularly at a source level. For now, the
focus is on the user interface changes.

While making these changes, I also made the VERSION and MANIFEST
resources more consistent.
2020-12-02 09:56:14 +11:00
Marc Durdin
7ccde0e3ed chore(windows): disable Sentry 'Started' event
We used the 'Started' event when testing Sentry integration. We no
longer need it, but I left it in as commented code so we can re-enable
if/when we do Sentry updates in the future and need to re-test.
2020-12-01 10:45:22 +11:00
Marc Durdin
bbfe5adcc8 fix(windows): crash with package online update
Fixes #4005.

The wrong object was being freed which caused an access violation
internally.
2020-12-01 10:15:05 +11:00
Marc Durdin
79cd83e105 chore(windows): fixup makefiles 2020-11-11 10:33:18 +11:00
Marc Durdin
00a9744253 chore(windows): symbol server support, initial steps 2020-11-11 10:33:16 +11:00
Marc Durdin
3d1601ffe5 fix(windows): SizeOfImage header was wrong for dbg
Fixes #3831.

This fixes both issues reported in the bug (dproj changes ensure
separate .tds, and Makefile changes fix order of execution so that
dbg is generated after sentryprep's cleanup).
2020-11-06 17:36:56 +11:00
Marc Durdin
94a062f20a fix(developer): remove obsolete NRSIAllTags
Relates to #799.

Removes NRSIAllTags, alltags.txt, parser and utility units.

Also re-enables standardsdata.dpr unit test which needed some syntax
cleanup.
2020-11-04 18:41:17 +11:00
Marc Durdin
fd5845a912
Merge pull request #3805 from keymanapp/fix/windows/3801-crash-installing-malformed-package
fix(windows): crash installing package with a race
2020-10-30 17:31:23 +11:00
Marc Durdin
76f77857c5 fix(windows): crash installing package with a race
Fixes #3801.
Fixes #3802.
Fixes KEYMAN-WINDOWS-5M.
Fixes KEYMAN-WINDOWS-5N.

This is a two-part fix for Keyman Configuration where it appears there
was a race with creating a temporary file, and which caused a cascading
exception.

The first part resolves the race; the second part (in
UfrmInstallKeyboard.pas) adds a little extra robustness (probably not
totally necessary).
2020-10-30 16:52:17 +11:00
Marc Durdin
99e44d030a fix(windows): keyboard menu could get out of sync
Fixes #3725.
Fixed #3783.

In some situations, the keyboard menu would either display empty or
would not refresh to get all installed keyboards.
2020-10-30 14:22:20 +11:00
Marc Durdin
5a4287a68d fix(windows): disabling/enabling a profile could have wrong association
Transient language profiles would get the wrong language association
when they were disabled and re-enabled.

Fixes #3798.
2020-10-30 14:20:00 +11:00
Marc Durdin
4b970fefbf
Merge pull request #3779 from keymanapp/fix/windows/3650-remove-msctf-dllmain-free
fix(windows): remove msctf free from DllMain
2020-10-29 06:43:49 +11:00
Marc Durdin
3178495e58
Merge pull request #3772 from keymanapp/fix/windows/3562-start-keyman-on-demand-keyman32
fix(windows): Start Keyman on Demand - keyman32
2020-10-29 06:43:42 +11:00
Marc Durdin
fc7b51c4ca fix(windows): remove msctf free from DllMain
Fixes #3650.

This removes the bad call to `FreeLibrary` that was still present in
a callee of `DllMain` in keyman32. The refactor moves responsibility for
loading TSF to the `SelectKeyboard` functions and gets rid of the
associated thread globals.

The `TSFINTERFACES` struct is of course a future candidate for a class.

In the process I removed a lot of cruft from keyman32.cpp which was
either obsolete, irrelevant or just plain wrong. None of which had
material impact on the running code.
2020-10-28 16:17:52 +11:00
Marc Durdin
3e9f397b27 chore(windows): small cleanups
1. Remove unused variables
2. Remove invalid build configurations
3. Move hotkey checks before touch keyboard panel check, so hotkeys
   still work when touch panel is active; the touch keyboard panel check
   is there to disable serialised input which conflicts with it.
2020-10-28 10:27:24 +11:00
Marc Durdin
c66eb49163 fix(windows): Start Keyman on Demand - keyman32
This is the first half of a two-part update to Keyman for Windows. There
are two significant changes here. These changes apply to
keyman32/keyman64, as well as kmtip/kmtip64, but will refer to the
32-bit equivalents for simplicity:

1. Instead of using `GetProcAddress` to connect to keyman32.dll, we
   now have an import library connection. This removes one particularly
   suspect piece of architecture for Keyman, as using `GetProcAddress`
   could lead to a race condition, where keyman32.dll is unloaded after
   that function is called but before we use the handle. This makes the
   kmtip.dll build dependent on keyman32.dll; loading kmtip.dll (by
   selecting a Keyman input method) also loads keyman32.dll.

2. It's not enough (yet) to load kmtip.dll. We also need to be running
   keyman.exe itself, due to global hooks that we still require (it may
   be possible, one day, to avoid these, but it doesn't look very
   hopeful). To that end, kmtip calls new function `TIPIsKeymanRunning`
   to check whether keyman32.dll is initialised (and hence keyman.exe
   has initialised it). Then, if keyman.exe is not running, it issues an
   event to the Windows Event Log, which we will pick up with a
   scheduled task in the next PR.

The first part of this is an architectural change which may lead to some
change in behaviours, as keyman32.dll now may not be unloaded from a
process when keyman.exe exits, due to the lock that kmtip.dll now has on
it. It will be important to test this (@MakaraSok) by running through
various startup and shutdown scenarios. In my initial testing, I found
that there were some situations after restarting keyman.exe where I
needed to switch in and out of the Keyman TIP, but those were not all
critical.

This change also lays groundwork for an eventual ability to run the
Keyman input method without keyman.exe running, which will be helpful
e.g. on login screen, even if missing certain additional functionality
such as the serialised input queue.
2020-10-28 06:10:22 +11:00
Marc Durdin
7a722639bb
Merge pull request #3753 from keymanapp/fix/windows/3518-config-auto-apply
fix(windows): Keyman Configuration changes apply instantly
2020-10-27 13:07:26 +11:00
Marc Durdin
79b41d0627
Merge pull request #3754 from keymanapp/fix/windows/remove-double-refresh
fix(windows): Remove double refresh
2020-10-27 10:38:25 +11:00
Marc Durdin
4269a4dbc4 fix(windows): Remove double refresh
Both the win32 and the win64 keyman engine libraries would receive a
refresh notification, and then they'd both broadcast the change. This
change limits the broadcast responsibility to the 32-bit engine.
2020-10-26 15:26:08 +11:00
Marc Durdin
11a2cf53c5 fix(windows): Keyman Configuration changes apply instantly
Fixes #3518.

Changes in Keyman Configuration will now apply immediately. This removes
the OK and Cancel buttons from the dialog and means that all actions
are consistent in when they are applied, unlike previously. This also
matches the Windows 10 Settings metaphor and metaphors for most modern
apps and devices.

For now, I have placed a message where the OK and Buttons were
previously, to help existing users understand the change. In time, I
expect us to be able to remove that message entirely.
2020-10-26 15:18:04 +11:00
Marc Durdin
82e15bead0 fix(windows): remove obsolete Reboot flag
The Reboot flag was never set by any Keyman code any longer. Thus,
removing to simplify code pathways for applying config changes.
2020-10-26 09:10:02 +11:00
Marc Durdin
0ab49191d8 fix(windows): buffer overrun in debug function 2020-10-24 14:46:19 +11:00
Marc Durdin
2da01e2210
Merge pull request #3727 from keymanapp/fix/windows/tsysinfo-clearer-upload-failure
fix(windows): improve tsysinfo upload messages
2020-10-22 14:49:24 +11:00
Marc Durdin
3d324b20aa
Merge pull request #3719 from keymanapp/fix/windows/3694-tweak-scrolling-in-keyboard-menu
fix(windows): tweak scrolling in keyboard menu
2020-10-20 18:31:21 +11:00
Marc Durdin
9ab40d9b48 fix(windows): improve tsysinfo upload messages
If tsysinfo fails to upload a diagnostic report, give more detail on
what happened.
2020-10-20 18:18:57 +11:00
Marc Durdin
929e32601c chore(windows): remove debug code 2020-10-19 16:33:59 +11:00
Marc Durdin
3935699262 fix(windows): tweak scrolling in keyboard menu
Fixes #3694.

The keyboard menu would sometimes scroll too far, which could be
confusing for the end user. This fix stops the scroll once the last
item is in view; it also tweaks the down arrow key handler to ensure
that the current item is correctly scrolled into view.
2020-10-19 16:31:08 +11:00
Marc Durdin
bc7b667f4d fix(windows): RefreshKeyboards loses some profiles
When loading transient language profiles, RefreshKeyboards would reset
the list of profiles (and in so doing, also leak memory). Instead, the
list should be cleared before the initial language profile list load.
2020-10-19 08:38:25 +11:00
Marc Durdin
3edec559ec fix(windows): disabled keyboards listed in hotkeys
Fixes #2942.
2020-10-09 11:13:11 +11:00
Marc Durdin
3c32267a50 chore: don't add tag to version in filenames
While it might be nice to add the tag to versions in filenames, this
creates a lot of work on the website where we make some filename
assumptions. So, this PR winds that detail of filename changes back,
and renames copydev.in to download.in to make it consistent with the
other download.in files.
2020-10-08 14:59:59 +11:00
Marc Durdin
facf94df26 chore: address review comments 2020-10-08 13:59:16 +11:00
Marc Durdin
c655c4eaf5 fix(windows): improve version numbers
Release build executables should have 3 component version numbers with
the version tag appended, e.g. keymandesktop-14.0.155-alpha-local.exe.

Coming later, rename keymandesktop-version.exe to keyman-version.exe.
2020-10-08 09:13:48 +11:00
Marc Durdin
f3d5fcbb28
Merge pull request #3668 from keymanapp/fix/windows/cherry-pick/3665-metro-apps-compat
fix(windows): Some registry keys could have incorrect permissions 🍒
2020-10-08 06:20:59 +11:00
Marc Durdin
258e4b4eff fix(windows): Some registry keys could have incorrect permissions
Fixes #3665.

On some systems, subkeys of HKCU\Software\Keyman could have incorrect
permissions and these would not be corrected with earlier fixes such as
in #2316. This fix resolves the problem by recursively correcting
permissions on all subkeys, rather than just the top two levels.

This issue caused Metro-style applications (Windows Store apps) to fail
to accept Keyman keyboard input.
2020-10-07 11:50:37 +11:00
Marc Durdin
53a197fba5 chore(windows): Move to Windows SDK 10.0.17763.0
This removes the requirement for the Windows 8.1 SDK.
2020-10-05 14:11:34 +11:00
Marc Durdin
0275f13e6c
Merge pull request #3649 from keymanapp/fix/engine/coverity-keyman32
fix(windows): coverity reports for keyman32
2020-10-05 13:47:08 +11:00
Marc Durdin
1d4307b2e9
Merge pull request #3642 from keymanapp/fix/engine/coverity-kmtip
fix(windows): coverity reports for kmtip
2020-10-05 13:46:59 +11:00
Marc Durdin
c83eb6f727
Merge pull request #3641 from keymanapp/fix/engine/coverity-mcompile
fix(windows): coverity reports for mcompile
2020-10-05 13:46:49 +11:00
Marc Durdin
7f70c14b2a fix(windows): Cast HANDLE types using PtrToInt 2020-10-05 09:30:55 +11:00