<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 "mcompositewindow.h"
#include "mcompwindowanimator.h"
#include "mcompositemanager.h"
#include "mcompositemanager_p.h"
#include "mtexturepixmapitem.h"
#include "mdecoratorframe.h"
#include "mcompositemanagerextension.h"
#include "mcompositewindowgroup.h"

#include <QX11Info>
#include <QGraphicsScene>
#include <QGraphicsSceneMouseEvent>
#include <X11/Xatom.h>

int MCompositeWindow::window_transitioning = 0;

static QRectF fadeRect = QRectF();

MCompositeWindow::MCompositeWindow(Qt::HANDLE window, 
                                   MWindowPropertyCache *mpc, 
                                   QGraphicsItem *p)
    : QGraphicsItem(p),
      pc(mpc),
      scalefrom(1),
      scaleto(1),
      scaled(false),
      zval(1),
      sent_ping_timestamp(0),
      received_ping_timestamp(0),
      blur(false),
      iconified(false),
      iconified_final(false),
      iconify_state(NoIconifyState),
      destroyed(false),
      window_status(Normal),
      need_decor(false),
      window_obscured(-1),
      is_transitioning(false),
      dimmed_effect(false),
      waiting_for_damage(0),
      win_id(window)
{
    thumb_mode = false;
    if (!mpc || (mpc && !mpc->is_valid)) {
        is_valid = false;
        anim = 0;
        newly_mapped = false;
        t_ping = t_reappear = damage_timer = 0;
        window_visible = false;
        return;
    } else
        is_valid = true;
    anim = new MCompWindowAnimator(this);
    connect(anim, SIGNAL(transitionDone()),  SLOT(finalizeState()));
    connect(anim, SIGNAL(transitionStart()), SLOT(beginAnimation()));
    connect(mpc, SIGNAL(iconGeometryUpdated()), SLOT(updateIconGeometry()));
    setAcceptHoverEvents(true);

    // this could be configurable. But will do for now. Most WMs use 5s delay
    t_ping = new QTimer(this);
    t_ping->setInterval(5000);
    connect(t_ping, SIGNAL(timeout()), SLOT(pingTimeout()));
    t_reappear = new QTimer(this);
    t_reappear->setSingleShot(true);
    t_reappear->setInterval(30 * 1000);
    connect(t_reappear, SIGNAL(timeout()), SLOT(reappearTimeout()));

    damage_timer = new QTimer(this);
    damage_timer->setSingleShot(true);
    damage_timer->setInterval(500);
    connect(damage_timer, SIGNAL(timeout()), SLOT(damageTimeout()));
    
    MCompAtoms* atoms = MCompAtoms::instance(); 
    if (pc->windowType() == MCompAtoms::NORMAL)
        pc->setWindowTypeAtom(ATOM(_NET_WM_WINDOW_TYPE_NORMAL));
    else
        pc->setWindowTypeAtom(atoms->getType(window));

    // needed before calling isAppWindow()
    QVector<Atom> states = atoms->getAtomArray(window, ATOM(_NET_WM_STATE));
    pc->setNetWmState(states.toList());

    // Newly-mapped non-decorated application windows are not initially 
    // visible to prevent flickering when animation is started.
    // We initially prevent item visibility from compositor itself
    // or it's corresponding thumbnail rendered by the switcher
    bool is_app = isAppWindow();
    newly_mapped = is_app;
    if (!pc->isInputOnly()) {
        // never paint InputOnly windows
        window_visible = !is_app;
        setVisible(window_visible); // newly_mapped used here
    }
    origPosition = QPointF(pc->realGeometry().x(), pc->realGeometry().y());

    if (fadeRect.isEmpty()) {
        QRectF d = QApplication::desktop()->availableGeometry();
        fadeRect.setWidth(d.width()/2);
        fadeRect.setHeight(d.height()/2);
        fadeRect.moveTo(fadeRect.width()/2, fadeRect.height()/2);
    }
}

MCompositeWindow::~MCompositeWindow()
{
    MCompositeManager *p = (MCompositeManager *) qApp;

    if (window()) {
        stopPing();
        t_ping = t_reappear = 0;
    }
    endAnimation();
    
    anim = 0;
    
    if (pc) {
        pc->damageTracking(false);
        p->d->prop_caches.remove(window());
        pc->deleteLater();
    }    
}
<commit_msg>MCompositeWindow::MCompositeWindow(): init window_visible for input-only wins<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 "mcompositewindow.h"
#include "mcompwindowanimator.h"
#include "mcompositemanager.h"
#include "mcompositemanager_p.h"
#include "mtexturepixmapitem.h"
#include "mdecoratorframe.h"
#include "mcompositemanagerextension.h"
#include "mcompositewindowgroup.h"

