all repos — fluxbox @ 34343bb20bdb3dc94fe426f69e5db16315353d57

custom fork of the fluxbox windowmanager

Feature #3602124: 'LHalf' and 'RHalf' buttons to the titlebar

First draft of feature request of #3602124: Having 2 buttons in the titlebar
which allow quick positioning of a Window into the left or right half of the
current monitor.
Mathias Gumz akira at fluxbox dot org
commit

34343bb20bdb3dc94fe426f69e5db16315353d57

parent

94fddc09c064555721dc521e3e94ed6f610653b9

M src/Resources.ccsrc/Resources.cc

@@ -108,6 +108,12 @@ break;

case WinButton::MENUICON: retval.append("MenuIcon"); break; + case WinButton::LEFT_HALF: + retval.append("LHalf"); + break; + case WinButton::RIGHT_HALF: + retval.append("RHalf"); + break; default: break; }

@@ -142,6 +148,10 @@ else if (v == "menuicon")

m_value.push_back(WinButton::MENUICON); else if (v == "close") m_value.push_back(WinButton::CLOSE); + else if (v == "lhalf") + m_value.push_back(WinButton::LEFT_HALF); + else if (v == "rhalf") + m_value.push_back(WinButton::RIGHT_HALF); } }
M src/WinButton.ccsrc/WinButton.cc

@@ -137,6 +137,10 @@ if (m_icon_pixmap.drawable())

return theme->titlePixmap().pixmap().drawable(); else return theme->menuiconPixmap().pixmap().drawable(); + case LEFT_HALF: + return theme->leftHalfPixmap().pixmap().drawable(); + case RIGHT_HALF: + return theme->rightHalfPixmap().pixmap().drawable(); default: return None; }

@@ -160,18 +164,14 @@

// otherwise draw old style imagery switch (m_type) { case MAXIMIZE: - // if no pixmap was used, use old style - if (gc() == 0) // must have valid graphic context - return; - - drawRectangle(gc(), - 2, 2, width() - 5, height() - 5); - drawLine(gc(), - 2, 3, width() - 3, 3); + drawRectangle(gc(), 2, 2, width() - 5, height() - 5); + drawLine(gc(), 2, 3, width() - 3, 3); break; + case MINIMIZE: drawRectangle(gc(), 2, height() - 5, width() - 5, 2); break; + case STICK: // width/4 != width/2, so we use /4*2 so that it's properly centred if (m_listen_to.isStuck()) {

@@ -184,6 +184,7 @@ width()/2 - width()/10, height()/2 - height()/10,

width()/10*2 + oddW, height()/10*2 + oddH); } break; + case CLOSE: drawLine(gc(), 2, 2,

@@ -199,15 +200,12 @@ // Mine:

// XFree86 Version 4.3.0.1 (Debian 4.3.0.dfsg.1-1 20040428170728) // (X Protocol Version 11, Revision 0, Release 6.6) - drawLine(gc(), - 2, height() - 3, - width() - 3, 2); + drawLine(gc(), 2, height() - 3, width() - 3, 2); break; - case SHADE: + case SHADE: { int size = width() - 5 - oddW; - drawRectangle(gc(), 2, 2, size, 2); // draw a one-quarter triangle below the rectangle

@@ -220,6 +218,7 @@ 100);

break; } + case MENUICON: if (m_icon_pixmap.drawable()) {

@@ -242,9 +241,15 @@ } else {

for (unsigned int y = height()/3; y <= height() - height()/3; y+=3) { drawLine(gc(), width()/4, y, width() - width()/4 - oddW - 1, y); } - drawRectangle(gc(), - 2, 2, width() - 5, height() - 5); + drawRectangle(gc(), 2, 2, width() - 5, height() - 5); } + break; + + case LEFT_HALF: + fillRectangle(gc(), 2, 2, (width() / 2) - oddW, height() - 4); + break; + case RIGHT_HALF: + fillRectangle(gc(), width() / 2, 2, (width() / 2) - 2 + oddW, height() - 4); break; } }
M src/WinButton.hhsrc/WinButton.hh

@@ -38,7 +38,17 @@ /// draws and handles basic window button graphic

