autoraise and clickraise

svn path=/trunk/kdebase/kcontrol/; revision=55877
This commit is contained in:
Matthias Ettrich 2000-07-09 20:29:53 +00:00
parent 7d6a4f63ed
commit 3156291b39
5 changed files with 89 additions and 26 deletions

View file

@ -233,7 +233,8 @@ static void ungrabButton( WId winId, int modifier )
void WindowWrapper::setActive( bool active ) void WindowWrapper::setActive( bool active )
{ {
if ( active ) { if ( active ) {
ungrabButton( winId(), None ); if ( options->focusPolicy == Options::ClickToFocus || !options->clickRaise )
ungrabButton( winId(), None );
ungrabButton( winId(), ShiftMask ); ungrabButton( winId(), ShiftMask );
ungrabButton( winId(), ControlMask ); ungrabButton( winId(), ControlMask );
ungrabButton( winId(), ControlMask | ShiftMask ); ungrabButton( winId(), ControlMask | ShiftMask );
@ -319,6 +320,12 @@ bool WindowWrapper::x11Event( XEvent * e)
switch ( e->type ) { switch ( e->type ) {
case ButtonPress: 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; bool mod1 = (e->xbutton.state & Mod1Mask) == Mod1Mask;
Options::MouseCommand com = Options::MouseNothing; Options::MouseCommand com = Options::MouseNothing;
if ( mod1){ if ( mod1){
@ -381,6 +388,7 @@ Client::Client( Workspace *ws, WId w, QWidget *parent, const char *name, WFlags
{ {
wspace = ws; wspace = ws;
win = w; win = w;
autoRaiseTimer = 0;
unsigned long properties = unsigned long properties =
NET::WMDesktop | 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? // should we open this window on a certain desktop?
if ( info->desktop() == NETWinInfo::OnAllDesktops ) if ( info->desktop() == NETWinInfo::OnAllDesktops )
setSticky( TRUE ); setSticky( TRUE );
else if ( info->desktop() ) else if ( info->desktop() )
desk= info->desktop(); // window had the initial desktop property! desk= info->desktop(); // window had the initial desktop property!
// window wants to stay on top? // window wants to stay on top?
stays_on_top = info->state() & NET::StaysOnTop; stays_on_top = info->state() & NET::StaysOnTop;
// if this window is transient, ensure that it is opened on the // 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 ) if ( options->focusPolicy == Options::ClickToFocus )
return TRUE; 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() ) ) if ( options->focusPolicy != Options::FocusStrictlyUnderMouse && ( isDesktop() || isDock() ) )
return TRUE; return TRUE;
@ -1598,6 +1613,8 @@ bool Client::x11Event( XEvent * e)
return TRUE; return TRUE;
} }
if ( e->type == LeaveNotify && e->xcrossing.mode == NotifyNormal ) { if ( e->type == LeaveNotify && e->xcrossing.mode == NotifyNormal ) {
delete autoRaiseTimer;
autoRaiseTimer = 0;
if ( !buttonDown ) if ( !buttonDown )
setCursor( arrowCursor ); setCursor( arrowCursor );
if ( options->focusPolicy == Options::FocusStrictlyUnderMouse ) if ( options->focusPolicy == Options::FocusStrictlyUnderMouse )
@ -1693,7 +1710,7 @@ void Client::setShade( bool s )
shaded = s; shaded = s;
int as = options->animateShade()? options->animSteps() : 1; int as = options->animateShade? options->animSteps : 1;
if (shaded ) { if (shaded ) {
int h = height(); int h = height();
@ -1760,6 +1777,10 @@ void Client::setActive( bool act)
if ( active == act ) if ( active == act )
return; return;
active = act; active = act;
if ( !active && autoRaiseTimer ) {
delete autoRaiseTimer;
autoRaiseTimer = 0;
}
activeChange( active ); activeChange( active );
} }
@ -1789,7 +1810,7 @@ void Client::setSticky( bool b )
/*! /*!
Let the window stay on top or not, depending on \a b Let the window stay on top or not, depending on \a b
\sa Workspace::setClientOnTop() \sa Workspace::setClientOnTop()
*/ */
void Client::setStaysOnTop( bool b ) void Client::setStaysOnTop( bool b )
@ -2299,6 +2320,10 @@ void Client::animateIconifyOrDeiconify( bool iconify)
XUngrabServer( qt_xdisplay() ); XUngrabServer( qt_xdisplay() );
} }
/*!
The pixmap shown during iconify/deiconify animation
*/
QPixmap Client::animationPixmap( int w ) QPixmap Client::animationPixmap( int w )
{ {
QFont font = options->font(isActive()); 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 ) NoBorderClient::NoBorderClient( Workspace *ws, WId w, QWidget *parent, const char *name )
: Client( ws, w, parent, name ) : Client( ws, w, parent, name )
{ {

View file

@ -165,6 +165,9 @@ public slots:
void toggleSticky(); void toggleSticky();
void contextHelp(); void contextHelp();
private slots:
void autoRaise();
protected: protected:
void paintEvent( QPaintEvent * ); void paintEvent( QPaintEvent * );
void mousePressEvent( QMouseEvent * ); void mousePressEvent( QMouseEvent * );
@ -260,6 +263,7 @@ private:
QRect geom_restore; QRect geom_restore;
QRegion mask; QRegion mask;
WinInfo* info; WinInfo* info;
QTimer* autoRaiseTimer;
}; };

View file

@ -153,12 +153,19 @@ void Options::reload()
else if (val == "Random") placement = Random; else if (val == "Random") placement = Random;
else if (val == "Cascade") placement = Cascade; 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") ); OpTitlebarDblClick = windowOperation( config->readEntry("TitlebarDoubleClickCommand", "Shade") );

View file

@ -56,6 +56,22 @@ public:
FocusPolicy focusPolicy; 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: Different Alt-Tab-Styles:
<ul> <ul>
@ -118,22 +134,26 @@ public:
* Return the active or inactive decoration font. * Return the active or inactive decoration font.
*/ */
const QFont& font(bool active=true); const QFont& font(bool active=true);
/** /**
* Return whether we animate the shading of windows to titlebar or not * whether we animate the shading of windows to titlebar or not
*/ */
const bool animateShade() { return animate_shade; }; bool animateShade;
/** /**
* Return the number of animation steps (would this be general?) * the number of animation steps (would this be general?)
*/ */
const int animSteps() { return anim_steps; }; int animSteps;
/** /**
* Return the size of the zone that triggers snapping on desktop borders * the size of the zone that triggers snapping on desktop borders
*/ */
const int borderSnapZone() { return border_snap_zone; }; int borderSnapZone;
/** /**
* Return the number of animation steps (would this be general?) * the number of animation steps (would this be general?)
*/ */
const int windowSnapZone() { return window_snap_zone; }; int windowSnapZone;
@ -192,9 +212,7 @@ protected:
QColorGroup *cg[KWINCOLORS*2]; QColorGroup *cg[KWINCOLORS*2];
private: private:
bool animate_shade;
int anim_steps;
int border_snap_zone, window_snap_zone;
WindowOperation OpTitlebarDblClick; WindowOperation OpTitlebarDblClick;

View file

@ -1034,7 +1034,7 @@ void Workspace::clientHidden( Client* c )
{ {
if ( c != active_client && ( active_client || c != should_get_focus ) ) if ( c != active_client && ( active_client || c != should_get_focus ) )
return; return;
active_client = 0; active_client = 0;
should_get_focus = 0; should_get_focus = 0;
if (!block_focus && if (!block_focus &&
@ -2155,7 +2155,7 @@ QPoint Workspace::adjustClientPosition( Client* c, QPoint pos )
{ {
//CT 16mar98, 27May98 - magics: BorderSnapZone, WindowSnapZone //CT 16mar98, 27May98 - magics: BorderSnapZone, WindowSnapZone
//CT adapted for kwin on 25Nov1999 //CT adapted for kwin on 25Nov1999
if (options->windowSnapZone() || options->borderSnapZone()) { if (options->windowSnapZone || options->borderSnapZone ) {
int snap; //snap trigger int snap; //snap trigger
@ -2177,7 +2177,7 @@ QPoint Workspace::adjustClientPosition( Client* c, QPoint pos )
ry = cy + (ch = c->height()); ry = cy + (ch = c->height());
// border snap // border snap
snap = options->borderSnapZone(); snap = options->borderSnapZone;
if (snap) { if (snap) {
if ( QABS(cx-xmin) < snap ){ if ( QABS(cx-xmin) < snap ){
deltaX = QABS(cx - xmin); deltaX = QABS(cx - xmin);
@ -2199,7 +2199,7 @@ QPoint Workspace::adjustClientPosition( Client* c, QPoint pos )
} }
// windows snap // windows snap
snap = options->windowSnapZone(); snap = options->windowSnapZone;
if (snap) { if (snap) {
QValueList<Client *>::ConstIterator l; QValueList<Client *>::ConstIterator l;
for (l = clients.begin();l != clients.end();++l ) { for (l = clients.begin();l != clients.end();++l ) {