Skip to content

Commit

Permalink
Bug 1882033 - Set the override-redirect and skip-taskbar hints for al…
Browse files Browse the repository at this point in the history
…erts. r=stransky

This prevents some WMs from stealing focus, see
qtile/qtile#4662

Differential Revision: https://phabricator.services.mozilla.com/D202701
  • Loading branch information
emilio committed Feb 27, 2024
1 parent 7887f9e commit d90370e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion widget/gtk/nsWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ nsWindow::nsWindow()
mIsDragPopup(false),
mCompositedScreen(gdk_screen_is_composited(gdk_screen_get_default())),
mIsAccelerated(false),
mIsAlert(false),
mWindowShouldStartDragging(false),
mHasMappedToplevel(false),
mRetryPointerGrab(false),
Expand Down Expand Up @@ -5855,6 +5856,10 @@ void nsWindow::ConfigureGdkWindow() {
EnsureGdkWindow();
OnScaleChanged(/* aNotify = */ false);

if (mIsAlert) {
gdk_window_set_override_redirect(mGdkWindow, TRUE);
}

#ifdef MOZ_X11
if (GdkIsX11Display()) {
GdkVisual* gdkVisual = gdk_window_get_visual(mGdkWindow);
Expand Down Expand Up @@ -6003,6 +6008,7 @@ nsresult nsWindow::Create(nsIWidget* aParent, nsNativeWidget aNativeParent,
// and can be changed so we use WaylandPopupIsPermanent() to get
// recent popup config (Bug 1728952).
mNoAutoHide = aInitData && aInitData->mNoAutoHide;
mIsAlert = aInitData && aInitData->mIsAlert;

// Popups that are not noautohide are only temporary. The are used
// for menus and the like and disappear when another window is used.
Expand Down Expand Up @@ -6092,10 +6098,11 @@ nsresult nsWindow::Create(nsIWidget* aParent, nsNativeWidget aNativeParent,
if (mIsPIPWindow) {
LOG(" Is PIP window\n");
gtk_window_set_type_hint(GTK_WINDOW(mShell), GDK_WINDOW_TYPE_HINT_UTILITY);
} else if (aInitData && aInitData->mIsAlert) {
} else if (mIsAlert) {
LOG(" Is alert window\n");
gtk_window_set_type_hint(GTK_WINDOW(mShell),
GDK_WINDOW_TYPE_HINT_NOTIFICATION);
gtk_window_set_skip_taskbar_hint(GTK_WINDOW(mShell), TRUE);
} else if (mWindowType == WindowType::Dialog) {
mGtkWindowRoleName = "Dialog";

Expand Down
1 change: 1 addition & 0 deletions widget/gtk/nsWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,7 @@ class nsWindow final : public nsBaseWidget {
bool mIsDragPopup : 1;
bool mCompositedScreen : 1;
bool mIsAccelerated : 1;
bool mIsAlert : 1;
bool mWindowShouldStartDragging : 1;
bool mHasMappedToplevel : 1;
bool mRetryPointerGrab : 1;
Expand Down

0 comments on commit d90370e

Please sign in to comment.