autoraise and clickraise
svn path=/trunk/kdebase/kcontrol/; revision=55877
This commit is contained in:
parent
7d6a4f63ed
commit
3156291b39
5 changed files with 89 additions and 26 deletions
36
client.cpp
36
client.cpp
|
@ -233,6 +233,7 @@ static void ungrabButton( WId winId, int modifier )
|
|||
void WindowWrapper::setActive( bool active )
|
||||
{
|
||||
if ( active ) {
|
||||
if ( options->focusPolicy == Options::ClickToFocus || !options->clickRaise )
|
||||
ungrabButton( winId(), None );
|
||||
ungrabButton( winId(), ShiftMask );
|
||||
ungrabButton( winId(), ControlMask );
|
||||
|
@ -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 |
|
||||
|
@ -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 );
|
||||
}
|
||||
|
||||
|
@ -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 )
|
||||
{
|
||||
|
|
4
client.h
4
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;
|
||||
|
||||
};
|
||||
|
||||
|
|
15
options.cpp
15
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") );
|
||||
|
|
40
options.h
40
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:
|
||||
<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;
|
||||
|
|
|
@ -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 ) {
|
||||
|
|
Loading…
Reference in a new issue