pretty sure all frame elements are placed correctly now
This commit is contained in:
parent
6e2593cadc
commit
3762f3c88f
3 changed files with 70 additions and 48 deletions
|
@ -89,6 +89,8 @@ public:
|
||||||
|
|
||||||
inline const BFont *getFont() const { return font; }
|
inline const BFont *getFont() const { return font; }
|
||||||
|
|
||||||
|
inline const BColor &getBorderColor() const { return border_color; }
|
||||||
|
|
||||||
inline void setImageControl(BImageControl *c) { image_control = c; }
|
inline void setImageControl(BImageControl *c) { image_control = c; }
|
||||||
inline void setScreenNumber(unsigned int scr) { screen_number = scr; }
|
inline void setScreenNumber(unsigned int scr) { screen_number = scr; }
|
||||||
|
|
||||||
|
|
92
src/frame.cc
92
src/frame.cc
|
@ -27,9 +27,6 @@ OBFrame::OBFrame(const OBClient *client, const otk::Style *style)
|
||||||
|
|
||||||
_decorations = client->decorations();
|
_decorations = client->decorations();
|
||||||
|
|
||||||
_style = 0;
|
|
||||||
loadStyle(style);
|
|
||||||
|
|
||||||
// create the base frame parent window
|
// create the base frame parent window
|
||||||
_window = createFrame();
|
_window = createFrame();
|
||||||
assert(_window);
|
assert(_window);
|
||||||
|
@ -57,23 +54,28 @@ OBFrame::OBFrame(const OBClient *client, const otk::Style *style)
|
||||||
assert(_grip_right);
|
assert(_grip_right);
|
||||||
XMapSubwindows(otk::OBDisplay::display, _handle);
|
XMapSubwindows(otk::OBDisplay::display, _handle);
|
||||||
|
|
||||||
|
_style = 0;
|
||||||
|
loadStyle(style);
|
||||||
|
|
||||||
grabClient();
|
grabClient();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
OBFrame::~OBFrame()
|
OBFrame::~OBFrame()
|
||||||
{
|
{
|
||||||
releaseClient(false);
|
|
||||||
|
|
||||||
XDestroyWindow(otk::OBDisplay::display, _titlebar);
|
|
||||||
XDestroyWindow(otk::OBDisplay::display, _button_iconify);
|
XDestroyWindow(otk::OBDisplay::display, _button_iconify);
|
||||||
XDestroyWindow(otk::OBDisplay::display, _button_max);
|
XDestroyWindow(otk::OBDisplay::display, _button_max);
|
||||||
XDestroyWindow(otk::OBDisplay::display, _button_stick);
|
XDestroyWindow(otk::OBDisplay::display, _button_stick);
|
||||||
XDestroyWindow(otk::OBDisplay::display, _button_close);
|
XDestroyWindow(otk::OBDisplay::display, _button_close);
|
||||||
XDestroyWindow(otk::OBDisplay::display, _label);
|
XDestroyWindow(otk::OBDisplay::display, _label);
|
||||||
XDestroyWindow(otk::OBDisplay::display, _handle);
|
XDestroyWindow(otk::OBDisplay::display, _titlebar);
|
||||||
XDestroyWindow(otk::OBDisplay::display, _grip_left);
|
XDestroyWindow(otk::OBDisplay::display, _grip_left);
|
||||||
XDestroyWindow(otk::OBDisplay::display, _grip_right);
|
XDestroyWindow(otk::OBDisplay::display, _grip_right);
|
||||||
|
XDestroyWindow(otk::OBDisplay::display, _handle);
|
||||||
|
|
||||||
|
releaseClient(false);
|
||||||
|
|
||||||
|
XDestroyWindow(otk::OBDisplay::display, _window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -83,7 +85,6 @@ void OBFrame::loadStyle(const otk::Style *style)
|
||||||
|
|
||||||
// if a style was previously set, then 'replace' is true, cause we're
|
// if a style was previously set, then 'replace' is true, cause we're
|
||||||
// replacing a style
|
// replacing a style
|
||||||
// NOTE: if this is false, then DO NOT DO SHIT WITH _window, it doesnt exist
|
|
||||||
bool replace = (_style);
|
bool replace = (_style);
|
||||||
|
|
||||||
if (replace) {
|
if (replace) {
|
||||||
|
@ -92,12 +93,31 @@ void OBFrame::loadStyle(const otk::Style *style)
|
||||||
|
|
||||||
_style = style;
|
_style = style;
|
||||||
|
|
||||||
|
XSetWindowBorderWidth(otk::OBDisplay::display, _window,
|
||||||
|
_style->getBorderWidth());
|
||||||
|
XSetWindowBorder(otk::OBDisplay::display, _window,
|
||||||
|
_style->getBorderColor().pixel());
|
||||||
|
XSetWindowBorderWidth(otk::OBDisplay::display, _titlebar,
|
||||||
|
_style->getBorderWidth());
|
||||||
|
XSetWindowBorder(otk::OBDisplay::display, _titlebar,
|
||||||
|
_style->getBorderColor().pixel());
|
||||||
|
XSetWindowBorderWidth(otk::OBDisplay::display, _grip_left,
|
||||||
|
_style->getBorderWidth());
|
||||||
|
XSetWindowBorder(otk::OBDisplay::display, _grip_left,
|
||||||
|
_style->getBorderColor().pixel());
|
||||||
|
XSetWindowBorderWidth(otk::OBDisplay::display, _grip_right,
|
||||||
|
_style->getBorderWidth());
|
||||||
|
XSetWindowBorder(otk::OBDisplay::display, _grip_right,
|
||||||
|
_style->getBorderColor().pixel());
|
||||||
|
XSetWindowBorderWidth(otk::OBDisplay::display, _handle,
|
||||||
|
_style->getBorderWidth());
|
||||||
|
XSetWindowBorder(otk::OBDisplay::display, _handle,
|
||||||
|
_style->getBorderColor().pixel());
|
||||||
|
|
||||||
|
// if !replace, then update() will get called after the client is grabbed!
|
||||||
if (replace) {
|
if (replace) {
|
||||||
update();
|
update();
|
||||||
|
|
||||||
XSetWindowBorderWidth(otk::OBDisplay::display, _window,
|
|
||||||
_style->getBorderWidth());
|
|
||||||
|
|
||||||
// XXX: make everything redraw
|
// XXX: make everything redraw
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,7 +132,7 @@ void OBFrame::update()
|
||||||
|
|
||||||
if (_decorations & OBClient::Decor_Border) {
|
if (_decorations & OBClient::Decor_Border) {
|
||||||
_size.left = _size.top = _size.bottom = _size.right =
|
_size.left = _size.top = _size.bottom = _size.right =
|
||||||
_style->getBorderWidth() + _style->getFrameWidth();
|
_style->getFrameWidth();
|
||||||
width = _client->area().width() + _style->getFrameWidth() * 2;
|
width = _client->area().width() + _style->getFrameWidth() * 2;
|
||||||
} else {
|
} else {
|
||||||
_size.left = _size.top = _size.bottom = _size.right = 0;
|
_size.left = _size.top = _size.bottom = _size.right = 0;
|
||||||
|
@ -120,15 +140,17 @@ void OBFrame::update()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_decorations & OBClient::Decor_Titlebar) {
|
if (_decorations & OBClient::Decor_Titlebar) {
|
||||||
_titlebar_area.setRect(0, 0, width,
|
// set the titlebar size
|
||||||
|
_titlebar_area.setRect(-_style->getBorderWidth(),
|
||||||
|
-_style->getBorderWidth(),
|
||||||
|
width,
|
||||||
(_style->getFont()->height() +
|
(_style->getFont()->height() +
|
||||||
_style->getFrameWidth() * 2));
|
_style->getBevelWidth() * 2));
|
||||||
_size.top += _titlebar_area.height() + _style->getBorderWidth();
|
_size.top += _titlebar_area.height() + _style->getBorderWidth();
|
||||||
|
|
||||||
// set the label size
|
// set the label size
|
||||||
_label_area.setRect(0, _style->getBevelWidth(),
|
_label_area.setRect(0, _style->getBevelWidth(),
|
||||||
width, (_titlebar_area.height() -
|
width, _style->getFont()->height());
|
||||||
_style->getBevelWidth() * 2));
|
|
||||||
// set the buttons sizes
|
// set the buttons sizes
|
||||||
if (_decorations & OBClient::Decor_Iconify)
|
if (_decorations & OBClient::Decor_Iconify)
|
||||||
_button_iconify_area.setRect(0, _style->getBevelWidth() + 1,
|
_button_iconify_area.setRect(0, _style->getBevelWidth() + 1,
|
||||||
|
@ -187,30 +209,30 @@ void OBFrame::update()
|
||||||
continue; // just to fuck with g++
|
continue; // just to fuck with g++
|
||||||
}
|
}
|
||||||
area->setX(x);
|
area->setX(x);
|
||||||
|
if (layout[i] != 'L')
|
||||||
|
_label_area.setWidth(_label_area.width() - area->width());
|
||||||
x += sep + area->width();
|
x += sep + area->width();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_decorations & OBClient::Decor_Handle) {
|
if (_decorations & OBClient::Decor_Handle) {
|
||||||
_handle_area.setRect(0, _size.top + _client->area().height() +
|
_handle_area.setRect(-_style->getBorderWidth(),
|
||||||
_style->getBorderWidth(),
|
_size.top + _client->area().height(),
|
||||||
width, _style->getHandleWidth());
|
width, _style->getHandleWidth());
|
||||||
_grip_left_area.setRect(0,
|
_grip_left_area.setRect(-_style->getBorderWidth(),
|
||||||
_handle_area.y() + _handle_area.height() +
|
-_style->getBorderWidth(),
|
||||||
_style->getBorderWidth(),
|
|
||||||
// XXX: get a Point class in otk and use that for
|
// XXX: get a Point class in otk and use that for
|
||||||
// the 'buttons size' since theyre all the same
|
// the 'buttons size' since theyre all the same
|
||||||
_button_iconify_area.width() * 2,
|
_button_iconify_area.width() * 2,
|
||||||
_handle_area.height());
|
_handle_area.height());
|
||||||
_grip_right_area.setRect(((_handle_area.right() + 1) -
|
_grip_right_area.setRect(((_handle_area.right() + 1) -
|
||||||
_button_iconify_area.width() * 2),
|
_button_iconify_area.width() * 2),
|
||||||
_handle_area.y() + _handle_area.height() +
|
-_style->getBorderWidth(),
|
||||||
_style->getBorderWidth(),
|
|
||||||
// XXX: get a Point class in otk and use that for
|
// XXX: get a Point class in otk and use that for
|
||||||
// the 'buttons size' since theyre all the same
|
// the 'buttons size' since theyre all the same
|
||||||
_button_iconify_area.width() * 2,
|
_button_iconify_area.width() * 2,
|
||||||
_handle_area.height());
|
_handle_area.height());
|
||||||
_size.bottom += _handle_area.height() + _style->getBorderWidth() * 2;
|
_size.bottom += _handle_area.height() + _style->getBorderWidth();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -266,9 +288,6 @@ void OBFrame::update()
|
||||||
|
|
||||||
// map/unmap all the windows
|
// map/unmap all the windows
|
||||||
if (_decorations & OBClient::Decor_Titlebar) {
|
if (_decorations & OBClient::Decor_Titlebar) {
|
||||||
XMapWindow(otk::OBDisplay::display, _titlebar);
|
|
||||||
XSetWindowBorder(otk::OBDisplay::display, _titlebar,
|
|
||||||
_style->getBorderWidth());
|
|
||||||
XMapWindow(otk::OBDisplay::display, _label);
|
XMapWindow(otk::OBDisplay::display, _label);
|
||||||
if (_decorations & OBClient::Decor_Iconify)
|
if (_decorations & OBClient::Decor_Iconify)
|
||||||
XMapWindow(otk::OBDisplay::display, _button_iconify);
|
XMapWindow(otk::OBDisplay::display, _button_iconify);
|
||||||
|
@ -286,6 +305,7 @@ void OBFrame::update()
|
||||||
XMapWindow(otk::OBDisplay::display, _button_close);
|
XMapWindow(otk::OBDisplay::display, _button_close);
|
||||||
else
|
else
|
||||||
XUnmapWindow(otk::OBDisplay::display, _button_close);
|
XUnmapWindow(otk::OBDisplay::display, _button_close);
|
||||||
|
XMapWindow(otk::OBDisplay::display, _titlebar);
|
||||||
} else {
|
} else {
|
||||||
XUnmapWindow(otk::OBDisplay::display, _titlebar);
|
XUnmapWindow(otk::OBDisplay::display, _titlebar);
|
||||||
XUnmapWindow(otk::OBDisplay::display, _label);
|
XUnmapWindow(otk::OBDisplay::display, _label);
|
||||||
|
@ -296,15 +316,9 @@ void OBFrame::update()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_decorations & OBClient::Decor_Handle) {
|
if (_decorations & OBClient::Decor_Handle) {
|
||||||
XMapWindow(otk::OBDisplay::display, _handle);
|
|
||||||
XSetWindowBorder(otk::OBDisplay::display, _handle,
|
|
||||||
_style->getBorderWidth());
|
|
||||||
XMapWindow(otk::OBDisplay::display, _grip_left);
|
XMapWindow(otk::OBDisplay::display, _grip_left);
|
||||||
XSetWindowBorder(otk::OBDisplay::display, _grip_left,
|
|
||||||
_style->getBorderWidth());
|
|
||||||
XMapWindow(otk::OBDisplay::display, _grip_right);
|
XMapWindow(otk::OBDisplay::display, _grip_right);
|
||||||
XSetWindowBorder(otk::OBDisplay::display, _grip_right,
|
XMapWindow(otk::OBDisplay::display, _handle);
|
||||||
_style->getBorderWidth());
|
|
||||||
} else {
|
} else {
|
||||||
XUnmapWindow(otk::OBDisplay::display, _handle);
|
XUnmapWindow(otk::OBDisplay::display, _handle);
|
||||||
XUnmapWindow(otk::OBDisplay::display, _grip_left);
|
XUnmapWindow(otk::OBDisplay::display, _grip_left);
|
||||||
|
@ -424,9 +438,11 @@ Window OBFrame::createChild(Window parent, Cursor cursor)
|
||||||
attrib_create.cursor = cursor;
|
attrib_create.cursor = cursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
return XCreateWindow(otk::OBDisplay::display, parent, 0, 0, 1, 1, 0,
|
Window w = XCreateWindow(otk::OBDisplay::display, parent, 0, 0, 1, 1, 0,
|
||||||
_screen->getDepth(), InputOutput, _screen->getVisual(),
|
_screen->getDepth(), InputOutput,
|
||||||
create_mask, &attrib_create);
|
_screen->getVisual(), create_mask, &attrib_create);
|
||||||
|
XRaiseWindow(otk::OBDisplay::display, w); // raise above the parent
|
||||||
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -447,7 +463,7 @@ Window OBFrame::createFrame()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return XCreateWindow(otk::OBDisplay::display, _screen->getRootWindow(),
|
return XCreateWindow(otk::OBDisplay::display, _screen->getRootWindow(),
|
||||||
0, 0, 1, 1, _style->getBorderWidth(),
|
0, 0, 1, 1, 0,
|
||||||
_screen->getDepth(), InputOutput, _screen->getVisual(),
|
_screen->getDepth(), InputOutput, _screen->getVisual(),
|
||||||
create_mask, &attrib_create);
|
create_mask, &attrib_create);
|
||||||
}
|
}
|
||||||
|
|
|
@ -156,16 +156,6 @@ void OBXEventHandler::manageWindow(int screen, Window window)
|
||||||
|
|
||||||
// create the OBClient class, which gets all of the hints on the window
|
// create the OBClient class, which gets all of the hints on the window
|
||||||
Openbox::instance->addClient(window, client = new OBClient(screen, window));
|
Openbox::instance->addClient(window, client = new OBClient(screen, window));
|
||||||
// add all the client's decoration windows as event handlers for the client
|
|
||||||
Openbox::instance->addClient(client->frame->titlebar(), client);
|
|
||||||
Openbox::instance->addClient(client->frame->buttonIconify(), client);
|
|
||||||
Openbox::instance->addClient(client->frame->buttonMax(), client);
|
|
||||||
Openbox::instance->addClient(client->frame->buttonStick(), client);
|
|
||||||
Openbox::instance->addClient(client->frame->buttonClose(), client);
|
|
||||||
Openbox::instance->addClient(client->frame->label(), client);
|
|
||||||
Openbox::instance->addClient(client->frame->handle(), client);
|
|
||||||
Openbox::instance->addClient(client->frame->gripLeft(), client);
|
|
||||||
Openbox::instance->addClient(client->frame->gripRight(), client);
|
|
||||||
|
|
||||||
// we dont want a border on the client
|
// we dont want a border on the client
|
||||||
XSetWindowBorderWidth(otk::OBDisplay::display, window, 0);
|
XSetWindowBorderWidth(otk::OBDisplay::display, window, 0);
|
||||||
|
@ -182,7 +172,20 @@ void OBXEventHandler::manageWindow(int screen, Window window)
|
||||||
otk::Style *style = ((Blackbox*)Openbox::instance)->
|
otk::Style *style = ((Blackbox*)Openbox::instance)->
|
||||||
searchScreen(RootWindow(otk::OBDisplay::display, screen))->
|
searchScreen(RootWindow(otk::OBDisplay::display, screen))->
|
||||||
getWindowStyle();
|
getWindowStyle();
|
||||||
|
// create the decoration frame for the client window
|
||||||
client->frame = new OBFrame(client, style);
|
client->frame = new OBFrame(client, style);
|
||||||
|
|
||||||
|
// add all the client's decoration windows as event handlers for the client
|
||||||
|
Openbox::instance->addClient(client->frame->window(), client);
|
||||||
|
Openbox::instance->addClient(client->frame->titlebar(), client);
|
||||||
|
Openbox::instance->addClient(client->frame->buttonIconify(), client);
|
||||||
|
Openbox::instance->addClient(client->frame->buttonMax(), client);
|
||||||
|
Openbox::instance->addClient(client->frame->buttonStick(), client);
|
||||||
|
Openbox::instance->addClient(client->frame->buttonClose(), client);
|
||||||
|
Openbox::instance->addClient(client->frame->label(), client);
|
||||||
|
Openbox::instance->addClient(client->frame->handle(), client);
|
||||||
|
Openbox::instance->addClient(client->frame->gripLeft(), client);
|
||||||
|
Openbox::instance->addClient(client->frame->gripRight(), client);
|
||||||
|
|
||||||
// XXX: if on the current desktop..
|
// XXX: if on the current desktop..
|
||||||
XMapWindow(otk::OBDisplay::display, client->frame->window());
|
XMapWindow(otk::OBDisplay::display, client->frame->window());
|
||||||
|
@ -212,6 +215,7 @@ void OBXEventHandler::unmanageWindow(OBClient *client)
|
||||||
// remove the client class from the search list
|
// remove the client class from the search list
|
||||||
Openbox::instance->removeClient(client->window());
|
Openbox::instance->removeClient(client->window());
|
||||||
// remove the frame's decor elements as event handlers for the client
|
// remove the frame's decor elements as event handlers for the client
|
||||||
|
Openbox::instance->removeClient(frame->window());
|
||||||
Openbox::instance->removeClient(frame->titlebar());
|
Openbox::instance->removeClient(frame->titlebar());
|
||||||
Openbox::instance->removeClient(frame->buttonIconify());
|
Openbox::instance->removeClient(frame->buttonIconify());
|
||||||
Openbox::instance->removeClient(frame->buttonMax());
|
Openbox::instance->removeClient(frame->buttonMax());
|
||||||
|
|
Loading…
Reference in a new issue