}
-ScreenInfo::ScreenInfo(BaseDisplay &d, int num) : basedisplay(d) {
- screen_number = num;
+ScreenInfo::ScreenInfo(BaseDisplay &d, int num) : basedisplay(d),
+ screen_number(num)
+{
root_window = RootWindow(basedisplay.getXDisplay(), screen_number);
depth = DefaultDepth(basedisplay.getXDisplay(), screen_number);
- width =
- WidthOfScreen(ScreenOfDisplay(basedisplay.getXDisplay(), screen_number));
- height =
- HeightOfScreen(ScreenOfDisplay(basedisplay.getXDisplay(), screen_number));
+ m_size = Size(WidthOfScreen(ScreenOfDisplay(basedisplay.getXDisplay(),
+ screen_number)),
+ HeightOfScreen(ScreenOfDisplay(basedisplay.getXDisplay(),
+ screen_number)));
// search for a TrueColor Visual... if we can't find one... we will use the
// default visual for the screen
#include "LinkedList.h"
#include "Timer.h"
+#include "Geometry.h"
#define AttribShaded (1l << 0)
#define AttribMaxHoriz (1l << 1)
Colormap colormap;
int depth, screen_number;
- unsigned int width, height;
+ Size m_size;
public:
inline const int &getDepth(void) const { return depth; }
inline const int &getScreenNumber(void) const { return screen_number; }
- inline const unsigned int &getWidth(void) const { return width; }
- inline const unsigned int &getHeight(void) const { return height; }
+// inline const unsigned int &getWidth(void) const { return width; }
+// inline const unsigned int &getHeight(void) const { return height; }
+ inline const Size &size() const { return m_size; }
};
while (((menu.item_h * (menuitems->count() + 1) / menu.sublevels)
+ menu.title_h + screen.getBorderWidth()) >
- screen.getHeight())
+ screen.size().h())
menu.sublevels++;
if (menu.sublevels < menu.minsub) menu.sublevels = menu.minsub;
y = (((shifted) ? menu.y_shift : menu.y) +
menu.height - item->submenu()->menu.height);
- if ((x + item->submenu()->getWidth()) > screen.getWidth()) {
+ if ((x + item->submenu()->getWidth()) > screen.size().w()) {
x = ((shifted) ? menu.x_shift : menu.x) -
item->submenu()->getWidth() - screen.getBorderWidth();
}
if (x < 0) x = 0;
- if ((y + item->submenu()->getHeight()) > screen.getHeight())
- y = screen.getHeight() - item->submenu()->getHeight() -
+ if ((y + item->submenu()->getHeight()) > screen.size().h())
+ y = screen.size().h() - item->submenu()->getHeight() -
(screen.getBorderWidth() * 2);
if (y < 0) y = 0;
void Basemenu::enterNotifyEvent(XCrossingEvent *ce) {
if (ce->window == menu.frame) {
menu.x_shift = menu.x, menu.y_shift = menu.y;
- if (menu.x + menu.width > screen.getWidth()) {
- menu.x_shift = screen.getWidth() - menu.width -
+ if (menu.x + menu.width > screen.size().w()) {
+ menu.x_shift = screen.size().w() - menu.width -
screen.getBorderWidth();
shifted = True;
} else if (menu.x < 0) {
shifted = True;
}
- if (menu.y + menu.height > screen.getHeight()) {
- menu.y_shift = screen.getHeight() - menu.height -
+ if (menu.y + menu.height > screen.size().h()) {
+ menu.y_shift = screen.size().h() - menu.height -
screen.getBorderWidth();
shifted = True;
} else if (menu.y + (signed) menu.title_h < 0) {
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) {
+Size::Size(const unsigned int w, const unsigned int h) : m_w(w), m_h(h) {
}
-void Size::setW(const int w) {
+void Size::setW(const unsigned int w) {
m_w = w;
}
-void Size::setH(const int h) {
+void Size::setH(const unsigned int h) {
m_h = h;
}
m_size(size) {
}
-Rect::Rect(const int x, const int y, const int w, const int h) : m_origin(x, y),
- m_size(w, h) {
+Rect::Rect(const int x, const int y, const unsigned int w, const unsigned int h)
+ : m_origin(x, y), m_size(w, h) {
}
void Rect::setSize(const Size &size) {
m_origin.setY(y);
}
-void Rect::setW(int w) {
+void Rect::setW(unsigned int w) {
m_size.setW(w);
}
-void Rect::setH(int h) {
+void Rect::setH(unsigned int h) {
m_size.setH(h);
}
};
class Size{
- int m_w, m_h;
+ unsigned int m_w, m_h;
public:
Size();
Size(const Size &size);
- Size(const int w, const int h);
+ Size(const unsigned int w, const unsigned int h);
- void setW(const int w);
- inline int w() const {
+ void setW(const unsigned int w);
+ inline unsigned int w() const {
return m_w;
}
- void setH(const int h);
- inline int h() const {
+ void setH(const unsigned int h);
+ inline unsigned int h() const {
return m_h;
}
};
public:
Rect();
Rect(const Point &origin, const Size &size);
- Rect(const int x, const int y, const int w, const int h);
+ Rect(const int x, const int y, const unsigned int w, const unsigned int h);
void setSize(const Size &size);
inline const Size &size() const {
return m_origin.y();
}
- void setW(const int w);
- inline int w() const {
+ void setW(const unsigned int w);
+ inline unsigned int w() const {
return m_size.w();
}
- void setH(const int h);
- inline int h() const {
+ void setH(const unsigned int h);
+ inline unsigned int h() const {
return m_size.h();
}
// load bevel, border and handle widths
if (conf.getValue("handleWidth", "HandleWidth", l)) {
- if (l <= getWidth() / 2 && l != 0)
+ if (l <= size().w() / 2 && l != 0)
resource.handle_width = l;
else
resource.handle_width = 6;
resource.border_width = 1;
if (conf.getValue("bevelWidth", "BevelWidth", l)) {
- if (l <= getWidth() / 2 && l != 0)
+ if (l <= size().w() / 2 && l != 0)
resource.bevel_width = l;
else
resource.bevel_width = 3;
resource.bevel_width = 3;
if (conf.getValue("frameWidth", "FrameWidth", l)) {
- if (l <= getWidth() / 2)
+ if (l <= size().w() / 2)
resource.frame_width = l;
else
resource.frame_width = resource.bevel_width;
void BScreen::showPosition(int x, int y) {
if (! geom_visible) {
XMoveResizeWindow(getBaseDisplay().getXDisplay(), geom_window,
- (getWidth() - geom_w) / 2,
- (getHeight() - geom_h) / 2, geom_w, geom_h);
+ (size().w() - geom_w) / 2,
+ (size().h() - geom_h) / 2, geom_w, geom_h);
XMapWindow(getBaseDisplay().getXDisplay(), geom_window);
XRaiseWindow(getBaseDisplay().getXDisplay(), geom_window);
void BScreen::showGeometry(unsigned int gx, unsigned int gy) {
if (! geom_visible) {
XMoveResizeWindow(getBaseDisplay().getXDisplay(), geom_window,
- (getWidth() - geom_w) / 2,
- (getHeight() - geom_h) / 2, geom_w, geom_h);
+ (size().w() - geom_w) / 2,
+ (size().h() - geom_h) / 2, geom_w, geom_h);
XMapWindow(getBaseDisplay().getXDisplay(), geom_window);
XRaiseWindow(getBaseDisplay().getXDisplay(), geom_window);
if (wmhints) {
if ((wmhints->flags & IconWindowHint) &&
(wmhints->icon_window != None)) {
- XMoveWindow(display, client->client_window, screen.getWidth() + 10,
- screen.getHeight() + 10);
+ XMoveWindow(display, client->client_window, screen.size().w() + 10,
+ screen.size().h() + 10);
XMapWindow(display, client->client_window);
client->icon_window = wmhints->icon_window;
case CenterLeft:
frame.x = 0;
- frame.y = (screen.getHeight() - frame.height) / 2;
+ frame.y = (screen.size().h() - frame.height) / 2;
frame.x_hidden = screen.getBevelWidth() - screen.getBorderWidth()
- frame.width;
frame.y_hidden = frame.y;
case BottomLeft:
frame.x = 0;
- frame.y = screen.getHeight() - frame.height
+ frame.y = screen.size().h() - frame.height
- (screen.getBorderWidth() * 2);
if (screen.getSlitDirection() == Vertical) {
frame.x_hidden = screen.getBevelWidth() - screen.getBorderWidth()
frame.y_hidden = frame.y;
} else {
frame.x_hidden = 0;
- frame.y_hidden = screen.getHeight() - screen.getBevelWidth()
+ frame.y_hidden = screen.size().h() - screen.getBevelWidth()
- screen.getBorderWidth();
}
break;
case TopCenter:
- frame.x = (screen.getWidth() - frame.width) / 2;
+ frame.x = (screen.size().w() - frame.width) / 2;
frame.y = 0;
frame.x_hidden = frame.x;
frame.y_hidden = screen.getBevelWidth() - screen.getBorderWidth()
break;
case BottomCenter:
- frame.x = (screen.getWidth() - frame.width) / 2;
- frame.y = screen.getHeight() - frame.height
+ frame.x = (screen.size().h() - frame.width) / 2;
+ frame.y = screen.size().h() - frame.height
- (screen.getBorderWidth() * 2);
frame.x_hidden = frame.x;
- frame.y_hidden = screen.getHeight() - screen.getBevelWidth()
+ frame.y_hidden = screen.size().h() - screen.getBevelWidth()
- screen.getBorderWidth();
break;
case TopRight:
- frame.x = screen.getWidth() - frame.width
+ frame.x = screen.size().w() - frame.width
- (screen.getBorderWidth() * 2);
frame.y = 0;
if (screen.getSlitDirection() == Vertical) {
- frame.x_hidden = screen.getWidth() - screen.getBevelWidth()
+ frame.x_hidden = screen.size().w() - screen.getBevelWidth()
- screen.getBorderWidth();
frame.y_hidden = 0;
} else {
case CenterRight:
default:
- frame.x = screen.getWidth() - frame.width
+ frame.x = screen.size().w() - frame.width
- (screen.getBorderWidth() * 2);
- frame.y = (screen.getHeight() - frame.height) / 2;
- frame.x_hidden = screen.getWidth() - screen.getBevelWidth()
+ frame.y = (screen.size().h() - frame.height) / 2;
+ frame.x_hidden = screen.size().w() - screen.getBevelWidth()
- screen.getBorderWidth();
frame.y_hidden = frame.y;
break;
case BottomRight:
- frame.x = screen.getWidth() - frame.width
+ frame.x = screen.size().w() - frame.width
- (screen.getBorderWidth() * 2);
- frame.y = screen.getHeight() - frame.height
+ frame.y = screen.size().h() - frame.height
- (screen.getBorderWidth() * 2);
if (screen.getSlitDirection() == Vertical) {
- frame.x_hidden = screen.getWidth() - screen.getBevelWidth()
+ frame.x_hidden = screen.size().w() - screen.getBevelWidth()
- screen.getBorderWidth();
frame.y_hidden = frame.y;
} else {
frame.x_hidden = frame.x;
- frame.y_hidden = screen.getHeight() - screen.getBevelWidth()
+ frame.y_hidden = screen.size().h() - screen.getBevelWidth()
- screen.getBorderWidth();
}
break;
if (x < 0)
x = 0;
- else if (x + slitmenu->getWidth() > screen.getWidth())
- x = screen.getWidth() - slitmenu->getWidth();
+ else if (x + slitmenu->getWidth() > screen.size().w())
+ x = screen.size().w() - slitmenu->getWidth();
if (y < 0)
y = 0;
- else if (y + slitmenu->getHeight() > screen.getHeight())
- y = screen.getHeight() - slitmenu->getHeight();
+ else if (y + slitmenu->getHeight() > screen.size().h())
+ y = screen.size().h() - slitmenu->getHeight();
slitmenu->move(x, y);
slitmenu->show();
void Toolbar::reconfigure(void) {
frame.bevel_w = screen.getBevelWidth();
- frame.width = screen.getWidth() * screen.getToolbarWidthPercent() / 100;
+ frame.width = screen.size().w() * screen.getToolbarWidthPercent() / 100;
if (i18n->multibyte())
frame.height =
case BottomLeft:
frame.x = 0;
- frame.y = screen.getHeight() - frame.height
+ frame.y = screen.size().h() - frame.height
- (screen.getBorderWidth() * 2);
frame.x_hidden = 0;
- frame.y_hidden = screen.getHeight() - screen.getBevelWidth()
+ frame.y_hidden = screen.size().h() - screen.getBevelWidth()
- screen.getBorderWidth();
break;
case TopCenter:
- frame.x = (screen.getWidth() - frame.width) / 2;
+ frame.x = (screen.size().w() - frame.width) / 2;
frame.y = 0;
frame.x_hidden = frame.x;
frame.y_hidden = screen.getBevelWidth() - screen.getBorderWidth()
case BottomCenter:
default:
- frame.x = (screen.getWidth() - frame.width) / 2;
- frame.y = screen.getHeight() - frame.height
+ frame.x = (screen.size().w() - frame.width) / 2;
+ frame.y = screen.size().h() - frame.height
- (screen.getBorderWidth() * 2);
frame.x_hidden = frame.x;
- frame.y_hidden = screen.getHeight() - screen.getBevelWidth()
+ frame.y_hidden = screen.size().h() - screen.getBevelWidth()
- screen.getBorderWidth();
break;
case TopRight:
- frame.x = screen.getWidth() - frame.width
+ frame.x = screen.size().w() - frame.width
- (screen.getBorderWidth() * 2);
frame.y = 0;
frame.x_hidden = frame.x;
break;
case BottomRight:
- frame.x = screen.getWidth() - frame.width
+ frame.x = screen.size().w() - frame.width
- (screen.getBorderWidth() * 2);
- frame.y = screen.getHeight() - frame.height
+ frame.y = screen.size().h() - frame.height
- (screen.getBorderWidth() * 2);
frame.x_hidden = frame.x;
- frame.y_hidden = screen.getHeight() - screen.getBevelWidth()
+ frame.y_hidden = screen.size().h() - screen.getBevelWidth()
- screen.getBorderWidth();
break;
}
if (x < 0)
x = 0;
- else if (x + toolbarmenu->getWidth() > screen.getWidth())
- x = screen.getWidth() - toolbarmenu->getWidth();
+ else if (x + toolbarmenu->getWidth() > screen.size().w())
+ x = screen.size().w() - toolbarmenu->getWidth();
if (y < 0)
y = 0;
- else if (y + toolbarmenu->getHeight() > screen.getHeight())
- y = screen.getHeight() - toolbarmenu->getHeight();
+ else if (y + toolbarmenu->getHeight() > screen.size().h())
+ y = screen.size().h() - toolbarmenu->getHeight();
toolbarmenu->move(x, y);
toolbarmenu->show();
if ((openbox.isStartup()) ||
(frame.x >= 0 &&
(signed) (frame.y + frame.y_border) >= 0 &&
- frame.x <= (signed) screen->getWidth() &&
- frame.y <= (signed) screen->getHeight()))
+ frame.x <= (signed) screen->size().w() &&
+ frame.y <= (signed) screen->size().h()))
place_window = False;
}
client.min_width = client.min_height =
client.base_width = client.base_height =
client.width_inc = client.height_inc = 1;
- client.max_width = screen->getWidth();
- client.max_height = screen->getHeight();
+ client.max_width = screen->size().w();
+ client.max_height = screen->size().h();
client.min_aspect_x = client.min_aspect_y =
client.max_aspect_x = client.max_aspect_y = 1;
client.win_gravity = NorthWestGravity;
if (((signed) (frame.x + frame.width)) < 0) {
if (((signed) (frame.y + frame.y_border)) < 0)
configure(frame.border_w, frame.border_w, frame.width, frame.height);
- else if (frame.y > (signed) screen->getHeight())
- configure(frame.border_w, screen->getHeight() - frame.height,
+ else if (frame.y > (signed) screen->size().h())
+ configure(frame.border_w, screen->size().h() - frame.height,
frame.width, frame.height);
else
configure(frame.border_w, frame.y + frame.border_w,
frame.width, frame.height);
- } else if (frame.x > (signed) screen->getWidth()) {
+ } else if (frame.x > (signed) screen->size().w()) {
if (((signed) (frame.y + frame.y_border)) < 0)
- configure(screen->getWidth() - frame.width, frame.border_w,
+ configure(screen->size().w() - frame.width, frame.border_w,
frame.width, frame.height);
- else if (frame.y > (signed) screen->getHeight())
- configure(screen->getWidth() - frame.width,
- screen->getHeight() - frame.height, frame.width, frame.height);
+ else if (frame.y > (signed) screen->size().h())
+ configure(screen->size().w() - frame.width,
+ screen->size().h() - frame.height, frame.width, frame.height);
else
- configure(screen->getWidth() - frame.width,
+ configure(screen->size().w() - frame.width,
frame.y + frame.border_w, frame.width, frame.height);
}
openbox_attrib.premax_w = frame.width;
openbox_attrib.premax_h = frame.height;
- dw = screen->getWidth();
+ dw = screen->size().w();
dw -= frame.border_w * 2;
dw -= frame.mwm_border_w * 2;
dw -= client.base_width;
- dh = screen->getHeight();
+ dh = screen->size().h();
dh -= frame.border_w * 2;
dh -= frame.mwm_border_w * 2;
dh -= ((frame.handle_h + frame.border_w) * decorations.handle);
dh += ((frame.handle_h + frame.border_w) * decorations.handle);
dh += frame.mwm_border_w * 2;
- dx += ((screen->getWidth() - dw) / 2) - frame.border_w;
+ dx += ((screen->size().w() - dw) / 2) - frame.border_w;
if (screen->doFullMax()) {
- dy += ((screen->getHeight() - dh) / 2) - frame.border_w;
+ dy += ((screen->size().h() - dh) / 2) - frame.border_w;
} else {
- dy += (((screen->getHeight() - screen->getToolbar()->getExposedHeight())
+ dy += (((screen->size().h() - screen->getToolbar()->getExposedHeight())
- dh) / 2) - frame.border_w;
switch (screen->getToolbarPlacement()) {
unsigned int snap_w = frame.width + (frame.border_w * 2);
unsigned int snap_h = size().h() + (frame.border_w * 2);
if (snap_distance) {
- int drx = screen->getWidth() - (dx + snap_w);
+ int drx = screen->size().w() - (dx + snap_w);
if (dx < drx && (dx > 0 && dx < snap_distance) ||
(dx < 0 && dx > -snap_distance) )
dx = 0;
else if ( (drx > 0 && drx < snap_distance) ||
(drx < 0 && drx > -snap_distance) )
- dx = screen->getWidth() - snap_w;
+ dx = screen->size().w() - snap_w;
int dtty, dbby, dty, dby;
switch (screen->getToolbarPlacement()) {
case Toolbar::TopRight:
dtty = screen->getToolbar()->getExposedHeight() +
frame.border_w;
- dbby = screen->getHeight();
+ dbby = screen->size().h();
break;
default:
LinkedListIterator<OpenboxWindow> it(windowList);
test_y = (screen.getColPlacementDirection() == BScreen::TopBottom) ?
- start_pos : screen.getHeight() - win_size.h() - start_pos;
+ start_pos : screen.size().h() - win_size.h() - start_pos;
while(!placed &&
((screen.getColPlacementDirection() == BScreen::BottomTop) ?
LinkedListIterator<OpenboxWindow> it(windowList);
Rect space(0, 0,
- screen.getWidth(),
- screen.getHeight()
+ screen.size().w(),
+ screen.size().h()
);
Size window_size(win_w, win_h);
case BScreen::ColSmartPlacement: {
test_x = (screen.getRowPlacementDirection() == BScreen::LeftRight) ?
- start_pos : screen.getWidth() - win_w - start_pos;
+ start_pos : screen.size().w() - win_w - start_pos;
while (!placed &&
((screen.getRowPlacementDirection() == BScreen::RightLeft) ?
- test_x > 0 : test_x + win_w < (signed) screen.getWidth())) {
+ test_x > 0 : test_x + win_w < (signed) screen.size().w())) {
test_y = (screen.getColPlacementDirection() == BScreen::TopBottom) ?
- start_pos : screen.getHeight() - win_h - start_pos;
+ start_pos : screen.size().h() - win_h - start_pos;
while (!placed &&
((screen.getColPlacementDirection() == BScreen::BottomTop) ?
- test_y > 0 : test_y + win_h < (signed) screen.getHeight())) {
+ test_y > 0 : test_y + win_h < (signed) screen.size().h())) {
placed = True;
it.reset();
} // switch
if (! placed) {
- if (((unsigned) cascade_x > (screen.getWidth() / 2)) ||
- ((unsigned) cascade_y > (screen.getHeight() / 2)))
+ if (((unsigned) cascade_x > (screen.size().w() / 2)) ||
+ ((unsigned) cascade_y > (screen.size().h() / 2)))
cascade_x = cascade_y = 32;
place_x = cascade_x;
cascade_y += win->getTitleHeight();
}
- if (place_x + win_w > (signed) screen.getWidth())
- place_x = (((signed) screen.getWidth()) - win_w) / 2;
- if (place_y + win_h > (signed) screen.getHeight())
- place_y = (((signed) screen.getHeight()) - win_h) / 2;
+ if (place_x + win_w > (signed) screen.size().w())
+ place_x = (((signed) screen.size().w()) - win_w) / 2;
+ if (place_y + win_h > (signed) screen.size().h())
+ place_y = (((signed) screen.size().h()) - win_h) / 2;
win->configure(place_x, place_y, win->size().w(), win->size().h());
}
if (my < 0) my = 0;
if (mx + screen->getWorkspacemenu()->getWidth() >
- screen->getWidth())
- mx = screen->getWidth() -
+ screen->size().w())
+ mx = screen->size().w() -
screen->getWorkspacemenu()->getWidth() -
screen->getBorderWidth();
if (my + screen->getWorkspacemenu()->getHeight() >
- screen->getHeight())
- my = screen->getHeight() -
+ screen->size().h())
+ my = screen->size().h() -
screen->getWorkspacemenu()->getHeight() -
screen->getBorderWidth();
if (mx < 0) mx = 0;
if (my < 0) my = 0;
- if (mx + screen->getRootmenu()->getWidth() > screen->getWidth())
- mx = screen->getWidth() -
+ if (mx + screen->getRootmenu()->getWidth() > screen->size().w())
+ mx = screen->size().w() -
screen->getRootmenu()->getWidth() -
screen->getBorderWidth();
- if (my + screen->getRootmenu()->getHeight() > screen->getHeight())
- my = screen->getHeight() -
+ if (my + screen->getRootmenu()->getHeight() > screen->size().h())
+ my = screen->size().h() -
screen->getRootmenu()->getHeight() -
screen->getBorderWidth();