From 1b48b749b9a376c883ff4cc2ca3e807ac85cf21f Mon Sep 17 00:00:00 2001 From: Mark Tiefenbruck Date: Sun, 23 Dec 2007 13:28:08 -0800 Subject: make FbWinFrame aware of the decoration state --- src/FbWinFrame.cc | 1 + src/FbWinFrame.hh | 30 +++++++++++++++++++++ src/Remember.cc | 22 ++++++++-------- src/Window.cc | 79 ++++++++++++++++++++++++++++--------------------------- src/Window.hh | 28 -------------------- 5 files changed, 82 insertions(+), 78 deletions(-) diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc index f710416..266ddea 100644 --- a/src/FbWinFrame.cc +++ b/src/FbWinFrame.cc @@ -81,6 +81,7 @@ FbWinFrame::FbWinFrame(BScreen &screen, FbWinFrameTheme &theme, FbTk::ImageContr ButtonMotionMask | ExposureMask | EnterWindowMask | LeaveWindowMask), m_bevel(1), + m_decoration_mask(DECOR_NORMAL), m_use_titlebar(true), m_use_tabs(true), m_use_handle(true), diff --git a/src/FbWinFrame.hh b/src/FbWinFrame.hh index 9bd29dd..5af852e 100644 --- a/src/FbWinFrame.hh +++ b/src/FbWinFrame.hh @@ -72,6 +72,34 @@ public: RIGHTBOTTOM, RIGHTTOP }; + /** + 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" + }; + + enum Decoration { + DECOR_NONE = 0, + DECOR_NORMAL = DECORM_LAST - 1, + DECOR_TINY = DECORM_TITLEBAR|DECORM_ICONIFY|DECORM_MENU|DECORM_TAB, + DECOR_TOOL = DECORM_TITLEBAR|DECORM_MENU, + DECOR_BORDER = DECORM_BORDER|DECORM_MENU, + DECOR_TAB = DECORM_BORDER|DECORM_MENU|DECORM_TAB + }; /// create a top level window FbWinFrame(BScreen &screen, FbWinFrameTheme &theme, FbTk::ImageControl &imgctrl, @@ -161,6 +189,7 @@ public: /// remove any handler for the windows void removeEventHandler(); + void setDecorationMask(unsigned int mask) { m_decoration_mask = mask; } // these return true/false for if something changed bool hideTitlebar(); bool showTitlebar(); @@ -314,6 +343,7 @@ private: typedef std::list LabelList; IconButton *m_current_label; ///< which client button is focused at the moment int m_bevel; ///< bevel between titlebar items and titlebar + unsigned int m_decoration_mask; ///< bitmask of applied decorations bool m_use_titlebar; ///< if we should use titlebar bool m_use_tabs; ///< if we should use tabs (turns them off in external mode only) bool m_use_handle; ///< if we should use handle diff --git a/src/Remember.cc b/src/Remember.cc index 2090008..a48f399 100644 --- a/src/Remember.cc +++ b/src/Remember.cc @@ -814,25 +814,25 @@ void Remember::save() { apps_file << " [Deco]\t{NONE}" << endl; break; case (0xffffffff): - case (FluxboxWindow::DECORM_LAST - 1): + case (FbWinFrame::DECORM_LAST - 1): apps_file << " [Deco]\t{NORMAL}" << endl; break; - case (FluxboxWindow::DECORM_TITLEBAR - | FluxboxWindow::DECORM_ICONIFY - | FluxboxWindow::DECORM_MENU): + case (FbWinFrame::DECORM_TITLEBAR + | FbWinFrame::DECORM_ICONIFY + | FbWinFrame::DECORM_MENU): apps_file << " [Deco]\t{TOOL}" << endl; break; - case (FluxboxWindow::DECORM_TITLEBAR - | FluxboxWindow::DECORM_MENU): + case (FbWinFrame::DECORM_TITLEBAR + | FbWinFrame::DECORM_MENU): apps_file << " [Deco]\t{TINY}" << endl; break; - case (FluxboxWindow::DECORM_BORDER - | FluxboxWindow::DECORM_MENU): + case (FbWinFrame::DECORM_BORDER + | FbWinFrame::DECORM_MENU): apps_file << " [Deco]\t{BORDER}" << endl; break; - case (FluxboxWindow::DECORM_BORDER - | FluxboxWindow::DECORM_MENU - | FluxboxWindow::DECORM_TAB): + case (FbWinFrame::DECORM_BORDER + | FbWinFrame::DECORM_MENU + | FbWinFrame::DECORM_TAB): apps_file << " [Deco]\t{TAB}" << endl; break; default: diff --git a/src/Window.cc b/src/Window.cc index 6806afa..54f6915 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -1516,10 +1516,10 @@ void FluxboxWindow::setFullscreen(bool flag) { frame().setUseShape(true); if (m_toggled_decos) { - if (m_old_decoration_mask & (DECORM_TITLEBAR | DECORM_TAB)) - setDecorationMask(DECOR_NONE); + if (m_old_decoration_mask & (FbWinFrame::DECORM_TITLEBAR | FbWinFrame::DECORM_TAB)) + setDecorationMask(FbWinFrame::DECOR_NONE); else - setDecorationMask(DECOR_NORMAL); + setDecorationMask(FbWinFrame::DECOR_NORMAL); } else setDecorationMask(m_old_decoration_mask); @@ -3032,6 +3032,7 @@ void FluxboxWindow::applyDecorations(bool initial) { client_move = true; } + frame().setDecorationMask(decorationMask()); frame().reconfigure(); if (client_move) Fluxbox::instance()->updateFrameExtents(*this); @@ -3051,9 +3052,9 @@ void FluxboxWindow::toggleDecoration() { if (m_toggled_decos) { m_old_decoration_mask = decorationMask(); if (decorations.titlebar | decorations.tab) - setDecorationMask(DECOR_NONE); + setDecorationMask(FbWinFrame::DECOR_NONE); else - setDecorationMask(DECOR_NORMAL); + setDecorationMask(FbWinFrame::DECOR_NORMAL); } else //revert back to old decoration setDecorationMask(m_old_decoration_mask); @@ -3062,42 +3063,42 @@ void FluxboxWindow::toggleDecoration() { unsigned int FluxboxWindow::decorationMask() const { unsigned int ret = 0; if (decorations.titlebar) - ret |= DECORM_TITLEBAR; + ret |= FbWinFrame::DECORM_TITLEBAR; if (decorations.handle) - ret |= DECORM_HANDLE; + ret |= FbWinFrame::DECORM_HANDLE; if (decorations.border) - ret |= DECORM_BORDER; + ret |= FbWinFrame::DECORM_BORDER; if (decorations.iconify) - ret |= DECORM_ICONIFY; + ret |= FbWinFrame::DECORM_ICONIFY; if (decorations.maximize) - ret |= DECORM_MAXIMIZE; + ret |= FbWinFrame::DECORM_MAXIMIZE; if (decorations.close) - ret |= DECORM_CLOSE; + ret |= FbWinFrame::DECORM_CLOSE; if (decorations.menu) - ret |= DECORM_MENU; + ret |= FbWinFrame::DECORM_MENU; if (decorations.sticky) - ret |= DECORM_STICKY; + ret |= FbWinFrame::DECORM_STICKY; if (decorations.shade) - ret |= DECORM_SHADE; + ret |= FbWinFrame::DECORM_SHADE; if (decorations.tab) - ret |= DECORM_TAB; + ret |= FbWinFrame::DECORM_TAB; if (decorations.enabled) - ret |= DECORM_ENABLED; + ret |= FbWinFrame::DECORM_ENABLED; return ret; } void FluxboxWindow::setDecorationMask(unsigned int mask, bool apply) { - decorations.titlebar = mask & DECORM_TITLEBAR; - decorations.handle = mask & DECORM_HANDLE; - decorations.border = mask & DECORM_BORDER; - decorations.iconify = mask & DECORM_ICONIFY; - decorations.maximize = mask & DECORM_MAXIMIZE; - decorations.close = mask & DECORM_CLOSE; - decorations.menu = mask & DECORM_MENU; - decorations.sticky = mask & DECORM_STICKY; - decorations.shade = mask & DECORM_SHADE; - decorations.tab = mask & DECORM_TAB; - decorations.enabled = mask & DECORM_ENABLED; + decorations.titlebar = mask & FbWinFrame::DECORM_TITLEBAR; + decorations.handle = mask & FbWinFrame::DECORM_HANDLE; + decorations.border = mask & FbWinFrame::DECORM_BORDER; + decorations.iconify = mask & FbWinFrame::DECORM_ICONIFY; + decorations.maximize = mask & FbWinFrame::DECORM_MAXIMIZE; + decorations.close = mask & FbWinFrame::DECORM_CLOSE; + decorations.menu = mask & FbWinFrame::DECORM_MENU; + decorations.sticky = mask & FbWinFrame::DECORM_STICKY; + decorations.shade = mask & FbWinFrame::DECORM_SHADE; + decorations.tab = mask & FbWinFrame::DECORM_TAB; + decorations.enabled = mask & FbWinFrame::DECORM_ENABLED; // we don't want to do this during initialization if (apply) applyDecorations(); @@ -3268,7 +3269,7 @@ void FluxboxWindow::doSnapping(int &orig_left, int &orig_top) { // we only care about the left/top etc that includes borders int borderW = 0; - if (decorationMask() & (DECORM_BORDER|DECORM_HANDLE)) + if (decorationMask() & (FbWinFrame::DECORM_BORDER|FbWinFrame::DECORM_HANDLE)) borderW = frame().window().borderWidth(); int top = orig_top; // orig include the borders @@ -3340,7 +3341,7 @@ void FluxboxWindow::doSnapping(int &orig_left, int &orig_top) { if ((*it) == this) continue; // skip myself - bw = (*it)->decorationMask() & (DECORM_BORDER|DECORM_HANDLE) ? + bw = (*it)->decorationMask() & (FbWinFrame::DECORM_BORDER|FbWinFrame::DECORM_HANDLE) ? (*it)->frame().window().borderWidth() : 0; snapToWindow(dx, dy, left, right, top, bottom, @@ -4106,17 +4107,17 @@ void FluxboxWindow::associateClient(WinClient &client) { int FluxboxWindow::getDecoMaskFromString(const string &str_label) { if (strcasecmp(str_label.c_str(), "NONE") == 0) - return DECOR_NONE; + return FbWinFrame::DECOR_NONE; if (strcasecmp(str_label.c_str(), "NORMAL") == 0) - return DECOR_NORMAL; + return FbWinFrame::DECOR_NORMAL; if (strcasecmp(str_label.c_str(), "TINY") == 0) - return DECOR_TINY; + return FbWinFrame::DECOR_TINY; if (strcasecmp(str_label.c_str(), "TOOL") == 0) - return DECOR_TOOL; + return FbWinFrame::DECOR_TOOL; if (strcasecmp(str_label.c_str(), "BORDER") == 0) - return DECOR_BORDER; + return FbWinFrame::DECOR_BORDER; if (strcasecmp(str_label.c_str(), "TAB") == 0) - return DECOR_TAB; + return FbWinFrame::DECOR_TAB; int mask = -1; if (str_label.size() > 1 && str_label[0] == '0' && str_label[1] == 'x' || str_label.size() > 0 && isdigit(str_label[0])) @@ -4158,7 +4159,7 @@ void FluxboxWindow::setWindowType(Focusable::WindowType type) { */ setFocusHidden(true); setIconHidden(true); - setDecorationMask(DECOR_NONE); + setDecorationMask(FbWinFrame::DECOR_NONE); moveToLayer(::Layer::DOCK); break; case Focusable::TYPE_DESKTOP: @@ -4171,7 +4172,7 @@ void FluxboxWindow::setWindowType(Focusable::WindowType type) { setFocusHidden(true); setIconHidden(true); moveToLayer(::Layer::DESKTOP); - setDecorationMask(DECOR_NONE); + setDecorationMask(FbWinFrame::DECOR_NONE); setTabable(false); setMovable(false); setResizable(false); @@ -4183,7 +4184,7 @@ void FluxboxWindow::setWindowType(Focusable::WindowType type) { * window is a splash screen displayed as an application * is starting up. */ - setDecorationMask(DECOR_NONE); + setDecorationMask(FbWinFrame::DECOR_NONE); setFocusHidden(true); setIconHidden(true); setMovable(false); @@ -4200,7 +4201,7 @@ void FluxboxWindow::setWindowType(Focusable::WindowType type) { * application). Windows of this type may set the * WM_TRANSIENT_FOR hint indicating the main application window. */ - setDecorationMask(DECOR_TOOL); + setDecorationMask(FbWinFrame::DECOR_TOOL); setIconHidden(true); moveToLayer(::Layer::ABOVE_DOCK); break; diff --git a/src/Window.hh b/src/Window.hh index eeb7ae1..1d54d18 100644 --- a/src/Window.hh +++ b/src/Window.hh @@ -110,34 +110,6 @@ public: 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" - }; - - enum Decoration { - DECOR_NONE = 0, - DECOR_NORMAL = DECORM_LAST - 1, - DECOR_TINY = DECORM_TITLEBAR|DECORM_ICONIFY|DECORM_MENU|DECORM_TAB, - DECOR_TOOL = DECORM_TITLEBAR|DECORM_MENU, - DECOR_BORDER = DECORM_BORDER|DECORM_MENU, - DECOR_TAB = DECORM_BORDER|DECORM_MENU|DECORM_TAB - }; /// Different resize modes when resizing a window enum ResizeModel { -- cgit v0.11.2