refactor: use base::fixed_flat_set in NativeWindowViews::SetAlwaysOnTop()
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
* refactor: use in-class member initialization for NativeWindow::widget_
Co-authored-by: Charles Kerr <charles@charleskerr.com>
* refactor: make NativeWindow::transparent_ const
refactor: make NativeWindow::enable_larger_than_screen_ const
Co-authored-by: Charles Kerr <charles@charleskerr.com>
* chore: make linter happy after rebase
Co-authored-by: Charles Kerr <charles@charleskerr.com>
---------
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
* refactor: use base::circular_deque in ResolveProxyHelper
Co-authored-by: Charles Kerr <charles@charleskerr.com>
* refactor: use base::circular_deque in GetExtraCrashKeys()
refactor: reduce visibility of kMaxCrashKeyValueSize
This change is to match Chromium's usage advice from
base/containers/README.md: `base:circular_deque` is preferred over
`std::deque` to provide consistent performance across platforms.
Co-authored-by: Charles Kerr <charles@charleskerr.com>
---------
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
refactor: make NativeWindow::pending_transitions a base::queue
Follow the base/containers/README.md advice that "Chromium code should
always use `base::circular_deque` or `base::queue` in preference to
`std::deque` or `std::queue` due to memory usage and platform variation."
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
* refactor: make NativeWindow::has_client_frame_ const
Co-authored-by: Charles Kerr <charles@charleskerr.com>
* refactor: make NativeWindow::has_client_frame_ const but not constexpr
Co-authored-by: Charles Kerr <charles@charleskerr.com>
---------
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
GTK >= 3.90.0 removed support for menuitem icons. When Electron is
built with GTK >= 3.90.0, our code builds these icons and then throws
them away unused. Instead, let's just not build them.
Our gtk_util::GdkPixbufFromSkBitmap utility uses BGRAToRGBA and is
expensive to call.
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
* refactor: make TrackableObject::weak_map_id() constexpr
refactor: make BaseWindow::GetID() inline and constexpr
Co-authored-by: Charles Kerr <charles@charleskerr.com>
* refactor: make NativeWindow::window_id() constexpr too
Co-authored-by: Charles Kerr <charles@charleskerr.com>
---------
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
The GlobalMenuBar used to hold a raw_ptr reference to its NativeWindow;
but since it doesn't use it & only wants the gfx::AcceleratedWidget info,
let's remove the NativeWindowViews reference.
AFAICT, GlobalMenuBarX11::window_ has never been used
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
feat: enable innerWidth and innerHeight for window open (#46749)
* feat: enable innerWidth and innerHeight for window open
* update comment for added special innerWidth and innerHeight
* update 100 min spec requirement handling
* update testing to include getContentSize
* update macOS min requirement handling
* adjust refactored consts
* update const values from nativewindowviews
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Michaela Laurencin <35157522+mlaurencin@users.noreply.github.com>
We probably didn't use this before because IsAltModifier() was written
two years before the KeyModifiers mask was added upstream in 98ec378a.
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
Fixes https://github.com/electron/electron/issues/45990
We previously made a change in https://github.com/electron/electron/pull/45868
to fix content protection being lost on hide and re-show. However, this
cause a breaking change where protected windows were made opaque black
instead of being hidden as before. This overrides relevant methods in
ElectronDesktopWindowTreeHostWin to restore the previous behavior.
without regressing the original issue.
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
refactor: use `gin_helper::Dictionary::ValueOrDefault()` (#46982)
* refactor: use ValueOrDefault() in electron_api_web_contents.cc
* refactor: use ValueOrDefault() in electron_api_url_loader.cc
* refactor: use ValueOrDefault() in electron_download_manager_delegate.cc
* refactor: use ValueOrDefault() in electron_touch_bar.mm
* refactor: use ValueOrDefault() in electron_url_loader_factory.cc
* refactor: use ValueOrDefault() in electron_browser_context.cc
* refactor: use ValueOrDefault() in electron_touch_bar.mm
* refactor: use ValueOrDefault() in blink_converter.cc
* feat: add ValueOrDefault() to PersistentDictionary
* empty commit
* refactor: use ValueOrDefault() in blink_converter.cc
* refactor: inline the rectangle base::Value::Dict
* refactor: remove has_scroll temporary
---------
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
* refactor: do not use native_widget_private() in NativeWindowViews::SetContentProtection()
refactor: do not use native_widget_private() in NativeWindowViews::IsContentProtected()
Co-authored-by: Charles Kerr <charles@charleskerr.com>
* refactor: do not use native_widget_private() in NativeWindowViews::Show()
Co-authored-by: Charles Kerr <charles@charleskerr.com>
* chore: remove native_widget_private #include from native_window_views_win
Not needed since Feb 2025: 9199d5c6
Co-authored-by: Charles Kerr <charles@charleskerr.com>
---------
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
* feat: add gin_helper::Dictionary::ValueOrDefault()
A convenience function for using a default value if the
specified key isn't present in the dictionary.
Co-authored-by: Charles Kerr <charles@charleskerr.com>
* refactor: use ValueOrDefault() in native_window.cc
Co-authored-by: Charles Kerr <charles@charleskerr.com>
* refactor: use ValueOrDefault() in native_window_mac.mm
Co-authored-by: Charles Kerr <charles@charleskerr.com>
* refactor: use ValueOrDefault() in native_window_views.cc
Co-authored-by: Charles Kerr <charles@charleskerr.com>
* refactor: use ValueOrDefault() in electron_api_native_image.cc
Co-authored-by: Charles Kerr <charles@charleskerr.com>
---------
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
refactor: pass gfx::ResizeEdge by value
It is an enum class, so no reason to pass by reference
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
refactor: remove some `NativeWindow` public API (#46919)
* refactor: make NativeWindow::titlebar_overlay_height_ private
* refactor: make NativeWindow::set_has_frame() protected
* refactor: remove NativeWindow::background_material()
It's only used once, in NativeWindow, so use |background_material_| directly.
* refactor: remove NativeWindow::vibrancy()
It's only used once, in a NativeWindow method, so use |vibrancy_| directly.
* refactor: unfriend api::BrowserView
It was added in Oct 2022 by 23d4a25 for access to protected NativeWindow
methods add_inspectable_view() and remove_inspectable_view().
That dependency was removed in Nov 2022 by 184ac2b, so BrowserView
doesn't need access to NativeWindow's private fields & methods anymore.
* refactor: make NativeWindow::ContentBoundsToWindowBounds() protected
refactor: make NativeWindow::WindowBoundsToContentBounds() protected
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
refactor: add `NativeWindow::FromWidget()` helper (#46917)
refactor: add NativeWindow::FromWidet() helper
refactor: make kElectronNativeWindowKey a protected field
* refactor: use ObserverList::Notify() in shell/browser/window_list.cc
Co-authored-by: Charles Kerr <charles@charleskerr.com>
* refactor: use ObserverList::Notify() in shell/browser/web_contents_zoom_controller.cc
Co-authored-by: Charles Kerr <charles@charleskerr.com>
* refactor: use ObserverList::Notify() in shell/browser/usb/usb_chooser_context.cc
Co-authored-by: Charles Kerr <charles@charleskerr.com>
* refactor: use ObserverList::Notify() in shell/browser/usb/electron_usb_delegate.cc
Co-authored-by: Charles Kerr <charles@charleskerr.com>
* refactor: use ObserverList::Notify() in shell/browser/ui/views/menu_delegate.cc
Co-authored-by: Charles Kerr <charles@charleskerr.com>
* refactor: use ObserverList::Notify() in shell/browser/ui/tray_icon.cc
Co-authored-by: Charles Kerr <charles@charleskerr.com>
* refactor: use ObserverList::Notify() in shell/browser/ui/electron_menu_model.cc
Co-authored-by: Charles Kerr <charles@charleskerr.com>
* refactor: use ObserverList::Notify() in shell/browser/serial/serial_chooser_context.cc
Co-authored-by: Charles Kerr <charles@charleskerr.com>
* refactor: use ObserverList::Notify() in shell/browser/native_window.cc
Co-authored-by: Charles Kerr <charles@charleskerr.com>
* refactor: use ObserverList::Notify() in shell/browser/serial/electron_serial_delegate.cc
Co-authored-by: Charles Kerr <charles@charleskerr.com>
* refactor: use ObserverList::Notify() in shell/browser/browser.cc
Co-authored-by: Charles Kerr <charles@charleskerr.com>
* refactor: use ObserverList::Notify() in shell/browser/api/electron_api_web_contents.cc
Co-authored-by: Charles Kerr <charles@charleskerr.com>
* refactor: use ObserverList::Notify() in shell/browser/hid/electron_hid_delegate.cc
Co-authored-by: Charles Kerr <charles@charleskerr.com>
* refactor: use ObserverList::Notify() in shell/browser/hid/hid_chooser_context.cc
Co-authored-by: Charles Kerr <charles@charleskerr.com>
---------
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
* refactor: add EmitDeprecationWarning helper
Also switches EmitWarning to using Node's ProcessEmitWarningGeneric
Co-authored-by: David Sanders <dsanders11@ucsbalum.com>
* chore: use node namespace for function call
Co-authored-by: David Sanders <dsanders11@ucsbalum.com>
---------
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: David Sanders <dsanders11@ucsbalum.com>
* test: do not skip visibleOnAllWorkspaces tests on Windows
That feature is supported on Linux, so move the test from the
"window states (excluding Linux)" section into the
"window states" section.
Co-authored-by: Charles Kerr <charles@charleskerr.com>
* chore: disable visibleOnAllWorkspaces test on Linux
* fix: NativeWindowViews::IsVisibleOnAllWorkspaces
* test: enable visibleOnAllWorkspaces tests on Linux
---------
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
fix: bluetooth crash on bluetooth off
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
WebView uses WebContentsViewChildFrame, which doesn't have a Focus impl
and triggers a fatal NOTREACHED.
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Jinli Wu <wujinli@bytedance.com>
* refactor: add electron::Buffer namespace; move the Buffer as_byte_span() into it
Co-authored-by: Charles Kerr <charles@charleskerr.com>
* feat: add electron::Buffer::Copy()
a span-friendly version of node::Buffer::Copy()
Co-authored-by: Charles Kerr <charles@charleskerr.com>
* refactor: use electron::Buffer::Copy() in electron_api_base_window.cc
Co-authored-by: Charles Kerr <charles@charleskerr.com>
* refactor: use electron::Buffer::Copy() in electron_api_data_pipe_holder.cc
Co-authored-by: Charles Kerr <charles@charleskerr.com>
* refactor: use electron::Buffer::Copy() in electron_api_safe_storage.cc
Co-authored-by: Charles Kerr <charles@charleskerr.com>
* refactor: use electron::Buffer::Copy() in electron_api_clipboard.cc
Co-authored-by: Charles Kerr <charles@charleskerr.com>
* refactor: use electron::Buffer::Copy() in osr_converter.cc
Co-authored-by: Charles Kerr <charles@charleskerr.com>
* refactor: use electron::Buffer::Copy() in electron_api_native_image.cc
Co-authored-by: Charles Kerr <charles@charleskerr.com>
* refactor: use electron::Buffer::Copy() in net_converter.cc
Co-authored-by: Charles Kerr <charles@charleskerr.com>
* refactor: use electron::Buffer::Copy() in electron_api_web_contents.cc
Co-authored-by: Charles Kerr <charles@charleskerr.com>
* refactor: make NewEmptyBuffer() return a Local<Value>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
---------
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
* fix: explicitly call GetNativeNSView() on macOS
Co-authored-by: Charles Kerr <charles@charleskerr.com>
* chore: move macOS impl to a .mm file
This is needed in order to access gfx::NativeView::GetNativeNSView()
Co-authored-by: Charles Kerr <charles@charleskerr.com>
---------
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>