CT: cascading placement. I feel it as a bit of an overkill for what it does
compared to smart placement. Whatever. Some people want it smart placement made smarter (just a bit) and faster (just a bit) Qt is a marvel. kwin is even better than kwm. KDE is amazing :-) You know who I am now, even if I don't sign. svn path=/trunk/kdebase/kwin/; revision=34452
This commit is contained in:
parent
b0b7769701
commit
52d957df8e
4 changed files with 126 additions and 3 deletions
19
options.cpp
19
options.cpp
|
@ -12,8 +12,10 @@ Options::Options()
|
|||
cg[i] = NULL;
|
||||
reload();
|
||||
|
||||
//CT
|
||||
placement = Smart; //ACHTUNG!! for the moment *only*
|
||||
//CT fix them for now. Will be read from rc
|
||||
placement = Smart;
|
||||
animate_shade = true;
|
||||
anim_steps = 100;
|
||||
}
|
||||
|
||||
Options::~Options(){
|
||||
|
@ -136,4 +138,17 @@ void Options::reload()
|
|||
cg[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
//CT well, what this costs us?
|
||||
config->setGroup("Actions");
|
||||
|
||||
QString val;
|
||||
val = config->readEntry("Placement","Smart");
|
||||
if (val == "Smart") placement = Smart;
|
||||
else if (val == "Random") placement = Random;
|
||||
else if (val == "Cascade") placement = Cascade;
|
||||
|
||||
animate_shade = config->readBoolEntry("AnimateShade", true);
|
||||
|
||||
anim_steps = config->readNumEntry("AnimSteps", 100);
|
||||
}
|
||||
|
|
14
options.h
14
options.h
|
@ -57,7 +57,7 @@ public:
|
|||
* Normally you don't have to worry. What the WM adds to the startup time
|
||||
* is nil compared to the creation of the window itself in the memory
|
||||
*/
|
||||
enum PlacementPolicy { Random, Smart };
|
||||
enum PlacementPolicy { Random, Smart, Cascade };
|
||||
PlacementPolicy placement;
|
||||
|
||||
bool focusPolicyIsReasonable() {
|
||||
|
@ -76,6 +76,14 @@ public:
|
|||
* Return the active or inactive decoration font.
|
||||
*/
|
||||
const QFont& font(bool active=true);
|
||||
/**
|
||||
* Return whether we animate the shading of windows to titlebar or not
|
||||
*/
|
||||
const bool animateShade() { return animate_shade; };
|
||||
/**
|
||||
* Return the number of animation steps (would this be general?)
|
||||
*/
|
||||
const int animSteps() { return anim_steps; };
|
||||
// When restarting is implemented this should get called (mosfet).
|
||||
void reload();
|
||||
|
||||
|
@ -85,6 +93,10 @@ protected:
|
|||
QFont activeFont, inactiveFont;
|
||||
QColor colors[KWINCOLORS*2];
|
||||
QColorGroup *cg[KWINCOLORS*2];
|
||||
|
||||
private:
|
||||
bool animate_shade;
|
||||
int anim_steps;
|
||||
};
|
||||
|
||||
extern Options* options;
|
||||
|
|
|
@ -186,6 +186,15 @@ void Workspace::init()
|
|||
XUngrabServer( qt_xdisplay() );
|
||||
popup = 0;
|
||||
propagateClients();
|
||||
|
||||
//CT initialize the cascading info
|
||||
for( int i = 0; i < numberOfDesktops(); i++) {
|
||||
CascadingInfo inf;
|
||||
inf.pos = QPoint(0,0);
|
||||
inf.col = 0;
|
||||
inf.row = 0;
|
||||
cci.append(inf);
|
||||
}
|
||||
}
|
||||
|
||||
Workspace::~Workspace()
|
||||
|
@ -846,6 +855,8 @@ void Workspace::doPlacement( Client* c )
|
|||
randomPlacement( c );
|
||||
else if (options->placement == Options::Smart)
|
||||
smartPlacement( c );
|
||||
else if (options->placement == Options::Cascade)
|
||||
cascadePlacement( c );
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -948,6 +959,13 @@ void Workspace::smartPlacement(Client* c){
|
|||
}
|
||||
}
|
||||
|
||||
//CT first time we get no overlap we stop.
|
||||
if (overlap == none) {
|
||||
x_optimal = x;
|
||||
y_optimal = y;
|
||||
break;
|
||||
}
|
||||
|
||||
if (first_pass) {
|
||||
first_pass = false;
|
||||
min_overlap = overlap;
|
||||
|
@ -1023,6 +1041,73 @@ void Workspace::smartPlacement(Client* c){
|
|||
|
||||
}
|
||||
|
||||
/*!
|
||||
Place windows in a cascading order, remembering positions for each desktop
|
||||
*/
|
||||
void Workspace::cascadePlacement (Client* c, bool re_init) {
|
||||
/* cascadePlacement by Cristian Tibirna (tibirna@kde.org) (30Jan98)
|
||||
*/
|
||||
|
||||
// work coords
|
||||
int xp, yp;
|
||||
|
||||
//CT how do I get from the 'Client' class the size that NW squarish "handle"
|
||||
int delta_x = 24;
|
||||
int delta_y = 24;
|
||||
|
||||
int d = currentDesktop() - 1;
|
||||
|
||||
// get the maximum allowed windows space and desk's origin
|
||||
// (CT 20Nov1999 - is this common to all desktops?)
|
||||
QRect maxRect = clientArea();
|
||||
|
||||
// initialize often used vars: width and height of c; we gain speed
|
||||
int ch = c->height();
|
||||
int cw = c->width();
|
||||
int H = maxRect.bottom();
|
||||
int W = maxRect.right();
|
||||
int X = maxRect.left();
|
||||
int Y = maxRect.top();
|
||||
|
||||
//initialize if needed
|
||||
if (re_init) {
|
||||
cci[d].pos = QPoint(X, Y);
|
||||
cci[d].col = cci[d].row = 0;
|
||||
}
|
||||
|
||||
|
||||
xp = cci[d].pos.x();
|
||||
yp = cci[d].pos.y();
|
||||
|
||||
//here to touch in case people vote for resize on placement
|
||||
if ((yp + ch ) > H) yp = Y;
|
||||
|
||||
if ((xp + cw ) > W)
|
||||
if (!yp) {
|
||||
smartPlacement(c);
|
||||
return;
|
||||
}
|
||||
else xp = X;
|
||||
|
||||
//if this isn't the first window
|
||||
if ( cci[d].pos.x() != X && cci[d].pos.y() != Y ) {
|
||||
if ( xp != X && yp == Y ) xp = delta_x * (++(cci[d].col));
|
||||
if ( yp != Y && xp == X ) yp = delta_y * (++(cci[d].row));
|
||||
|
||||
// last resort: if still doesn't fit, smart place it
|
||||
if ( ((xp + cw) > W - X) || ((yp + ch) > H - Y) ) {
|
||||
smartPlacement(c);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// place the window
|
||||
c->move( QPoint( xp, yp ) );
|
||||
|
||||
// new position
|
||||
cci[d].pos = QPoint( xp + delta_x, yp + delta_y );
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Raises the client \a c taking layers, transient windows and window
|
||||
|
|
11
workspace.h
11
workspace.h
|
@ -134,6 +134,7 @@ private:
|
|||
void raiseTransientsOf( ClientList& safeset, Client* c );
|
||||
void randomPlacement(Client* c);
|
||||
void smartPlacement(Client* c);
|
||||
void cascadePlacement(Client* c, bool re_init = false);
|
||||
|
||||
void focusToNull();
|
||||
Client* desktop_client;
|
||||
|
@ -154,6 +155,16 @@ private:
|
|||
bool removeDockwin( WId w );
|
||||
void propagateDockwins();
|
||||
DockWindow findDockwin( WId w );
|
||||
|
||||
//CT needed for cascading+
|
||||
struct CascadingInfo {
|
||||
QPoint pos;
|
||||
int col;
|
||||
int row;
|
||||
};
|
||||
|
||||
QValueList<CascadingInfo> cci;
|
||||
// -cascading
|
||||
};
|
||||
|
||||
inline WId Workspace::rootWin() const
|
||||
|
|
Loading…
Reference in a new issue