cleanups: less debug output, less flicker, less confusing code

svn path=/trunk/kdebase/kwin/; revision=50775
This commit is contained in:
Matthias Ettrich 2000-05-26 13:54:50 +00:00
parent 795b743459
commit c0d337d352
5 changed files with 103 additions and 125 deletions

View file

@ -323,10 +323,11 @@ bool WindowWrapper::x11Event( XEvent * e)
Creates a client on workspace \a ws for window \a w. Creates a client on workspace \a ws for window \a w.
*/ */
Client::Client( Workspace *ws, WId w, QWidget *parent, const char *name, WFlags f ) Client::Client( Workspace *ws, WId w, QWidget *parent, const char *name, WFlags f )
: QWidget( parent, name, f | WStyle_Customize | WStyle_NoBorder ), : QWidget( parent, name, f | WStyle_Customize | WStyle_NoBorder )
avoid_(false),
anchorEdge_(AnchorNorth)
{ {
avoid = false;
anchor = AnchorNorth;
wspace = ws; wspace = ws;
win = w; win = w;
XWindowAttributes attr; XWindowAttributes attr;
@ -1926,61 +1927,62 @@ QCString Client::sessionId()
void Client::activateLayout() void Client::activateLayout()
{ {
if (layout()) if ( layout() )
layout()->activate(); layout()->activate();
} }
void Client::updateAvoidPolicy() void Client::updateAvoidPolicy()
{ {
avoid_ = false; avoid = false;
// Find out if we should be avoided. // Find out if we should be avoided.
XTextProperty avoidProp;
if ( XGetTextProperty(
qt_xdisplay(),
win,
&avoidProp,
atoms->net_avoid_spec
) == 0 )
return;
XTextProperty avoidProp; char ** avoidList;
int avoidListCount;
Status avoidStatus = if ( XTextPropertyToStringList(
XGetTextProperty( &avoidProp, &avoidList, &avoidListCount) == 0 ) {
qt_xdisplay(), qDebug("kwin: Client::updateAvoidPolicy: "
win, "XTextPropertyToStringList failed");
&avoidProp, return;
atoms->net_avoid_spec }
);
if (0 == avoidStatus) // Must be one value only in string list.
return; if (avoidListCount != 1) {
qDebug( "kwin: Client::updateAvoidPolicy(): "
"Avoid list value count incorrect");
return;
}
char ** avoidList; // Which border is the client anchored to ?
int avoidListCount; avoid = true;
switch (avoidList[0][0]) {
case 'N':
anchor = AnchorNorth;
break;
case 'S':
anchor = AnchorSouth;
break;
case 'E':
anchor = AnchorEast;
break;
case 'W':
anchor = AnchorWest;
break;
default:
avoid = false;
break;
}
Status convertStatus = XFreeStringList(avoidList);
XTextPropertyToStringList(
&avoidProp, &avoidList, &avoidListCount);
if (0 == convertStatus) {
qDebug("kwin: Client::updateAvoidPolicy: "
"XTextPropertyToStringList failed");
return;
}
// Must be one value only in string list.
if (1 != avoidListCount) {
qDebug( "kwin: Client::updateAvoidPolicy(): "
"Avoid list value count incorrect");
return;
}
// Which border is the client anchored to ?
switch (avoidList[0][0]) {
case 'N': anchorEdge_ = AnchorNorth; avoid_ = true; break;
case 'S': anchorEdge_ = AnchorSouth; avoid_ = true; break;
case 'E': anchorEdge_ = AnchorEast; avoid_ = true; break;
case 'W': anchorEdge_ = AnchorWest; avoid_ = true; break;
default: break;
}
XFreeStringList(avoidList);
} }
NoBorderClient::NoBorderClient( Workspace *ws, WId w, QWidget *parent, const char *name ) NoBorderClient::NoBorderClient( Workspace *ws, WId w, QWidget *parent, const char *name )

View file

@ -71,8 +71,8 @@ public:
Client* mainClient(); Client* mainClient();
void updateAvoidPolicy(); void updateAvoidPolicy();
bool avoid() const { return avoid_; } bool isAvoid() const { return avoid; }
int anchorEdge() const { return anchorEdge_; } int anchorEdge() const { return anchor; }
virtual bool windowEvent( XEvent * ); virtual bool windowEvent( XEvent * );
@ -176,7 +176,7 @@ protected:
void showEvent( QShowEvent* ); void showEvent( QShowEvent* );
void hideEvent( QHideEvent* ); void hideEvent( QHideEvent* );
bool x11Event( XEvent * ); // X11 event bool x11Event( XEvent * ); // X11 event
virtual void activateLayout(); virtual void activateLayout();
bool eventFilter( QObject *, QEvent * ); bool eventFilter( QObject *, QEvent * );
@ -250,8 +250,8 @@ private:
QRect geom_restore; QRect geom_restore;
QRegion mask; QRegion mask;
bool avoid_; bool avoid;
int anchorEdge_; int anchor;
}; };
inline WId Client::window() const inline WId Client::window() const

