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->onExposeEvent(window))
121 if (q->d->m_globalEventFilters.empty())
128 const auto filters = std::as_const(q->d->m_globalEventFilters);
133 if (std::find(q->d->m_globalEventFilters.cbegin(), q->d->m_globalEventFilters.cend(),
135 == q->d->m_globalEventFilters.cend())
138 if (filter->onMouseEvent(view.get(), ev))
141 switch (ev->
type()) {
143 if (filter->onMouseButtonPress(view.get(), ev))
147 if (filter->onMouseButtonRelease(view.get(), ev))
151 if (filter->onMouseButtonMove(view.get(), ev))
155 if (filter->onMouseDoubleClick(view.get(), ev))
166 ~GlobalEventFilter()
override;
167 bool m_isProcessingAppQuitEvent =
false;
171Platform_qt::GlobalEventFilter::~GlobalEventFilter() =
default;
174 : m_globalEventFilter(new GlobalEventFilter(this))
177 qWarning() <<
"Please call KDDockWidgets::initPlatform() after QGuiApplication";
180#ifdef DOCKS_DEVELOPER_MODE
184 : m_globalEventFilter(new GlobalEventFilter(this))
189 View_qt::s_logicalDpiFactorOverride = 1;
196 delete m_globalEventFilter;
207 const auto qtwindows = qGuiApp->topLevelWindows();
208 windows.reserve(qtwindows.size());
209 for (
QWindow *qtwindow : qtwindows) {
218 if (
auto window = qobject_cast<QWindow *>(obj))
234 return qGuiApp->screens().indexOf(screen);
247 return m_globalEventFilter->m_isProcessingAppQuitEvent;
252 return qGuiApp->applicationName();
258 qGuiApp->changeOverrideCursor(shape);
260 qGuiApp->setOverrideCursor(shape);
266 qGuiApp->restoreOverrideCursor();
309 const auto qscreens = qGuiApp->
screens();
311 screens.reserve(qscreens.size());
312 for (
auto qscreen : qscreens) {
313 screens.push_back(std::make_shared<Screen_qt>(qscreen));
320 return std::make_shared<Screen_qt>(qGuiApp->primaryScreen());
333 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