• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • superkaramba
 

superkaramba

  • superkaramba
  • src
showdesktop.cpp
1/*
2 * Copyright (C) 2003-2004 Adam Geitgey <adam@rootnode.org>
3 * Copyright (c) 2005 Ryan Nickell <p0z3r@earthlink.net>
4 *
5 * This file is part of SuperKaramba.
6 *
7 * SuperKaramba 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.
11 *
12 * SuperKaramba 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.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with SuperKaramba; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 ****************************************************************************/
21#include <twinmodule.h>
22#include <netwm.h>
23#include <twin.h>
24
25#include "karambaapp.h"
26#include "showdesktop.h"
27#include "showdesktop.moc"
28
29ShowDesktop* ShowDesktop::the()
30{
31 static ShowDesktop showDesktop;
32 return &showDesktop;
33}
34
35ShowDesktop::ShowDesktop()
36 : TQObject()
37 , showingDesktop( false )
38 , kWinModule( 0 )
39{
40 kWinModule = new KWinModule( this );
41
42 // on desktop changes or when a window is deiconified, we abort the show desktop mode
43 connect( kWinModule, TQ_SIGNAL(currentDesktopChanged(int)),
44 TQ_SLOT(slotCurrentDesktopChanged(int)));
45 connect( kWinModule, TQ_SIGNAL(windowChanged(WId,unsigned int)),
46 TQ_SLOT(slotWindowChanged(WId,unsigned int)));
47}
48
49void ShowDesktop::slotCurrentDesktopChanged(int)
50{
51 showDesktop( false );
52}
53
54#ifdef KDE_3_3
55#define NET_ALL_TYPES_MASK (NET::AllTypesMask)
56#else
57#define NET_ALL_TYPES_MASK (-1LU)
58#endif
59
60void ShowDesktop::slotWindowChanged(WId w, unsigned int dirty)
61{
62 if (!showingDesktop)
63 return;
64
65 // SELI this needs checking for twin_iii (_NET_SHOWING_DESKTOP)
66 if ( dirty & NET::XAWMState )
67 {
68 NETWinInfo inf(tqt_xdisplay(), w, tqt_xrootwin(),
69 NET::XAWMState | NET::WMWindowType);
70#ifdef KDE_3_2
71 NET::WindowType windowType = inf.windowType(NET_ALL_TYPES_MASK);
72#else
73 NET::WindowType windowType = inf.windowType();
74#endif
75 if ((windowType == NET::Normal || windowType == NET::Unknown)
76 && inf.mappingState() == NET::Visible )
77 {
78 // a window was deiconified, abort the show desktop mode.
79 iconifiedList.clear();
80 showingDesktop = false;
81 emit desktopShown( false );
82 }
83 }
84}
85
86void ShowDesktop::showDesktop( bool b )
87{
88 if( b == showingDesktop ) return;
89 showingDesktop = b;
90
91 if ( b ) {
92 // this code should move to KWin after supporting NETWM1.2
93 iconifiedList.clear();
94 const TQValueList<WId> windows = kWinModule->windows();
95 TQValueList<WId>::ConstIterator it;
96 TQValueList<WId>::ConstIterator end( windows.end() );
97 for ( it=windows.begin(); it!=end; ++it ) {
98 WId w = *it;
99 NETWinInfo info( tqt_xdisplay(), w, tqt_xrootwin(),
100 NET::XAWMState | NET::WMDesktop );
101 if ( info.mappingState() == NET::Visible &&
102 ( info.desktop() == NETWinInfo::OnAllDesktops
103 || info.desktop() == (int) kWinModule->currentDesktop() )
104 ) {
105 iconifiedList.append( w );
106 }
107 }
108 // find first, hide later, otherwise transients may get minimized
109 // with the window they're transient for
110 TQValueList<WId>::ConstIterator endInconifiedList( iconifiedList.end() );
111 for ( it=iconifiedList.begin(); it!=endInconifiedList; ++it ) {
112 KWin::iconifyWindow( *it, false );
113 }
114 } else {
115 TQValueList<WId>::ConstIterator it;
116 TQValueList<WId>::ConstIterator end( iconifiedList.end() );
117 for ( it=iconifiedList.begin(); it!=end; ++it ) {
118 KWin::deIconifyWindow( *it, false );
119 }
120 }
121
122 emit desktopShown( showingDesktop );
123}
ShowDesktop
Singleton class that handles desktop access (minimizing all windows)
Definition: showdesktop.h:31

superkaramba

Skip menu "superkaramba"
  • Main Page
  • Alphabetical List
  • Class List
  • File List
  • Class Members

superkaramba

Skip menu "superkaramba"
  • kcalc
  •   knumber
  • superkaramba
Generated for superkaramba by doxygen 1.9.4
This website is maintained by Timothy Pearson.