From 6b3881d999b79126595df8bca2585ee3eed366d2 Mon Sep 17 00:00:00 2001 From: fluxgen Date: Wed, 25 Jun 2003 13:37:06 +0000 Subject: applied max vert horiz toggle patch from MrChuoi --- src/Window.cc | 66 +++++++++++++++++++++++++++++++++++------------------------ src/Window.hh | 56 ++++++++++++++++++++++++++++++-------------------- 2 files changed, 73 insertions(+), 49 deletions(-) diff --git a/src/Window.cc b/src/Window.cc index 2cecd25..464210c 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Window.cc,v 1.197 2003/06/25 06:02:15 fluxgen Exp $ +// $Id: Window.cc,v 1.198 2003/06/25 13:37:06 fluxgen Exp $ #include "Window.hh" @@ -219,10 +219,6 @@ void LayerMenuItem::click(int button, int time) { m_object->moveToLayer(m_layernum); } - -//int FluxboxWindow::PropBlackboxHintsElements = 5; -//int FluxboxWindow::PropBlackboxAttributesElements = 8; - FluxboxWindow::FluxboxWindow(WinClient &client, BScreen &scr, FbWinFrameTheme &tm, FbTk::MenuTheme &menutheme, FbTk::XLayer &layer): @@ -232,9 +228,10 @@ FluxboxWindow::FluxboxWindow(WinClient &client, BScreen &scr, FbWinFrameTheme &t m_layersig(*this), m_workspacesig(*this), m_diesig(*this), - moving(false), resizing(false), shaded(false), maximized(false), + moving(false), resizing(false), shaded(false), iconic(false), focused(false), stuck(false), m_managed(false), + maximized(MAX_NONE), m_screen(scr), m_timer(this), display(0), @@ -512,7 +509,7 @@ void FluxboxWindow::init() { } if (maximized && functions.maximize) { // start maximized - maximized = false; + maximized = MAX_NONE; maximize(); } @@ -961,13 +958,13 @@ void FluxboxWindow::getBlackboxHints() { (hint->flags & ATTRIB_MAXVERT)) maximized = ((hint->attrib & (ATTRIB_MAXHORIZ | - ATTRIB_MAXVERT)) ? 1 : 0); + ATTRIB_MAXVERT)) ? MAX_FULL : MAX_NONE); else if (hint->flags & ATTRIB_MAXVERT) maximized = ((hint->attrib & - ATTRIB_MAXVERT) ? 2 : 0); + ATTRIB_MAXVERT) ? MAX_VERT : MAX_NONE); else if (hint->flags & ATTRIB_MAXHORIZ) maximized = ((hint->attrib & - ATTRIB_MAXHORIZ) ? 3 : 0); + ATTRIB_MAXHORIZ) ? MAX_HORZ : MAX_NONE); if (hint->flags & ATTRIB_OMNIPRESENT) stuck = (hint->attrib & @@ -1244,32 +1241,47 @@ void FluxboxWindow::maximize() { moveResize(left_x, max_top, max_width - left_x - 2*frame().window().borderWidth(), screen().maxBottom(head) - max_top - 2*frame().window().borderWidth()); + maximized = MAX_FULL; } else { // demaximize, restore to old values moveResize(m_old_pos_x, m_old_pos_y, m_old_width, m_old_height); + maximized = MAX_NONE; } - // toggle maximize - maximized = !maximized; -} +} +/** + * Maximize window horizontal + */ void FluxboxWindow::maximizeHorizontal() { - int head = screen().getHead(frame().window()); - unsigned int left_x = screen().maxLeft(head); - unsigned int max_width = screen().maxRight(head); - moveResize(left_x, frame().y(), - max_width - left_x - 2*frame().window().borderWidth(), frame().height()); - + if (! (maximized & MAX_HORZ) ) { + const int head = screen().getHead(frame().window()); + const unsigned int left_x = screen().maxLeft(head); + const unsigned int max_width = screen().maxRight(head); + m_old_width = frame().width(); + m_old_pos_x = frame().x(); + moveResize(left_x, frame().y(), max_width - left_x, frame().height()); + maximized |= MAX_HORZ; + } else { + moveResize(m_old_pos_x, frame().y(), m_old_width, frame().height()); + maximized &= ~MAX_HORZ; + } } /** - Maximize window horizontal + * Maximize window vertical */ void FluxboxWindow::maximizeVertical() { - int head = screen().getHead(frame().window()); - unsigned int max_top = screen().maxTop(head); - moveResize(frame().x(), max_top, - frame().width(), - screen().maxBottom(head) - max_top - 2*frame().window().borderWidth()); + if (! (maximized & MAX_VERT) ) { + const int head = screen().getHead(frame().window()); + const unsigned int max_top = screen().maxTop(head); + m_old_height = frame().height(); + m_old_pos_y = frame().y(); + moveResize(frame().x(), max_top, frame().width(), screen().maxBottom(head) - max_top); + maximized |= MAX_VERT; + } else { + moveResize(frame().x(), m_old_pos_y, frame().width(), m_old_height); + maximized &= ~MAX_VERT; + } } @@ -1753,10 +1765,10 @@ void FluxboxWindow::restoreAttributes() { (m_blackbox_attrib.flags & ATTRIB_MAXVERT)) { int x = m_blackbox_attrib.premax_x, y = m_blackbox_attrib.premax_y; unsigned int w = m_blackbox_attrib.premax_w, h = m_blackbox_attrib.premax_h; - maximized = false; + maximized = MAX_NONE; if ((m_blackbox_attrib.flags & ATTRIB_MAXHORIZ) && (m_blackbox_attrib.flags & ATTRIB_MAXVERT)) - maximized = true; + maximized = MAX_FULL; else if (m_blackbox_attrib.flags & ATTRIB_MAXVERT) maximizeVertical(); else if (m_blackbox_attrib.flags & ATTRIB_MAXHORIZ) diff --git a/src/Window.hh b/src/Window.hh index d7a6769..a7ef327 100644 --- a/src/Window.hh +++ b/src/Window.hh @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Window.hh,v 1.81 2003/06/24 14:57:06 fluxgen Exp $ +// $Id: Window.hh,v 1.82 2003/06/25 13:37:06 fluxgen Exp $ #ifndef WINDOW_HH #define WINDOW_HH @@ -103,6 +103,35 @@ public: ATTRIB_DECORATION = 0x40 }; + /** + * Types of maximization + */ + enum MaximizeMode { + MAX_NONE = 0, ///< normal state + MAX_HORZ = 1, ///< maximize horizontal + MAX_VERT = 2, ///< maximize vertical + MAX_FULL = 3 ///< maximize full + }; + /** + This enumeration represents individual decoration + attributes, they can be OR-d together to get a mask. + Useful for saving. + */ + enum DecorationMask { + DECORM_TITLEBAR = (1<<0), + DECORM_HANDLE = (1<<1), + DECORM_BORDER = (1<<2), + DECORM_ICONIFY = (1<<3), + DECORM_MAXIMIZE = (1<<4), + DECORM_CLOSE = (1<<5), + DECORM_MENU = (1<<6), + DECORM_STICKY = (1<<7), + DECORM_SHADE = (1<<8), + DECORM_TAB = (1<<9), + DECORM_ENABLED = (1<<10), + DECORM_LAST = (1<<11) // useful for getting "All" + }; + typedef struct _blackbox_hints { unsigned long flags, attrib, workspace, stack; int decoration; @@ -212,25 +241,6 @@ public: void applyDecorations(); void toggleDecoration(); - /** - This enumeration represents individual decoration - attributes, they can be OR-d together to get a mask. - Useful for saving. - */ - enum DecorationMask { - DECORM_TITLEBAR = (1<<0), - DECORM_HANDLE = (1<<1), - DECORM_BORDER = (1<<2), - DECORM_ICONIFY = (1<<3), - DECORM_MAXIMIZE = (1<<4), - DECORM_CLOSE = (1<<5), - DECORM_MENU = (1<<6), - DECORM_STICKY = (1<<7), - DECORM_SHADE = (1<<8), - DECORM_TAB = (1<<9), - DECORM_ENABLED = (1<<10), - DECORM_LAST = (1<<11) // useful for getting "All" - }; void setStrut(Strut *strut); void clearStrut(); @@ -249,7 +259,7 @@ public: bool isVisible() const; inline bool isIconic() const { return iconic; } inline bool isShaded() const { return shaded; } - inline bool isMaximized() const { return maximized; } + inline bool isMaximized() const { return maximized == MAX_FULL; } inline bool isIconifiable() const { return functions.iconify; } inline bool isMaximizable() const { return functions.maximize; } inline bool isResizable() const { return functions.resize; } @@ -382,9 +392,11 @@ private: WinSubject m_hintsig, m_statesig, m_layersig, m_workspacesig, m_diesig; // Window states - bool moving, resizing, shaded, maximized, iconic, + bool moving, resizing, shaded, iconic, focused, stuck, m_managed; + int maximized; + WinClient *m_attaching_tab; BScreen &m_screen; /// screen on which this window exist -- cgit v0.11.2