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 )
{
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 )
{

View file

@ -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;
};

View file

@ -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") );

View file

@ -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:
<ul>
@ -118,22 +134,26 @@ public:
* Return the active or inactive decoration font.
*/
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];
private:
bool animate_shade;
int anim_steps;
int border_snap_zone, window_snap_zone;
WindowOperation OpTitlebarDblClick;

View file

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