[wayland] Start Compositor and Scene before Workspace

For Xwayland we need to have the Scene (and EglDisplay) created prior
to starting Xwayland and having X11. This requires creating the
Compositor before creating Workspace and starting Xwayland.

To support this the startup of Compositor is split into two parts:
prior and after Workspace creation.

The change might also be interesting for the kwin_x11 case as it could
result in the compositor being up in a quicker way.
master
Martin Gräßlin 10 years ago
parent 659ff1c732
commit 50ef02fa1b

@ -177,20 +177,13 @@ extern bool is_multihead;
void Compositor::slotCompositingOptionsInitialized()
{
char selection_name[ 100 ];
sprintf(selection_name, "_NET_WM_CM_S%d", Application::x11ScreenNumber());
if (!cm_selection) {
cm_selection = new CompositorSelectionOwner(selection_name);
connect(cm_selection, SIGNAL(lostOwnership()), SLOT(finish()));
}
if (!cm_selection->owning) {
cm_selection->claim(true); // force claiming
cm_selection->owning = true;
}
claimCompositorSelection();
// There might still be a deleted around, needs to be cleared before creating the scene (BUG 333275)
while (!Workspace::self()->deletedList().isEmpty()) {
Workspace::self()->deletedList().first()->discard();
if (Workspace::self()) {
while (!Workspace::self()->deletedList().isEmpty()) {
Workspace::self()->deletedList().first()->discard();
}
}
switch(options->compositingMode()) {
@ -245,8 +238,10 @@ void Compositor::slotCompositingOptionsInitialized()
default:
qCDebug(KWIN_CORE) << "No compositing enabled";
m_starting = false;
cm_selection->owning = false;
cm_selection->release();
if (cm_selection) {
cm_selection->owning = false;
cm_selection->release();
}
if (kwinApp()->requiresCompositing()) {
qCCritical(KWIN_CORE) << "The used windowing system requires compositing";
qCCritical(KWIN_CORE) << "We are going to quit KWin now as it is broken";
@ -259,8 +254,10 @@ void Compositor::slotCompositingOptionsInitialized()
delete m_scene;
m_scene = NULL;
m_starting = false;
cm_selection->owning = false;
cm_selection->release();
if (cm_selection) {
cm_selection->owning = false;
cm_selection->release();
}
if (kwinApp()->requiresCompositing()) {
qCCritical(KWIN_CORE) << "The used windowing system requires compositing";
qCCritical(KWIN_CORE) << "We are going to quit KWin now as it is broken";
@ -268,6 +265,38 @@ void Compositor::slotCompositingOptionsInitialized()
}
return;
}
if (Workspace::self()) {
startupWithWorkspace();
} else {
connect(kwinApp(), &Application::workspaceCreated, this, &Compositor::startupWithWorkspace);
}
}
void Compositor::claimCompositorSelection()
{
if (!cm_selection && kwinApp()->x11Connection()) {
char selection_name[ 100 ];
sprintf(selection_name, "_NET_WM_CM_S%d", Application::x11ScreenNumber());
cm_selection = new CompositorSelectionOwner(selection_name);
connect(cm_selection, SIGNAL(lostOwnership()), SLOT(finish()));
} else {
// no X11 yet
return;
}
if (!cm_selection->owning) {
cm_selection->claim(true); // force claiming
cm_selection->owning = true;
}
}
void Compositor::startupWithWorkspace()
{
if (!m_starting) {
return;
}
Q_ASSERT(m_scene);
claimCompositorSelection();
connect(Workspace::self(), &Workspace::deletedRemoved, m_scene, &Scene::windowDeleted);
m_xrrRefreshRate = KWin::currentRefreshRate();
fpsInterval = options->maxFpsInterval();
@ -373,8 +402,10 @@ void Compositor::releaseCompositorSelection()
return;
}
qCDebug(KWIN_CORE) << "Releasing compositor selection";
cm_selection->owning = false;
cm_selection->release();
if (cm_selection) {
cm_selection->owning = false;
cm_selection->release();
}
}
void Compositor::keepSupportProperty(xcb_atom_t atom)

@ -210,8 +210,13 @@ private Q_SLOTS:
void deleteUnusedSupportProperties();
private:
void claimCompositorSelection();
void setCompositeTimer();
bool windowRepaintsPending() const;
/**
* Continues the startup after Scene And Workspace are created
**/
void startupWithWorkspace();
/**
* Whether the Compositor is currently suspended, 8 bits encoding the reason

@ -23,6 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <config-kwin.h>
// kwin
#include "atoms.h"
#include "composite.h"
#include "cursor.h"
#include "input.h"
#include "logind.h"
@ -400,6 +401,11 @@ void Application::createOptions()
options = new Options;
}
void Application::createCompositor()
{
Compositor::create(this);
}
void Application::setupEventFilters()
{
installNativeEventFilter(m_eventFilter.data());

@ -161,6 +161,7 @@ protected:
void createWorkspace();
void createAtoms();
void createOptions();
void createCompositor();
void setupEventFilters();
void destroyWorkspace();
/**

@ -80,6 +80,8 @@ ApplicationWayland::~ApplicationWayland()
void ApplicationWayland::performStartup()
{
setOperationMode(m_startXWayland ? OperationModeXwayland : OperationModeWaylandAndX11);
// first load options - done internally by a different thread
createOptions();
// try creating the Wayland Backend
createInput();
@ -103,6 +105,7 @@ void ApplicationWayland::continueStartupWithScreens()
continueStartupWithX();
return;
}
createCompositor();
int sx[2];
if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, sx) < 0) {
@ -149,8 +152,6 @@ void ApplicationWayland::continueStartupWithX()
createAtoms();
setupEventFilters();
// first load options - done internally by a different thread
createOptions();
// Check whether another windowmanager is running
const uint32_t maskValues[] = {XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT};

@ -192,7 +192,11 @@ Workspace::Workspace(bool restore)
// init XRenderUtils
XRenderUtils::init(connection(), rootWindow());
m_compositor = Compositor::create(this);
if (Compositor::self()) {
m_compositor = Compositor::self();
} else {
m_compositor = Compositor::create(this);
}
connect(this, SIGNAL(currentDesktopChanged(int,KWin::Client*)), m_compositor, SLOT(addRepaintFull()));
auto decorationBridge = Decoration::DecorationBridge::create(this);

Loading…
Cancel
Save