File tree Expand file tree Collapse file tree 2 files changed +22
-7
lines changed Expand file tree Collapse file tree 2 files changed +22
-7
lines changed Original file line number Diff line number Diff line change @@ -13,15 +13,11 @@ QPoint mapPopupToScreen(
13
13
const QWidget& widget,
14
14
const QPoint& popupUpperLeft,
15
15
const QSize& popupSize) {
16
- const QWindow* window = widget. windowHandle ( );
17
- VERIFY_OR_DEBUG_ASSERT (window ) {
16
+ const auto * pWindow = getWindow (widget );
17
+ if (!pWindow ) {
18
18
return popupUpperLeft;
19
19
}
20
- const QScreen* screen = window->screen ();
21
- VERIFY_OR_DEBUG_ASSERT (screen) {
22
- return popupUpperLeft;
23
- }
24
- const QSize screenSize = screen->size ();
20
+ const auto screenSize = pWindow->screen ()->size ();
25
21
// math_clamp() cannot be used, because if the dimensions of
26
22
// the popup menu are greater than the screen size a debug
27
23
// assertion would be triggered!
@@ -36,6 +32,17 @@ QPoint mapPopupToScreen(
36
32
return QPoint (adjustedX, adjustedY);
37
33
}
38
34
35
+ QWindow* getWindow (
36
+ const QWidget& widget) {
37
+ if (auto * window = widget.windowHandle ()) {
38
+ return window;
39
+ }
40
+ if (auto * nativeParent = widget.nativeParentWidget ()) {
41
+ return nativeParent->windowHandle ();
42
+ }
43
+ return nullptr ;
44
+ }
45
+
39
46
} // namespace widgethelper
40
47
41
48
} // namespace mixxx
Original file line number Diff line number Diff line change @@ -16,6 +16,14 @@ QPoint mapPopupToScreen(
16
16
const QPoint& popupUpperLeft,
17
17
const QSize& popupSize);
18
18
19
+ // / Obtains the corresponding window for the given widget.
20
+ // /
21
+ // / Might return nullptr if no window could be determined.
22
+ // /
23
+ // / Adopted from windowForWidget() in qtbase/src/widgets/kernel/qapplication_p.h
24
+ QWindow* getWindow (
25
+ const QWidget& widget);
26
+
19
27
} // namespace widgethelper
20
28
21
29
} // namespace mixxx
You can’t perform that action at this time.
0 commit comments