electron/shell/common/electron_constants.h
Maksim Sisov 3ea623364b
feat: support global shortcuts via GlobalShortcutsPortal feature with ozone/wayland (#45171)
* fix: backport patch to fix systemd unit activation in Chromium

This backports a patch from Chromium, which fixes systemd unit
activation. That is, a globalShortcuts feature that Chromium has
needs to create a systemd unit and rename it properly. Portal's
global shortcuts uses that name afterwards to map the app with
the shortcuts bound. However, there might be a race between
Chromium binding shortcuts and renaming the unit.

This is a first step to add Portal's globalShortcuts to
Electron.

* feat: Support global shortcuts via GlobalShortcutsPortal feature

Chromium has a new feature called GlobalShortcutsPortal. It
allows clients to use Portal's globalShortcuts to register and
listen to shortcuts.

This patches adds necessary bits, which allows Electron to
use that feature.

In order to make it work, one has to add
--enable-features=GlobalShortcutsPortal

Test: tested manually with a sample app.

* docs: add GlobalShortcutsPortal feature to globalShortcuts docs

Electron supports Portal's globalShortcuts API now via Chromium, and Electron
apps can use that in a Wayland session. Update the docs with the required
feature flag that must be passed to be able to use that implementation.
2025-01-22 11:59:48 +01:00

42 lines
1.5 KiB
C++

// Copyright (c) 2015 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef ELECTRON_SHELL_COMMON_ELECTRON_CONSTANTS_H_
#define ELECTRON_SHELL_COMMON_ELECTRON_CONSTANTS_H_
#include <string_view>
#include "base/strings/cstring_view.h"
#include "electron/buildflags/buildflags.h"
namespace electron {
// The app-command in NativeWindow.
inline constexpr std::string_view kBrowserForward = "browser-forward";
inline constexpr std::string_view kBrowserBackward = "browser-backward";
// Keys for Device APIs
inline constexpr std::string_view kDeviceVendorIdKey = "vendorId";
inline constexpr std::string_view kDeviceProductIdKey = "productId";
inline constexpr std::string_view kDeviceSerialNumberKey = "serialNumber";
inline constexpr base::cstring_view kRunAsNode = "ELECTRON_RUN_AS_NODE";
// Per-profile UUID to distinguish global shortcut sessions for
// org.freedesktop.portal.GlobalShortcuts. This is a counterpart to
// extensions::pref_names::kGlobalShortcutsUuid, which may be not defined
// if extensions are disabled.
inline constexpr char kElectronGlobalShortcutsUuid[] =
"electron.global_shortcuts.uuid";
#if BUILDFLAG(ENABLE_PDF_VIEWER)
inline constexpr std::string_view kPDFExtensionPluginName =
"Chromium PDF Viewer";
inline constexpr std::string_view kPDFInternalPluginName =
"Chromium PDF Plugin";
#endif // BUILDFLAG(ENABLE_PDF_VIEWER)
} // namespace electron
#endif // ELECTRON_SHELL_COMMON_ELECTRON_CONSTANTS_H_