not quite so much needs to be delayed to the init() function
[personal-kdebase.git] / workspace / kwin / unmanaged.cpp
blob083f9c265c5aca59e40a7728c11cb0a7f26615a9
1 /********************************************************************
2 KWin - the KDE window manager
3 This file is part of the KDE project.
5 Copyright (C) 2006 Lubos Lunak <l.lunak@kde.org>
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *********************************************************************/
21 #include "unmanaged.h"
23 #include "workspace.h"
24 #include "effects.h"
25 #include "deleted.h"
27 #include <X11/extensions/shape.h>
29 namespace KWin
32 Unmanaged::Unmanaged( Workspace* ws )
33 : Toplevel( ws )
37 Unmanaged::~Unmanaged()
41 bool Unmanaged::track( Window w )
43 XWindowAttributes attr;
44 grabXServer();
45 if( !XGetWindowAttributes(display(), w, &attr) || attr.map_state != IsViewable )
47 ungrabXServer();
48 return false;
50 if( attr.c_class == InputOnly )
52 ungrabXServer();
53 return false;
55 setWindowHandles( w, w ); // the window is also the frame
56 XSelectInput( display(), w, attr.your_event_mask | StructureNotifyMask | PropertyChangeMask);
57 geom = QRect( attr.x, attr.y, attr.width, attr.height );
58 vis = attr.visual;
59 bit_depth = attr.depth;
60 unsigned long properties[ 2 ];
61 properties[ NETWinInfo::PROTOCOLS ] =
62 NET::WMWindowType |
63 NET::WMPid |
65 properties[ NETWinInfo::PROTOCOLS2 ] =
66 NET::WM2Opacity |
68 info = new NETWinInfo2( display(), w, rootWindow(), properties, 2 );
69 getResourceClass();
70 getWindowRole();
71 getWmClientLeader();
72 getWmClientMachine();
73 if( Extensions::shapeAvailable())
74 XShapeSelectInput( display(), w, ShapeNotifyMask );
75 detectShape( w );
76 setupCompositing();
77 ungrabXServer();
78 if( effects )
79 static_cast<EffectsHandlerImpl*>(effects)->checkInputWindowStacking();
80 return true;
83 void Unmanaged::release()
85 Deleted* del = Deleted::create( this );
86 if( effects )
88 static_cast<EffectsHandlerImpl*>(effects)->windowClosed( effectWindow());
89 scene->windowClosed( this, del );
91 finishCompositing();
92 workspace()->removeUnmanaged( this, Allowed );
93 if( !QWidget::find( window())) // don't affect our own windows
95 if( Extensions::shapeAvailable())
96 XShapeSelectInput( display(), window(), NoEventMask );
97 XSelectInput( display(), window(), NoEventMask );
99 addWorkspaceRepaint( geometry());
100 disownDataPassedToDeleted();
101 del->unrefWindow();
102 deleteUnmanaged( this, Allowed );
105 void Unmanaged::deleteUnmanaged( Unmanaged* c, allowed_t )
107 delete c;
110 int Unmanaged::desktop() const
112 return NET::OnAllDesktops; // TODO for some window types should be the current desktop?
115 QPoint Unmanaged::clientPos() const
117 return QPoint( 0, 0 ); // unmanaged windows don't have decorations
120 QSize Unmanaged::clientSize() const
122 return size();
125 void Unmanaged::debug( kdbgstream& stream ) const
127 stream << "\'ID:" << window() << "\'";
130 } // namespace
132 #include "unmanaged.moc"