Bug 1641546 - Make sure alwaysontop windows don't pull focus when first opening on Linux GTK. r=stransky

Differential Revision: https://phabricator.services.mozilla.com/D77695
This commit is contained in:
Mike Conley 2020-06-05 09:16:30 +00:00
Родитель 459268dbff
Коммит daad35ae28
3 изменённых файлов: 17 добавлений и 2 удалений

Просмотреть файл

@ -524,6 +524,7 @@ STUB(gtk_window_set_accept_focus)
STUB(gtk_window_set_decorated)
STUB(gtk_window_set_deletable)
STUB(gtk_window_set_destroy_with_parent)
STUB(gtk_window_set_focus_on_map)
STUB(gtk_window_set_geometry_hints)
STUB(gtk_window_set_icon_name)
STUB(gtk_window_set_modal)

Просмотреть файл

@ -479,6 +479,7 @@ nsWindow::nsWindow() {
mHasAlphaVisual = false;
mIsPIPWindow = false;
mAlwaysOnTop = false;
mWindowScaleFactorChanged = true;
mWindowScaleFactor = 1;
@ -4177,6 +4178,7 @@ nsresult nsWindow::Create(nsIWidget* aParent, nsNativeWidget aNativeParent,
}
}
mAlwaysOnTop = aInitData && aInitData->mAlwaysOnTop;
mIsPIPWindow = aInitData && aInitData->mPIPWindow;
// ok, create our windows
@ -4394,7 +4396,7 @@ nsresult nsWindow::Create(nsIWidget* aParent, nsNativeWidget aNativeParent,
g_object_unref(group);
}
if (aInitData->mAlwaysOnTop) {
if (mAlwaysOnTop) {
gtk_window_set_keep_above(GTK_WINDOW(mShell), TRUE);
}
@ -4451,11 +4453,21 @@ nsresult nsWindow::Create(nsIWidget* aParent, nsNativeWidget aNativeParent,
gtk_widget_set_has_window(container, mDrawToContainer);
gtk_container_add(GTK_CONTAINER(mShell), container);
// alwaysontop windows are generally used for peripheral indicators,
// so we don't focus them by default.
if (mAlwaysOnTop) {
gtk_window_set_focus_on_map(GTK_WINDOW(mShell), FALSE);
}
gtk_widget_realize(container);
// make sure this is the focus widget in the container
gtk_widget_show(container);
gtk_widget_grab_focus(container);
if (!mAlwaysOnTop) {
gtk_widget_grab_focus(container);
}
// the drawing window
mGdkWindow = gtk_widget_get_window(eventWidget);
@ -4978,6 +4990,7 @@ void nsWindow::NativeShow(bool aAction) {
return;
}
}
gtk_widget_show(mShell);
if (!mIsX11Display) {
WaylandStartVsync();

Просмотреть файл

@ -581,6 +581,7 @@ class nsWindow final : public nsBaseWidget {
LayoutDeviceIntRegion mDraggableRegion;
// It's PictureInPicture window.
bool mIsPIPWindow;
bool mAlwaysOnTop;
#ifdef ACCESSIBILITY
RefPtr<mozilla::a11y::Accessible> mRootAccessible;