[decorations] Allow decorations to use a QWindow instead of QWidget
A setMainWindow() method is added which behaves similar to setMainWidget(). In addition a few convenient methods are added which can be used by KWin core to show/hide the decoration without caring whether the decoration uses a QWindow or QWidget.icc-effect-5.14.5
parent
8ecb69cd8c
commit
f8b9b98345
|
@ -109,11 +109,46 @@ void KDecoration::setMainWidget(QWidget* w)
|
||||||
widget()->resize(geometry().size());
|
widget()->resize(geometry().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void KDecoration::setMainWindow(QWindow *window)
|
||||||
|
{
|
||||||
|
assert(d->window.isNull());
|
||||||
|
d->window.reset(window);
|
||||||
|
d->window->resize(geometry().size());
|
||||||
|
}
|
||||||
|
|
||||||
Qt::WindowFlags KDecoration::initialWFlags() const
|
Qt::WindowFlags KDecoration::initialWFlags() const
|
||||||
{
|
{
|
||||||
return d->bridge->initialWFlags();
|
return d->bridge->initialWFlags();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void KDecoration::show()
|
||||||
|
{
|
||||||
|
if (!d->w.isNull()) {
|
||||||
|
d->w->show();
|
||||||
|
} else if (!d->window.isNull()) {
|
||||||
|
d->window->show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void KDecoration::hide()
|
||||||
|
{
|
||||||
|
if (!d->w.isNull()) {
|
||||||
|
d->w->hide();
|
||||||
|
} else if (!d->window.isNull()) {
|
||||||
|
d->window->hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QRect KDecoration::rect() const
|
||||||
|
{
|
||||||
|
if (!d->w.isNull()) {
|
||||||
|
return d->w->rect();
|
||||||
|
} else if (!d->window.isNull()) {
|
||||||
|
return QRect(QPoint(0, 0), d->window->size());
|
||||||
|
}
|
||||||
|
return QRect();
|
||||||
|
}
|
||||||
|
|
||||||
bool KDecoration::isActive() const
|
bool KDecoration::isActive() const
|
||||||
{
|
{
|
||||||
return d->bridge->isActive();
|
return d->bridge->isActive();
|
||||||
|
|
|
@ -982,6 +982,17 @@ public:
|
||||||
* like WX11BypassWM or WStyle_NoBorder are forbidden.
|
* like WX11BypassWM or WStyle_NoBorder are forbidden.
|
||||||
*/
|
*/
|
||||||
void createMainWidget(Qt::WindowFlags flags = 0);
|
void createMainWidget(Qt::WindowFlags flags = 0);
|
||||||
|
/**
|
||||||
|
* This should be the first function called in init() to specify
|
||||||
|
* the main window of the decoration. The window should be created
|
||||||
|
* with window flags specified by initialWFlags().
|
||||||
|
*
|
||||||
|
* This class takes over ownership of the QWindow.
|
||||||
|
*
|
||||||
|
* A window decoration can either be QWidget based or QWindow based. If it
|
||||||
|
* calls both setMainWidget() and setMainWindow() the behavior is undefined.
|
||||||
|
*/
|
||||||
|
void setMainWindow(QWindow *window);
|
||||||
/**
|
/**
|
||||||
* The flags that should be used when creating the main widget.
|
* The flags that should be used when creating the main widget.
|
||||||
* It is possible to add more flags when creating the main widget, but only flags
|
* It is possible to add more flags when creating the main widget, but only flags
|
||||||
|
@ -1022,6 +1033,18 @@ public:
|
||||||
* a button press was for window tab dragging or for displaying the client menu.
|
* a button press was for window tab dragging or for displaying the client menu.
|
||||||
*/
|
*/
|
||||||
WindowOperation buttonToWindowOperation(Qt::MouseButtons button);
|
WindowOperation buttonToWindowOperation(Qt::MouseButtons button);
|
||||||
|
/**
|
||||||
|
* Convenient method to show the decoration's widget or window.
|
||||||
|
**/
|
||||||
|
void show();
|
||||||
|
/**
|
||||||
|
* Convenient method to hide the decoration's widget or window.
|
||||||
|
**/
|
||||||
|
void hide();
|
||||||
|
/**
|
||||||
|
* Convenient method to get the geometry of the decoration widget or window.
|
||||||
|
**/
|
||||||
|
QRect rect() const;
|
||||||
|
|
||||||
|
|
||||||
// Window tabbing
|
// Window tabbing
|
||||||
|
|
Loading…
Reference in New Issue