Call xcb_set_input_focus rather than setting X11BypassWindowManagerHint
Setting the hint has some side effects, unfortunately...
This commit is contained in:
parent
f82162f05a
commit
2dcad89d3c
1 changed files with 17 additions and 22 deletions
|
|
@ -11,9 +11,12 @@
|
||||||
#include "base/invoke_queued.h"
|
#include "base/invoke_queued.h"
|
||||||
#include "base/platform/base_platform_info.h"
|
#include "base/platform/base_platform_info.h"
|
||||||
|
|
||||||
|
#ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION
|
||||||
|
#include "base/platform/linux/base_linux_xcb_utilities.h"
|
||||||
|
#endif // !DESKTOP_APP_DISABLE_X11_INTEGRATION
|
||||||
|
|
||||||
#include <QtCore/QPointer>
|
#include <QtCore/QPointer>
|
||||||
#include <QtGui/QGuiApplication>
|
#include <QtWidgets/QApplication>
|
||||||
#include <QtGui/QWindow>
|
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
@ -43,15 +46,11 @@ void ActivateWindowDelayed(not_null<QWidget*> widget) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto focusAncestor = [&] {
|
const auto focusAncestor = [&] {
|
||||||
const auto focusWindow = QGuiApplication::focusWindow();
|
const auto focusWidget = QApplication::focusWidget();
|
||||||
if (!focusWindow || !widget->window()) {
|
if (!focusWidget || !widget->window()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const auto handle = widget->window()->windowHandle();
|
return widget->window()->isAncestorOf(focusWidget);
|
||||||
if (!handle) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return handle->isAncestorOf(focusWindow);
|
|
||||||
}();
|
}();
|
||||||
crl::on_main(Window, [=] {
|
crl::on_main(Window, [=] {
|
||||||
const auto widget = base::take(Window);
|
const auto widget = base::take(Window);
|
||||||
|
|
@ -62,21 +61,17 @@ void ActivateWindowDelayed(not_null<QWidget*> widget) {
|
||||||
if (!window || window->isHidden()) {
|
if (!window || window->isHidden()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto guard = [&] {
|
|
||||||
if (!::Platform::IsX11() || !focusAncestor) {
|
|
||||||
return gsl::finally(Fn<void()>([] {}));
|
|
||||||
}
|
|
||||||
const auto handle = window->windowHandle();
|
|
||||||
if (handle->flags() & Qt::X11BypassWindowManagerHint) {
|
|
||||||
return gsl::finally(Fn<void()>([] {}));
|
|
||||||
}
|
|
||||||
handle->setFlag(Qt::X11BypassWindowManagerHint);
|
|
||||||
return gsl::finally(Fn<void()>([handle] {
|
|
||||||
handle->setFlag(Qt::X11BypassWindowManagerHint, false);
|
|
||||||
}));
|
|
||||||
}();
|
|
||||||
window->raise();
|
window->raise();
|
||||||
window->activateWindow();
|
window->activateWindow();
|
||||||
|
#ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION
|
||||||
|
if (::Platform::IsX11() && focusAncestor) {
|
||||||
|
xcb_set_input_focus(
|
||||||
|
base::Platform::XCB::GetConnectionFromQt(),
|
||||||
|
XCB_INPUT_FOCUS_PARENT,
|
||||||
|
window->winId(),
|
||||||
|
XCB_CURRENT_TIME);
|
||||||
|
}
|
||||||
|
#endif // !DESKTOP_APP_DISABLE_X11_INTEGRATION
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue