mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
fix: calling of X11 functions when running under Wayland (#33355)
* fix: don't call X11 functions in file dialog and message box * refactor: remove unused GtkUiPlatform declaration * fix: set gtk darktheme only when running under X11 * fix: replace X11 window state watcher with implementation using ozone * fix: make sure global menu barr is used only when supported * fix: don't call X11 function in native window views under wayland * style: fix lint issues * fix: use GtkUiPlatform::ShowGtkWindow instead of gtk_window_present directly * refactor: extract CreateGlobalMenuBar into separate function * refactor: move checking for WaylandWindowDecorations inside class * fix: check if we run under X11 only in ozone build * refactor: drop including unused ui/base/ui_base_features.h header * fix: modify ui_gtk_public_header.patch to also export gtk_ui.h * fix: refactor guarding of X11 calls - Introduce patch exposing new electron_can_call_x11 property - Replace defined(USE_OZONE) with BUILDFLAG(OZONE_PLATFORM_X11) flags * fix: remove the last remaining usage of USE_X11 * fix: usage of BUILDFLAG(OZONE_PLATFORM_X11) not building on non ozone * fix: call UpdateWindowState from OnBoundsChanged only under X11
This commit is contained in:
@@ -10,7 +10,9 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "base/feature_list.h"
|
||||
#include "base/i18n/rtl.h"
|
||||
#include "shell/browser/native_window_features.h"
|
||||
#include "shell/browser/ui/views/client_frame_view_linux.h"
|
||||
#include "ui/gfx/geometry/rect.h"
|
||||
#include "ui/gfx/geometry/skia_conversions.h"
|
||||
@@ -20,6 +22,14 @@
|
||||
#include "ui/views/widget/desktop_aura/desktop_window_tree_host_linux.h"
|
||||
#include "ui/views/window/non_client_view.h"
|
||||
|
||||
#if defined(USE_OZONE)
|
||||
#include "ui/ozone/buildflags.h"
|
||||
#if BUILDFLAG(OZONE_PLATFORM_X11)
|
||||
#define USE_OZONE_PLATFORM_X11
|
||||
#endif
|
||||
#include "ui/ozone/public/ozone_platform.h"
|
||||
#endif
|
||||
|
||||
namespace electron {
|
||||
|
||||
ElectronDesktopWindowTreeHostLinux::ElectronDesktopWindowTreeHostLinux(
|
||||
@@ -46,6 +56,18 @@ void ElectronDesktopWindowTreeHostLinux::OnBoundsChanged(
|
||||
const BoundsChange& change) {
|
||||
views::DesktopWindowTreeHostLinux::OnBoundsChanged(change);
|
||||
UpdateFrameHints();
|
||||
|
||||
#if defined(USE_OZONE_PLATFORM_X11)
|
||||
if (ui::OzonePlatform::GetInstance()
|
||||
->GetPlatformProperties()
|
||||
.electron_can_call_x11) {
|
||||
// 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
|
||||
// X11Window::ToggleFullscreen in ui/ozone/platform/x11/x11_window.cc.
|
||||
UpdateWindowState(platform_window()->GetPlatformWindowState());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void ElectronDesktopWindowTreeHostLinux::OnWindowStateChanged(
|
||||
@@ -53,6 +75,43 @@ void ElectronDesktopWindowTreeHostLinux::OnWindowStateChanged(
|
||||
ui::PlatformWindowState new_state) {
|
||||
views::DesktopWindowTreeHostLinux::OnWindowStateChanged(old_state, new_state);
|
||||
UpdateFrameHints();
|
||||
UpdateWindowState(new_state);
|
||||
}
|
||||
|
||||
void ElectronDesktopWindowTreeHostLinux::UpdateWindowState(
|
||||
ui::PlatformWindowState new_state) {
|
||||
if (window_state_ == new_state)
|
||||
return;
|
||||
|
||||
switch (window_state_) {
|
||||
case ui::PlatformWindowState::kMinimized:
|
||||
native_window_view_->NotifyWindowRestore();
|
||||
break;
|
||||
case ui::PlatformWindowState::kMaximized:
|
||||
native_window_view_->NotifyWindowUnmaximize();
|
||||
break;
|
||||
case ui::PlatformWindowState::kFullScreen:
|
||||
native_window_view_->NotifyWindowLeaveFullScreen();
|
||||
break;
|
||||
case ui::PlatformWindowState::kUnknown:
|
||||
case ui::PlatformWindowState::kNormal:
|
||||
break;
|
||||
}
|
||||
switch (new_state) {
|
||||
case ui::PlatformWindowState::kMinimized:
|
||||
native_window_view_->NotifyWindowMinimize();
|
||||
break;
|
||||
case ui::PlatformWindowState::kMaximized:
|
||||
native_window_view_->NotifyWindowMaximize();
|
||||
break;
|
||||
case ui::PlatformWindowState::kFullScreen:
|
||||
native_window_view_->NotifyWindowEnterFullScreen();
|
||||
break;
|
||||
case ui::PlatformWindowState::kUnknown:
|
||||
case ui::PlatformWindowState::kNormal:
|
||||
break;
|
||||
}
|
||||
window_state_ = new_state;
|
||||
}
|
||||
|
||||
void ElectronDesktopWindowTreeHostLinux::OnNativeThemeUpdated(
|
||||
@@ -65,13 +124,15 @@ void ElectronDesktopWindowTreeHostLinux::OnDeviceScaleFactorChanged() {
|
||||
}
|
||||
|
||||
void ElectronDesktopWindowTreeHostLinux::UpdateFrameHints() {
|
||||
if (SupportsClientFrameShadow() && native_window_view_->has_frame() &&
|
||||
native_window_view_->has_client_frame()) {
|
||||
UpdateClientDecorationHints(static_cast<ClientFrameViewLinux*>(
|
||||
native_window_view_->widget()->non_client_view()->frame_view()));
|
||||
}
|
||||
if (base::FeatureList::IsEnabled(features::kWaylandWindowDecorations)) {
|
||||
if (SupportsClientFrameShadow() && native_window_view_->has_frame() &&
|
||||
native_window_view_->has_client_frame()) {
|
||||
UpdateClientDecorationHints(static_cast<ClientFrameViewLinux*>(
|
||||
native_window_view_->widget()->non_client_view()->frame_view()));
|
||||
}
|
||||
|
||||
SizeConstraintsChanged();
|
||||
SizeConstraintsChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void ElectronDesktopWindowTreeHostLinux::UpdateClientDecorationHints(
|
||||
|
||||
Reference in New Issue
Block a user