all repos — openbox @ 767e04e090eb94850da6cf746278c152f464cf1b

openbox fork - make it a bit more like ryudo

Added a optional omnipresent button, enabled using the title bar layout key "S".
Needs to be documented, and the drawing tweaked a bit.
Scott Moynes smoynes@nexus.carleton.ca
commit

767e04e090eb94850da6cf746278c152f464cf1b

parent

d139e299d5c247fec472f177c4bca9b8d2bcbd06

2 files changed, 97 insertions(+), 7 deletions(-)

jump to
M src/Window.ccsrc/Window.cc

@@ -128,7 +128,8 @@ blackbox_attrib.premax_w = blackbox_attrib.premax_h = 0;

frame.border_w = 1; frame.window = frame.plate = frame.title = frame.handle = None; - frame.close_button = frame.iconify_button = frame.maximize_button = None; + frame.close_button = frame.iconify_button = frame.maximize_button = + frame.stick_button = None; frame.right_grip = frame.left_grip = None; frame.ulabel_pixel = frame.flabel_pixel = frame.utitle_pixel =

@@ -719,6 +720,9 @@

if (frame.maximize_button) destroyMaximizeButton(); + if (frame.stick_button) + destroyStickyButton(); + if (frame.ftitle) screen->getImageControl()->removeImage(frame.ftitle);

@@ -802,13 +806,28 @@ XDestroyWindow(blackbox->getXDisplay(), frame.maximize_button);

frame.maximize_button = None; } +void BlackboxWindow::createStickyButton(void) { + if (frame.title != None) { + frame.stick_button = createChildWindow(frame.title, + ButtonPressMask | + ButtonReleaseMask | + ButtonMotionMask | ExposureMask); + blackbox->saveWindowSearch(frame.stick_button, this); + } +} + +void BlackboxWindow::destroyStickyButton(void) { + blackbox->removeWindowSearch(frame.stick_button); + XDestroyWindow(blackbox->getXDisplay(), frame.stick_button); + frame.stick_button = None; +} void BlackboxWindow::positionButtons(bool redecorate_label) { string layout = blackbox->getTitlebarLayout(); string parsed; - bool hasclose, hasiconify, hasmaximize, haslabel; - hasclose = hasiconify = hasmaximize = haslabel = false; + bool hasclose, hasiconify, hasmaximize, haslabel, hasstick; + hasclose = hasiconify = hasmaximize = haslabel = hasstick = false; string::const_iterator it, end; for (it = layout.begin(), end = layout.end(); it != end; ++it) {

@@ -825,6 +844,12 @@ hasiconify = true;

parsed += *it; } break; + case 'S': + if (!hasstick) { + hasstick = true; + parsed += *it; + } + break; case 'M': if (! hasmaximize && (decorations & Decor_Maximize)) { hasmaximize = true;

@@ -836,14 +861,18 @@ if (! haslabel) {

haslabel = true; parsed += *it; } + break; } } + if (! hasclose && frame.close_button) destroyCloseButton(); if (! hasiconify && frame.iconify_button) destroyIconifyButton(); if (! hasmaximize && frame.maximize_button) destroyMaximizeButton(); + if (! hasstick && frame.stick_button) + destroyStickyButton(); if (! haslabel) parsed += 'L'; // require that the label be in the layout

@@ -866,6 +895,12 @@ break;

case 'I': if (! frame.iconify_button) createIconifyButton(); XMoveResizeWindow(blackbox->getXDisplay(), frame.iconify_button, x, by, + frame.button_w, frame.button_w); + x += frame.button_w + bsep; + break; + case 'S': + if (! frame.stick_button) createStickyButton(); + XMoveResizeWindow(blackbox->getXDisplay(), frame.stick_button, x, by, frame.button_w, frame.button_w); x += frame.button_w + bsep; break;

@@ -2077,6 +2112,9 @@ screen->getWorkspace(i)->addWindow(this, False, True);

setState(current_state); } + + redrawAllButtons(); + // go up the chain if (isTransient() && client.transient_for != (BlackboxWindow *) ~0ul && client.transient_for->isStuck() != flags.stuck)

@@ -2542,6 +2580,7 @@ void BlackboxWindow::redrawAllButtons(void) const {

if (frame.iconify_button) redrawIconifyButton(False); if (frame.maximize_button) redrawMaximizeButton(flags.maximized); if (frame.close_button) redrawCloseButton(False); + if (frame.stick_button) redrawStickyButton(flags.stuck); }

