2003-09-16 19:28:03 +00:00
|
|
|
/*****************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
2003-01-07 12:42:32 +00:00
|
|
|
|
2003-09-16 19:28:03 +00:00
|
|
|
Copyright (c) 2003, Karol Szwed <kszwed@kde.org>
|
2003-01-07 12:42:32 +00:00
|
|
|
|
2003-09-16 19:28:03 +00:00
|
|
|
You can Freely distribute this program under the GNU General Public
|
|
|
|
License. See the file "COPYING" for the exact licensing terms.
|
|
|
|
******************************************************************/
|
2003-01-07 12:42:32 +00:00
|
|
|
|
2003-09-16 19:28:03 +00:00
|
|
|
#include "geometrytip.h"
|
2003-06-15 07:19:05 +00:00
|
|
|
|
2003-09-16 19:28:03 +00:00
|
|
|
namespace KWinInternal
|
2003-01-07 12:42:32 +00:00
|
|
|
{
|
2003-06-15 07:19:05 +00:00
|
|
|
|
2003-09-16 19:28:03 +00:00
|
|
|
GeometryTip::GeometryTip( const XSizeHints* xSizeHints, bool save_under ):
|
2003-11-11 18:38:19 +00:00
|
|
|
QLabel(NULL, "kwingeometry" )
|
2003-06-15 07:19:05 +00:00
|
|
|
{
|
2003-01-07 12:42:32 +00:00
|
|
|
setMargin(1);
|
|
|
|
setIndent(0);
|
|
|
|
setLineWidth(1);
|
|
|
|
setFrameStyle( QFrame::Raised | QFrame::StyledPanel );
|
|
|
|
setAlignment( AlignCenter | AlignTop );
|
|
|
|
sizeHints = xSizeHints;
|
2003-09-16 19:28:03 +00:00
|
|
|
if( save_under )
|
|
|
|
{
|
|
|
|
XSetWindowAttributes attr;
|
|
|
|
attr.save_under = True; // use saveunder if possible to avoid weird effects in transparent mode
|
|
|
|
XChangeWindowAttributes( qt_xdisplay(), winId(), CWSaveUnder, &attr );
|
|
|
|
}
|
|
|
|
}
|
2003-01-07 12:42:32 +00:00
|
|
|
|
|
|
|
GeometryTip::~GeometryTip()
|
2003-09-16 19:28:03 +00:00
|
|
|
{
|
|
|
|
}
|
2003-01-07 12:42:32 +00:00
|
|
|
|
|
|
|
void GeometryTip::setGeometry( const QRect& geom )
|
2003-09-16 19:28:03 +00:00
|
|
|
{
|
2003-01-07 12:42:32 +00:00
|
|
|
int w, h;
|
|
|
|
int bw, bh;
|
|
|
|
|
2003-09-16 19:28:03 +00:00
|
|
|
w = geom.width();
|
|
|
|
h = geom.height();
|
|
|
|
|
|
|
|
if (sizeHints)
|
|
|
|
{
|
|
|
|
// PBaseSize is only for aspect ratios, see Client::getWMNormalHints()
|
|
|
|
if (!(sizeHints->flags & PMinSize))
|
|
|
|
{
|
|
|
|
bw = 0;
|
|
|
|
bh = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bw = sizeHints->min_width;
|
|
|
|
bh = sizeHints->min_height;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sizeHints->flags & PResizeInc)
|
|
|
|
{
|
|
|
|
if (sizeHints->width_inc > 0)
|
|
|
|
w = (w - bw) / sizeHints->width_inc;
|
|
|
|
if (sizeHints->height_inc > 0)
|
|
|
|
h = (h - bh) / sizeHints->height_inc;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
h = QMAX( h, 0 ); // in case of isShade() and PBaseSize
|
2003-01-07 12:42:32 +00:00
|
|
|
QString pos;
|
2003-12-01 12:01:32 +00:00
|
|
|
pos.sprintf( "%+d,%+d<br>(<b>%d x %d</b>)",
|
2003-09-16 19:28:03 +00:00
|
|
|
geom.x(), geom.y(), w, h );
|
2003-01-07 12:42:32 +00:00
|
|
|
setText( pos );
|
|
|
|
adjustSize();
|
|
|
|
move( geom.x() + ((geom.width() - width()) / 2),
|
2003-09-16 19:28:03 +00:00
|
|
|
geom.y() + ((geom.height() - height()) / 2) );
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|
2003-07-29 16:00:52 +00:00
|
|
|
|
|
|
|
#include "geometrytip.moc"
|