Recommiting PopupInfo after several thousand cleanups inspired by CT
svn path=/trunk/kdebase/kwin/; revision=147307
This commit is contained in:
parent
789bb8c535
commit
d343b3a1a3
4 changed files with 205 additions and 3 deletions
|
@ -7,7 +7,7 @@ lib_LTLIBRARIES = kwin.la
|
||||||
|
|
||||||
# workspace.cpp has to be first in order not to break --enable-final
|
# workspace.cpp has to be first in order not to break --enable-final
|
||||||
kwin_la_SOURCES = workspace.cpp atoms.cpp client.cpp main.cpp \
|
kwin_la_SOURCES = workspace.cpp atoms.cpp client.cpp main.cpp \
|
||||||
tabbox.cpp options.cpp plugins.cpp events.cpp KWinInterface.skel \
|
popupinfo.cpp tabbox.cpp options.cpp plugins.cpp events.cpp KWinInterface.skel \
|
||||||
killwindow.cpp kwinbutton.cpp
|
killwindow.cpp kwinbutton.cpp
|
||||||
kwin_la_LIBADD = $(LIB_KDEUI) $(LIBXINERAMA)
|
kwin_la_LIBADD = $(LIB_KDEUI) $(LIBXINERAMA)
|
||||||
kwin_la_LDFLAGS = $(all_libraries) -module -avoid-version
|
kwin_la_LDFLAGS = $(all_libraries) -module -avoid-version
|
||||||
|
|
137
popupinfo.cpp
Normal file
137
popupinfo.cpp
Normal file
|
@ -0,0 +1,137 @@
|
||||||
|
/*****************************************************************
|
||||||
|
kwin - the KDE window manager
|
||||||
|
|
||||||
|
Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org>
|
||||||
|
******************************************************************/
|
||||||
|
//#define QT_CLEAN_NAMESPACE
|
||||||
|
#include "popupinfo.h"
|
||||||
|
#include "workspace.h"
|
||||||
|
#include "client.h"
|
||||||
|
#include <qpainter.h>
|
||||||
|
#include <qlabel.h>
|
||||||
|
#include <qdrawutil.h>
|
||||||
|
#include <qstyle.h>
|
||||||
|
#undef Bool // f**king X11
|
||||||
|
#include <kglobal.h>
|
||||||
|
#include <kconfig.h>
|
||||||
|
#include <kdebug.h>
|
||||||
|
#include <klocale.h>
|
||||||
|
#include <qapplication.h>
|
||||||
|
#include <qdesktopwidget.h>
|
||||||
|
#include <qcursor.h>
|
||||||
|
#include <kstringhandler.h>
|
||||||
|
|
||||||
|
// specify externals before namespace
|
||||||
|
|
||||||
|
using namespace KWinInternal;
|
||||||
|
|
||||||
|
PopupInfo::PopupInfo( const char *name )
|
||||||
|
: QWidget( 0, name, WStyle_Customize | WStyle_NoBorder )
|
||||||
|
{
|
||||||
|
m_infoString = "";
|
||||||
|
reset();
|
||||||
|
reconfigure();
|
||||||
|
connect(&m_delayedHideTimer, SIGNAL(timeout()), this, SLOT(hide()));
|
||||||
|
|
||||||
|
QFont f = font();
|
||||||
|
f.setBold( TRUE );
|
||||||
|
f.setPointSize( 14 );
|
||||||
|
setFont( f );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
PopupInfo::~PopupInfo()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Resets the popup info
|
||||||
|
*/
|
||||||
|
void PopupInfo::reset()
|
||||||
|
{
|
||||||
|
QDesktopWidget* desktop = qApp->desktop();
|
||||||
|
int screen = desktop->screenNumber( QCursor::pos() );
|
||||||
|
QRect r = desktop->screenGeometry(screen);
|
||||||
|
|
||||||
|
int w = fontMetrics().width( m_infoString ) + 30;
|
||||||
|
|
||||||
|
setGeometry(
|
||||||
|
(r.width()-w)/2 + r.x(), r.height()/2-fontMetrics().height()-10 + r.y(),
|
||||||
|
w, fontMetrics().height() + 20 );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Paints the popup info
|
||||||
|
*/
|
||||||
|
void PopupInfo::paintEvent( QPaintEvent* )
|
||||||
|
{
|
||||||
|
QPainter p( this );
|
||||||
|
style().drawPrimitive( QStyle::PE_Panel, &p, QRect( 0, 0, width(), height() ),
|
||||||
|
colorGroup(), QStyle::Style_Default );
|
||||||
|
paintContents();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Paints the contents of the tab popup info box.
|
||||||
|
Used in paintEvent() and whenever the contents changes.
|
||||||
|
*/
|
||||||
|
void PopupInfo::paintContents()
|
||||||
|
{
|
||||||
|
QPainter p( this );
|
||||||
|
QRect r( 6, 6, width()-12, height()-12 );
|
||||||
|
|
||||||
|
p.fillRect( r, colorGroup().brush( QColorGroup::Background ) );
|
||||||
|
|
||||||
|
/*
|
||||||
|
p.setPen(Qt::white);
|
||||||
|
p.drawText( r, AlignCenter, m_infoString );
|
||||||
|
p.setPen(Qt::black);
|
||||||
|
r.moveBy( -1, -1 );
|
||||||
|
p.drawText( r, AlignCenter, m_infoString );
|
||||||
|
r.moveBy( -1, 0 );
|
||||||
|
*/
|
||||||
|
p.drawText( r, AlignCenter, m_infoString );
|
||||||
|
}
|
||||||
|
|
||||||
|
void PopupInfo::hide()
|
||||||
|
{
|
||||||
|
m_delayedHideTimer.stop();
|
||||||
|
QWidget::hide();
|
||||||
|
QApplication::syncX();
|
||||||
|
XEvent otherEvent;
|
||||||
|
while (XCheckTypedEvent (qt_xdisplay(), EnterNotify, &otherEvent ) )
|
||||||
|
;
|
||||||
|
m_shown = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PopupInfo::reconfigure()
|
||||||
|
{
|
||||||
|
KConfig * c(KGlobal::config());
|
||||||
|
c->setGroup("PopupInfo");
|
||||||
|
m_show = c->readNumEntry("Show", false );
|
||||||
|
m_delayTime = c->readNumEntry("HideDelay", 250 );
|
||||||
|
}
|
||||||
|
|
||||||
|
void PopupInfo::showInfo(QString infoString)
|
||||||
|
{
|
||||||
|
if (m_show) {
|
||||||
|
m_infoString = infoString;
|
||||||
|
if (m_shown) {
|
||||||
|
// AK, maybe reset() should be called for every view, otherwise the
|
||||||
|
// contents is painted but setGeometry not called
|
||||||
|
// reset();
|
||||||
|
paintContents();
|
||||||
|
} else {
|
||||||
|
reset();
|
||||||
|
show();
|
||||||
|
raise();
|
||||||
|
m_shown = true;
|
||||||
|
}
|
||||||
|
m_delayedHideTimer.start(m_delayTime, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "popupinfo.moc"
|
43
popupinfo.h
Normal file
43
popupinfo.h
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
/*****************************************************************
|
||||||
|
kwin - the KDE window manager
|
||||||
|
|
||||||
|
Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org>
|
||||||
|
******************************************************************/
|
||||||
|
#ifndef POPUPINFO_H
|
||||||
|
#define POPUPINFO_H
|
||||||
|
#include <qwidget.h>
|
||||||
|
#include <qtimer.h>
|
||||||
|
#include <qvaluelist.h>
|
||||||
|
|
||||||
|
namespace KWinInternal {
|
||||||
|
|
||||||
|
class Workspace;
|
||||||
|
|
||||||
|
class PopupInfo : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
PopupInfo( const char *name=0 );
|
||||||
|
~PopupInfo();
|
||||||
|
|
||||||
|
void reset();
|
||||||
|
void hide();
|
||||||
|
void showInfo(QString infoString);
|
||||||
|
|
||||||
|
void reconfigure();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void paintEvent( QPaintEvent* );
|
||||||
|
void paintContents();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QTimer m_delayedHideTimer;
|
||||||
|
int m_delayTime;
|
||||||
|
bool m_show;
|
||||||
|
bool m_shown;
|
||||||
|
QString m_infoString;
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -28,6 +28,7 @@ Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org>
|
||||||
#include "workspace.h"
|
#include "workspace.h"
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
#include "tabbox.h"
|
#include "tabbox.h"
|
||||||
|
#include "popupinfo.h"
|
||||||
#include "atoms.h"
|
#include "atoms.h"
|
||||||
#include "plugins.h"
|
#include "plugins.h"
|
||||||
#include "events.h"
|
#include "events.h"
|
||||||
|
@ -272,6 +273,7 @@ Workspace::Workspace( bool restore )
|
||||||
mouse_emulation (false),
|
mouse_emulation (false),
|
||||||
focus_change (true),
|
focus_change (true),
|
||||||
tab_box (0),
|
tab_box (0),
|
||||||
|
popupinfo (0),
|
||||||
popup (0),
|
popup (0),
|
||||||
desk_popup (0),
|
desk_popup (0),
|
||||||
keys (0),
|
keys (0),
|
||||||
|
@ -331,6 +333,7 @@ Workspace::Workspace( bool restore )
|
||||||
|
|
||||||
initShortcuts();
|
initShortcuts();
|
||||||
tab_box = new TabBox( this );
|
tab_box = new TabBox( this );
|
||||||
|
popupinfo = new PopupInfo( );
|
||||||
|
|
||||||
init();
|
init();
|
||||||
|
|
||||||
|
@ -456,6 +459,7 @@ Workspace::~Workspace()
|
||||||
}
|
}
|
||||||
delete desktop_widget;
|
delete desktop_widget;
|
||||||
delete tab_box;
|
delete tab_box;
|
||||||
|
delete popupinfo;
|
||||||
delete popup;
|
delete popup;
|
||||||
if ( root == qt_xrootwin() )
|
if ( root == qt_xrootwin() )
|
||||||
XDeleteProperty(qt_xdisplay(), qt_xrootwin(), atoms->kwin_running);
|
XDeleteProperty(qt_xdisplay(), qt_xrootwin(), atoms->kwin_running);
|
||||||
|
@ -1182,8 +1186,10 @@ bool Workspace::keyRelease(XKeyEvent& ev)
|
||||||
tab_box->hide();
|
tab_box->hide();
|
||||||
keys->setEnabled( true );
|
keys->setEnabled( true );
|
||||||
control_grab = False;
|
control_grab = False;
|
||||||
if ( tab_box->currentDesktop() != -1 )
|
if ( tab_box->currentDesktop() != -1 ) {
|
||||||
setCurrentDesktop( tab_box->currentDesktop() );
|
setCurrentDesktop( tab_box->currentDesktop() );
|
||||||
|
// popupinfo->showInfo( desktopName(currentDesktop()) ); // AK - not sure
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -1432,6 +1438,7 @@ void Workspace::activateClient( Client* c, bool force )
|
||||||
|
|
||||||
if (!c->isOnDesktop(currentDesktop()) ) {
|
if (!c->isOnDesktop(currentDesktop()) ) {
|
||||||
setCurrentDesktop( c->desktop() );
|
setCurrentDesktop( c->desktop() );
|
||||||
|
// popupinfo->showInfo( desktopName(currentDesktop()) ); // AK - not sure
|
||||||
}
|
}
|
||||||
c->updateUserTime();
|
c->updateUserTime();
|
||||||
|
|
||||||
|
@ -2039,6 +2046,7 @@ void Workspace::slotReconfigure()
|
||||||
KGlobal::config()->reparseConfiguration();
|
KGlobal::config()->reparseConfiguration();
|
||||||
options->reload();
|
options->reload();
|
||||||
tab_box->reconfigure();
|
tab_box->reconfigure();
|
||||||
|
popupinfo->reconfigure();
|
||||||
readShortcuts();
|
readShortcuts();
|
||||||
|
|
||||||
mgr->updatePlugin();
|
mgr->updatePlugin();
|
||||||
|
@ -2211,6 +2219,9 @@ void Workspace::raiseClient( Client* c )
|
||||||
if ( tab_box->isVisible() )
|
if ( tab_box->isVisible() )
|
||||||
tab_box->raise();
|
tab_box->raise();
|
||||||
|
|
||||||
|
if ( popupinfo->isVisible() )
|
||||||
|
popupinfo->raise();
|
||||||
|
|
||||||
raiseElectricBorders();
|
raiseElectricBorders();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2544,12 +2555,14 @@ void Workspace::nextDesktop()
|
||||||
{
|
{
|
||||||
int desktop = currentDesktop() + 1;
|
int desktop = currentDesktop() + 1;
|
||||||
setCurrentDesktop(desktop > numberOfDesktops() ? 1 : desktop);
|
setCurrentDesktop(desktop > numberOfDesktops() ? 1 : desktop);
|
||||||
|
popupinfo->showInfo( desktopName(currentDesktop()) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Workspace::previousDesktop()
|
void Workspace::previousDesktop()
|
||||||
{
|
{
|
||||||
int desktop = currentDesktop() - 1;
|
int desktop = currentDesktop() - 1;
|
||||||
setCurrentDesktop(desktop ? desktop : numberOfDesktops());
|
setCurrentDesktop(desktop ? desktop : numberOfDesktops());
|
||||||
|
popupinfo->showInfo( desktopName(currentDesktop()) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -2729,6 +2742,7 @@ void Workspace::slotSwitchDesktopNext(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setCurrentDesktop(d);
|
setCurrentDesktop(d);
|
||||||
|
popupinfo->showInfo( desktopName(currentDesktop()) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Workspace::slotSwitchDesktopPrevious(){
|
void Workspace::slotSwitchDesktopPrevious(){
|
||||||
|
@ -2740,6 +2754,7 @@ void Workspace::slotSwitchDesktopPrevious(){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setCurrentDesktop(d);
|
setCurrentDesktop(d);
|
||||||
|
popupinfo->showInfo( desktopName(currentDesktop()) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Workspace::setDesktopLayout(int o, int x, int y)
|
void Workspace::setDesktopLayout(int o, int x, int y)
|
||||||
|
@ -2791,6 +2806,7 @@ void Workspace::slotSwitchDesktopRight()
|
||||||
dt = dt - (dt % x) + d;
|
dt = dt - (dt % x) + d;
|
||||||
}
|
}
|
||||||
setCurrentDesktop(dt+1);
|
setCurrentDesktop(dt+1);
|
||||||
|
popupinfo->showInfo( desktopName(currentDesktop()) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Workspace::slotSwitchDesktopLeft(){
|
void Workspace::slotSwitchDesktopLeft(){
|
||||||
|
@ -2819,6 +2835,7 @@ void Workspace::slotSwitchDesktopLeft(){
|
||||||
dt = dt - (dt % x) + d;
|
dt = dt - (dt % x) + d;
|
||||||
}
|
}
|
||||||
setCurrentDesktop(dt+1);
|
setCurrentDesktop(dt+1);
|
||||||
|
popupinfo->showInfo( desktopName(currentDesktop()) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Workspace::slotSwitchDesktopUp(){
|
void Workspace::slotSwitchDesktopUp(){
|
||||||
|
@ -2847,6 +2864,7 @@ void Workspace::slotSwitchDesktopUp(){
|
||||||
dt = dt - (dt % y) + d;
|
dt = dt - (dt % y) + d;
|
||||||
}
|
}
|
||||||
setCurrentDesktop(dt+1);
|
setCurrentDesktop(dt+1);
|
||||||
|
popupinfo->showInfo( desktopName(currentDesktop()) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Workspace::slotSwitchDesktopDown(){
|
void Workspace::slotSwitchDesktopDown(){
|
||||||
|
@ -2875,11 +2893,13 @@ void Workspace::slotSwitchDesktopDown(){
|
||||||
dt = dt - (dt % y) + d;
|
dt = dt - (dt % y) + d;
|
||||||
}
|
}
|
||||||
setCurrentDesktop(dt+1);
|
setCurrentDesktop(dt+1);
|
||||||
|
popupinfo->showInfo( desktopName(currentDesktop()) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Workspace::slotSwitchToDesktop( int i )
|
void Workspace::slotSwitchToDesktop( int i )
|
||||||
{
|
{
|
||||||
setCurrentDesktop( i );
|
setCurrentDesktop( i );
|
||||||
|
popupinfo->showInfo( desktopName(currentDesktop()) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2983,6 +3003,7 @@ void Workspace::slotWindowToNextDesktop(){
|
||||||
if (popup_client)
|
if (popup_client)
|
||||||
sendClientToDesktop(popup_client,d);
|
sendClientToDesktop(popup_client,d);
|
||||||
setCurrentDesktop(d);
|
setCurrentDesktop(d);
|
||||||
|
popupinfo->showInfo( desktopName(currentDesktop()) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -2995,6 +3016,7 @@ void Workspace::slotWindowToPreviousDesktop(){
|
||||||
if (popup_client)
|
if (popup_client)
|
||||||
sendClientToDesktop(popup_client,d);
|
sendClientToDesktop(popup_client,d);
|
||||||
setCurrentDesktop(d);
|
setCurrentDesktop(d);
|
||||||
|
popupinfo->showInfo( desktopName(currentDesktop()) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -3199,7 +3221,7 @@ void Workspace::slotWindowOperations()
|
||||||
*/
|
*/
|
||||||
void Workspace::slotWindowClose()
|
void Workspace::slotWindowClose()
|
||||||
{
|
{
|
||||||
if ( tab_box->isVisible() )
|
if ( tab_box->isVisible() || popupinfo->isVisible() )
|
||||||
return;
|
return;
|
||||||
performWindowOperation( popup_client, Options::CloseOp );
|
performWindowOperation( popup_client, Options::CloseOp );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue