summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenrik Kinnunen <fluxgen@fluxbox.org>2008-09-28 08:46:49 (GMT)
committerHenrik Kinnunen <fluxgen@fluxbox.org>2008-09-28 08:46:49 (GMT)
commitbcf37890b617730cfded161b9a3d18f7c377e724 (patch)
treed17e0fe6ac69d023fba66fdc1d176c16174e6a1b
parented53f3c623e7c3ae35672b33ae3b52759dc1a6ed (diff)
downloadfluxbox_lack-bcf37890b617730cfded161b9a3d18f7c377e724.zip
fluxbox_lack-bcf37890b617730cfded161b9a3d18f7c377e724.tar.bz2
Change focused signal to use the new signal system
-rw-r--r--ChangeLog4
-rw-r--r--src/FbTk/Signal.hh32
-rw-r--r--src/FocusControl.cc4
-rw-r--r--src/FocusableList.cc15
-rw-r--r--src/FocusableList.hh6
-rw-r--r--src/Screen.cc1
-rw-r--r--src/Screen.hh4
-rw-r--r--src/Window.cc25
-rw-r--r--src/Window.hh7
-rw-r--r--src/fluxbox.cc23
-rw-r--r--src/fluxbox.hh4
11 files changed, 84 insertions, 41 deletions
diff --git a/ChangeLog b/ChangeLog
index a2bddf2..e860745 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
1 (Format: Year/Month/Day) 1 (Format: Year/Month/Day)
2Changes for 1.1.2 2Changes for 1.1.2
3*08/09/28:
4 * Change focused window signal to use the new signal system (Henrik)
5 FbTk/Signal.hh, FocusControl.cc, FocusableList.hh/cc, Screen.hh/cc
6 Window.hh/cc, fluxbox.hh/cc
3*08/09/21: 7*08/09/21:
4 * Changed icon list signal in BScreen to use the new signal system 8 * Changed icon list signal in BScreen to use the new signal system
5 (Henrik) 9 (Henrik)
diff --git a/src/FbTk/Signal.hh b/src/FbTk/Signal.hh
index 18b03b3..df30cda 100644
--- a/src/FbTk/Signal.hh
+++ b/src/FbTk/Signal.hh
@@ -191,8 +191,8 @@ public:
191class SignalTracker { 191class SignalTracker {
192public: 192public:
193 /// Internal type, do not use. 193 /// Internal type, do not use.
194 typedef std::list< std::pair<SigImpl::SignalHolder*, 194 typedef std::map<SigImpl::SignalHolder*,
195 SigImpl::SignalHolder::SlotID> > Connections; 195 SigImpl::SignalHolder::SlotID> Connections;
196 typedef Connections::iterator TrackID; ///< \c ID type for join/leave. 196 typedef Connections::iterator TrackID; ///< \c ID type for join/leave.
197 197
198 ~SignalTracker() { 198 ~SignalTracker() {
@@ -203,9 +203,13 @@ public:
203 /// @return A tracking ID ( not unique ) 203 /// @return A tracking ID ( not unique )
204 template <typename Signal, typename Functor> 204 template <typename Signal, typename Functor>
205 TrackID join(Signal& sig, const Functor& functor) { 205 TrackID join(Signal& sig, const Functor& functor) {
206 return 206 ValueType value = std::make_pair(&sig, sig.connect(functor));
207 m_connections.insert(m_connections.end(), 207 std::pair<TrackID, bool> ret = m_connections.insert(value);
208 Connections::value_type(&sig, sig.connect(functor))); 208 if ( !ret.second ) {
209 // failed to insert this functor
210 sig.disconnect(value.second);
211 }
212 return ret.first;
209 } 213 }
210 214
211 /// Leave tracking for a signal 215 /// Leave tracking for a signal
@@ -217,23 +221,29 @@ public:
217 /// Leave tracking for a signal 221 /// Leave tracking for a signal
218 /// @param sig the signal to leave 222 /// @param sig the signal to leave
219 template <typename Signal> 223 template <typename Signal>
220 void leave(const Signal &sig) { 224 void leave(Signal &sig) {
221 m_connections.erase(&sig); 225 Iterator it = m_connections.find(&sig);
226 if (it != m_connections.end()) {
227 it->first->disconnect( it->second );
228 m_connections.erase(it);
229 }
222 } 230 }
223 231
224 232
225 void leaveAll() { 233 void leaveAll() {
226 // disconnect all connections 234 // disconnect all connections
227 for ( Connections::iterator conIt = m_connections.begin(); 235 for ( Iterator conIt = m_connections.begin();
228 conIt != m_connections.end(); ) { 236 conIt != m_connections.end(); ++conIt) {
229 // keep temporary, while disconnecting we can 237 // keep temporary, while disconnecting we can
230 // in some strange cases get a call to this again 238 // in some strange cases get a call to this again
231 Connections::value_type tmp = *conIt; 239 ValueType tmp = *conIt;
232 conIt = m_connections.erase(conIt); 240 m_connections.erase(conIt);
233 tmp.first->disconnect(tmp.second); 241 tmp.first->disconnect(tmp.second);
234 } 242 }
235 } 243 }
236private: 244private:
245 typedef Connections::value_type ValueType;
246 typedef Connections::iterator Iterator;
237 /// holds all connections to different signals and slots. 247 /// holds all connections to different signals and slots.
238 Connections m_connections; 248 Connections m_connections;
239}; 249};
diff --git a/src/FocusControl.cc b/src/FocusControl.cc
index 6533ac1..9c531bb 100644
--- a/src/FocusControl.cc
+++ b/src/FocusControl.cc
@@ -560,9 +560,9 @@ void FocusControl::setFocusedWindow(WinClient *client) {
560 560
561 // update AtomHandlers and/or other stuff... 561 // update AtomHandlers and/or other stuff...
562 if (screen) 562 if (screen)
563 screen->focusedWindowSig().notify(); 563 screen->focusedWindowSig().emit(*screen, s_focused_fbwindow, s_focused_window);
564 if (old_screen && screen != old_screen) 564 if (old_screen && screen != old_screen)
565 old_screen->focusedWindowSig().notify(); 565 old_screen->focusedWindowSig().emit(*old_screen, s_focused_fbwindow, s_focused_window);
566} 566}
567 567
568////////////////////// FocusControl RESOURCES 568////////////////////// FocusControl RESOURCES
diff --git a/src/FocusableList.cc b/src/FocusableList.cc
index b06faac..b2b0320 100644
--- a/src/FocusableList.cc
+++ b/src/FocusableList.cc
@@ -100,8 +100,10 @@ void FocusableList::init() {
100 join(m_screen.currentWorkspaceSig(), 100 join(m_screen.currentWorkspaceSig(),
101 FbTk::MemFun(*this, &FocusableList::workspaceChanged)); 101 FbTk::MemFun(*this, &FocusableList::workspaceChanged));
102 } 102 }
103 if (m_pat->dependsOnFocusedWindow()) 103 if (m_pat->dependsOnFocusedWindow()) {
104 m_screen.focusedWindowSig().attach(this); 104 join(m_screen.focusedWindowSig(),
105 FbTk::MemFun(*this, &FocusableList::focusedWindowChanged));
106 }
105} 107}
106 108
107void FocusableList::update(FbTk::Subject *subj) { 109void FocusableList::update(FbTk::Subject *subj) {
@@ -150,8 +152,7 @@ void FocusableList::update(FbTk::Subject *subj) {
150 if (insertFromParent(*win)) 152 if (insertFromParent(*win))
151 m_ordersig.notify(win); 153 m_ordersig.notify(win);
152 } 154 }
153 } else if (subj == &m_screen.focusedWindowSig()) 155 }
154 reset();
155} 156}
156 157
157void FocusableList::checkUpdate(Focusable &win) { 158void FocusableList::checkUpdate(Focusable &win) {
@@ -315,3 +316,9 @@ void FocusableList::attachChild(FocusableList &child) const {
315void FocusableList::workspaceChanged(BScreen &screen) { 316void FocusableList::workspaceChanged(BScreen &screen) {
316 reset(); 317 reset();
317} 318}
319
320void FocusableList::focusedWindowChanged(BScreen &screen,
321 FluxboxWindow *focused_win,
322 WinClient *client) {
323 reset();
324}
diff --git a/src/FocusableList.hh b/src/FocusableList.hh
index 1dd8437..58ef9b6 100644
--- a/src/FocusableList.hh
+++ b/src/FocusableList.hh
@@ -35,6 +35,8 @@
35 35
36class BScreen; 36class BScreen;
37class Focusable; 37class Focusable;
38class WinClient;
39class FluxboxWindow;
38 40
39class FocusableList: public FbTk::Observer, private FbTk::NotCopyable, 41class FocusableList: public FbTk::Observer, private FbTk::NotCopyable,
40 private FbTk::SignalTracker { 42 private FbTk::SignalTracker {
@@ -112,8 +114,8 @@ private:
112 void detachSignals(Focusable &win); 114 void detachSignals(Focusable &win);
113 void reset(); 115 void reset();
114 void attachChild(FocusableList &child) const; 116 void attachChild(FocusableList &child) const;
115 void workspaceChanged(BScreen& screen); 117 void workspaceChanged(BScreen &screen);
116 118 void focusedWindowChanged(BScreen &screen, FluxboxWindow *win, WinClient *client);
117 std::auto_ptr<ClientPattern> m_pat; 119 std::auto_ptr<ClientPattern> m_pat;
118 const FocusableList *m_parent; 120 const FocusableList *m_parent;
119 BScreen &m_screen; 121 BScreen &m_screen;
diff --git a/src/Screen.cc b/src/Screen.cc
index 8746fd2..2c038d2 100644
--- a/src/Screen.cc
+++ b/src/Screen.cc
@@ -340,7 +340,6 @@ BScreen::BScreen(FbTk::ResourceManager &rm,
340 const string &altscreenname, 340 const string &altscreenname,
341 int scrn, int num_layers) : 341 int scrn, int num_layers) :
342 m_workspace_area_sig(*this), // workspace area signal 342 m_workspace_area_sig(*this), // workspace area signal
343 m_focusedwindow_sig(*this), // focused window signal
344 m_reconfigure_sig(*this), // reconfigure signal 343 m_reconfigure_sig(*this), // reconfigure signal
345 m_resize_sig(*this), 344 m_resize_sig(*this),
346 m_layermanager(num_layers), 345 m_layermanager(num_layers),
diff --git a/src/Screen.hh b/src/Screen.hh
index a5e80ee..e77056d 100644
--- a/src/Screen.hh
+++ b/src/Screen.hh
@@ -223,7 +223,7 @@ public:
223 /// current workspace signal 223 /// current workspace signal
224 ScreenSignal &currentWorkspaceSig() { return m_currentworkspace_sig; } 224 ScreenSignal &currentWorkspaceSig() { return m_currentworkspace_sig; }
225 /// focused window signal 225 /// focused window signal
226 FbTk::Subject &focusedWindowSig() { return m_focusedwindow_sig; } 226 FbTk::Signal<void, BScreen&, FluxboxWindow*, WinClient*> &focusedWindowSig() { return m_focusedwindow_sig; }
227 /// reconfigure signal 227 /// reconfigure signal
228 FbTk::Subject &reconfigureSig() { return m_reconfigure_sig; } 228 FbTk::Subject &reconfigureSig() { return m_reconfigure_sig; }
229 FbTk::Subject &resizeSig() { return m_resize_sig; } 229 FbTk::Subject &resizeSig() { return m_resize_sig; }
@@ -494,10 +494,10 @@ private:
494 494
495 ScreenSubject 495 ScreenSubject
496 m_workspace_area_sig, ///< workspace area changed signal 496 m_workspace_area_sig, ///< workspace area changed signal
497 m_focusedwindow_sig, ///< focused window signal
498 m_reconfigure_sig, ///< reconfigure signal 497 m_reconfigure_sig, ///< reconfigure signal
499 m_resize_sig; ///< resize signal 498 m_resize_sig; ///< resize signal
500 499
500 FbTk::Signal<void, BScreen&, FluxboxWindow*, WinClient*> m_focusedwindow_sig; ///< focused window signal
501 ScreenSignal m_iconlist_sig; ///< notify if a window gets iconified/deiconified 501 ScreenSignal m_iconlist_sig; ///< notify if a window gets iconified/deiconified
502 ScreenSignal m_clientlist_sig; ///< client signal 502 ScreenSignal m_clientlist_sig; ///< client signal
503 ScreenSignal m_bg_change_sig; ///< background change signal 503 ScreenSignal m_bg_change_sig; ///< background change signal
diff --git a/src/Window.cc b/src/Window.cc
index 5d50fcf..7e5a273 100644
--- a/src/Window.cc
+++ b/src/Window.cc
@@ -49,6 +49,7 @@
49#include "FbTk/KeyUtil.hh" 49#include "FbTk/KeyUtil.hh"
50#include "FbTk/SimpleCommand.hh" 50#include "FbTk/SimpleCommand.hh"
51#include "FbTk/Select2nd.hh" 51#include "FbTk/Select2nd.hh"
52#include "FbTk/MemFun.hh"
52 53
53#ifdef HAVE_CONFIG_H 54#ifdef HAVE_CONFIG_H
54#include "config.h" 55#include "config.h"
@@ -1450,8 +1451,10 @@ void FluxboxWindow::setFullscreen(bool flag) {
1450 frame().applyState(); 1451 frame().applyState();
1451 1452
1452 setFullscreenLayer(); // calls stateSig().notify() 1453 setFullscreenLayer(); // calls stateSig().notify()
1453 if (!isFocused()) 1454 if (!isFocused()) {
1454 screen().focusedWindowSig().attach(this); 1455 join(screen().focusedWindowSig(),
1456 FbTk::MemFun(*this, &FluxboxWindow::focusedWindowChanged));
1457 }
1455 1458
1456 } else if (!flag && isFullscreen()) { 1459 } else if (!flag && isFullscreen()) {
1457 1460
@@ -1769,12 +1772,14 @@ void FluxboxWindow::setFocusFlag(bool focus) {
1769 1772
1770 // if we're fullscreen and another window gains focus on the same head, 1773 // if we're fullscreen and another window gains focus on the same head,
1771 // then we need to let the user see it 1774 // then we need to let the user see it
1772 if (m_state.fullscreen && !focus) 1775 if (m_state.fullscreen && !focus) {
1773 screen().focusedWindowSig().attach(this); 1776 join(screen().focusedWindowSig(),
1777 FbTk::MemFun(*this, &FluxboxWindow::focusedWindowChanged));
1778 }
1774 1779
1775 if (m_state.fullscreen && focus) { 1780 if (m_state.fullscreen && focus) {
1776 moveToLayer(::Layer::ABOVE_DOCK); 1781 moveToLayer(::Layer::ABOVE_DOCK);
1777 screen().focusedWindowSig().detach(this); 1782 leave(screen().focusedWindowSig());
1778 } 1783 }
1779 1784
1780 if (focus != frame().focused()) 1785 if (focus != frame().focused())
@@ -2721,9 +2726,6 @@ void FluxboxWindow::update(FbTk::Subject *subj) {
2721 titleSig().notify(); 2726 titleSig().notify();
2722 } 2727 }
2723 2728
2724 } else if (subj == &screen().focusedWindowSig()) {
2725 if (FocusControl::focusedFbWindow())
2726 setFullscreenLayer();
2727 } else if (subj == &m_theme.reconfigSig()) { 2729 } else if (subj == &m_theme.reconfigSig()) {
2728 frame().applyDecorations(); 2730 frame().applyDecorations();
2729 sendConfigureNotify(); 2731 sendConfigureNotify();
@@ -3867,3 +3869,10 @@ void FluxboxWindow::setWindowType(WindowState::WindowType type) {
3867 * _NET_WM_WINDOW_TYPE_UTILITY 3869 * _NET_WM_WINDOW_TYPE_UTILITY
3868 */ 3870 */
3869} 3871}
3872
3873void FluxboxWindow::focusedWindowChanged(BScreen &screen,
3874 FluxboxWindow *focused_win, WinClient* client) {
3875 if (focused_win) {
3876 setFullscreenLayer();
3877 }
3878}
diff --git a/src/Window.hh b/src/Window.hh
index 8ee2b5c..e5e5c1f 100644
--- a/src/Window.hh
+++ b/src/Window.hh
@@ -31,12 +31,14 @@
31#include "FbTk/Observer.hh" 31#include "FbTk/Observer.hh"
32#include "FbTk/EventHandler.hh" 32#include "FbTk/EventHandler.hh"
33#include "FbTk/XLayerItem.hh" 33#include "FbTk/XLayerItem.hh"
34#include "FbTk/Signal.hh"
34 35
35#include "FbWinFrame.hh" 36#include "FbWinFrame.hh"
36#include "Focusable.hh" 37#include "Focusable.hh"
37#include "FocusableTheme.hh" 38#include "FocusableTheme.hh"
38#include "WinButton.hh" 39#include "WinButton.hh"
39 40
41
40#include <sys/time.h> 42#include <sys/time.h>
41#include <vector> 43#include <vector>
42#include <string> 44#include <string>
@@ -58,7 +60,8 @@ class XLayer;
58 60
59/// Creates the window frame and handles any window event for it 61/// Creates the window frame and handles any window event for it
60class FluxboxWindow: public Focusable, public FbTk::Observer, 62class FluxboxWindow: public Focusable, public FbTk::Observer,
61 public FbTk::EventHandler { 63 public FbTk::EventHandler,
64 private FbTk::SignalTracker {
62public: 65public:
63 /// Motif wm Hints 66 /// Motif wm Hints
64 enum { 67 enum {
@@ -521,6 +524,8 @@ private:
521 static void ungrabPointer(Time time); 524 static void ungrabPointer(Time time);
522 525
523 void associateClient(WinClient &client); 526 void associateClient(WinClient &client);
527 /// Called when focused changed, and is attached when it is not in fullscreen mode
528 void focusedWindowChanged(BScreen &screen, FluxboxWindow *focused_win, WinClient* client);
524 529
525 // state and hint signals 530 // state and hint signals
526 WinSubject m_hintsig, 531 WinSubject m_hintsig,
diff --git a/src/fluxbox.cc b/src/fluxbox.cc
index 3a07060..4041444 100644
--- a/src/fluxbox.cc
+++ b/src/fluxbox.cc
@@ -453,9 +453,11 @@ void Fluxbox::initScreen(BScreen *screen) {
453 screen->initWindows(); 453 screen->initWindows();
454 454
455 // attach screen signals to this 455 // attach screen signals to this
456 screen->focusedWindowSig().attach(this);
457 screen->workspaceAreaSig().attach(this); 456 screen->workspaceAreaSig().attach(this);
458 457
458 join(screen->focusedWindowSig(),
459 FbTk::MemFun(*this, &Fluxbox::focusedWindowChanged));
460
459 join(screen->clientListSig(), 461 join(screen->clientListSig(),
460 FbTk::MemFun(*this, &Fluxbox::clientListChanged)); 462 FbTk::MemFun(*this, &Fluxbox::clientListChanged));
461 463
@@ -1105,15 +1107,7 @@ void Fluxbox::update(FbTk::Subject *changedsub) {
1105 } else if (typeid(*changedsub) == typeid(BScreen::ScreenSubject)) { 1107 } else if (typeid(*changedsub) == typeid(BScreen::ScreenSubject)) {
1106 BScreen::ScreenSubject *subj = dynamic_cast<BScreen::ScreenSubject *>(changedsub); 1108 BScreen::ScreenSubject *subj = dynamic_cast<BScreen::ScreenSubject *>(changedsub);
1107 BScreen &screen = subj->screen(); 1109 BScreen &screen = subj->screen();
1108 if ((&(screen.focusedWindowSig())) == changedsub) { 1110 if ((&(screen.workspaceAreaSig())) == changedsub) {
1109 for (AtomHandlerContainerIt it= m_atomhandler.begin();
1110 it != m_atomhandler.end(); it++) {
1111 (*it).first->updateFocusedWindow(screen,
1112 (FocusControl::focusedWindow() ?
1113 FocusControl::focusedWindow()->window() :
1114 0));
1115 }
1116 } else if ((&(screen.workspaceAreaSig())) == changedsub) {
1117 for (AtomHandlerContainerIt it= m_atomhandler.begin(); 1111 for (AtomHandlerContainerIt it= m_atomhandler.begin();
1118 it != m_atomhandler.end(); ++it) { 1112 it != m_atomhandler.end(); ++it) {
1119 if ((*it).first->update()) 1113 if ((*it).first->update())
@@ -1537,3 +1531,12 @@ void Fluxbox::clientListChanged(BScreen &screen) {
1537 (*it).first->updateClientList(screen); 1531 (*it).first->updateClientList(screen);
1538 } 1532 }
1539} 1533}
1534
1535void Fluxbox::focusedWindowChanged(BScreen &screen,
1536 FluxboxWindow* win,
1537 WinClient* client) {
1538 for (AtomHandlerContainerIt it= m_atomhandler.begin();
1539 it != m_atomhandler.end(); it++) {
1540 (*it).first->updateFocusedWindow(screen, client ? client->window() : 0 );
1541 }
1542}
diff --git a/src/fluxbox.hh b/src/fluxbox.hh
index c15aa8a..4cf0555 100644
--- a/src/fluxbox.hh
+++ b/src/fluxbox.hh
@@ -209,6 +209,10 @@ private:
209 void workspaceNamesChanged(BScreen &screen); 209 void workspaceNamesChanged(BScreen &screen);
210 /// Called when the client list changed. 210 /// Called when the client list changed.
211 void clientListChanged(BScreen &screen); 211 void clientListChanged(BScreen &screen);
212 /// Called when the focused window changed on a screen
213 void focusedWindowChanged(BScreen &screen,
214 FluxboxWindow* win,
215 WinClient* client);
212 216
213 std::auto_ptr<FbAtoms> m_fbatoms; 217 std::auto_ptr<FbAtoms> m_fbatoms;
214 218