diff --git a/Makefile.am b/Makefile.am index 9f370288b8..d5ec4e4958 100644 --- a/Makefile.am +++ b/Makefile.am @@ -8,7 +8,7 @@ lib_LTLIBRARIES = kwin.la # workspace.cpp has to be first in order not to break --enable-final kwin_la_SOURCES = client.cpp workspace.cpp placement.cpp atoms.cpp main.cpp \ popupinfo.cpp tabbox.cpp options.cpp plugins.cpp events.cpp KWinInterface.skel \ - killwindow.cpp kwinbutton.cpp + killwindow.cpp kwinbutton.cpp geometrytip.cpp kwin_la_LIBADD = $(LIB_KDEUI) kwin_la_LDFLAGS = $(all_libraries) -module -avoid-version diff --git a/client.cpp b/client.cpp index 3946ca026c..7ee0c56e02 100644 --- a/client.cpp +++ b/client.cpp @@ -27,6 +27,7 @@ Copyright (C) 1999, 2000 Matthias Ettrich #include "client.h" #include "events.h" #include "atoms.h" +#include "geometrytip.h" #include #include #include @@ -118,9 +119,9 @@ static int nullErrorHandler(Display *, XErrorEvent *) using namespace KWinInternal; -static bool blockAnimation = FALSE; - -static QRect* visible_bound = 0; +static bool blockAnimation = FALSE; +static QRect* visible_bound = 0; +static GeometryTip* geometryTip = 0; static QCString getStringProperty(WId w, Atom prop, char separator=0); @@ -1616,6 +1617,11 @@ void Client::mouseReleaseEvent( QMouseEvent * e) if ( (e->stateAfter() & MouseButtonMask) == 0 ) { buttonDown = FALSE; if ( moveResizeMode ) { + if (geometryTip) { + geometryTip->hide(); + delete geometryTip; + geometryTip = NULL; + } clearbound(); stopMoveResize(); setGeometry( geom ); @@ -1736,6 +1742,16 @@ void Client::mouseMoveEvent( QMouseEvent * e) clearbound(); drawbound( geom ); } + + // Position and Size display + if (!geometryTip) + geometryTip = new GeometryTip( this, &xSizeHint ); + + geometryTip->setGeometry( geom ); + if (!geometryTip->isVisible()) { + geometryTip->show(); + geometryTip->raise(); + } } else if ( isMove() && geom.topLeft() != geometry().topLeft() ) { geom.moveTopLeft( workspace()->adjustClientPosition( this, geom.topLeft() ) ); @@ -1756,6 +1772,16 @@ void Client::mouseMoveEvent( QMouseEvent * e) drawbound( geom ); break; } + + // Position and Size display + if (!geometryTip) + geometryTip = new GeometryTip( this, &xSizeHint ); + + geometryTip->setGeometry( geom ); + if (!geometryTip->isVisible()) { + geometryTip->show(); + geometryTip->raise(); + } } if ( isMove() ) diff --git a/geometrytip.cpp b/geometrytip.cpp new file mode 100644 index 0000000000..7438232ed6 --- /dev/null +++ b/geometrytip.cpp @@ -0,0 +1,65 @@ +/* + * $Id$ + * Window Geometry Display + * Copyright (c) 2003, Karol Szwed + */ + +#include "geometrytip.h" + +using namespace KWinInternal; + + +GeometryTip::GeometryTip( const Client* client, const XSizeHints* xSizeHints ): + QLabel(NULL, "kwingeometry", WStyle_Customize | WStyle_StaysOnTop | + WStyle_NoBorder | WX11BypassWM ) +{ + c = client; + setMargin(1); + setIndent(0); + setLineWidth(1); + setFrameStyle( QFrame::Raised | QFrame::StyledPanel ); + setAlignment( AlignCenter | AlignTop ); + sizeHints = xSizeHints; +} + +GeometryTip::~GeometryTip() +{ +} + +void GeometryTip::setGeometry( const QRect& geom ) +{ + int w, h; + int bw, bh; + QWidget* wrap = c->windowWrapper(); + + w = wrap->width(); + h = wrap->height(); + + if (sizeHints) { + if (!(sizeHints->flags & PBaseSize)) { + bw = 0; + bh = 0; + } else { + bw = sizeHints->base_width; + bh = sizeHints->base_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; + + } + } + + QString pos; + pos.sprintf( "%+d,%+d (%d x %d)", + geom.x(), geom.y(), w, h ); + setText( pos ); + adjustSize(); + move( geom.x() + ((geom.width() - width()) / 2), + geom.y() + ((geom.height() - height()) / 2) ); +} + + diff --git a/geometrytip.h b/geometrytip.h new file mode 100644 index 0000000000..b0ff460ad7 --- /dev/null +++ b/geometrytip.h @@ -0,0 +1,30 @@ +/* + * $Id$ + * Window Geometry Display + * Copyright (c) 2003, Karol Szwed + */ + +#ifndef KWIN_GEOMETRY_TIP_H +#define KWIN_GEOMETRY_TIP_H + +#include +#include "client.h" + +namespace KWinInternal { + +class GeometryTip: public QLabel +{ + Q_OBJECT + public: + GeometryTip( const Client* client, const XSizeHints* xSizeHints ); + ~GeometryTip(); + void setGeometry( const QRect& geom ); + + private: + const XSizeHints* sizeHints; + const Client* c; +}; + +}; + +#endif