Browse Source

add needed patches

Noah Vogt 1 year ago
parent
commit
b839328bf7

+ 65 - 0
0001-adjust-buffer-format-order.patch

@@ -0,0 +1,65 @@
+From 44a44adecbc97242371cf67f8bbd5553c95fa123 Mon Sep 17 00:00:00 2001
+From: Yaowei Zhou <yaowei.zhou@intel.com>
+Date: Wed, 18 Jan 2023 17:00:50 +0800
+Subject: [PATCH] Adjust the order of wayland drm and zwp dma buf in WaylandBufferFactory
+
+Adjust the order as buffer format implementation of zwp dma buffer from
+Mutter, which will cause inconsistent with gbm support format list of
+GPU process.
+
+Bug: N/A
+Change-Id: Ice63c52fbd6eff0a099c35c0943e24c1fd1a1d70
+---
+
+diff --git a/ui/ozone/platform/wayland/host/wayland_buffer_factory.cc b/ui/ozone/platform/wayland/host/wayland_buffer_factory.cc
+index 2376d77..7d6c032e 100644
+--- a/ui/ozone/platform/wayland/host/wayland_buffer_factory.cc
++++ b/ui/ozone/platform/wayland/host/wayland_buffer_factory.cc
+@@ -25,13 +25,13 @@
+     uint32_t planes_count,
+     wl::OnRequestBufferCallback callback) const {
+   DCHECK(SupportsDmabuf());
+-  if (wayland_zwp_dmabuf_) {
++  if (wayland_drm_) {
++    wayland_drm_->CreateBuffer(fd, size, strides, offsets, modifiers, format,
++                               planes_count, std::move(callback));
++  } else if (wayland_zwp_dmabuf_) {
+     wayland_zwp_dmabuf_->CreateBuffer(fd, size, strides, offsets, modifiers,
+                                       format, planes_count,
+                                       std::move(callback));
+-  } else if (wayland_drm_) {
+-    wayland_drm_->CreateBuffer(fd, size, strides, offsets, modifiers, format,
+-                               planes_count, std::move(callback));
+   } else {
+     // This method must never be called if neither zwp_linux_dmabuf or wl_drm
+     // are supported.
+@@ -52,10 +52,11 @@
+ wl::BufferFormatsWithModifiersMap
+ WaylandBufferFactory::GetSupportedBufferFormats() const {
+ #if defined(WAYLAND_GBM)
+-  if (wayland_zwp_dmabuf_)
+-    return wayland_zwp_dmabuf_->supported_buffer_formats();
+-  else if (wayland_drm_)
++  if (wayland_drm_) {
+     return wayland_drm_->supported_buffer_formats();
++  } else if (wayland_zwp_dmabuf_) {
++    return wayland_zwp_dmabuf_->supported_buffer_formats();
++  }
+ #endif
+   return {};
+ }
+@@ -71,10 +72,11 @@
+ 
+ bool WaylandBufferFactory::CanCreateDmabufImmed() const {
+ #if defined(WAYLAND_GBM)
+-  if (wayland_zwp_dmabuf_)
+-    return wayland_zwp_dmabuf_->CanCreateBufferImmed();
+-  else if (wayland_drm_)
++  if (wayland_drm_) {
+     return wayland_drm_->CanCreateBufferImmed();
++  } else if (wayland_zwp_dmabuf_) {
++    return wayland_zwp_dmabuf_->CanCreateBufferImmed();
++  }
+ #endif
+   return false;
+ }

+ 33 - 0
0001-enable-linux-unstable-deb-target.patch

@@ -0,0 +1,33 @@
+From 22fe045deac0551720d7292022f443b22703f336 Mon Sep 17 00:00:00 2001
+From: Yaowei Zhou <yaowei.zhou@intel.com>
+Date: Thu, 20 Apr 2023 14:37:26 +0800
+Subject: [PATCH] Enable "linux:unstable_deb" build target when using the chromium minigbm
+
+Bug: N/A
+Change-Id: Ic37059be0f0719895acdba756292aed71820feba
+---
+
+diff --git a/third_party/minigbm/BUILD.gn b/third_party/minigbm/BUILD.gn
+index 739e278..50bf5d8 100644
+--- a/third_party/minigbm/BUILD.gn
++++ b/third_party/minigbm/BUILD.gn
+@@ -58,7 +58,7 @@
+     }
+   }
+ 
+-  shared_library("minigbm") {
++  static_library("minigbm") {
+     sources = [
+       "src/amdgpu.c",
+       "src/dri.c",
+@@ -89,8 +89,8 @@
+     }
+ 
+     # Clients need this to pick up the shared library correctly.
+-    all_dependent_configs =
+-        [ "//build/config/gcc:rpath_for_built_shared_libraries" ]
++    #all_dependent_configs =
++    #    [ "//build/config/gcc:rpath_for_built_shared_libraries" ]
+   }
+ 
+   # This target is used for Chromecast build, which expects the resulting lib

+ 42 - 0
0001-ozone-wayland-implement-text_input_manager-fixes.patch

@@ -0,0 +1,42 @@
+
+ui/ozone/platform/wayland/host/zwp_text_input_wrapper.h
+
+# https://github.com/chromium/chromium/commit/de30ba3f21f824be05443d5820b988d226780d68
+Support offset of surrounding text in Lacros wayland client.
+
+# https://github.com/chromium/chromium/commit/71bba2b7ae8117fdf053563a864d6cff018d7e94
+Support large size surrounding text in Lacros.
+
+---
+diff --git a/ui/ozone/platform/wayland/host/zwp_text_input_wrapper_v3.cc b/ui/ozone/platform/wayland/host/zwp_text_input_wrapper_v3.cc
+index a3ce6e4..83f2c58 100644
+--- a/ui/ozone/platform/wayland/host/zwp_text_input_wrapper_v3.cc
++++ b/ui/ozone/platform/wayland/host/zwp_text_input_wrapper_v3.cc
+@@ -147,6 +147,14 @@ void ZWPTextInputWrapperV3::SetSurroundingText(
+   zwp_text_input_v3_commit(obj_.get());
+ }
+ 
++bool ZWPTextInputWrapperV3::HasAdvancedSurroundingTextSupport() const {
++	return false;
++}
++
++void ZWPTextInputWrapperV3::SetSurroundingTextOffsetUtf16(
++    uint32_t offset_utf16) {
++}
++
+ void ZWPTextInputWrapperV3::ResetPendingState() {
+   commit_string_.clear();
+   delete_surrounding_text_before_length_ = 0;
+diff --git a/ui/ozone/platform/wayland/host/zwp_text_input_wrapper_v3.h b/ui/ozone/platform/wayland/host/zwp_text_input_wrapper_v3.h
+index 204d7e3..5d03a1d 100644
+--- a/ui/ozone/platform/wayland/host/zwp_text_input_wrapper_v3.h
++++ b/ui/ozone/platform/wayland/host/zwp_text_input_wrapper_v3.h
+@@ -45,6 +45,8 @@ class ZWPTextInputWrapperV3 : public ZWPTextInputWrapper {
+   void SetCursorRect(const gfx::Rect& rect) override;
+   void SetSurroundingText(const std::string& text,
+                           const gfx::Range& selection_range) override;
++  bool HasAdvancedSurroundingTextSupport() const override;
++  void SetSurroundingTextOffsetUtf16(uint32_t offset_utf16) override;
+   void SetContentType(TextInputType type,
+                       TextInputMode mode,
+                       uint32_t flags,

+ 521 - 0
0001-ozone-wayland-implement-text_input_manager_v3.patch

@@ -0,0 +1,521 @@
+From dba362808a97ced4f43635cbd73de6b06d156527 Mon Sep 17 00:00:00 2001
+From: Moon Sungjoon <sumoon@seoulsaram.org>
+Date: Wed, 26 Apr 2023 03:25:44 +0900
+Subject: [PATCH] ui/ozone/platform/wayland: Implement text_input_manager_v3
+
+Based on the original work of Lukas Lihotzki <lukas@lihotzki.de> in https://crrev.com/c/3015331
+
+Bug: 1227719
+Change-Id: Ib883c9087377c9f1a0dfacc45a27e3e67ccf042e
+---
+
+diff --git a/AUTHORS b/AUTHORS
+index f275151..a43a528 100644
+--- a/AUTHORS
++++ b/AUTHORS
+@@ -942,6 +942,7 @@ Mohit Bhalla <bhallam@amazon.com>
+ Moiseanu Rares-Marian <moiseanurares@gmail.com>
+ Momoka Yamamoto <momoka.my6@gmail.com>
+ Momoko Hattori <momohatt10@gmail.com>
++Moon Sungjoon <sumoon@seoulsaram.org>
+ Mostafa Sedaghat joo <mostafa.sedaghat@gmail.com>
+ Mrunal Kapade <mrunal.kapade@intel.com>
+ Munira Tursunova <moonira@google.com>
+diff --git a/third_party/wayland-protocols/BUILD.gn b/third_party/wayland-protocols/BUILD.gn
+index c84ec11..dffa0aa 100644
+--- a/third_party/wayland-protocols/BUILD.gn
++++ b/third_party/wayland-protocols/BUILD.gn
+@@ -141,7 +141,10 @@ wayland_protocol("text_input_extension_protocol") {
+ }
+ 
+ wayland_protocol("text_input_protocol") {
+-  sources = [ "src/unstable/text-input/text-input-unstable-v1.xml" ]
++  sources = [
++    "src/unstable/text-input/text-input-unstable-v1.xml",
++    "src/unstable/text-input/text-input-unstable-v3.xml",
++  ]
+ }
+ 
+ wayland_protocol("touchpad_haptics_protocol") {
+diff --git a/ui/ozone/platform/wayland/BUILD.gn b/ui/ozone/platform/wayland/BUILD.gn
+index 31314f3..c22888c 100644
+--- a/ui/ozone/platform/wayland/BUILD.gn
++++ b/ui/ozone/platform/wayland/BUILD.gn
+@@ -221,6 +221,8 @@ source_set("wayland") {
+     "host/zwp_text_input_wrapper.h",
+     "host/zwp_text_input_wrapper_v1.cc",
+     "host/zwp_text_input_wrapper_v1.h",
++    "host/zwp_text_input_wrapper_v3.cc",
++    "host/zwp_text_input_wrapper_v3.h",
+     "ozone_platform_wayland.cc",
+     "ozone_platform_wayland.h",
+     "wayland_utils.cc",
+diff --git a/ui/ozone/platform/wayland/common/wayland_object.cc b/ui/ozone/platform/wayland/common/wayland_object.cc
+index bcc48aa..009667b 100644
+--- a/ui/ozone/platform/wayland/common/wayland_object.cc
++++ b/ui/ozone/platform/wayland/common/wayland_object.cc
+@@ -30,6 +30,7 @@
+ #include <surface-augmenter-client-protocol.h>
+ #include <text-input-extension-unstable-v1-client-protocol.h>
+ #include <text-input-unstable-v1-client-protocol.h>
++#include <text-input-unstable-v3-client-protocol.h>
+ #include <touchpad-haptics-unstable-v1-client-protocol.h>
+ #include <viewporter-client-protocol.h>
+ #include <wayland-client-core.h>
+@@ -287,6 +288,8 @@ IMPLEMENT_WAYLAND_OBJECT_TRAITS(zwp_relative_pointer_manager_v1)
+ IMPLEMENT_WAYLAND_OBJECT_TRAITS(zwp_relative_pointer_v1)
+ IMPLEMENT_WAYLAND_OBJECT_TRAITS(zwp_text_input_manager_v1)
+ IMPLEMENT_WAYLAND_OBJECT_TRAITS(zwp_text_input_v1)
++IMPLEMENT_WAYLAND_OBJECT_TRAITS(zwp_text_input_manager_v3)
++IMPLEMENT_WAYLAND_OBJECT_TRAITS(zwp_text_input_v3)
+ IMPLEMENT_WAYLAND_OBJECT_TRAITS(zxdg_decoration_manager_v1)
+ IMPLEMENT_WAYLAND_OBJECT_TRAITS(zxdg_exporter_v1)
+ IMPLEMENT_WAYLAND_OBJECT_TRAITS(zxdg_exported_v1)
+diff --git a/ui/ozone/platform/wayland/common/wayland_object.h b/ui/ozone/platform/wayland/common/wayland_object.h
+index c84c084..0817e78 100644
+--- a/ui/ozone/platform/wayland/common/wayland_object.h
++++ b/ui/ozone/platform/wayland/common/wayland_object.h
+@@ -202,6 +202,8 @@ DECLARE_WAYLAND_OBJECT_TRAITS(zwp_relative_pointer_manager_v1)
+ DECLARE_WAYLAND_OBJECT_TRAITS(zwp_relative_pointer_v1)
+ DECLARE_WAYLAND_OBJECT_TRAITS(zwp_text_input_manager_v1)
+ DECLARE_WAYLAND_OBJECT_TRAITS(zwp_text_input_v1)
++DECLARE_WAYLAND_OBJECT_TRAITS(zwp_text_input_manager_v3)
++DECLARE_WAYLAND_OBJECT_TRAITS(zwp_text_input_v3)
+ DECLARE_WAYLAND_OBJECT_TRAITS(zxdg_decoration_manager_v1)
+ DECLARE_WAYLAND_OBJECT_TRAITS(zxdg_exporter_v1)
+ DECLARE_WAYLAND_OBJECT_TRAITS(zxdg_exported_v1)
+diff --git a/ui/ozone/platform/wayland/host/wayland_connection.cc b/ui/ozone/platform/wayland/host/wayland_connection.cc
+index ad3bbd6..995b1e2 100644
+--- a/ui/ozone/platform/wayland/host/wayland_connection.cc
++++ b/ui/ozone/platform/wayland/host/wayland_connection.cc
+@@ -647,6 +647,14 @@ void WaylandConnection::HandleGlobal(wl_registry* registry,
+              strcmp(interface, "zcr_text_input_extension_v1") == 0) {
+     text_input_extension_v1_ = wl::Bind<zcr_text_input_extension_v1>(
+         registry, name, std::min(version, kMaxTextInputExtensionVersion));
++  } else if (!text_input_manager_v3_ &&
++             strcmp(interface, "zwp_text_input_manager_v3") == 0) {
++    text_input_manager_v3_ = wl::Bind<zwp_text_input_manager_v3>(
++        registry, name, std::min(version, kMaxTextInputManagerVersion));
++    if (!text_input_manager_v3_) {
++      LOG(ERROR) << "Failed to bind to zwp_text_input_manager_v3 global";
++      return;
++    }
+   } else if (!xdg_decoration_manager_ &&
+              strcmp(interface, "zxdg_decoration_manager_v1") == 0) {
+     xdg_decoration_manager_ = wl::Bind<zxdg_decoration_manager_v1>(
+diff --git a/ui/ozone/platform/wayland/host/wayland_connection.h b/ui/ozone/platform/wayland/host/wayland_connection.h
+index 6659bc5..f9739ea 100644
+--- a/ui/ozone/platform/wayland/host/wayland_connection.h
++++ b/ui/ozone/platform/wayland/host/wayland_connection.h
+@@ -149,6 +149,9 @@ class WaylandConnection {
+   zcr_text_input_extension_v1* text_input_extension_v1() const {
+     return text_input_extension_v1_.get();
+   }
++  zwp_text_input_manager_v3* text_input_manager_v3() const {
++    return text_input_manager_v3_.get();
++  }
+   zwp_linux_explicit_synchronization_v1* linux_explicit_synchronization_v1()
+       const {
+     return linux_explicit_synchronization_.get();
+@@ -447,6 +450,7 @@ class WaylandConnection {
+   wl::Object<zcr_stylus_v2> zcr_stylus_v2_;
+   wl::Object<zwp_text_input_manager_v1> text_input_manager_v1_;
+   wl::Object<zcr_text_input_extension_v1> text_input_extension_v1_;
++  wl::Object<zwp_text_input_manager_v3> text_input_manager_v3_;
+   wl::Object<zwp_linux_explicit_synchronization_v1>
+       linux_explicit_synchronization_;
+   wl::Object<zxdg_decoration_manager_v1> xdg_decoration_manager_;
+diff --git a/ui/ozone/platform/wayland/host/wayland_input_method_context.cc b/ui/ozone/platform/wayland/host/wayland_input_method_context.cc
+index caa5074..c2e1798 100644
+--- a/ui/ozone/platform/wayland/host/wayland_input_method_context.cc
++++ b/ui/ozone/platform/wayland/host/wayland_input_method_context.cc
+@@ -35,6 +35,7 @@
+ #include "ui/ozone/platform/wayland/host/wayland_seat.h"
+ #include "ui/ozone/platform/wayland/host/wayland_window.h"
+ #include "ui/ozone/platform/wayland/host/zwp_text_input_wrapper_v1.h"
++#include "ui/ozone/platform/wayland/host/zwp_text_input_wrapper_v3.h"
+ #include "ui/ozone/public/ozone_switches.h"
+ 
+ #if BUILDFLAG(USE_XKBCOMMON)
+@@ -285,11 +286,18 @@ void WaylandInputMethodContext::Init(bool initialize_for_testing) {
+   // If text input instance is not created then all ime context operations
+   // are noop. This option is because in some environments someone might not
+   // want to enable ime/virtual keyboard even if it's available.
+-  if (use_ozone_wayland_vkb && !text_input_ &&
+-      connection_->text_input_manager_v1()) {
++  if (!use_ozone_wayland_vkb || text_input_)
++    return;
++
++  // Prefer text_input_manager_v1 because it is more powerful.
++  // It supports preedit styling for example.
++  if (connection_->text_input_manager_v1()) {
+     text_input_ = std::make_unique<ZWPTextInputWrapperV1>(
+         connection_, this, connection_->text_input_manager_v1(),
+         connection_->text_input_extension_v1());
++  } else if (connection_->text_input_manager_v3()) {
++    text_input_ = std::make_unique<ZWPTextInputWrapperV3>(
++        connection_, this, connection_->text_input_manager_v3());
+   }
+ }
+ 
+@@ -657,6 +665,11 @@ void WaylandInputMethodContext::OnCursorPosition(int32_t index,
+ 
+ void WaylandInputMethodContext::OnDeleteSurroundingText(int32_t index,
+                                                         uint32_t length) {
++  // Never fail if length is 0.
++  if (length == 0) {
++    return;
++  }
++
+   const auto& [surrounding_text, utf16_offset, selection, unsused_composition] =
+       surrounding_text_tracker_.predicted_state();
+   DCHECK(selection.IsValid());
+diff --git a/ui/ozone/platform/wayland/host/zwp_text_input_wrapper_v3.cc b/ui/ozone/platform/wayland/host/zwp_text_input_wrapper_v3.cc
+new file mode 100644
+index 0000000..a3ce6e4
+--- /dev/null
++++ b/ui/ozone/platform/wayland/host/zwp_text_input_wrapper_v3.cc
+@@ -0,0 +1,239 @@
++// Copyright 2023 The Chromium Authors
++// Use of this source code is governed by a BSD-style license that can be
++// found in the LICENSE file.
++
++#include "ui/ozone/platform/wayland/host/zwp_text_input_wrapper_v3.h"
++
++#include <string>
++#include <utility>
++
++#include "base/logging.h"
++#include "base/memory/ptr_util.h"
++#include "ui/base/wayland/wayland_client_input_types.h"
++#include "ui/gfx/range/range.h"
++#include "ui/ozone/platform/wayland/host/wayland_connection.h"
++#include "ui/ozone/platform/wayland/host/wayland_seat.h"
++#include "ui/ozone/platform/wayland/host/wayland_window.h"
++
++namespace ui {
++
++// Converts Chrome's TextInputType into wayland's content_purpose.
++// Some of TextInputType values do not have clearly corresponding wayland value,
++// and they fallback to closer type.
++uint32_t InputTypeToContentPurpose(TextInputType input_type) {
++  switch (input_type) {
++    case TEXT_INPUT_TYPE_NONE:
++      return ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_NORMAL;
++    case TEXT_INPUT_TYPE_TEXT:
++      return ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_NORMAL;
++    case TEXT_INPUT_TYPE_PASSWORD:
++      return ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_PASSWORD;
++    case TEXT_INPUT_TYPE_SEARCH:
++      return ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_NORMAL;
++    case TEXT_INPUT_TYPE_EMAIL:
++      return ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_EMAIL;
++    case TEXT_INPUT_TYPE_NUMBER:
++      return ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_NUMBER;
++    case TEXT_INPUT_TYPE_TELEPHONE:
++      return ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_PHONE;
++    case TEXT_INPUT_TYPE_URL:
++      return ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_URL;
++    case TEXT_INPUT_TYPE_DATE:
++      return ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_DATE;
++    case TEXT_INPUT_TYPE_DATE_TIME:
++      return ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_DATETIME;
++    case TEXT_INPUT_TYPE_DATE_TIME_LOCAL:
++      return ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_DATETIME;
++    case TEXT_INPUT_TYPE_MONTH:
++      return ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_DATE;
++    case TEXT_INPUT_TYPE_TIME:
++      return ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_TIME;
++    case TEXT_INPUT_TYPE_WEEK:
++      return ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_DATE;
++    case TEXT_INPUT_TYPE_TEXT_AREA:
++      return ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_NORMAL;
++    case TEXT_INPUT_TYPE_CONTENT_EDITABLE:
++      return ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_NORMAL;
++    case TEXT_INPUT_TYPE_DATE_TIME_FIELD:
++      return ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_DATETIME;
++    case TEXT_INPUT_TYPE_NULL:
++      return ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_NORMAL;
++  }
++}
++
++// Converts Chrome's TextInputType into wayland's content_hint.
++uint32_t InputFlagsToContentHint(int input_flags) {
++  uint32_t hint = 0;
++  if (input_flags & TEXT_INPUT_FLAG_AUTOCOMPLETE_ON)
++    hint |= ZWP_TEXT_INPUT_V3_CONTENT_HINT_COMPLETION;
++  if (input_flags & TEXT_INPUT_FLAG_SPELLCHECK_ON)
++    hint |= ZWP_TEXT_INPUT_V3_CONTENT_HINT_SPELLCHECK;
++  // No good match. Fallback to AUTO_CORRECTION.
++  if (input_flags & TEXT_INPUT_FLAG_AUTOCORRECT_ON)
++    hint |= ZWP_TEXT_INPUT_V3_CONTENT_HINT_SPELLCHECK;
++  if (input_flags & TEXT_INPUT_FLAG_AUTOCAPITALIZE_CHARACTERS)
++    hint |= ZWP_TEXT_INPUT_V3_CONTENT_HINT_AUTO_CAPITALIZATION;
++  if (input_flags & TEXT_INPUT_FLAG_AUTOCAPITALIZE_WORDS)
++    hint |= ZWP_TEXT_INPUT_V3_CONTENT_HINT_AUTO_CAPITALIZATION;
++  if (input_flags & TEXT_INPUT_FLAG_AUTOCAPITALIZE_SENTENCES)
++    hint |= ZWP_TEXT_INPUT_V3_CONTENT_HINT_AUTO_CAPITALIZATION;
++  if (input_flags & TEXT_INPUT_FLAG_HAS_BEEN_PASSWORD)
++    hint |= ZWP_TEXT_INPUT_V3_CONTENT_HINT_SENSITIVE_DATA;
++  return hint;
++}
++
++ZWPTextInputWrapperV3::ZWPTextInputWrapperV3(
++    WaylandConnection* connection,
++    ZWPTextInputWrapperClient* client,
++    zwp_text_input_manager_v3* text_input_manager)
++    : connection_(connection), client_(client) {
++  static const zwp_text_input_v3_listener text_input_listener = {
++      &OnEnter,                  // text_input_enter,
++      &OnLeave,                  // text_input_leave,
++      &OnPreeditString,          // text_input_preedit_string,
++      &OnCommitString,           // text_input_commit_string,
++      &OnDeleteSurroundingText,  // text_input_delete_surrounding_text,
++      &OnDone,                   // text_input_done,
++  };
++
++  DCHECK(text_input_manager);
++  auto* text_input = zwp_text_input_manager_v3_get_text_input(
++      text_input_manager, connection_->seat()->wl_object());
++  obj_ = wl::Object<zwp_text_input_v3>(text_input);
++
++  zwp_text_input_v3_add_listener(text_input, &text_input_listener, this);
++}
++
++ZWPTextInputWrapperV3::~ZWPTextInputWrapperV3() = default;
++
++void ZWPTextInputWrapperV3::Reset() {
++  NOTIMPLEMENTED_LOG_ONCE();
++}
++
++void ZWPTextInputWrapperV3::Activate(WaylandWindow* window,
++                                     TextInputClient::FocusReason reason) {
++  zwp_text_input_v3_enable(obj_.get());
++  zwp_text_input_v3_commit(obj_.get());
++}
++
++void ZWPTextInputWrapperV3::Deactivate() {
++  zwp_text_input_v3_disable(obj_.get());
++  zwp_text_input_v3_commit(obj_.get());
++}
++
++void ZWPTextInputWrapperV3::ShowInputPanel() {
++  // Not directly supported in zwp_text_input_v3
++  // Enable again to show the screen keyboard in GNOME:
++  // https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1543#note_1051704
++  zwp_text_input_v3_enable(obj_.get());
++  zwp_text_input_v3_commit(obj_.get());
++}
++
++void ZWPTextInputWrapperV3::HideInputPanel() {
++  // unsupported in zwp_text_input_v3
++}
++
++void ZWPTextInputWrapperV3::SetCursorRect(const gfx::Rect& rect) {
++  zwp_text_input_v3_set_cursor_rectangle(obj_.get(), rect.x(), rect.y(),
++                                         rect.width(), rect.height());
++  zwp_text_input_v3_commit(obj_.get());
++}
++
++void ZWPTextInputWrapperV3::SetSurroundingText(
++    const std::string& text,
++    const gfx::Range& selection_range) {
++  zwp_text_input_v3_set_surrounding_text(
++      obj_.get(), text.c_str(), selection_range.start(), selection_range.end());
++  zwp_text_input_v3_commit(obj_.get());
++}
++
++void ZWPTextInputWrapperV3::ResetPendingState() {
++  commit_string_.clear();
++  delete_surrounding_text_before_length_ = 0;
++  delete_surrounding_text_after_length_ = 0;
++  preedit_string_.clear();
++  preedit_string_cursor_begin_ = 0;
++  preedit_string_cursor_end_ = 0;
++}
++
++void ZWPTextInputWrapperV3::SetContentType(ui::TextInputType type,
++                                           ui::TextInputMode mode,
++                                           uint32_t flags,
++                                           bool should_do_learning,
++                                           bool can_compose_inline) {
++  // V3 doesn't have extension
++  uint32_t content_purpose = InputTypeToContentPurpose(type);
++  uint32_t content_hint = InputFlagsToContentHint(flags);
++  static_cast<void>(flags);
++  static_cast<void>(should_do_learning);
++  zwp_text_input_v3_set_content_type(obj_.get(), content_hint, content_purpose);
++}
++
++void ZWPTextInputWrapperV3::OnEnter(void* data,
++                                    struct zwp_text_input_v3* text_input,
++                                    struct wl_surface* surface) {
++  NOTIMPLEMENTED_LOG_ONCE();
++}
++
++void ZWPTextInputWrapperV3::OnLeave(void* data,
++                                    struct zwp_text_input_v3* text_input,
++                                    struct wl_surface* surface) {
++  NOTIMPLEMENTED_LOG_ONCE();
++}
++
++void ZWPTextInputWrapperV3::OnPreeditString(
++    void* data,
++    struct zwp_text_input_v3* text_input,
++    const char* text,
++    int32_t cursor_begin,
++    int32_t cursor_end) {
++  auto* wti = static_cast<ZWPTextInputWrapperV3*>(data);
++  wti->preedit_string_ = text ? text : "";
++  wti->preedit_string_cursor_begin_ = cursor_begin;
++  wti->preedit_string_cursor_end_ = cursor_end;
++}
++
++void ZWPTextInputWrapperV3::OnCommitString(void* data,
++                                           struct zwp_text_input_v3* text_input,
++                                           const char* text) {
++  auto* wti = static_cast<ZWPTextInputWrapperV3*>(data);
++  wti->commit_string_ = text ? text : "";
++}
++
++void ZWPTextInputWrapperV3::OnDeleteSurroundingText(
++    void* data,
++    struct zwp_text_input_v3* text_input,
++    uint32_t before_length,
++    uint32_t after_length) {
++  auto* wti = static_cast<ZWPTextInputWrapperV3*>(data);
++  wti->delete_surrounding_text_before_length_ = before_length;
++  wti->delete_surrounding_text_after_length_ = after_length;
++}
++
++void ZWPTextInputWrapperV3::OnDone(void* data,
++                                   struct zwp_text_input_v3* text_input,
++                                   uint32_t serial) {
++  auto* wti = static_cast<ZWPTextInputWrapperV3*>(data);
++  wti->client_->OnPreeditString("", {}, 0);
++  wti->client_->OnDeleteSurroundingText(
++      -int32_t(wti->delete_surrounding_text_before_length_),
++      int32_t(wti->delete_surrounding_text_before_length_) +
++          int32_t(wti->delete_surrounding_text_after_length_));
++  wti->client_->OnCommitString(wti->commit_string_.c_str());
++  wti->client_->OnPreeditString(wti->preedit_string_.c_str(), {},
++                                wti->preedit_string_cursor_begin_);
++  wti->ResetPendingState();
++}
++
++void ZWPTextInputWrapperV3::SetGrammarFragmentAtCursor(
++    const ui::GrammarFragment& fragment) {
++  NOTIMPLEMENTED_LOG_ONCE();
++}
++
++void ZWPTextInputWrapperV3::SetAutocorrectInfo(
++    const gfx::Range& autocorrect_range,
++    const gfx::Rect& autocorrect_bounds) {
++  NOTIMPLEMENTED_LOG_ONCE();
++}
++
++}  // namespace ui
+diff --git a/ui/ozone/platform/wayland/host/zwp_text_input_wrapper_v3.h b/ui/ozone/platform/wayland/host/zwp_text_input_wrapper_v3.h
+new file mode 100644
+index 0000000..204d7e3
+--- /dev/null
++++ b/ui/ozone/platform/wayland/host/zwp_text_input_wrapper_v3.h
+@@ -0,0 +1,98 @@
++// Copyright 2023 The Chromium Authors
++// Use of this source code is governed by a BSD-style license that can be
++// found in the LICENSE file.
++
++#ifndef UI_OZONE_PLATFORM_WAYLAND_HOST_ZWP_TEXT_INPUT_WRAPPER_V3_H_
++#define UI_OZONE_PLATFORM_WAYLAND_HOST_ZWP_TEXT_INPUT_WRAPPER_V3_H_
++
++#include <cstdint>
++#include <string>
++
++#include <text-input-unstable-v3-client-protocol.h>
++
++#include "base/memory/raw_ptr.h"
++#include "ui/ozone/platform/wayland/common/wayland_object.h"
++#include "ui/ozone/platform/wayland/host/zwp_text_input_wrapper.h"
++
++namespace gfx {
++class Rect;
++}
++
++namespace ui {
++
++class WaylandConnection;
++class WaylandWindow;
++
++// Text input wrapper for text-input-unstable-v3
++class ZWPTextInputWrapperV3 : public ZWPTextInputWrapper {
++ public:
++  ZWPTextInputWrapperV3(WaylandConnection* connection,
++                        ZWPTextInputWrapperClient* client,
++                        zwp_text_input_manager_v3* text_input_manager);
++  ZWPTextInputWrapperV3(const ZWPTextInputWrapperV3&) = delete;
++  ZWPTextInputWrapperV3& operator=(const ZWPTextInputWrapperV3&) = delete;
++  ~ZWPTextInputWrapperV3() override;
++
++  void Reset() override;
++
++  void Activate(WaylandWindow* window,
++                ui::TextInputClient::FocusReason reason) override;
++  void Deactivate() override;
++
++  void ShowInputPanel() override;
++  void HideInputPanel() override;
++
++  void SetCursorRect(const gfx::Rect& rect) override;
++  void SetSurroundingText(const std::string& text,
++                          const gfx::Range& selection_range) override;
++  void SetContentType(TextInputType type,
++                      TextInputMode mode,
++                      uint32_t flags,
++                      bool should_do_learning,
++                      bool can_compose_inline) override;
++  void SetGrammarFragmentAtCursor(const ui::GrammarFragment& fragment) override;
++  void SetAutocorrectInfo(const gfx::Range& autocorrect_range,
++                          const gfx::Rect& autocorrect_bounds) override;
++
++ private:
++  void ResetPendingState();
++
++  // zwp_text_input_v3_listener
++  static void OnEnter(void* data,
++                      struct zwp_text_input_v3* text_input,
++                      struct wl_surface* surface);
++  static void OnLeave(void* data,
++                      struct zwp_text_input_v3* text_input,
++                      struct wl_surface* surface);
++  static void OnPreeditString(void* data,
++                              struct zwp_text_input_v3* text_input,
++                              const char* text,
++                              int32_t cursor_begin,
++                              int32_t cursor_end);
++  static void OnCommitString(void* data,
++                             struct zwp_text_input_v3* text_input,
++                             const char* text);
++  static void OnDeleteSurroundingText(void* data,
++                                      struct zwp_text_input_v3* text_input,
++                                      uint32_t before_length,
++                                      uint32_t after_length);
++  static void OnDone(void* data,
++                     struct zwp_text_input_v3* text_input,
++                     uint32_t serial);
++
++  const raw_ptr<WaylandConnection> connection_;
++  wl::Object<zwp_text_input_v3> obj_;
++  const raw_ptr<ZWPTextInputWrapperClient> client_;
++
++  // pending state until OnDone
++  std::string commit_string_;
++  uint32_t delete_surrounding_text_before_length_ = 0;
++  uint32_t delete_surrounding_text_after_length_ = 0;
++  std::string preedit_string_;  // preedit string of pending state
++  int32_t preedit_string_cursor_begin_ = 0;
++  int32_t preedit_string_cursor_end_ = 0;
++};
++
++}  // namespace ui
++
++#endif  // UI_OZONE_PLATFORM_WAYLAND_HOST_ZWP_TEXT_INPUT_WRAPPER_V3_H_

+ 23 - 0
0001-vaapi-flag-ozone-wayland.patch

@@ -0,0 +1,23 @@
+From 12724af6284195381377e074cc7f7c2fbc6cb05c Mon Sep 17 00:00:00 2001
+From: Yaowei Zhou <yaowei.zhou@intel.com>
+Date: Tue, 30 May 2023 12:45:27 +0800
+Subject: [PATCH] Enable VA-API flag on ozone wayland
+
+Bug: POC
+Change-Id: I4af3c2c4925958bbca86a25a4d9c66fd8922c806
+---
+
+diff --git a/ui/ozone/platform/wayland/ozone_platform_wayland.cc b/ui/ozone/platform/wayland/ozone_platform_wayland.cc
+index 1de5c418..9f2f1f5 100644
+--- a/ui/ozone/platform/wayland/ozone_platform_wayland.cc
++++ b/ui/ozone/platform/wayland/ozone_platform_wayland.cc
+@@ -311,6 +311,9 @@
+       // arbitrary position.
+       properties->supports_global_screen_coordinates =
+           kDefaultScreenCoordinateEnabled;
++
++      properties->supports_vaapi = true;
++
+       initialised = true;
+     }
+ 

+ 33 - 12
PKGBUILD

@@ -22,7 +22,7 @@ url="https://github.com/ungoogled-software/ungoogled-chromium"
 license=('BSD')
 depends=('gtk3' 'nss' 'alsa-lib' 'xdg-utils' 'libxss' 'libcups' 'libgcrypt'
          'ttf-liberation' 'systemd' 'dbus' 'libpulse' 'pciutils' 'libva'
-         'wayland' 'desktop-file-utils' 'hicolor-icon-theme')
+         'libffi' 'desktop-file-utils' 'hicolor-icon-theme')
 makedepends=('python' 'gn' 'ninja' 'clang' 'lld' 'gperf' 'nodejs' 'pipewire'
              'qt5-base' 'java-runtime-headless' 'git')
 optdepends=('pipewire: WebRTC desktop sharing under Wayland'
@@ -64,11 +64,23 @@ _uc_usr=ungoogled-software
 _uc_rel=1
 # _uc_ver="$pkgver-$_uc_rel"
 _uc_ver="120.0.6099.109-$_uc_rel"
+optdepends=("${optdepends[@]}"
+            'chromium-extension-web-store: Web Store Functionality')
 source=(${source[@]}
-        ${pkgname%-*}-$_uc_ver.tar.gz::https://github.com/$_uc_usr/ungoogled-chromium/archive/refs/tags/$_uc_ver.tar.gz)
-        # ${pkgname%-*}-$_uc_ver.zip::https://github.com/noahvogt/${pkgname%-*}/archive/refs/heads/update.zip)
+        ${pkgname%-*}-$_uc_ver.tar.gz::https://github.com/$_uc_usr/ungoogled-chromium/archive/refs/tags/$_uc_ver.tar.gz
+        0001-vaapi-flag-ozone-wayland.patch
+        0001-adjust-buffer-format-order.patch
+        0001-enable-linux-unstable-deb-target.patch
+        0001-ozone-wayland-implement-text_input_manager_v3.patch
+        0001-ozone-wayland-implement-text_input_manager-fixes.patch)
+        # ${pkgname%-*}-$_uc_ver.zip::https://github.com/noahvogt/${pkgname%-*}/archive/refs/heads/update.zip
 sha256sums=(${sha256sums[@]}
-            '8a54932b0f2098dcd334e79e4f680614f57dc192037bc495d2099e28dbc507c8')
+            '8a54932b0f2098dcd334e79e4f680614f57dc192037bc495d2099e28dbc507c8'
+            '9a5594293616e1390462af1f50276ee29fd6075ffab0e3f944f6346cb2eb8aec'
+            '8ba5c67b7eb6cacd2dbbc29e6766169f0fca3bbb07779b1a0a76c913f17d343f'
+            '2a44756404e13c97d000cc0d859604d6848163998ea2f838b3b9bb2c840967e3'
+            'd9974ddb50777be428fd0fa1e01ffe4b587065ba6adefea33678e1b3e25d1285'
+            'a2da75d0c20529f2d635050e0662941c0820264ea9371eb900b9d90b5968fa6a')
 
 # Possible replacements are listed in build/linux/unbundle/replace_gn_files.py
 # Keys are the names in the above script; values are the dependencies in Arch
@@ -151,6 +163,20 @@ prepare() {
 
 
   # Custom Patches
+  sed -i '/^bool IsHevcProfileSupported(const VideoType& type) {$/{s++bool IsHevcProfileSupported(const VideoType\& type) { return true;+;h};${x;/./{x;q0};x;q1}' \
+			media/base/supported_types.cc
+
+  # Implement text_input_manager_v3
+  # https://chromium-review.googlesource.com/c/chromium/src/+/3750452
+  patch -Np1 -i ../0001-ozone-wayland-implement-text_input_manager_v3.patch
+  patch -Np1 -i ../0001-ozone-wayland-implement-text_input_manager-fixes.patch
+
+  # Enable VAAPI on Wayland
+  # https://discourse.ubuntu.com/t/chromium-hardware-accelerated-build-for-intel-based-platforms-available-for-beta-testing/35625
+  # https://git.launchpad.net/~chromium-team/chromium-browser/+git/snap-from-source/
+  # patch -Np1 -i ../0001-enable-linux-unstable-deb-target.patch
+  patch -Np1 -i ../0001-adjust-buffer-format-order.patch
+  patch -Np1 -i ../0001-vaapi-flag-ozone-wayland.patch
 
   # move ~/.pki directory to ${XDG_DATA_HOME:-$HOME/.local}/share/pki
   patch -p1 -i ../xdg-basedir.patch
@@ -160,14 +186,8 @@ prepare() {
   # called 'shoulder surfing').
   patch -p1 -i ../no-omnibox-suggestion-autocomplete.patch
 
-
   # Ungoogled Chromium changes
-  if [[ -d "$srcdir/${pkgname%xdg*}$_uc_ver" ]]
-  then
-    _ungoogled_repo="$srcdir/${pkgname%xdg*}$_uc_ver"
-  else
-    _ungoogled_repo="$srcdir/${pkgname%xdg*}update"
-  fi
+  _ungoogled_repo="$srcdir/${pkgname%xdg*}$_uc_ver"
 
   _utils="${_ungoogled_repo}/utils"
   msg2 'Pruning binaries'
@@ -232,6 +252,7 @@ build() {
     'enable_widevine=true'
     'enable_nacl=false'
     'enable_rust=false'
+    "google_api_key=\"$_google_api_key\""
   )
 
   if [[ -n ${_system_libs[icu]+set} ]]; then
@@ -245,7 +266,7 @@ build() {
   )
 
   # Append ungoogled chromium flags to _flags array
-    _ungoogled_repo="$srcdir/${pkgname%xdg*}-$_uc_ver"
+  _ungoogled_repo="$srcdir/${pkgname%xdg*}$_uc_ver"
   readarray -t -O ${#_flags[@]} _flags < "${_ungoogled_repo}/flags.gn"
 
   # Facilitate deterministic builds (taken from build/config/compiler/BUILD.gn)