fix systemtray related things

This commit is contained in:
rathnor 2004-06-20 10:29:51 +00:00
parent 9b7775751d
commit abc86f0028
4 changed files with 53 additions and 17 deletions

View file

@ -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

View file

@ -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<screen number>
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<unsigned int>(event.xconfigure.width) != (*it)->width() ||
static_cast<unsigned int>(event.xconfigure.height) != (*it)->height())
static_cast<unsigned int>(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()<<endl;
#endif // DEBUG
}
resize(next_x, height());
}
void SystemTray::removeAllClients() {

View file

@ -22,7 +22,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// $Id: Toolbar.cc,v 1.144 2004/06/16 15:38:19 rathnor Exp $
// $Id: Toolbar.cc,v 1.145 2004/06/20 10:29:51 rathnor Exp $
#include "Toolbar.hh"
@ -405,6 +405,7 @@ void Toolbar::reconfigure() {
if (item == 0)
continue;
m_item_list.push_back(item);
item->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

View file

@ -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