KWin
geometrytip.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "geometrytip.h"
00022 #include <QX11Info>
00023
00024 namespace KWin
00025 {
00026
00027 GeometryTip::GeometryTip( const XSizeHints* xSizeHints, bool save_under ):
00028 QLabel( 0 )
00029 {
00030 setObjectName( "kwingeometry" );
00031 setMargin(1);
00032 setIndent(0);
00033 setLineWidth(1);
00034 setFrameStyle( QFrame::Raised | QFrame::StyledPanel );
00035 setAlignment( Qt::AlignCenter | Qt::AlignTop );
00036 sizeHints = xSizeHints;
00037 if( save_under )
00038 {
00039 XSetWindowAttributes attr;
00040 attr.save_under = True;
00041 XChangeWindowAttributes( display(), winId(), CWSaveUnder, &attr );
00042 }
00043 }
00044
00045 GeometryTip::~GeometryTip()
00046 {
00047 }
00048
00049 void GeometryTip::setGeometry( const QRect& geom )
00050 {
00051 int w = geom.width();
00052 int h = geom.height();
00053
00054 if (sizeHints)
00055 {
00056 if (sizeHints->flags & PResizeInc)
00057 {
00058 w = ( w - sizeHints->base_width ) / sizeHints->width_inc;
00059 h = ( h - sizeHints->base_height ) / sizeHints->height_inc;
00060 }
00061 }
00062
00063 h = qMax( h, 0 );
00064 QString pos;
00065 pos.sprintf( "%+d,%+d<br>(<b>%d x %d</b>)",
00066 geom.x(), geom.y(), w, h );
00067 setText( pos );
00068 adjustSize();
00069 move( geom.x() + ((geom.width() - width()) / 2),
00070 geom.y() + ((geom.height() - height()) / 2) );
00071 }
00072
00073 }
00074
00075 #include "geometrytip.moc"