diff --git a/Changelog.md b/Changelog.md index 24405f324d..9377a47d38 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,6 +2,7 @@ - Fixes scrolling in alt-screen. - Fixes VT sequence for setting indexed color from palette. +- Fixes `XTSMGRAPHICS` when querying sixel image limits, to be capped at terminal viewport dimensions (#656). - Implements UTF-8 encoded mouse transport (`CSI ? 1005 h`) - Improved vi-like input modes. - Fixed the text cursor not being visible during selection. diff --git a/src/terminal/Screen.cpp b/src/terminal/Screen.cpp index 665420aa6d..949092a24c 100644 --- a/src/terminal/Screen.cpp +++ b/src/terminal/Screen.cpp @@ -1654,13 +1654,11 @@ void Screen::requestPixelSize(RequestPixelSize _area) switch (_area) { case RequestPixelSize::WindowArea: [[fallthrough]]; // TODO - case RequestPixelSize::TextArea: + case RequestPixelSize::TextArea: { // Result is CSI 4 ; height ; width t - _terminal.reply( - "\033[4;{};{}t", - unbox(_state.cellPixelSize.height) * unbox(_state.pageSize.lines), - unbox(_state.cellPixelSize.width) * unbox(_state.pageSize.columns)); + _terminal.reply("\033[4;{};{}t", pixelSize().height, pixelSize().width); break; + } case RequestPixelSize::CellArea: // Result is CSI 6 ; height ; width t _terminal.reply("\033[6;{};{}t", _state.cellPixelSize.height, _state.cellPixelSize.width); @@ -2002,13 +2000,15 @@ void Screen::smGraphics(XtSmGraphics::Item _item, case Item::SixelGraphicsGeometry: switch (_action) { - case Action::Read: + case Action::Read: { + auto const viewportSize = pixelSize(); _terminal.reply("\033[?{};{};{};{}S", SixelItem, Success, - _state.maxImageSize.width, - _state.maxImageSize.height); - break; + min(viewportSize.width, _state.maxImageSize.width), + min(viewportSize.height, _state.maxImageSize.height)); + } + break; case Action::ReadLimit: _terminal.reply("\033[?{};{};{};{}S", SixelItem, diff --git a/src/terminal/Screen.h b/src/terminal/Screen.h index 2a12233197..6aaf26acaf 100644 --- a/src/terminal/Screen.h +++ b/src/terminal/Screen.h @@ -254,6 +254,7 @@ class Screen: public ScreenBase, public capabilities::StaticDatabase void requestDECMode(unsigned int _mode); [[nodiscard]] PageSize pageSize() const noexcept { return _state.pageSize; } + [[nodiscard]] ImageSize pixelSize() const noexcept { return _state.cellPixelSize * _state.pageSize; } constexpr CellLocation realCursorPosition() const noexcept { return _state.cursor.position; }