Skip to content

Commit

Permalink
Fix embedding in non-KDDW QMainWindow
Browse files Browse the repository at this point in the history
Supports the case of having our KDDW MainWindow parented to another
main window. Was broken on Windows.
  • Loading branch information
iamsergio committed Jun 14, 2021
1 parent fb1f3fa commit 206433e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions Changelog
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- Added MainWindowBase::frameCountChanged()
- Introduced Config::setDropIndicatorsInhibited(), which allows you to disable support
for drop indicators while dragging.
- Fixed embedding the main window into a non-kddw main window (#204, #168)

* v1.3.2 (unreleased)
-
Expand Down
17 changes: 14 additions & 3 deletions src/private/DragController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -774,12 +774,23 @@ static QWidgetOrQuick *qtTopLevelForHWND(HWND hwnd)
{
const QList<QWindow*> windows = qApp->topLevelWindows();
for (QWindow *window : windows) {
if (!window->isVisible()) {
if (!window->isVisible())
continue;
}

if (hwnd == (HWND)window->winId()) {
return DockRegistry::self()->topLevelForHandle(window);
if (auto result = DockRegistry::self()->topLevelForHandle(window))
return result;
#ifdef KDDOCKWIDGETS_QTWIDGETS
// It's not a KDDW window, but we still return something, as the KDDW main window
// might be embedded into another non-kddw QMainWindow
// Case not supported for QtQuick.
const QWidgetList widgets = qApp->topLevelWidgets();
for (QWidget *widget : widgets) {
if (hwnd == (HWND)widget->winId()) {
return widget;
}
}
#endif
}
}

Expand Down

0 comments on commit 206433e

Please sign in to comment.