From abc86f0028402a54ef74c378cf5b6805f01e0347 Mon Sep 17 00:00:00 2001 From: rathnor Date: Sun, 20 Jun 2004 10:29:51 +0000 Subject: fix systemtray related things --- ChangeLog | 2 ++ src/SystemTray.cc | 40 +++++++++++++++++++++++++++++----------- src/Toolbar.cc | 18 +++++++++++++----- src/ToolbarItem.hh | 10 +++++++++- 4 files changed, 53 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6601db6..d5ba4c1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,8 @@ (Format: Year/Month/Day) Changes for 0.9.10: *04/06/20: + * Fix various systray issues (Simon) + SystemTray.cc Toolbar.cc ToolbarItem.hh * Support _NET_WM_WINDOW_TYPE_DESKTOP (Simon) - eg nautilus desktop windows are on the bottom, not tabable, etc Ewmh.hh/cc Window.hh/cc 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 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: SystemTray.cc,v 1.10 2004/05/04 14:33:37 rathnor Exp $ +// $Id: SystemTray.cc,v 1.11 2004/06/20 10:29:51 rathnor Exp $ #include "SystemTray.hh" @@ -63,6 +63,9 @@ public: // if not kde dockapp... if (!winclient.screen().isKdeDockapp(winclient.window())) return; + // if not our screen... + if (winclient.screenNumber() != m_tray.window().screenNumber()) + return; winclient.setEventMask(StructureNotifyMask | SubstructureNotifyMask | EnterWindowMask); m_tray.addClient(winclient.window()); @@ -96,6 +99,9 @@ SystemTray::SystemTray(const FbTk::FbWindow &parent): FbTk::EventManager::instance()->add(*this, m_window); + // just try to blend in... (better than defaulting to white) + m_window.setBackgroundPixmap(ParentRelative); + // setup atom name to _NET_SYSTEM_TRAY_S char intbuff[16]; sprintf(intbuff, "%d", m_window.screenNumber()); @@ -151,15 +157,26 @@ void SystemTray::move(int x, int y) { void SystemTray::resize(unsigned int width, unsigned int height) { if (width != m_window.width() || height != m_window.height()) { - m_window.resize(SystemTray::width(), height); - rearrangeClients(); + m_window.resize(width, height); + if (!m_clients.empty()) { + rearrangeClients(); + resizeSig().notify(); + } } } void SystemTray::moveResize(int x, int y, unsigned int width, unsigned int height) { - move(x, y); - resize(width, height); + if (width != m_window.width() || + height != m_window.height()) { + m_window.moveResize(x, y, width, height); + if (!m_clients.empty()) { + rearrangeClients(); + resizeSig().notify(); + } + } else { + move(x, y); + } } void SystemTray::hide() { @@ -241,8 +258,6 @@ void SystemTray::addClient(Window win) { traywin->reparent(m_window, 0, 0); traywin->show(); - resize(width(), m_clients.size()*height()); - rearrangeClients(); } @@ -260,9 +275,8 @@ void SystemTray::removeClient(Window win) { resize(width(), height()); rearrangeClients(); if (m_clients.empty()) { - // so we send configurenotify signal to parent - m_window.resize(1, 1); - hide(); + // so we send notify signal to parent + resizeSig().notify(); } } @@ -281,11 +295,13 @@ void SystemTray::handleEvent(XEvent &event) { } else if (event.type == ConfigureNotify) { // we got configurenotify from an client // check and see if we need to update it's size + // we don't let them be their size, we enforce ours (mwahaha) ClientList::iterator it = findClient(event.xconfigure.window); if (it != m_clients.end()) { if (static_cast(event.xconfigure.width) != (*it)->width() || - static_cast(event.xconfigure.height) != (*it)->height()) + static_cast(event.xconfigure.height) != (*it)->height()) { (*it)->resize((*it)->width(), (*it)->height()); + } } } } @@ -302,6 +318,8 @@ void SystemTray::rearrangeClients() { cerr<<__FILE__<<"("<<__FUNCTION__<<"): "<<(*client_it)->width()<<", "<<(*client_it)->height()<resizeSig().attach(this); } // show all items @@ -564,9 +565,14 @@ void Toolbar::handleEvent(XEvent &event) { void Toolbar::update(FbTk::Subject *subj) { - // either screen reconfigured or theme was reloaded - - reconfigure(); + // either screen reconfigured, theme was reloaded + // or a tool resized itself + + if (typeid(*subj) == typeid(ToolbarItem::ToolbarItemSubject)) { + rearrangeItems(); + } else { + reconfigure(); + } } void Toolbar::setPlacement(Toolbar::Placement where) { @@ -921,6 +927,8 @@ void Toolbar::rearrangeItems() { for (item_it = m_item_list.begin(); item_it != item_it_end; ++item_it) { if (!(*item_it)->active()) { (*item_it)->hide(); + // make sure it still gets told the toolbar height + (*item_it)->resize(1, height()); // width of 0 changes to 1 anyway continue; } int borderW = (*item_it)->borderWidth(); @@ -931,7 +939,6 @@ void Toolbar::rearrangeItems() { next_x += last_bw; last_bw = borderW; - (*item_it)->show(); if ((*item_it)->type() == ToolbarItem::RELATIVE) { int extra = 0; if (rounding_error != 0) { // distribute rounding error over all relatives @@ -944,6 +951,7 @@ void Toolbar::rearrangeItems() { (*item_it)->moveResize(next_x - borderW, -borderW, (*item_it)->width(), height()); } + (*item_it)->show(); next_x += (*item_it)->width(); } // 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 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: ToolbarItem.hh,v 1.3 2003/10/31 10:37:09 rathnor Exp $ +// $Id: ToolbarItem.hh,v 1.4 2004/06/20 10:29:51 rathnor Exp $ #ifndef TOOLBARITEM_HH #define TOOLBARITEM_HH +#include "FbTk/Subject.hh" + /// An item in the toolbar that has either fixed or realive size to the toolbar class ToolbarItem { public: @@ -50,11 +52,17 @@ public: // some items might be there, but effectively empty, so shouldn't appear virtual bool active() { return true; } + FbTk::Subject &resizeSig() { return m_resize_sig; } + void setType(Type type) { m_type = type; } Type type() const { return m_type; } + class ToolbarItemSubject : public FbTk::Subject {}; + private: Type m_type; + + ToolbarItemSubject m_resize_sig; }; #endif // TOOLBARITEM_HH -- cgit v0.11.2