allow various combinations of shaded, maximized, and fullscreen states

This commit is contained in:
Mark Tiefenbruck 2008-08-22 16:29:09 -07:00
parent c37a91e150
commit e3fb16c993
3 changed files with 41 additions and 50 deletions

View file

@ -88,7 +88,6 @@ FbWinFrame::FbWinFrame(BScreen &screen,
m_active_orig_client_bw(0), m_active_orig_client_bw(0),
m_need_render(true), m_need_render(true),
m_button_size(1), m_button_size(1),
m_height_before_shade(1),
m_focused_alpha(AlphaAcc(*theme.focusedTheme(), &FbWinFrameTheme::alpha)), m_focused_alpha(AlphaAcc(*theme.focusedTheme(), &FbWinFrameTheme::alpha)),
m_unfocused_alpha(AlphaAcc(*theme.unfocusedTheme(), &FbWinFrameTheme::alpha)), m_unfocused_alpha(AlphaAcc(*theme.unfocusedTheme(), &FbWinFrameTheme::alpha)),
m_shape(m_window, theme->shapePlace()) { m_shape(m_window, theme->shapePlace()) {
@ -195,21 +194,14 @@ void FbWinFrame::show() {
Toggle shade state, and resize window Toggle shade state, and resize window
*/ */
void FbWinFrame::shade() { void FbWinFrame::shade() {
if (!m_use_titlebar) if (!(m_state.deco_mask & DECORM_TITLEBAR))
return; return;
// toggle shade // toggle shade
if (!m_state.shaded)
saveGeometry();
m_state.shaded = !m_state.shaded; m_state.shaded = !m_state.shaded;
if (m_state.shaded) { // i.e. should be shaded now applyState();
m_height_before_shade = m_window.height();
m_window.resize(m_window.width(), m_titlebar.height());
alignTabs();
// need to update our shape
m_shape.update();
} else { // should be unshaded
m_window.resize(m_window.width(), m_height_before_shade);
reconfigure();
}
} }
@ -246,8 +238,8 @@ void FbWinFrame::moveResize(int x, int y, unsigned int width, unsigned int heigh
if (move && x == window().x() && y == window().y()) if (move && x == window().x() && y == window().y())
move = false; move = false;
if (resize && (m_state.shaded || (width == FbWinFrame::width() && if (resize && width == FbWinFrame::width() &&
height == FbWinFrame::height()))) height == FbWinFrame::height())
resize = false; resize = false;
if (!move && !resize) if (!move && !resize)
@ -544,44 +536,52 @@ void FbWinFrame::setMaximized(int value) {
} }
void FbWinFrame::saveGeometry() { void FbWinFrame::saveGeometry() {
if (m_state.fullscreen || m_state.maximized) if (m_state.fullscreen || m_state.maximized == MAX_FULL)
return; return;
m_state.x = x(); m_state.x = x();
m_state.y = y(); m_state.y = y();
if (!(m_state.maximized & MAX_HORZ))
m_state.width = width(); m_state.width = width();
if (!m_state.shaded && !(m_state.maximized & MAX_VERT))
m_state.height = height(); m_state.height = height();
} }
void FbWinFrame::applyState() { void FbWinFrame::applyState() {
applyDecorations(); applyDecorations();
if (m_state.fullscreen) {
const int head = m_screen.getHead(window());
moveResize(m_screen.getHeadX(head), m_screen.getHeadY(head),
m_screen.getHeadWidth(head), m_screen.getHeadHeight(head));
} else if (m_state.maximized) {
const int head = m_screen.getHead(window()); const int head = m_screen.getHead(window());
int new_x = m_state.x, new_y = m_state.y; int new_x = m_state.x, new_y = m_state.y;
unsigned int new_w = m_state.width, new_h = m_state.height; unsigned int new_w = m_state.width, new_h = m_state.height;
if (m_state.maximized & MAX_VERT) { if (m_state.maximized & MAX_VERT) {
new_y = m_screen.maxTop(head); new_y = m_screen.maxTop(head);
new_h = m_screen.maxBottom(head) - new_y - 2*window().borderWidth(); new_h = m_screen.maxBottom(head) - new_y - 2*window().borderWidth();
if (!m_screen.getMaxOverTabs()) {
new_y += yOffset();
new_h -= heightOffset();
}
} }
if (m_state.maximized & MAX_HORZ) { if (m_state.maximized & MAX_HORZ) {
new_x = m_screen.maxLeft(head); new_x = m_screen.maxLeft(head);
new_w = m_screen.maxRight(head) - new_x - 2*window().borderWidth(); new_w = m_screen.maxRight(head) - new_x - 2*window().borderWidth();
}
if (!m_screen.getMaxOverTabs()) { if (!m_screen.getMaxOverTabs()) {
new_y += yOffset();
new_h -= heightOffset();
new_x += xOffset(); new_x += xOffset();
new_w -= widthOffset(); new_w -= widthOffset();
} }
moveResize(new_x, new_y, new_w, new_h); }
} else
moveResize(m_state.x, m_state.y, m_state.width, m_state.height);
if (m_state.shaded)
new_h = m_titlebar.height();
if (m_state.fullscreen) {
new_x = m_screen.getHeadX(head);
new_y = m_screen.getHeadY(head);
new_w = m_screen.getHeadWidth(head);
new_h = m_screen.getHeadHeight(head);
}
moveResize(new_x, new_y, new_w, new_h);
frameExtentSig().notify(); frameExtentSig().notify();
} }
@ -973,7 +973,7 @@ void FbWinFrame::reconfigure() {
} }
// leave client+grips alone if we're shaded (it'll get fixed when we unshade) // leave client+grips alone if we're shaded (it'll get fixed when we unshade)
if (!m_state.shaded) { if (!m_state.shaded || m_state.fullscreen) {
int client_top = 0; int client_top = 0;
int client_height = m_window.height(); int client_height = m_window.height();
if (m_use_titlebar) { if (m_use_titlebar) {
@ -1369,7 +1369,6 @@ void FbWinFrame::init() {
m_button_size = 26; m_button_size = 26;
m_label.setBorderWidth(0); m_label.setBorderWidth(0);
m_state.shaded = false;
setTabMode(NOTSET); setTabMode(NOTSET);
@ -1516,7 +1515,8 @@ bool FbWinFrame::useTitlebar() const {
} }
bool FbWinFrame::useHandle() const { bool FbWinFrame::useHandle() const {
return !m_state.fullscreen && m_state.deco_mask & DECORM_HANDLE; return !m_state.fullscreen && !m_state.shaded &&
m_state.deco_mask & DECORM_HANDLE;
} }
int FbWinFrame::getShape() const { int FbWinFrame::getShape() const {
@ -1734,10 +1734,8 @@ unsigned int FbWinFrame::normalWidth() const {
} }
unsigned int FbWinFrame::normalHeight() const { unsigned int FbWinFrame::normalHeight() const {
if ((m_state.maximized & MAX_VERT) || m_state.fullscreen) if ((m_state.maximized & MAX_VERT) || m_state.fullscreen || m_state.shaded)
return m_state.height; return m_state.height;
if (m_state.shaded)
return m_height_before_shade;
return height(); return height();
} }

View file

@ -467,7 +467,6 @@ private:
bool m_need_render; bool m_need_render;
int m_button_size; ///< size for all titlebar buttons int m_button_size; ///< size for all titlebar buttons
unsigned int m_height_before_shade; ///< height before shade, so we can restore it when we unshade
/// alpha values /// alpha values
typedef FbTk::ConstObjectAccessor<unsigned char, FbWinFrameTheme> AlphaAcc; typedef FbTk::ConstObjectAccessor<unsigned char, FbWinFrameTheme> AlphaAcc;
FbTk::DefaultValue<unsigned char, AlphaAcc> m_focused_alpha; FbTk::DefaultValue<unsigned char, AlphaAcc> m_focused_alpha;

View file

@ -1465,9 +1465,6 @@ void FluxboxWindow::setFullscreen(bool flag) {
if (flag && !isFullscreen()) { if (flag && !isFullscreen()) {
if (isShaded())
shade();
m_old_layernum = layerNum(); m_old_layernum = layerNum();
fullscreen = true; fullscreen = true;
frame().setFullscreen(true); frame().setFullscreen(true);
@ -1535,9 +1532,6 @@ void FluxboxWindow::setMaximizedState(int type) {
return; return;
} }
if (isShaded())
shade();
if (isResizing()) if (isResizing())
stopResizing(); stopResizing();
@ -1605,7 +1599,7 @@ void FluxboxWindow::shade() {
frame().shade(); frame().shade();
shaded = !shaded; shaded = !shaded;
stateSig().notify();
// TODO: this should set IconicState, but then we can't focus the window // TODO: this should set IconicState, but then we can't focus the window
} }