From 3156291b39cba451c75f7b6353dd7a4f625c9e76 Mon Sep 17 00:00:00 2001 From: Matthias Ettrich Date: Sun, 9 Jul 2000 20:29:53 +0000 Subject: [PATCH] autoraise and clickraise svn path=/trunk/kdebase/kcontrol/; revision=55877 --- client.cpp | 48 +++++++++++++++++++++++++++++++++++++++++------- client.h | 4 ++++ options.cpp | 15 +++++++++++---- options.h | 40 +++++++++++++++++++++++++++++----------- workspace.cpp | 8 ++++---- 5 files changed, 89 insertions(+), 26 deletions(-) diff --git a/client.cpp b/client.cpp index 46356ed994..c2e51522ea 100644 --- a/client.cpp +++ b/client.cpp @@ -233,7 +233,8 @@ static void ungrabButton( WId winId, int modifier ) void WindowWrapper::setActive( bool active ) { if ( active ) { - ungrabButton( winId(), None ); + if ( options->focusPolicy == Options::ClickToFocus || !options->clickRaise ) + ungrabButton( winId(), None ); ungrabButton( winId(), ShiftMask ); ungrabButton( winId(), ControlMask ); ungrabButton( winId(), ControlMask | ShiftMask ); @@ -319,6 +320,12 @@ bool WindowWrapper::x11Event( XEvent * e) switch ( e->type ) { case ButtonPress: { + if ( ((Client*)parentWidget())->isActive() + && ( options->focusPolicy != Options::ClickToFocus && options->clickRaise ) ) { + ((Client*)parentWidget())->workspace()->raiseClient( (Client*) parentWidget() ); + ungrabButton( winId(), None ); + } + bool mod1 = (e->xbutton.state & Mod1Mask) == Mod1Mask; Options::MouseCommand com = Options::MouseNothing; if ( mod1){ @@ -381,6 +388,7 @@ Client::Client( Workspace *ws, WId w, QWidget *parent, const char *name, WFlags { wspace = ws; win = w; + autoRaiseTimer = 0; unsigned long properties = NET::WMDesktop | @@ -437,14 +445,14 @@ Client::Client( Workspace *ws, WId w, QWidget *parent, const char *name, WFlags // should we open this window on a certain desktop? if ( info->desktop() == NETWinInfo::OnAllDesktops ) setSticky( TRUE ); - else if ( info->desktop() ) + else if ( info->desktop() ) desk= info->desktop(); // window had the initial desktop property! - + // window wants to stay on top? stays_on_top = info->state() & NET::StaysOnTop; - - + + // if this window is transient, ensure that it is opened on the @@ -1591,6 +1599,13 @@ bool Client::x11Event( XEvent * e) if ( options->focusPolicy == Options::ClickToFocus ) return TRUE; + if ( options->autoRaise ) { + delete autoRaiseTimer; + autoRaiseTimer = new QTimer( this ); + connect( autoRaiseTimer, SIGNAL( timeout() ), this, SLOT( autoRaise() ) ); + autoRaiseTimer->start( options->autoRaiseInterval, TRUE ); + } + if ( options->focusPolicy != Options::FocusStrictlyUnderMouse && ( isDesktop() || isDock() ) ) return TRUE; @@ -1598,6 +1613,8 @@ bool Client::x11Event( XEvent * e) return TRUE; } if ( e->type == LeaveNotify && e->xcrossing.mode == NotifyNormal ) { + delete autoRaiseTimer; + autoRaiseTimer = 0; if ( !buttonDown ) setCursor( arrowCursor ); if ( options->focusPolicy == Options::FocusStrictlyUnderMouse ) @@ -1693,7 +1710,7 @@ void Client::setShade( bool s ) shaded = s; - int as = options->animateShade()? options->animSteps() : 1; + int as = options->animateShade? options->animSteps : 1; if (shaded ) { int h = height(); @@ -1760,6 +1777,10 @@ void Client::setActive( bool act) if ( active == act ) return; active = act; + if ( !active && autoRaiseTimer ) { + delete autoRaiseTimer; + autoRaiseTimer = 0; + } activeChange( active ); } @@ -1789,7 +1810,7 @@ void Client::setSticky( bool b ) /*! Let the window stay on top or not, depending on \a b - + \sa Workspace::setClientOnTop() */ void Client::setStaysOnTop( bool b ) @@ -2299,6 +2320,10 @@ void Client::animateIconifyOrDeiconify( bool iconify) XUngrabServer( qt_xdisplay() ); } + +/*! + The pixmap shown during iconify/deiconify animation + */ QPixmap Client::animationPixmap( int w ) { QFont font = options->font(isActive()); @@ -2313,6 +2338,15 @@ QPixmap Client::animationPixmap( int w ) } + +void Client::autoRaise() +{ + workspace()->raiseClient( this ); + delete autoRaiseTimer; + autoRaiseTimer = 0; +} + + NoBorderClient::NoBorderClient( Workspace *ws, WId w, QWidget *parent, const char *name ) : Client( ws, w, parent, name ) { diff --git a/client.h b/client.h index 38df2a7cc1..1ab9250964 100644 --- a/client.h +++ b/client.h @@ -165,6 +165,9 @@ public slots: void toggleSticky(); void contextHelp(); +private slots: + void autoRaise(); + protected: void paintEvent( QPaintEvent * ); void mousePressEvent( QMouseEvent * ); @@ -260,6 +263,7 @@ private: QRect geom_restore; QRegion mask; WinInfo* info; + QTimer* autoRaiseTimer; }; diff --git a/options.cpp b/options.cpp index 3e98e0395e..5acc9d74e9 100644 --- a/options.cpp +++ b/options.cpp @@ -153,12 +153,19 @@ void Options::reload() else if (val == "Random") placement = Random; else if (val == "Cascade") placement = Cascade; - animate_shade = config->readBoolEntry("AnimateShade", TRUE ); + animateShade = config->readBoolEntry("AnimateShade", TRUE ); - anim_steps = config->readNumEntry("AnimSteps", 10); + animSteps = config->readNumEntry("AnimSteps", 10); - border_snap_zone = config->readNumEntry("BorderSnapZone", 10); - window_snap_zone = config->readNumEntry("WindowSnapZone", 10); + + autoRaise = config->readBoolEntry("AutoRaise", FALSE ); + autoRaiseInterval = config->readNumEntry("AutoRaiseInterval", 0 ); + + // important: autoRaise implies ClickRaise + clickRaise = autoRaise || config->readBoolEntry("ClickRaise", FALSE ); + + borderSnapZone = config->readNumEntry("BorderSnapZone", 10); + windowSnapZone = config->readNumEntry("WindowSnapZone", 10); OpTitlebarDblClick = windowOperation( config->readEntry("TitlebarDoubleClickCommand", "Shade") ); diff --git a/options.h b/options.h index ec20f23ebb..d62016d3c7 100644 --- a/options.h +++ b/options.h @@ -56,6 +56,22 @@ public: FocusPolicy focusPolicy; + /** + Whether clicking on a window raises it in FocusFollowsMouse + mode or not. + */ + bool clickRaise; + + /** + whether autoraise is enabled FocusFollowsMouse mode or not. + */ + bool autoRaise; + + /** + autoraise interval + */ + int autoRaiseInterval; + /** Different Alt-Tab-Styles: