Blame SOURCES/0037-Update-the-preedit-styling-mapping.patch

869fe3
From 3ddd4dcb1790920ce2598ebdbe14c95bdba55005 Mon Sep 17 00:00:00 2001
9fb289
From: Weng Xuetian <wengxt@gmail.com>
9fb289
Date: Wed, 22 Dec 2021 10:42:38 -0800
869fe3
Subject: [PATCH 37/40] Update the preedit styling mapping
9fb289
9fb289
- None mapping to no style.
9fb289
- Default/Underline mapping to underline.
9fb289
- Highlight/Selection mapping to background color/text color with highlight/highlight
9fb289
text with underline.
9fb289
- Active/Inactive mapping to bold text with underline.
9fb289
- Incorrect mapping to red wave underline.
9fb289
9fb289
Pick-to: 5.15 6.2 6.3
9fb289
Change-Id: Iab51d671b8f83aece8596f7f7610de19343fcceb
9fb289
Reviewed-by: Aleix Pol Gonzalez <aleixpol@kde.org>
9fb289
(cherry picked from commit f1fb5d9e568a24e213ee41e82a1142cef56f1098)
9fb289
---
9fb289
 .../qwaylandinputmethodeventbuilder.cpp       | 31 ++++++++++++-------
9fb289
 1 file changed, 20 insertions(+), 11 deletions(-)
9fb289
9fb289
diff --git a/src/shared/qwaylandinputmethodeventbuilder.cpp b/src/shared/qwaylandinputmethodeventbuilder.cpp
9fb289
index 458d818e..f50ccf30 100644
9fb289
--- a/src/shared/qwaylandinputmethodeventbuilder.cpp
9fb289
+++ b/src/shared/qwaylandinputmethodeventbuilder.cpp
9fb289
@@ -39,7 +39,10 @@
9fb289
 
9fb289
 #include "qwaylandinputmethodeventbuilder_p.h"
9fb289
 
9fb289
+#include <QBrush>
9fb289
+#include <QGuiApplication>
9fb289
 #include <QInputMethod>
9fb289
+#include <QPalette>
9fb289
 #include <QTextCharFormat>
9fb289
 
9fb289
 #ifdef QT_BUILD_WAYLANDCOMPOSITOR_LIB
9fb289
@@ -81,32 +84,38 @@ void QWaylandInputMethodEventBuilder::addPreeditStyling(uint32_t index, uint32_t
9fb289
     QTextCharFormat format;
9fb289
 
9fb289
     switch (style) {
9fb289
-    case 0:
9fb289
-    case 1:
9fb289
+    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_NONE:
9fb289
+        break;
9fb289
+    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_DEFAULT:
9fb289
+    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_UNDERLINE:
9fb289
         format.setFontUnderline(true);
9fb289
         format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
9fb289
         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
9fb289
         break;
9fb289
-    case 2:
9fb289
-    case 3:
9fb289
+    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_ACTIVE:
9fb289
+    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INACTIVE:
9fb289
         format.setFontWeight(QFont::Bold);
9fb289
         format.setFontUnderline(true);
9fb289
         format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
9fb289
         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
9fb289
         break;
9fb289
-    case 4:
9fb289
-        format.setFontUnderline(true);
9fb289
-        format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
9fb289
-        m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
9fb289
+    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_HIGHLIGHT:
9fb289
+    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_SELECTION:
9fb289
+        {
9fb289
+            format.setFontUnderline(true);
9fb289
+            format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
9fb289
+            QPalette palette = qApp->palette();
9fb289
+            format.setBackground(QBrush(palette.color(QPalette::Active, QPalette::Highlight)));
9fb289
+            format.setForeground(QBrush(palette.color(QPalette::Active, QPalette::HighlightedText)));
9fb289
+            m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
9fb289
+        }
9fb289
         break;
9fb289
-    case 5:
9fb289
+    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INCORRECT:
9fb289
         format.setFontUnderline(true);
9fb289
         format.setUnderlineStyle(QTextCharFormat::WaveUnderline);
9fb289
         format.setUnderlineColor(QColor(Qt::red));
9fb289
         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
9fb289
         break;
9fb289
-//    case QtWayland::wl_text_input::preedit_style_selection:
9fb289
-//    case QtWayland::wl_text_input::preedit_style_none:
9fb289
     default:
9fb289
         break;
9fb289
     }
9fb289
-- 
9fb289
2.35.1
9fb289