14#include "kddockwidgets/KDDockWidgets.h"
15#include "kddockwidgets/core/EventFilterInterface.h"
16#include "core/Platform_p.h"
17#include "core/Utils_p.h"
18#include "core/Logging_p.h"
19#include "core/DelayedCall_p.h"
24#include <QGuiApplication>
25#include <QElapsedTimer>
29#include <QOperatingSystemVersion>
37class Platform_qt::GlobalEventFilter :
public QObject
44 qGuiApp->installEventFilter(
this);
46 qWarning() << Q_FUNC_INFO <<
"Expected a qGuiApp!";
53 return handleExpose(o);
55 return handleMouseEvent(o, me);
56 else if (isDnDEvent(ev))
57 return handleDnDEvent(o, ev);
59 return handleMoveEvent(o, ev);
67 m_isProcessingAppQuitEvent =
true;
68 qGuiApp->sendEvent(qApp, ev);
69 m_isProcessingAppQuitEvent =
false;
75 if (q->d->m_globalEventFilters.empty())
80 if (filter->onMoveEvent(view.get()))
89 if (q->d->m_globalEventFilters.empty())
94 if (filter->onDnDEvent(view.get(), ev))
104 if (q->d->m_globalEventFilters.empty())
112 if (filter->enabled() && filter->onExposeEvent(window))
121 if (q->d->m_globalEventFilters.empty())
128 const auto &filters = std::as_const(q->d->m_globalEventFilters);
132 if (std::find(q->d->m_globalEventFilters.cbegin(), q->d->m_globalEventFilters.cend(),
134 == q->d->m_globalEventFilters.cend())
137 if (!filter->enabled())
140 if (filter->onMouseEvent(view.get(), ev))
143 switch (ev->
type()) {
145 if (filter->onMouseButtonPress(view.get(), ev))
149 if (filter->onMouseButtonRelease(view.get(), ev))
153 if (filter->onMouseButtonMove(view.get(), ev))
157 if (filter->onMouseDoubleClick(view.get(), ev))
168 ~GlobalEventFilter()
override;
169 bool m_isProcessingAppQuitEvent =
false;
173Platform_qt::GlobalEventFilter::~GlobalEventFilter() =
default;
176 : m_globalEventFilter(new GlobalEventFilter(this))
179 qWarning() <<
"Please call KDDockWidgets::initPlatform() after QGuiApplication";
182#ifdef DOCKS_DEVELOPER_MODE
186 : m_globalEventFilter(new GlobalEventFilter(this))
191 View_qt::s_logicalDpiFactorOverride = 1;
198 delete m_globalEventFilter;
209 const auto qtwindows = qGuiApp->topLevelWindows();
210 windows.reserve(qtwindows.size());
211 for (
QWindow *qtwindow : qtwindows) {
220 if (
auto window = qobject_cast<QWindow *>(obj))
236 return qGuiApp->screens().indexOf(screen);
249 return m_globalEventFilter->m_isProcessingAppQuitEvent;
254 return qGuiApp->applicationName();
260 qGuiApp->changeOverrideCursor(shape);
262 qGuiApp->setOverrideCursor(shape);
268 qGuiApp->restoreOverrideCursor();
314 const auto qscreens = qGuiApp->
screens();
316 screens.reserve(qscreens.size());
317 for (
auto qscreen : qscreens) {
318 screens.push_back(std::make_shared<Screen_qt>(qscreen));
325 return std::make_shared<Screen_qt>(qGuiApp->primaryScreen());
338 KDDW_ERROR(
"Failed to open {}, error={}", fileName, f.
errorString());
void setPos(int x, int y)
QEvent::Type type() const const
virtual bool open(QIODevice::OpenMode mode) override
QString errorString() const const
virtual bool eventFilter(QObject *watched, QEvent *event)
QOperatingSystemVersion current()
int majorVersion() const const
QScreen * screen() const const