aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrathnor <rathnor>2004-03-21 09:00:25 (GMT)
committerrathnor <rathnor>2004-03-21 09:00:25 (GMT)
commitdea3281e6917601a81df7833457a942b875b8e49 (patch)
tree09878620d13c944a2a6af724dc3b3366984bac2f /src
parent2d82374b2f458c32895b093aff8c77e88daea2ba (diff)
downloadfluxbox_pavel-dea3281e6917601a81df7833457a942b875b8e49.zip
fluxbox_pavel-dea3281e6917601a81df7833457a942b875b8e49.tar.bz2
primarily focus fix/tweak/rejigging
Diffstat (limited to 'src')
-rw-r--r--src/FbWinFrame.cc7
-rw-r--r--src/Screen.cc32
-rw-r--r--src/Screen.hh3
-rw-r--r--src/Window.cc30
-rw-r--r--src/Window.hh4
-rw-r--r--src/Workspace.cc32
-rw-r--r--src/Workspace.hh2
-rw-r--r--src/fluxbox.cc62
-rw-r--r--src/fluxbox.hh4
9 files changed, 114 insertions, 62 deletions
diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc
index 9b8b7e7..8d93184 100644
--- a/src/FbWinFrame.cc
+++ b/src/FbWinFrame.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: FbWinFrame.cc,v 1.76 2004/02/28 16:54:04 fluxgen Exp $ 22// $Id: FbWinFrame.cc,v 1.77 2004/03/21 09:00:24 rathnor Exp $
23 23
24#include "FbWinFrame.hh" 24#include "FbWinFrame.hh"
25 25
@@ -301,10 +301,11 @@ void FbWinFrame::removeLabelButton(FbTk::TextButton &btn) {
301 if (erase_it == m_labelbuttons.end()) 301 if (erase_it == m_labelbuttons.end())
302 return; 302 return;
303 303
304 if (&btn == m_current_label)
305 m_current_label = 0;
306
304 m_labelbuttons.erase(erase_it); 307 m_labelbuttons.erase(erase_it);
305 308
306 if (*erase_it == m_current_label)
307 m_current_label = 0;
308} 309}
309 310
310 311
diff --git a/src/Screen.cc b/src/Screen.cc
index 4fb6576..8c01402 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.269 2004/03/18 14:45:56 fluxgen Exp $ 25// $Id: Screen.cc,v 1.270 2004/03/21 09:00:24 rathnor Exp $
26 26
27 27
28#include "Screen.hh" 28#include "Screen.hh"
@@ -937,7 +937,7 @@ void BScreen::removeWindow(FluxboxWindow *win) {
937 if (win->isIconic()) 937 if (win->isIconic())
938 removeIcon(win); 938 removeIcon(win);
939 else 939 else
940 getWorkspace(win->workspaceNumber())->removeWindow(win); 940 getWorkspace(win->workspaceNumber())->removeWindow(win, false);
941} 941}
942 942
943 943
@@ -951,13 +951,6 @@ void BScreen::removeClient(WinClient &client) {
951 focused_list.remove(&client); 951 focused_list.remove(&client);
952 if (cyc == &client) { 952 if (cyc == &client) {
953 cycling_window = focused_list.end(); 953 cycling_window = focused_list.end();
954 } else if (focused == &client) {
955 // if we are focused, then give our focus to our transient parent
956 // or revert normally
957 if (client.transientFor() && client.transientFor()->fbwindow())
958 client.transientFor()->fbwindow()->setInputFocus();
959 else
960 Fluxbox::instance()->revertFocus(focused->screen());
961 } 954 }
962 955
963 if (cycling_last == &client) 956 if (cycling_last == &client)
@@ -1471,7 +1464,7 @@ void BScreen::reassociateWindow(FluxboxWindow *w, unsigned int wkspc_id,
1471 // gets updated 1464 // gets updated
1472 m_clientlist_sig.notify(); 1465 m_clientlist_sig.notify();
1473 } else if (ignore_sticky || ! w->isStuck()) { 1466 } else if (ignore_sticky || ! w->isStuck()) {
1474 getWorkspace(w->workspaceNumber())->removeWindow(w); 1467 getWorkspace(w->workspaceNumber())->removeWindow(w, true);
1475 getWorkspace(wkspc_id)->addWindow(*w); 1468 getWorkspace(wkspc_id)->addWindow(*w);
1476 // see comment above 1469 // see comment above
1477 m_clientlist_sig.notify(); 1470 m_clientlist_sig.notify();
@@ -2544,8 +2537,25 @@ WinClient *BScreen::getLastFocusedWindow(int workspace) {
2544 return 0; 2537 return 0;
2545} 2538}
2546 2539
2540/**
2541 * Used to find out which window was last active in the given group
2542 * If ignore_client is given, it excludes that client.
2543 * Stuck, iconic etc don't matter within a group
2544 */
2545WinClient *BScreen::getLastFocusedWindow(FluxboxWindow &group, WinClient *ignore_client) {
2546 if (focused_list.empty()) return 0;
2547
2548 FocusedWindows::iterator it = focused_list.begin();
2549 FocusedWindows::iterator it_end = focused_list.end();
2550 for (; it != it_end; ++it) {
2551 if (((*it)->fbwindow() == &group) &&
2552 (*it) != ignore_client)
2553 return *it;
2554 }
2555 return 0;
2556}
2557
2547void BScreen::updateSize() { 2558void BScreen::updateSize() {
2548 cerr<<"update Size"<<endl;
2549 // force update geometry 2559 // force update geometry
2550 rootWindow().updateGeometry(); 2560 rootWindow().updateGeometry();
2551 2561
diff --git a/src/Screen.hh b/src/Screen.hh
index ced6f66..070c45a 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.134 2004/01/19 18:28:58 fluxgen Exp $ 25// $Id: Screen.hh,v 1.135 2004/03/21 09:00:25 rathnor Exp $
26 26
27#ifndef SCREEN_HH 27#ifndef SCREEN_HH
28#define SCREEN_HH 28#define SCREEN_HH
@@ -147,6 +147,7 @@ public:
147 inline const FocusedWindows &getFocusedList() const { return focused_list; } 147 inline const FocusedWindows &getFocusedList() const { return focused_list; }
148 inline FocusedWindows &getFocusedList() { return focused_list; } 148 inline FocusedWindows &getFocusedList() { return focused_list; }
149 WinClient *getLastFocusedWindow(int workspace = -1); 149 WinClient *getLastFocusedWindow(int workspace = -1);
150 WinClient *getLastFocusedWindow(FluxboxWindow &group, WinClient *ignore_client = 0);
150 const Workspaces &getWorkspacesList() const { return m_workspaces_list; } 151 const Workspaces &getWorkspacesList() const { return m_workspaces_list; }
151 Workspaces &getWorkspacesList() { return m_workspaces_list; } 152 Workspaces &getWorkspacesList() { return m_workspaces_list; }
152 const WorkspaceNames &getWorkspaceNames() const { return m_workspace_names; } 153 const WorkspaceNames &getWorkspaceNames() const { return m_workspace_names; }
diff --git a/src/Window.cc b/src/Window.cc
index 6d9a344..5a93385 100644
--- a/src/Window.cc
+++ b/src/Window.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: Window.cc,v 1.270 2004/03/08 12:20:31 rathnor Exp $ 25// $Id: Window.cc,v 1.271 2004/03/21 09:00:25 rathnor Exp $
26 26
27#include "Window.hh" 27#include "Window.hh"
28 28
@@ -784,15 +784,11 @@ bool FluxboxWindow::removeClient(WinClient &client) {
784 784
785 // if it is our active client, deal with it... 785 // if it is our active client, deal with it...
786 if (m_client == &client) { 786 if (m_client == &client) {
787 // set next client to be focused 787 WinClient *next_client = screen().getLastFocusedWindow(*this, m_client);
788 // if the client we're about to remove is the last client then set prev client 788 if (next_client != 0)
789 if (&client == m_clientlist.back()) 789 setCurrentClient(*next_client, false);
790 prevClient();
791 else
792 nextClient();
793 } 790 }
794 791
795 client.m_win = 0;
796 m_clientlist.remove(&client); 792 m_clientlist.remove(&client);
797 793
798 if (m_client == &client) { 794 if (m_client == &client) {
@@ -815,12 +811,12 @@ bool FluxboxWindow::removeClient(WinClient &client) {
815 } 811 }
816 812
817 m_labelbuttons.erase(&client); 813 m_labelbuttons.erase(&client);
818
819 frame().reconfigure(); 814 frame().reconfigure();
815 updateClientLeftWindow();
820 816
821#ifdef DEBUG 817#ifdef DEBUG
822 cerr<<__FILE__<<"("<<__FUNCTION__<<")["<<this<<"] numClients = "<<numClients()<<endl; 818 cerr<<__FILE__<<"("<<__FUNCTION__<<")["<<this<<"] numClients = "<<numClients()<<endl;
823#endif // DEBUG 819#endif // DEBUG
824 820
825 return true; 821 return true;
826} 822}
@@ -905,6 +901,9 @@ void FluxboxWindow::moveClientRight() {
905 901
906/// Update LEFT window atom on all clients. 902/// Update LEFT window atom on all clients.
907void FluxboxWindow::updateClientLeftWindow() { 903void FluxboxWindow::updateClientLeftWindow() {
904 if (clientList().empty())
905 return;
906
908 // It should just update the affected clients but that 907 // It should just update the affected clients but that
909 // would require more complex code and we're assuming 908 // would require more complex code and we're assuming
910 // the user dont have alot of windows grouped so this 909 // the user dont have alot of windows grouped so this
@@ -929,8 +928,11 @@ bool FluxboxWindow::setCurrentClient(WinClient &client, bool setinput) {
929 928
930 m_client = &client; 929 m_client = &client;
931 m_client->raise(); 930 m_client->raise();
931
932 // frame focused doesn't necessarily mean input focused
933 frame().setLabelButtonFocus(*m_labelbuttons[m_client]);
934
932 if (setinput && setInputFocus()) { 935 if (setinput && setInputFocus()) {
933 frame().setLabelButtonFocus(*m_labelbuttons[m_client]);
934 return true; 936 return true;
935 } 937 }
936 938
@@ -1242,7 +1244,6 @@ bool FluxboxWindow::setInputFocus() {
1242 } else { 1244 } else {
1243 ret = m_client->sendFocus(); 1245 ret = m_client->sendFocus();
1244 } 1246 }
1245
1246 1247
1247 return ret; 1248 return ret;
1248} 1249}
@@ -1296,10 +1297,7 @@ void FluxboxWindow::iconify() {
1296 } 1297 }
1297 } 1298 }
1298 1299
1299 WinClient *focused_client = Fluxbox::instance()->getFocusedWindow(); 1300 // focus revert is done elsewhere (based on signal)
1300 if (focused_client && focused_client->fbwindow() == this)
1301 Fluxbox::instance()->revertFocus(screen());
1302
1303} 1301}
1304 1302
1305void FluxboxWindow::deiconify(bool reassoc, bool do_raise) { 1303void FluxboxWindow::deiconify(bool reassoc, bool do_raise) {
diff --git a/src/Window.hh b/src/Window.hh
index f6cb3d0..0c80669 100644
--- a/src/Window.hh
+++ b/src/Window.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: Window.hh,v 1.109 2004/02/20 09:07:27 fluxgen Exp $ 25// $Id: Window.hh,v 1.110 2004/03/21 09:00:25 rathnor Exp $
26 26
27#ifndef WINDOW_HH 27#ifndef WINDOW_HH
28#define WINDOW_HH 28#define WINDOW_HH
@@ -281,6 +281,7 @@ public:
281 inline bool isResizing() const { return resizing; } 281 inline bool isResizing() const { return resizing; }
282 bool isGroupable() const; 282 bool isGroupable() const;
283 inline int numClients() const { return m_clientlist.size(); } 283 inline int numClients() const { return m_clientlist.size(); }
284 inline bool empty() const { return m_clientlist.empty(); }
284 inline ClientList &clientList() { return m_clientlist; } 285 inline ClientList &clientList() { return m_clientlist; }
285 inline const ClientList &clientList() const { return m_clientlist; } 286 inline const ClientList &clientList() const { return m_clientlist; }
286 inline WinClient &winClient() { return *m_client; } 287 inline WinClient &winClient() { return *m_client; }
@@ -370,6 +371,7 @@ public:
370 }; 371 };
371 372
372 bool oplock; ///< Used to help stop transient loops occurring by locking a window during certain operations 373 bool oplock; ///< Used to help stop transient loops occurring by locking a window during certain operations
374
373private: 375private:
374 static const int PropBlackboxAttributesElements = 8; 376 static const int PropBlackboxAttributesElements = 8;
375 377
diff --git a/src/Workspace.cc b/src/Workspace.cc
index 33818ad..da6d9c1 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.94 2004/03/15 23:36:13 rathnor Exp $ 25// $Id: Workspace.cc,v 1.95 2004/03/21 09:00:25 rathnor Exp $
26 26
27#include "Workspace.hh" 27#include "Workspace.hh"
28 28
@@ -167,8 +167,11 @@ void Workspace::addWindow(FluxboxWindow &w, bool place) {
167 167
168} 168}
169 169
170 170// still_alive is true if the window will continue to exist after
171int Workspace::removeWindow(FluxboxWindow *w) { 171// this event. Particularly, this isn't the removeWindow for
172// the destruction of the window. Because if so, the focus revert
173// is done in another place
174int Workspace::removeWindow(FluxboxWindow *w, bool still_alive) {
172 175
173 if (w == 0) 176 if (w == 0)
174 return -1; 177 return -1;
@@ -180,27 +183,8 @@ int Workspace::removeWindow(FluxboxWindow *w) {
180 m_lastfocus = 0; 183 m_lastfocus = 0;
181 } 184 }
182 185
183 if (w->isFocused()) { 186 if (w->isFocused() && still_alive)
184 if (screen().isSloppyFocus()) { 187 Fluxbox::instance()->unfocusWindow(w->winClient(), true, true);
185 Fluxbox::instance()->revertFocus(screen());
186 } else {
187 // go up the transient tree looking for a focusable window
188 WinClient *client = 0;
189 if (w->numClients() > 0) {
190 client = w->winClient().transientFor();
191 while (client) {
192 if (client->fbwindow() &&
193 client->fbwindow() != w && // can't be this window
194 client->fbwindow()->isVisible() &&
195 client->fbwindow()->setCurrentClient(*client, true))
196 break;
197 client = client->transientFor();
198 }
199 }
200 if (client == 0) // we were unsuccessful
201 Fluxbox::instance()->revertFocus(screen());
202 }
203 }
204 188
205 // we don't remove it from the layermanager, as it may be being moved 189 // we don't remove it from the layermanager, as it may be being moved
206 Windows::iterator erase_it = remove(m_windowlist.begin(), 190 Windows::iterator erase_it = remove(m_windowlist.begin(),
diff --git a/src/Workspace.hh b/src/Workspace.hh
index 55479b3..c2b02f3 100644
--- a/src/Workspace.hh
+++ b/src/Workspace.hh
@@ -62,7 +62,7 @@ public:
62 void reconfigure(); 62 void reconfigure();
63 void shutdown(); 63 void shutdown();
64 void addWindow(FluxboxWindow &win, bool place = false); 64 void addWindow(FluxboxWindow &win, bool place = false);
65 int removeWindow(FluxboxWindow *win); 65 int removeWindow(FluxboxWindow *win, bool still_alive);
66 void updateClientmenu(); 66 void updateClientmenu();
67 67
68 BScreen &screen() { return m_screen; } 68 BScreen &screen() { return m_screen; }
diff --git a/src/fluxbox.cc b/src/fluxbox.cc
index dd70d6c..d32840a 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.234 2004/03/03 12:53:06 rathnor Exp $ 25// $Id: fluxbox.cc,v 1.235 2004/03/21 09:00:25 rathnor Exp $
26 26
27#include "fluxbox.hh" 27#include "fluxbox.hh"
28 28
@@ -1321,7 +1321,7 @@ void Fluxbox::update(FbTk::Subject *changedsub) {
1321 if (win.isIconic()) { 1321 if (win.isIconic()) {
1322 Workspace *space = win.screen().getWorkspace(win.workspaceNumber()); 1322 Workspace *space = win.screen().getWorkspace(win.workspaceNumber());
1323 if (space != 0) 1323 if (space != 0)
1324 space->removeWindow(&win); 1324 space->removeWindow(&win, true);
1325 win.screen().addIcon(&win); 1325 win.screen().addIcon(&win);
1326 } 1326 }
1327 1327
@@ -1409,8 +1409,14 @@ void Fluxbox::update(FbTk::Subject *changedsub) {
1409 // finaly send notify signal 1409 // finaly send notify signal
1410 screen.updateNetizenWindowDel(client.window()); 1410 screen.updateNetizenWindowDel(client.window());
1411 1411
1412 if (m_focused_window == &client) 1412 // At this point, we trust that this client is no longer in the
1413 revertFocus(screen); 1413 // client list of its frame (but it still has reference to the frame)
1414 // We also assume that any remaining active one is the last focused one
1415
1416 // This is where we revert focus on window close
1417 // NOWHERE ELSE!!!
1418 if (m_focused_window == &client)
1419 unfocusWindow(client);
1414 1420
1415 // failed to revert focus? 1421 // failed to revert focus?
1416 if (m_focused_window == &client) 1422 if (m_focused_window == &client)
@@ -1992,6 +1998,54 @@ void Fluxbox::revertFocus(BScreen &screen) {
1992 } 1998 }
1993} 1999}
1994 2000
2001/*
2002 * Like revertFocus, but specifically related to this window (transients etc)
2003 * if full_revert, we fallback to a full revertFocus if we can't find anything
2004 * local to the client.
2005 * If unfocus_frame is true, we won't focus anything in the same frame
2006 * as the client.
2007 *
2008 * So, we first prefer to choose a transient parent, then the last
2009 * client in this window, and if no luck (or unfocus_frame), then
2010 * we just use the normal revertFocus on the screen.
2011 *
2012 * assumption: client has focus
2013 */
2014void Fluxbox::unfocusWindow(WinClient &client, bool full_revert, bool unfocus_frame) {
2015 // go up the transient tree looking for a focusable window
2016
2017 FluxboxWindow *fbwin = client.fbwindow();
2018 if (fbwin == 0)
2019 unfocus_frame = false;
2020
2021 WinClient *trans_parent = client.transientFor();
2022 while (trans_parent) {
2023 if (trans_parent->fbwindow() && // can't focus if no fbwin
2024 (!unfocus_frame || trans_parent->fbwindow() != fbwin) && // can't be this window
2025 trans_parent->fbwindow()->isVisible() &&
2026 trans_parent->fbwindow()->setCurrentClient(*trans_parent, m_focused_window == &client)) {
2027 return;
2028 }
2029 trans_parent = trans_parent->transientFor();
2030 }
2031
2032 if (fbwin == 0)
2033 return; // nothing more we can do
2034
2035 BScreen &screen = fbwin->screen();
2036
2037 if (!unfocus_frame) {
2038 WinClient *last_focus = screen.getLastFocusedWindow(*fbwin, &client);
2039 if (last_focus != 0 &&
2040 fbwin->setCurrentClient(*last_focus, m_focused_window == &client)) {
2041 return;
2042 }
2043 }
2044
2045 if (full_revert && m_focused_window == &client)
2046 revertFocus(screen);
2047
2048}
1995 2049
1996 2050
1997void Fluxbox::watchKeyRelease(BScreen &screen, unsigned int mods) { 2051void Fluxbox::watchKeyRelease(BScreen &screen, unsigned int mods) {
diff --git a/src/fluxbox.hh b/src/fluxbox.hh
index 184ffd2..f063a1b 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.83 2004/02/10 18:45:57 fluxgen Exp $ 25// $Id: fluxbox.hh,v 1.84 2004/03/21 09:00:25 rathnor Exp $
26 26
27#ifndef FLUXBOX_HH 27#ifndef FLUXBOX_HH
28#define FLUXBOX_HH 28#define FLUXBOX_HH
@@ -157,6 +157,8 @@ public:
157 157
158 void setFocusedWindow(WinClient *w); 158 void setFocusedWindow(WinClient *w);
159 void revertFocus(BScreen &screen); 159 void revertFocus(BScreen &screen);
160 // like revertFocus, but specifically related to this window (transients etc)
161 void unfocusWindow(WinClient &client, bool full_revert = true, bool unfocus_frame = false);
160 void shutdown(); 162 void shutdown();
161 void load_rc(BScreen &scr); 163 void load_rc(BScreen &scr);
162 void loadRootCommand(BScreen &scr); 164 void loadRootCommand(BScreen &scr);