//
//     Copyright 2008 Jim Bublitz <jbublitz@nwinternet.com>
//     Earlier copyrights 1998 - 2007 Jim Bublitz also apply

//                 Generated by twine

// This file is part of PyKDE4.

// PyKDE4 is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of
// the License, or (at your option) any later version.

// PyKDE4 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.


class KWindowSystem : QObject, NET
{
%TypeHeaderCode
#include <kwindowsystem.h>
%End


public:
    static KWindowSystem*   self ();
    static const QList<WId>&  windows ();
    static bool             hasWId (WId id);
    static KWindowInfo      windowInfo (WId win, unsigned long properties, unsigned long properties2 = 0);
    static QList<WId>       stackingOrder ();
    static WId              activeWindow ();
    static void             activateWindow (WId win, long time = 0);
    static void             forceActiveWindow (WId win, long time = 0);
    static void             demandAttention (WId win, bool set = 1);
    static bool             compositingActive ();
    static int              currentDesktop ();
    static int              numberOfDesktops ();
    static void             setCurrentDesktop (int desktop);
    static void             setOnAllDesktops (WId win, bool b);
    static void             setOnDesktop (WId win, int desktop);
    static void             setMainWindow (QWidget* subwindow, WId mainwindow);
    static WId              transientFor (WId window);
    static WId              groupLeader (WId window);
    static QPixmap          icon (WId win, int width = -1, int height = -1, bool scale = 0);

    enum IconSource
    {
        NETWM,
        WMHints,
        ClassHint,
        XApp
    };

    static QPixmap          icon (WId win, int width, int height, bool scale, int flags);
    static void             setIcons (WId win, const QPixmap& icon, const QPixmap& miniIcon);
    static void             setType (WId win, NET::WindowType windowType);
    static void             setState (WId win, unsigned long state);
    static void             clearState (WId win, unsigned long state);
    static void             minimizeWindow (WId win, bool animation = 1);
    static void             unminimizeWindow (WId win, bool animation = 1);
    static void             raiseWindow (WId win);
    static void             lowerWindow (WId win);
    static bool             icccmCompliantMappingState ();
    static QRect            workArea (int desktop = -1);
    static QRect            workArea (const QList<WId>& excludes, int desktop = -1);
    static QString          desktopName (int desktop);
    static void             setDesktopName (int desktop, const QString& name);
    static bool             showingDesktop ();
    static void             setUserTime (WId win, long time);
    static void             setExtendedStrut (WId win, int left_width, int left_start, int left_end, int right_width, int right_start, int right_end, int top_width, int top_start, int top_end, int bottom_width, int bottom_start, int bottom_end);
    static void             setStrut (WId win, int left, int right, int top, int bottom);
    static bool             allowedActionsSupported ();
    static QString          readNameProperty (WId window, unsigned long atom);
    static void             doNotManage (const QString& title);
    static void             allowExternalProcessWindowActivation (int pid = -1);
    static bool             mapViewport ();
    static int              viewportToDesktop (const QPoint& pos);
    static int              viewportWindowToDesktop (const QRect& r);
    static QPoint           desktopToViewport (int desktop, bool absolute);
    static QPoint           constrainViewportRelativePosition (const QPoint& pos);

signals:
    void                    currentDesktopChanged (int desktop);
    void                    windowAdded (WId id);
    void                    windowRemoved (WId id);
    void                    activeWindowChanged (WId id);
    void                    desktopNamesChanged ();
    void                    numberOfDesktopsChanged (int num);
    void                    workAreaChanged ();
    void                    strutChanged ();
    void                    stackingOrderChanged ();
//ig     void               windowChanged (WId id, const unsigned long* properties /Out/);
    void                    windowChanged (WId id, unsigned int properties);
    void                    windowChanged (WId id);
    void                    showingDesktopChanged (bool showing);

protected:
    virtual void            connectNotify (const char* signal);

private:
                            KWindowSystem ();
};   // KWindowSystem



%MappedType QList<WId>
{
%TypeHeaderCode
#include <qlist.h>
%End

%ConvertFromTypeCode
    // Create the list.
    PyObject *l;

    if ((l = PyList_New(sipCpp->size())) == NULL)
        return NULL;

    // Set the list elements.
    for (int i = 0; i < sipCpp->size(); ++i)
    {
        PyObject *pobj;

        if ((pobj = PyInt_FromLong ((long)sipCpp->value(i))) == NULL)
        {
            Py_DECREF(l);

            return NULL;
        }

        PyList_SET_ITEM(l, i, pobj);
    }

    return l;
%End

%ConvertToTypeCode
    // Check the type if that is all that is required.
    if (sipIsErr == NULL)
        return PyList_Check(sipPy);

    QList<WId> *ql = new QList<WId>;
 
    for (int i = 0; i < PyList_GET_SIZE(sipPy); ++i)
        ql->append((WId)PyInt_AS_LONG (PyList_GET_ITEM(sipPy, i)));
 
    *sipCppPtr = ql;
 
    return sipGetState(sipTransferObj);
%End
};

