mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
* chore: bump chromium in DEPS to 117.0.5866.0 * chore: bump chromium in DEPS to 117.0.5868.0 * chore: update mas_no_private_api.patch Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4634925 Minor manual patch syncing due to upstream code shear * chore: update mas_disable_remote_layer.patch Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4647191 Manually sync patch to minor upstream code shear * chore: update mas_disable_remote_accessibility.patch Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4641746 No manual changes; patch applied with fuzz * chore: update mas_avoid_usage_of_private_macos_apis.patch Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4634925 Manually sync base/process/launch_mac.cc to minor upstream shear Manually sync base/mac/foundation_util.mm to upstream changes: _CFIsObjC use has been removed upstream, so we no longer need to remove it 🎉 * chore: update printing.patch Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4658496 Manually sync patch to minor upstream code shear * chore: update disable_color_correct_rendering.patch Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4625254 Manually sync patch to minor upstream code shear * chore: update feat_expose_raw_response_headers_from_urlloader.patch Xref: services/network/public/cpp/resource_request.cc No manual changes; patch applied with fuzz * chore: update add_electron_deps_to_license_credits_file.patch Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4634961 No manual changes; patch applied with fuzz * chore: update build_only_use_the_mas_build_config_in_the_required_components.patch Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4648411 No manual changes; patch applied with fuzz * chore: update patches * fixup! chore: update add_electron_deps_to_license_credits_file.patch chore: license files must be an array * chore: bump chromium in DEPS to 117.0.5870.0 * chore: update patches * chore: run ./script/gen-libc++-filenames.js * chore: update json_parse_errors_made_user-friendly.patch Xref: https://chromium-review.googlesource.com/c/v8/v8/+/4652014 v8 error message changed upstream; update Node test to match it * chore: bump chromium in DEPS to 117.0.5872.0 * chore: update patches * chore: explicitly cast x11::Window to unsigned int Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4661049 This is an `enum class Window : uint32_t` defined in ui/gfx/x/xproto.h. Previous versions of clang let this implicit cast happen, but it generates a warning in the new clang roll. * chore: remove unused #include Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4650453 header was removed upstream, so FTBFS unless removed here * chore: add include guard patch Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4628373 h/t @jkleinsc * chore: bump chromium in DEPS to 117.0.5874.0 * chore: update render_widget_host_view_mac.patch Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4661244 Manually sync patch to minor upstream code * chore: update mas_disable_remote_accessibility.patch Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4653209 Manually sync patch to upstream code shear * chore: update build_only_use_the_mas_build_config_in_the_required_components.patch Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4653209 Manually sync patch to minor upstream code shear * chore: update GetInitiatorProcessId() Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4641991 trivial upstream naming change: s/ProcessID/ProcessId/ * chore: sync to upstream SetInputRegion() changes Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4665245 Simple upstream chang: SetInputRegion() used to take a gfx::Rect* where `nullptr` meant "no opaque region". The function signature changed to absl::optional<gfx::Rect> w/the same meaning. * chore: sync to upstream SetOpaqueRegion() changes Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4656738 Simple upstream chang: SetOpaqueRegion() used to take a vector<Rect>* where `nullptr` meant "no opaque region". The function signature changed to absl::optional<std::vector<gfx::Rect>> w/the same meaning. * chore: update patches * chore: bump chromium in DEPS to 117.0.5876.0 * chore: update mas_disable_remote_accessibility.patch Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4658375 We no longer need to patch out a field that's now removed upstream. RenderWidgetHostNSViewBridgeOwner.remote_accessibility_element_ * chore: update feat_filter_out_non-shareable_windows_in_the_current_application_in.patch Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4658680 Manually sync patch to upstream code shear (ARC adoption). * chore: update patches * fix: -Werror,-Wshadow error in Node.js * chore: bump chromium in DEPS to 117.0.5878.0 * chore: bump chromium in DEPS to 117.0.5880.0 * chore: bump chromium in DEPS to 117.0.5880.4 * chore: update patches * 4658680: Convert /content/browser to use ARC https://chromium-review.googlesource.com/c/chromium/src/+/4658680 * 4669995: Remove CFToNSCast and NSToCFCast https://chromium-review.googlesource.com/c/chromium/src/+/4669995 * WIP: 4658680: Convert /content/browser to use ARC https://chromium-review.googlesource.com/c/chromium/src/+/4658680 * chore: update printing patch after rebase * chore: bump chromium in DEPS to 117.0.5882.0 * Revert "WIP: 4658680: Convert /content/browser to use ARC" This reverts commitc8559ea448. * Revert "4669995: Remove CFToNSCast and NSToCFCast" This reverts commit38e145f33d. * chore: bump chromium in DEPS to 117.0.5874.0 * 4661244: Convert /content/browser/renderer_host to use ARC https://chromium-review.googlesource.com/c/chromium/src/+/4661244 * 4653209: Convert /ui/views:views to use ARC https://chromium-review.googlesource.com/c/chromium/src/+/4653209 * chore: fixup mas_disable_remote_accessibility.patch * chore: fixup render_widget_host_view_mac.patch * chore: update to newer clang * chore: bump chromium in DEPS to 117.0.5884.1 (cherry picked from commit a3879acfde8f3d962d58d6ad0632164ccb88ee63) * 4669995: Remove CFToNSCast and NSToCFCast https://chromium-review.googlesource.com/c/chromium/src/+/4669995 (cherry picked from commit38e145f33d) (cherry picked from commit b1224ab7e00aedbd0e5dc78ebb3c6162573b28c4) * 4658680: Convert /content/browser to use ARC https://chromium-review.googlesource.com/c/chromium/src/+/4658680 (cherry picked from commit 77039a323b9ebb3e8edb3a92a3b94a8d7d026a32) * Rename and cleanup ExtensionsBrowserClient functions | https://chromium-review.googlesource.com/c/chromium/src/+/4665670 (cherry picked from commit 677a2e646a8d82da60dc252b08b320c3ddff6be6) * chore: bump chromium in DEPS to 117.0.5886.0 * chore: update patches * Revert "chore: update patches" This reverts commitdb9294f944. * Revert "chore: bump chromium in DEPS to 117.0.5886.0" This reverts commita7de0276e6. * build: use built toolchains instead of locally installed VSCode * fixup: build: use built toolchains instead of locally installed VSCode * chore: add missing mojo dep --------- Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com> Co-authored-by: Charles Kerr <charles@charleskerr.com> Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
232 lines
8.1 KiB
C++
232 lines
8.1 KiB
C++
// Copyright (c) 2021 Ryan Gonzalez.
|
|
// Use of this source code is governed by the MIT license that can be
|
|
// found in the LICENSE file.
|
|
// Portions of this file are sourced from
|
|
// chrome/browser/ui/views/frame/browser_desktop_window_tree_host_linux.cc,
|
|
// Copyright (c) 2019 The Chromium Authors,
|
|
// which is governed by a BSD-style license
|
|
|
|
#include "shell/browser/ui/electron_desktop_window_tree_host_linux.h"
|
|
|
|
#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"
|
|
#include "ui/linux/linux_ui.h"
|
|
#include "ui/platform_window/platform_window.h"
|
|
#include "ui/views/widget/desktop_aura/desktop_window_tree_host.h"
|
|
#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(
|
|
NativeWindowViews* native_window_view,
|
|
views::DesktopNativeWidgetAura* desktop_native_widget_aura)
|
|
: views::DesktopWindowTreeHostLinux(native_window_view->widget(),
|
|
desktop_native_widget_aura),
|
|
native_window_view_(native_window_view) {}
|
|
|
|
ElectronDesktopWindowTreeHostLinux::~ElectronDesktopWindowTreeHostLinux() =
|
|
default;
|
|
|
|
bool ElectronDesktopWindowTreeHostLinux::SupportsClientFrameShadow() const {
|
|
return platform_window()->CanSetDecorationInsets() &&
|
|
platform_window()->IsTranslucentWindowOpacitySupported();
|
|
}
|
|
|
|
void ElectronDesktopWindowTreeHostLinux::OnWidgetInitDone() {
|
|
views::DesktopWindowTreeHostLinux::OnWidgetInitDone();
|
|
UpdateFrameHints();
|
|
}
|
|
|
|
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(
|
|
ui::PlatformWindowState old_state,
|
|
ui::PlatformWindowState new_state) {
|
|
views::DesktopWindowTreeHostLinux::OnWindowStateChanged(old_state, new_state);
|
|
UpdateFrameHints();
|
|
UpdateWindowState(new_state);
|
|
}
|
|
|
|
void ElectronDesktopWindowTreeHostLinux::OnWindowTiledStateChanged(
|
|
ui::WindowTiledEdges new_tiled_edges) {
|
|
static_cast<ClientFrameViewLinux*>(
|
|
native_window_view_->widget()->non_client_view()->frame_view())
|
|
->set_tiled_edges(new_tiled_edges);
|
|
UpdateFrameHints();
|
|
}
|
|
|
|
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:
|
|
case ui::PlatformWindowState::kSnappedPrimary:
|
|
case ui::PlatformWindowState::kSnappedSecondary:
|
|
case ui::PlatformWindowState::kFloated:
|
|
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:
|
|
case ui::PlatformWindowState::kSnappedPrimary:
|
|
case ui::PlatformWindowState::kSnappedSecondary:
|
|
case ui::PlatformWindowState::kFloated:
|
|
break;
|
|
}
|
|
window_state_ = new_state;
|
|
}
|
|
|
|
void ElectronDesktopWindowTreeHostLinux::OnNativeThemeUpdated(
|
|
ui::NativeTheme* observed_theme) {
|
|
UpdateFrameHints();
|
|
}
|
|
|
|
void ElectronDesktopWindowTreeHostLinux::OnDeviceScaleFactorChanged() {
|
|
UpdateFrameHints();
|
|
}
|
|
|
|
void ElectronDesktopWindowTreeHostLinux::UpdateFrameHints() {
|
|
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();
|
|
}
|
|
}
|
|
|
|
void ElectronDesktopWindowTreeHostLinux::UpdateClientDecorationHints(
|
|
ClientFrameViewLinux* view) {
|
|
ui::PlatformWindow* window = platform_window();
|
|
bool showing_frame = !native_window_view_->IsFullscreen();
|
|
float scale = device_scale_factor();
|
|
|
|
bool should_set_opaque_region = window->IsTranslucentWindowOpacitySupported();
|
|
|
|
gfx::Insets insets;
|
|
gfx::Insets input_insets;
|
|
if (showing_frame) {
|
|
insets = view->GetBorderDecorationInsets();
|
|
if (base::i18n::IsRTL()) {
|
|
insets.set_left_right(insets.right(), insets.left());
|
|
}
|
|
|
|
input_insets = view->GetInputInsets();
|
|
}
|
|
const auto tiled_edges = view->tiled_edges();
|
|
if (tiled_edges.left)
|
|
insets.set_left(0);
|
|
if (tiled_edges.right)
|
|
insets.set_right(0);
|
|
if (tiled_edges.top)
|
|
insets.set_top(0);
|
|
if (tiled_edges.bottom)
|
|
insets.set_bottom(0);
|
|
gfx::Insets scaled_insets = gfx::ScaleToCeiledInsets(insets, scale);
|
|
window->SetDecorationInsets(&scaled_insets);
|
|
|
|
gfx::Rect input_bounds(view->GetWidget()->GetWindowBoundsInScreen().size());
|
|
input_bounds.Inset(insets + input_insets);
|
|
window->SetInputRegion(gfx::ScaleToEnclosingRect(input_bounds, scale));
|
|
|
|
if (should_set_opaque_region) {
|
|
// The opaque region is a list of rectangles that contain only fully
|
|
// opaque pixels of the window. We need to convert the clipping
|
|
// rounded-rect into this format.
|
|
SkRRect rrect = view->GetRoundedWindowContentBounds();
|
|
gfx::RectF rectf(view->GetWindowContentBounds());
|
|
rectf.Scale(scale);
|
|
// It is acceptable to omit some pixels that are opaque, but the region
|
|
// must not include any translucent pixels. Therefore, we must
|
|
// conservatively scale to the enclosed rectangle.
|
|
gfx::Rect rect = gfx::ToEnclosedRect(rectf);
|
|
|
|
// Create the initial region from the clipping rectangle without rounded
|
|
// corners.
|
|
SkRegion region(gfx::RectToSkIRect(rect));
|
|
|
|
// Now subtract out the small rectangles that cover the corners.
|
|
struct {
|
|
SkRRect::Corner corner;
|
|
bool left;
|
|
bool upper;
|
|
} kCorners[] = {
|
|
{SkRRect::kUpperLeft_Corner, true, true},
|
|
{SkRRect::kUpperRight_Corner, false, true},
|
|
{SkRRect::kLowerLeft_Corner, true, false},
|
|
{SkRRect::kLowerRight_Corner, false, false},
|
|
};
|
|
for (const auto& corner : kCorners) {
|
|
auto radii = rrect.radii(corner.corner);
|
|
auto rx = std::ceil(scale * radii.x());
|
|
auto ry = std::ceil(scale * radii.y());
|
|
auto corner_rect = SkIRect::MakeXYWH(
|
|
corner.left ? rect.x() : rect.right() - rx,
|
|
corner.upper ? rect.y() : rect.bottom() - ry, rx, ry);
|
|
region.op(corner_rect, SkRegion::kDifference_Op);
|
|
}
|
|
|
|
// Convert the region to a list of rectangles.
|
|
std::vector<gfx::Rect> opaque_region;
|
|
for (SkRegion::Iterator i(region); !i.done(); i.next())
|
|
opaque_region.emplace_back(gfx::SkIRectToRect(i.rect()));
|
|
window->SetOpaqueRegion(opaque_region);
|
|
}
|
|
}
|
|
|
|
} // namespace electron
|