Window: Major crash fix. (#1021)

A patch handling focus was recently merged, but a special condition on
Windows was inverted, causing a segfault.

Bug:https://github.com/ArthurSonzogni/FTXUI/issues/1020
This commit is contained in:
Arthur Sonzogni 2025-03-29 12:51:08 +01:00 committed by GitHub
parent ee24bec3ba
commit 4ba7dd2c5e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 28 additions and 21 deletions

View File

@ -104,7 +104,7 @@ jobs:
--gcov-executable '${{ matrix.gcov_executable }}';
- name: Windows - Test and coverage
if: runner.os == 'Windows' && false
if: runner.os == 'Windows'
working-directory: ./build
run: >
OpenCppCoverage.exe

View File

@ -1,6 +1,13 @@
Changelog
=========
Unreleased
-----
### Component
- BugFix: Fix major crash on Windows affecting all components. See #1020
- BugFix: Fix focusRelative.
6.0.1 (2025-03-28)
-----

View File

@ -36,7 +36,7 @@ Decorator focusPositionRelative(float x, float y) {
void ComputeRequirement() override {
NodeDecorator::ComputeRequirement();
requirement_.focused.enabled = false;
requirement_.focused.enabled = true;
requirement_.focused.node = this;
requirement_.focused.box.x_min = int(float(requirement_.min_x) * x_);
requirement_.focused.box.y_min = int(float(requirement_.min_y) * y_);

View File

@ -125,6 +125,8 @@ void Render(Screen& screen, Node* node, Selection& selection) {
node->Select(selection);
}
if (node->requirement().focused.enabled
#if defined(FTXUI_MICROSOFT_TERMINAL_FALLBACK)
// Setting the cursor to the right position allow folks using CJK (China,
// Japanese, Korean, ...) characters to see their [input method editor]
// displayed at the right location. See [issue].
@ -136,16 +138,14 @@ void Render(Screen& screen, Node* node, Selection& selection) {
// https://github.com/ArthurSonzogni/FTXUI/issues/2#issuecomment-505282355
//
// Unfortunately, Microsoft terminal do not handle properly hiding the
// cursor. Instead the character under the cursor is hidden, which is a big
// problem. As a result, we can't enable setting cursor to the right
// cursor. Instead the character under the cursor is hidden, which is a
// big problem. As a result, we can't enable setting cursor to the right
// location. It will be displayed at the bottom right corner.
// See:
// https://github.com/microsoft/terminal/issues/1203
// https://github.com/microsoft/terminal/issues/3093
if (node->requirement().focused.enabled
#if defined(FTXUI_MICROSOFT_TERMINAL_FALLBACK)
||
node->requirement().focused.cursor_shape == Screen::Cursor::Shape::Hidden
&&
!node->requirement().focused.cursor_shape == Screen::Cursor::Shape::Hidden
#endif
) {
screen.SetCursor(Screen::Cursor{