File indexing completed on 2024-05-05 16:39:02

0001 /* This file is part of the KDE project
0002    Copyright (C) 2000,2001,2002 Carsten Pfeiffer <pfeiffer@kde.org>
0003 
0004    This program is free software; you can redistribute it and/or
0005    modify it under the terms of the GNU General Public
0006    License as published by the Free Software Foundation, version 2.
0007 
0008    This program is distributed in the hope that it will be useful,
0009    but WITHOUT ANY WARRANTY; without even the implied warranty of
0010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0011     General Public License for more details.
0012 
0013    You should have received a copy of the GNU General Public License
0014    along with this program; see the file COPYING.  If not, write to
0015    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0016    Boston, MA 02110-1301, USA.
0017 */
0018 
0019 #ifndef KUICKGLOBALS_H
0020 #define KUICKGLOBALS_H
0021 
0022 #include <KWindowInfo>
0023 #include <KWindowSystem>
0024 
0025 #include <QRect>
0026 #include <QSize>
0027 
0028 
0029 class Kuick
0030 {
0031 public:
0032     static QRect workArea() {
0033     return KWindowSystem::workArea();
0034     }
0035 
0036     static QSize frameSize( WId win = 0L ) {
0037     if ( win ) {
0038         KWindowInfo info(win, NET::WMFrameExtents | NET::WMGeometry | NET::WMDesktop);
0039         int wborder = info.frameGeometry().width() - info.geometry().width();
0040         int hborder = info.frameGeometry().height() - info.geometry().height();
0041     
0042         if ( wborder || hborder ) { // we get a 0,0 border when not shown
0043         s_frameSize.setWidth( wborder );
0044         s_frameSize.setHeight( hborder );
0045         }
0046     }
0047     
0048     if ( !s_frameSize.isValid() )
0049         return QSize( 0, 0 );
0050 
0051     return s_frameSize;
0052     }
0053 
0054     static Kuick * self() {
0055     if ( !s_self ) {
0056         s_self = new Kuick;
0057     }
0058     return s_self;
0059     }
0060 
0061 private:
0062     Kuick() {}
0063     static Kuick * s_self;
0064 
0065     static QSize s_frameSize;
0066 };
0067 
0068 
0069 #endif // KUICKGLOBALS_H