Пример #1
0
Application::Application() : KApplication(), owner(screen_number)
{
    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
    if(!config()->isImmutable() && args->isSet("lock"))
    {
        config()->setReadOnly(true);
        config()->reparseConfiguration();
    }

    if(screen_number == -1)
        screen_number = DefaultScreen(qt_xdisplay());

    if(!owner.claim(args->isSet("replace"), true))
    {
        fputs(i18n("kwin: unable to claim manager selection, another wm running? (try using --replace)\n").local8Bit(), stderr);
        ::exit(1);
    }
    connect(&owner, SIGNAL(lostOwnership()), SLOT(lostSelection()));

    // if there was already kwin running, it saved its configuration after loosing the selection -> reread
    config()->reparseConfiguration();

    initting = TRUE; // startup....

    // install X11 error handler
    XSetErrorHandler(x11ErrorHandler);

    // check  whether another windowmanager is running
    XSelectInput(qt_xdisplay(), qt_xrootwin(), SubstructureRedirectMask);
    syncX(); // trigger error now

    options = new Options;
    atoms = new Atoms;

    // create workspace.
    (void)new Workspace(isSessionRestored());

    syncX(); // trigger possible errors, there's still a chance to abort

    DCOPRef ref("kded", "kded");
    ref.send("unloadModule", QCString("kdetrayproxy"));

    initting = FALSE; // startup done, we are up and running now.

    dcopClient()->send("ksplash", "", "upAndRunning(QString)", QString("wm started"));
    XEvent e;
    e.xclient.type = ClientMessage;
    e.xclient.message_type = XInternAtom(qt_xdisplay(), "_KDE_SPLASH_PROGRESS", False);
    e.xclient.display = qt_xdisplay();
    e.xclient.window = qt_xrootwin();
    e.xclient.format = 8;
    strcpy(e.xclient.data.b, "wm started");
    XSendEvent(qt_xdisplay(), qt_xrootwin(), False, SubstructureNotifyMask, &e);
}
Пример #2
0
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()));
    }

    if (!cm_selection) // no X11 yet
        return;

    if (!cm_selection->owning) {
        cm_selection->claim(true);   // force claiming
        cm_selection->owning = true;
    }
}