[decorations] Allow Client to use QWindow based decorations
Shared implementation using the delegating methods in KDecoration which uses either QWindow or QWidget where possible.
This commit is contained in:
parent
f8b9b98345
commit
695697ebbd
2 changed files with 22 additions and 11 deletions
28
client.cpp
28
client.cpp
|
@ -420,7 +420,7 @@ void Client::updateDecoration(bool check_workspace_pos, bool force)
|
||||||
updateInputWindow();
|
updateInputWindow();
|
||||||
blockGeometryUpdates(false);
|
blockGeometryUpdates(false);
|
||||||
if (!noBorder())
|
if (!noBorder())
|
||||||
decoration->widget()->show();
|
decoration->show();
|
||||||
updateFrameExtents();
|
updateFrameExtents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -450,7 +450,9 @@ void Client::createDecoration(const QRect& oldgeom)
|
||||||
#endif
|
#endif
|
||||||
// TODO: Check decoration's minimum size?
|
// TODO: Check decoration's minimum size?
|
||||||
decoration->init();
|
decoration->init();
|
||||||
decoration->widget()->installEventFilter(this);
|
if (decoration->widget()) {
|
||||||
|
decoration->widget()->installEventFilter(this);
|
||||||
|
}
|
||||||
xcb_reparent_window(connection(), decoration->window()->winId(), frameId(), 0, 0);
|
xcb_reparent_window(connection(), decoration->window()->winId(), frameId(), 0, 0);
|
||||||
decoration->window()->lower();
|
decoration->window()->lower();
|
||||||
decoration->borders(border_left, border_right, border_top, border_bottom);
|
decoration->borders(border_left, border_right, border_top, border_bottom);
|
||||||
|
@ -526,13 +528,13 @@ bool Client::checkBorderSizes(bool also_resize)
|
||||||
|
|
||||||
void Client::triggerDecorationRepaint()
|
void Client::triggerDecorationRepaint()
|
||||||
{
|
{
|
||||||
if (decoration != NULL)
|
if (decoration && decoration->widget())
|
||||||
decoration->widget()->update();
|
decoration->widget()->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::layoutDecorationRects(QRect &left, QRect &top, QRect &right, QRect &bottom, Client::CoordinateMode mode) const
|
void Client::layoutDecorationRects(QRect &left, QRect &top, QRect &right, QRect &bottom, Client::CoordinateMode mode) const
|
||||||
{
|
{
|
||||||
QRect r = decoration->widget()->rect();
|
QRect r = decoration->rect();
|
||||||
if (mode == WindowRelative)
|
if (mode == WindowRelative)
|
||||||
r.translate(-padding_left, -padding_top);
|
r.translate(-padding_left, -padding_top);
|
||||||
|
|
||||||
|
@ -642,11 +644,17 @@ void Client::resizeDecoration(const QSize& s)
|
||||||
if (decoration == NULL)
|
if (decoration == NULL)
|
||||||
return;
|
return;
|
||||||
QSize newSize = s + QSize(padding_left + padding_right, padding_top + padding_bottom);
|
QSize newSize = s + QSize(padding_left + padding_right, padding_top + padding_bottom);
|
||||||
QSize oldSize = decoration->widget()->size();
|
QSize oldSize = decoration->window()->size();
|
||||||
decoration->resize(newSize);
|
decoration->resize(newSize);
|
||||||
if (oldSize == newSize) {
|
if (oldSize == newSize) {
|
||||||
QResizeEvent e(newSize, oldSize);
|
QResizeEvent e(newSize, oldSize);
|
||||||
QApplication::sendEvent(decoration->widget(), &e);
|
QObject *receiver = nullptr;
|
||||||
|
if (decoration->widget()) {
|
||||||
|
receiver = decoration->widget();
|
||||||
|
} else {
|
||||||
|
receiver = decoration->window();
|
||||||
|
}
|
||||||
|
QApplication::sendEvent(receiver, &e);
|
||||||
} else if (paintRedirector) { // oldSize != newSize
|
} else if (paintRedirector) { // oldSize != newSize
|
||||||
paintRedirector->resizePixmaps();
|
paintRedirector->resizePixmaps();
|
||||||
} else {
|
} else {
|
||||||
|
@ -1191,7 +1199,7 @@ void Client::map()
|
||||||
if (compositing())
|
if (compositing())
|
||||||
discardWindowPixmap();
|
discardWindowPixmap();
|
||||||
if (decoration != NULL)
|
if (decoration != NULL)
|
||||||
decoration->widget()->show(); // Not really necessary, but let it know the state
|
decoration->show(); // Not really necessary, but let it know the state
|
||||||
m_frame.map();
|
m_frame.map();
|
||||||
if (!isShade()) {
|
if (!isShade()) {
|
||||||
m_wrapper.map();
|
m_wrapper.map();
|
||||||
|
@ -1220,7 +1228,7 @@ void Client::unmap()
|
||||||
m_decoInputExtent.unmap();
|
m_decoInputExtent.unmap();
|
||||||
m_wrapper.selectInput(ClientWinMask | XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY);
|
m_wrapper.selectInput(ClientWinMask | XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY);
|
||||||
if (decoration != NULL)
|
if (decoration != NULL)
|
||||||
decoration->widget()->hide(); // Not really necessary, but let it know the state
|
decoration->hide(); // Not really necessary, but let it know the state
|
||||||
exportMappingState(IconicState);
|
exportMappingState(IconicState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2402,8 +2410,8 @@ void Client::setSessionInteract(bool needed)
|
||||||
|
|
||||||
QRect Client::decorationRect() const
|
QRect Client::decorationRect() const
|
||||||
{
|
{
|
||||||
if (decoration && decoration->widget()) {
|
if (decoration) {
|
||||||
return decoration->widget()->rect().translated(-padding_left, -padding_top);
|
return decoration->rect().translated(-padding_left, -padding_top);
|
||||||
} else {
|
} else {
|
||||||
return QRect(0, 0, width(), height());
|
return QRect(0, 0, width(), height());
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,7 +78,7 @@ static int align(int value, int align)
|
||||||
|
|
||||||
void PaintRedirector::performPendingPaint()
|
void PaintRedirector::performPendingPaint()
|
||||||
{
|
{
|
||||||
if (!widget) {
|
if (!widget && !m_decoration->window()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//qDebug() << "### performing paint, pending:" << pending.boundingRect();
|
//qDebug() << "### performing paint, pending:" << pending.boundingRect();
|
||||||
|
@ -169,6 +169,9 @@ QRegion PaintRedirector::scheduledRepaintRegion()
|
||||||
|
|
||||||
void PaintRedirector::added(QWidget* w)
|
void PaintRedirector::added(QWidget* w)
|
||||||
{
|
{
|
||||||
|
if (!w) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
w->installEventFilter(this);
|
w->installEventFilter(this);
|
||||||
foreach (QObject * o, w->children()) {
|
foreach (QObject * o, w->children()) {
|
||||||
if (o->isWidgetType() && !isToolTip(static_cast< QWidget* >(o)))
|
if (o->isWidgetType() && !isToolTip(static_cast< QWidget* >(o)))
|
||||||
|
|
Loading…
Reference in a new issue