12 #include "FloatingWindowWidget_p.h"
13 #include "../DockRegistry_p.h"
14 #include "../DropArea_p.h"
15 #include "../Logging_p.h"
16 #include "../TitleBar_p.h"
17 #include "../Utils_p.h"
19 #include <QApplication>
21 #include <QVBoxLayout>
23 #include <QWindowStateChangeEvent>
28 : FloatingWindow(suggestedGeometry, parent)
34 FloatingWindowWidget::FloatingWindowWidget(Frame *frame,
QRect suggestedGeometry,
MainWindowBase *parent)
35 : FloatingWindow(frame, suggestedGeometry, parent)
41 void FloatingWindowWidget::paintEvent(
QPaintEvent *ev)
43 if (Config::self().disabledPaintEvents() & Config::CustomizableWidget_FloatingWindow) {
53 const qreal halfPenWidth = p.pen().widthF() / 2;
54 const QRectF rectf = rect();
55 p.drawRect(rectf.
adjusted(halfPenWidth, halfPenWidth, -halfPenWidth, -halfPenWidth));
58 bool FloatingWindowWidget::event(
QEvent *ev)
62 if (Config::self().flags() & Config::Flag_DoubleClickMaximizes) {
67 if (m_titleBar->isFloating()) {
68 m_titleBar->onFloatClicked();
79 m_screenChangedConnection =
81 [
this] { Q_EMIT DockRegistry::self()->windowChangedScreen(windowHandle()); });
83 windowHandle()->installEventFilter(
this);
86 return FloatingWindow::event(ev);
89 bool FloatingWindowWidget::eventFilter(
QObject *o,
QEvent *ev)
100 m_lastWindowManagerState = windowHandle()->windowState();
101 Q_EMIT windowStateChanged();
105 return FloatingWindow::eventFilter(o, ev);
108 void FloatingWindowWidget::init()
110 m_vlayout->setSpacing(0);
112 m_vlayout->addWidget(m_titleBar);
113 m_vlayout->addWidget(m_dropArea);
115 connect(DockRegistry::self(), &DockRegistry::windowChangedScreen,
this, [
this](
QWindow *w) {
116 if (w == window()->windowHandle())
121 void FloatingWindowWidget::updateMargins()
123 m_vlayout->setContentsMargins(
QMargins(4, 4, 4, 4) * logicalDpiFactor(
this));