• 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 
29 ShowDesktop* ShowDesktop::the()
30 {
31  static ShowDesktop showDesktop;
32  return &showDesktop;
33 }
34 
35 ShowDesktop::ShowDesktop()
36  : TQObject()
37  , showingDesktop( false )
38  , tWinModule( 0 )
39 {
40  tWinModule = new TWinModule( this );
41 
42  // on desktop changes or when a window is deiconified, we abort the show desktop mode
43  connect( tWinModule, TQ_SIGNAL(currentDesktopChanged(int)),
44  TQ_SLOT(slotCurrentDesktopChanged(int)));
45  connect( tWinModule, TQ_SIGNAL(windowChanged(WId,unsigned int)),
46  TQ_SLOT(slotWindowChanged(WId,unsigned int)));
47 }
48 
49 void ShowDesktop::slotCurrentDesktopChanged(int)
50 {
51  showDesktop( false );
52 }
53 
54 void ShowDesktop::slotWindowChanged(WId w, unsigned int dirty)
55 {
56  if (!showingDesktop)
57  return;
58 
59  // SELI this needs checking for twin_iii (_NET_SHOWING_DESKTOP)
60  if ( dirty & NET::XAWMState )
61  {
62  NETWinInfo inf(tqt_xdisplay(), w, tqt_xrootwin(),
63  NET::XAWMState | NET::WMWindowType);
64  NET::WindowType windowType = inf.windowType(NET::AllTypesMask);
65  if ((windowType == NET::Normal || windowType == NET::Unknown)
66  && inf.mappingState() == NET::Visible )
67  {
68  // a window was deiconified, abort the show desktop mode.
69  iconifiedList.clear();
70  showingDesktop = false;
71  emit desktopShown( false );
72  }
73  }
74 }
75 
76 void ShowDesktop::showDesktop( bool b )
77 {
78  if( b == showingDesktop ) return;
79  showingDesktop = b;
80 
81  if ( b ) {
82  // this code should move to KWin after supporting NETWM1.2
83  iconifiedList.clear();
84  const TQValueList<WId> windows = tWinModule->windows();
85  TQValueList<WId>::ConstIterator it;
86  TQValueList<WId>::ConstIterator end( windows.end() );
87  for ( it=windows.begin(); it!=end; ++it ) {
88  WId w = *it;
89  NETWinInfo info( tqt_xdisplay(), w, tqt_xrootwin(),
90  NET::XAWMState | NET::WMDesktop );
91  if ( info.mappingState() == NET::Visible &&
92  ( info.desktop() == NETWinInfo::OnAllDesktops
93  || info.desktop() == (int) tWinModule->currentDesktop() )
94  ) {
95  iconifiedList.append( w );
96  }
97  }
98  // find first, hide later, otherwise transients may get minimized
99  // with the window they're transient for
100  TQValueList<WId>::ConstIterator endInconifiedList( iconifiedList.end() );
101  for ( it=iconifiedList.begin(); it!=endInconifiedList; ++it ) {
102  KWin::iconifyWindow( *it, false );
103  }
104  } else {
105  TQValueList<WId>::ConstIterator it;
106  TQValueList<WId>::ConstIterator end( iconifiedList.end() );
107  for ( it=iconifiedList.begin(); it!=end; ++it ) {
108  KWin::deIconifyWindow( *it, false );
109  }
110  }
111 
112  emit desktopShown( showingDesktop );
113 }
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.1
This website is maintained by Timothy Pearson.