~ubuntu-branches/ubuntu/gutsy/kdebase-workspace/gutsy

« back to all changes in this revision

Viewing changes to kwin/unmanaged.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2007-09-05 20:45:14 UTC
  • Revision ID: james.westby@ubuntu.com-20070905204514-632hhspl0nvrc84i
Tags: upstream-3.93.0
ImportĀ upstreamĀ versionĀ 3.93.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*****************************************************************
 
2
 KWin - the KDE window manager
 
3
 This file is part of the KDE project.
 
4
 
 
5
Copyright (C) 2006 Lubos Lunak <l.lunak@kde.org>
 
6
 
 
7
You can Freely distribute this program under the GNU General Public
 
8
License. See the file "COPYING" for the exact licensing terms.
 
9
******************************************************************/
 
10
 
 
11
#include "unmanaged.h"
 
12
 
 
13
#include "workspace.h"
 
14
#include "effects.h"
 
15
#include "deleted.h"
 
16
 
 
17
#include <X11/extensions/shape.h>
 
18
 
 
19
namespace KWin
 
20
{
 
21
 
 
22
Unmanaged::Unmanaged( Workspace* ws )
 
23
    : Toplevel( ws )
 
24
    {
 
25
    }
 
26
    
 
27
Unmanaged::~Unmanaged()
 
28
    {
 
29
    }
 
30
 
 
31
bool Unmanaged::track( Window w )
 
32
    {
 
33
    XWindowAttributes attr;
 
34
    grabXServer();
 
35
    if( !XGetWindowAttributes(display(), w, &attr) || attr.map_state != IsViewable )
 
36
        {
 
37
        ungrabXServer();
 
38
        return false;
 
39
        }
 
40
    if( attr.c_class == InputOnly )
 
41
        {
 
42
        ungrabXServer();
 
43
        return false;
 
44
        }
 
45
    setWindowHandles( w, w ); // the window is also the frame
 
46
    XSelectInput( display(), w, StructureNotifyMask );
 
47
    geom = QRect( attr.x, attr.y, attr.width, attr.height );
 
48
    vis = attr.visual;
 
49
    bit_depth = attr.depth;
 
50
    unsigned long properties[ 2 ];
 
51
    properties[ NETWinInfo::PROTOCOLS ] =
 
52
        NET::WMWindowType |
 
53
        NET::WMPid |
 
54
        0;
 
55
    properties[ NETWinInfo::PROTOCOLS2 ] =
 
56
        NET::WM2Opacity |
 
57
        0;
 
58
    info = new NETWinInfo( display(), w, rootWindow(), properties, 2 );
 
59
 
 
60
    if( Extensions::shapeAvailable())
 
61
        XShapeSelectInput( display(), w, ShapeNotifyMask );
 
62
    detectShape( w );
 
63
    setupCompositing();
 
64
    ungrabXServer();
 
65
    if( effects )
 
66
        static_cast<EffectsHandlerImpl*>(effects)->checkInputWindowStacking();
 
67
    return true;
 
68
    }
 
69
 
 
70
void Unmanaged::release()
 
71
    {
 
72
    Deleted* del = Deleted::create( this );
 
73
    if( effects )
 
74
        {
 
75
        static_cast<EffectsHandlerImpl*>(effects)->windowClosed( effectWindow());
 
76
        scene->windowClosed( this, del );
 
77
        }
 
78
    finishCompositing();
 
79
    workspace()->removeUnmanaged( this, Allowed );
 
80
    if( Extensions::shapeAvailable())
 
81
        XShapeSelectInput( display(), window(), NoEventMask );
 
82
    XSelectInput( display(), window(), NoEventMask );
 
83
    addWorkspaceRepaint( geometry());
 
84
    disownDataPassedToDeleted();
 
85
    del->unrefWindow();
 
86
    deleteUnmanaged( this, Allowed );
 
87
    }
 
88
 
 
89
void Unmanaged::deleteUnmanaged( Unmanaged* c, allowed_t )
 
90
    {
 
91
    delete c;
 
92
    }
 
93
 
 
94
int Unmanaged::desktop() const
 
95
    {
 
96
    return NET::OnAllDesktops; // TODO for some window types should be the current desktop?
 
97
    }
 
98
 
 
99
QPoint Unmanaged::clientPos() const
 
100
    {
 
101
    return QPoint( 0, 0 ); // unmanaged windows don't have decorations
 
102
    }
 
103
 
 
104
QSize Unmanaged::clientSize() const
 
105
    {
 
106
    return size();
 
107
    }
 
108
 
 
109
void Unmanaged::debug( kdbgstream& stream ) const
 
110
    {
 
111
    stream << "\'ID:" << window() << "\'";
 
112
    }
 
113
 
 
114
} // namespace
 
115
 
 
116
#include "unmanaged.moc"