diff options
Diffstat (limited to 'src/Window.cc')
-rw-r--r-- | src/Window.cc | 80 |
1 files changed, 47 insertions, 33 deletions
diff --git a/src/Window.cc b/src/Window.cc index 29f8bca..6fc4007 100644 --- a/src/Window.cc +++ b/src/Window.cc | |||
@@ -58,8 +58,8 @@ | |||
58 | #endif // SHAPE | 58 | #endif // SHAPE |
59 | 59 | ||
60 | //use GNU extensions | 60 | //use GNU extensions |
61 | #ifndef _GNU_SOURCE | 61 | #ifndef _GNU_SOURCE |
62 | #define _GNU_SOURCE | 62 | #define _GNU_SOURCE |
63 | #endif // _GNU_SOURCE | 63 | #endif // _GNU_SOURCE |
64 | 64 | ||
65 | #include <X11/Xatom.h> | 65 | #include <X11/Xatom.h> |
@@ -84,9 +84,23 @@ | |||
84 | #include <functional> | 84 | #include <functional> |
85 | #include <algorithm> | 85 | #include <algorithm> |
86 | 86 | ||
87 | using namespace std; | 87 | using std::cerr; |
88 | using std::endl; | ||
89 | using std::string; | ||
90 | using std::vector; | ||
91 | using std::bind2nd; | ||
92 | using std::mem_fun; | ||
93 | using std::equal_to; | ||
94 | using std::max; | ||
95 | using std::swap; | ||
96 | |||
88 | using namespace FbTk; | 97 | using namespace FbTk; |
89 | 98 | ||
99 | #ifdef DEBUG | ||
100 | using std::dec; | ||
101 | using std::hex; | ||
102 | #endif // DEBUG | ||
103 | |||
90 | namespace { | 104 | namespace { |
91 | 105 | ||
92 | void grabButton(unsigned int button, | 106 | void grabButton(unsigned int button, |
@@ -439,7 +453,7 @@ void FluxboxWindow::init() { | |||
439 | decorations.enabled = true; | 453 | decorations.enabled = true; |
440 | 454 | ||
441 | // set default values for decoration | 455 | // set default values for decoration |
442 | decorations.menu = true; //override menu option | 456 | decorations.menu = true; //override menu option |
443 | // all decorations on by default | 457 | // all decorations on by default |
444 | decorations.titlebar = decorations.border = decorations.handle = true; | 458 | decorations.titlebar = decorations.border = decorations.handle = true; |
445 | decorations.maximize = decorations.close = | 459 | decorations.maximize = decorations.close = |
@@ -518,7 +532,7 @@ void FluxboxWindow::init() { | |||
518 | 532 | ||
519 | if (fluxbox.isStartup()) | 533 | if (fluxbox.isStartup()) |
520 | place_window = false; | 534 | place_window = false; |
521 | else if (m_client->isTransient() || | 535 | else if (m_client->isTransient() || |
522 | m_client->normal_hint_flags & (PPosition|USPosition)) { | 536 | m_client->normal_hint_flags & (PPosition|USPosition)) { |
523 | 537 | ||
524 | int real_x = frame().x(); | 538 | int real_x = frame().x(); |
@@ -640,15 +654,15 @@ void FluxboxWindow::attachClient(WinClient &client, int x, int y) { | |||
640 | if (client.fbwindow() != 0) { | 654 | if (client.fbwindow() != 0) { |
641 | FluxboxWindow *old_win = client.fbwindow(); // store old window | 655 | FluxboxWindow *old_win = client.fbwindow(); // store old window |
642 | 656 | ||
643 | ClientList::iterator client_insert_pos = getClientInsertPosition(x, y); | 657 | ClientList::iterator client_insert_pos = getClientInsertPosition(x, y); |
644 | FbTk::TextButton *button_insert_pos = NULL; | 658 | FbTk::TextButton *button_insert_pos = NULL; |
645 | if (client_insert_pos != m_clientlist.end()) | 659 | if (client_insert_pos != m_clientlist.end()) |
646 | button_insert_pos = m_labelbuttons[*client_insert_pos]; | 660 | button_insert_pos = m_labelbuttons[*client_insert_pos]; |
647 | 661 | ||
648 | // make sure we set new window search for each client | 662 | // make sure we set new window search for each client |
649 | ClientList::iterator client_it = old_win->clientList().begin(); | 663 | ClientList::iterator client_it = old_win->clientList().begin(); |
650 | ClientList::iterator client_it_end = old_win->clientList().end(); | 664 | ClientList::iterator client_it_end = old_win->clientList().end(); |
651 | for (; client_it != client_it_end; ++client_it) { | 665 | for (; client_it != client_it_end; ++client_it) { |
652 | // reparent window to this | 666 | // reparent window to this |
653 | frame().setClientWindow(**client_it); | 667 | frame().setClientWindow(**client_it); |
654 | if ((*client_it) == focused_win) | 668 | if ((*client_it) == focused_win) |
@@ -665,7 +679,7 @@ void FluxboxWindow::attachClient(WinClient &client, int x, int y) { | |||
665 | associateClient(*(*client_it)); | 679 | associateClient(*(*client_it)); |
666 | 680 | ||
667 | //null if we want the new button at the end of the list | 681 | //null if we want the new button at the end of the list |
668 | if (x >= 0 && button_insert_pos) | 682 | if (x >= 0 && button_insert_pos) |
669 | frame().moveLabelButtonLeftOf(*m_labelbuttons[*client_it], *button_insert_pos); | 683 | frame().moveLabelButtonLeftOf(*m_labelbuttons[*client_it], *button_insert_pos); |
670 | 684 | ||
671 | (*client_it)->saveBlackboxAttribs(m_blackbox_attrib); | 685 | (*client_it)->saveBlackboxAttribs(m_blackbox_attrib); |
@@ -673,8 +687,8 @@ void FluxboxWindow::attachClient(WinClient &client, int x, int y) { | |||
673 | 687 | ||
674 | // add client and move over all attached clients | 688 | // add client and move over all attached clients |
675 | // from the old window to this list | 689 | // from the old window to this list |
676 | m_clientlist.splice(client_insert_pos, old_win->m_clientlist); | 690 | m_clientlist.splice(client_insert_pos, old_win->m_clientlist); |
677 | updateClientLeftWindow(); | 691 | updateClientLeftWindow(); |
678 | old_win->m_client = 0; | 692 | old_win->m_client = 0; |
679 | 693 | ||
680 | delete old_win; | 694 | delete old_win; |
@@ -879,7 +893,7 @@ void FluxboxWindow::moveClientLeft() { | |||
879 | // move client in clientlist to the left | 893 | // move client in clientlist to the left |
880 | ClientList::iterator oldpos = find(m_clientlist.begin(), m_clientlist.end(), &winClient()); | 894 | ClientList::iterator oldpos = find(m_clientlist.begin(), m_clientlist.end(), &winClient()); |
881 | ClientList::iterator newpos = oldpos; newpos--; | 895 | ClientList::iterator newpos = oldpos; newpos--; |
882 | std::swap(*newpos, *oldpos); | 896 | swap(*newpos, *oldpos); |
883 | frame().moveLabelButtonLeft(*m_labelbuttons[&winClient()]); | 897 | frame().moveLabelButtonLeft(*m_labelbuttons[&winClient()]); |
884 | 898 | ||
885 | updateClientLeftWindow(); | 899 | updateClientLeftWindow(); |
@@ -893,13 +907,13 @@ void FluxboxWindow::moveClientRight() { | |||
893 | 907 | ||
894 | ClientList::iterator oldpos = find(m_clientlist.begin(), m_clientlist.end(), &winClient()); | 908 | ClientList::iterator oldpos = find(m_clientlist.begin(), m_clientlist.end(), &winClient()); |
895 | ClientList::iterator newpos = oldpos; newpos++; | 909 | ClientList::iterator newpos = oldpos; newpos++; |
896 | std::swap(*newpos, *oldpos); | 910 | swap(*newpos, *oldpos); |
897 | frame().moveLabelButtonRight(*m_labelbuttons[&winClient()]); | 911 | frame().moveLabelButtonRight(*m_labelbuttons[&winClient()]); |
898 | 912 | ||
899 | updateClientLeftWindow(); | 913 | updateClientLeftWindow(); |
900 | } | 914 | } |
901 | 915 | ||
902 | //std::list<*WinClient>::iterator FluxboxWindow::getClientInsertPosition(int x, int y) { | 916 | //list<*WinClient>::iterator FluxboxWindow::getClientInsertPosition(int x, int y) { |
903 | FluxboxWindow::ClientList::iterator FluxboxWindow::getClientInsertPosition(int x, int y) { | 917 | FluxboxWindow::ClientList::iterator FluxboxWindow::getClientInsertPosition(int x, int y) { |
904 | 918 | ||
905 | int dest_x = 0, dest_y = 0; | 919 | int dest_x = 0, dest_y = 0; |
@@ -2448,7 +2462,7 @@ void FluxboxWindow::mapRequestEvent(XMapRequestEvent &re) { | |||
2448 | if (wsp != 0 && isGroupable()) | 2462 | if (wsp != 0 && isGroupable()) |
2449 | destroyed = wsp->checkGrouping(*this); | 2463 | destroyed = wsp->checkGrouping(*this); |
2450 | 2464 | ||
2451 | // if we weren't grouped with another window we deiconify ourself | 2465 | // if we weren't grouped with another window we deiconify ourself |
2452 | if (!destroyed && !iconic) | 2466 | if (!destroyed && !iconic) |
2453 | deiconify(false); | 2467 | deiconify(false); |
2454 | 2468 | ||
@@ -2612,7 +2626,7 @@ void FluxboxWindow::propertyNotifyEvent(WinClient &client, Atom atom) { | |||
2612 | 2626 | ||
2613 | if (changed) | 2627 | if (changed) |
2614 | setupWindow(); | 2628 | setupWindow(); |
2615 | } | 2629 | } |
2616 | 2630 | ||
2617 | moveResize(frame().x(), frame().y(), | 2631 | moveResize(frame().x(), frame().y(), |
2618 | frame().width(), frame().height()); | 2632 | frame().width(), frame().height()); |
@@ -3116,10 +3130,10 @@ void FluxboxWindow::setDecoration(Decoration decoration, bool apply) { | |||
3116 | decorations.iconify = decorations.maximize = | 3130 | decorations.iconify = decorations.maximize = |
3117 | decorations.tab = false; //tab is also a decor | 3131 | decorations.tab = false; //tab is also a decor |
3118 | decorations.menu = true; // menu is present | 3132 | decorations.menu = true; // menu is present |
3119 | // functions.iconify = functions.maximize = true; | 3133 | // functions.iconify = functions.maximize = true; |
3120 | // functions.move = true; // We need to move even without decor | 3134 | // functions.move = true; // We need to move even without decor |
3121 | // functions.resize = true; // We need to resize even without decor | 3135 | // functions.resize = true; // We need to resize even without decor |
3122 | break; | 3136 | break; |
3123 | 3137 | ||
3124 | default: | 3138 | default: |
3125 | case DECOR_NORMAL: | 3139 | case DECOR_NORMAL: |
@@ -3128,7 +3142,7 @@ void FluxboxWindow::setDecoration(Decoration decoration, bool apply) { | |||
3128 | decorations.menu = decorations.tab = true; | 3142 | decorations.menu = decorations.tab = true; |
3129 | functions.resize = functions.move = functions.iconify = | 3143 | functions.resize = functions.move = functions.iconify = |
3130 | functions.maximize = true; | 3144 | functions.maximize = true; |
3131 | break; | 3145 | break; |
3132 | 3146 | ||
3133 | case DECOR_TAB: | 3147 | case DECOR_TAB: |
3134 | decorations.border = decorations.iconify = decorations.maximize = | 3148 | decorations.border = decorations.iconify = decorations.maximize = |
@@ -3136,21 +3150,21 @@ void FluxboxWindow::setDecoration(Decoration decoration, bool apply) { | |||
3136 | decorations.titlebar = decorations.handle = false; | 3150 | decorations.titlebar = decorations.handle = false; |
3137 | functions.resize = functions.move = functions.iconify = | 3151 | functions.resize = functions.move = functions.iconify = |
3138 | functions.maximize = true; | 3152 | functions.maximize = true; |
3139 | break; | 3153 | break; |
3140 | 3154 | ||
3141 | case DECOR_TINY: | 3155 | case DECOR_TINY: |
3142 | decorations.titlebar = decorations.iconify = decorations.menu = | 3156 | decorations.titlebar = decorations.iconify = decorations.menu = |
3143 | functions.move = functions.iconify = decorations.tab = true; | 3157 | functions.move = functions.iconify = decorations.tab = true; |
3144 | decorations.border = decorations.handle = decorations.maximize = | 3158 | decorations.border = decorations.handle = decorations.maximize = |
3145 | functions.resize = functions.maximize = false; | 3159 | functions.resize = functions.maximize = false; |
3146 | break; | 3160 | break; |
3147 | 3161 | ||
3148 | case DECOR_TOOL: | 3162 | case DECOR_TOOL: |
3149 | decorations.titlebar = decorations.tab = decorations.menu = functions.move = true; | 3163 | decorations.titlebar = decorations.tab = decorations.menu = functions.move = true; |
3150 | decorations.iconify = decorations.border = decorations.handle = | 3164 | decorations.iconify = decorations.border = decorations.handle = |
3151 | decorations.maximize = functions.resize = functions.maximize = | 3165 | decorations.maximize = functions.resize = functions.maximize = |
3152 | functions.iconify = false; | 3166 | functions.iconify = false; |
3153 | break; | 3167 | break; |
3154 | } | 3168 | } |
3155 | 3169 | ||
3156 | // we might want to wait with apply decorations | 3170 | // we might want to wait with apply decorations |
@@ -3778,14 +3792,14 @@ Window FluxboxWindow::clientWindow() const { | |||
3778 | return m_client->window(); | 3792 | return m_client->window(); |
3779 | } | 3793 | } |
3780 | 3794 | ||
3781 | const std::string &FluxboxWindow::title() const { | 3795 | const string &FluxboxWindow::title() const { |
3782 | static string empty_string(""); | 3796 | static string empty_string(""); |
3783 | if (m_client == 0) | 3797 | if (m_client == 0) |
3784 | return empty_string; | 3798 | return empty_string; |
3785 | return m_client->title(); | 3799 | return m_client->title(); |
3786 | } | 3800 | } |
3787 | 3801 | ||
3788 | const std::string &FluxboxWindow::iconTitle() const { | 3802 | const string &FluxboxWindow::iconTitle() const { |
3789 | static string empty_string(""); | 3803 | static string empty_string(""); |
3790 | if (m_client == 0) | 3804 | if (m_client == 0) |
3791 | return empty_string; | 3805 | return empty_string; |
@@ -3992,10 +4006,10 @@ void FluxboxWindow::setupWindow() { | |||
3992 | // clear old buttons from frame | 4006 | // clear old buttons from frame |
3993 | frame().removeAllButtons(); | 4007 | frame().removeAllButtons(); |
3994 | 4008 | ||
3995 | typedef FbTk::Resource<std::vector<WinButton::Type> > WinButtonsResource; | 4009 | typedef FbTk::Resource<vector<WinButton::Type> > WinButtonsResource; |
3996 | 4010 | ||
3997 | std::string titlebar_name[2]; | 4011 | string titlebar_name[2]; |
3998 | std::string titlebar_alt_name[2]; | 4012 | string titlebar_alt_name[2]; |
3999 | titlebar_name[0] = screen().name() + ".titlebar.left"; | 4013 | titlebar_name[0] = screen().name() + ".titlebar.left"; |
4000 | titlebar_alt_name[0] = screen().altName() + ".Titlebar.Left"; | 4014 | titlebar_alt_name[0] = screen().altName() + ".Titlebar.Left"; |
4001 | titlebar_name[1] = screen().name() + ".titlebar.right"; | 4015 | titlebar_name[1] = screen().name() + ".titlebar.right"; |
@@ -4050,7 +4064,7 @@ void FluxboxWindow::setupWindow() { | |||
4050 | 4064 | ||
4051 | for (size_t c = 0; c < 2 ; c++) { | 4065 | for (size_t c = 0; c < 2 ; c++) { |
4052 | // get titlebar configuration for current side | 4066 | // get titlebar configuration for current side |
4053 | const std::vector<WinButton::Type> &dir = *(*titlebar_side[c]); | 4067 | const vector<WinButton::Type> &dir = *(*titlebar_side[c]); |
4054 | 4068 | ||
4055 | for (size_t i=0; i < dir.size(); ++i) { | 4069 | for (size_t i=0; i < dir.size(); ++i) { |
4056 | //create new buttons | 4070 | //create new buttons |
@@ -4142,10 +4156,10 @@ void FluxboxWindow::setupWindow() { | |||
4142 | if (screen().getScrollReverse()) | 4156 | if (screen().getScrollReverse()) |
4143 | reverse = 1; | 4157 | reverse = 1; |
4144 | 4158 | ||
4145 | if (StringUtil::toLower(screen().getScrollAction()) == std::string("shade")) { | 4159 | if (StringUtil::toLower(screen().getScrollAction()) == string("shade")) { |
4146 | frame().setOnClickTitlebar(shade_on_cmd, 5 - reverse); // shade on mouse roll | 4160 | frame().setOnClickTitlebar(shade_on_cmd, 5 - reverse); // shade on mouse roll |
4147 | frame().setOnClickTitlebar(shade_off_cmd, 4 + reverse); // unshade if rolled oposite direction | 4161 | frame().setOnClickTitlebar(shade_off_cmd, 4 + reverse); // unshade if rolled oposite direction |
4148 | } else if (StringUtil::toLower(screen().getScrollAction()) == std::string("nexttab")) { | 4162 | } else if (StringUtil::toLower(screen().getScrollAction()) == string("nexttab")) { |
4149 | frame().setOnClickTitlebar(next_tab_cmd, 5 - reverse); // next tab | 4163 | frame().setOnClickTitlebar(next_tab_cmd, 5 - reverse); // next tab |
4150 | frame().setOnClickTitlebar(prev_tab_cmd, 4 + reverse); // previous tab | 4164 | frame().setOnClickTitlebar(prev_tab_cmd, 4 + reverse); // previous tab |
4151 | } | 4165 | } |