X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2FWindow.cc;h=e179824365885361661ea9dee601236a28c5b21b;hb=08d793bb796f608774d6fdefd1950df54477e2c6;hp=e735d07b8809352977cc877c4edd126a0016ed10;hpb=888c0bac90d4932d00dd7f7447ea52117aff6de0;p=chaz%2Fopenbox diff --git a/src/Window.cc b/src/Window.cc index e735d07b..e1798243 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -44,6 +44,7 @@ extern "C" { #include "i18n.hh" #include "blackbox.hh" +#include "Font.hh" #include "GCCache.hh" #include "Iconmenu.hh" #include "Image.hh" @@ -1225,9 +1226,12 @@ void BlackboxWindow::getMWMHints(void) { num = PropMwmHintsElements; if (! xatom->getValue(client.window, XAtom::motif_wm_hints, XAtom::motif_wm_hints, num, - (unsigned long **)&mwm_hint) || - num < PropMwmHintsElements) + (unsigned long **)&mwm_hint)) return; + if (num < PropMwmHintsElements) { + delete [] mwm_hint; + return; + } if (mwm_hint->flags & MwmHintsDecorations) { if (mwm_hint->decorations & MwmDecorAll) { @@ -1268,7 +1272,7 @@ void BlackboxWindow::getMWMHints(void) { functions |= Func_Close; } } - delete mwm_hint; + delete [] mwm_hint; } @@ -1286,9 +1290,12 @@ bool BlackboxWindow::getBlackboxHints(void) { num = PropBlackboxHintsElements; if (! xatom->getValue(client.window, XAtom::blackbox_hints, XAtom::blackbox_hints, num, - (unsigned long **)&blackbox_hint) || - num < PropBlackboxHintsElements) + (unsigned long **)&blackbox_hint)) return False; + if (num < PropBlackboxHintsElements) { + delete [] blackbox_hint; + return False; + } if (blackbox_hint->flags & AttribShaded) flags.shaded = (blackbox_hint->attrib & AttribShaded); @@ -1350,7 +1357,7 @@ bool BlackboxWindow::getBlackboxHints(void) { reconfigure(); } - delete blackbox_hint; + delete [] blackbox_hint; return True; } @@ -2103,7 +2110,7 @@ void BlackboxWindow::restoreAttributes(void) { (unsigned long **)&net)) return; if (num < PropBlackboxAttributesElements) { - delete net; + delete [] net; return; } @@ -2169,7 +2176,7 @@ void BlackboxWindow::restoreAttributes(void) { // with the state set it will then be the map event's job to read the // window's state and behave accordingly - delete net; + delete [] net; } @@ -2317,20 +2324,12 @@ void BlackboxWindow::redrawLabel(void) const { WindowStyle *style = screen->getWindowStyle(); - int pos = frame.bevel_w * 2, - dlen = style->doJustify(client.title.c_str(), pos, frame.label_w, - frame.bevel_w * 4, i18n.multibyte()); - - BPen pen((flags.focused) ? style->l_text_focus : style->l_text_unfocus, - style->font); - if (i18n.multibyte()) - XmbDrawString(blackbox->getXDisplay(), frame.label, style->fontset, - pen.gc(), pos, - (1 - style->fontset_extents->max_ink_extent.y), - client.title.c_str(), dlen); - else - XDrawString(blackbox->getXDisplay(), frame.label, pen.gc(), pos, - (style->font->ascent + 1), client.title.c_str(), dlen); + int pos = frame.bevel_w * 2; + style->doJustify(client.title.c_str(), pos, frame.label_w, frame.bevel_w * 4); + style->font->drawString(frame.label, pos, 1, + (flags.focused ? style->l_text_focus : + style->l_text_unfocus), + client.title); } @@ -3400,12 +3399,7 @@ void BlackboxWindow::upsize(void) { // the height of the titlebar is based upon the height of the font being // used to display the window's title WindowStyle *style = screen->getWindowStyle(); - if (i18n.multibyte()) - frame.title_h = (style->fontset_extents->max_ink_extent.height + - (frame.bevel_w * 2) + 2); - else - frame.title_h = (style->font->ascent + style->font->descent + - (frame.bevel_w * 2) + 2); + frame.title_h = style->font->height() + (frame.bevel_w * 2) + 2; frame.label_h = frame.title_h - (frame.bevel_w * 2); frame.button_w = (frame.label_h - 2); @@ -3548,21 +3542,14 @@ void BlackboxWindow::constrain(Corner anchor, int *pw, int *ph) { } -int WindowStyle::doJustify(const char *text, int &start_pos, - unsigned int max_length, unsigned int modifier, - bool multibyte) const { - size_t text_len = strlen(text); +int WindowStyle::doJustify(const std::string &text, int &start_pos, + unsigned int max_length, + unsigned int modifier) const { + size_t text_len = text.size(); unsigned int length; do { - if (multibyte) { - XRectangle ink, logical; - XmbTextExtents(fontset, text, text_len, &ink, &logical); - length = logical.width; - } else { - length = XTextWidth(font, text, text_len); - } - length += modifier; + length = font->measureString(string(text, 0, text_len)) + modifier; } while (length > max_length && text_len-- > 0); switch (justify) {