X-Git-Url: https://git.brokenzipper.com/gitweb?a=blobdiff_plain;f=src%2FToolbar.cc;h=587d3fd430269c444c93dc39010347368c4fdb75;hb=87e63d53af67d5ea98f55a27007663d4c9c8fc6c;hp=0018e43ff96c73972f648c17f35acf45096ec46e;hpb=08d793bb796f608774d6fdefd1950df54477e2c6;p=chaz%2Fopenbox diff --git a/src/Toolbar.cc b/src/Toolbar.cc index 0018e43f..587d3fd4 100644 --- a/src/Toolbar.cc +++ b/src/Toolbar.cc @@ -53,16 +53,14 @@ using std::string; #include "i18n.hh" #include "blackbox.hh" -#include "Clientmenu.hh" #include "Font.hh" #include "GCCache.hh" -#include "Iconmenu.hh" #include "Image.hh" -#include "Rootmenu.hh" #include "Screen.hh" #include "Toolbar.hh" #include "Window.hh" #include "Workspace.hh" +#include "Clientmenu.hh" #include "Workspacemenu.hh" #include "Slit.hh" @@ -77,8 +75,8 @@ static long aMinuteFromNow(void) { Toolbar::Toolbar(BScreen *scrn) { screen = scrn; blackbox = screen->getBlackbox(); - toolbarstr = (string)"session.screen" + itostring(screen->getScreenNumber()) - + ".toolbar."; + toolbarstr = "session.screen" + itostring(screen->getScreenNumber()) + + ".toolbar."; config = blackbox->getConfig(); load_rc(); @@ -96,7 +94,6 @@ Toolbar::Toolbar(BScreen *scrn) { editing = False; new_name_pos = 0; - frame.grab_x = frame.grab_y = 0; toolbarmenu = new Toolbarmenu(this); @@ -159,8 +156,6 @@ Toolbar::Toolbar(BScreen *scrn) { frame.base = frame.label = frame.wlabel = frame.clk = frame.button = frame.pbutton = None; - screen->addStrut(&strut); - reconfigure(); mapToolbar(); } @@ -203,6 +198,7 @@ void Toolbar::mapToolbar() { XMapSubwindows(display, frame.window); XMapWindow(display, frame.window); } + screen->addStrut(&strut); updateStrut(); } @@ -211,6 +207,9 @@ void Toolbar::unmapToolbar() { if (toolbarmenu->isVisible()) toolbarmenu->hide(); //hidden so we can maximize over the toolbar + screen->removeStrut(&strut); + screen->updateAvailableArea(); + XUnmapWindow(display, frame.window); updateStrut(); } @@ -582,6 +581,11 @@ void Toolbar::checkClock(bool redraw, bool date) { int pos = frame.bevel_w * 2; // this is modified by doJustify() style->doJustify(t, pos, frame.clock_w, frame.bevel_w * 4); + +#ifdef XFT + XClearWindow(display, frame.clock); +#endif // XFT + style->font->drawString(frame.clock, pos, 1, style->c_text, t); } } @@ -594,6 +598,10 @@ void Toolbar::redrawWindowLabel(bool redraw) { return; } +#ifdef XFT + redraw = true; +#endif // XFT + if (redraw) XClearWindow(display, frame.window_label); @@ -611,6 +619,10 @@ void Toolbar::redrawWindowLabel(bool redraw) { void Toolbar::redrawWorkspaceLabel(bool redraw) { const string& name = screen->getCurrentWorkspace()->getName(); +#ifdef XFT + redraw = true; +#endif // XFT + if (redraw) XClearWindow(display, frame.workspace_label); @@ -623,6 +635,78 @@ void Toolbar::redrawWorkspaceLabel(bool redraw) { } +void Toolbar::drawArrow(Drawable surface, bool left) const { + ToolbarStyle *style = screen->getToolbarStyle(); + + BPen pen(style->b_pic); + + int hh = frame.button_w / 2, hw = frame.button_w / 2; + XPoint pts[3]; + const int bullet_size = 3; + + + if (left) { +#ifdef BITMAPBUTTONS + if (style->left_button.mask != None) { + XSetClipMask(blackbox->getXDisplay(), pen.gc(), style->left_button.mask); + XSetClipOrigin(blackbox->getXDisplay(), pen.gc(), + (frame.button_w - style->left_button.w)/2, + (frame.button_w - style->left_button.h)/2); + + XFillRectangle(blackbox->getXDisplay(), surface, pen.gc(), + (frame.button_w - style->left_button.w)/2, + (frame.button_w - style->left_button.h)/2, + style->left_button.w, style->left_button.h); + + XSetClipMask(blackbox->getXDisplay(), pen.gc(), None); + XSetClipOrigin(blackbox->getXDisplay(), pen.gc(), 0, 0); + } else { +#endif // BITMAPBUTTONS + pts[0].x = hw - bullet_size; + pts[0].y = hh; + pts[1].x = 2 * bullet_size; + pts[1].y = bullet_size; + pts[2].x = 0; + pts[2].y = -(2 * bullet_size); + XFillPolygon(display, surface, pen.gc(), pts, 3, Convex, + CoordModePrevious); +#ifdef BITMAPBUTTONS + } +#endif // BITMAPBUTTONS + } else { +#ifdef BITMAPBUTTONS + if (style->right_button.mask != None) { + XSetClipMask(blackbox->getXDisplay(), pen.gc(), + style->right_button.mask); + XSetClipOrigin(blackbox->getXDisplay(), pen.gc(), + (frame.button_w - style->right_button.w)/2, + (frame.button_w - style->right_button.h)/2); + + XFillRectangle(blackbox->getXDisplay(), surface, pen.gc(), + (frame.button_w - style->right_button.w)/2, + (frame.button_w - style->right_button.h)/2, + (frame.button_w + style->right_button.w)/2, + (frame.button_w + style->right_button.h)/2); + + XSetClipMask(blackbox->getXDisplay(), pen.gc(), None); + XSetClipOrigin(blackbox->getXDisplay(), pen.gc(), 0, 0); + } else { +#endif // BITMAPBUTTONS + pts[0].x = hw - bullet_size; + pts[0].y = hh - bullet_size; + pts[1].x = (2 * bullet_size); + pts[1].y = bullet_size; + pts[2].x = -(2 * bullet_size); + pts[2].y = bullet_size; + XFillPolygon(display, surface, pen.gc(), pts, 3, Convex, + CoordModePrevious); +#ifdef BITMAPBUTTONS + } +#endif + } +} + + void Toolbar::redrawPrevWorkspaceButton(bool pressed, bool redraw) { if (redraw) { if (pressed) { @@ -639,17 +723,7 @@ void Toolbar::redrawPrevWorkspaceButton(bool pressed, bool redraw) { XClearWindow(display, frame.psbutton); } - int hh = frame.button_w / 2, hw = frame.button_w / 2; - - XPoint pts[3]; - pts[0].x = hw - 2; pts[0].y = hh; - pts[1].x = 4; pts[1].y = 2; - pts[2].x = 0; pts[2].y = -4; - - ToolbarStyle *style = screen->getToolbarStyle(); - BPen pen(style->b_pic); - XFillPolygon(display, frame.psbutton, pen.gc(), - pts, 3, Convex, CoordModePrevious); + drawArrow(frame.psbutton, True); } @@ -669,17 +743,7 @@ void Toolbar::redrawNextWorkspaceButton(bool pressed, bool redraw) { XClearWindow(display, frame.nsbutton); } - int hh = frame.button_w / 2, hw = frame.button_w / 2; - - XPoint pts[3]; - pts[0].x = hw - 2; pts[0].y = hh - 2; - pts[1].x = 4; pts[1].y = 2; - pts[2].x = -4; pts[2].y = 2; - - ToolbarStyle *style = screen->getToolbarStyle(); - BPen pen(style->b_pic); - XFillPolygon(display, frame.nsbutton, pen.gc(), - pts, 3, Convex, CoordModePrevious); + drawArrow(frame.nsbutton, False); } @@ -699,17 +763,7 @@ void Toolbar::redrawPrevWindowButton(bool pressed, bool redraw) { XClearWindow(display, frame.pwbutton); } - int hh = frame.button_w / 2, hw = frame.button_w / 2; - - XPoint pts[3]; - pts[0].x = hw - 2; pts[0].y = hh; - pts[1].x = 4; pts[1].y = 2; - pts[2].x = 0; pts[2].y = -4; - - ToolbarStyle *style = screen->getToolbarStyle(); - BPen pen(style->b_pic); - XFillPolygon(display, frame.pwbutton, pen.gc(), - pts, 3, Convex, CoordModePrevious); + drawArrow(frame.pwbutton, True); } @@ -729,17 +783,7 @@ void Toolbar::redrawNextWindowButton(bool pressed, bool redraw) { XClearWindow(display, frame.nwbutton); } - int hh = frame.button_w / 2, hw = frame.button_w / 2; - - XPoint pts[3]; - pts[0].x = hw - 2; pts[0].y = hh - 2; - pts[1].x = 4; pts[1].y = 2; - pts[2].x = -4; pts[2].y = 2; - - ToolbarStyle *style = screen->getToolbarStyle(); - BPen pen(style->b_pic); - XFillPolygon(display, frame.nwbutton, pen.gc(), pts, 3, Convex, - CoordModePrevious); + drawArrow(frame.nwbutton, False); } @@ -777,7 +821,7 @@ void Toolbar::edit(void) { } -void Toolbar::buttonPressEvent(XButtonEvent *be) { +void Toolbar::buttonPressEvent(const XButtonEvent *be) { if (be->button == 1) { if (be->window == frame.psbutton) redrawPrevWorkspaceButton(True, True); @@ -826,7 +870,7 @@ void Toolbar::buttonPressEvent(XButtonEvent *be) { -void Toolbar::buttonReleaseEvent(XButtonEvent *re) { +void Toolbar::buttonReleaseEvent(const XButtonEvent *re) { if (re->button == 1) { if (re->window == frame.psbutton) { redrawPrevWorkspaceButton(False, True); @@ -873,7 +917,7 @@ void Toolbar::buttonReleaseEvent(XButtonEvent *re) { } -void Toolbar::enterNotifyEvent(XCrossingEvent *) { +void Toolbar::enterNotifyEvent(const XCrossingEvent *) { if (! do_auto_hide) return; @@ -884,7 +928,7 @@ void Toolbar::enterNotifyEvent(XCrossingEvent *) { } } -void Toolbar::leaveNotifyEvent(XCrossingEvent *) { +void Toolbar::leaveNotifyEvent(const XCrossingEvent *) { if (! do_auto_hide) return; @@ -896,7 +940,7 @@ void Toolbar::leaveNotifyEvent(XCrossingEvent *) { } -void Toolbar::exposeEvent(XExposeEvent *ee) { +void Toolbar::exposeEvent(const XExposeEvent *ee) { if (ee->window == frame.clock) checkClock(True); else if (ee->window == frame.workspace_label && (! editing)) redrawWorkspaceLabel(); @@ -908,7 +952,7 @@ void Toolbar::exposeEvent(XExposeEvent *ee) { } -void Toolbar::keyPressEvent(XKeyEvent *ke) { +void Toolbar::keyPressEvent(const XKeyEvent *ke) { if (ke->window == frame.workspace_label && editing) { if (new_workspace_name.empty()) { new_name_pos = 0; @@ -916,26 +960,21 @@ void Toolbar::keyPressEvent(XKeyEvent *ke) { KeySym ks; char keychar[1]; - XLookupString(ke, keychar, 1, &ks, 0); + XLookupString(const_cast(ke), keychar, 1, &ks, 0); // either we are told to end with a return or we hit 127 chars if (ks == XK_Return || new_name_pos == 127) { editing = False; blackbox->setNoFocus(False); - if (blackbox->getFocusedWindow()) { + if (blackbox->getFocusedWindow()) blackbox->getFocusedWindow()->setInputFocus(); - } else { + else blackbox->setFocusedWindow(0); - } - - Workspace *wkspc = screen->getCurrentWorkspace(); - wkspc->setName(new_workspace_name); - wkspc->getMenu()->hide(); - screen->getWorkspacemenu()->changeItemLabel(wkspc->getID() + 2, - wkspc->getName()); - screen->getWorkspacemenu()->update(); + // the toolbar will be reconfigured when the change to the workspace name + // gets caught in the PropertyNotify event handler + screen->getCurrentWorkspace()->setName(new_workspace_name); new_workspace_name.erase(); new_name_pos = 0; @@ -951,7 +990,6 @@ void Toolbar::keyPressEvent(XKeyEvent *ke) { else XSetWindowBackgroundPixmap(display, frame.workspace_label, frame.wlabel); - reconfigure(); } else if (! (ks == XK_Shift_L || ks == XK_Shift_R || ks == XK_Control_L || ks == XK_Control_R || ks == XK_Caps_Lock || ks == XK_Shift_Lock || @@ -1172,9 +1210,9 @@ void Toolbarmenu::Placementmenu::itemSelected(int button, unsigned int index) { } -int ToolbarStyle::doJustify(const std::string &text, int &start_pos, - unsigned int max_length, - unsigned int modifier) const { +void ToolbarStyle::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; @@ -1195,6 +1233,4 @@ int ToolbarStyle::doJustify(const std::string &text, int &start_pos, default: break; } - - return text_len; }