@@ -2651,6 +2690,40 @@ 2, (frame.button_w - 3), (frame.button_w - 3), 2);

} +void BlackboxWindow::redrawStickyButton(bool pressed) const { + if (! pressed) { + if (flags.focused) { + if (frame.fbutton) + XSetWindowBackgroundPixmap(blackbox->getXDisplay(), + frame.stick_button, frame.fbutton); + else + XSetWindowBackground(blackbox->getXDisplay(), frame.stick_button, + frame.fbutton_pixel); + } else { + if (frame.ubutton) + XSetWindowBackgroundPixmap(blackbox->getXDisplay(), + frame.stick_button, frame.ubutton); + else + XSetWindowBackground(blackbox->getXDisplay(), frame.stick_button, + frame.ubutton_pixel); + } + } else { + if (frame.pbutton) + XSetWindowBackgroundPixmap(blackbox->getXDisplay(), + frame.stick_button, frame.pbutton); + else + XSetWindowBackground(blackbox->getXDisplay(), frame.stick_button, + frame.pbutton_pixel); + } + XClearWindow(blackbox->getXDisplay(), frame.stick_button); + + BPen pen((flags.focused) ? screen->getWindowStyle()->b_pic_focus : + screen->getWindowStyle()->b_pic_unfocus); + + XFillRectangle(blackbox->getXDisplay(), frame.stick_button, pen.gc(), + frame.button_w/2 - 1, frame.button_w/2 -1, 2, 2 ); +} + void BlackboxWindow::mapRequestEvent(const XMapRequestEvent *re) { if (re->window != client.window) return;

@@ -2865,6 +2938,8 @@ else if (frame.maximize_button == ee->window)

redrawMaximizeButton(flags.maximized); else if (frame.iconify_button == ee->window) redrawIconifyButton(False); + else if (frame.stick_button == ee->window) + redrawStickyButton(flags.stuck); }

@@ -2958,6 +3033,8 @@ if (frame.iconify_button == be->window) {

redrawIconifyButton(True); } else if (frame.close_button == be->window) { redrawCloseButton(True); + } else if (frame.stick_button == be->window) { + redrawStickyButton(True); } else if (frame.plate == be->window) { if (windowmenu && windowmenu->isVisible()) windowmenu->hide();

@@ -2981,7 +3058,8 @@

screen->getWorkspace(blackbox_attrib.workspace)->raiseWindow(this); } } else if (be->button == 2 && (be->window != frame.iconify_button) && - (be->window != frame.close_button)) { + (be->window != frame.close_button) && + (be->window != frame.stick_button)) { screen->getWorkspace(blackbox_attrib.workspace)->lowerWindow(this); } else if (windowmenu && be->button == 3 && (frame.title == be->window || frame.label == be->window ||

@@ -3029,7 +3107,8 @@ if ((be->window == frame.label ||

be->window == frame.title || be->window == frame.maximize_button || be->window == frame.iconify_button || - be->window == frame.close_button) && + be->window == frame.close_button || + be->window == frame.stick_button) && ! flags.shaded) shade(); // mouse wheel down

@@ -3038,7 +3117,8 @@ if ((be->window == frame.label ||

be->window == frame.title || be->window == frame.maximize_button || be->window == frame.iconify_button || - be->window == frame.close_button) && + be->window == frame.close_button || + be->window == frame.stick_button) && flags.shaded) shade(); }

@@ -3065,6 +3145,13 @@ (re->y >= 0 && re->y <= static_cast<signed>(frame.button_w))) {

iconify(); } else { redrawIconifyButton(False); + } + } else if (re->window == frame.stick_button && re->button == 1) { + if ((re->x >= 0 && re->x <= static_cast<signed>(frame.button_w)) && + (re->y >= 0 && re->y <= static_cast<signed>(frame.button_w))) { + stick(); + } else { + redrawStickyButton(False); } } else if (re->window == frame.close_button & re->button == 1) { if ((re->x >= 0 && re->x <= static_cast<signed>(frame.button_w)) &&
M src/Window.hhsrc/Window.hh

@@ -230,7 +230,7 @@ plate, // holds the client

title, label, handle, - close_button, iconify_button, maximize_button, + close_button, iconify_button, maximize_button, stick_button, right_grip, left_grip; /*

@@ -285,12 +285,15 @@ void createIconifyButton(void);

void destroyIconifyButton(void); void createMaximizeButton(void); void destroyMaximizeButton(void); + void createStickyButton(void); + void destroyStickyButton(void); void redrawWindowFrame(void) const; void redrawLabel(void) const; void redrawAllButtons(void) const; void redrawCloseButton(bool pressed) const; void redrawIconifyButton(bool pressed) const; void redrawMaximizeButton(bool pressed) const; + void redrawStickyButton(bool pressed) const; void applyGravity(Rect &r); void restoreGravity(Rect &r); void setAllowedActions(void);