Skip to content

Commit

Permalink
fix: calling of X11 functions when running under Wayland (#33499)
Browse files Browse the repository at this point in the history
Backports #33355
  • Loading branch information
deepak1556 committed Mar 29, 2022
1 parent a071825 commit db0ad4f
Show file tree
Hide file tree
Showing 16 changed files with 300 additions and 306 deletions.
1 change: 0 additions & 1 deletion BUILD.gn
Expand Up @@ -556,7 +556,6 @@ source_set("electron_lib") {
defines += [
# Disable warnings for g_settings_list_schemas.
"GLIB_DISABLE_DEPRECATION_WARNINGS",
"USE_X11=1",
]

sources += [
Expand Down
2 changes: 0 additions & 2 deletions filenames.gni
Expand Up @@ -53,8 +53,6 @@ filenames = {
"shell/browser/ui/views/global_menu_bar_x11.h",
"shell/browser/ui/x/event_disabler.cc",
"shell/browser/ui/x/event_disabler.h",
"shell/browser/ui/x/window_state_watcher.cc",
"shell/browser/ui/x/window_state_watcher.h",
"shell/browser/ui/x/x_window_utils.cc",
"shell/browser/ui/x/x_window_utils.h",
]
Expand Down
3 changes: 2 additions & 1 deletion patches/chromium/.patches
Expand Up @@ -67,7 +67,6 @@ feat_enable_offscreen_rendering_with_viz_compositor.patch
gpu_notify_when_dxdiag_request_fails.patch
feat_allow_embedders_to_add_observers_on_created_hunspell.patch
feat_add_onclose_to_messageport.patch
ui_gtk_public_header.patch
allow_in-process_windows_to_have_different_web_prefs.patch
refactor_expose_cursor_changes_to_the_webcontentsobserver.patch
crash_allow_setting_more_options.patch
Expand Down Expand Up @@ -118,3 +117,5 @@ build_disable_partition_alloc_on_mac.patch
fix_non-client_mouse_tracking_and_message_bubbling_on_windows.patch
remove_incorrect_width_height_adjustments.patch
set_dpi_correctly_during_main_window_creation.patch
ui_gtk_public_header.patch
introduce_ozoneplatform_electron_can_call_x11_property.patch
@@ -0,0 +1,37 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Marek Rusinowski <marekrusinowski@gmail.com>
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 013abeeea0bb9c52bb52cb6bf3972f78d21eef9a..88668a14e38b4391a7951ed16072b4c85a2cb6cb 100644
--- a/ui/ozone/platform/x11/ozone_platform_x11.cc
+++ b/ui/ozone/platform/x11/ozone_platform_x11.cc
@@ -200,6 +200,7 @@ class OzonePlatformX11 : public OzonePlatform,
properties->supports_vulkan_swap_chain = true;
properties->uses_external_vulkan_image_factory = true;
properties->skia_can_fall_back_to_x11 = true;
+ properties->electron_can_call_x11 = true;
properties->platform_shows_drag_image = false;
properties->supports_global_application_menus = true;
properties->app_modal_dialogs_use_event_blocker = true;
diff --git a/ui/ozone/public/ozone_platform.h b/ui/ozone/public/ozone_platform.h
index 4af0f65265b6402031f0f6a25660cb850b9ec1ed..a425243b7c67fbec28a5704b5e953b417fbdfa0f 100644
--- a/ui/ozone/public/ozone_platform.h
+++ b/ui/ozone/public/ozone_platform.h
@@ -132,6 +132,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 BufferQueue needs a background image to
// be stacked below an AcceleratedWidget to make a widget opaque.
bool needs_background_image = false;
20 changes: 14 additions & 6 deletions patches/chromium/ui_gtk_public_header.patch
@@ -1,24 +1,32 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: deepak1556 <hop2deep@gmail.com>
Date: Fri, 10 Apr 2020 17:47:18 -0700
Date: Tue, 29 Mar 2022 20:17:54 +0900
Subject: ui_gtk_public_header.patch

Allow electron to depend on //ui/gtk/gtk_util.h
Allow electron to depend on gtk_util.h and gtk_ui.h from //ui/gtk/

diff --git a/ui/gtk/BUILD.gn b/ui/gtk/BUILD.gn
index db29cdca6f02fb8ca9dd0f25e13ed902589adc25..6fa1496b4d529ccf7e4e543579462f990aae5ede 100644
index db29cdca6f02fb8ca9dd0f25e13ed902589adc25..48f19e145cb81f4e4d2fdd6f3bd1cc72128358a7 100644
--- a/ui/gtk/BUILD.gn
+++ b/ui/gtk/BUILD.gn
@@ -39,7 +39,7 @@ generate_stubs("gtk_stubs") {
@@ -39,7 +39,11 @@ generate_stubs("gtk_stubs") {
}

component("gtk") {
- public = [ "gtk_ui_factory.h" ]
+ public = [ "gtk_ui_factory.h", "gtk_util.h" ]
+ public = [
+ "gtk_ui.h",
+ "gtk_ui_factory.h",
+ "gtk_util.h",
+ ]

sources = [
"gtk_color_mixers.cc",
@@ -53,7 +53,6 @@ component("gtk") {
@@ -49,11 +53,9 @@ component("gtk") {
"gtk_key_bindings_handler.cc",
"gtk_key_bindings_handler.h",
"gtk_ui.cc",
- "gtk_ui.h",
"gtk_ui_factory.cc",
"gtk_ui_platform.h",
"gtk_util.cc",
Expand Down
6 changes: 0 additions & 6 deletions shell/browser/electron_browser_main_parts.h
Expand Up @@ -36,12 +36,6 @@ class Screen;
}
#endif

#if defined(USE_X11)
namespace ui {
class GtkUiPlatform;
}
#endif

namespace device {
class GeolocationManager;
}
Expand Down
2 changes: 1 addition & 1 deletion shell/browser/native_window.cc
Expand Up @@ -25,7 +25,7 @@
#include "ui/display/win/screen_win.h"
#endif

#if defined(USE_OZONE) || defined(USE_X11)
#if defined(USE_OZONE)
#include "ui/base/ui_base_features.h"
#include "ui/ozone/public/ozone_platform.h"
#endif
Expand Down

0 comments on commit db0ad4f

Please sign in to comment.