aboutsummaryrefslogtreecommitdiff
path: root/src/Window.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/Window.cc')
-rw-r--r--src/Window.cc162
1 files changed, 84 insertions, 78 deletions
diff --git a/src/Window.cc b/src/Window.cc
index 50b6f53..02a9d7f 100644
--- a/src/Window.cc
+++ b/src/Window.cc
@@ -45,6 +45,7 @@
45#include "FbTk/EventManager.hh" 45#include "FbTk/EventManager.hh"
46#include "FbTk/KeyUtil.hh" 46#include "FbTk/KeyUtil.hh"
47#include "FbTk/SimpleCommand.hh" 47#include "FbTk/SimpleCommand.hh"
48#include "FbTk/Select2nd.hh"
48 49
49#ifdef HAVE_CONFIG_H 50#ifdef HAVE_CONFIG_H
50#include "config.h" 51#include "config.h"
@@ -81,15 +82,18 @@
81#include <algorithm> 82#include <algorithm>
82 83
83using namespace std; 84using namespace std;
85using namespace FbTk;
84 86
85namespace { 87namespace {
86 88
87void grabButton(Display *display, unsigned int button, 89void grabButton(unsigned int button,
88 Window window, Cursor cursor) { 90 Window window, Cursor cursor) {
89 91
90 const int numlock = FbTk::KeyUtil::instance().numlock(); 92 static Display *display = App::instance()->display();
91 const int capslock = FbTk::KeyUtil::instance().capslock(); 93
92 const int scrolllock = FbTk::KeyUtil::instance().scrolllock(); 94 const int numlock = KeyUtil::instance().numlock();
95 const int capslock = KeyUtil::instance().capslock();
96 const int scrolllock = KeyUtil::instance().scrolllock();
93 97
94 // Grab with Mod1 and with all lock modifiers 98 // Grab with Mod1 and with all lock modifiers
95 // (num, scroll and caps) 99 // (num, scroll and caps)
@@ -863,8 +867,8 @@ bool FluxboxWindow::removeClient(WinClient &client) {
863WinClient *FluxboxWindow::findClient(Window win) { 867WinClient *FluxboxWindow::findClient(Window win) {
864 ClientList::iterator it = find_if(clientList().begin(), 868 ClientList::iterator it = find_if(clientList().begin(),
865 clientList().end(), 869 clientList().end(),
866 FbTk::Compose(bind2nd(equal_to<Window>(), win), 870 Compose(bind2nd(equal_to<Window>(), win),
867 mem_fun(&WinClient::window))); 871 mem_fun(&WinClient::window)));
868 return (it == clientList().end() ? 0 : *it); 872 return (it == clientList().end() ? 0 : *it);
869} 873}
870 874
@@ -941,74 +945,77 @@ void FluxboxWindow::moveClientRight() {
941//std::list<*WinClient>::iterator FluxboxWindow::getClientInsertPosition(int x, int y) { 945//std::list<*WinClient>::iterator FluxboxWindow::getClientInsertPosition(int x, int y) {
942FluxboxWindow::ClientList::iterator FluxboxWindow::getClientInsertPosition(int x, int y) { 946FluxboxWindow::ClientList::iterator FluxboxWindow::getClientInsertPosition(int x, int y) {
943 947
944 int dest_x=0, dest_y=0; 948 int dest_x = 0, dest_y = 0;
945 Window labelbutton=0; 949 Window labelbutton = 0;
946 if(!XTranslateCoordinates(FbTk::App::instance()->display(), 950 if (!XTranslateCoordinates(FbTk::App::instance()->display(),
947 parent().window(), frame().label().window(), 951 parent().window(), frame().label().window(),
948 x,y, &dest_x, &dest_y, 952 x, y, &dest_x, &dest_y,
949 &labelbutton)) 953 &labelbutton))
950 return m_clientlist.end(); 954 return m_clientlist.end();
951 Client2ButtonMap::iterator it = m_labelbuttons.begin(); 955
952 Client2ButtonMap::iterator it_end = m_labelbuttons.end(); 956 Client2ButtonMap::iterator it = m_labelbuttons.begin();
953 //find the label button to move next to 957 Client2ButtonMap::iterator it_end = m_labelbuttons.end();
954 for(; it!=it_end; it++) { 958 // find the label button to move next to
955 if( (*it).second->window()==labelbutton) 959 for (; it != it_end; it++) {
956 break; 960 if ((*it).second->window() == labelbutton)
957 } 961 break;
958 //label button not found 962 }
959 if(it==it_end) { 963
960 return m_clientlist.end(); 964 // label button not found
961 } 965 if (it == m_labelbuttons.end())
962 Window child_return=0; 966 return m_clientlist.end();
963 //make x and y relative to our labelbutton 967
964 if(!XTranslateCoordinates(FbTk::App::instance()->display(), 968 Window child_return=0;
965 frame().label().window(),labelbutton, 969 // make x and y relative to our labelbutton
966 dest_x,dest_y, &x, &y, 970 if (!XTranslateCoordinates(FbTk::App::instance()->display(),
967 &child_return)) 971 frame().label().window(), labelbutton,
968 return m_clientlist.end(); 972 dest_x, dest_y, &x, &y,
969 ClientList::iterator client = find(m_clientlist.begin(), 973 &child_return))
970 m_clientlist.end(), 974 return m_clientlist.end();
971 it->first); 975
972 if(x>(*it).second->width()/2) 976 ClientList::iterator client = find(m_clientlist.begin(),
973 client++; 977 m_clientlist.end(),
974 return client; 978 it->first);
975 979 if (x > (*it).second->width() / 2)
980 client++;
981
982 return client;
976 983
977} 984}
978 985
979 986
980 987
981void FluxboxWindow::moveClientTo(WinClient &win, int x, int y) { 988void FluxboxWindow::moveClientTo(WinClient &win, int x, int y) {
982 int dest_x=0, dest_y=0; 989 int dest_x = 0, dest_y = 0;
983 Window labelbutton=0; 990 Window labelbutton = 0;
984 if(!XTranslateCoordinates(FbTk::App::instance()->display(), 991 if (!XTranslateCoordinates(FbTk::App::instance()->display(),
985 parent().window(), frame().label().window(), 992 parent().window(), frame().label().window(),
986 x,y, &dest_x, &dest_y, 993 x, y, &dest_x, &dest_y,
987 &labelbutton)) 994 &labelbutton))
988 return; 995 return;
989 Client2ButtonMap::iterator it = m_labelbuttons.begin(); 996 Client2ButtonMap::iterator it = m_labelbuttons.begin();
990 Client2ButtonMap::iterator it_end = m_labelbuttons.end(); 997 Client2ButtonMap::iterator it_end = m_labelbuttons.end();
991 //find the label button to move next to 998 //find the label button to move next to
992 for(; it!=it_end; it++) { 999 for (; it != it_end; it++) {
993 if( (*it).second->window()==labelbutton) 1000 if ((*it).second->window() == labelbutton)
994 break; 1001 break;
995 } 1002 }
996 //label button not found 1003
997 if(it==it_end) { 1004 // label button not found
998 return; 1005 if (it == it_end)
999 } 1006 return;
1000 Window child_return=0; 1007
1001 //make x and y relative to our labelbutton 1008 Window child_return = 0;
1002 if(!XTranslateCoordinates(FbTk::App::instance()->display(), 1009 //make x and y relative to our labelbutton
1003 frame().label().window(),labelbutton, 1010 if (!XTranslateCoordinates(FbTk::App::instance()->display(),
1004 dest_x,dest_y, &x, &y, 1011 frame().label().window(), labelbutton,
1005 &child_return)) 1012 dest_x, dest_y, &x, &y,
1006 return; 1013 &child_return))
1007 if(x>(*it).second->width()/2) { 1014 return;
1008 moveClientRightOf(win, *it->first); 1015 if (x > (*it).second->width() / 2)
1009 } else { 1016 moveClientRightOf(win, *it->first);
1010 moveClientLeftOf(win, *it->first); 1017 else
1011 } 1018 moveClientLeftOf(win, *it->first);
1012 1019
1013} 1020}
1014 1021
@@ -1154,7 +1161,7 @@ void FluxboxWindow::grabButtons() {
1154 GrabModeAsync, None, frame().theme().moveCursor()); 1161 GrabModeAsync, None, frame().theme().moveCursor());
1155 1162
1156 //----grab with "all" modifiers 1163 //----grab with "all" modifiers
1157 grabButton(display, Button1, frame().window().window(), frame().theme().moveCursor()); 1164 grabButton(Button1, frame().window().window(), frame().theme().moveCursor());
1158 1165
1159 XGrabButton(display, Button2, Mod1Mask, frame().window().window(), True, 1166 XGrabButton(display, Button2, Mod1Mask, frame().window().window(), True,
1160 ButtonReleaseMask, GrabModeAsync, GrabModeAsync, None, None); 1167 ButtonReleaseMask, GrabModeAsync, GrabModeAsync, None, None);
@@ -1164,7 +1171,7 @@ void FluxboxWindow::grabButtons() {
1164 GrabModeAsync, None, None); 1171 GrabModeAsync, None, None);
1165 1172
1166 //---grab with "all" modifiers 1173 //---grab with "all" modifiers
1167 grabButton(display, Button3, frame().window().window(), None); 1174 grabButton(Button3, frame().window().window(), None);
1168 } 1175 }
1169} 1176}
1170 1177
@@ -3772,14 +3779,13 @@ void FluxboxWindow::addExtraMenu(const char *label, FbTk::Menu *menu) {
3772} 3779}
3773 3780
3774void FluxboxWindow::removeExtraMenu(FbTk::Menu *menu) { 3781void FluxboxWindow::removeExtraMenu(FbTk::Menu *menu) {
3775 ExtraMenus::iterator it = m_extramenus.begin(); 3782 ExtraMenus::iterator it = find_if(m_extramenus.begin(),
3776 ExtraMenus::iterator it_end = m_extramenus.end(); 3783 m_extramenus.end(),
3777 for (; it != it_end; ++it) { 3784 Compose(bind2nd(equal_to<Menu *>(), menu),
3778 if (it->second == menu) { 3785 Select2nd<ExtraMenus::value_type>()));
3779 m_extramenus.erase(it); 3786 if (it != m_extramenus.end())
3780 break; 3787 m_extramenus.erase(it);
3781 } 3788
3782 }
3783 setupMenu(); 3789 setupMenu();
3784} 3790}
3785 3791