changed OpenboxWindow to not have getFrameX/getWidth/etc functions, and to return Origins and Sizes and Rects, in fuctions like size(), origin(), and area().
This commit is contained in:
parent
973880dd25
commit
bea6e5f78d
4 changed files with 83 additions and 84 deletions
|
@ -30,11 +30,11 @@ Point::Point(const Point &point) : m_x(point.m_x), m_y(point.m_y) {
|
|||
Point::Point(const int x, const int y) : m_x(x), m_y(y) {
|
||||
}
|
||||
|
||||
inline void Point::setX(const int x) {
|
||||
void Point::setX(const int x) {
|
||||
m_x = x;
|
||||
}
|
||||
|
||||
inline void Point::setY(const int y) {
|
||||
void Point::setY(const int y) {
|
||||
m_y = y;
|
||||
}
|
||||
|
||||
|
@ -47,11 +47,11 @@ Size::Size(const Size &size) : m_w(size.m_w), m_h(size.m_h) {
|
|||
Size::Size(const int w, const int h) : m_w(w), m_h(h) {
|
||||
}
|
||||
|
||||
inline void Size::setW(const int w) {
|
||||
void Size::setW(const int w) {
|
||||
m_w = w;
|
||||
}
|
||||
|
||||
inline void Size::setH(const int h) {
|
||||
void Size::setH(const int h) {
|
||||
m_h = h;
|
||||
}
|
||||
|
||||
|
|
|
@ -2805,7 +2805,7 @@ void OpenboxWindow::motionNotifyEvent(XMotionEvent *me) {
|
|||
int snap_distance = screen->getEdgeSnapThreshold();
|
||||
// width/height of the snapping window
|
||||
unsigned int snap_w = frame.width + (frame.border_w * 2);
|
||||
unsigned int snap_h = getHeight() + (frame.border_w * 2);
|
||||
unsigned int snap_h = size().h() + (frame.border_w * 2);
|
||||
if (snap_distance) {
|
||||
int drx = screen->getWidth() - (dx + snap_w);
|
||||
|
||||
|
|
47
src/Window.h
47
src/Window.h
|
@ -271,43 +271,44 @@ public:
|
|||
|
||||
inline char **getTitle(void) { return &client.title; }
|
||||
inline char **getIconTitle(void) { return &client.icon_title; }
|
||||
inline const int &getXFrame(void) const { return frame.x; }
|
||||
inline const int &getYFrame(void) const { return frame.y; }
|
||||
inline const int &getXClient(void) const { return client.x; }
|
||||
inline const int &getYClient(void) const { return client.y; }
|
||||
//inline const int &getXFrame(void) const { return frame.x; }
|
||||
//inline const int &getYFrame(void) const { return frame.y; }
|
||||
//inline const int &getXClient(void) const { return client.x; }
|
||||
//inline const int &getYClient(void) const { return client.y; }
|
||||
inline const int &getWorkspaceNumber(void) const { return workspace_number; }
|
||||
inline const int &getWindowNumber(void) const { return window_number; }
|
||||
|
||||
inline const unsigned int &getWidth(void) const { return frame.width; }
|
||||
inline const unsigned int &getHeight(void) const {
|
||||
if (!flags.shaded)
|
||||
return frame.height;
|
||||
else
|
||||
return frame.title_h;
|
||||
}
|
||||
inline const unsigned int &getClientHeight(void) const
|
||||
{ return client.height; }
|
||||
inline const unsigned int &getClientWidth(void) const
|
||||
{ return client.width; }
|
||||
//inline const unsigned int &getWidth(void) const { return frame.width; }
|
||||
//inline const unsigned int &getHeight(void) const {
|
||||
// if (!flags.shaded)
|
||||
// return frame.height;
|
||||
// else
|
||||
// return frame.title_h;
|
||||
//}
|
||||
//inline const unsigned int &getClientHeight(void) const
|
||||
//{ return client.height; }
|
||||
//inline const unsigned int &getClientWidth(void) const
|
||||
//{ return client.width; }
|
||||
inline const unsigned int &getTitleHeight(void) const
|
||||
{ return frame.title_h; }
|
||||
|
||||
inline const Point getOrigin() const {
|
||||
inline const Point origin() const {
|
||||
return Point(frame.x, frame.y);
|
||||
}
|
||||
inline const Point getClientOrigin() const {
|
||||
inline const Point clientOrigin() const {
|
||||
return Point(client.x, client.y);
|
||||
}
|
||||
inline const Size getSize() const {
|
||||
return Size(frame.width, frame.height);
|
||||
inline const Size size() const {
|
||||
return Size(frame.width, flags.shaded ? frame.title_h : frame.height);
|
||||
}
|
||||
inline const Size getClientSize() const {
|
||||
inline const Size clientSize() const {
|
||||
return Size(client.width, client.height);
|
||||
}
|
||||
inline const Rect getArea() const {
|
||||
return Rect(frame.x, frame.y, frame.width, frame.height);
|
||||
inline const Rect area() const {
|
||||
return Rect(frame.x, frame.y, frame.width,
|
||||
flags.shaded ? frame.title_h : frame.height);
|
||||
}
|
||||
inline const Rect getClientArea() const {
|
||||
inline const Rect clientArea() const {
|
||||
return Rect(client.x, client.y, client.width, client.height);
|
||||
}
|
||||
|
||||
|
|
110
src/Workspace.cc
110
src/Workspace.cc
|
@ -334,33 +334,33 @@ static rectList calcSpace(const OpenboxWindow &win, const rectList &spaces) {
|
|||
rectList result;
|
||||
rectList::const_iterator siter;
|
||||
for(siter=spaces.begin(); siter!=spaces.end(); ++siter) {
|
||||
if(win.getArea().Intersect(*siter)) {
|
||||
if(win.area().Intersect(*siter)) {
|
||||
//Check for space to the left of the window
|
||||
if(win.getXFrame() > siter->x())
|
||||
if(win.origin().x() > siter->x())
|
||||
result.push_back(Rect(siter->x(), siter->y(),
|
||||
win.getXFrame() - siter->x() - 1,
|
||||
win.origin().x() - siter->x() - 1,
|
||||
siter->h()));
|
||||
//Check for space above the window
|
||||
if(win.getYFrame() > siter->y())
|
||||
if(win.origin().y() > siter->y())
|
||||
result.push_back(Rect(siter->x(), siter->y(),
|
||||
siter->w(),
|
||||
win.getYFrame() - siter->y() - 1));
|
||||
win.origin().y() - siter->y() - 1));
|
||||
//Check for space to the right of the window
|
||||
if((win.getXFrame()+win.getWidth()) <
|
||||
if((win.origin().x()+win.size().w()) <
|
||||
(siter->x()+siter->w()))
|
||||
result.push_back(Rect(win.getXFrame() + win.getWidth() + 1,
|
||||
result.push_back(Rect(win.origin().x() + win.size().w() + 1,
|
||||
siter->y(),
|
||||
siter->x() + siter->w() -
|
||||
win.getXFrame() - win.getWidth() - 1,
|
||||
win.origin().x() - win.size().w() - 1,
|
||||
siter->h()));
|
||||
//Check for space below the window
|
||||
if((win.getYFrame()+win.getHeight()) <
|
||||
if((win.origin().y()+win.size().h()) <
|
||||
(siter->y()+siter->h()))
|
||||
result.push_back(Rect(siter->x(),
|
||||
win.getYFrame() + win.getHeight() + 1,
|
||||
win.origin().y() + win.size().h() + 1,
|
||||
siter->w(),
|
||||
siter->y() + siter->h()-
|
||||
win.getYFrame() - win.getHeight() - 1));
|
||||
win.origin().y() - win.size().h() - 1));
|
||||
|
||||
}
|
||||
else
|
||||
|
@ -417,43 +417,41 @@ inline Point *Workspace::rowSmartPlacement(const Size &win_size,
|
|||
while(!placed &&
|
||||
((screen.getColPlacementDirection() == BScreen::BottomTop) ?
|
||||
test_y > 0 : test_y + win_size.h() < (signed) space.h())) {
|
||||
test_x = (screen.getRowPlacementDirection() == BScreen::LeftRight) ?
|
||||
start_pos : space.w() - win_size.w() - start_pos;
|
||||
while (!placed &&
|
||||
((screen.getRowPlacementDirection() == BScreen::RightLeft) ?
|
||||
test_x > 0 : test_x + win_size.w() < (signed) space.w())) {
|
||||
placed = true;
|
||||
|
||||
it.reset();
|
||||
for (OpenboxWindow *curr = it.current(); placed && curr;
|
||||
it++, curr = it.current()) {
|
||||
int curr_w = curr->getWidth() + (screen.getBorderWidth() * 4);
|
||||
int curr_h =
|
||||
((curr->isShaded()) ? curr->getTitleHeight() : curr->getHeight()) +
|
||||
(screen.getBorderWidth() * 4);
|
||||
|
||||
if (curr->getXFrame() < test_x + win_size.w() &&
|
||||
curr->getXFrame() + curr_w > test_x &&
|
||||
curr->getYFrame() < test_y + win_size.h() &&
|
||||
curr->getYFrame() + curr_h > test_y) {
|
||||
placed = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Removed code for checking toolbar and slit
|
||||
// The space passed in should not include either
|
||||
|
||||
if (placed) {
|
||||
place_x = test_x;
|
||||
place_y = test_y;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
test_x += (change_x * delta_x);
|
||||
}
|
||||
test_x = (screen.getRowPlacementDirection() == BScreen::LeftRight) ?
|
||||
start_pos : space.w() - win_size.w() - start_pos;
|
||||
while (!placed &&
|
||||
((screen.getRowPlacementDirection() == BScreen::RightLeft) ?
|
||||
test_x > 0 : test_x + win_size.w() < (signed) space.w())) {
|
||||
placed = true;
|
||||
|
||||
test_y += (change_y * delta_y);
|
||||
it.reset();
|
||||
for (OpenboxWindow *curr = it.current(); placed && curr;
|
||||
it++, curr = it.current()) {
|
||||
int curr_w = curr->size().w() + (screen.getBorderWidth() * 4);
|
||||
int curr_h = curr->size().h() + (screen.getBorderWidth() * 4);
|
||||
|
||||
if (curr->origin().x() < test_x + win_size.w() &&
|
||||
curr->origin().x() + curr_w > test_x &&
|
||||
curr->origin().y() < test_y + win_size.h() &&
|
||||
curr->origin().y() + curr_h > test_y) {
|
||||
placed = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Removed code for checking toolbar and slit
|
||||
// The space passed in should not include either
|
||||
|
||||
if (placed) {
|
||||
place_x = test_x;
|
||||
place_y = test_y;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
test_x += (change_x * delta_x);
|
||||
}
|
||||
|
||||
test_y += (change_y * delta_y);
|
||||
}
|
||||
return new Point(place_x, place_y);
|
||||
}
|
||||
|
@ -463,8 +461,8 @@ void Workspace::placeWindow(OpenboxWindow *win) {
|
|||
|
||||
Bool placed = False;
|
||||
|
||||
const int win_w = win->getWidth() + (screen.getBorderWidth() * 4),
|
||||
win_h = win->getHeight() + (screen.getBorderWidth() * 4),
|
||||
const int win_w = win->size().w() + (screen.getBorderWidth() * 4),
|
||||
win_h = win->size().h() + (screen.getBorderWidth() * 4),
|
||||
#ifdef SLIT
|
||||
slit_x = screen.getSlit()->getX() - screen.getBorderWidth(),
|
||||
slit_y = screen.getSlit()->getY() - screen.getBorderWidth(),
|
||||
|
@ -537,15 +535,15 @@ void Workspace::placeWindow(OpenboxWindow *win) {
|
|||
it++, curr = it.current()) {
|
||||
if (curr->isMaximizedFull()) // fully maximized, ignore it
|
||||
continue;
|
||||
int curr_w = curr->getWidth() + (screen.getBorderWidth() * 4);
|
||||
int curr_w = curr->size().w() + (screen.getBorderWidth() * 4);
|
||||
int curr_h =
|
||||
((curr->isShaded()) ? curr->getTitleHeight() : curr->getHeight()) +
|
||||
((curr->isShaded()) ? curr->getTitleHeight() : curr->size().h()) +
|
||||
(screen.getBorderWidth() * 4);
|
||||
|
||||
if (curr->getXFrame() < test_x + win_w &&
|
||||
curr->getXFrame() + curr_w > test_x &&
|
||||
curr->getYFrame() < test_y + win_h &&
|
||||
curr->getYFrame() + curr_h > test_y) {
|
||||
if (curr->origin().x() < test_x + win_w &&
|
||||
curr->origin().x() + curr_w > test_x &&
|
||||
curr->origin().y() < test_y + win_h &&
|
||||
curr->origin().y() + curr_h > test_y) {
|
||||
placed = False;
|
||||
}
|
||||
}
|
||||
|
@ -599,5 +597,5 @@ void Workspace::placeWindow(OpenboxWindow *win) {
|
|||
if (place_y + win_h > (signed) screen.getHeight())
|
||||
place_y = (((signed) screen.getHeight()) - win_h) / 2;
|
||||
|
||||
win->configure(place_x, place_y, win->getWidth(), win->getHeight());
|
||||
win->configure(place_x, place_y, win->size().w(), win->size().h());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue