+
+ XSetWindowAttributes attrib;
+ unsigned long mask;
+ const otk::ScreenInfo *info = otk::display->screenInfo(client->screen());
+
+ // create all of the decor windows (except title bar buttons)
+ mask = CWOverrideRedirect | CWEventMask;
+ attrib.event_mask = Frame::event_mask;
+ attrib.override_redirect = true;
+ _frame = createWindow(info, info->rootWindow(), mask, &attrib);
+
+ mask = 0;
+ _plate = createWindow(info, _frame, mask, &attrib);
+ mask = CWEventMask;
+ attrib.event_mask = (ButtonPressMask | ButtonReleaseMask | ButtonMotionMask |
+ ExposureMask);
+ _title = createWindow(info, _frame, mask, &attrib);
+ _label = createWindow(info, _title, mask, &attrib);
+ _max = createWindow(info, _title, mask, &attrib);
+ _close = createWindow(info, _title, mask, &attrib);
+ _desk = createWindow(info, _title, mask, &attrib);
+ _icon = createWindow(info, _title, mask, &attrib);
+ _iconify = createWindow(info, _title, mask, &attrib);
+ _handle = createWindow(info, _frame, mask, &attrib);
+ mask |= CWCursor;
+ attrib.cursor = openbox->cursors().ll_angle;
+ _lgrip = createWindow(info, _handle, mask, &attrib);
+ attrib.cursor = openbox->cursors().lr_angle;
+ _rgrip = createWindow(info, _handle, mask, &attrib);
+
+ // the other stuff is shown based on decor settings
+ XMapWindow(**otk::display, _plate);
+ XMapWindow(**otk::display, _lgrip);
+ XMapWindow(**otk::display, _rgrip);
+ XMapWindow(**otk::display, _label);
+
+ applyStyle(*otk::RenderStyle::style(_client->screen()));
+
+ _layout = openbox->screen(_client->screen())->config().titlebar_layout;
+
+ // register all of the windows with the event dispatcher
+ Window *w = allWindows();
+ for (unsigned int i = 0; w[i]; ++i)
+ openbox->registerHandler(w[i], this);
+ delete [] w;
+}
+
+Frame::~Frame()
+{
+ // unregister all of the windows with the event dispatcher
+ Window *w = allWindows();
+ for (unsigned int i = 0; w[i]; ++i)
+ openbox->clearHandler(w[i]);
+ delete [] w;
+
+ XDestroyWindow(**otk::display, _rgrip);
+ XDestroyWindow(**otk::display, _lgrip);
+ XDestroyWindow(**otk::display, _handle);
+ XDestroyWindow(**otk::display, _max);
+ XDestroyWindow(**otk::display, _icon);
+ XDestroyWindow(**otk::display, _iconify);
+ XDestroyWindow(**otk::display, _desk);
+ XDestroyWindow(**otk::display, _close);
+ XDestroyWindow(**otk::display, _label);
+ XDestroyWindow(**otk::display, _title);
+ XDestroyWindow(**otk::display, _frame);
+
+ if (_frame_sur) delete _frame_sur;
+ if (_title_sur) delete _title_sur;
+ if (_label_sur) delete _label_sur;
+ if (_handle_sur) delete _handle_sur;
+ if (_grip_sur) delete _grip_sur;
+ if (_max_sur) delete _max_sur;
+ if (_desk_sur) delete _desk_sur;
+ if (_iconify_sur) delete _iconify_sur;
+ if (_icon_sur) delete _icon_sur;
+ if (_close_sur) delete _close_sur;
+}
+
+void Frame::show()
+{
+ if (!_visible) {
+ _visible = true;
+ XMapWindow(**otk::display, _frame);
+ }
+}
+
+void Frame::hide()
+{
+ if (_visible) {
+ _visible = false;
+ XUnmapWindow(**otk::display, _frame);
+ }
+}
+
+void Frame::buttonPressHandler(const XButtonEvent &e)
+{
+ if (_press_button) return;
+ _press_button = e.button;