diff options
author | rathnor <rathnor> | 2004-06-20 10:29:51 (GMT) |
---|---|---|
committer | rathnor <rathnor> | 2004-06-20 10:29:51 (GMT) |
commit | abc86f0028402a54ef74c378cf5b6805f01e0347 (patch) | |
tree | 2539f1f974e142a0424473f484c90a1b7b32b393 /src | |
parent | 9b7775751decd095f091d122c1ce057c6a04b64d (diff) | |
download | fluxbox-abc86f0028402a54ef74c378cf5b6805f01e0347.zip fluxbox-abc86f0028402a54ef74c378cf5b6805f01e0347.tar.bz2 |
fix systemtray related things
Diffstat (limited to 'src')
-rw-r--r-- | src/SystemTray.cc | 40 | ||||
-rw-r--r-- | src/Toolbar.cc | 18 | ||||
-rw-r--r-- | src/ToolbarItem.hh | 10 |
3 files changed, 51 insertions, 17 deletions
diff --git a/src/SystemTray.cc b/src/SystemTray.cc index 5e28681..c1a4f53 100644 --- a/src/SystemTray.cc +++ b/src/SystemTray.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: SystemTray.cc,v 1.10 2004/05/04 14:33:37 rathnor Exp $ | 22 | // $Id: SystemTray.cc,v 1.11 2004/06/20 10:29:51 rathnor Exp $ |
23 | 23 | ||
24 | #include "SystemTray.hh" | 24 | #include "SystemTray.hh" |
25 | 25 | ||
@@ -63,6 +63,9 @@ public: | |||
63 | // if not kde dockapp... | 63 | // if not kde dockapp... |
64 | if (!winclient.screen().isKdeDockapp(winclient.window())) | 64 | if (!winclient.screen().isKdeDockapp(winclient.window())) |
65 | return; | 65 | return; |
66 | // if not our screen... | ||
67 | if (winclient.screenNumber() != m_tray.window().screenNumber()) | ||
68 | return; | ||
66 | winclient.setEventMask(StructureNotifyMask | | 69 | winclient.setEventMask(StructureNotifyMask | |
67 | SubstructureNotifyMask | EnterWindowMask); | 70 | SubstructureNotifyMask | EnterWindowMask); |
68 | m_tray.addClient(winclient.window()); | 71 | m_tray.addClient(winclient.window()); |
@@ -96,6 +99,9 @@ SystemTray::SystemTray(const FbTk::FbWindow &parent): | |||
96 | 99 | ||
97 | FbTk::EventManager::instance()->add(*this, m_window); | 100 | FbTk::EventManager::instance()->add(*this, m_window); |
98 | 101 | ||
102 | // just try to blend in... (better than defaulting to white) | ||
103 | m_window.setBackgroundPixmap(ParentRelative); | ||
104 | |||
99 | // setup atom name to _NET_SYSTEM_TRAY_S<screen number> | 105 | // setup atom name to _NET_SYSTEM_TRAY_S<screen number> |
100 | char intbuff[16]; | 106 | char intbuff[16]; |
101 | sprintf(intbuff, "%d", m_window.screenNumber()); | 107 | sprintf(intbuff, "%d", m_window.screenNumber()); |
@@ -151,15 +157,26 @@ void SystemTray::move(int x, int y) { | |||
151 | void SystemTray::resize(unsigned int width, unsigned int height) { | 157 | void SystemTray::resize(unsigned int width, unsigned int height) { |
152 | if (width != m_window.width() || | 158 | if (width != m_window.width() || |
153 | height != m_window.height()) { | 159 | height != m_window.height()) { |
154 | m_window.resize(SystemTray::width(), height); | 160 | m_window.resize(width, height); |
155 | rearrangeClients(); | 161 | if (!m_clients.empty()) { |
162 | rearrangeClients(); | ||
163 | resizeSig().notify(); | ||
164 | } | ||
156 | } | 165 | } |
157 | } | 166 | } |
158 | 167 | ||
159 | void SystemTray::moveResize(int x, int y, | 168 | void SystemTray::moveResize(int x, int y, |
160 | unsigned int width, unsigned int height) { | 169 | unsigned int width, unsigned int height) { |
161 | move(x, y); | 170 | if (width != m_window.width() || |
162 | resize(width, height); | 171 | height != m_window.height()) { |
172 | m_window.moveResize(x, y, width, height); | ||
173 | if (!m_clients.empty()) { | ||
174 | rearrangeClients(); | ||
175 | resizeSig().notify(); | ||
176 | } | ||
177 | } else { | ||
178 | move(x, y); | ||
179 | } | ||
163 | } | 180 | } |
164 | 181 | ||
165 | void SystemTray::hide() { | 182 | void SystemTray::hide() { |
@@ -241,8 +258,6 @@ void SystemTray::addClient(Window win) { | |||
241 | traywin->reparent(m_window, 0, 0); | 258 | traywin->reparent(m_window, 0, 0); |
242 | traywin->show(); | 259 | traywin->show(); |
243 | 260 | ||
244 | resize(width(), m_clients.size()*height()); | ||
245 | |||
246 | rearrangeClients(); | 261 | rearrangeClients(); |
247 | } | 262 | } |
248 | 263 | ||
@@ -260,9 +275,8 @@ void SystemTray::removeClient(Window win) { | |||
260 | resize(width(), height()); | 275 | resize(width(), height()); |
261 | rearrangeClients(); | 276 | rearrangeClients(); |
262 | if (m_clients.empty()) { | 277 | if (m_clients.empty()) { |
263 | // so we send configurenotify signal to parent | 278 | // so we send notify signal to parent |
264 | m_window.resize(1, 1); | 279 | resizeSig().notify(); |
265 | hide(); | ||
266 | } | 280 | } |
267 | } | 281 | } |
268 | 282 | ||
@@ -281,11 +295,13 @@ void SystemTray::handleEvent(XEvent &event) { | |||
281 | } else if (event.type == ConfigureNotify) { | 295 | } else if (event.type == ConfigureNotify) { |
282 | // we got configurenotify from an client | 296 | // we got configurenotify from an client |
283 | // check and see if we need to update it's size | 297 | // check and see if we need to update it's size |
298 | // we don't let them be their size, we enforce ours (mwahaha) | ||
284 | ClientList::iterator it = findClient(event.xconfigure.window); | 299 | ClientList::iterator it = findClient(event.xconfigure.window); |
285 | if (it != m_clients.end()) { | 300 | if (it != m_clients.end()) { |
286 | if (static_cast<unsigned int>(event.xconfigure.width) != (*it)->width() || | 301 | if (static_cast<unsigned int>(event.xconfigure.width) != (*it)->width() || |
287 | static_cast<unsigned int>(event.xconfigure.height) != (*it)->height()) | 302 | static_cast<unsigned int>(event.xconfigure.height) != (*it)->height()) { |
288 | (*it)->resize((*it)->width(), (*it)->height()); | 303 | (*it)->resize((*it)->width(), (*it)->height()); |
304 | } | ||
289 | } | 305 | } |
290 | } | 306 | } |
291 | } | 307 | } |
@@ -302,6 +318,8 @@ void SystemTray::rearrangeClients() { | |||
302 | cerr<<__FILE__<<"("<<__FUNCTION__<<"): "<<(*client_it)->width()<<", "<<(*client_it)->height()<<endl; | 318 | cerr<<__FILE__<<"("<<__FUNCTION__<<"): "<<(*client_it)->width()<<", "<<(*client_it)->height()<<endl; |
303 | #endif // DEBUG | 319 | #endif // DEBUG |
304 | } | 320 | } |
321 | |||
322 | resize(next_x, height()); | ||
305 | } | 323 | } |
306 | 324 | ||
307 | void SystemTray::removeAllClients() { | 325 | void SystemTray::removeAllClients() { |
diff --git a/src/Toolbar.cc b/src/Toolbar.cc index c6ab79c..c72e54c 100644 --- a/src/Toolbar.cc +++ b/src/Toolbar.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: Toolbar.cc,v 1.144 2004/06/16 15:38:19 rathnor Exp $ | 25 | // $Id: Toolbar.cc,v 1.145 2004/06/20 10:29:51 rathnor Exp $ |
26 | 26 | ||
27 | #include "Toolbar.hh" | 27 | #include "Toolbar.hh" |
28 | 28 | ||
@@ -405,6 +405,7 @@ void Toolbar::reconfigure() { | |||
405 | if (item == 0) | 405 | if (item == 0) |
406 | continue; | 406 | continue; |
407 | m_item_list.push_back(item); | 407 | m_item_list.push_back(item); |
408 | item->resizeSig().attach(this); | ||
408 | 409 | ||
409 | } | 410 | } |
410 | // show all items | 411 | // show all items |
@@ -564,9 +565,14 @@ void Toolbar::handleEvent(XEvent &event) { | |||
564 | 565 | ||
565 | void Toolbar::update(FbTk::Subject *subj) { | 566 | void Toolbar::update(FbTk::Subject *subj) { |
566 | 567 | ||
567 | // either screen reconfigured or theme was reloaded | 568 | // either screen reconfigured, theme was reloaded |
568 | 569 | // or a tool resized itself | |
569 | reconfigure(); | 570 | |
571 | if (typeid(*subj) == typeid(ToolbarItem::ToolbarItemSubject)) { | ||
572 | rearrangeItems(); | ||
573 | } else { | ||
574 | reconfigure(); | ||
575 | } | ||
570 | } | 576 | } |
571 | 577 | ||
572 | void Toolbar::setPlacement(Toolbar::Placement where) { | 578 | void Toolbar::setPlacement(Toolbar::Placement where) { |
@@ -921,6 +927,8 @@ void Toolbar::rearrangeItems() { | |||
921 | for (item_it = m_item_list.begin(); item_it != item_it_end; ++item_it) { | 927 | for (item_it = m_item_list.begin(); item_it != item_it_end; ++item_it) { |
922 | if (!(*item_it)->active()) { | 928 | if (!(*item_it)->active()) { |
923 | (*item_it)->hide(); | 929 | (*item_it)->hide(); |
930 | // make sure it still gets told the toolbar height | ||
931 | (*item_it)->resize(1, height()); // width of 0 changes to 1 anyway | ||
924 | continue; | 932 | continue; |
925 | } | 933 | } |
926 | int borderW = (*item_it)->borderWidth(); | 934 | int borderW = (*item_it)->borderWidth(); |
@@ -931,7 +939,6 @@ void Toolbar::rearrangeItems() { | |||
931 | next_x += last_bw; | 939 | next_x += last_bw; |
932 | last_bw = borderW; | 940 | last_bw = borderW; |
933 | 941 | ||
934 | (*item_it)->show(); | ||
935 | if ((*item_it)->type() == ToolbarItem::RELATIVE) { | 942 | if ((*item_it)->type() == ToolbarItem::RELATIVE) { |
936 | int extra = 0; | 943 | int extra = 0; |
937 | if (rounding_error != 0) { // distribute rounding error over all relatives | 944 | if (rounding_error != 0) { // distribute rounding error over all relatives |
@@ -944,6 +951,7 @@ void Toolbar::rearrangeItems() { | |||
944 | (*item_it)->moveResize(next_x - borderW, -borderW, | 951 | (*item_it)->moveResize(next_x - borderW, -borderW, |
945 | (*item_it)->width(), height()); | 952 | (*item_it)->width(), height()); |
946 | } | 953 | } |
954 | (*item_it)->show(); | ||
947 | next_x += (*item_it)->width(); | 955 | next_x += (*item_it)->width(); |
948 | } | 956 | } |
949 | // unlock | 957 | // unlock |
diff --git a/src/ToolbarItem.hh b/src/ToolbarItem.hh index 57088e0..78f1f12 100644 --- a/src/ToolbarItem.hh +++ b/src/ToolbarItem.hh | |||
@@ -20,11 +20,13 @@ | |||
20 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 20 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
21 | // DEALINGS IN THE SOFTWARE. | 21 | // DEALINGS IN THE SOFTWARE. |
22 | 22 | ||
23 | // $Id: ToolbarItem.hh,v 1.3 2003/10/31 10:37:09 rathnor Exp $ | 23 | // $Id: ToolbarItem.hh,v 1.4 2004/06/20 10:29:51 rathnor Exp $ |
24 | 24 | ||
25 | #ifndef TOOLBARITEM_HH | 25 | #ifndef TOOLBARITEM_HH |
26 | #define TOOLBARITEM_HH | 26 | #define TOOLBARITEM_HH |
27 | 27 | ||
28 | #include "FbTk/Subject.hh" | ||
29 | |||
28 | /// An item in the toolbar that has either fixed or realive size to the toolbar | 30 | /// An item in the toolbar that has either fixed or realive size to the toolbar |
29 | class ToolbarItem { | 31 | class ToolbarItem { |
30 | public: | 32 | public: |
@@ -50,11 +52,17 @@ public: | |||
50 | // some items might be there, but effectively empty, so shouldn't appear | 52 | // some items might be there, but effectively empty, so shouldn't appear |
51 | virtual bool active() { return true; } | 53 | virtual bool active() { return true; } |
52 | 54 | ||
55 | FbTk::Subject &resizeSig() { return m_resize_sig; } | ||
56 | |||
53 | void setType(Type type) { m_type = type; } | 57 | void setType(Type type) { m_type = type; } |
54 | Type type() const { return m_type; } | 58 | Type type() const { return m_type; } |
55 | 59 | ||
60 | class ToolbarItemSubject : public FbTk::Subject {}; | ||
61 | |||
56 | private: | 62 | private: |
57 | Type m_type; | 63 | Type m_type; |
64 | |||
65 | ToolbarItemSubject m_resize_sig; | ||
58 | }; | 66 | }; |
59 | 67 | ||
60 | #endif // TOOLBARITEM_HH | 68 | #endif // TOOLBARITEM_HH |