Skip to content

Commit

Permalink
macOS: Fix "on top" windows missing from Mission Control / Exposé
Browse files Browse the repository at this point in the history
  • Loading branch information
jdpurcell committed Jan 4, 2025
1 parent fe52bb5 commit 03202ac
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1412,6 +1412,11 @@ void MainWindow::toggleWindowOnTop()
for (const auto &action : qvApp->getActionManager().getAllClonesOfAction("windowontop", this))
action->setChecked(targetValue);

#ifdef COCOA_LOADED
// Make sure window still participates in Mission Control
QVCocoaFunctions::setWindowCollectionBehaviorManaged(this);
#endif

emit qvApp->windowOnTopChanged();
}

Expand Down
2 changes: 2 additions & 0 deletions src/qvcocoafunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class QVCocoaFunctions

static void setTitlebarHidden(QWidget *window, const bool hide);

static void setWindowCollectionBehaviorManaged(QWidget *window);

static void setVibrancy(bool alwaysDark, QWindow *window);

static int getObscuredHeight(QWindow *window);
Expand Down
8 changes: 8 additions & 0 deletions src/qvcocoafunctions.mm
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,14 @@ static void fixNativeMenuEccentricities(QMenu *menu, NSMenu *nativeMenu)
view.window.titleVisibility = hide ? NSWindowTitleHidden : NSWindowTitleVisible;
}

void QVCocoaFunctions::setWindowCollectionBehaviorManaged(QWidget *window)
{
auto *view = reinterpret_cast<NSView*>(window->winId());
view.window.collectionBehavior =
(view.window.collectionBehavior | NSWindowCollectionBehaviorManaged) &
~(NSWindowCollectionBehaviorTransient | NSWindowCollectionBehaviorStationary);
}

void QVCocoaFunctions::setVibrancy(bool alwaysDark, QWindow *window)
{
auto *view = reinterpret_cast<NSView*>(window->winId());
Expand Down

0 comments on commit 03202ac

Please sign in to comment.