2003-09-16 19:28:03 +00:00
|
|
|
/*****************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org>
|
|
|
|
|
|
|
|
You can Freely distribute this program under the GNU General Public
|
|
|
|
License. See the file "COPYING" for the exact licensing terms.
|
|
|
|
******************************************************************/
|
|
|
|
|
|
|
|
#include "bridge.h"
|
|
|
|
|
|
|
|
#include "client.h"
|
|
|
|
#include "options.h"
|
|
|
|
|
|
|
|
namespace KWinInternal
|
|
|
|
{
|
|
|
|
|
|
|
|
Bridge::Bridge( Client* cl )
|
|
|
|
: c( cl )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
#define BRIDGE_HELPER( rettype, prototype, args1, args2, cst ) \
|
|
|
|
rettype Bridge::prototype ( args1 ) cst \
|
|
|
|
{ \
|
|
|
|
return c->prototype( args2 ); \
|
|
|
|
}
|
|
|
|
|
|
|
|
BRIDGE_HELPER( bool, isActive,,, const )
|
|
|
|
BRIDGE_HELPER( bool, isCloseable,,, const )
|
|
|
|
BRIDGE_HELPER( bool, isMaximizable,,, const )
|
|
|
|
BRIDGE_HELPER( Bridge::MaximizeMode, maximizeMode,,, const )
|
|
|
|
BRIDGE_HELPER( bool, isMinimizable,,, const )
|
|
|
|
BRIDGE_HELPER( bool, providesContextHelp,,, const )
|
|
|
|
BRIDGE_HELPER( int, desktop,,, const )
|
|
|
|
BRIDGE_HELPER( bool, isModal,,, const )
|
|
|
|
BRIDGE_HELPER( bool, isShadeable,,, const )
|
|
|
|
BRIDGE_HELPER( bool, isShade,,, const )
|
|
|
|
BRIDGE_HELPER( bool, keepAbove,,, const )
|
|
|
|
BRIDGE_HELPER( bool, keepBelow,,, const )
|
|
|
|
BRIDGE_HELPER( bool, isMovable,,, const )
|
|
|
|
BRIDGE_HELPER( bool, isResizable,,, const )
|
|
|
|
BRIDGE_HELPER( QString, caption,,, const )
|
|
|
|
BRIDGE_HELPER( void, processMousePressEvent, QMouseEvent* e, e, )
|
|
|
|
BRIDGE_HELPER( QRect, geometry,,, const )
|
|
|
|
BRIDGE_HELPER( void, closeWindow,,, )
|
|
|
|
BRIDGE_HELPER( void, maximize, MaximizeMode m, m, )
|
|
|
|
BRIDGE_HELPER( void, minimize,,, )
|
|
|
|
BRIDGE_HELPER( void, showContextHelp,,, )
|
|
|
|
BRIDGE_HELPER( void, setDesktop, int desktop, desktop, )
|
2005-05-02 12:49:06 +00:00
|
|
|
|
|
|
|
void Bridge::setKeepAbove( bool set )
|
|
|
|
{
|
|
|
|
if( c->keepAbove() != set )
|
|
|
|
c->workspace()->performWindowOperation( c, KeepAboveOp );
|
|
|
|
}
|
|
|
|
|
|
|
|
void Bridge::setKeepBelow( bool set )
|
|
|
|
{
|
|
|
|
if( c->keepBelow() != set )
|
|
|
|
c->workspace()->performWindowOperation( c, KeepBelowOp );
|
|
|
|
}
|
2003-09-16 19:28:03 +00:00
|
|
|
|
|
|
|
NET::WindowType Bridge::windowType( unsigned long supported_types ) const
|
|
|
|
{
|
|
|
|
return c->windowType( false, supported_types );
|
|
|
|
}
|
|
|
|
|
|
|
|
QIconSet Bridge::icon() const
|
|
|
|
{
|
|
|
|
return QIconSet( c->miniIcon(), c->icon());
|
|
|
|
}
|
|
|
|
|
2003-11-25 15:26:50 +00:00
|
|
|
bool Bridge::isSetShade() const
|
|
|
|
{
|
2004-06-18 08:57:42 +00:00
|
|
|
return c->shadeMode() != ShadeNone;
|
2003-11-25 15:26:50 +00:00
|
|
|
}
|
|
|
|
|
2003-09-16 19:28:03 +00:00
|
|
|
void Bridge::showWindowMenu( QPoint p )
|
|
|
|
{
|
|
|
|
c->workspace()->showWindowMenu( p, c );
|
|
|
|
}
|
|
|
|
|
2004-06-02 09:47:36 +00:00
|
|
|
void Bridge::showWindowMenu( const QRect &p )
|
|
|
|
{
|
|
|
|
c->workspace()->showWindowMenu( p, c );
|
|
|
|
}
|
|
|
|
|
2003-09-16 19:28:03 +00:00
|
|
|
void Bridge::performWindowOperation( WindowOperation op )
|
|
|
|
{
|
|
|
|
c->workspace()->performWindowOperation( c, op );
|
|
|
|
}
|
|
|
|
|
|
|
|
void Bridge::setMask( const QRegion& r, int mode )
|
|
|
|
{
|
|
|
|
c->setMask( r, mode );
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Bridge::isPreview() const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
QRect Bridge::iconGeometry() const
|
|
|
|
{
|
2003-09-30 10:55:06 +00:00
|
|
|
NETRect r = c->info->iconGeometry();
|
2003-09-16 19:28:03 +00:00
|
|
|
return QRect( r.pos.x, r.pos.y, r.size.width, r.size.height );
|
|
|
|
}
|
|
|
|
|
|
|
|
QWidget* Bridge::workspaceWidget() const
|
|
|
|
{
|
|
|
|
return c->workspace()->desktopWidget();
|
|
|
|
}
|
|
|
|
|
2004-12-06 15:46:27 +00:00
|
|
|
WId Bridge::windowId() const
|
|
|
|
{
|
|
|
|
return c->window();
|
|
|
|
}
|
|
|
|
|
2003-09-16 19:28:03 +00:00
|
|
|
void Bridge::titlebarDblClickOperation()
|
|
|
|
{
|
|
|
|
c->workspace()->performWindowOperation( c, options->operationTitlebarDblClick());
|
|
|
|
}
|
|
|
|
|
2005-05-06 15:20:49 +00:00
|
|
|
void Bridge::titlebarMouseWheelOperation( int delta )
|
|
|
|
{
|
|
|
|
c->performMouseCommand( options->operationTitlebarMouseWheel( delta ), QCursor::pos());
|
|
|
|
}
|
|
|
|
|
2003-09-16 19:28:03 +00:00
|
|
|
void Bridge::setShade( bool set )
|
|
|
|
{
|
2004-06-18 08:57:42 +00:00
|
|
|
c->setShade( set ? ShadeNormal : ShadeNone );
|
2003-09-16 19:28:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int Bridge::currentDesktop() const
|
|
|
|
{
|
|
|
|
return c->workspace()->currentDesktop();
|
|
|
|
}
|
|
|
|
|
|
|
|
QWidget* Bridge::initialParentWidget() const
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
Qt::WFlags Bridge::initialWFlags() const
|
|
|
|
{
|
2003-11-11 18:38:19 +00:00
|
|
|
return 0;
|
2003-09-16 19:28:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Bridge::helperShowHide( bool show )
|
|
|
|
{
|
|
|
|
if( show )
|
|
|
|
c->rawShow();
|
|
|
|
else
|
|
|
|
c->rawHide();
|
|
|
|
}
|
|
|
|
|
2003-10-27 16:28:53 +00:00
|
|
|
QRegion Bridge::unobscuredRegion( const QRegion& r ) const
|
|
|
|
{
|
|
|
|
QRegion reg( r );
|
|
|
|
const ClientList stacking_order = c->workspace()->stackingOrder();
|
|
|
|
ClientList::ConstIterator it = stacking_order.find( c );
|
|
|
|
++it;
|
|
|
|
for(;
|
|
|
|
it != stacking_order.end();
|
|
|
|
++it )
|
|
|
|
{
|
2003-10-30 18:12:23 +00:00
|
|
|
if( !(*it)->isShown( true ))
|
|
|
|
continue; // these don't obscure the window
|
|
|
|
if( c->isOnAllDesktops())
|
|
|
|
{
|
|
|
|
if( !(*it)->isOnCurrentDesktop())
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( !(*it)->isOnDesktop( c->desktop()))
|
|
|
|
continue;
|
|
|
|
}
|
2003-10-27 16:28:53 +00:00
|
|
|
/* the clients all have their mask-regions in local coords
|
|
|
|
so we have to translate them to a shared coord system
|
|
|
|
we choose ours */
|
|
|
|
int dx = (*it)->x() - c->x();
|
|
|
|
int dy = (*it)->y() - c->y();
|
|
|
|
QRegion creg = (*it)->mask();
|
|
|
|
creg.translate(dx, dy);
|
|
|
|
reg -= creg;
|
|
|
|
if (reg.isEmpty())
|
|
|
|
{
|
|
|
|
// early out, we are completely obscured
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return reg;
|
|
|
|
}
|
|
|
|
|
2003-12-04 13:54:10 +00:00
|
|
|
void Bridge::grabXServer( bool grab )
|
|
|
|
{
|
|
|
|
if( grab )
|
|
|
|
KWinInternal::grabXServer();
|
|
|
|
else
|
|
|
|
KWinInternal::ungrabXServer();
|
|
|
|
}
|
|
|
|
|
2003-09-16 19:28:03 +00:00
|
|
|
} // namespace
|