aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrathnor <rathnor>2003-05-04 13:07:00 (GMT)
committerrathnor <rathnor>2003-05-04 13:07:00 (GMT)
commit6871d536eca0b95af281dafae5d59b535a7694ed (patch)
tree0c8bd03a6a7c8a62dfc3be8f265d850925cc9222 /src
parent1762dd8a0bc64c88942908dd87bd94f0fa910ae0 (diff)
downloadfluxbox-6871d536eca0b95af281dafae5d59b535a7694ed.zip
fluxbox-6871d536eca0b95af281dafae5d59b535a7694ed.tar.bz2
fix multiple screen keyactions to sometimes take effect on screen the pointer is on
Diffstat (limited to 'src')
-rw-r--r--src/fluxbox.cc113
1 files changed, 59 insertions, 54 deletions
diff --git a/src/fluxbox.cc b/src/fluxbox.cc
index 1886aa0..6b7d427 100644
--- a/src/fluxbox.cc
+++ b/src/fluxbox.cc
@@ -22,7 +22,7 @@
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
24 24
25// $Id: fluxbox.cc,v 1.125 2003/04/29 12:39:45 rathnor Exp $ 25// $Id: fluxbox.cc,v 1.126 2003/05/04 13:07:00 rathnor Exp $
26 26
27#include "fluxbox.hh" 27#include "fluxbox.hh"
28 28
@@ -984,9 +984,18 @@ void Fluxbox::handleClientMessage(XClientMessageEvent &ce) {
984void Fluxbox::handleKeyEvent(XKeyEvent &ke) { 984void Fluxbox::handleKeyEvent(XKeyEvent &ke) {
985 switch (ke.type) { 985 switch (ke.type) {
986 case KeyPress: { 986 case KeyPress: {
987 BScreen *screen = searchScreen(ke.window); 987 BScreen *keyscreen = searchScreen(ke.window);
988 988
989 if (screen == 0) 989 BScreen *mousescreen = keyscreen;
990 Window root, ignorew;
991 int ignored;
992 if (!XQueryPointer(FbTk::App::instance()->display(),
993 ke.window, &root, &ignorew, &ignored, &ignored,
994 &ignored, &ignored, &((unsigned int) ignored)))
995 // pointer on different screen to ke.window
996 mousescreen = searchScreen(root);
997
998 if (keyscreen == 0 || mousescreen == 0)
990 break; 999 break;
991 1000
992#ifdef DEBUG 1001#ifdef DEBUG
@@ -1035,60 +1044,59 @@ void Fluxbox::handleKeyEvent(XKeyEvent &ke) {
1035 switch (action) { 1044 switch (action) {
1036 case Keys::WORKSPACE: 1045 case Keys::WORKSPACE:
1037 // Workspace1 has id 0, hence -1 1046 // Workspace1 has id 0, hence -1
1038 screen->changeWorkspaceID(m_key->getParam()-1); 1047 mousescreen->changeWorkspaceID(m_key->getParam()-1);
1039 break; 1048 break;
1040 case Keys::SENDTOWORKSPACE: 1049 case Keys::SENDTOWORKSPACE:
1041 // Workspace1 has id 0, hence -1 1050 // Workspace1 has id 0, hence -1
1042 screen->sendToWorkspace(m_key->getParam()-1); 1051 keyscreen->sendToWorkspace(m_key->getParam()-1);
1043 break; 1052 break;
1044 // NOTE!!! The WORKSPACEn commands are not needed anymore 1053 // NOTE!!! The WORKSPACEn commands are not needed anymore
1045 case Keys::WORKSPACE1: 1054 case Keys::WORKSPACE1:
1046 screen->changeWorkspaceID(0); 1055 mousescreen->changeWorkspaceID(0);
1047 break; 1056 break;
1048 case Keys::WORKSPACE2: 1057 case Keys::WORKSPACE2:
1049 screen->changeWorkspaceID(1); 1058 mousescreen->changeWorkspaceID(1);
1050 break; 1059 break;
1051 case Keys::WORKSPACE3: 1060 case Keys::WORKSPACE3:
1052 screen->changeWorkspaceID(2); 1061 mousescreen->changeWorkspaceID(2);
1053 break; 1062 break;
1054 case Keys::WORKSPACE4: 1063 case Keys::WORKSPACE4:
1055 screen->changeWorkspaceID(3); 1064 mousescreen->changeWorkspaceID(3);
1056 break; 1065 break;
1057 case Keys::WORKSPACE5: 1066 case Keys::WORKSPACE5:
1058 screen->changeWorkspaceID(4); 1067 mousescreen->changeWorkspaceID(4);
1059 break; 1068 break;
1060 case Keys::WORKSPACE6: 1069 case Keys::WORKSPACE6:
1061 screen->changeWorkspaceID(5); 1070 mousescreen->changeWorkspaceID(5);
1062 break; 1071 break;
1063 case Keys::WORKSPACE7: 1072 case Keys::WORKSPACE7: mousescreen->changeWorkspaceID(6);
1064 screen->changeWorkspaceID(6);
1065 break; 1073 break;
1066 case Keys::WORKSPACE8: 1074 case Keys::WORKSPACE8:
1067 screen->changeWorkspaceID(7); 1075 mousescreen->changeWorkspaceID(7);
1068 break; 1076 break;
1069 case Keys::WORKSPACE9: 1077 case Keys::WORKSPACE9:
1070 screen->changeWorkspaceID(8); 1078 mousescreen->changeWorkspaceID(8);
1071 break; 1079 break;
1072 case Keys::WORKSPACE10: 1080 case Keys::WORKSPACE10:
1073 screen->changeWorkspaceID(9); 1081 mousescreen->changeWorkspaceID(9);
1074 break; 1082 break;
1075 case Keys::WORKSPACE11: 1083 case Keys::WORKSPACE11:
1076 screen->changeWorkspaceID(10); 1084 mousescreen->changeWorkspaceID(10);
1077 break; 1085 break;
1078 case Keys::WORKSPACE12: 1086 case Keys::WORKSPACE12:
1079 screen->changeWorkspaceID(11); 1087 mousescreen->changeWorkspaceID(11);
1080 break; 1088 break;
1081 case Keys::NEXTWORKSPACE: 1089 case Keys::NEXTWORKSPACE:
1082 screen->nextWorkspace(m_key->getParam()); 1090 mousescreen->nextWorkspace(m_key->getParam());
1083 break; 1091 break;
1084 case Keys::PREVWORKSPACE: 1092 case Keys::PREVWORKSPACE:
1085 screen->prevWorkspace(m_key->getParam()); 1093 mousescreen->prevWorkspace(m_key->getParam());
1086 break; 1094 break;
1087 case Keys::LEFTWORKSPACE: 1095 case Keys::LEFTWORKSPACE:
1088 screen->leftWorkspace(m_key->getParam()); 1096 mousescreen->leftWorkspace(m_key->getParam());
1089 break; 1097 break;
1090 case Keys::RIGHTWORKSPACE: 1098 case Keys::RIGHTWORKSPACE:
1091 screen->rightWorkspace(m_key->getParam()); 1099 mousescreen->rightWorkspace(m_key->getParam());
1092 break; 1100 break;
1093 case Keys::KILLWINDOW: //kill the current window 1101 case Keys::KILLWINDOW: //kill the current window
1094 if (m_focused_window) { 1102 if (m_focused_window) {
@@ -1100,47 +1108,47 @@ void Fluxbox::handleKeyEvent(XKeyEvent &ke) {
1100 { 1108 {
1101 unsigned int mods = Keys::cleanMods(ke.state); 1109 unsigned int mods = Keys::cleanMods(ke.state);
1102 if (mods == 0) { // can't stacked cycle unless there is a mod to grab 1110 if (mods == 0) { // can't stacked cycle unless there is a mod to grab
1103 screen->nextFocus(m_key->getParam() | BScreen::CYCLELINEAR); 1111 mousescreen->nextFocus(m_key->getParam() | BScreen::CYCLELINEAR);
1104 break; 1112 break;
1105 } 1113 }
1106 if (!m_watching_screen && !(m_key->getParam() & BScreen::CYCLELINEAR)) { 1114 if (!m_watching_screen && !(m_key->getParam() & BScreen::CYCLELINEAR)) {
1107 // if stacked cycling, then set a watch for 1115 // if stacked cycling, then set a watch for
1108 // the release of exactly these modifiers 1116 // the release of exactly these modifiers
1109 watchKeyRelease(screen, mods); 1117 watchKeyRelease(mousescreen, mods);
1110 } 1118 }
1111 screen->nextFocus(m_key->getParam()); 1119 mousescreen->nextFocus(m_key->getParam());
1112 break; 1120 break;
1113 } 1121 }
1114 case Keys::PREVWINDOW: //activate prev window 1122 case Keys::PREVWINDOW: //activate prev window
1115 { 1123 {
1116 unsigned int mods = Keys::cleanMods(ke.state); 1124 unsigned int mods = Keys::cleanMods(ke.state);
1117 if (mods == 0) { // can't stacked cycle unless there is a mod to grab 1125 if (mods == 0) { // can't stacked cycle unless there is a mod to grab
1118 screen->prevFocus(m_key->getParam() | BScreen::CYCLELINEAR); 1126 mousescreen->prevFocus(m_key->getParam() | BScreen::CYCLELINEAR);
1119 break; 1127 break;
1120 } 1128 }
1121 if (!m_watching_screen && !(m_key->getParam() & BScreen::CYCLELINEAR)) { 1129 if (!m_watching_screen && !(m_key->getParam() & BScreen::CYCLELINEAR)) {
1122 // if stacked cycling, then set a watch for 1130 // if stacked cycling, then set a watch for
1123 // the release of exactly these modifiers 1131 // the release of exactly these modifiers
1124 watchKeyRelease(screen, mods); 1132 watchKeyRelease(mousescreen, mods);
1125 } 1133 }
1126 screen->prevFocus(m_key->getParam()); 1134 mousescreen->prevFocus(m_key->getParam());
1127 break; 1135 break;
1128 } 1136 }
1129 case Keys::FOCUSUP: 1137 case Keys::FOCUSUP:
1130 if (m_focused_window) 1138 if (m_focused_window)
1131 screen->dirFocus(*m_focused_window, BScreen::FOCUSUP); 1139 keyscreen->dirFocus(*m_focused_window, BScreen::FOCUSUP);
1132 break; 1140 break;
1133 case Keys::FOCUSDOWN: 1141 case Keys::FOCUSDOWN:
1134 if (m_focused_window) 1142 if (m_focused_window)
1135 screen->dirFocus(*m_focused_window, BScreen::FOCUSDOWN); 1143 keyscreen->dirFocus(*m_focused_window, BScreen::FOCUSDOWN);
1136 break; 1144 break;
1137 case Keys::FOCUSLEFT: 1145 case Keys::FOCUSLEFT:
1138 if (m_focused_window) 1146 if (m_focused_window)
1139 screen->dirFocus(*m_focused_window, BScreen::FOCUSLEFT); 1147 keyscreen->dirFocus(*m_focused_window, BScreen::FOCUSLEFT);
1140 break; 1148 break;
1141 case Keys::FOCUSRIGHT: 1149 case Keys::FOCUSRIGHT:
1142 if (m_focused_window) 1150 if (m_focused_window)
1143 screen->dirFocus(*m_focused_window, BScreen::FOCUSRIGHT); 1151 keyscreen->dirFocus(*m_focused_window, BScreen::FOCUSRIGHT);
1144 break; 1152 break;
1145 case Keys::NEXTTAB: 1153 case Keys::NEXTTAB:
1146 if (m_focused_window && m_focused_window->numClients() > 1) 1154 if (m_focused_window && m_focused_window->numClients() > 1)
@@ -1166,16 +1174,16 @@ void Fluxbox::handleKeyEvent(XKeyEvent &ke) {
1166 case Keys::ATTACHLAST: 1174 case Keys::ATTACHLAST:
1167 //!! just attach last window to focused window 1175 //!! just attach last window to focused window
1168 if (m_focused_window) { 1176 if (m_focused_window) {
1169 Workspace *space = screen->getCurrentWorkspace(); 1177 Workspace *space = keyscreen->getCurrentWorkspace();
1170 Workspace::Windows &wins = space->getWindowList(); 1178 Workspace::Windows &wins = space->getWindowList();
1171 if (wins.size() == 1) 1179 if (wins.size() == 1)
1172 break; 1180 break;
1173 BScreen::FocusedWindows &fwins = screen->getFocusedList(); 1181 BScreen::FocusedWindows &fwins = keyscreen->getFocusedList();
1174 BScreen::FocusedWindows::iterator it = fwins.begin(); 1182 BScreen::FocusedWindows::iterator it = fwins.begin();
1175 for (; it != fwins.end(); ++it) { 1183 for (; it != fwins.end(); ++it) {
1176 if ((*it)->fbwindow() != m_focused_window && 1184 if ((*it)->fbwindow() != m_focused_window &&
1177 (*it)->fbwindow()->getWorkspaceNumber() == 1185 (*it)->fbwindow()->getWorkspaceNumber() ==
1178 screen->getCurrentWorkspaceID()) { 1186 keyscreen->getCurrentWorkspaceID()) {
1179 m_focused_window->attachClient(**it); 1187 m_focused_window->attachClient(**it);
1180 break; 1188 break;
1181 } 1189 }
@@ -1188,44 +1196,41 @@ void Fluxbox::handleKeyEvent(XKeyEvent &ke) {
1188 } 1196 }
1189 break; 1197 break;
1190 case Keys::EXECUTE: { //execute command on keypress 1198 case Keys::EXECUTE: { //execute command on keypress
1191 FbCommands::ExecuteCmd cmd(m_key->getExecCommand(), screen->getScreenNumber()); 1199 FbCommands::ExecuteCmd cmd(m_key->getExecCommand(), mousescreen->getScreenNumber());
1192 cmd.execute(); 1200 cmd.execute();
1193 } break; 1201 } break;
1194 case Keys::QUIT: 1202 case Keys::QUIT:
1195 shutdown(); 1203 shutdown();
1196 break; 1204 break;
1197 case Keys::ROOTMENU: { //show root menu 1205 case Keys::ROOTMENU: { //show root menu
1198 BScreen *screen = searchScreen(ke.window);
1199 if (screen == 0)
1200 break;
1201 1206
1202 //calculate placement of workspace menu 1207 //calculate placement of workspace menu
1203 //and show/hide it 1208 //and show/hide it
1204 int mx = ke.x_root - 1209 int mx = ke.x_root -
1205 (screen->getRootmenu()->width() / 2); 1210 (mousescreen->getRootmenu()->width() / 2);
1206 int my = ke.y_root - 1211 int my = ke.y_root -
1207 (screen->getRootmenu()->titleHeight() / 2); 1212 (mousescreen->getRootmenu()->titleHeight() / 2);
1208 1213
1209 if (mx < 0) mx = 0; 1214 if (mx < 0) mx = 0;
1210 if (my < 0) my = 0; 1215 if (my < 0) my = 0;
1211 1216
1212 if (mx + screen->getRootmenu()->width() > screen->getWidth()) { 1217 if (mx + mousescreen->getRootmenu()->width() > mousescreen->getWidth()) {
1213 mx = screen->getWidth() - 1218 mx = mousescreen->getWidth() -
1214 screen->getRootmenu()->width() - 1219 mousescreen->getRootmenu()->width() -
1215 screen->getRootmenu()->fbwindow().borderWidth(); 1220 mousescreen->getRootmenu()->fbwindow().borderWidth();
1216 } 1221 }
1217 1222
1218 if (my + screen->getRootmenu()->height() > 1223 if (my + mousescreen->getRootmenu()->height() >
1219 screen->getHeight()) { 1224 mousescreen->getHeight()) {
1220 my = screen->getHeight() - 1225 my = mousescreen->getHeight() -
1221 screen->getRootmenu()->height() - 1226 mousescreen->getRootmenu()->height() -
1222 screen->getRootmenu()->fbwindow().borderWidth(); 1227 mousescreen->getRootmenu()->fbwindow().borderWidth();
1223 } 1228 }
1224 screen->getRootmenu()->move(mx, my); 1229 mousescreen->getRootmenu()->move(mx, my);
1225 1230
1226 if (! screen->getRootmenu()->isVisible()) { 1231 if (! mousescreen->getRootmenu()->isVisible()) {
1227 checkMenu(); 1232 checkMenu();
1228 screen->getRootmenu()->show(); 1233 mousescreen->getRootmenu()->show();
1229 } 1234 }
1230 1235
1231 } break; 1236 } break;