class WinButton:public FbTk::Button, public FbTk::SignalTracker { public: /// draw type for the button - enum Type {MAXIMIZE, MINIMIZE, SHADE, STICK, CLOSE, MENUICON}; + enum Type { + MAXIMIZE, + MINIMIZE, + SHADE, + STICK, + CLOSE, + MENUICON, + LEFT_HALF, + RIGHT_HALF + }; + WinButton(FluxboxWindow &listen_to, FbTk::ThemeProxy<WinButtonTheme> &theme, FbTk::ThemeProxy<WinButtonTheme> &pressed,

@@ -66,7 +76,7 @@ FbTk::ThemeProxy<WinButtonTheme> &m_theme, &m_pressed_theme;

FbTk::FbPixmap m_icon_pixmap; FbTk::FbPixmap m_icon_mask; - + bool overrode_bg, overrode_pressed; };
M src/WinButtonTheme.ccsrc/WinButtonTheme.cc

@@ -52,6 +52,10 @@ m_stick_pm(*this, "window.stick" + extra + ".pixmap",

"Window.Stick" + altextra + ".Pixmap"), m_stuck_pm(*this, "window.stuck" + extra + ".pixmap", "Window.Stuck" + altextra + ".Pixmap"), + m_lefthalf_pm(*this, "window.lhalf" + extra + ".pixmap", + "Window.LHalf" + altextra + ".Pixmap"), + m_righthalf_pm(*this, "window.rhalf" + extra + ".pixmap", + "Window.RHalf" + altextra + ".Pixmap"), m_frame_theme(frame_theme) { FbTk::ThemeManager::instance().loadTheme(*this);

@@ -82,5 +86,7 @@ m_unshade_pm->scale(size, size);

m_title_pm->scale(size, size); m_stick_pm->scale(size, size); m_stuck_pm->scale(size, size); + m_lefthalf_pm->scale(size, size); + m_righthalf_pm->scale(size, size); }
M src/WinButtonTheme.hhsrc/WinButtonTheme.hh

@@ -62,10 +62,18 @@ FbTk::PixmapWithMask &unshadePixmap() { return *m_unshade_pm; }

const FbTk::PixmapWithMask &menuiconPixmap() const { return *m_menuicon_pm; } FbTk::PixmapWithMask &menuiconPixmap() { return *m_menuicon_pm; } - + FbTk::PixmapWithMask &titlePixmap() { return *m_title_pm; } const FbTk::PixmapWithMask &titlePixmap() const { return *m_title_pm; } + + FbTk::PixmapWithMask &leftHalfPixmap() { return *m_lefthalf_pm; } + const FbTk::PixmapWithMask &leftHalfPixmap() const { return *m_lefthalf_pm; } + + FbTk::PixmapWithMask &rightHalfPixmap() { return *m_righthalf_pm; } + const FbTk::PixmapWithMask &rightHalfPixmap() const { return *m_righthalf_pm; } + + virtual FbTk::Signal<> &reconfigSig() { return FbTk::Theme::reconfigSig(); } virtual WinButtonTheme &operator *() { return *this; }

@@ -75,7 +83,7 @@ private:

FbTk::ThemeItem<FbTk::PixmapWithMask> m_close_pm, m_maximize_pm, m_iconify_pm, m_shade_pm, m_unshade_pm, m_menuicon_pm, m_title_pm, - m_stick_pm, m_stuck_pm; + m_stick_pm, m_stuck_pm, m_lefthalf_pm, m_righthalf_pm; FbTk::ThemeProxy<FbWinFrameTheme> &m_frame_theme; };
M src/Window.ccsrc/Window.cc

@@ -48,6 +48,7 @@ #include "Debug.hh"

#include "FbTk/StringUtil.hh" #include "FbTk/Compose.hh" +#include "FbTk/CommandParser.hh" #include "FbTk/EventManager.hh" #include "FbTk/KeyUtil.hh" #include "FbTk/SimpleCommand.hh"

@@ -3600,6 +3601,32 @@ FbTk::MemFunIgnoreArgs(*winbtn, &WinButton::updateAll));

winbtn->setOnClick(show_menu_cmd); } break; + + case WinButton::LEFT_HALF: + { + winbtn = new WinButton(*this, m_button_theme, + screen().pressedWinButtonTheme(), + dir[i], + frame().titlebar(), + 0, 0, 10, 10); + + CommandRef lhalf_cmd(FbTk::CommandParser<void>::instance().parse("MacroCmd {MoveTo 0 0} {ResizeTo 50% 100%}")); + winbtn->setOnClick(lhalf_cmd); + } + break; + + case WinButton::RIGHT_HALF: + { + winbtn = new WinButton(*this, m_button_theme, + screen().pressedWinButtonTheme(), + dir[i], + frame().titlebar(), + 0, 0, 10, 10); + CommandRef rhalf_cmd(FbTk::CommandParser<void>::instance().parse("MacroCmd {MoveTo 50% 0} {ResizeTo 50% 100%}")); + winbtn->setOnClick(rhalf_cmd); + } + break; + }