aboutsummaryrefslogtreecommitdiff
path: root/src/FbWinFrame.cc
diff options
context:
space:
mode:
authorMark Tiefenbruck <mark@fluxbox.org>2008-08-15 11:36:02 (GMT)
committerMark Tiefenbruck <mark@fluxbox.org>2008-08-15 11:36:02 (GMT)
commit4093d2641f371bb8e80616a4c51dea9af508dac2 (patch)
treeee55897193105bfe0dca0b9dd771af7f6cf06d19 /src/FbWinFrame.cc
parentf32fdc29d28dce26f87e9f10f32e9399686766d8 (diff)
downloadfluxbox-4093d2641f371bb8e80616a4c51dea9af508dac2.zip
fluxbox-4093d2641f371bb8e80616a4c51dea9af508dac2.tar.bz2
group some window properties into a new class FbWinFrame::State
Diffstat (limited to 'src/FbWinFrame.cc')
-rw-r--r--src/FbWinFrame.cc59
1 files changed, 28 insertions, 31 deletions
diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc
index 9136d20..3a3dc86 100644
--- a/src/FbWinFrame.cc
+++ b/src/FbWinFrame.cc
@@ -78,11 +78,9 @@ FbWinFrame::FbWinFrame(BScreen &screen,
78 ButtonMotionMask | ExposureMask | 78 ButtonMotionMask | ExposureMask |
79 EnterWindowMask | LeaveWindowMask), 79 EnterWindowMask | LeaveWindowMask),
80 m_bevel(1), 80 m_bevel(1),
81 m_decoration_mask(DECOR_NORMAL),
82 m_use_titlebar(true), 81 m_use_titlebar(true),
83 m_use_tabs(true), 82 m_use_tabs(true),
84 m_use_handle(true), 83 m_use_handle(true),
85 m_focused(false),
86 m_visible(false), 84 m_visible(false),
87 m_button_pm(0), 85 m_button_pm(0),
88 m_tabmode(screen.getDefaultInternalTabs()?INTERNAL:EXTERNAL), 86 m_tabmode(screen.getDefaultInternalTabs()?INTERNAL:EXTERNAL),
@@ -91,7 +89,6 @@ FbWinFrame::FbWinFrame(BScreen &screen,
91 m_need_render(true), 89 m_need_render(true),
92 m_button_size(1), 90 m_button_size(1),
93 m_height_before_shade(1), 91 m_height_before_shade(1),
94 m_shaded(false),
95 m_focused_alpha(AlphaAcc(*theme.focusedTheme(), &FbWinFrameTheme::alpha)), 92 m_focused_alpha(AlphaAcc(*theme.focusedTheme(), &FbWinFrameTheme::alpha)),
96 m_unfocused_alpha(AlphaAcc(*theme.unfocusedTheme(), &FbWinFrameTheme::alpha)), 93 m_unfocused_alpha(AlphaAcc(*theme.unfocusedTheme(), &FbWinFrameTheme::alpha)),
97 m_shape(m_window, theme->shapePlace()), 94 m_shape(m_window, theme->shapePlace()),
@@ -203,8 +200,8 @@ void FbWinFrame::shade() {
203 return; 200 return;
204 201
205 // toggle shade 202 // toggle shade
206 m_shaded = !m_shaded; 203 m_state.shaded = !m_state.shaded;
207 if (m_shaded) { // i.e. should be shaded now 204 if (m_state.shaded) { // i.e. should be shaded now
208 m_height_before_shade = m_window.height(); 205 m_height_before_shade = m_window.height();
209 m_window.resize(m_window.width(), m_titlebar.height()); 206 m_window.resize(m_window.width(), m_titlebar.height());
210 alignTabs(); 207 alignTabs();
@@ -250,7 +247,7 @@ void FbWinFrame::moveResize(int x, int y, unsigned int width, unsigned int heigh
250 if (move && x == window().x() && y == window().y()) 247 if (move && x == window().x() && y == window().y())
251 move = false; 248 move = false;
252 249
253 if (resize && (m_shaded || width == FbWinFrame::width() && 250 if (resize && (m_state.shaded || width == FbWinFrame::width() &&
254 height == FbWinFrame::height())) 251 height == FbWinFrame::height()))
255 resize = false; 252 resize = false;
256 253
@@ -412,7 +409,7 @@ void FbWinFrame::alignTabs() {
412 409
413void FbWinFrame::notifyMoved(bool clear) { 410void FbWinFrame::notifyMoved(bool clear) {
414 // not important if no alpha... 411 // not important if no alpha...
415 unsigned char alpha = getAlpha(m_focused); 412 unsigned char alpha = getAlpha(m_state.focused);
416 if (alpha == 255) 413 if (alpha == 255)
417 return; 414 return;
418 415
@@ -469,14 +466,14 @@ void FbWinFrame::clearAll() {
469} 466}
470 467
471void FbWinFrame::setFocus(bool newvalue) { 468void FbWinFrame::setFocus(bool newvalue) {
472 if (m_focused == newvalue) 469 if (m_state.focused == newvalue)
473 return; 470 return;
474 471
475 m_focused = newvalue; 472 m_state.focused = newvalue;
476 473
477 if (FbTk::Transparent::haveRender() && 474 if (FbTk::Transparent::haveRender() &&
478 getAlpha(true) != getAlpha(false)) { // different alpha for focused and unfocused 475 getAlpha(true) != getAlpha(false)) { // different alpha for focused and unfocused
479 unsigned char alpha = getAlpha(m_focused); 476 unsigned char alpha = getAlpha(m_state.focused);
480 if (FbTk::Transparent::haveComposite()) { 477 if (FbTk::Transparent::haveComposite()) {
481 m_tab_container.setAlpha(255); 478 m_tab_container.setAlpha(255);
482 m_window.setOpaque(alpha); 479 m_window.setOpaque(alpha);
@@ -498,12 +495,12 @@ void FbWinFrame::setAlpha(bool focused, unsigned char alpha) {
498 else 495 else
499 m_unfocused_alpha = alpha; 496 m_unfocused_alpha = alpha;
500 497
501 if (m_focused == focused) 498 if (m_state.focused == focused)
502 applyAlpha(); 499 applyAlpha();
503} 500}
504 501
505void FbWinFrame::applyAlpha() { 502void FbWinFrame::applyAlpha() {
506 unsigned char alpha = getAlpha(m_focused); 503 unsigned char alpha = getAlpha(m_state.focused);
507 if (FbTk::Transparent::haveComposite()) 504 if (FbTk::Transparent::haveComposite())
508 m_window.setOpaque(alpha); 505 m_window.setOpaque(alpha);
509 else { 506 else {
@@ -845,7 +842,7 @@ void FbWinFrame::reconfigure() {
845 m_bevel = theme()->bevelWidth(); 842 m_bevel = theme()->bevelWidth();
846 setBorderWidth(); 843 setBorderWidth();
847 844
848 if (m_decoration_mask & DECORM_HANDLE && theme()->handleWidth() != 0) 845 if (m_state.deco_mask & DECORM_HANDLE && theme()->handleWidth() != 0)
849 showHandle(); 846 showHandle();
850 else 847 else
851 hideHandle(); 848 hideHandle();
@@ -889,7 +886,7 @@ void FbWinFrame::reconfigure() {
889 } 886 }
890 887
891 // leave client+grips alone if we're shaded (it'll get fixed when we unshade) 888 // leave client+grips alone if we're shaded (it'll get fixed when we unshade)
892 if (!m_shaded) { 889 if (!m_state.shaded) {
893 int client_top = 0; 890 int client_top = 0;
894 int client_height = m_window.height(); 891 int client_height = m_window.height();
895 if (m_use_titlebar) { 892 if (m_use_titlebar) {
@@ -945,7 +942,7 @@ void FbWinFrame::reconfigure() {
945 // update transparency settings 942 // update transparency settings
946 if (FbTk::Transparent::haveRender()) { 943 if (FbTk::Transparent::haveRender()) {
947 unsigned char alpha = 944 unsigned char alpha =
948 getAlpha(m_focused); 945 getAlpha(m_state.focused);
949 if (FbTk::Transparent::haveComposite()) { 946 if (FbTk::Transparent::haveComposite()) {
950 m_tab_container.setAlpha(255); 947 m_tab_container.setAlpha(255);
951 m_window.setOpaque(alpha); 948 m_window.setOpaque(alpha);
@@ -1160,7 +1157,7 @@ void FbWinFrame::applyTitlebar() {
1160 getCurrentFocusPixmap(label_pm, title_pm, 1157 getCurrentFocusPixmap(label_pm, title_pm,
1161 label_color, title_color); 1158 label_color, title_color);
1162 1159
1163 unsigned char alpha = getAlpha (m_focused); 1160 unsigned char alpha = getAlpha (m_state.focused);
1164 m_titlebar.setAlpha(alpha); 1161 m_titlebar.setAlpha(alpha);
1165 m_label.setAlpha(alpha); 1162 m_label.setAlpha(alpha);
1166 1163
@@ -1212,12 +1209,12 @@ void FbWinFrame::renderHandles() {
1212 1209
1213void FbWinFrame::applyHandles() { 1210void FbWinFrame::applyHandles() {
1214 1211
1215 unsigned char alpha = getAlpha (m_focused); 1212 unsigned char alpha = getAlpha(m_state.focused);
1216 m_handle.setAlpha(alpha); 1213 m_handle.setAlpha(alpha);
1217 m_grip_left.setAlpha(alpha); 1214 m_grip_left.setAlpha(alpha);
1218 m_grip_right.setAlpha(alpha); 1215 m_grip_right.setAlpha(alpha);
1219 1216
1220 if (m_focused) { 1217 if (m_state.focused) {
1221 1218
1222 if (m_handle_focused_pm) { 1219 if (m_handle_focused_pm) {
1223 m_handle.setBackgroundPixmap(m_handle_focused_pm); 1220 m_handle.setBackgroundPixmap(m_handle_focused_pm);
@@ -1302,7 +1299,7 @@ void FbWinFrame::init() {
1302 1299
1303 m_clientarea.setBorderWidth(0); 1300 m_clientarea.setBorderWidth(0);
1304 m_label.setBorderWidth(0); 1301 m_label.setBorderWidth(0);
1305 m_shaded = false; 1302 m_state.shaded = false;
1306 1303
1307 setTabMode(NOTSET); 1304 setTabMode(NOTSET);
1308 1305
@@ -1327,13 +1324,13 @@ void FbWinFrame::applyButton(FbTk::Button &btn) {
1327 else 1324 else
1328 btn.setPressedColor(m_button_pressed_color); 1325 btn.setPressedColor(m_button_pressed_color);
1329 1326
1330 Pixmap pm = m_focused ? m_button_pm : m_button_unfocused_pm; 1327 Pixmap pm = m_state.focused ? m_button_pm : m_button_unfocused_pm;
1331 btn.setAlpha(getAlpha(m_focused)); 1328 btn.setAlpha(getAlpha(m_state.focused));
1332 btn.setGC(theme()->buttonPicGC()); 1329 btn.setGC(theme()->buttonPicGC());
1333 if (pm) 1330 if (pm)
1334 btn.setBackgroundPixmap(pm); 1331 btn.setBackgroundPixmap(pm);
1335 else 1332 else
1336 btn.setBackgroundColor(m_focused ? m_button_color 1333 btn.setBackgroundColor(m_state.focused ? m_button_color
1337 : m_button_unfocused_color); 1334 : m_button_unfocused_color);
1338} 1335}
1339 1336
@@ -1355,7 +1352,7 @@ void FbWinFrame::render(const FbTk::Texture &tex, FbTk::Color &col, Pixmap &pm,
1355 1352
1356void FbWinFrame::getCurrentFocusPixmap(Pixmap &label_pm, Pixmap &title_pm, 1353void FbWinFrame::getCurrentFocusPixmap(Pixmap &label_pm, Pixmap &title_pm,
1357 FbTk::Color &label_color, FbTk::Color &title_color) { 1354 FbTk::Color &label_color, FbTk::Color &title_color) {
1358 if (m_focused) { 1355 if (m_state.focused) {
1359 if (m_label_focused_pm != 0) 1356 if (m_label_focused_pm != 0)
1360 label_pm = m_label_focused_pm; 1357 label_pm = m_label_focused_pm;
1361 else 1358 else
@@ -1379,12 +1376,12 @@ void FbWinFrame::getCurrentFocusPixmap(Pixmap &label_pm, Pixmap &title_pm,
1379} 1376}
1380 1377
1381void FbWinFrame::applyTabContainer() { 1378void FbWinFrame::applyTabContainer() {
1382 m_tab_container.setAlpha(getAlpha(m_focused)); 1379 m_tab_container.setAlpha(getAlpha(m_state.focused));
1383 1380
1384 // do the parent container 1381 // do the parent container
1385 Pixmap tabcontainer_pm = None; 1382 Pixmap tabcontainer_pm = None;
1386 FbTk::Color *tabcontainer_color = NULL; 1383 FbTk::Color *tabcontainer_color = NULL;
1387 if (m_focused) { 1384 if (m_state.focused) {
1388 if (m_tabcontainer_focused_pm != 0) 1385 if (m_tabcontainer_focused_pm != 0)
1389 tabcontainer_pm = m_tabcontainer_focused_pm; 1386 tabcontainer_pm = m_tabcontainer_focused_pm;
1390 else 1387 else
@@ -1421,13 +1418,13 @@ void FbWinFrame::applyDecorations() {
1421 // tab deocration only affects if we're external 1418 // tab deocration only affects if we're external
1422 // must do before the setTabMode in case it goes 1419 // must do before the setTabMode in case it goes
1423 // to external and is meant to be hidden 1420 // to external and is meant to be hidden
1424 if (m_decoration_mask & DECORM_TAB) 1421 if (m_state.deco_mask & DECORM_TAB)
1425 client_move |= showTabs(); 1422 client_move |= showTabs();
1426 else 1423 else
1427 client_move |= hideTabs(); 1424 client_move |= hideTabs();
1428 1425
1429 // we rely on frame not doing anything if it is already shown/hidden 1426 // we rely on frame not doing anything if it is already shown/hidden
1430 if (m_decoration_mask & DECORM_TITLEBAR) { 1427 if (m_state.deco_mask & DECORM_TITLEBAR) {
1431 client_move |= showTitlebar(); 1428 client_move |= showTitlebar();
1432 if (m_screen.getDefaultInternalTabs()) 1429 if (m_screen.getDefaultInternalTabs())
1433 client_move |= setTabMode(INTERNAL); 1430 client_move |= setTabMode(INTERNAL);
@@ -1435,11 +1432,11 @@ void FbWinFrame::applyDecorations() {
1435 client_move |= setTabMode(EXTERNAL); 1432 client_move |= setTabMode(EXTERNAL);
1436 } else { 1433 } else {
1437 client_move |= hideTitlebar(); 1434 client_move |= hideTitlebar();
1438 if (m_decoration_mask & DECORM_TAB) 1435 if (m_state.deco_mask & DECORM_TAB)
1439 client_move |= setTabMode(EXTERNAL); 1436 client_move |= setTabMode(EXTERNAL);
1440 } 1437 }
1441 1438
1442 if (m_decoration_mask & DECORM_HANDLE) 1439 if (m_state.deco_mask & DECORM_HANDLE)
1443 client_move |= showHandle(); 1440 client_move |= showHandle();
1444 else 1441 else
1445 client_move |= hideHandle(); 1442 client_move |= hideHandle();
@@ -1461,7 +1458,7 @@ void FbWinFrame::applyDecorations() {
1461 1458
1462bool FbWinFrame::setBorderWidth(bool do_move) { 1459bool FbWinFrame::setBorderWidth(bool do_move) {
1463 unsigned int border_width = theme()->border().width(); 1460 unsigned int border_width = theme()->border().width();
1464 unsigned int win_bw = m_decoration_mask & DECORM_BORDER ? border_width : 0; 1461 unsigned int win_bw = m_state.deco_mask & DECORM_BORDER ? border_width : 0;
1465 1462
1466 if (border_width && 1463 if (border_width &&
1467 theme()->border().color().pixel() != window().borderColor()) { 1464 theme()->border().color().pixel() != window().borderColor()) {
@@ -1598,7 +1595,7 @@ void FbWinFrame::gravityTranslate(int &x, int &y,
1598} 1595}
1599 1596
1600unsigned int FbWinFrame::normalHeight() const { 1597unsigned int FbWinFrame::normalHeight() const {
1601 if (m_shaded) 1598 if (m_state.shaded)
1602 return m_height_before_shade; 1599 return m_height_before_shade;
1603 return height(); 1600 return height();
1604} 1601}