QWindowKit  1.5.1.0
Cross-platform window customization framework
Loading...
Searching...
No Matches
qwkglobal_p.h
1// Copyright (C) 2023-present Stdware Collections (https://www.github.com/stdware)
2// Copyright (C) 2021-2023 wangwenx190 (Yuhang Zhao)
3// SPDX-License-Identifier: Apache-2.0
4
5#ifndef QWKGLOBAL_P_H
6#define QWKGLOBAL_P_H
7
8//
9// W A R N I N G !!!
10// -----------------
11//
12// This file is not part of the QWindowKit API. It is used purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or may even be removed.
15//
16
17#include <QtCore/QObject>
18#include <QtCore/QLoggingCategory>
19#include <QtGui/QMouseEvent>
20
21#include <QWKCore/qwkglobal.h>
22
23QWK_CORE_EXPORT Q_DECLARE_LOGGING_CATEGORY(qWindowKitLog)
24
25#define QWK_INFO qCInfo(qWindowKitLog)
26#define QWK_DEBUG qCDebug(qWindowKitLog)
27#define QWK_WARNING qCWarning(qWindowKitLog)
28#define QWK_CRITICAL qCCritical(qWindowKitLog)
29#if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0)
30# define QWK_FATAL qCFatal(qWindowKitLog)
31#endif
32
33#define MAKE_RGB_COLOR(r, g, b) ((quint32) (((r) &0xFF) << 16) | (((g) &0xFF) << 8) | ((b) &0xFF))
34
35#define MAKE_RGBA_COLOR(r, g, b, a) \
36 ((quint32) (((a) &0xFF) << 24) | (((r) &0xFF) << 16) | (((g) &0xFF) << 8) | ((b) &0xFF))
37
38#if defined(Q_CC_MSVC)
39# define QWK_NOINLINE __declspec(noinline)
40# define QWK_INLINE __forceinline
41# define QWK_USED
42#else
43# define QWK_NOINLINE __attribute__((noinline))
44# define QWK_INLINE __attribute__((always_inline))
45# define QWK_USED __attribute__((used))
46#endif
47
48namespace QWK {
49
50 inline QPoint getMouseEventScenePos(const QMouseEvent *event) {
51 Q_ASSERT(event);
52#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
53 return event->scenePosition().toPoint();
54#else
55 return event->windowPos().toPoint();
56#endif
57 }
58
59 inline QPoint getMouseEventGlobalPos(const QMouseEvent *event) {
60 Q_ASSERT(event);
61#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
62 return event->globalPosition().toPoint();
63#else
64 return event->screenPos().toPoint();
65#endif
66 }
67
68 // Be careful when apply this function to a widget
69 QWK_CORE_EXPORT bool forwardObjectEventFilters(QObject *currentFilter, QObject *receiver,
70 QEvent *event);
71}
72
73#endif // QWKGLOBAL_P_H
QWindowKit namespace.
Definition abstractwindowcontext.cpp:13