diff options
Diffstat (limited to 'src/Window.cc')
-rw-r--r-- | src/Window.cc | 138 |
1 files changed, 37 insertions, 101 deletions
diff --git a/src/Window.cc b/src/Window.cc index 133a84f..2f06603 100644 --- a/src/Window.cc +++ b/src/Window.cc | |||
@@ -303,6 +303,7 @@ FluxboxWindow::FluxboxWindow(WinClient &client, FbTk::XLayer &layer): | |||
303 | m_resize_corner(RIGHTBOTTOM) { | 303 | m_resize_corner(RIGHTBOTTOM) { |
304 | 304 | ||
305 | m_theme.reconfigSig().attach(this); | 305 | m_theme.reconfigSig().attach(this); |
306 | m_frame.frameExtentSig().attach(this); | ||
306 | 307 | ||
307 | init(); | 308 | init(); |
308 | 309 | ||
@@ -325,6 +326,8 @@ FluxboxWindow::FluxboxWindow(WinClient &client, FbTk::XLayer &layer): | |||
325 | FluxboxWindow::~FluxboxWindow() { | 326 | FluxboxWindow::~FluxboxWindow() { |
326 | if (WindowCmd<void>::window() == this) | 327 | if (WindowCmd<void>::window() == this) |
327 | WindowCmd<void>::setWindow(0); | 328 | WindowCmd<void>::setWindow(0); |
329 | if (FbMenu::window() == this) | ||
330 | FbMenu::setWindow(0); | ||
328 | if ( Fluxbox::instance()->keys() != 0 ) { | 331 | if ( Fluxbox::instance()->keys() != 0 ) { |
329 | Fluxbox::instance()->keys()-> | 332 | Fluxbox::instance()->keys()-> |
330 | unregisterWindow(frame().window().window()); | 333 | unregisterWindow(frame().window().window()); |
@@ -500,13 +503,14 @@ void FluxboxWindow::init() { | |||
500 | } else | 503 | } else |
501 | setOnHead(screen().getCurrHead()); | 504 | setOnHead(screen().getCurrHead()); |
502 | 505 | ||
506 | // we must do this now, or else resizing may not work properly | ||
507 | applyDecorations(); | ||
508 | |||
503 | Fluxbox::instance()->attachSignals(*this); | 509 | Fluxbox::instance()->attachSignals(*this); |
504 | 510 | ||
505 | // this window is managed, we are now allowed to modify actual state | 511 | // this window is managed, we are now allowed to modify actual state |
506 | m_initialized = true; | 512 | m_initialized = true; |
507 | 513 | ||
508 | applyDecorations(true); | ||
509 | |||
510 | restoreAttributes(); | 514 | restoreAttributes(); |
511 | 515 | ||
512 | if (m_workspace_number >= screen().numberOfWorkspaces()) | 516 | if (m_workspace_number >= screen().numberOfWorkspaces()) |
@@ -600,7 +604,7 @@ void FluxboxWindow::init() { | |||
600 | gettimeofday(&now, NULL); | 604 | gettimeofday(&now, NULL); |
601 | m_creation_time = now.tv_sec; | 605 | m_creation_time = now.tv_sec; |
602 | 606 | ||
603 | sendConfigureNotify(); | 607 | frame().frameExtentSig().notify(); |
604 | 608 | ||
605 | setupWindow(); | 609 | setupWindow(); |
606 | 610 | ||
@@ -2150,11 +2154,11 @@ void FluxboxWindow::restoreAttributes() { | |||
2150 | Show the window menu at pos mx, my | 2154 | Show the window menu at pos mx, my |
2151 | */ | 2155 | */ |
2152 | void FluxboxWindow::showMenu(int menu_x, int menu_y) { | 2156 | void FluxboxWindow::showMenu(int menu_x, int menu_y) { |
2153 | // move menu directly under titlebar | 2157 | menu().reloadHelper()->checkReload(); |
2154 | 2158 | ||
2155 | int head = screen().getHead(menu_x, menu_y); | 2159 | int head = screen().getHead(menu_x, menu_y); |
2156 | 2160 | ||
2157 | // but not off the screen | 2161 | // move menu directly under titlebar but not off the screen |
2158 | if (menu_y < static_cast<signed>(screen().maxTop(head))) | 2162 | if (menu_y < static_cast<signed>(screen().maxTop(head))) |
2159 | menu_y = screen().maxTop(head); | 2163 | menu_y = screen().maxTop(head); |
2160 | else if (menu_y + menu().height() >= screen().maxBottom(head)) | 2164 | else if (menu_y + menu().height() >= screen().maxBottom(head)) |
@@ -2172,25 +2176,28 @@ void FluxboxWindow::showMenu(int menu_x, int menu_y) { | |||
2172 | menu().grabInputFocus(); | 2176 | menu().grabInputFocus(); |
2173 | } | 2177 | } |
2174 | 2178 | ||
2179 | void FluxboxWindow::popupMenu(int x, int y) { | ||
2180 | // hide menu if it was opened for this window before | ||
2181 | if (menu().isVisible() && FbMenu::window() == this) { | ||
2182 | menu().hide(); | ||
2183 | return; | ||
2184 | } | ||
2185 | |||
2186 | menu().disableTitle(); | ||
2187 | |||
2188 | showMenu(x, y); | ||
2189 | } | ||
2190 | |||
2175 | /** | 2191 | /** |
2176 | Moves the menu to last button press position and shows it, | 2192 | Moves the menu to last button press position and shows it, |
2177 | if it's already visible it'll be hidden | 2193 | if it's already visible it'll be hidden |
2178 | */ | 2194 | */ |
2179 | void FluxboxWindow::popupMenu() { | 2195 | void FluxboxWindow::popupMenu() { |
2180 | 2196 | ||
2181 | // hide menu if it was opened for this window before | ||
2182 | if (menu().isVisible() && FbMenu::window() == this) { | ||
2183 | menu().hide(); | ||
2184 | return; | ||
2185 | } | ||
2186 | |||
2187 | menu().disableTitle(); | ||
2188 | int menu_y = frame().titlebar().height() + frame().titlebar().borderWidth(); | ||
2189 | if (!decorations.titlebar) // if we don't have any titlebar | ||
2190 | menu_y = 0; | ||
2191 | if (m_last_button_x < x() || m_last_button_x > x() + static_cast<signed>(width())) | 2197 | if (m_last_button_x < x() || m_last_button_x > x() + static_cast<signed>(width())) |
2192 | m_last_button_x = x(); | 2198 | m_last_button_x = x(); |
2193 | showMenu(m_last_button_x, menu_y + frame().y()); | 2199 | |
2200 | popupMenu(m_last_button_x, frame().titlebarHeight() + frame().y()); | ||
2194 | } | 2201 | } |
2195 | 2202 | ||
2196 | 2203 | ||
@@ -3008,74 +3015,16 @@ void FluxboxWindow::update(FbTk::Subject *subj) { | |||
3008 | } else if (subj == &m_theme.reconfigSig()) { | 3015 | } else if (subj == &m_theme.reconfigSig()) { |
3009 | frame().reconfigure(); | 3016 | frame().reconfigure(); |
3010 | reconfigTheme(); | 3017 | reconfigTheme(); |
3018 | } else if (m_initialized && subj == &m_frame.frameExtentSig()) { | ||
3019 | Fluxbox::instance()->updateFrameExtents(*this); | ||
3020 | sendConfigureNotify(); | ||
3011 | } | 3021 | } |
3012 | } | 3022 | } |
3013 | 3023 | ||
3014 | // commit current decoration values to actual displayed things | 3024 | // commit current decoration values to actual displayed things |
3015 | void FluxboxWindow::applyDecorations(bool initial) { | 3025 | void FluxboxWindow::applyDecorations() { |
3016 | frame().clientArea().setBorderWidth(0); // client area bordered by other things | ||
3017 | |||
3018 | unsigned int border_width = 0; | ||
3019 | if (decorations.border) | ||
3020 | border_width = frame().theme()->border().width(); | ||
3021 | |||
3022 | bool client_move = false; | ||
3023 | |||
3024 | // borderWidth setting handles its own gravity | ||
3025 | if (initial || frame().window().borderWidth() != border_width) { | ||
3026 | client_move = true; | ||
3027 | frame().setBorderWidth(border_width); | ||
3028 | } | ||
3029 | |||
3030 | int grav_x=0, grav_y=0; | ||
3031 | // negate gravity | ||
3032 | frame().gravityTranslate(grav_x, grav_y, -m_client->gravity(), m_client->old_bw, false); | ||
3033 | |||
3034 | // tab deocration only affects if we're external | ||
3035 | // must do before the setTabMode in case it goes | ||
3036 | // to external and is meant to be hidden | ||
3037 | if (decorations.tab) | ||
3038 | client_move |= frame().showTabs(); | ||
3039 | else | ||
3040 | client_move |= frame().hideTabs(); | ||
3041 | |||
3042 | // we rely on frame not doing anything if it is already shown/hidden | ||
3043 | if (decorations.titlebar) { | ||
3044 | bool change = frame().showTitlebar(); | ||
3045 | client_move |= change; | ||
3046 | if (screen().getDefaultInternalTabs()) { | ||
3047 | client_move |= frame().setTabMode(FbWinFrame::INTERNAL); | ||
3048 | } else { | ||
3049 | client_move |= frame().setTabMode(FbWinFrame::EXTERNAL); | ||
3050 | } | ||
3051 | } else { | ||
3052 | client_move |= frame().hideTitlebar(); | ||
3053 | if (decorations.tab) | ||
3054 | client_move |= frame().setTabMode(FbWinFrame::EXTERNAL); | ||
3055 | } | ||
3056 | |||
3057 | if (decorations.handle) { | ||
3058 | client_move |= frame().showHandle(); | ||
3059 | } else | ||
3060 | client_move |= frame().hideHandle(); | ||
3061 | |||
3062 | // apply gravity once more | ||
3063 | frame().gravityTranslate(grav_x, grav_y, m_client->gravity(), m_client->old_bw, false); | ||
3064 | |||
3065 | // if the location changes, shift it | ||
3066 | if (grav_x != 0 || grav_y != 0) { | ||
3067 | move(grav_x + frame().x(), grav_y + frame().y()); | ||
3068 | client_move = true; | ||
3069 | } | ||
3070 | |||
3071 | frame().setDecorationMask(decorationMask()); | 3026 | frame().setDecorationMask(decorationMask()); |
3072 | frame().reconfigure(); | 3027 | frame().applyDecorations(); |
3073 | if (client_move) | ||
3074 | Fluxbox::instance()->updateFrameExtents(*this); | ||
3075 | |||
3076 | if (!initial && client_move) | ||
3077 | sendConfigureNotify(); | ||
3078 | |||
3079 | } | 3028 | } |
3080 | 3029 | ||
3081 | void FluxboxWindow::toggleDecoration() { | 3030 | void FluxboxWindow::toggleDecoration() { |
@@ -3699,7 +3648,7 @@ const FbTk::FbWindow &FluxboxWindow::fbWindow() const { | |||
3699 | return frame().window(); | 3648 | return frame().window(); |
3700 | } | 3649 | } |
3701 | 3650 | ||
3702 | FbTk::Menu &FluxboxWindow::menu() { | 3651 | FbMenu &FluxboxWindow::menu() { |
3703 | return screen().windowMenu(); | 3652 | return screen().windowMenu(); |
3704 | } | 3653 | } |
3705 | 3654 | ||
@@ -3711,7 +3660,7 @@ const FbTk::PixmapWithMask &FluxboxWindow::icon() const { | |||
3711 | return (m_client ? m_client->icon() : m_icon); | 3660 | return (m_client ? m_client->icon() : m_icon); |
3712 | } | 3661 | } |
3713 | 3662 | ||
3714 | const FbTk::Menu &FluxboxWindow::menu() const { | 3663 | const FbMenu &FluxboxWindow::menu() const { |
3715 | return screen().windowMenu(); | 3664 | return screen().windowMenu(); |
3716 | } | 3665 | } |
3717 | 3666 | ||
@@ -3751,25 +3700,25 @@ bool FluxboxWindow::isTransient() const { | |||
3751 | } | 3700 | } |
3752 | 3701 | ||
3753 | int FluxboxWindow::normalX() const { | 3702 | int FluxboxWindow::normalX() const { |
3754 | if (maximized & MAX_HORZ) | 3703 | if (maximized & MAX_HORZ || fullscreen) |
3755 | return m_old_pos_x; | 3704 | return m_old_pos_x; |
3756 | return x(); | 3705 | return x(); |
3757 | } | 3706 | } |
3758 | 3707 | ||
3759 | int FluxboxWindow::normalY() const { | 3708 | int FluxboxWindow::normalY() const { |
3760 | if (maximized & MAX_VERT) | 3709 | if (maximized & MAX_VERT || fullscreen) |
3761 | return m_old_pos_y; | 3710 | return m_old_pos_y; |
3762 | return y(); | 3711 | return y(); |
3763 | } | 3712 | } |
3764 | 3713 | ||
3765 | unsigned int FluxboxWindow::normalWidth() const { | 3714 | unsigned int FluxboxWindow::normalWidth() const { |
3766 | if (maximized & MAX_HORZ) | 3715 | if (maximized & MAX_HORZ || fullscreen) |
3767 | return m_old_width; | 3716 | return m_old_width; |
3768 | return width(); | 3717 | return width(); |
3769 | } | 3718 | } |
3770 | 3719 | ||
3771 | unsigned int FluxboxWindow::normalHeight() const { | 3720 | unsigned int FluxboxWindow::normalHeight() const { |
3772 | if (maximized & MAX_VERT) | 3721 | if (maximized & MAX_VERT || fullscreen) |
3773 | return m_old_height; | 3722 | return m_old_height; |
3774 | if (shaded) | 3723 | if (shaded) |
3775 | return frame().normalHeight(); | 3724 | return frame().normalHeight(); |
@@ -3779,13 +3728,7 @@ unsigned int FluxboxWindow::normalHeight() const { | |||
3779 | int FluxboxWindow::initialState() const { return m_client->initial_state; } | 3728 | int FluxboxWindow::initialState() const { return m_client->initial_state; } |
3780 | 3729 | ||
3781 | void FluxboxWindow::fixsize(int *user_w, int *user_h, bool maximizing) { | 3730 | void FluxboxWindow::fixsize(int *user_w, int *user_h, bool maximizing) { |
3782 | int titlebar_height = (decorations.titlebar ? | 3731 | int decoration_height = frame().titlebarHeight() + frame().handleHeight(); |
3783 | frame().titlebar().height() + | ||
3784 | frame().titlebar().borderWidth() : 0); | ||
3785 | int handle_height = (decorations.handle ? | ||
3786 | frame().handle().height() + | ||
3787 | frame().handle().borderWidth() : 0); | ||
3788 | int decoration_height = titlebar_height + handle_height; | ||
3789 | 3732 | ||
3790 | // dx is new width = current width + difference between new and old x values | 3733 | // dx is new width = current width + difference between new and old x values |
3791 | //int dx = frame().width() + frame().x() - m_last_resize_x; | 3734 | //int dx = frame().width() + frame().x() - m_last_resize_x; |
@@ -3818,8 +3761,8 @@ void FluxboxWindow::moveResizeClient(WinClient &client, int x, int y, | |||
3818 | client.moveResize(x, y, | 3761 | client.moveResize(x, y, |
3819 | frame().clientArea().width(), | 3762 | frame().clientArea().width(), |
3820 | frame().clientArea().height()); | 3763 | frame().clientArea().height()); |
3821 | client.sendConfigureNotify(frame().x() + frame().clientArea().x(), | 3764 | client.sendConfigureNotify(frame().x() + frame().clientArea().x() + frame().window().borderWidth(), |
3822 | frame().y() + frame().clientArea().y(), | 3765 | frame().y() + frame().clientArea().y() + frame().window().borderWidth(), |
3823 | frame().clientArea().width(), | 3766 | frame().clientArea().width(), |
3824 | frame().clientArea().height()); | 3767 | frame().clientArea().height()); |
3825 | } | 3768 | } |
@@ -4070,13 +4013,6 @@ void FluxboxWindow::updateButtons() { | |||
4070 | */ | 4013 | */ |
4071 | void FluxboxWindow::reconfigTheme() { | 4014 | void FluxboxWindow::reconfigTheme() { |
4072 | 4015 | ||
4073 | m_frame.setBorderWidth(decorations.border ? | ||
4074 | frame().theme()->border().width() : 0); | ||
4075 | if (decorations.handle && frame().theme()->handleWidth() != 0) | ||
4076 | frame().showHandle(); | ||
4077 | else | ||
4078 | frame().hideHandle(); | ||
4079 | |||
4080 | ClientList::iterator it = clientList().begin(); | 4016 | ClientList::iterator it = clientList().begin(); |
4081 | ClientList::iterator it_end = clientList().end(); | 4017 | ClientList::iterator it_end = clientList().end(); |
4082 | 4018 | ||