a4de915b74
* chore: bump chromium in DEPS to db7d7b3e7cb2bc925f2abfde526280cfdfc21a41 * Update patches * chore: bump chromium in DEPS to 5613e1b99a44fcbe22f3910f803ca76903a77ec1 * Update patches * Network service: Remove primary_network_context bool. https://chromium-review.googlesource.com/c/chromium/src/+/2204678 * WebContentsObserver now implements OnRendererResponsive https://chromium-review.googlesource.com/c/chromium/src/+/2211066 * update patches * Fixup printing patch * chore: bump chromium in DEPS to e387b972cdd7160c416fa6c64a724e2258aa0218 * update patches * [printing] Move PrintHostMsg_DidPrintContent_Params to print.mojom https://chromium-review.googlesource.com/c/chromium/src/+/2212110 * [XProto] Move items from ::x11::XProto to ::x11 https://chromium-review.googlesource.com/c/chromium/src/+/2218476 * revert Add IChromeAccessible This was added in https://chromium-review.googlesource.com/c/chromium/src/+/2206224 but it breaks WOA builds because third_party/win_build_output/midl/ui/accessibility/platform/arm64 does not exist. The link above says that the new interface is behind a feature flag which is disabled by default so it is safe to remove for now. * rebaseline ichromeaccessible for Windows arm64 This patch will not be needed once we get the next roll. * Update to 1b9e01844e8bf1aaafc4a52c0c62af7f56d9637b to get arm64 fix * update patches * chore: bump chromium in DEPS to 096aefa04092ea00f7b68d8d19345883f20db3c3 * chore: bump chromium in DEPS to a524a45ffd1d6fd46a7a86138fe2b22df5b6651a * chore: update patches * Window Placement: Gate cross-screen fullscreen behavior on permission https://chromium-review.googlesource.com/c/chromium/src/+/2203268 * chore: add spec for https://crbug.com/1085836 * chore: bump chromium in DEPS to ff6c4f4b826d66c2e32380bf5d1eb5e1fe37faef * update patches Co-authored-by: John Kleinschmidt <jkleinsc@github.com> Co-authored-by: Electron Bot <anonymous@electronjs.org> Co-authored-by: deepak1556 <hop2deep@gmail.com>
116 lines
3.6 KiB
C++
116 lines
3.6 KiB
C++
// Copyright (c) 2014 GitHub, Inc.
|
|
// Use of this source code is governed by the MIT license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "shell/browser/ui/x/x_window_utils.h"
|
|
|
|
#include <X11/Xatom.h>
|
|
#include <memory>
|
|
|
|
#include "base/environment.h"
|
|
#include "base/strings/string_util.h"
|
|
#include "base/threading/thread_restrictions.h"
|
|
#include "dbus/bus.h"
|
|
#include "dbus/message.h"
|
|
#include "dbus/object_proxy.h"
|
|
#include "ui/base/x/x11_util.h"
|
|
#include "ui/gfx/x/x11_atom_cache.h"
|
|
|
|
namespace electron {
|
|
|
|
void SetWMSpecState(::Window xwindow, bool enabled, x11::Atom state) {
|
|
XEvent xclient;
|
|
memset(&xclient, 0, sizeof(xclient));
|
|
xclient.type = ClientMessage;
|
|
xclient.xclient.window = xwindow;
|
|
xclient.xclient.message_type =
|
|
static_cast<uint32_t>(gfx::GetAtom("_NET_WM_STATE"));
|
|
xclient.xclient.format = 32;
|
|
xclient.xclient.data.l[0] = enabled ? 1 : 0;
|
|
xclient.xclient.data.l[1] = static_cast<uint32_t>(state);
|
|
xclient.xclient.data.l[2] = x11::None;
|
|
xclient.xclient.data.l[3] = 1;
|
|
xclient.xclient.data.l[4] = 0;
|
|
|
|
XDisplay* xdisplay = gfx::GetXDisplay();
|
|
XSendEvent(xdisplay, DefaultRootWindow(xdisplay), x11::False,
|
|
SubstructureRedirectMask | SubstructureNotifyMask, &xclient);
|
|
}
|
|
|
|
void SetWindowType(::Window xwindow, const std::string& type) {
|
|
std::string type_prefix = "_NET_WM_WINDOW_TYPE_";
|
|
x11::Atom window_type = gfx::GetAtom(type_prefix + base::ToUpperASCII(type));
|
|
ui::SetProperty(xwindow, gfx::GetAtom("_NET_WM_WINDOW_TYPE"), x11::Atom::ATOM,
|
|
window_type);
|
|
}
|
|
|
|
bool ShouldUseGlobalMenuBar() {
|
|
base::ThreadRestrictions::ScopedAllowIO allow_io;
|
|
std::unique_ptr<base::Environment> env(base::Environment::Create());
|
|
if (env->HasVar("ELECTRON_FORCE_WINDOW_MENU_BAR"))
|
|
return false;
|
|
|
|
dbus::Bus::Options options;
|
|
scoped_refptr<dbus::Bus> bus(new dbus::Bus(options));
|
|
|
|
dbus::ObjectProxy* object_proxy =
|
|
bus->GetObjectProxy(DBUS_SERVICE_DBUS, dbus::ObjectPath(DBUS_PATH_DBUS));
|
|
dbus::MethodCall method_call(DBUS_INTERFACE_DBUS, "ListNames");
|
|
std::unique_ptr<dbus::Response> response(object_proxy->CallMethodAndBlock(
|
|
&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT));
|
|
if (!response) {
|
|
bus->ShutdownAndBlock();
|
|
return false;
|
|
}
|
|
|
|
dbus::MessageReader reader(response.get());
|
|
dbus::MessageReader array_reader(nullptr);
|
|
if (!reader.PopArray(&array_reader)) {
|
|
bus->ShutdownAndBlock();
|
|
return false;
|
|
}
|
|
while (array_reader.HasMoreData()) {
|
|
std::string name;
|
|
if (array_reader.PopString(&name) &&
|
|
name == "com.canonical.AppMenu.Registrar") {
|
|
bus->ShutdownAndBlock();
|
|
return true;
|
|
}
|
|
}
|
|
|
|
bus->ShutdownAndBlock();
|
|
return false;
|
|
}
|
|
|
|
void MoveWindowToForeground(::Window xwindow) {
|
|
MoveWindowAbove(xwindow, 0);
|
|
}
|
|
|
|
void MoveWindowAbove(::Window xwindow, ::Window other_xwindow) {
|
|
XDisplay* xdisplay = gfx::GetXDisplay();
|
|
XEvent xclient;
|
|
memset(&xclient, 0, sizeof(xclient));
|
|
|
|
xclient.type = ClientMessage;
|
|
xclient.xclient.display = xdisplay;
|
|
xclient.xclient.window = xwindow;
|
|
xclient.xclient.message_type =
|
|
static_cast<uint32_t>(gfx::GetAtom("_NET_RESTACK_WINDOW"));
|
|
xclient.xclient.format = 32;
|
|
xclient.xclient.data.l[0] = 2;
|
|
xclient.xclient.data.l[1] = other_xwindow;
|
|
xclient.xclient.data.l[2] = static_cast<uint32_t>(x11::StackMode::Above);
|
|
xclient.xclient.data.l[3] = 0;
|
|
xclient.xclient.data.l[4] = 0;
|
|
|
|
XSendEvent(xdisplay, DefaultRootWindow(xdisplay), x11::False,
|
|
SubstructureRedirectMask | SubstructureNotifyMask, &xclient);
|
|
XFlush(xdisplay);
|
|
}
|
|
|
|
bool IsWindowValid(::Window xwindow) {
|
|
XWindowAttributes attrs;
|
|
return XGetWindowAttributes(gfx::GetXDisplay(), xwindow, &attrs);
|
|
}
|
|
|
|
} // namespace electron
|