aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrathnor <rathnor>2003-05-04 23:38:06 (GMT)
committerrathnor <rathnor>2003-05-04 23:38:06 (GMT)
commit2ac0d82e451abd3cdc92df2a02c0da4eb8638ba1 (patch)
treeacb6c82d00dd1258773c45ef539f38b2f093e191 /src
parent65bbfbe51b9d8531490708e83ba422c7dc53dc1a (diff)
downloadfluxbox-2ac0d82e451abd3cdc92df2a02c0da4eb8638ba1.zip
fluxbox-2ac0d82e451abd3cdc92df2a02c0da4eb8638ba1.tar.bz2
fix up focus problems
Diffstat (limited to 'src')
-rw-r--r--src/Ewmh.cc6
-rw-r--r--src/Screen.cc37
-rw-r--r--src/Screen.hh3
-rw-r--r--src/WinClient.cc4
-rw-r--r--src/Workspace.cc6
-rw-r--r--src/fluxbox.cc60
-rw-r--r--src/fluxbox.hh3
7 files changed, 92 insertions, 27 deletions
diff --git a/src/Ewmh.cc b/src/Ewmh.cc
index 4fdede2..47a74c3 100644
--- a/src/Ewmh.cc
+++ b/src/Ewmh.cc
@@ -19,7 +19,7 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22// $Id: Ewmh.cc,v 1.18 2003/04/25 11:14:11 fluxgen Exp $ 22// $Id: Ewmh.cc,v 1.19 2003/05/04 23:38:06 rathnor Exp $
23 23
24#include "Ewmh.hh" 24#include "Ewmh.hh"
25 25
@@ -337,9 +337,7 @@ bool Ewmh::checkClientMessage(const XClientMessageEvent &ce, BScreen * screen, F
337 return true; 337 return true;
338 // ce.window = window to focus 338 // ce.window = window to focus
339 339
340 // should move set focus somewhere else 340 win->setInputFocus();
341 // so we don't need fluxbox depedencies here
342 Fluxbox::instance()->setFocusedWindow(win);
343 return true; 341 return true;
344 } else if (ce.message_type == m_net_close_window) { 342 } else if (ce.message_type == m_net_close_window) {
345 if (win == 0) 343 if (win == 0)
diff --git a/src/Screen.cc b/src/Screen.cc
index 7677ec9..28d1506 100644
--- a/src/Screen.cc
+++ b/src/Screen.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: Screen.cc,v 1.143 2003/05/04 13:04:31 rathnor Exp $ 25// $Id: Screen.cc,v 1.144 2003/05/04 23:38:06 rathnor Exp $
26 26
27 27
28#include "Screen.hh" 28#include "Screen.hh"
@@ -1069,12 +1069,6 @@ void BScreen::changeWorkspaceID(unsigned int id) {
1069 1069
1070 workspacemenu->setItemSelected(current_workspace->workspaceID() + 2, false); 1070 workspacemenu->setItemSelected(current_workspace->workspaceID() + 2, false);
1071 1071
1072 if (focused && &focused->getScreen() == this &&
1073 (! focused->isStuck()) && (!focused->isMoving())) {
1074 current_workspace->setLastFocusedWindow(focused);
1075 Fluxbox::instance()->setFocusedWindow(0); // set focused window to none
1076 }
1077
1078 // set new workspace 1072 // set new workspace
1079 current_workspace = getWorkspace(id); 1073 current_workspace = getWorkspace(id);
1080 1074
@@ -1084,13 +1078,10 @@ void BScreen::changeWorkspaceID(unsigned int id) {
1084 1078
1085 current_workspace->showAll(); 1079 current_workspace->showAll();
1086 1080
1087 if (*resource.focus_last && current_workspace->getLastFocusedWindow() && 1081 if (focused && (focused->isStuck() || focused->isMoving())) {
1088 !(focused && focused->isMoving())) {
1089 current_workspace->getLastFocusedWindow()->setInputFocus();
1090
1091 } else if (focused && (focused->isStuck() || focused->isMoving())) {
1092 focused->setInputFocus(); 1082 focused->setInputFocus();
1093 } 1083 } else
1084 Fluxbox::instance()->revertFocus(this);
1094 1085
1095 if (focused && focused->isMoving()) { 1086 if (focused && focused->isMoving()) {
1096 focused->resumeMoving(); 1087 focused->resumeMoving();
@@ -2432,6 +2423,26 @@ void BScreen::notifyReleasedKeys(XKeyEvent &ke) {
2432} 2423}
2433 2424
2434/** 2425/**
2426 * Used to find out which window was last focused on the given workspace
2427 * If workspace is outside the ID range, then the absolute last focused window
2428 * is given.
2429 */
2430WinClient *BScreen::getLastFocusedWindow(int workspace) {
2431 if (focused_list.empty()) return 0;
2432 if (workspace < 0 || workspace >= (int) getCount())
2433 return focused_list.front();
2434
2435 FocusedWindows::iterator it = focused_list.begin();
2436 FocusedWindows::iterator it_end = focused_list.end();
2437 for (; it != it_end; ++it)
2438 if ((*it)->fbwindow() &&
2439 (((int)(*it)->fbwindow()->getWorkspaceNumber()) == workspace
2440 || (*it)->fbwindow()->isStuck()))
2441 return *it;
2442 return 0;
2443}
2444
2445/**
2435 Access and clear the auto-group window 2446 Access and clear the auto-group window
2436*/ 2447*/
2437FluxboxWindow* BScreen::useAutoGroupWindow() { 2448FluxboxWindow* BScreen::useAutoGroupWindow() {
diff --git a/src/Screen.hh b/src/Screen.hh
index 59e2df4..16644fb 100644
--- a/src/Screen.hh
+++ b/src/Screen.hh
@@ -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: Screen.hh,v 1.89 2003/04/28 22:42:29 fluxgen Exp $ 25// $Id: Screen.hh,v 1.90 2003/05/04 23:38:06 rathnor Exp $
26 26
27#ifndef SCREEN_HH 27#ifndef SCREEN_HH
28#define SCREEN_HH 28#define SCREEN_HH
@@ -150,6 +150,7 @@ public:
150 inline Icons &getIconList() { return iconList; } 150 inline Icons &getIconList() { return iconList; }
151 inline const FocusedWindows &getFocusedList() const { return focused_list; } 151 inline const FocusedWindows &getFocusedList() const { return focused_list; }
152 inline FocusedWindows &getFocusedList() { return focused_list; } 152 inline FocusedWindows &getFocusedList() { return focused_list; }
153 WinClient *getLastFocusedWindow(int workspace = -1);
153 const Workspaces &getWorkspacesList() const { return workspacesList; } 154 const Workspaces &getWorkspacesList() const { return workspacesList; }
154 const WorkspaceNames &getWorkspaceNames() const { return workspaceNames; } 155 const WorkspaceNames &getWorkspaceNames() const { return workspaceNames; }
155 /** 156 /**
diff --git a/src/WinClient.cc b/src/WinClient.cc
index 6a41434..ac84c91 100644
--- a/src/WinClient.cc
+++ b/src/WinClient.cc
@@ -19,7 +19,7 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22// $Id: WinClient.cc,v 1.5 2003/04/27 02:26:21 rathnor Exp $ 22// $Id: WinClient.cc,v 1.6 2003/05/04 23:38:06 rathnor Exp $
23 23
24#include "WinClient.hh" 24#include "WinClient.hh"
25 25
@@ -71,8 +71,6 @@ WinClient::~WinClient() {
71 transient_for = 0; 71 transient_for = 0;
72 } 72 }
73 73
74 fluxbox->setFocusedWindow(transient_for);
75
76 if (transient_for != 0) { 74 if (transient_for != 0) {
77 FluxboxWindow::ClientList::iterator client_it = 75 FluxboxWindow::ClientList::iterator client_it =
78 transientFor()->clientList().begin(); 76 transientFor()->clientList().begin();
diff --git a/src/Workspace.cc b/src/Workspace.cc
index d8b77a4..ae986ad 100644
--- a/src/Workspace.cc
+++ b/src/Workspace.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: Workspace.cc,v 1.57 2003/05/04 13:07:17 rathnor Exp $ 25// $Id: Workspace.cc,v 1.58 2003/05/04 23:38:06 rathnor Exp $
26 26
27#include "Workspace.hh" 27#include "Workspace.hh"
28 28
@@ -218,7 +218,7 @@ int Workspace::removeWindow(FluxboxWindow *w) {
218 218
219 if (w->isFocused()) { 219 if (w->isFocused()) {
220 if (screen.isSloppyFocus()) { 220 if (screen.isSloppyFocus()) {
221 Fluxbox::instance()->setFocusedWindow(0); // set focused window to none 221 Fluxbox::instance()->revertFocus(&screen);
222 } else if (w->isTransient() && w->getTransientFor() && 222 } else if (w->isTransient() && w->getTransientFor() &&
223 w->getTransientFor()->isVisible()) { 223 w->getTransientFor()->isVisible()) {
224 w->getTransientFor()->setInputFocus(); 224 w->getTransientFor()->setInputFocus();
@@ -263,7 +263,7 @@ int Workspace::removeWindow(FluxboxWindow *w) {
263 } 263 }
264 */ 264 */
265 if (top == 0|| !top->setInputFocus()) { 265 if (top == 0|| !top->setInputFocus()) {
266 Fluxbox::instance()->setFocusedWindow(0); // set focused window to none 266 Fluxbox::instance()->revertFocus(&screen);
267 } 267 }
268 } 268 }
269 } 269 }
diff --git a/src/fluxbox.cc b/src/fluxbox.cc
index d26d8b3..19580d9 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.127 2003/05/04 16:55:40 rathnor Exp $ 25// $Id: fluxbox.cc,v 1.128 2003/05/04 23:38:06 rathnor Exp $
26 26
27#include "fluxbox.hh" 27#include "fluxbox.hh"
28 28
@@ -902,7 +902,7 @@ void Fluxbox::handleUnmapNotify(XUnmapEvent &ue) {
902 client = 0; // it's invalid now when win destroyed the client 902 client = 0; // it's invalid now when win destroyed the client
903 903
904 if (win == m_focused_window) 904 if (win == m_focused_window)
905 m_focused_window = 0; 905 revertFocus(&win->getScreen());
906 906
907 // finaly destroy window if empty 907 // finaly destroy window if empty
908 if (win->numClients() == 0) { 908 if (win->numClients() == 0) {
@@ -1492,6 +1492,8 @@ void Fluxbox::update(FbTk::Subject *changedsub) {
1492 // make sure each workspace get this 1492 // make sure each workspace get this
1493 BScreen &scr = win.getScreen(); 1493 BScreen &scr = win.getScreen();
1494 scr.removeWindow(&win); 1494 scr.removeWindow(&win);
1495 if (m_focused_window == &win)
1496 revertFocus(&scr);
1495 1497
1496 } else if ((&(win.workspaceSig())) == changedsub) { // workspace signal 1498 } else if ((&(win.workspaceSig())) == changedsub) { // workspace signal
1497 for (size_t i=0; i<m_atomhandler.size(); ++i) { 1499 for (size_t i=0; i<m_atomhandler.size(); ++i) {
@@ -2276,6 +2278,60 @@ void Fluxbox::setFocusedWindow(FluxboxWindow *win) {
2276 2278
2277} 2279}
2278 2280
2281/**
2282 * This function is called whenever we aren't quite sure what
2283 * focus is meant to be, it'll make things right ;-)
2284 * last_focused is set to something if we want to make use of the
2285 * previously focused window (it must NOT be set focused now, it
2286 * is probably dying).
2287 */
2288void Fluxbox::revertFocus(BScreen *screen) {
2289 // Relevant resources:
2290 // resource.focus_last = whether we focus last focused when changing workspace
2291 // Fluxbox::FocusModel = sloppy, click, whatever
2292
2293 // if no given screen, get it from the mouse
2294 if (screen == 0) {
2295 Window root = 0, ignorew;
2296 int ignored;
2297 BScreen *tempscr = m_screen_list.front();
2298 XQueryPointer(FbTk::App::instance()->display(),
2299 tempscr->getRootWindow(), &root, &ignorew, &ignored,
2300 &ignored, &ignored, &ignored, &((unsigned int) ignored));
2301 screen = searchScreen(root);
2302 if (screen == 0) {
2303#ifdef DEBUG
2304 cerr<<"No screen to base focus revert on!"<<endl;
2305#endif // DEBUG
2306 // flounder
2307 XSetInputFocus(FbTk::App::instance()->display(),
2308 PointerRoot, None, CurrentTime);
2309 return;
2310 }
2311 }
2312
2313 WinClient *next_focus = screen->getLastFocusedWindow(screen->getCurrentWorkspaceID());
2314
2315 if (next_focus && next_focus->fbwindow()) {
2316 next_focus->fbwindow()->setInputFocus();
2317 } else {
2318 switch (screen->getFocusModel()) {
2319 case SLOPPYFOCUS:
2320 case SEMISLOPPYFOCUS:
2321 XSetInputFocus(FbTk::App::instance()->display(),
2322 PointerRoot, None, CurrentTime);
2323 break;
2324 case CLICKTOFOCUS:
2325 XSetInputFocus(FbTk::App::instance()->display(),
2326 screen->getRootWindow(),
2327 RevertToPointerRoot, CurrentTime);
2328 break;
2329 }
2330 }
2331}
2332
2333
2334
2279void Fluxbox::watchKeyRelease(BScreen *screen, unsigned int mods) { 2335void Fluxbox::watchKeyRelease(BScreen *screen, unsigned int mods) {
2280 if (mods == 0) { 2336 if (mods == 0) {
2281 cerr<<"WARNING: attempt to grab without modifiers!"<<endl; 2337 cerr<<"WARNING: attempt to grab without modifiers!"<<endl;
diff --git a/src/fluxbox.hh b/src/fluxbox.hh
index 35f7c79..ae51e35 100644
--- a/src/fluxbox.hh
+++ b/src/fluxbox.hh
@@ -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.hh,v 1.52 2003/05/04 16:55:40 rathnor Exp $ 25// $Id: fluxbox.hh,v 1.53 2003/05/04 23:38:06 rathnor Exp $
26 26
27#ifndef FLUXBOX_HH 27#ifndef FLUXBOX_HH
28#define FLUXBOX_HH 28#define FLUXBOX_HH
@@ -143,6 +143,7 @@ public:
143 void watchKeyRelease(BScreen *screen, unsigned int mods); 143 void watchKeyRelease(BScreen *screen, unsigned int mods);
144 144
145 void setFocusedWindow(FluxboxWindow *w); 145 void setFocusedWindow(FluxboxWindow *w);
146 void revertFocus(BScreen *screen);
146 void shutdown(); 147 void shutdown();
147 void load_rc(BScreen &scr); 148 void load_rc(BScreen &scr);
148 void loadRootCommand(BScreen &scr); 149 void loadRootCommand(BScreen &scr);