#include <QX11Info>
#include <QGraphicsScene>
#include <QGraphicsSceneMouseEvent>
#include <X11/Xatom.h>

int MCompositeWindow::window_transitioning = 0;

static QRectF fadeRect = QRectF();

MCompositeWindow::MCompositeWindow(Qt::HANDLE window, 
                                   MWindowPropertyCache *mpc, 
                                   QGraphicsItem *p)
    : QGraphicsItem(p),
      pc(mpc),
      scalefrom(1),
      scaleto(1),
      scaled(false),
      zval(1),
      sent_ping_timestamp(0),
      received_ping_timestamp(0),
      blur(false),
      iconified(false),
      iconified_final(false),
      iconify_state(NoIconifyState),
      destroyed(false),
      window_status(Normal),
      need_decor(false),
      window_obscured(-1),
      is_transitioning(false),
      dimmed_effect(false),
      waiting_for_damage(0),
      win_id(window)
{
    thumb_mode = false;
    if (!mpc || (mpc && !mpc->is_valid)) {
        is_valid = false;
        anim = 0;
        newly_mapped = false;
        t_ping = t_reappear = damage_timer = 0;
        window_visible = false;
        return;
    } else
        is_valid = true;
    anim = new MCompWindowAnimator(this);
    connect(anim, SIGNAL(transitionDone()),  SLOT(finalizeState()));
    connect(anim, SIGNAL(transitionStart()), SLOT(beginAnimation()));
    connect(mpc, SIGNAL(iconGeometryUpdated()), SLOT(updateIconGeometry()));
    setAcceptHoverEvents(true);

    // this could be configurable. But will do for now. Most WMs use 5s delay
    t_ping = new QTimer(this);
    t_ping->setInterval(5000);
    connect(t_ping, SIGNAL(timeout()), SLOT(pingTimeout()));
    t_reappear = new QTimer(this);
    t_reappear->setSingleShot(true);
    t_reappear->setInterval(30 * 1000);
    connect(t_reappear, SIGNAL(timeout()), SLOT(reappearTimeout()));

    damage_timer = new QTimer(this);
    damage_timer->setSingleShot(true);
    damage_timer->setInterval(500);
    connect(damage_timer, SIGNAL(timeout()), SLOT(damageTimeout()));
    
    MCompAtoms* atoms = MCompAtoms::instance(); 
    if (pc->windowType() == MCompAtoms::NORMAL)
        pc->setWindowTypeAtom(ATOM(_NET_WM_WINDOW_TYPE_NORMAL));
    else
        pc->setWindowTypeAtom(atoms->getType(window));

    // needed before calling isAppWindow()
    QVector<Atom> states = atoms->getAtomArray(window, ATOM(_NET_WM_STATE));
    pc->setNetWmState(states.toList());

    // Newly-mapped non-decorated application windows are not initially 
    // visible to prevent flickering when animation is started.
    // We initially prevent item visibility from compositor itself
    // or it's corresponding thumbnail rendered by the switcher
    bool is_app = isAppWindow();
    newly_mapped = is_app;
    if (!pc->isInputOnly()) {
        // never paint InputOnly windows
        window_visible = !is_app;
        setVisible(window_visible); // newly_mapped used here
    } else
        window_visible = false;
    origPosition = QPointF(pc->realGeometry().x(), pc->realGeometry().y());

    if (fadeRect.isEmpty()) {
        QRectF d = QApplication::desktop()->availableGeometry();
        fadeRect.setWidth(d.width()/2);
        fadeRect.setHeight(d.height()/2);
        fadeRect.moveTo(fadeRect.width()/2, fadeRect.height()/2);
    }
}

MCompositeWindow::~MCompositeWindow()
{
    MCompositeManager *p = (MCompositeManager *) qApp;

    if (window()) {
        stopPing();
        t_ping = t_reappear = 0;
    }
    endAnimation();
    
    anim = 0;
    
    if (pc) {
        pc->damageTracking(false);
        p->d->prop_caches.remove(window());
        pc->deleteLater();
    }    
}

{'fraction_non_alphanumeric': 0.15402920497566253, 'fraction_numerical': 0.008653326122228232, 'mean_word_length': 3.460202604920405, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 57, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2817129', 'n_tokens_mistral': 2924, 'n_tokens_neox': 2819, 'n_words': 624}