X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2FToolbar.cc;h=a1a6e118269ad96182dd8b5885c913bffdcfab53;hb=733b4f4a3366eca53dc68fd40069b673b0261c96;hp=2487c112b62adee76eecbad3b7462c8e90f42dd6;hpb=300491ce5a932ba777274e7f5c3d085f5ca59ee0;p=chaz%2Fopenbox diff --git a/src/Toolbar.cc b/src/Toolbar.cc index 2487c112..a1a6e118 100644 --- a/src/Toolbar.cc +++ b/src/Toolbar.cc @@ -77,8 +77,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 +96,6 @@ Toolbar::Toolbar(BScreen *scrn) { editing = False; new_name_pos = 0; - frame.grab_x = frame.grab_y = 0; toolbarmenu = new Toolbarmenu(this); @@ -625,6 +624,32 @@ void Toolbar::redrawWorkspaceLabel(bool redraw) { } +void Toolbar::drawArrow(Drawable surface, bool left) const { + int hh = frame.button_w / 2, hw = frame.button_w / 2; + XPoint pts[3]; + const int bullet_size = 3; + + if (left) { + 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); + } else { + 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; + } + + BPen pen(screen->getToolbarStyle()->b_pic); + XFillPolygon(display, surface, pen.gc(), pts, 3, Convex, CoordModePrevious); +} + + void Toolbar::redrawPrevWorkspaceButton(bool pressed, bool redraw) { if (redraw) { if (pressed) { @@ -641,17 +666,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); } @@ -671,17 +686,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); } @@ -701,17 +706,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); } @@ -731,17 +726,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); } @@ -931,13 +916,9 @@ void Toolbar::keyPressEvent(const XKeyEvent *ke) { 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; @@ -953,7 +934,6 @@ void Toolbar::keyPressEvent(const 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 ||