Adapt dependent code to KShortcut/KAction changes.

svn path=/trunk/KDE/kdebase/khotkeys/; revision=608181
This commit is contained in:
Andreas Hartmetz 2006-11-27 00:32:31 +00:00
parent 6001aabfa5
commit 8fc2b1843b
6 changed files with 262 additions and 284 deletions

View file

@ -28,7 +28,6 @@ License. See the file "COPYING" for the exact licensing terms.
#include "atoms.h"
#include "notifications.h"
#include "rules.h"
#include "scene.h"
#include <X11/extensions/shape.h>
#include <QX11Info>
@ -64,10 +63,12 @@ namespace KWinInternal
is done in manage().
*/
Client::Client( Workspace *ws )
: Toplevel( ws ),
: QObject( NULL ),
client( None ),
wrapper( None ),
frame( None ),
decoration( NULL ),
wspace( ws ),
bridge( new Bridge( this )),
move_faked_activity( false ),
move_resize_grab_window( None ),
@ -81,7 +82,7 @@ Client::Client( Workspace *ws )
process_killer( NULL ),
user_time( CurrentTime ), // not known yet
allowed_actions( 0 ),
block_geometry_updates( 0 ),
postpone_geometry_updates( 0 ),
pending_geometry_update( false ),
shade_geometry_change( false ),
border_left( 0 ),
@ -110,6 +111,7 @@ Client::Client( Workspace *ws )
deleting = false;
keep_above = false;
keep_below = false;
is_shape = false;
motif_noborder = false;
motif_may_move = true;
motif_may_resize = true;
@ -122,7 +124,6 @@ Client::Client( Workspace *ws )
modal = false;
noborder = false;
user_noborder = false;
not_obscured = false;
urgency = false;
ignore_focus_stealing = false;
demands_attention = false;
@ -141,7 +142,7 @@ Client::Client( Workspace *ws )
cmap = None;
geom = QRect( 0, 0, 100, 100 ); // so that decorations don't start with size being (0,0)
frame_geometry = QRect( 0, 0, 100, 100 ); // so that decorations don't start with size being (0,0)
client_size = QSize( 100, 100 );
// SELI initialize xsizehints??
@ -154,10 +155,9 @@ Client::~Client()
{
assert(!moveResizeMode);
assert( client == None );
assert( wrapper == None );
// assert( frameId() == None );
assert( frame == None && wrapper == None );
assert( decoration == NULL );
assert( block_geometry_updates == 0 );
assert( postpone_geometry_updates == 0 );
assert( !check_active_modal );
delete info;
delete bridge;
@ -176,15 +176,12 @@ void Client::releaseWindow( bool on_shutdown )
{
assert( !deleting );
deleting = true;
finishCompositing();
workspace()->discardUsedWindowRules( this, true ); // remove ForceTemporarily rules
StackingUpdatesBlocker blocker( workspace());
if (moveResizeMode)
leaveMoveResize();
finishWindowRules();
++block_geometry_updates;
if( isNormalState()) // is mapped?
workspace()->addDamage( geometry());
++postpone_geometry_updates;
setMappingState( WithdrawnState );
setModal( false ); // otherwise its mainwindow wouldn't get focus
hidden = true; // so that it's not considered visible anymore (can't use hideClient(), it would set flags)
@ -222,9 +219,9 @@ void Client::releaseWindow( bool on_shutdown )
client = None;
XDestroyWindow( display(), wrapper );
wrapper = None;
XDestroyWindow( display(), frameId());
// frame = None;
--block_geometry_updates; // don't use GeometryUpdatesBlocker, it would now set the geometry
XDestroyWindow( display(), frame );
frame = None;
--postpone_geometry_updates; // don't use GeometryUpdatesBlocker, it would now set the geometry
deleteClient( this, Allowed );
}
@ -234,15 +231,12 @@ void Client::destroyClient()
{
assert( !deleting );
deleting = true;
finishCompositing();
workspace()->discardUsedWindowRules( this, true ); // remove ForceTemporarily rules
StackingUpdatesBlocker blocker( workspace());
if (moveResizeMode)
leaveMoveResize();
finishWindowRules();
++block_geometry_updates;
if( isNormalState()) // is mapped?
workspace()->addDamage( geometry());
++postpone_geometry_updates;
setModal( false );
hidden = true; // so that it's not considered visible anymore
workspace()->clientHidden( this );
@ -252,9 +246,9 @@ void Client::destroyClient()
client = None; // invalidate
XDestroyWindow( display(), wrapper );
wrapper = None;
XDestroyWindow( display(), frameId());
// frame = None;
--block_geometry_updates; // don't use GeometryUpdatesBlocker, it would now set the geometry
XDestroyWindow( display(), frame );
frame = None;
--postpone_geometry_updates; // don't use GeometryUpdatesBlocker, it would now set the geometry
deleteClient( this, Allowed );
}
@ -264,11 +258,12 @@ void Client::updateDecoration( bool check_workspace_pos, bool force )
|| ( decoration != NULL && !noBorder())))
return;
bool do_show = false;
blockGeometryUpdates( true );
postponeGeometryUpdates( true );
if( force )
destroyDecoration();
if( !noBorder())
{
setMask( QRegion()); // reset shape mask
decoration = workspace()->createDecoration( bridge );
// TODO check decoration's minimum size?
decoration->init();
@ -283,18 +278,15 @@ void Client::updateDecoration( bool check_workspace_pos, bool force )
workarea_diff_x = save_workarea_diff_x;
workarea_diff_y = save_workarea_diff_y;
do_show = true;
if( scene != NULL )
scene->windowGeometryShapeChanged( this );
}
else
destroyDecoration();
if( check_workspace_pos )
checkWorkspacePosition();
blockGeometryUpdates( false );
postponeGeometryUpdates( false );
if( do_show )
decoration->widget()->show();
updateFrameExtents();
addDamageFull();
}
void Client::destroyDecoration()
@ -312,9 +304,6 @@ void Client::destroyDecoration()
move( grav );
workarea_diff_x = save_workarea_diff_x;
workarea_diff_y = save_workarea_diff_y;
if( scene != NULL )
scene->windowGeometryShapeChanged( this );
addDamageFull();
}
}
@ -327,7 +316,7 @@ void Client::checkBorderSizes()
if( new_left == border_left && new_right == border_right
&& new_top == border_top && new_bottom == border_bottom )
return;
GeometryUpdatesBlocker blocker( this );
GeometryUpdatesPostponer blocker( this );
move( calculateGravitation( true ));
border_left = new_left;
border_right = new_right;
@ -344,7 +333,7 @@ void Client::checkBorderSizes()
void Client::detectNoBorder()
{
if( shape())
if( Shape::hasShape( window()))
{
noborder = true;
return;
@ -432,22 +421,47 @@ void Client::setUserNoBorder( bool set )
void Client::updateShape()
{
if ( shape() )
XShapeCombineShape(display(), frameId(), ShapeBounding,
clientPos().x(), clientPos().y(),
window(), ShapeBounding, ShapeSet);
else
XShapeCombineMask( display(), frameId(), ShapeBounding, 0, 0,
None, ShapeSet);
if( scene != NULL )
scene->windowGeometryShapeChanged( this );
addDamageFull();
// workaround for #19644 - shaped windows shouldn't have decoration
if( shape() && !noBorder())
{
noborder = true;
updateDecoration( true );
}
if( shape())
{
XShapeCombineShape(display(), frameId(), ShapeBounding,
clientPos().x(), clientPos().y(),
window(), ShapeBounding, ShapeSet);
}
// !shape() mask setting is done in setMask() when the decoration
// calls it or when the decoration is created/destroyed
if( Shape::version() >= 0x11 ) // 1.1, has input shape support
{ // There appears to be no way to find out if a window has input
// shape set or not, so always propagate the input shape
// (it's the same like the bounding shape by default).
// Also, build the shape using a helper window, not directly
// in the frame window, because the sequence set-shape-to-frame,
// remove-shape-of-client, add-input-shape-of-client has the problem
// that after the second step there's a hole in the input shape
// until the real shape of the client is added and that can make
// the window lose focus (which is a problem with mouse focus policies)
static Window helper_window = None;
if( helper_window == None )
helper_window = XCreateSimpleWindow( display(), rootWindow(),
0, 0, 1, 1, 0, 0, 0 );
XResizeWindow( display(), helper_window, width(), height());
XShapeCombineShape( display(), helper_window, ShapeInput, 0, 0,
frameId(), ShapeBounding, ShapeSet );
XShapeCombineShape( display(), helper_window, ShapeInput,
clientPos().x(), clientPos().y(),
window(), ShapeBounding, ShapeSubtract );
XShapeCombineShape( display(), helper_window, ShapeInput,
clientPos().x(), clientPos().y(),
window(), ShapeInput, ShapeUnion );
XShapeCombineShape( display(), frameId(), ShapeInput, 0, 0,
helper_window, ShapeInput, ShapeSet );
}
}
void Client::setMask( const QRegion& reg, int mode )
@ -476,9 +490,7 @@ void Client::setMask( const QRegion& reg, int mode )
xrects, rects.count(), ShapeSet, mode );
delete[] xrects;
}
if( scene != NULL )
scene->windowGeometryShapeChanged( this );
addDamageFull();
updateShape();
}
QRegion Client::mask() const
@ -727,7 +739,7 @@ void Client::setShade( ShadeMode mode )
}
assert( decoration != NULL ); // noborder windows can't be shaded
GeometryUpdatesBlocker blocker( this );
GeometryUpdatesPostponer blocker( this );
// decorations may turn off some borders when shaded
decoration->borders( border_left, border_right, border_top, border_bottom );
@ -774,13 +786,9 @@ void Client::setShade( ShadeMode mode )
// tell xcompmgr shade's done
_shade = 2;
XChangeProperty(display(), frameId(), atoms->net_wm_window_shade, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &_shade, 1L);
if( isNormalState()) // is mapped?
workspace()->addDamage( geometry());
}
else
{
if( isNormalState()) // is mapped?
workspace()->addDamage( geometry());
int h = height();
shade_geometry_change = true;
QSize s( sizeForClientSize( clientSize()));
@ -915,8 +923,8 @@ void Client::setMappingState(int s)
XChangeProperty(display(), window(), atoms->wm_state, atoms->wm_state, 32,
PropModeReplace, (unsigned char *)data, 2);
if( was_unmanaged ) // manage() did block_geometry_updates = 1, now it's ok to finally set the geometry
blockGeometryUpdates( false );
if( was_unmanaged ) // manage() did postpone_geometry_updates = 1, now it's ok to finally set the geometry
postponeGeometryUpdates( false );
}
/*!
@ -927,7 +935,7 @@ void Client::rawShow()
{
if( decoration != NULL )
decoration->widget()->show(); // not really necessary, but let it know the state
XMapWindow( display(), frameId());
XMapWindow( display(), frame );
if( !isShade())
{
XMapWindow( display(), wrapper );
@ -942,7 +950,6 @@ void Client::rawShow()
*/
void Client::rawHide()
{
workspace()->addDamage( geometry());
// Here it may look like a race condition, as some other client might try to unmap
// the window between these two XSelectInput() calls. However, they're supposed to
// use XWithdrawWindow(), which also sends a synthetic event to the root window,
@ -950,7 +957,7 @@ void Client::rawHide()
// will be missed is also very minimal, so I don't think it's needed to grab the server
// here.
XSelectInput( display(), wrapper, ClientWinMask ); // avoid getting UnmapNotify
XUnmapWindow( display(), frameId());
XUnmapWindow( display(), frame );
XUnmapWindow( display(), wrapper );
XUnmapWindow( display(), client );
XSelectInput( display(), wrapper, ClientWinMask | SubstructureNotifyMask );
@ -1295,7 +1302,7 @@ QString Client::readName() const
return KWin::readNameProperty( window(), XA_WM_NAME );
}
KWIN_COMPARE_PREDICATE( FetchNameInternalPredicate, Client, const Client*, (!cl->isSpecialWindow() || cl->isToolbar()) && cl != value && cl->caption() == value->caption());
KWIN_COMPARE_PREDICATE( FetchNameInternalPredicate, const Client*, (!cl->isSpecialWindow() || cl->isToolbar()) && cl != value && cl->caption() == value->caption());
void Client::setCaption( const QString& _s, bool force )
{
@ -1313,7 +1320,7 @@ void Client::setCaption( const QString& _s, bool force )
QString machine_suffix;
if( wmClientMachine( false ) != "localhost" && !isLocalMachine( wmClientMachine( false )))
machine_suffix = " <@" + wmClientMachine( true ) + '>';
QString shortcut_suffix = !shortcut().isNull() ? ( " {" + shortcut().toString() + '}' ) : "";
QString shortcut_suffix = !shortcut().isEmpty() ? ( " {" + shortcut().toString() + '}' ) : QString();
cap_suffix = machine_suffix + shortcut_suffix;
if ( ( !isSpecialWindow() || isToolbar()) && workspace()->findClient( FetchNameInternalPredicate( this )))
{
@ -1612,6 +1619,58 @@ bool Client::wantsInput() const
return rules()->checkAcceptFocus( input || Ptakefocus );
}
bool Client::isDesktop() const
{
return windowType() == NET::Desktop;
}
bool Client::isDock() const
{
return windowType() == NET::Dock;
}
bool Client::isTopMenu() const
{
return windowType() == NET::TopMenu;
}
bool Client::isMenu() const
{
return windowType() == NET::Menu && !isTopMenu(); // because of backwards comp.
}
bool Client::isToolbar() const
{
return windowType() == NET::Toolbar;
}
bool Client::isSplash() const
{
return windowType() == NET::Splash;
}
bool Client::isUtility() const
{
return windowType() == NET::Utility;
}
bool Client::isDialog() const
{
return windowType() == NET::Dialog;
}
bool Client::isNormalWindow() const
{
return windowType() == NET::Normal;
}
bool Client::isSpecialWindow() const
{
return isDesktop() || isDock() || isSplash() || isTopMenu()
|| isToolbar(); // TODO
}
NET::WindowType Client::windowType( bool direct, int supported_types ) const
{
NET::WindowType wt = info->windowType( supported_types );
@ -1643,12 +1702,6 @@ NET::WindowType Client::windowType( bool direct, int supported_types ) const
return wt;
}
bool Client::isSpecialWindow() const
{
return isDesktop() || isDock() || isSplash() || isTopMenu()
|| isToolbar(); // TODO
}
/*!
Sets an appropriate cursor shape for the logical mouse position \a m
@ -1745,24 +1798,46 @@ void Client::cancelAutoRaise()
autoRaiseTimer = 0;
}
double Client::opacity() const
#ifndef NDEBUG
kdbgstream& operator<<( kdbgstream& stream, const Client* cl )
{
if( info->opacity() == 0xffffffff )
return 1.0;
return info->opacity() * 1.0 / 0xffffffff;
if( cl == NULL )
return stream << "\'NULL_CLIENT\'";
return stream << "\'ID:" << cl->window() << ";WMCLASS:" << cl->resourceClass() << ":" << cl->resourceName() << ";Caption:" << cl->caption() << "\'";
}
void Client::setOpacity( double opacity )
kdbgstream& operator<<( kdbgstream& stream, const ClientList& list )
{
opacity = qBound( 0.0, opacity, 1.0 );
info->setOpacity( static_cast< unsigned long >( opacity * 0xffffffff ));
// we'll react on PropertyNotify
stream << "LIST:(";
bool first = true;
for( ClientList::ConstIterator it = list.begin();
it != list.end();
++it )
{
if( !first )
stream << ":";
first = false;
stream << *it;
}
stream << ")";
return stream;
}
void Client::debug( kdbgstream& stream ) const
kdbgstream& operator<<( kdbgstream& stream, const ConstClientList& list )
{
stream << "\'ID:" << window() << ";WMCLASS:" << resourceClass() << ":" << resourceName() << ";Caption:" << caption() << "\'";
stream << "LIST:(";
bool first = true;
for( ConstClientList::ConstIterator it = list.begin();
it != list.end();
++it )
{
if( !first )
stream << ":";
first = false;
stream << *it;
}
stream << ")";
return stream;
}
#endif
QPixmap * kwin_get_menu_pix_hack()
{

View file

@ -779,11 +779,8 @@ ShortcutDialog::ShortcutDialog( const KShortcut& cut, QWidget* parent )
void ShortcutDialog::accept()
{
for( int i = 0;
;
++i )
foreach( const QKeySequence &seq, shortcut().toList() )
{
QKeySequence seq = shortcut().seq( i );
if( seq.isEmpty())
break;
if( seq[0] == Qt::Key_Escape )
@ -800,7 +797,7 @@ void ShortcutDialog::accept()
if( (seq[0] & Qt::KeyboardModifierMask) == 0 )
{ // no shortcuts without modifiers
KShortcut cut = shortcut();
cut.setSeq( i, QKeySequence());
cut.remove( seq );
setShortcut( cut );
return;
}

View file

@ -831,13 +831,9 @@ static bool areModKeysDepressed( const QKeySequence& seq )
static bool areModKeysDepressed( const KShortcut& cut )
{
for( int i = 0;
i < cut.count();
++i )
{
if( areModKeysDepressed( cut.seq( i )))
return true;
}
if( areModKeysDepressed( cut.primary()) || areModKeysDepressed( cut.alternate()) )
return true;
return false;
}

View file

@ -61,30 +61,30 @@ QMenu* Workspace::clientPopup()
mKeepAboveOpAction = advanced_popup->addAction( i18n("Keep &Above Others") );
mKeepAboveOpAction->setIcon( SmallIconSet( "up" ) );
mKeepAboveOpAction->setShortcut( keys->action("Window Above Other Windows")->globalShortcut() );
mKeepAboveOpAction->setShortcut( keys->action("Window Above Other Windows")->globalShortcut().primary() );
mKeepAboveOpAction->setCheckable( true );
mKeepAboveOpAction->setData( Options::KeepAboveOp );
mKeepBelowOpAction = advanced_popup->addAction( i18n("Keep &Below Others") );
mKeepBelowOpAction->setIcon( SmallIconSet( "down" ) );
mKeepBelowOpAction->setShortcut( keys->action("Window Below Other Windows")->globalShortcut() );
mKeepBelowOpAction->setShortcut( keys->action("Window Below Other Windows")->globalShortcut().primary() );
mKeepBelowOpAction->setCheckable( true );
mKeepBelowOpAction->setData( Options::KeepBelowOp );
mFullScreenOpAction = advanced_popup->addAction( i18n("&Fullscreen") );
mFullScreenOpAction->setIcon( SmallIconSet( "window_fullscreen" ) );
mFullScreenOpAction->setShortcut( keys->action("Window Fullscreen")->globalShortcut() );
mFullScreenOpAction->setShortcut( keys->action("Window Fullscreen")->globalShortcut().primary() );
mFullScreenOpAction->setCheckable( true );
mFullScreenOpAction->setData( Options::FullScreenOp );
mNoBorderOpAction = advanced_popup->addAction( i18n("&No Border") );
mNoBorderOpAction->setShortcut( keys->action("Window No Border")->globalShortcut() );
mNoBorderOpAction->setShortcut( keys->action("Window No Border")->globalShortcut().primary() );
mNoBorderOpAction->setCheckable( true );
mNoBorderOpAction->setData( Options::NoBorderOp );
QAction *action = advanced_popup->addAction( i18n("Window &Shortcut...") );
action->setIcon( SmallIconSet("key_bindings") );
action->setShortcut( keys->action("Setup Window Shortcut")->globalShortcut() );
action->setShortcut( keys->action("Setup Window Shortcut")->globalShortcut().primary() );
action->setData( Options::SetupWindowShortcutOp );
action = advanced_popup->addAction( i18n("&Special Window Settings...") );
@ -101,42 +101,46 @@ QMenu* Workspace::clientPopup()
desk_popup_index = popup->actions().count();
if (options->useTranslucency){
trans_popup = new QMenu( popup );
trans_popup->setFont(KGlobalSettings::menuFont());
connect( trans_popup, SIGNAL( triggered(QAction*) ), this, SLOT( setPopupClientOpacity(QAction*)));
const int levels[] = { 100, 90, 75, 50, 25, 10 };
for( unsigned int i = 0;
i < sizeof( levels ) / sizeof( levels[ 0 ] );
++i )
{
action = trans_popup->addAction( QString::number( levels[ i ] ) + "%" );
action->setCheckable( true );
action->setData( levels[ i ] );
}
QMenu *trans_popup = new QMenu( popup );
QVBoxLayout *transLayout = new QVBoxLayout(trans_popup);
trans_popup->setLayout( transLayout );
transButton = new QPushButton(trans_popup);
transButton->setObjectName("transButton");
transButton->setToolTip( i18n("Reset opacity to default value"));
transSlider = new QSlider(trans_popup);
transSlider->setObjectName( "transSlider" );
transSlider->setRange( 0, 100 );
transSlider->setValue( 100 );
transSlider->setOrientation( Qt::Vertical );
transSlider->setToolTip( i18n("Slide this to set the window's opacity"));
connect(transButton, SIGNAL(clicked()), SLOT(resetClientOpacity()));
connect(transButton, SIGNAL(clicked()), trans_popup, SLOT(hide()));
connect(transSlider, SIGNAL(valueChanged(int)), SLOT(setTransButtonText(int)));
connect(transSlider, SIGNAL(valueChanged(int)), this, SLOT(setPopupClientOpacity(int)));
action = popup->addMenu( trans_popup );
action->setText( i18n("&Opacity") );
}
mMoveOpAction = popup->addAction( i18n("&Move") );
mMoveOpAction->setIcon( SmallIconSet( "move" ) );
mMoveOpAction->setShortcut( keys->action("Window Move")->globalShortcut() );
mMoveOpAction->setShortcut( keys->action("Window Move")->globalShortcut().primary() );
mMoveOpAction->setData( Options::MoveOp );
mResizeOpAction = popup->addAction( i18n("Re&size") );
mResizeOpAction->setShortcut( keys->action("Window Resize")->globalShortcut() );
mResizeOpAction->setShortcut( keys->action("Window Resize")->globalShortcut().primary() );
mResizeOpAction->setData( Options::ResizeOp );
mMinimizeOpAction = popup->addAction( i18n("Mi&nimize") );
mMinimizeOpAction->setShortcut( keys->action("Window Minimize")->globalShortcut() );
mMinimizeOpAction->setShortcut( keys->action("Window Minimize")->globalShortcut().primary() );
mMinimizeOpAction->setData( Options::MinimizeOp );
mMaximizeOpAction = popup->addAction( i18n("Ma&ximize") );
mMaximizeOpAction->setShortcut( keys->action("Window Maximize")->globalShortcut() );
mMaximizeOpAction->setShortcut( keys->action("Window Maximize")->globalShortcut().primary() );
mMaximizeOpAction->setCheckable( true );
mMaximizeOpAction->setData( Options::MaximizeOp );
mShadeOpAction = popup->addAction( i18n("Sh&ade") );
mShadeOpAction->setShortcut( keys->action("Window Shade")->globalShortcut() );
mShadeOpAction->setShortcut( keys->action("Window Shade")->globalShortcut().primary() );
mShadeOpAction->setCheckable( true );
mShadeOpAction->setData( Options::ShadeOp );
@ -153,20 +157,37 @@ QMenu* Workspace::clientPopup()
mCloseOpAction = popup->addAction( i18n("&Close") );
mCloseOpAction->setIcon( SmallIconSet( "fileclose" ) );
mCloseOpAction->setShortcut( keys->action("Window Close")->globalShortcut() );
mCloseOpAction->setShortcut( keys->action("Window Close")->globalShortcut().primary() );
mCloseOpAction->setData( Options::CloseOp );
}
return popup;
}
void Workspace::setPopupClientOpacity( QAction* action )
//sets the transparency of the client to given value(given by slider)
void Workspace::setPopupClientOpacity(int value)
{
if( active_popup_client == NULL )
return;
int level = action->data().toInt();
active_popup_client->setOpacity( level / 100.0 );
// TODO
}
void Workspace::setTransButtonText(int value)
{
value = 100 - value;
if(value < 0)
transButton->setText("000 %");
else if (value >= 100 )
transButton->setText("100 %");
else if(value < 10)
transButton->setText("00"+QString::number(value)+" %");
else if(value < 100)
transButton->setText('0'+QString::number(value)+" %");
}
void Workspace::resetClientOpacity()
{
// TODO
}
/*!
The client popup menu will become visible soon.
@ -201,16 +222,6 @@ void Workspace::clientPopupAboutToShow()
mNoBorderOpAction->setChecked( active_popup_client->noBorder() );
mMinimizeOpAction->setEnabled( active_popup_client->isMinimizable() );
mCloseOpAction->setEnabled( active_popup_client->isCloseable() );
if (options->useTranslucency)
{
foreach( QAction* action, trans_popup->actions())
{
if( action->data().toInt() == qRound( active_popup_client->opacity() * 100 ))
action->setChecked( true );
else
action->setChecked( false );
}
}
}
@ -352,7 +363,7 @@ void Workspace::clientShortcutUpdated( Client* c )
{
QString key = QString::number( c->window());
KAction* action = client_keys->action( key.toLatin1().constData() );
if( !c->shortcut().isNull())
if( !c->shortcut().isEmpty())
{
action->setShortcut(c->shortcut());
connect(action, SIGNAL(triggered(bool)), c, SLOT(shortcutActivated()));
@ -629,10 +640,10 @@ bool Client::performMouseCommand( Options::MouseCommand command, QPoint globalPo
workspace()->windowToNextDesktop( this );
break;
case Options::MouseOpacityMore:
setOpacity( qMin( opacity() + 0.1, 1.0 ));
// TODO
break;
case Options::MouseOpacityLess:
setOpacity( qMax( opacity() - 0.1, 0.0 ));
// TODO
break;
case Options::MouseNothing:
replay = true;
@ -1092,7 +1103,7 @@ void Client::setShortcut( const QString& _cut )
++i )
{
KShortcut c( base + list[ i ] );
if( !c.isNull())
if( !c.isEmpty())
keys.append( c );
}
}

View file

@ -30,7 +30,6 @@ License. See the file "COPYING" for the exact licensing terms.
#include <X11/extensions/shape.h>
#include <X11/Xatom.h>
#include <QX11Info>
#include <stdio.h>
#include "atoms.h"
@ -43,68 +42,19 @@ namespace KWinInternal
#ifndef KCMRULES
bool Extensions::has_shape = false;
int Extensions::shape_event_base = 0;
bool Extensions::has_randr = false;
int Extensions::randr_event_base = 0;
bool Extensions::has_damage = false;
int Extensions::damage_event_base = 0;
bool Extensions::has_composite = false;
bool Extensions::has_composite_overlay = false;
bool Extensions::has_fixes = false;
// used to store the return values of
// XShapeQueryExtension.
// Necessary since shaped window are an extension to X
int Shape::kwin_shape_version = 0;
int Shape::kwin_shape_event = 0;
void Extensions::init()
{
int dummy;
has_shape = XShapeQueryExtension( display(), &shape_event_base, &dummy);
#ifdef HAVE_XRANDR
has_randr = XRRQueryExtension( display(), &randr_event_base, &dummy );
if( has_randr )
{
int major, minor;
XRRQueryVersion( display(), &major, &minor );
has_randr = ( major > 1 || ( major == 1 && minor >= 1 ) );
}
#else
has_randr = false;
#endif
#ifdef HAVE_XDAMAGE
has_damage = XDamageQueryExtension( display(), &damage_event_base, &dummy );
#else
has_damage = false;
#endif
#ifdef HAVE_XCOMPOSITE
has_composite = XCompositeQueryExtension( display(), &dummy, &dummy );
if( has_composite )
{
int major, minor;
XCompositeQueryVersion( display(), &major, &minor );
has_composite = ( major > 0 || minor >= 2 );
has_composite_overlay = ( major > 0 || minor >= 3 );
}
#else
has_composite = false;
has_composite_overlay = false;
#endif
#ifdef HAVE_XFIXES
has_fixes = XFixesQueryExtension( display(), &dummy, &dummy );
#else
has_fixes = false;
#endif
}
int Extensions::shapeNotifyEvent()
{
return shape_event_base + ShapeNotify;
}
// does the window w need a shape combine mask around it?
bool Extensions::hasShape( Window w )
// does the window w need a shape combine mask around it?
bool Shape::hasShape( WId w)
{
int xws, yws, xbs, ybs;
unsigned int wws, hws, wbs, hbs;
int boundingShaped = 0, clipShaped = 0;
if( !Extensions::shapeAvailable())
if (!available())
return false;
XShapeQueryExtents(display(), w,
&boundingShaped, &xws, &yws, &wws, &hws,
@ -112,22 +62,21 @@ bool Extensions::hasShape( Window w )
return boundingShaped != 0;
}
int Extensions::randrNotifyEvent()
int Shape::shapeEvent()
{
#ifdef HAVE_XRANDR
return randr_event_base + RRScreenChangeNotify;
#else
return 0;
#endif
return kwin_shape_event;
}
int Extensions::damageNotifyEvent()
void Shape::init()
{
#ifdef HAVE_XDAMAGE
return damage_event_base + XDamageNotify;
#else
return 0;
#endif
kwin_shape_version = 0;
int dummy;
if( !XShapeQueryExtension( display(), &kwin_shape_event, &dummy ))
return;
int major, minor;
if( !XShapeQueryVersion( display(), &major, &minor ))
return;
kwin_shape_version = major * 0x10 + minor;
}
void Motif::readFlags( WId w, bool& noborder, bool& resize, bool& move,
@ -351,6 +300,7 @@ bool grabbedXServer()
{
return server_grab_count > 0;
}
#endif
bool isLocalMachine( const QByteArray& host )
@ -388,11 +338,8 @@ ShortcutDialog::ShortcutDialog( const KShortcut& cut )
void ShortcutDialog::accept()
{
for( int i = 0;
;
++i )
foreach( const QKeySequence &seq, shortcut().toList() )
{
QKeySequence seq = shortcut().seq( i );
if( seq.isEmpty())
break;
if( seq[0] == Qt::Key_Escape )
@ -409,7 +356,7 @@ void ShortcutDialog::accept()
if( (seq[0] & Qt::KeyboardModifierMask) == 0 )
{ // no shortcuts without modifiers
KShortcut cut = shortcut();
cut.setSeq( i, QKeySequence());
cut.remove( seq );
setShortcut( cut );
return;
}
@ -417,6 +364,8 @@ void ShortcutDialog::accept()
KShortcutDialog::accept();
}
#endif
} // namespace
#ifndef KCMRULES

View file

@ -42,9 +42,6 @@ License. See the file "COPYING" for the exact licensing terms.
#include "group.h"
#include "rules.h"
#include "kwinadaptor.h"
#include "unmanaged.h"
#include "scene.h"
#include "effects.h"
#include <X11/extensions/shape.h>
#include <X11/keysym.h>
@ -96,7 +93,6 @@ Workspace::Workspace( bool restore )
popupinfo (0),
popup (0),
advanced_popup (0),
trans_popup (0),
desk_popup (0),
desk_popup_index (0),
keys (0),
@ -126,12 +122,7 @@ Workspace::Workspace( bool restore )
topmenu_space( NULL ),
set_active_client_recursion( 0 ),
block_stacking_updates( 0 ),
forced_global_mouse_grab( false ),
cm_selection( NULL ),
damage_region( None ),
overlay( None ),
transSlider( NULL ),
transButton( NULL )
forced_global_mouse_grab( false )
{
new KWinAdaptor( "org.kde.kwin", "/KWin", QDBusConnection::sessionBus(), this );
@ -175,12 +166,10 @@ Workspace::Workspace( bool restore )
ColormapChangeMask |
SubstructureRedirectMask |
SubstructureNotifyMask |
FocusChangeMask | // for NotifyDetailNone
ExposureMask
FocusChangeMask // for NotifyDetailNone
);
Extensions::init();
setupCompositing();
Shape::init();
// compatibility
long data = 1;
@ -329,7 +318,6 @@ void Workspace::init()
connect(&reconfigureTimer, SIGNAL(timeout()), this,
SLOT(slotReconfigure()));
connect( &updateToolWindowsTimer, SIGNAL( timeout()), this, SLOT( slotUpdateToolWindows()));
connect( &compositeTimer, SIGNAL( timeout()), SLOT( performCompositing()));
connect(KGlobalSettings::self(), SIGNAL(appearanceChanged()), this,
SLOT(slotReconfigure()));
@ -367,11 +355,7 @@ void Workspace::init()
XWindowAttributes attr;
XGetWindowAttributes(display(), wins[i], &attr);
if (attr.override_redirect )
{
if( attr.map_state != IsUnmapped && attr.c_class != InputOnly && compositing())
createUnmanaged( wins[ i ] );
continue;
}
if( topmenu_space && topmenu_space->winId() == wins[ i ] )
continue;
if (attr.map_state != IsUnmapped)
@ -434,7 +418,6 @@ void Workspace::init()
Workspace::~Workspace()
{
finishCompositing();
blockStackingUpdates( true );
// TODO grabXServer();
// use stacking_order, so that kwin --replace keeps stacking order
@ -446,10 +429,6 @@ Workspace::~Workspace()
(*it)->releaseWindow( true );
// no removeClient() is called !
}
for( UnmanagedList::ConstIterator it = unmanaged.begin();
it != unmanaged.end();
++it )
(*it)->release();
delete desktop_widget;
delete tab_box;
delete popupinfo;
@ -493,28 +472,6 @@ Client* Workspace::createClient( Window w, bool is_mapped )
return NULL;
}
addClient( c, Allowed );
if( scene )
scene->windowAdded( c );
if( effects )
effects->windowAdded( c );
return c;
}
Unmanaged* Workspace::createUnmanaged( Window w )
{
if( w == overlay )
return NULL;
Unmanaged* c = new Unmanaged( this );
if( !c->track( w ))
{
Unmanaged::deleteUnmanaged( c, Allowed );
return NULL;
}
addUnmanaged( c, Allowed );
if( scene )
scene->windowAdded( c );
if( effects )
effects->windowAdded( c );
return c;
}
@ -557,11 +514,6 @@ void Workspace::addClient( Client* c, allowed_t )
updateToolWindows( true );
}
void Workspace::addUnmanaged( Unmanaged* c, allowed_t )
{
unmanaged.append( c );
}
/*
Destroys the client \a c
*/
@ -572,7 +524,7 @@ void Workspace::removeClient( Client* c, allowed_t )
if( client_keys_client == c )
setupWindowShortcutDone( false );
if( !c->shortcut().isNull())
if( !c->shortcut().isEmpty())
c->setShortcut( QString() ); // remove from client_keys
if( c->isDialog())
@ -581,10 +533,6 @@ void Workspace::removeClient( Client* c, allowed_t )
Notify::raise( Notify::Delete );
Q_ASSERT( clients.contains( c ) || desktops.contains( c ));
if( scene )
scene->windowDeleted( c );
if( effects )
effects->windowDeleted( c );
clients.removeAll( c );
desktops.removeAll( c );
unconstrained_stacking_order.removeAll( c );
@ -620,16 +568,6 @@ void Workspace::removeClient( Client* c, allowed_t )
updateClientArea();
}
void Workspace::removeUnmanaged( Unmanaged* c, allowed_t )
{
assert( unmanaged.contains( c ));
if( scene )
scene->windowDeleted( c );
if( effects )
effects->windowDeleted( c );
unmanaged.removeAll( c );
}
void Workspace::updateFocusChains( Client* c, FocusChainChange change )
{
if( !c->wantsTabFocus()) // doesn't want tab focus, remove
@ -655,7 +593,13 @@ void Workspace::updateFocusChains( Client* c, FocusChainChange change )
focus_chain[ i ].prepend( c );
}
else if( !focus_chain[ i ].contains( c ))
focus_chain[ i ].prepend( c ); // otherwise add as the last one
{ // add it after the active one
if( active_client != NULL && active_client != c
&& !focus_chain[ i ].isEmpty() && focus_chain[ i ].last() == active_client )
focus_chain[ i ].insert( focus_chain[ i ].size() - 1, c );
else
focus_chain[ i ].append( c ); // otherwise add as the first one
}
}
}
else //now only on desktop, remove it anywhere else
@ -675,7 +619,13 @@ void Workspace::updateFocusChains( Client* c, FocusChainChange change )
focus_chain[ i ].prepend( c );
}
else if( !focus_chain[ i ].contains( c ))
focus_chain[ i ].prepend( c );
{ // add it after the active one
if( active_client != NULL && active_client != c
&& !focus_chain[ i ].isEmpty() && focus_chain[ i ].last() == active_client )
focus_chain[ i ].insert( focus_chain[ i ].size() - 1, c );
else
focus_chain[ i ].append( c ); // otherwise add as the first one
}
}
else
focus_chain[ i ].removeAll( c );
@ -692,7 +642,13 @@ void Workspace::updateFocusChains( Client* c, FocusChainChange change )
global_focus_chain.prepend( c );
}
else if( !global_focus_chain.contains( c ))
global_focus_chain.prepend( c );
{ // add it after the active one
if( active_client != NULL && active_client != c
&& !global_focus_chain.isEmpty() && global_focus_chain.last() == active_client )
global_focus_chain.insert( global_focus_chain.size() - 1, c );
else
global_focus_chain.append( c ); // otherwise add as the first one
}
}
void Workspace::updateCurrentTopMenu()
@ -926,7 +882,7 @@ void Workspace::slotSettingsChanged(int category)
/*!
Reread settings
*/
KWIN_PROCEDURE( CheckBorderSizesProcedure, Client, cl->checkBorderSizes() );
KWIN_PROCEDURE( CheckBorderSizesProcedure, cl->checkBorderSizes() );
void Workspace::slotReconfigure()
{
@ -983,11 +939,6 @@ void Workspace::slotReconfigure()
updateTopMenuGeometry();
updateCurrentTopMenu();
}
if( options->useTranslucency )
setupCompositing();
else
finishCompositing();
loadWindowRules();
for( ClientList::Iterator it = clients.begin();
@ -1689,7 +1640,7 @@ void Workspace::slotGrabWindow()
QPixmap snapshot = QPixmap::grabWindow( active_client->frameId() );
//No XShape - no work.
if( Extensions::shapeAvailable())
if( Shape::available())
{
//As the first step, get the mask from XShape.
int count, order;
@ -2042,8 +1993,7 @@ void Workspace::createBorderWindows()
XSetWindowAttributes attributes;
unsigned long valuemask;
attributes.override_redirect = True;
attributes.event_mask = (EnterWindowMask | LeaveWindowMask |
VisibilityChangeMask);
attributes.event_mask = ( EnterWindowMask | LeaveWindowMask );
valuemask= (CWOverrideRedirect | CWEventMask | CWCursor );
attributes.cursor = XCreateFontCursor(display(),
XC_sb_up_arrow);
@ -2402,7 +2352,7 @@ void Workspace::helperDialog( const QString& message, const Client* c )
{
KAction* action = keys->action( "Window Operations Menu" );
QString shortcut = QString( "%1 (%2)" ).arg( action->text() )
.arg( action->globalShortcut().seq( 0 ).toString());
.arg( action->globalShortcut().primary().toString());
args << "--msgbox" <<
i18n( "You have selected to show a window without its border.\n"
"Without the border, you will not be able to enable the border "
@ -2415,7 +2365,7 @@ void Workspace::helperDialog( const QString& message, const Client* c )
{
KAction* action = keys->action( "Window Operations Menu" );
QString shortcut = QString( "%1 (%2)" ).arg( action->text() )
.arg( action->globalShortcut().seq( 0 ).toString());
.arg( action->globalShortcut().primary().toString());
args << "--msgbox" <<
i18n( "You have selected to show a window in fullscreen mode.\n"
"If the application itself does not have an option to turn the fullscreen "