cleanups: less debug output, less flicker, less confusing code
svn path=/trunk/kdebase/kwin/; revision=50775
This commit is contained in:
parent
795b743459
commit
c0d337d352
5 changed files with 103 additions and 125 deletions
98
client.cpp
98
client.cpp
|
@ -323,10 +323,11 @@ bool WindowWrapper::x11Event( XEvent * e)
|
|||
Creates a client on workspace \a ws for window \a w.
|
||||
*/
|
||||
Client::Client( Workspace *ws, WId w, QWidget *parent, const char *name, WFlags f )
|
||||
: QWidget( parent, name, f | WStyle_Customize | WStyle_NoBorder ),
|
||||
avoid_(false),
|
||||
anchorEdge_(AnchorNorth)
|
||||
: QWidget( parent, name, f | WStyle_Customize | WStyle_NoBorder )
|
||||
{
|
||||
avoid = false;
|
||||
anchor = AnchorNorth;
|
||||
|
||||
wspace = ws;
|
||||
win = w;
|
||||
XWindowAttributes attr;
|
||||
|
@ -1926,61 +1927,62 @@ QCString Client::sessionId()
|
|||
|
||||
void Client::activateLayout()
|
||||
{
|
||||
if (layout())
|
||||
layout()->activate();
|
||||
if ( layout() )
|
||||
layout()->activate();
|
||||
}
|
||||
|
||||
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 =
|
||||
XGetTextProperty(
|
||||
qt_xdisplay(),
|
||||
win,
|
||||
&avoidProp,
|
||||
atoms->net_avoid_spec
|
||||
);
|
||||
if ( XTextPropertyToStringList(
|
||||
&avoidProp, &avoidList, &avoidListCount) == 0 ) {
|
||||
qDebug("kwin: Client::updateAvoidPolicy: "
|
||||
"XTextPropertyToStringList failed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (0 == avoidStatus)
|
||||
return;
|
||||
// Must be one value only in string list.
|
||||
if (avoidListCount != 1) {
|
||||
qDebug( "kwin: Client::updateAvoidPolicy(): "
|
||||
"Avoid list value count incorrect");
|
||||
return;
|
||||
}
|
||||
|
||||
char ** avoidList;
|
||||
int avoidListCount;
|
||||
// Which border is the client anchored to ?
|
||||
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 =
|
||||
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);
|
||||
XFreeStringList(avoidList);
|
||||
}
|
||||
|
||||
NoBorderClient::NoBorderClient( Workspace *ws, WId w, QWidget *parent, const char *name )
|
||||
|
|
10
client.h
10
client.h
|
@ -71,8 +71,8 @@ public:
|
|||
Client* mainClient();
|
||||
|
||||
void updateAvoidPolicy();
|
||||
bool avoid() const { return avoid_; }
|
||||
int anchorEdge() const { return anchorEdge_; }
|
||||
bool isAvoid() const { return avoid; }
|
||||
int anchorEdge() const { return anchor; }
|
||||
|
||||
virtual bool windowEvent( XEvent * );
|
||||
|
||||
|
@ -176,7 +176,7 @@ protected:
|
|||
void showEvent( QShowEvent* );
|
||||
void hideEvent( QHideEvent* );
|
||||
bool x11Event( XEvent * ); // X11 event
|
||||
|
||||
|
||||
virtual void activateLayout();
|
||||
|
||||
bool eventFilter( QObject *, QEvent * );
|
||||
|
@ -250,8 +250,8 @@ private:
|
|||
QRect geom_restore;
|
||||
QRegion mask;
|
||||
|
||||
bool avoid_;
|
||||
int anchorEdge_;
|
||||
bool avoid;
|
||||
int anchor;
|
||||
};
|
||||
|
||||
inline WId Client::window() const
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*****************************************************************
|
||||
kwin - the KDE window manager
|
||||
|
||||
|
||||
Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org>
|
||||
******************************************************************/
|
||||
#include "stdclient.h"
|
||||
|
@ -292,10 +292,8 @@ void StdClient::resizeEvent( QResizeEvent* e)
|
|||
|
||||
if ( isVisibleToTLW() && !testWFlags( WNorthWestGravity )) {
|
||||
// manual clearing without the titlebar (we selected WResizeNoErase )
|
||||
QPainter p( this );
|
||||
r = rr.subtract( t );
|
||||
p.setClipRegion( r );
|
||||
p.fillRect( rect(), colorGroup().brush( QColorGroup::Background ) );
|
||||
QRect cr( 2, 2, width()-4, height()- 4 );
|
||||
erase( QRegion( cr ).subtract( t ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
102
workspace.cpp
102
workspace.cpp
|
@ -1421,7 +1421,7 @@ void Workspace::raiseClient( Client* c )
|
|||
if ( !c )
|
||||
return;
|
||||
ClientList saveset;
|
||||
|
||||
|
||||
if ( c == desktop_client ) {
|
||||
saveset.clear();
|
||||
saveset.append( c );
|
||||
|
@ -1931,7 +1931,7 @@ void Workspace::killWindowAtPosition(int x, int y)
|
|||
{
|
||||
Client *client = (*it);
|
||||
if ( client->rect().contains(QPoint(x, y)) &&
|
||||
client->isOnDesktop( currentDesktop() ) &&
|
||||
client->isOnDesktop( currentDesktop() ) &&
|
||||
!client->isIconified() )
|
||||
{
|
||||
client->killWindow();
|
||||
|
@ -2333,76 +2333,54 @@ SessionInfo* Workspace::takeSessionInfo( Client* c )
|
|||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
Workspace::updateClientArea()
|
||||
void Workspace::updateClientArea()
|
||||
{
|
||||
kdDebug() << "KWin: Updating client area" << endl;
|
||||
QRect area = QApplication::desktop()->geometry();
|
||||
QRect edgeArea = QApplication::desktop()->geometry();
|
||||
|
||||
clientArea_ = QApplication::desktop()->geometry();
|
||||
edgeClientArea_ = QApplication::desktop()->geometry();
|
||||
for (ClientList::ConstIterator it(clients.begin()); it != clients.end(); ++it) {
|
||||
(*it)->updateAvoidPolicy();
|
||||
|
||||
for (ClientList::ConstIterator it(clients.begin()); it != clients.end(); ++it)
|
||||
{
|
||||
(*it)->updateAvoidPolicy();
|
||||
if ((*it)->isAvoid() ) {
|
||||
switch (AnchorEdge((*it)->anchorEdge())) {
|
||||
|
||||
kdDebug() << "Looking at client " << (KWM::title((*it)->winId()))
|
||||
<< (*it)->winId() << endl;
|
||||
kdDebug() << "Avoid policy is " << (*it)->avoid() << endl;
|
||||
case AnchorNorth:
|
||||
area.setTop(QMAX(area.top(), (*it)->geometry().bottom()));
|
||||
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:
|
||||
kdDebug() <<"KWin: Ignoring at edge N" << endl;
|
||||
clientArea_
|
||||
.setTop(QMAX(clientArea_.top(), (*it)->geometry().bottom()));
|
||||
break;
|
||||
case AnchorWest:
|
||||
area.setLeft(QMAX(area.left(), (*it)->geometry().right()));
|
||||
break;
|
||||
|
||||
case AnchorSouth:
|
||||
kdDebug() <<"KWin: Ignoring at edge S" << endl;
|
||||
clientArea_
|
||||
.setBottom(QMIN(clientArea_.bottom(), (*it)->geometry().top() - 1));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
case AnchorEast:
|
||||
kdDebug() <<"KWin: Ignoring at edge E" << endl;
|
||||
clientArea_
|
||||
.setRight(QMIN(clientArea_.right(), (*it)->geometry().left() - 1));
|
||||
break;
|
||||
|
||||
case AnchorWest:
|
||||
kdDebug() <<"KWin: Ignoring at edge W" << endl;
|
||||
clientArea_
|
||||
.setLeft(QMAX(clientArea_.left(), (*it)->geometry().right()));
|
||||
break;
|
||||
|
||||
default:
|
||||
kdDebug() <<"KWin: Not ignoring" << endl;
|
||||
break;
|
||||
}
|
||||
// FIXME: Using the hackish method...
|
||||
if (KWM::title((*it)->winId()) == "MAC MENU [menu]")
|
||||
edgeArea.setTop((*it)->geometry().bottom());
|
||||
}
|
||||
|
||||
edgeClientArea_ = edgeArea;
|
||||
|
||||
if ( clientArea_ != area ) {
|
||||
// something changed, remember it and notify kdesktop
|
||||
clientArea_ = area;
|
||||
|
||||
QByteArray data;
|
||||
QDataStream arg( data, IO_WriteOnly );
|
||||
arg << clientArea_;
|
||||
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()
|
||||
|
|
10
workspace.h
10
workspace.h
|
@ -90,7 +90,7 @@ public:
|
|||
Client* findClient( WId w ) const;
|
||||
|
||||
QRect geometry() const;
|
||||
|
||||
|
||||
/**
|
||||
* @return the area available for clients. This is the desktop
|
||||
* geometry adjusted for edge-anchored windows.
|
||||
|
@ -169,14 +169,14 @@ public:
|
|||
void storeSession( KConfig* config );
|
||||
|
||||
SessionInfo* takeSessionInfo( Client* );
|
||||
|
||||
|
||||
/**
|
||||
* When the area that is available for clients (that which is not
|
||||
* taken by windows like panels, the top-of-screen menu etc) may
|
||||
* have changed, this will recalculate the available space.
|
||||
*/
|
||||
virtual void updateClientArea();
|
||||
|
||||
|
||||
/**
|
||||
* @return the area available for edge-anchored windows. This
|
||||
* is the desktop geometry adjusted for other edge-anchored
|
||||
|
@ -269,7 +269,7 @@ private:
|
|||
QGuardedPtr<Client> popup_client;
|
||||
|
||||
void loadSessionInfo();
|
||||
|
||||
|
||||
QWidget* desktop_widget;
|
||||
|
||||
QList<SessionInfo> session;
|
||||
|
@ -278,7 +278,7 @@ private:
|
|||
Client* desktop_client;
|
||||
Client* active_client;
|
||||
Client* should_get_focus;
|
||||
|
||||
|
||||
ClientList clients;
|
||||
ClientList stacking_order;
|
||||
ClientList focus_chain;
|
||||
|
|
Loading…
Reference in a new issue