<commit_before>/***************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (<EMAIL>)
**
** This file is part of mcompositor.
**
** If you have questions regarding the use of this file, please contact
** Nokia at <EMAIL>.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation
** and appearing in the file LICENSE.LGPL included in the packaging
** of this file.
**
****************************************************************************/

#include "mdecoratorframe.h"
#include "mcompositewindow.h"
#include "mtexturepixmapitem.h"
#include "mcompositemanager.h"
#include "mcompositordebug.h"
#include "mrmi.h"

#include <QX11Info>

#include <X11/Xutil.h>
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <X11/Xmd.h>

MDecoratorFrame *MDecoratorFrame::d = 0;

MDecoratorFrame::MDecoratorFrame(QObject *p)
    : QObject(p),
      client(0),
      decorator_window(0),
      decorator_item(0),
      no_resize(false)
{    
    // One instance at a time
    Q_ASSERT(!d);
    d = this;

    remote_decorator = new MRmiClient(".mabstractdecorator", this);
    remote_decorator->exportObject(this);
}

Qt::HANDLE MDecoratorFrame::managedWindow() const
{
    return client ? client->window() : 0;
}

Qt::HANDLE MDecoratorFrame::winId() const
{
    return decorator_window;
}

void MDecoratorFrame::hide()
{
    if (decorator_item)
        decorator_item->setVisible(false);
}

void MDecoratorFrame::show()
{
    if (decorator_item)
        decorator_item->setVisible(true);
}

void MDecoratorFrame::sendManagedWindowId(bool show_dialog)
{
    QVector<QVariant> args;

    if (client) {
        MWindowPropertyCache *pc = client->propertyCache();
        args << unsigned(client->window())
             << pc->requestedGeometry()
             << pc->wmName()
             << pc->orientationAngle()
             << only_statusbar
             << show_dialog;
    } else
        args << unsigned(0) << QRect() << QString() << unsigned(0)
             << false << false;

    remote_decorator->invoke("MAbstractDecorator", "RemoteSetManagedWinId",
                             args);
}

void MDecoratorFrame::setManagedWindow(MCompositeWindow *cw,
                                       bool no_resize,
                                       bool only_statusbar,
                                       bool show_dialog)
{    
    this->no_resize = no_resize;
    this->only_statusbar = only_statusbar;

    if (client == cw)
        return;
    if (client)
        disconnect(client, SIGNAL(destroyed()), this, SLOT(destroyClient()));
    client = cw;

    if (decorator_item)<commit_msg>fix zombie-dialog reappearing<commit_after>/***************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (<EMAIL>)
**
** This file is part of mcompositor.
**
** If you have questions regarding the use of this file, please contact
** Nokia at <EMAIL>.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation
** and appearing in the file LICENSE.LGPL included in the packaging
** of this file.
**
****************************************************************************/

#include "mdecoratorframe.h"
#include "mcompositewindow.h"
#include "mtexturepixmapitem.h"
#include "mcompositemanager.h"
#include "mcompositordebug.h"
#include "mrmi.h"

#include <QX11Info>

#include <X11/Xutil.h>
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <X11/Xmd.h>

MDecoratorFrame *MDecoratorFrame::d = 0;

MDecoratorFrame::MDecoratorFrame(QObject *p)
    : QObject(p),
      client(0),
      decorator_window(0),
      decorator_item(0),
      no_resize(false)
{    
    // One instance at a time
    Q_ASSERT(!d);
    d = this;

    remote_decorator = new MRmiClient(".mabstractdecorator", this);
    remote_decorator->exportObject(this);
}

Qt::HANDLE MDecoratorFrame::managedWindow() const
{
    return client ? client->window() : 0;
}

Qt::HANDLE MDecoratorFrame::winId() const
{
    return decorator_window;
}

void MDecoratorFrame::hide()
{
    if (decorator_item)
        decorator_item->setVisible(false);
}

void MDecoratorFrame::show()
{
    if (decorator_item)
        decorator_item->setVisible(true);
}

void MDecoratorFrame::sendManagedWindowId(bool show_dialog)
{
    QVector<QVariant> args;

    if (client) {
        MWindowPropertyCache *pc = client->propertyCache();
        args << unsigned(client->window())
             << pc->requestedGeometry()
             << pc->wmName()
             << pc->orientationAngle()
             << only_statusbar
             << show_dialog;
    } else
        args << unsigned(0) << QRect() << QString() << unsigned(0)
             << false << false;

    remote_decorator->invoke("MAbstractDecorator", "RemoteSetManagedWinId",
                             args);
}

void MDecoratorFrame::setManagedWindow(MCompositeWindow *cw,
                                       bool no_resize,
                                       bool only_statusbar,
                                       bool show_dialog)
{    
    this->no_resize = no_resize;
    this->only_statusbar = only_statusbar;

    if (client == cw) {
        if (cw && show_dialog)
            // Time to @show_dialog again.
            sendManagedWindowId(show_dialog);
        return;
    }

    if (client)
        disconnect(client, SIGNAL(destroyed()), this, SLOT(destroyClient()));
    client = cw;

    if (decorator_item)
{'fraction_non_alphanumeric': 0.16578902666893156, 'fraction_numerical': 0.007813827076609478, 'mean_word_length': 3.005442176870748, 'pattern_counts': {'":': 0, '<': 67, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4788428', 'n_tokens_mistral': 1806, 'n_tokens_neox': 1723, 'n_words': 415}