aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/FbTk/KeyUtil.cc57
-rw-r--r--src/FbTk/KeyUtil.hh2
-rw-r--r--src/FocusControl.cc1
-rw-r--r--src/Screen.cc12
-rw-r--r--src/Window.cc96
5 files changed, 47 insertions, 121 deletions
diff --git a/src/FbTk/KeyUtil.cc b/src/FbTk/KeyUtil.cc
index b02a76b..3f413a9 100644
--- a/src/FbTk/KeyUtil.cc
+++ b/src/FbTk/KeyUtil.cc
@@ -118,44 +118,29 @@ void KeyUtil::grabKey(unsigned int key, unsigned int mod, Window win) {
118 const unsigned int nummod = instance().numlock(); 118 const unsigned int nummod = instance().numlock();
119 const unsigned int scrollmod = instance().scrolllock(); 119 const unsigned int scrollmod = instance().scrolllock();
120 120
121 XGrabKey(display, key, mod,
122 win, True,
123 GrabModeAsync, GrabModeAsync);
124
125 // Grab with numlock, capslock and scrlock 121 // Grab with numlock, capslock and scrlock
122 for (int i = 0; i < 8; i++) {
123 XGrabKey(display, key, mod | (i & 1 ? capsmod : 0) |
124 (i & 2 ? nummod : 0) | (i & 4 ? scrollmod : 0),
125 win, True, GrabModeAsync, GrabModeAsync);
126 }
127
128}
126 129
127 //numlock 130void KeyUtil::grabButton(unsigned int button, unsigned int mod, Window win,
128 XGrabKey(display, key, mod|nummod, 131 unsigned int event_mask, Cursor cursor) {
129 win, True, 132 Display *display = App::instance()->display();
130 GrabModeAsync, GrabModeAsync); 133 const unsigned int capsmod = instance().capslock();
131 //scrolllock 134 const unsigned int nummod = instance().numlock();
132 XGrabKey(display, key, mod|scrollmod, 135 const unsigned int scrollmod = instance().scrolllock();
133 win, True, 136
134 GrabModeAsync, GrabModeAsync); 137 // Grab with numlock, capslock and scrlock
135 //capslock 138 for (int i = 0; i < 8; i++) {
136 XGrabKey(display, key, mod|capsmod, 139 XGrabButton(display, button, mod | (i & 1 ? capsmod : 0) |
137 win, True, 140 (i & 2 ? nummod : 0) | (i & 4 ? scrollmod : 0),
138 GrabModeAsync, GrabModeAsync); 141 win, True, event_mask, GrabModeAsync, GrabModeAsync,
139 142 None, cursor);
140 //capslock+numlock 143 }
141 XGrabKey(display, key, mod|capsmod|nummod,
142 win, True,
143 GrabModeAsync, GrabModeAsync);
144
145 //capslock+scrolllock
146 XGrabKey(display, key, mod|capsmod|scrollmod,
147 win, True,
148 GrabModeAsync, GrabModeAsync);
149
150 //capslock+numlock+scrolllock
151 XGrabKey(display, key, mod|capsmod|scrollmod|nummod,
152 win, True,
153 GrabModeAsync, GrabModeAsync);
154
155 //numlock+scrollLock
156 XGrabKey(display, key, mod|nummod|scrollmod,
157 win, True,
158 GrabModeAsync, GrabModeAsync);
159 144
160} 145}
161 146
diff --git a/src/FbTk/KeyUtil.hh b/src/FbTk/KeyUtil.hh
index 902d27e..eb2cdd5 100644
--- a/src/FbTk/KeyUtil.hh
+++ b/src/FbTk/KeyUtil.hh
@@ -44,6 +44,8 @@ public:
44 Grab the specified key 44 Grab the specified key
45 */ 45 */
46 static void grabKey(unsigned int key, unsigned int mod, Window win); 46 static void grabKey(unsigned int key, unsigned int mod, Window win);
47 static void grabButton(unsigned int button, unsigned int mod, Window win,
48 unsigned int event_mask, Cursor cursor = None);
47 49
48 /** 50 /**
49 convert the string to the keysym 51 convert the string to the keysym
diff --git a/src/FocusControl.cc b/src/FocusControl.cc
index 21c243d..29a1b8b 100644
--- a/src/FocusControl.cc
+++ b/src/FocusControl.cc
@@ -193,6 +193,7 @@ void FocusControl::stopCyclingFocus() {
193 m_cycling_window = find(m_focused_list.begin(),m_focused_list.end(),*m_cycling_window); 193 m_cycling_window = find(m_focused_list.begin(),m_focused_list.end(),*m_cycling_window);
194 if (m_cycling_window != m_focused_list.end() && 194 if (m_cycling_window != m_focused_list.end() &&
195 m_cycling_window != m_creation_order_list.end() && 195 m_cycling_window != m_creation_order_list.end() &&
196 (*m_cycling_window)->fbwindow() &&
196 (*m_cycling_window)->fbwindow()->isVisible()) { 197 (*m_cycling_window)->fbwindow()->isVisible()) {
197 WinClient *client = *m_cycling_window; 198 WinClient *client = *m_cycling_window;
198 m_focused_list.erase(m_cycling_window); 199 m_focused_list.erase(m_cycling_window);
diff --git a/src/Screen.cc b/src/Screen.cc
index 7c0bed9..90d0a4a 100644
--- a/src/Screen.cc
+++ b/src/Screen.cc
@@ -1404,7 +1404,8 @@ FluxboxWindow *BScreen::createWindow(Window client) {
1404 } 1404 }
1405 1405
1406 // add the window to the focus list 1406 // add the window to the focus list
1407 if (focusControl().focusNew()) 1407 // always add to front on startup to keep the focus order the same
1408 if (focusControl().focusNew() || Fluxbox::instance()->isStartup())
1408 focusControl().addFocusFront(*winclient); 1409 focusControl().addFocusFront(*winclient);
1409 else 1410 else
1410 focusControl().addFocusBack(*winclient); 1411 focusControl().addFocusBack(*winclient);
@@ -1435,7 +1436,7 @@ FluxboxWindow *BScreen::createWindow(WinClient &client) {
1435 1436
1436#ifdef SLIT 1437#ifdef SLIT
1437 if (win->initialState() == WithdrawnState && slit() != 0) { 1438 if (win->initialState() == WithdrawnState && slit() != 0) {
1438 slit()->addClient(win->clientWindow()); 1439 slit()->addClient(client.window());
1439 } 1440 }
1440#endif // SLIT 1441#endif // SLIT
1441 1442
@@ -1445,8 +1446,11 @@ FluxboxWindow *BScreen::createWindow(WinClient &client) {
1445 return 0; 1446 return 0;
1446 } 1447 }
1447 1448
1448 // can't setInputFocus yet and mapNotifyEvent doesn't happen for the client 1449 win->show();
1449 if (focusControl().focusNew() || FocusControl::focusedWindow() == &client) 1450 // don't ask me why, but client doesn't seem to keep focus in new window
1451 // and we don't seem to get a FocusIn event from setInputFocus
1452 if ((focusControl().focusNew() || FocusControl::focusedWindow() == &client)
1453 && win->setInputFocus())
1450 FocusControl::setFocusedWindow(&client); 1454 FocusControl::setFocusedWindow(&client);
1451 1455
1452 m_clientlist_sig.notify(); 1456 m_clientlist_sig.notify();
diff --git a/src/Window.cc b/src/Window.cc
index 5634f8f..bb271c3 100644
--- a/src/Window.cc
+++ b/src/Window.cc
@@ -104,57 +104,6 @@ using std::hex;
104 104
105namespace { 105namespace {
106 106
107void grabButton(unsigned int button,
108 Window window, Cursor cursor) {
109
110 static Display *display = App::instance()->display();
111
112 const int numlock = KeyUtil::instance().numlock();
113 const int capslock = KeyUtil::instance().capslock();
114 const int scrolllock = KeyUtil::instance().scrolllock();
115
116 // Grab with modkey and with all lock modifiers
117 // (num, scroll and caps)
118
119 unsigned int modkey = Fluxbox::instance()->getModKey();
120
121 //numlock
122 XGrabButton(display, button, modkey|numlock, window, True,
123 ButtonReleaseMask | ButtonMotionMask, GrabModeAsync,
124 GrabModeAsync, None, cursor);
125 //scrolllock
126 XGrabButton(display, button, modkey|scrolllock, window, True,
127 ButtonReleaseMask | ButtonMotionMask, GrabModeAsync,
128 GrabModeAsync, None, cursor);
129
130 //capslock
131 XGrabButton(display, button, modkey|capslock, window, True,
132 ButtonReleaseMask | ButtonMotionMask, GrabModeAsync,
133 GrabModeAsync, None, cursor);
134
135 //capslock+numlock
136 XGrabButton(display, Button1, modkey|capslock|numlock, window, True,
137 ButtonReleaseMask | ButtonMotionMask, GrabModeAsync,
138 GrabModeAsync, None, cursor);
139
140 //capslock+scrolllock
141 XGrabButton(display, button, modkey|capslock|scrolllock, window, True,
142 ButtonReleaseMask | ButtonMotionMask, GrabModeAsync,
143 GrabModeAsync, None, cursor);
144
145 //capslock+numlock+scrolllock
146 XGrabButton(display, button, modkey|capslock|numlock|scrolllock, window,
147 True,
148 ButtonReleaseMask | ButtonMotionMask, GrabModeAsync,
149 GrabModeAsync, None, cursor);
150
151 //numlock+scrollLock
152 XGrabButton(display, button, modkey|numlock|scrolllock, window, True,
153 ButtonReleaseMask | ButtonMotionMask, GrabModeAsync,
154 GrabModeAsync, None, cursor);
155
156}
157
158// X event scanner for enter/leave notifies - adapted from twm 107// X event scanner for enter/leave notifies - adapted from twm
159typedef struct scanargs { 108typedef struct scanargs {
160 Window w; 109 Window w;
@@ -402,8 +351,7 @@ void FluxboxWindow::init() {
402 351
403 assert(m_client); 352 assert(m_client);
404 m_client->setFluxboxWindow(this); 353 m_client->setFluxboxWindow(this);
405 if (!m_client->hasGroupLeftWindow()) 354 m_client->setGroupLeftWindow(None); // nothing to the left.
406 m_client->setGroupLeftWindow(None); // nothing to the left.
407 355
408 // check for shape extension and whether the window is shaped 356 // check for shape extension and whether the window is shaped
409 m_shaped = false; 357 m_shaped = false;
@@ -702,10 +650,10 @@ void FluxboxWindow::attachClient(WinClient &client, int x, int y) {
702 frame().clientArea().width(), 650 frame().clientArea().width(),
703 frame().clientArea().height()); 651 frame().clientArea().height());
704 652
705 if (&client == FocusControl::focusedWindow()) { 653 // right now, this block only happens with new windows or on restart
706 was_focused = true; 654 if (screen().focusControl().focusNew() ||
655 Fluxbox::instance()->isStartup())
707 focused_win = &client; 656 focused_win = &client;
708 }
709 657
710 client.saveBlackboxAttribs(m_blackbox_attrib); 658 client.saveBlackboxAttribs(m_blackbox_attrib);
711 m_clientlist.push_back(&client); 659 m_clientlist.push_back(&client);
@@ -718,16 +666,15 @@ void FluxboxWindow::attachClient(WinClient &client, int x, int y) {
718 m_workspacesig.notify(); 666 m_workspacesig.notify();
719 m_layersig.notify(); 667 m_layersig.notify();
720 668
721 if (was_focused) 669 if (was_focused) {
722 // already has focus, we're just assuming the state of the old window 670 // don't ask me why, but client doesn't seem to keep focus in new window
671 // and we don't seem to get a FocusIn event from setInputFocus
672 setCurrentClient(client);
723 FocusControl::setFocusedWindow(&client); 673 FocusControl::setFocusedWindow(&client);
674 } else if (focused_win)
675 setCurrentClient(*focused_win, false);
724 676
725 frame().reconfigure(); 677 frame().reconfigure();
726
727 // keep the current window on top
728 if (focused_win)
729 m_client = focused_win;
730 m_client->raise();
731} 678}
732 679
733 680
@@ -748,11 +695,7 @@ bool FluxboxWindow::detachClient(WinClient &client) {
748 (*client_it_after)->setGroupLeftWindow(leftwin); 695 (*client_it_after)->setGroupLeftWindow(leftwin);
749 696
750 removeClient(client); 697 removeClient(client);
751 698 screen().createWindow(client);
752 // m_client must be valid as there should be at least one other window
753 // otherwise this wouldn't be here (refer numClients() <= 1 return)
754 client.setFluxboxWindow(screen().createWindow(client));
755 client.setGroupLeftWindow(None);
756 return true; 699 return true;
757} 700}
758 701
@@ -1123,22 +1066,16 @@ void FluxboxWindow::grabButtons() {
1123 unsigned int modkey = Fluxbox::instance()->getModKey(); 1066 unsigned int modkey = Fluxbox::instance()->getModKey();
1124 1067
1125 if (modkey) { 1068 if (modkey) {
1126 XGrabButton(display, Button1, modkey, frame().window().window(), True,
1127 ButtonReleaseMask | ButtonMotionMask, GrabModeAsync,
1128 GrabModeAsync, None, frame().theme().moveCursor());
1129
1130 //----grab with "all" modifiers 1069 //----grab with "all" modifiers
1131 grabButton(Button1, frame().window().window(), frame().theme().moveCursor()); 1070 FbTk::KeyUtil::grabButton(Button1, modkey, frame().window().window(),
1071 ButtonReleaseMask | ButtonMotionMask, frame().theme().moveCursor());
1132 1072
1133 XGrabButton(display, Button2, modkey, frame().window().window(), True, 1073 XGrabButton(display, Button2, modkey, frame().window().window(), True,
1134 ButtonReleaseMask, GrabModeAsync, GrabModeAsync, None, None); 1074 ButtonReleaseMask, GrabModeAsync, GrabModeAsync, None, None);
1135 1075
1136 XGrabButton(display, Button3, modkey, frame().window().window(), True,
1137 ButtonReleaseMask | ButtonMotionMask, GrabModeAsync,
1138 GrabModeAsync, None, None);
1139
1140 //---grab with "all" modifiers 1076 //---grab with "all" modifiers
1141 grabButton(Button3, frame().window().window(), None); 1077 FbTk::KeyUtil::grabButton(Button3, modkey, frame().window().window(),
1078 ButtonReleaseMask | ButtonMotionMask);
1142 } 1079 }
1143} 1080}
1144 1081
@@ -3641,9 +3578,6 @@ void FluxboxWindow::attachTo(int x, int y, bool interrupted) {
3641 // since just detached, move relative to old location 3578 // since just detached, move relative to old location
3642 if (client.fbwindow() != 0) { 3579 if (client.fbwindow() != 0) {
3643 client.fbwindow()->move(frame().x() - m_last_resize_x + x, frame().y() - m_last_resize_y + y); 3580 client.fbwindow()->move(frame().x() - m_last_resize_x + x, frame().y() - m_last_resize_y + y);
3644 client.fbwindow()->show();
3645 FocusControl::setFocusedWindow(&client);
3646 client.fbwindow()->setInputFocus();
3647 } 3581 }
3648 } else if( attach_to_win == this && attach_to_win->isTabable()) { 3582 } else if( attach_to_win == this && attach_to_win->isTabable()) {
3649 //reording of tabs within a frame 3583 //reording of tabs within a frame