Delay showing the close window button in present window to prevent accidential closing of windows.
svn path=/trunk/KDE/kdebase/workspace/; revision=1189407
This commit is contained in:
parent
134314a5dc
commit
723f7d1a81
2 changed files with 36 additions and 6 deletions
|
@ -41,6 +41,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
namespace KWin
|
namespace KWin
|
||||||
{
|
{
|
||||||
|
@ -472,13 +473,15 @@ void PresentWindowsEffect::windowInputMouseEvent( Window w, QEvent *e )
|
||||||
if( !m_closeView->isVisible() )
|
if( !m_closeView->isVisible() )
|
||||||
{
|
{
|
||||||
updateCloseWindow();
|
updateCloseWindow();
|
||||||
|
}
|
||||||
|
if( m_closeView->isVisible() )
|
||||||
|
{
|
||||||
|
const QPoint widgetPos = m_closeView->mapFromGlobal( me->pos() );
|
||||||
|
const QPointF scenePos = m_closeView->mapToScene( widgetPos );
|
||||||
|
QMouseEvent event( me->type(), widgetPos, me->pos(), me->button(), me->buttons(), me->modifiers() );
|
||||||
|
m_closeView->windowInputMouseEvent( &event );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const QPoint widgetPos = m_closeView->mapFromGlobal( me->pos() );
|
|
||||||
const QPointF scenePos = m_closeView->mapToScene( widgetPos );
|
|
||||||
QMouseEvent event( me->type(), widgetPos, me->pos(), me->button(), me->buttons(), me->modifiers() );
|
|
||||||
m_closeView->windowInputMouseEvent( &event );
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
// Which window are we hovering over? Always trigger as we don't always get move events before clicking
|
// Which window are we hovering over? Always trigger as we don't always get move events before clicking
|
||||||
// We cannot use m_motionManager.windowAtPoint() as the window might not be visible
|
// We cannot use m_motionManager.windowAtPoint() as the window might not be visible
|
||||||
|
@ -1792,7 +1795,7 @@ void PresentWindowsEffect::updateCloseWindow()
|
||||||
m_closeView->setGeometry( rect.x() + rect.width() - m_closeView->sceneRect().width(), rect.y(),
|
m_closeView->setGeometry( rect.x() + rect.width() - m_closeView->sceneRect().width(), rect.y(),
|
||||||
m_closeView->sceneRect().width(), m_closeView->sceneRect().height() );
|
m_closeView->sceneRect().width(), m_closeView->sceneRect().height() );
|
||||||
if( rect.contains( effects->cursorPos() ) )
|
if( rect.contains( effects->cursorPos() ) )
|
||||||
m_closeView->show();
|
m_closeView->delayedShow();
|
||||||
else
|
else
|
||||||
m_closeView->hide();
|
m_closeView->hide();
|
||||||
}
|
}
|
||||||
|
@ -2007,6 +2010,7 @@ void PresentWindowsEffect::globalShortcutChangedClass( const QKeySequence& seq )
|
||||||
************************************************/
|
************************************************/
|
||||||
CloseWindowView::CloseWindowView( QWidget* parent )
|
CloseWindowView::CloseWindowView( QWidget* parent )
|
||||||
: QGraphicsView(parent)
|
: QGraphicsView(parent)
|
||||||
|
, m_delayedShowTimer( new QTimer( this ))
|
||||||
{
|
{
|
||||||
setWindowFlags( Qt::X11BypassWindowManagerHint );
|
setWindowFlags( Qt::X11BypassWindowManagerHint );
|
||||||
setAttribute( Qt::WA_TranslucentBackground );
|
setAttribute( Qt::WA_TranslucentBackground );
|
||||||
|
@ -2045,10 +2049,17 @@ CloseWindowView::CloseWindowView( QWidget* parent )
|
||||||
form->setPos( left, top );
|
form->setPos( left, top );
|
||||||
scene->setSceneRect( QRectF( QPointF( 0, 0 ), QSizeF( width, height ) ) );
|
scene->setSceneRect( QRectF( QPointF( 0, 0 ), QSizeF( width, height ) ) );
|
||||||
setScene( scene );
|
setScene( scene );
|
||||||
|
|
||||||
|
// setup the timer
|
||||||
|
m_delayedShowTimer->setSingleShot( true );
|
||||||
|
m_delayedShowTimer->setInterval( 500 );
|
||||||
|
connect( m_delayedShowTimer, SIGNAL(timeout()), SLOT(show()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CloseWindowView::windowInputMouseEvent( QMouseEvent* e )
|
void CloseWindowView::windowInputMouseEvent( QMouseEvent* e )
|
||||||
{
|
{
|
||||||
|
if( m_delayedShowTimer->isActive() )
|
||||||
|
return;
|
||||||
if( e->type() == QEvent::MouseMove )
|
if( e->type() == QEvent::MouseMove )
|
||||||
{
|
{
|
||||||
mouseMoveEvent( e );
|
mouseMoveEvent( e );
|
||||||
|
@ -2074,6 +2085,20 @@ void CloseWindowView::drawBackground( QPainter* painter, const QRectF& rect )
|
||||||
m_frame->paintFrame( painter );
|
m_frame->paintFrame( painter );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CloseWindowView::hide()
|
||||||
|
{
|
||||||
|
m_delayedShowTimer->stop();
|
||||||
|
QWidget::hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CloseWindowView::delayedShow()
|
||||||
|
{
|
||||||
|
if( isVisible() || m_delayedShowTimer->isActive() )
|
||||||
|
return;
|
||||||
|
m_delayedShowTimer->start();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
#include "presentwindows.moc"
|
#include "presentwindows.moc"
|
||||||
|
|
|
@ -28,6 +28,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#include <kshortcut.h>
|
#include <kshortcut.h>
|
||||||
#include <QtGui/QGraphicsView>
|
#include <QtGui/QGraphicsView>
|
||||||
|
|
||||||
|
class QTimer;
|
||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
class PushButton;
|
class PushButton;
|
||||||
|
@ -44,12 +45,16 @@ class CloseWindowView : public QGraphicsView
|
||||||
void windowInputMouseEvent( QMouseEvent* e );
|
void windowInputMouseEvent( QMouseEvent* e );
|
||||||
virtual void drawBackground( QPainter* painter, const QRectF& rect );
|
virtual void drawBackground( QPainter* painter, const QRectF& rect );
|
||||||
|
|
||||||
|
void delayedShow();
|
||||||
|
void hide();
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void close();
|
void close();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Plasma::PushButton* m_closeButton;
|
Plasma::PushButton* m_closeButton;
|
||||||
Plasma::FrameSvg* m_frame;
|
Plasma::FrameSvg* m_frame;
|
||||||
|
QTimer* m_delayedShowTimer;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue