From 11fa915724fb0c7a8478be8bd7716a50ce078552 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Tue, 13 May 2025 23:38:35 -0500 Subject: [PATCH] refactor: remove `introduce_ozoneplatform_electron_can_call_x11_property.patch` (#47075) * refactor: use x11_util::IsX11() in BuildSubmenuFromModel() * refactor: use x11_util::IsX11() in ElectronDesktopWindowTreeHostLinux::OnBoundsChanged() * refactor: use skia_can_fall_back_to_x11 in x11_util::IsX11() it is identical in practice to electron_can_call_x11 and does not require a Chromium patch * chore: remove introduce_ozoneplatform_electron_can_call_x11_property.patch * refactor: use ui::GetOzonePlatformId() to test for x11 --- patches/chromium/.patches | 1 - ...tform_electron_can_call_x11_property.patch | 37 ------------------- shell/browser/linux/x11_util.cc | 7 ++-- ...electron_desktop_window_tree_host_linux.cc | 5 +-- shell/browser/ui/gtk/menu_util.cc | 5 +-- 5 files changed, 7 insertions(+), 48 deletions(-) delete mode 100644 patches/chromium/introduce_ozoneplatform_electron_can_call_x11_property.patch diff --git a/patches/chromium/.patches b/patches/chromium/.patches index cbc9273208..5ffefb2192 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -74,7 +74,6 @@ fix_aspect_ratio_with_max_size.patch port_autofill_colors_to_the_color_pipeline.patch fix_non-client_mouse_tracking_and_message_bubbling_on_windows.patch build_make_libcxx_abi_unstable_false_for_electron.patch -introduce_ozoneplatform_electron_can_call_x11_property.patch make_gtk_getlibgtk_public.patch custom_protocols_plzserviceworker.patch feat_filter_out_non-shareable_windows_in_the_current_application_in.patch diff --git a/patches/chromium/introduce_ozoneplatform_electron_can_call_x11_property.patch b/patches/chromium/introduce_ozoneplatform_electron_can_call_x11_property.patch deleted file mode 100644 index 3b780f397d..0000000000 --- a/patches/chromium/introduce_ozoneplatform_electron_can_call_x11_property.patch +++ /dev/null @@ -1,37 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Marek Rusinowski -Date: Wed, 23 Mar 2022 21:09:37 +0100 -Subject: introduce OzonePlatform::electron_can_call_x11 property - -We expose this additonal property in the OzonePlatform to be able to easily -determine whatever we can call X11 functions without crashing the application -at rutime. It would be best if eventually all usages of this property were -replaced with clean ozone native implementations. - -diff --git a/ui/ozone/platform/x11/ozone_platform_x11.cc b/ui/ozone/platform/x11/ozone_platform_x11.cc -index 4f00f630665a10a0fb85fe7c2ddc0fa67add1603..e9e8da125b518387546275bf84e0b09c3d49e254 100644 ---- a/ui/ozone/platform/x11/ozone_platform_x11.cc -+++ b/ui/ozone/platform/x11/ozone_platform_x11.cc -@@ -194,6 +194,7 @@ class OzonePlatformX11 : public OzonePlatform, - base::MessagePumpType::UI; - properties->supports_vulkan_swap_chain = true; - properties->skia_can_fall_back_to_x11 = true; -+ properties->electron_can_call_x11 = true; - properties->platform_shows_drag_image = false; - properties->app_modal_dialogs_use_event_blocker = true; - properties->fetch_buffer_formats_for_gmb_on_gpu = true; -diff --git a/ui/ozone/public/ozone_platform.h b/ui/ozone/public/ozone_platform.h -index 1384e1620dc07874e2103d12cd6f31da5ca7a821..7c8639f6f57fd3b8977bbb3d811edf466b4ccc64 100644 ---- a/ui/ozone/public/ozone_platform.h -+++ b/ui/ozone/public/ozone_platform.h -@@ -129,6 +129,10 @@ class COMPONENT_EXPORT(OZONE) OzonePlatform { - // Linux only: determines if Skia can fall back to the X11 output device. - bool skia_can_fall_back_to_x11 = false; - -+ // Linux only: determines is Electron can call selected X11 functions while -+ // it migrates to pure ozone abstractions. -+ bool electron_can_call_x11 = false; -+ - // Wayland only: determines whether windows which are not top level ones - // should be given parents explicitly. - bool set_parent_for_non_top_level_windows = false; diff --git a/shell/browser/linux/x11_util.cc b/shell/browser/linux/x11_util.cc index 38a33fe36d..f65453b68d 100644 --- a/shell/browser/linux/x11_util.cc +++ b/shell/browser/linux/x11_util.cc @@ -4,14 +4,13 @@ #include "shell/browser/linux/x11_util.h" -#include "ui/ozone/public/ozone_platform.h" +#include "ui/ozone/platform_selection.h" // nogncheck namespace x11_util { bool IsX11() { - return ui::OzonePlatform::GetInstance() - ->GetPlatformProperties() - .electron_can_call_x11; + static const bool is_x11 = ui::GetOzonePlatformId() == ui::kPlatformX11; + return is_x11; } } // namespace x11_util diff --git a/shell/browser/ui/electron_desktop_window_tree_host_linux.cc b/shell/browser/ui/electron_desktop_window_tree_host_linux.cc index 7e8f06c2b1..dd7a5e2b64 100644 --- a/shell/browser/ui/electron_desktop_window_tree_host_linux.cc +++ b/shell/browser/ui/electron_desktop_window_tree_host_linux.cc @@ -13,6 +13,7 @@ #include "base/feature_list.h" #include "base/i18n/rtl.h" #include "shell/browser/api/electron_api_web_contents.h" +#include "shell/browser/linux/x11_util.h" #include "shell/browser/native_window_features.h" #include "shell/browser/native_window_views.h" #include "shell/browser/ui/views/client_frame_view_linux.h" @@ -82,9 +83,7 @@ void ElectronDesktopWindowTreeHostLinux::OnBoundsChanged( views::DesktopWindowTreeHostLinux::OnBoundsChanged(change); UpdateFrameHints(); - if (ui::OzonePlatform::GetInstance() - ->GetPlatformProperties() - .electron_can_call_x11) { + if (x11_util::IsX11()) { // The OnWindowStateChanged should receive all updates but currently under // X11 it doesn't receive changes to the fullscreen status because chromium // is handling the fullscreen state changes synchronously, see diff --git a/shell/browser/ui/gtk/menu_util.cc b/shell/browser/ui/gtk/menu_util.cc index 5870a85414..5ef7a08c2e 100644 --- a/shell/browser/ui/gtk/menu_util.cc +++ b/shell/browser/ui/gtk/menu_util.cc @@ -12,6 +12,7 @@ #include "base/containers/flat_map.h" #include "base/strings/utf_string_conversions.h" #include "chrome/app/chrome_command_ids.h" +#include "shell/browser/linux/x11_util.h" #include "shell/browser/ui/gtk_util.h" #include "third_party/skia/include/core/SkBitmap.h" #include "ui/base/accelerators/accelerator.h" @@ -219,9 +220,7 @@ void BuildSubmenuFromModel(ui::MenuModel* model, connect_to_activate = false; } - if (ui::OzonePlatform::GetInstance() - ->GetPlatformProperties() - .electron_can_call_x11) { + if (x11_util::IsX11()) { ui::Accelerator accelerator; if (model->GetAcceleratorAt(i, &accelerator)) { gtk_widget_add_accelerator(menu_item, "activate", nullptr,