merge branches/work/kaction-cleanup-branch: Simplify and clean up KShortcut

svn path=/trunk/KDE/kdebase/workspace/; revision=614599
This commit is contained in:
Simon Hausmann 2006-12-18 12:25:10 +00:00
parent 37cdd4efb8
commit ca449ecaee
5 changed files with 213 additions and 150 deletions

View file

@ -779,7 +779,7 @@ ShortcutDialog::ShortcutDialog( const KShortcut& cut, QWidget* parent )
void ShortcutDialog::accept() void ShortcutDialog::accept()
{ {
foreach( const QKeySequence &seq, shortcut().toList() ) foreach( const QKeySequence &seq, shortcut() )
{ {
if( seq.isEmpty()) if( seq.isEmpty())
break; break;

26
sm.cpp
View file

@ -11,6 +11,7 @@ License. See the file "COPYING" for the exact licensing terms.
#include "sm.h" #include "sm.h"
//#include <kdebug.h>
#include <unistd.h> #include <unistd.h>
#include <stdlib.h> #include <stdlib.h>
#include <pwd.h> #include <pwd.h>
@ -22,7 +23,6 @@ License. See the file "COPYING" for the exact licensing terms.
#include "client.h" #include "client.h"
#include <QSocketNotifier> #include <QSocketNotifier>
#include <qsessionmanager.h> #include <qsessionmanager.h>
#include <kdebug.h>
namespace KWinInternal namespace KWinInternal
{ {
@ -113,7 +113,7 @@ void Workspace::storeSession( KConfig* config, SMSavePhase phase )
config->writeEntry( QString("skipPager")+n, c->skipPager() ); config->writeEntry( QString("skipPager")+n, c->skipPager() );
config->writeEntry( QString("userNoBorder")+n, c->isUserNoBorder() ); config->writeEntry( QString("userNoBorder")+n, c->isUserNoBorder() );
config->writeEntry( QString("windowType")+n, windowTypeToTxt( c->windowType())); config->writeEntry( QString("windowType")+n, windowTypeToTxt( c->windowType()));
config->writeEntry( QString("shortcut")+n, c->shortcut().toStringInternal()); config->writeEntry( QString("shortcut")+n, c->shortcut().toString());
config->writeEntry( QString("stackingOrder")+n, unconstrained_stacking_order.indexOf( c )); config->writeEntry( QString("stackingOrder")+n, unconstrained_stacking_order.indexOf( c ));
} }
} }
@ -257,28 +257,6 @@ bool Workspace::sessionInfoWindowTypeMatch( Client* c, SessionInfo* info )
return info->windowType == c->windowType(); return info->windowType == c->windowType();
} }
// maybe needed later
#if 0
// KMainWindow's without name() given have WM_WINDOW_ROLE in the form
// of <appname>-mainwindow#<number>
// when comparing them for fake session info, it's probably better to check
// them without the trailing number
bool Workspace::windowRoleMatch( const QByteArray& role1, const QByteArray& role2 )
{
if( role1.isEmpty() && role2.isEmpty())
return true;
int pos1 = role1.find( '#' );
int pos2 = role2.find( '#' );
bool ret;
if( pos1 < 0 || pos2 < 0 || pos1 != pos2 )
ret = role1 == role2;
else
ret = qstrncmp( role1, role2, pos1 ) == 0;
kDebug() << "WR:" << role1 << ":" << pos1 << ":" << role2 << ":" << pos2 << ":::" << ret << endl;
return ret;
}
#endif
static const char* const window_type_names[] = static const char* const window_type_names[] =
{ {
"Unknown", "Normal" , "Desktop", "Dock", "Toolbar", "Menu", "Dialog", "Unknown", "Normal" , "Desktop", "Dock", "Toolbar", "Menu", "Dialog",

View file

@ -43,7 +43,7 @@ namespace KWinInternal
extern QPixmap* kwin_get_menu_pix_hack(); extern QPixmap* kwin_get_menu_pix_hack();
TabBox::TabBox( Workspace *ws, const char *name ) TabBox::TabBox( Workspace *ws, const char *name )
: Q3Frame( 0, name, Qt::WNoAutoErase ), client(0), wspace(ws) : Q3Frame( 0, name, Qt::WNoAutoErase ), current_client( NULL ), wspace(ws)
{ {
setFrameStyle(QFrame::StyledPanel | QFrame::Plain); setFrameStyle(QFrame::StyledPanel | QFrame::Plain);
setLineWidth(2); setLineWidth(2);
@ -57,10 +57,25 @@ TabBox::TabBox( Workspace *ws, const char *name )
reconfigure(); reconfigure();
reset(); reset();
connect(&delayedShowTimer, SIGNAL(timeout()), this, SLOT(show())); connect(&delayedShowTimer, SIGNAL(timeout()), this, SLOT(show()));
XSetWindowAttributes attr;
attr.override_redirect = 1;
outline_left = XCreateWindow( display(), rootWindow(), 0, 0, 1, 1, 0,
CopyFromParent, CopyFromParent, CopyFromParent, CWOverrideRedirect, &attr );
outline_right = XCreateWindow( display(), rootWindow(), 0, 0, 1, 1, 0,
CopyFromParent, CopyFromParent, CopyFromParent, CWOverrideRedirect, &attr );
outline_top = XCreateWindow( display(), rootWindow(), 0, 0, 1, 1, 0,
CopyFromParent, CopyFromParent, CopyFromParent, CWOverrideRedirect, &attr );
outline_bottom = XCreateWindow( display(), rootWindow(), 0, 0, 1, 1, 0,
CopyFromParent, CopyFromParent, CopyFromParent, CWOverrideRedirect, &attr );
} }
TabBox::~TabBox() TabBox::~TabBox()
{ {
XDestroyWindow( display(), outline_left );
XDestroyWindow( display(), outline_right );
XDestroyWindow( display(), outline_top );
XDestroyWindow( display(), outline_bottom );
} }
@ -111,7 +126,9 @@ void TabBox::createClientList(ClientList &list, int desktop /*-1 = all*/, Client
else if( !list.contains( modal )) else if( !list.contains( modal ))
list += modal; list += modal;
else else
; // nothing {
// nothing
}
} }
} }
@ -147,10 +164,10 @@ void TabBox::reset()
if ( mode() == WindowsMode ) if ( mode() == WindowsMode )
{ {
client = workspace()->activeClient(); setCurrentClient( workspace()->activeClient());
// get all clients to show // get all clients to show
createClientList(clients, options_traverse_all ? -1 : workspace()->currentDesktop(), client, true); createClientList(clients, options_traverse_all ? -1 : workspace()->currentDesktop(), current_client, true);
// calculate maximum caption width // calculate maximum caption width
cw = fontMetrics().width(no_tasks)+20; cw = fontMetrics().width(no_tasks)+20;
@ -227,7 +244,8 @@ void TabBox::nextPrev( bool next)
{ {
if ( mode() == WindowsMode ) if ( mode() == WindowsMode )
{ {
Client* firstClient = 0; Client* firstClient = NULL;
Client* client = current_client;
do do
{ {
if ( next ) if ( next )
@ -247,6 +265,7 @@ void TabBox::nextPrev( bool next)
break; break;
} }
} while ( client && !clients.contains( client )); } while ( client && !clients.contains( client ));
setCurrentClient( client );
} }
else if( mode() == DesktopMode ) else if( mode() == DesktopMode )
{ {
@ -284,9 +303,18 @@ Client* TabBox::currentClient()
{ {
if ( mode() != WindowsMode ) if ( mode() != WindowsMode )
return 0; return 0;
if (!workspace()->hasClient( client )) if (!workspace()->hasClient( current_client ))
return 0; return 0;
return client; return current_client;
}
void TabBox::setCurrentClient( Client* c )
{
if( current_client != c )
{
current_client = c;
updateOutline();
}
} }
/*! /*!
@ -308,6 +336,11 @@ int TabBox::currentDesktop()
*/ */
void TabBox::showEvent( QShowEvent* ) void TabBox::showEvent( QShowEvent* )
{ {
updateOutline();
XRaiseWindow( display(), outline_left );
XRaiseWindow( display(), outline_right );
XRaiseWindow( display(), outline_top );
XRaiseWindow( display(), outline_bottom );
raise(); raise();
} }
@ -317,6 +350,10 @@ void TabBox::showEvent( QShowEvent* )
*/ */
void TabBox::hideEvent( QHideEvent* ) void TabBox::hideEvent( QHideEvent* )
{ {
XUnmapWindow( display(), outline_left );
XUnmapWindow( display(), outline_right );
XUnmapWindow( display(), outline_top );
XUnmapWindow( display(), outline_bottom );
} }
/*! /*!
@ -355,7 +392,7 @@ void TabBox::drawContents( QPainter * )
if ( workspace()->hasClient( *it ) ) // safety if ( workspace()->hasClient( *it ) ) // safety
{ {
// draw highlight background // draw highlight background
if ( (*it) == currentClient() ) if ( (*it) == current_client )
p.fillRect(x, y, r.width(), lineHeight, palette().brush( QPalette::Highlight )); p.fillRect(x, y, r.width(), lineHeight, palette().brush( QPalette::Highlight ));
// draw icon // draw icon
@ -389,10 +426,10 @@ void TabBox::drawContents( QPainter * )
else else
s += (*it)->caption(); s += (*it)->caption();
s = KStringHandler::cPixelSqueeze(s, fontMetrics(), r.width() - 5 - iconWidth - 8); s = fontMetrics().elidedText(s, Qt::ElideMiddle, r.width() - 5 - iconWidth - 8);
// draw text // draw text
if ( (*it) == currentClient() ) if ( (*it) == current_client )
p.setPen(palette().color( QPalette::HighlightedText )); p.setPen(palette().color( QPalette::HighlightedText ));
else if( (*it)->isMinimized()) else if( (*it)->isMinimized())
{ {
@ -510,6 +547,91 @@ void TabBox::drawContents( QPainter * )
localPainter.drawImage( QPoint( r.x(), r.y() ), pix.toImage() ); localPainter.drawImage( QPoint( r.x(), r.y() ), pix.toImage() );
} }
void TabBox::updateOutline()
{
Client* c = currentClient();
if( c == NULL || this->isHidden() || !c->isShown( true ) || !c->isOnCurrentDesktop())
{
XUnmapWindow( display(), outline_left );
XUnmapWindow( display(), outline_right );
XUnmapWindow( display(), outline_top );
XUnmapWindow( display(), outline_bottom );
return;
}
// left/right parts are between top/bottom, they don't reach as far as the corners
XMoveResizeWindow( display(), outline_left, c->x(), c->y() + 5, 5, c->height() - 10 );
XMoveResizeWindow( display(), outline_right, c->x() + c->width() - 5, c->y() + 5, 5, c->height() - 10 );
XMoveResizeWindow( display(), outline_top, c->x(), c->y(), c->width(), 5 );
XMoveResizeWindow( display(), outline_bottom, c->x(), c->y() + c->height() - 5, c->width(), 5 );
{
QPixmap pix( 5, c->height() - 10 );
QPainter p( &pix );
p.setPen( Qt::white );
p.drawLine( 0, 0, 0, pix.height() - 1 );
p.drawLine( 4, 0, 4, pix.height() - 1 );
p.setPen( Qt::gray );
p.drawLine( 1, 0, 1, pix.height() - 1 );
p.drawLine( 3, 0, 3, pix.height() - 1 );
p.setPen( Qt::black );
p.drawLine( 2, 0, 2, pix.height() - 1 );
p.end();
XSetWindowBackgroundPixmap( display(), outline_left, pix.handle());
XSetWindowBackgroundPixmap( display(), outline_right, pix.handle());
}
{
QPixmap pix( c->width(), 5 );
QPainter p( &pix );
p.setPen( Qt::white );
p.drawLine( 0, 0, pix.width() - 1 - 0, 0 );
p.drawLine( 4, 4, pix.width() - 1 - 4, 4 );
p.drawLine( 0, 0, 0, 4 );
p.drawLine( pix.width() - 1 - 0, 0, pix.width() - 1 - 0, 4 );
p.setPen( Qt::gray );
p.drawLine( 1, 1, pix.width() - 1 - 1, 1 );
p.drawLine( 3, 3, pix.width() - 1 - 3, 3 );
p.drawLine( 1, 1, 1, 4 );
p.drawLine( 3, 3, 3, 4 );
p.drawLine( pix.width() - 1 - 1, 1, pix.width() - 1 - 1, 4 );
p.drawLine( pix.width() - 1 - 3, 3, pix.width() - 1 - 3, 4 );
p.setPen( Qt::black );
p.drawLine( 2, 2, pix.width() - 1 - 2, 2 );
p.drawLine( 2, 2, 2, 4 );
p.drawLine( pix.width() - 1 - 2, 2, pix.width() - 1 - 2, 4 );
p.end();
XSetWindowBackgroundPixmap( display(), outline_top, pix.handle());
}
{
QPixmap pix( c->width(), 5 );
QPainter p( &pix );
p.setPen( Qt::white );
p.drawLine( 4, 0, pix.width() - 1 - 4, 0 );
p.drawLine( 0, 4, pix.width() - 1 - 0, 4 );
p.drawLine( 0, 4, 0, 0 );
p.drawLine( pix.width() - 1 - 0, 4, pix.width() - 1 - 0, 0 );
p.setPen( Qt::gray );
p.drawLine( 3, 1, pix.width() - 1 - 3, 1 );
p.drawLine( 1, 3, pix.width() - 1 - 1, 3 );
p.drawLine( 3, 1, 3, 0 );
p.drawLine( 1, 3, 1, 0 );
p.drawLine( pix.width() - 1 - 3, 1, pix.width() - 1 - 3, 0 );
p.drawLine( pix.width() - 1 - 1, 3, pix.width() - 1 - 1, 0 );
p.setPen( Qt::black );
p.drawLine( 2, 2, pix.width() - 1 - 2, 2 );
p.drawLine( 2, 0, 2, 2 );
p.drawLine( pix.width() - 1 - 2, 0, pix.width() - 1 - 2 , 2 );
p.end();
XSetWindowBackgroundPixmap( display(), outline_bottom, pix.handle());
}
XClearWindow( display(), outline_left );
XClearWindow( display(), outline_right );
XClearWindow( display(), outline_top );
XClearWindow( display(), outline_bottom );
XMapWindow( display(), outline_left );
XMapWindow( display(), outline_right );
XMapWindow( display(), outline_top );
XMapWindow( display(), outline_bottom );
}
void TabBox::hide() void TabBox::hide()
{ {
delayedShowTimer.stop(); delayedShowTimer.stop();
@ -587,7 +709,7 @@ void TabBox::handleMouseEvent( XEvent* e )
{ {
if( workspace()->hasClient( *it ) && (num == 0) ) // safety if( workspace()->hasClient( *it ) && (num == 0) ) // safety
{ {
client = *it; setCurrentClient( *it );
break; break;
} }
num--; num--;
@ -1031,8 +1153,8 @@ void Workspace::tabBoxKeyPress( int keyQt )
backward = cutWalkThroughWindowsReverse.contains( keyQt ); backward = cutWalkThroughWindowsReverse.contains( keyQt );
if (forward || backward) if (forward || backward)
{ {
kDebug(125) << "== " << cutWalkThroughWindows.toStringInternal() kDebug(125) << "== " << cutWalkThroughWindows.toString()
<< " or " << cutWalkThroughWindowsReverse.toStringInternal() << endl; << " or " << cutWalkThroughWindowsReverse.toString() << endl;
KDEWalkThroughWindows( forward ); KDEWalkThroughWindows( forward );
} }
} }

View file

@ -111,18 +111,22 @@ QMenu* Workspace::clientPopup()
desk_popup_index = popup->actions().count(); desk_popup_index = popup->actions().count();
if (options->useTranslucency){ if (options->useTranslucency){
trans_popup = new QMenu( popup ); QMenu *trans_popup = new QMenu( popup );
trans_popup->setFont(KGlobalSettings::menuFont()); QVBoxLayout *transLayout = new QVBoxLayout(trans_popup);
connect( trans_popup, SIGNAL( triggered(QAction*) ), this, SLOT( setPopupClientOpacity(QAction*))); trans_popup->setLayout( transLayout );
const int levels[] = { 100, 90, 75, 50, 25, 10 }; transButton = new QPushButton(trans_popup);
for( unsigned int i = 0; transButton->setObjectName("transButton");
i < sizeof( levels ) / sizeof( levels[ 0 ] ); transButton->setToolTip( i18n("Reset opacity to default value"));
++i ) transSlider = new QSlider(trans_popup);
{ transSlider->setObjectName( "transSlider" );
action = trans_popup->addAction( QString::number( levels[ i ] ) + "%" ); transSlider->setRange( 0, 100 );
action->setCheckable( true ); transSlider->setValue( 100 );
action->setData( levels[ i ] ); 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 = popup->addMenu( trans_popup );
action->setText( i18n("&Opacity") ); action->setText( i18n("&Opacity") );
} }
@ -181,14 +185,31 @@ QMenu* Workspace::clientPopup()
return popup; 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 ) // TODO
return;
int level = action->data().toInt();
active_popup_client->setOpacity( level / 100.0 );
} }
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. The client popup menu will become visible soon.
@ -223,16 +244,6 @@ void Workspace::clientPopupAboutToShow()
mNoBorderOpAction->setChecked( active_popup_client->noBorder() ); mNoBorderOpAction->setChecked( active_popup_client->noBorder() );
mMinimizeOpAction->setEnabled( active_popup_client->isMinimizable() ); mMinimizeOpAction->setEnabled( active_popup_client->isMinimizable() );
mCloseOpAction->setEnabled( active_popup_client->isCloseable() ); 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 );
}
}
} }
@ -393,7 +404,7 @@ void Workspace::clientShortcutUpdated( Client* c )
QAction* action = client_keys->action( key.toLatin1().constData() ); QAction* action = client_keys->action( key.toLatin1().constData() );
if( !c->shortcut().isEmpty()) if( !c->shortcut().isEmpty())
{ {
action->setShortcuts(c->shortcut().toList()); action->setShortcuts(c->shortcut());
connect(action, SIGNAL(triggered(bool)), c, SLOT(shortcutActivated())); connect(action, SIGNAL(triggered(bool)), c, SLOT(shortcutActivated()));
action->setEnabled( true ); action->setEnabled( true );
} }
@ -430,7 +441,7 @@ void Workspace::clientPopupActivated( QAction *action )
} }
void Workspace::performWindowOperation( Client* c, Options::WindowOperation op ) void Workspace::performWindowOperation( Client* c, Options::WindowOperation op )
{ {
if ( !c ) if ( !c )
return; return;
@ -439,7 +450,7 @@ void Workspace::performWindowOperation( Client* c, Options::WindowOperation op )
QCursor::setPos( c->geometry().center() ); QCursor::setPos( c->geometry().center() );
if (op == Options::ResizeOp || op == Options::UnrestrictedResizeOp ) if (op == Options::ResizeOp || op == Options::UnrestrictedResizeOp )
QCursor::setPos( c->geometry().bottomRight()); QCursor::setPos( c->geometry().bottomRight());
switch ( op ) switch ( op )
{ {
case Options::MoveOp: case Options::MoveOp:
c->performMouseCommand( Options::MouseMove, QCursor::pos() ); c->performMouseCommand( Options::MouseMove, QCursor::pos() );
@ -528,7 +539,7 @@ void Workspace::performWindowOperation( Client* c, Options::WindowOperation op )
bool Client::performMouseCommand( Options::MouseCommand command, QPoint globalPos, bool handled ) bool Client::performMouseCommand( Options::MouseCommand command, QPoint globalPos, bool handled )
{ {
bool replay = false; bool replay = false;
switch (command) switch (command)
{ {
case Options::MouseRaise: case Options::MouseRaise:
workspace()->raiseClient( this ); workspace()->raiseClient( this );
@ -668,10 +679,10 @@ bool Client::performMouseCommand( Options::MouseCommand command, QPoint globalPo
workspace()->windowToNextDesktop( this ); workspace()->windowToNextDesktop( this );
break; break;
case Options::MouseOpacityMore: case Options::MouseOpacityMore:
setOpacity( qMin( opacity() + 0.1, 1.0 )); // TODO
break; break;
case Options::MouseOpacityLess: case Options::MouseOpacityLess:
setOpacity( qMax( opacity() - 0.1, 0.0 )); // TODO
break; break;
case Options::MouseNothing: case Options::MouseNothing:
replay = true; replay = true;
@ -695,13 +706,13 @@ void Workspace::slotActivateAttentionWindow()
void Workspace::slotSwitchDesktopNext() void Workspace::slotSwitchDesktopNext()
{ {
int d = currentDesktop() + 1; int d = currentDesktop() + 1;
if ( d > numberOfDesktops() ) if ( d > numberOfDesktops() )
{ {
if ( options->rollOverDesktops ) if ( options->rollOverDesktops )
{ {
d = 1; d = 1;
} }
else else
{ {
return; return;
} }
@ -712,7 +723,7 @@ void Workspace::slotSwitchDesktopNext()
void Workspace::slotSwitchDesktopPrevious() void Workspace::slotSwitchDesktopPrevious()
{ {
int d = currentDesktop() - 1; int d = currentDesktop() - 1;
if ( d <= 0 ) if ( d <= 0 )
{ {
if ( options->rollOverDesktops ) if ( options->rollOverDesktops )
d = numberOfDesktops(); d = numberOfDesktops();
@ -897,7 +908,7 @@ void Workspace::slotWindowToNextDesktop()
{ {
windowToNextDesktop( active_popup_client ? active_popup_client : active_client ); windowToNextDesktop( active_popup_client ? active_popup_client : active_client );
} }
void Workspace::windowToNextDesktop( Client* c ) void Workspace::windowToNextDesktop( Client* c )
{ {
int d = currentDesktop() + 1; int d = currentDesktop() + 1;
@ -919,7 +930,7 @@ void Workspace::slotWindowToPreviousDesktop()
{ {
windowToPreviousDesktop( active_popup_client ? active_popup_client : active_client ); windowToPreviousDesktop( active_popup_client ? active_popup_client : active_client );
} }
void Workspace::windowToPreviousDesktop( Client* c ) void Workspace::windowToPreviousDesktop( Client* c )
{ {
int d = currentDesktop() - 1; int d = currentDesktop() - 1;
@ -1014,7 +1025,7 @@ void Workspace::slotSendToDesktop( QAction *action )
int desk = action->data().toInt(); int desk = action->data().toInt();
if ( !active_popup_client ) if ( !active_popup_client )
return; return;
if ( desk == 0 ) if ( desk == 0 )
{ // the 'on_all_desktops' menu entry { // the 'on_all_desktops' menu entry
active_popup_client->setOnAllDesktops( !active_popup_client->isOnAllDesktops()); active_popup_client->setOnAllDesktops( !active_popup_client->isOnAllDesktops());
return; return;
@ -1173,7 +1184,7 @@ bool Workspace::shortcutAvailable( const KShortcut& cut, Client* ignore ) const
++it ) ++it )
{ {
if( (*it) != ignore && (*it)->shortcut() == cut ) if( (*it) != ignore && (*it)->shortcut() == cut )
return false; return false;
} }
return true; return true;
} }

View file

@ -30,7 +30,6 @@ License. See the file "COPYING" for the exact licensing terms.
#include <X11/extensions/shape.h> #include <X11/extensions/shape.h>
#include <X11/Xatom.h> #include <X11/Xatom.h>
#include <QX11Info> #include <QX11Info>
#include <stdio.h> #include <stdio.h>
#include "atoms.h" #include "atoms.h"
@ -43,68 +42,19 @@ namespace KWinInternal
#ifndef KCMRULES #ifndef KCMRULES
bool Extensions::has_shape = false; // used to store the return values of
int Extensions::shape_event_base = 0; // XShapeQueryExtension.
bool Extensions::has_randr = false; // Necessary since shaped window are an extension to X
int Extensions::randr_event_base = 0; int Shape::kwin_shape_version = 0;
bool Extensions::has_damage = false; int Shape::kwin_shape_event = 0;
int Extensions::damage_event_base = 0;
bool Extensions::has_composite = false;
bool Extensions::has_composite_overlay = false;
bool Extensions::has_fixes = false;
void Extensions::init() // does the window w need a shape combine mask around it?
{ bool Shape::hasShape( WId w)
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 )
{ {
int xws, yws, xbs, ybs; int xws, yws, xbs, ybs;
unsigned int wws, hws, wbs, hbs; unsigned int wws, hws, wbs, hbs;
int boundingShaped = 0, clipShaped = 0; int boundingShaped = 0, clipShaped = 0;
if( !Extensions::shapeAvailable()) if (!available())
return false; return false;
XShapeQueryExtents(display(), w, XShapeQueryExtents(display(), w,
&boundingShaped, &xws, &yws, &wws, &hws, &boundingShaped, &xws, &yws, &wws, &hws,
@ -112,22 +62,21 @@ bool Extensions::hasShape( Window w )
return boundingShaped != 0; return boundingShaped != 0;
} }
int Extensions::randrNotifyEvent() int Shape::shapeEvent()
{ {
#ifdef HAVE_XRANDR return kwin_shape_event;
return randr_event_base + RRScreenChangeNotify;
#else
return 0;
#endif
} }
int Extensions::damageNotifyEvent() void Shape::init()
{ {
#ifdef HAVE_XDAMAGE kwin_shape_version = 0;
return damage_event_base + XDamageNotify; int dummy;
#else if( !XShapeQueryExtension( display(), &kwin_shape_event, &dummy ))
return 0; return;
#endif 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, void Motif::readFlags( WId w, bool& noborder, bool& resize, bool& move,
@ -351,6 +300,7 @@ bool grabbedXServer()
{ {
return server_grab_count > 0; return server_grab_count > 0;
} }
#endif #endif
bool isLocalMachine( const QByteArray& host ) bool isLocalMachine( const QByteArray& host )
@ -388,7 +338,7 @@ ShortcutDialog::ShortcutDialog( const KShortcut& cut )
void ShortcutDialog::accept() void ShortcutDialog::accept()
{ {
foreach( const QKeySequence &seq, shortcut().toList() ) foreach( const QKeySequence &seq, shortcut() )
{ {
if( seq.isEmpty()) if( seq.isEmpty())
break; break;
@ -414,6 +364,8 @@ void ShortcutDialog::accept()
KShortcutDialog::accept(); KShortcutDialog::accept();
} }
#endif #endif
} // namespace } // namespace
#ifndef KCMRULES #ifndef KCMRULES