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)
64 if (Config::self().flags() & Config::Flag_DoubleClickMaximizes) {
69 if (m_titleBar->isFloating()) {
70 m_titleBar->onFloatClicked();
81 m_screenChangedConnection =
83 [
this] { Q_EMIT DockRegistry::self()->windowChangedScreen(windowHandle()); });
86 return FloatingWindow::event(ev);
89 void FloatingWindowWidget::init()
91 m_vlayout->setSpacing(0);
93 m_vlayout->addWidget(m_titleBar);
94 m_vlayout->addWidget(m_dropArea);
96 connect(DockRegistry::self(), &DockRegistry::windowChangedScreen,
this, [
this](
QWindow *w) {
97 if (w == window()->windowHandle())
102 void FloatingWindowWidget::updateMargins()
104 m_vlayout->setContentsMargins(
QMargins(4, 4, 4, 4) * logicalDpiFactor(
this));