make FbWinFrame aware of the decoration state

This commit is contained in:
Mark Tiefenbruck 2007-12-23 13:28:08 -08:00
parent 0676161673
commit 1b48b749b9
5 changed files with 82 additions and 78 deletions

View file

@ -81,6 +81,7 @@ FbWinFrame::FbWinFrame(BScreen &screen, FbWinFrameTheme &theme, FbTk::ImageContr
ButtonMotionMask | ExposureMask | ButtonMotionMask | ExposureMask |
EnterWindowMask | LeaveWindowMask), EnterWindowMask | LeaveWindowMask),
m_bevel(1), m_bevel(1),
m_decoration_mask(DECOR_NORMAL),
m_use_titlebar(true), m_use_titlebar(true),
m_use_tabs(true), m_use_tabs(true),
m_use_handle(true), m_use_handle(true),

View file

@ -72,6 +72,34 @@ public:
RIGHTBOTTOM, RIGHTTOP 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 /// create a top level window
FbWinFrame(BScreen &screen, FbWinFrameTheme &theme, FbTk::ImageControl &imgctrl, FbWinFrame(BScreen &screen, FbWinFrameTheme &theme, FbTk::ImageControl &imgctrl,
@ -161,6 +189,7 @@ public:
/// remove any handler for the windows /// remove any handler for the windows
void removeEventHandler(); void removeEventHandler();
void setDecorationMask(unsigned int mask) { m_decoration_mask = mask; }
// these return true/false for if something changed // these return true/false for if something changed
bool hideTitlebar(); bool hideTitlebar();
bool showTitlebar(); bool showTitlebar();
@ -314,6 +343,7 @@ private:
typedef std::list<FbTk::TextButton *> LabelList; typedef std::list<FbTk::TextButton *> LabelList;
IconButton *m_current_label; ///< which client button is focused at the moment IconButton *m_current_label; ///< which client button is focused at the moment
int m_bevel; ///< bevel between titlebar items and titlebar 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_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_tabs; ///< if we should use tabs (turns them off in external mode only)
bool m_use_handle; ///< if we should use handle bool m_use_handle; ///< if we should use handle

View file

@ -814,25 +814,25 @@ void Remember::save() {
apps_file << " [Deco]\t{NONE}" << endl; apps_file << " [Deco]\t{NONE}" << endl;
break; break;
case (0xffffffff): case (0xffffffff):
case (FluxboxWindow::DECORM_LAST - 1): case (FbWinFrame::DECORM_LAST - 1):
apps_file << " [Deco]\t{NORMAL}" << endl; apps_file << " [Deco]\t{NORMAL}" << endl;
break; break;
case (FluxboxWindow::DECORM_TITLEBAR case (FbWinFrame::DECORM_TITLEBAR
| FluxboxWindow::DECORM_ICONIFY | FbWinFrame::DECORM_ICONIFY
| FluxboxWindow::DECORM_MENU): | FbWinFrame::DECORM_MENU):
apps_file << " [Deco]\t{TOOL}" << endl; apps_file << " [Deco]\t{TOOL}" << endl;
break; break;
case (FluxboxWindow::DECORM_TITLEBAR case (FbWinFrame::DECORM_TITLEBAR
| FluxboxWindow::DECORM_MENU): | FbWinFrame::DECORM_MENU):
apps_file << " [Deco]\t{TINY}" << endl; apps_file << " [Deco]\t{TINY}" << endl;
break; break;
case (FluxboxWindow::DECORM_BORDER case (FbWinFrame::DECORM_BORDER
| FluxboxWindow::DECORM_MENU): | FbWinFrame::DECORM_MENU):
apps_file << " [Deco]\t{BORDER}" << endl; apps_file << " [Deco]\t{BORDER}" << endl;
break; break;
case (FluxboxWindow::DECORM_BORDER case (FbWinFrame::DECORM_BORDER
| FluxboxWindow::DECORM_MENU | FbWinFrame::DECORM_MENU
| FluxboxWindow::DECORM_TAB): | FbWinFrame::DECORM_TAB):
apps_file << " [Deco]\t{TAB}" << endl; apps_file << " [Deco]\t{TAB}" << endl;
break; break;
default: default:

View file

@ -1516,10 +1516,10 @@ void FluxboxWindow::setFullscreen(bool flag) {
frame().setUseShape(true); frame().setUseShape(true);
if (m_toggled_decos) { if (m_toggled_decos) {
if (m_old_decoration_mask & (DECORM_TITLEBAR | DECORM_TAB)) if (m_old_decoration_mask & (FbWinFrame::DECORM_TITLEBAR | FbWinFrame::DECORM_TAB))
setDecorationMask(DECOR_NONE); setDecorationMask(FbWinFrame::DECOR_NONE);
else else
setDecorationMask(DECOR_NORMAL); setDecorationMask(FbWinFrame::DECOR_NORMAL);
} else } else
setDecorationMask(m_old_decoration_mask); setDecorationMask(m_old_decoration_mask);
@ -3032,6 +3032,7 @@ void FluxboxWindow::applyDecorations(bool initial) {
client_move = true; client_move = true;
} }
frame().setDecorationMask(decorationMask());
frame().reconfigure(); frame().reconfigure();
if (client_move) if (client_move)
Fluxbox::instance()->updateFrameExtents(*this); Fluxbox::instance()->updateFrameExtents(*this);
@ -3051,9 +3052,9 @@ void FluxboxWindow::toggleDecoration() {
if (m_toggled_decos) { if (m_toggled_decos) {
m_old_decoration_mask = decorationMask(); m_old_decoration_mask = decorationMask();
if (decorations.titlebar | decorations.tab) if (decorations.titlebar | decorations.tab)
setDecorationMask(DECOR_NONE); setDecorationMask(FbWinFrame::DECOR_NONE);
else else
setDecorationMask(DECOR_NORMAL); setDecorationMask(FbWinFrame::DECOR_NORMAL);
} else //revert back to old decoration } else //revert back to old decoration
setDecorationMask(m_old_decoration_mask); setDecorationMask(m_old_decoration_mask);
@ -3062,42 +3063,42 @@ void FluxboxWindow::toggleDecoration() {
unsigned int FluxboxWindow::decorationMask() const { unsigned int FluxboxWindow::decorationMask() const {
unsigned int ret = 0; unsigned int ret = 0;
if (decorations.titlebar) if (decorations.titlebar)
ret |= DECORM_TITLEBAR; ret |= FbWinFrame::DECORM_TITLEBAR;
if (decorations.handle) if (decorations.handle)
ret |= DECORM_HANDLE; ret |= FbWinFrame::DECORM_HANDLE;
if (decorations.border) if (decorations.border)
ret |= DECORM_BORDER; ret |= FbWinFrame::DECORM_BORDER;
if (decorations.iconify) if (decorations.iconify)
ret |= DECORM_ICONIFY; ret |= FbWinFrame::DECORM_ICONIFY;
if (decorations.maximize) if (decorations.maximize)
ret |= DECORM_MAXIMIZE; ret |= FbWinFrame::DECORM_MAXIMIZE;
if (decorations.close) if (decorations.close)
ret |= DECORM_CLOSE; ret |= FbWinFrame::DECORM_CLOSE;
if (decorations.menu) if (decorations.menu)
ret |= DECORM_MENU; ret |= FbWinFrame::DECORM_MENU;
if (decorations.sticky) if (decorations.sticky)
ret |= DECORM_STICKY; ret |= FbWinFrame::DECORM_STICKY;
if (decorations.shade) if (decorations.shade)
ret |= DECORM_SHADE; ret |= FbWinFrame::DECORM_SHADE;
if (decorations.tab) if (decorations.tab)
ret |= DECORM_TAB; ret |= FbWinFrame::DECORM_TAB;
if (decorations.enabled) if (decorations.enabled)
ret |= DECORM_ENABLED; ret |= FbWinFrame::DECORM_ENABLED;
return ret; return ret;
} }
void FluxboxWindow::setDecorationMask(unsigned int mask, bool apply) { void FluxboxWindow::setDecorationMask(unsigned int mask, bool apply) {
decorations.titlebar = mask & DECORM_TITLEBAR; decorations.titlebar = mask & FbWinFrame::DECORM_TITLEBAR;
decorations.handle = mask & DECORM_HANDLE; decorations.handle = mask & FbWinFrame::DECORM_HANDLE;
decorations.border = mask & DECORM_BORDER; decorations.border = mask & FbWinFrame::DECORM_BORDER;
decorations.iconify = mask & DECORM_ICONIFY; decorations.iconify = mask & FbWinFrame::DECORM_ICONIFY;
decorations.maximize = mask & DECORM_MAXIMIZE; decorations.maximize = mask & FbWinFrame::DECORM_MAXIMIZE;
decorations.close = mask & DECORM_CLOSE; decorations.close = mask & FbWinFrame::DECORM_CLOSE;
decorations.menu = mask & DECORM_MENU; decorations.menu = mask & FbWinFrame::DECORM_MENU;
decorations.sticky = mask & DECORM_STICKY; decorations.sticky = mask & FbWinFrame::DECORM_STICKY;
decorations.shade = mask & DECORM_SHADE; decorations.shade = mask & FbWinFrame::DECORM_SHADE;
decorations.tab = mask & DECORM_TAB; decorations.tab = mask & FbWinFrame::DECORM_TAB;
decorations.enabled = mask & DECORM_ENABLED; decorations.enabled = mask & FbWinFrame::DECORM_ENABLED;
// we don't want to do this during initialization // we don't want to do this during initialization
if (apply) if (apply)
applyDecorations(); 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 // we only care about the left/top etc that includes borders
int borderW = 0; int borderW = 0;
if (decorationMask() & (DECORM_BORDER|DECORM_HANDLE)) if (decorationMask() & (FbWinFrame::DECORM_BORDER|FbWinFrame::DECORM_HANDLE))
borderW = frame().window().borderWidth(); borderW = frame().window().borderWidth();
int top = orig_top; // orig include the borders int top = orig_top; // orig include the borders
@ -3340,7 +3341,7 @@ void FluxboxWindow::doSnapping(int &orig_left, int &orig_top) {
if ((*it) == this) if ((*it) == this)
continue; // skip myself continue; // skip myself
bw = (*it)->decorationMask() & (DECORM_BORDER|DECORM_HANDLE) ? bw = (*it)->decorationMask() & (FbWinFrame::DECORM_BORDER|FbWinFrame::DECORM_HANDLE) ?
(*it)->frame().window().borderWidth() : 0; (*it)->frame().window().borderWidth() : 0;
snapToWindow(dx, dy, left, right, top, bottom, snapToWindow(dx, dy, left, right, top, bottom,
@ -4106,17 +4107,17 @@ void FluxboxWindow::associateClient(WinClient &client) {
int FluxboxWindow::getDecoMaskFromString(const string &str_label) { int FluxboxWindow::getDecoMaskFromString(const string &str_label) {
if (strcasecmp(str_label.c_str(), "NONE") == 0) if (strcasecmp(str_label.c_str(), "NONE") == 0)
return DECOR_NONE; return FbWinFrame::DECOR_NONE;
if (strcasecmp(str_label.c_str(), "NORMAL") == 0) if (strcasecmp(str_label.c_str(), "NORMAL") == 0)
return DECOR_NORMAL; return FbWinFrame::DECOR_NORMAL;
if (strcasecmp(str_label.c_str(), "TINY") == 0) if (strcasecmp(str_label.c_str(), "TINY") == 0)
return DECOR_TINY; return FbWinFrame::DECOR_TINY;
if (strcasecmp(str_label.c_str(), "TOOL") == 0) if (strcasecmp(str_label.c_str(), "TOOL") == 0)
return DECOR_TOOL; return FbWinFrame::DECOR_TOOL;
if (strcasecmp(str_label.c_str(), "BORDER") == 0) if (strcasecmp(str_label.c_str(), "BORDER") == 0)
return DECOR_BORDER; return FbWinFrame::DECOR_BORDER;
if (strcasecmp(str_label.c_str(), "TAB") == 0) if (strcasecmp(str_label.c_str(), "TAB") == 0)
return DECOR_TAB; return FbWinFrame::DECOR_TAB;
int mask = -1; int mask = -1;
if (str_label.size() > 1 && str_label[0] == '0' && str_label[1] == 'x' || if (str_label.size() > 1 && str_label[0] == '0' && str_label[1] == 'x' ||
str_label.size() > 0 && isdigit(str_label[0])) str_label.size() > 0 && isdigit(str_label[0]))
@ -4158,7 +4159,7 @@ void FluxboxWindow::setWindowType(Focusable::WindowType type) {
*/ */
setFocusHidden(true); setFocusHidden(true);
setIconHidden(true); setIconHidden(true);
setDecorationMask(DECOR_NONE); setDecorationMask(FbWinFrame::DECOR_NONE);
moveToLayer(::Layer::DOCK); moveToLayer(::Layer::DOCK);
break; break;
case Focusable::TYPE_DESKTOP: case Focusable::TYPE_DESKTOP:
@ -4171,7 +4172,7 @@ void FluxboxWindow::setWindowType(Focusable::WindowType type) {
setFocusHidden(true); setFocusHidden(true);
setIconHidden(true); setIconHidden(true);
moveToLayer(::Layer::DESKTOP); moveToLayer(::Layer::DESKTOP);
setDecorationMask(DECOR_NONE); setDecorationMask(FbWinFrame::DECOR_NONE);
setTabable(false); setTabable(false);
setMovable(false); setMovable(false);
setResizable(false); setResizable(false);
@ -4183,7 +4184,7 @@ void FluxboxWindow::setWindowType(Focusable::WindowType type) {
* window is a splash screen displayed as an application * window is a splash screen displayed as an application
* is starting up. * is starting up.
*/ */
setDecorationMask(DECOR_NONE); setDecorationMask(FbWinFrame::DECOR_NONE);
setFocusHidden(true); setFocusHidden(true);
setIconHidden(true); setIconHidden(true);
setMovable(false); setMovable(false);
@ -4200,7 +4201,7 @@ void FluxboxWindow::setWindowType(Focusable::WindowType type) {
* application). Windows of this type may set the * application). Windows of this type may set the
* WM_TRANSIENT_FOR hint indicating the main application window. * WM_TRANSIENT_FOR hint indicating the main application window.
*/ */
setDecorationMask(DECOR_TOOL); setDecorationMask(FbWinFrame::DECOR_TOOL);
setIconHidden(true); setIconHidden(true);
moveToLayer(::Layer::ABOVE_DOCK); moveToLayer(::Layer::ABOVE_DOCK);
break; break;

View file

@ -110,34 +110,6 @@ public:
MAX_VERT = 2, ///< maximize vertical MAX_VERT = 2, ///< maximize vertical
MAX_FULL = 3 ///< maximize full 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 /// Different resize modes when resizing a window
enum ResizeModel { enum ResizeModel {