linux: minor improvements
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
parent
b5eebada2c
commit
f2faf5dac3
|
@ -23,8 +23,9 @@
|
||||||
]]
|
]]
|
||||||
|
|
||||||
if(UNIX AND NOT APPLE)
|
if(UNIX AND NOT APPLE)
|
||||||
find_package(GTK3 REQUIRED)
|
find_package(PkgConfig REQUIRED)
|
||||||
find_package(X11 REQUIRED)
|
find_package(X11 REQUIRED)
|
||||||
|
pkg_search_module(GTK3 REQUIRED gtk+-3.0)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(SUB_PROJ_NAME FramelessHelperCore)
|
set(SUB_PROJ_NAME FramelessHelperCore)
|
||||||
|
@ -117,11 +118,11 @@ if(UNIX AND NOT APPLE)
|
||||||
GDK_VERSION_MIN_REQUIRED=GDK_VERSION_3_6
|
GDK_VERSION_MIN_REQUIRED=GDK_VERSION_3_6
|
||||||
)
|
)
|
||||||
target_link_libraries(${SUB_PROJ_NAME} PRIVATE
|
target_link_libraries(${SUB_PROJ_NAME} PRIVATE
|
||||||
PkgConfig::GTK3
|
${GTK3_LIBRARIES}
|
||||||
X11::X11
|
X11::X11
|
||||||
)
|
)
|
||||||
target_include_directories(${SUB_PROJ_NAME} PRIVATE
|
target_include_directories(${SUB_PROJ_NAME} PRIVATE
|
||||||
"/usr/include/harfbuzz" # GCC complains about can't find "hb.h". Why do we need this?
|
${GTK3_INCLUDE_DIRS}
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
@ -275,12 +275,12 @@ void FramelessHelper::Core::initialize(const Options options)
|
||||||
// and resize by yourself.
|
// and resize by yourself.
|
||||||
Utils::tryToEnableHighestDpiAwarenessLevel();
|
Utils::tryToEnableHighestDpiAwarenessLevel();
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if (!(options & Option::DontEnsureNonNativeWidgetSiblings)) {
|
if (!(options & Option::DontEnsureNonNativeWidgetSiblings)) {
|
||||||
// This attribute is known to be __NOT__ compatible with QGLWidget.
|
// This attribute is known to be __NOT__ compatible with QGLWidget.
|
||||||
// Please consider migrating to the recommended QOpenGLWidget instead.
|
// Please consider migrating to the recommended QOpenGLWidget instead.
|
||||||
QCoreApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
|
QCoreApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||||
if (!(options & Option::DontTouchHighDpiScalingPolicy)) {
|
if (!(options & Option::DontTouchHighDpiScalingPolicy)) {
|
||||||
// Enable high DPI scaling by default, but only for Qt5 applications,
|
// Enable high DPI scaling by default, but only for Qt5 applications,
|
||||||
|
|
|
@ -40,30 +40,42 @@
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "qtx11extras_p.h"
|
#include "qtx11extras_p.h"
|
||||||
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
#if (QT_VERSION < QT_VERSION_CHECK(6, 2, 0))
|
||||||
#include <QtCore/qdebug.h>
|
#include <QtCore/qdebug.h>
|
||||||
#include <QtGui/qscreen.h>
|
#include <QtGui/qscreen.h>
|
||||||
#include <QtGui/qwindow.h>
|
#include <QtGui/qwindow.h>
|
||||||
#include <QtGui/qguiapplication.h>
|
#include <QtGui/qguiapplication.h>
|
||||||
#include <QtGui/qpa/qplatformnativeinterface.h>
|
#include <QtGui/qpa/qplatformnativeinterface.h>
|
||||||
#include <QtGui/qpa/qplatformwindow.h>
|
#include <QtGui/qpa/qplatformwindow.h>
|
||||||
#include <QtGui/qpa/qplatformscreen_p.h>
|
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||||
#include <QtGui/qpa/qplatformscreen.h>
|
# include <QtGui/qpa/qplatformscreen_p.h>
|
||||||
#include <xcb/xcb.h>
|
# include <QtGui/qpa/qplatformscreen.h>
|
||||||
|
#else
|
||||||
|
# include <QtPlatformHeaders/qxcbscreenfunctions.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
[[nodiscard]] static inline QScreen *findScreenForVirtualDesktop(const int virtualDesktopNumber)
|
[[nodiscard]] static inline QScreen *findScreenForVirtualDesktop(const int virtualDesktopNumber)
|
||||||
{
|
{
|
||||||
|
if (virtualDesktopNumber == -1) {
|
||||||
|
return QGuiApplication::primaryScreen();
|
||||||
|
}
|
||||||
const QList<QScreen *> screens = QGuiApplication::screens();
|
const QList<QScreen *> screens = QGuiApplication::screens();
|
||||||
if (screens.isEmpty()) {
|
if (screens.isEmpty()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
for (auto &&screen : qAsConst(screens)) {
|
for (auto &&screen : qAsConst(screens)) {
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||||
const auto qxcbScreen = dynamic_cast<QNativeInterface::Private::QXcbScreen *>(screen->handle());
|
const auto qxcbScreen = dynamic_cast<QNativeInterface::Private::QXcbScreen *>(screen->handle());
|
||||||
if (qxcbScreen && (qxcbScreen->virtualDesktopNumber() == virtualDesktopNumber)) {
|
if (qxcbScreen && (qxcbScreen->virtualDesktopNumber() == virtualDesktopNumber)) {
|
||||||
return screen;
|
return screen;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
if (QXcbScreenFunctions::virtualDesktopNumber(screen) == virtualDesktopNumber) {
|
||||||
|
return screen;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -169,7 +181,11 @@ int QX11Info::appDpiY(const int screen)
|
||||||
multiscreen), there is only one X screen. Use QDesktopWidget to
|
multiscreen), there is only one X screen. Use QDesktopWidget to
|
||||||
query for information about Xinerama screens.
|
query for information about Xinerama screens.
|
||||||
*/
|
*/
|
||||||
|
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||||
|
unsigned long QX11Info::appRootWindow(const int screen)
|
||||||
|
#else
|
||||||
quint32 QX11Info::appRootWindow(const int screen)
|
quint32 QX11Info::appRootWindow(const int screen)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
if (!qApp)
|
if (!qApp)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -556,4 +572,4 @@ bool QX11Info::peekEventQueue(PeekerCallback peeker, void *peekerData,
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
#endif // (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
#endif // (QT_VERSION < QT_VERSION_CHECK(6, 2, 0))
|
||||||
|
|
|
@ -51,15 +51,10 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "framelesshelpercore_global.h"
|
#include "framelesshelpercore_global.h"
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
#if (QT_VERSION >= QT_VERSION_CHECK(6, 2, 0))
|
||||||
#include <QtGui/private/qtx11extras_p.h>
|
#include <QtGui/private/qtx11extras_p.h>
|
||||||
#else // (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
#else // (QT_VERSION >= QT_VERSION_CHECK(6, 2, 0))
|
||||||
#include <QtCore/private/qglobal_p.h>
|
#include <xcb/xcb.h>
|
||||||
#include <QtGui/qtguiglobal.h>
|
|
||||||
|
|
||||||
struct xcb_connection_t;
|
|
||||||
struct xcb_generic_event_t;
|
|
||||||
struct _XDisplay;
|
|
||||||
|
|
||||||
using Display = struct _XDisplay;
|
using Display = struct _XDisplay;
|
||||||
|
|
||||||
|
@ -67,6 +62,7 @@ QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
class FRAMELESSHELPER_CORE_API QX11Info
|
class FRAMELESSHELPER_CORE_API QX11Info
|
||||||
{
|
{
|
||||||
|
Q_GADGET
|
||||||
Q_DISABLE_COPY_MOVE(QX11Info)
|
Q_DISABLE_COPY_MOVE(QX11Info)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -84,7 +80,11 @@ public:
|
||||||
[[nodiscard]] static int appDpiX(const int screen = -1);
|
[[nodiscard]] static int appDpiX(const int screen = -1);
|
||||||
[[nodiscard]] static int appDpiY(const int screen = -1);
|
[[nodiscard]] static int appDpiY(const int screen = -1);
|
||||||
|
|
||||||
|
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||||
|
[[nodiscard]] static unsigned long appRootWindow(const int screen = -1);
|
||||||
|
#else
|
||||||
[[nodiscard]] static quint32 appRootWindow(const int screen = -1);
|
[[nodiscard]] static quint32 appRootWindow(const int screen = -1);
|
||||||
|
#endif
|
||||||
[[nodiscard]] static int appScreen();
|
[[nodiscard]] static int appScreen();
|
||||||
|
|
||||||
[[nodiscard]] static quint32 appTime();
|
[[nodiscard]] static quint32 appTime();
|
||||||
|
@ -119,4 +119,4 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(QX11Info::PeekOptions)
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
#endif // (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
#endif // (QT_VERSION >= QT_VERSION_CHECK(6, 2, 0))
|
||||||
|
|
|
@ -352,6 +352,7 @@ void FramelessWidgetsHelper::initialize()
|
||||||
m_initialized = true;
|
m_initialized = true;
|
||||||
// Let the user be able to get the helper class instance from outside.
|
// Let the user be able to get the helper class instance from outside.
|
||||||
q->setProperty(FRAMELESSHELPER_PROP_NAME, QVariant::fromValue(this));
|
q->setProperty(FRAMELESSHELPER_PROP_NAME, QVariant::fromValue(this));
|
||||||
|
#ifdef Q_OS_WINDOWS
|
||||||
// Without this flag, Qt will always create an invisible native parent window
|
// Without this flag, Qt will always create an invisible native parent window
|
||||||
// for any native widgets which will intercept some win32 messages and confuse
|
// 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,
|
// our own native event filter, so to prevent some weired bugs from happening,
|
||||||
|
@ -360,6 +361,7 @@ void FramelessWidgetsHelper::initialize()
|
||||||
// Force the widget become a native window now so that we can deal with its
|
// Force the widget become a native window now so that we can deal with its
|
||||||
// win32 events as soon as possible.
|
// win32 events as soon as possible.
|
||||||
q->setAttribute(Qt::WA_NativeWindow);
|
q->setAttribute(Qt::WA_NativeWindow);
|
||||||
|
#endif
|
||||||
m_params.getWindowId = [this]() -> WId { return q->winId(); };
|
m_params.getWindowId = [this]() -> WId { return q->winId(); };
|
||||||
m_params.getWindowFlags = [this]() -> Qt::WindowFlags { return q->windowFlags(); };
|
m_params.getWindowFlags = [this]() -> Qt::WindowFlags { return q->windowFlags(); };
|
||||||
m_params.setWindowFlags = [this](const Qt::WindowFlags flags) -> void { q->setWindowFlags(flags); };
|
m_params.setWindowFlags = [this](const Qt::WindowFlags flags) -> void { q->setWindowFlags(flags); };
|
||||||
|
|
Loading…
Reference in New Issue