macos: verify functionality

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
Yuhang Zhao 2022-04-20 16:31:30 +08:00
parent f2faf5dac3
commit cf4e4c331b
4 changed files with 14 additions and 4 deletions

View File

@ -275,12 +275,12 @@ void FramelessHelper::Core::initialize(const Options options)
// and resize by yourself.
Utils::tryToEnableHighestDpiAwarenessLevel();
}
#endif
if (!(options & Option::DontEnsureNonNativeWidgetSiblings)) {
// This attribute is known to be __NOT__ compatible with QGLWidget.
// Please consider migrating to the recommended QOpenGLWidget instead.
QCoreApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
}
#endif
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
if (!(options & Option::DontTouchHighDpiScalingPolicy)) {
// Enable high DPI scaling by default, but only for Qt5 applications,

View File

@ -59,6 +59,11 @@ FRAMELESSHELPER_STRING_CONSTANT(highcontrast)
Qt::CursorShape Utils::calculateCursorShape(const QWindow *window, const QPoint &pos)
{
#ifdef Q_OS_MACOS
Q_UNUSED(window);
Q_UNUSED(pos);
return Qt::ArrowCursor;
#else
Q_ASSERT(window);
if (!window) {
return Qt::ArrowCursor;
@ -81,10 +86,16 @@ Qt::CursorShape Utils::calculateCursorShape(const QWindow *window, const QPoint
return Qt::SizeVerCursor;
}
return Qt::ArrowCursor;
#endif
}
Qt::Edges Utils::calculateWindowEdges(const QWindow *window, const QPoint &pos)
{
#ifdef Q_OS_MACOS
Q_UNUSED(window);
Q_UNUSED(pos);
return {};
#else
Q_ASSERT(window);
if (!window) {
return {};
@ -106,6 +117,7 @@ Qt::Edges Utils::calculateWindowEdges(const QWindow *window, const QPoint &pos)
edges |= Qt::BottomEdge;
}
return edges;
#endif
}
QVariant Utils::getSystemButtonIconResource

View File

@ -81,7 +81,7 @@ else()
endif()
target_link_libraries(${SUB_PROJ_NAME} PRIVATE
Qt${QT_VERSION_MAJOR}::Widgets
Qt${QT_VERSION_MAJOR}::WidgetsPrivate
)
target_link_libraries(${SUB_PROJ_NAME} PUBLIC

View File

@ -352,7 +352,6 @@ void FramelessWidgetsHelper::initialize()
m_initialized = true;
// Let the user be able to get the helper class instance from outside.
q->setProperty(FRAMELESSHELPER_PROP_NAME, QVariant::fromValue(this));
#ifdef Q_OS_WINDOWS
// Without this flag, Qt will always create an invisible native parent window
// for any native widgets which will intercept some win32 messages and confuse
// our own native event filter, so to prevent some weired bugs from happening,
@ -361,7 +360,6 @@ void FramelessWidgetsHelper::initialize()
// Force the widget become a native window now so that we can deal with its
// win32 events as soon as possible.
q->setAttribute(Qt::WA_NativeWindow);
#endif
m_params.getWindowId = [this]() -> WId { return q->winId(); };
m_params.getWindowFlags = [this]() -> Qt::WindowFlags { return q->windowFlags(); };
m_params.setWindowFlags = [this](const Qt::WindowFlags flags) -> void { q->setWindowFlags(flags); };