View file

@ -1,6 +1,6 @@
/***************************************************************** /*****************************************************************
kwin - the KDE window manager kwin - the KDE window manager
Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org> Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org>
******************************************************************/ ******************************************************************/
#include "stdclient.h" #include "stdclient.h"
@ -292,10 +292,8 @@ void StdClient::resizeEvent( QResizeEvent* e)
if ( isVisibleToTLW() && !testWFlags( WNorthWestGravity )) { if ( isVisibleToTLW() && !testWFlags( WNorthWestGravity )) {
// manual clearing without the titlebar (we selected WResizeNoErase ) // manual clearing without the titlebar (we selected WResizeNoErase )
QPainter p( this ); QRect cr( 2, 2, width()-4, height()- 4 );
r = rr.subtract( t ); erase( QRegion( cr ).subtract( t ) );
p.setClipRegion( r );
p.fillRect( rect(), colorGroup().brush( QColorGroup::Background ) );
} }
} }

View file

@ -1421,7 +1421,7 @@ void Workspace::raiseClient( Client* c )
if ( !c ) if ( !c )
return; return;
ClientList saveset; ClientList saveset;
if ( c == desktop_client ) { if ( c == desktop_client ) {
saveset.clear(); saveset.clear();
saveset.append( c ); saveset.append( c );
@ -1931,7 +1931,7 @@ void Workspace::killWindowAtPosition(int x, int y)
{ {
Client *client = (*it); Client *client = (*it);
if ( client->rect().contains(QPoint(x, y)) && if ( client->rect().contains(QPoint(x, y)) &&
client->isOnDesktop( currentDesktop() ) && client->isOnDesktop( currentDesktop() ) &&
!client->isIconified() ) !client->isIconified() )
{ {
client->killWindow(); client->killWindow();
@ -2333,76 +2333,54 @@ SessionInfo* Workspace::takeSessionInfo( Client* c )
return 0; return 0;
} }
void void Workspace::updateClientArea()
Workspace::updateClientArea()
{ {
kdDebug() << "KWin: Updating client area" << endl; QRect area = QApplication::desktop()->geometry();
QRect edgeArea = QApplication::desktop()->geometry();
clientArea_ = QApplication::desktop()->geometry(); for (ClientList::ConstIterator it(clients.begin()); it != clients.end(); ++it) {
edgeClientArea_ = QApplication::desktop()->geometry(); (*it)->updateAvoidPolicy();
for (ClientList::ConstIterator it(clients.begin()); it != clients.end(); ++it) if ((*it)->isAvoid() ) {
{ switch (AnchorEdge((*it)->anchorEdge())) {
(*it)->updateAvoidPolicy();
kdDebug() << "Looking at client " << (KWM::title((*it)->winId())) case AnchorNorth:
<< (*it)->winId() << endl; area.setTop(QMAX(area.top(), (*it)->geometry().bottom()));
kdDebug() << "Avoid policy is " << (*it)->avoid() << endl; break;
if ((*it)->avoid()) { case AnchorSouth:
area.setBottom(QMIN(area.bottom(), (*it)->geometry().top() - 1));
break;
switch (AnchorEdge((*it)->anchorEdge())) { case AnchorEast:
area.setRight(QMIN(area.right(), (*it)->geometry().left() - 1));
break;
case AnchorNorth: case AnchorWest:
kdDebug() <<"KWin: Ignoring at edge N" << endl; area.setLeft(QMAX(area.left(), (*it)->geometry().right()));
clientArea_ break;
.setTop(QMAX(clientArea_.top(), (*it)->geometry().bottom()));
break;
case AnchorSouth: default:
kdDebug() <<"KWin: Ignoring at edge S" << endl; break;
clientArea_ }
.setBottom(QMIN(clientArea_.bottom(), (*it)->geometry().top() - 1)); }
break;
case AnchorEast: // FIXME: Using the hackish method...
kdDebug() <<"KWin: Ignoring at edge E" << endl; if (KWM::title((*it)->winId()) == "MAC MENU [menu]")
clientArea_ edgeArea.setTop((*it)->geometry().bottom());
.setRight(QMIN(clientArea_.right(), (*it)->geometry().left() - 1)); }
break;
edgeClientArea_ = edgeArea;
case AnchorWest:
kdDebug() <<"KWin: Ignoring at edge W" << endl; if ( clientArea_ != area ) {
clientArea_ // something changed, remember it and notify kdesktop
.setLeft(QMAX(clientArea_.left(), (*it)->geometry().right())); clientArea_ = area;
break;
QByteArray data;
default: QDataStream arg( data, IO_WriteOnly );
kdDebug() <<"KWin: Not ignoring" << endl; arg << clientArea_;
break; kapp->dcopClient()->send("kdesktop", "KDesktopIface", "clientAreaUpdated(QRect)", data);
}
} }
// FIXME: Using the hackish method...
if (KWM::title((*it)->winId()) == "MAC MENU [menu]")
edgeClientArea_.setTop((*it)->geometry().bottom());
}
DCOPClient * client = kapp->dcopClient();
if (!client->isAttached())
client->attach();
QByteArray param;
QDataStream str(param, IO_WriteOnly);
str << clientArea_;
client->send("kdesktop", "KDesktopIface", "clientAreaUpdated(QRect)", param);
// Useful when you want to see whether the client area has been
// updated correctly...
qDebug("clientArea now == l: %d, r: %d, t: %d, b: %d", clientArea_.left(), clientArea_.top(), clientArea_.right(), clientArea_.bottom());
} }
QRect Workspace::clientArea() QRect Workspace::clientArea()

View file

@ -90,7 +90,7 @@ public:
Client* findClient( WId w ) const; Client* findClient( WId w ) const;
QRect geometry() const; QRect geometry() const;
/** /**
* @return the area available for clients. This is the desktop * @return the area available for clients. This is the desktop
* geometry adjusted for edge-anchored windows. * geometry adjusted for edge-anchored windows.
@ -169,14 +169,14 @@ public:
void storeSession( KConfig* config ); void storeSession( KConfig* config );
SessionInfo* takeSessionInfo( Client* ); SessionInfo* takeSessionInfo( Client* );
/** /**
* When the area that is available for clients (that which is not * When the area that is available for clients (that which is not
* taken by windows like panels, the top-of-screen menu etc) may * taken by windows like panels, the top-of-screen menu etc) may
* have changed, this will recalculate the available space. * have changed, this will recalculate the available space.
*/ */
virtual void updateClientArea(); virtual void updateClientArea();
/** /**
* @return the area available for edge-anchored windows. This * @return the area available for edge-anchored windows. This
* is the desktop geometry adjusted for other edge-anchored * is the desktop geometry adjusted for other edge-anchored
@ -269,7 +269,7 @@ private:
QGuardedPtr<Client> popup_client; QGuardedPtr<Client> popup_client;
void loadSessionInfo(); void loadSessionInfo();
QWidget* desktop_widget; QWidget* desktop_widget;
QList<SessionInfo> session; QList<SessionInfo> session;
@ -278,7 +278,7 @@ private:
Client* desktop_client; Client* desktop_client;
Client* active_client; Client* active_client;
Client* should_get_focus; Client* should_get_focus;
ClientList clients; ClientList clients;
ClientList stacking_order; ClientList stacking_order;
ClientList focus_chain; ClientList focus_chain;