systemtray-tool has now a propper background. its styleable via the
toolbar.systray.* ressource, same way as the clock.
This commit is contained in:
parent
a07d61e63d
commit
69e86c6c25
4 changed files with 91 additions and 30 deletions
|
@ -1,5 +1,5 @@
|
||||||
// SystemTray.cc
|
// SystemTray.cc
|
||||||
// Copyright (c) 2003-2004 Henrik Kinnunen (fluxgen at users.sourceforge.net)
|
// Copyright (c) 2003-2005 Henrik Kinnunen (fluxgen at users.sourceforge.net)
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
|
@ -24,6 +24,7 @@
|
||||||
#include "SystemTray.hh"
|
#include "SystemTray.hh"
|
||||||
|
|
||||||
#include "FbTk/EventManager.hh"
|
#include "FbTk/EventManager.hh"
|
||||||
|
#include "FbTk/ImageControl.hh"
|
||||||
|
|
||||||
#include "AtomHandler.hh"
|
#include "AtomHandler.hh"
|
||||||
#include "fluxbox.hh"
|
#include "fluxbox.hh"
|
||||||
|
@ -100,15 +101,19 @@ private:
|
||||||
SystemTray &m_tray;
|
SystemTray &m_tray;
|
||||||
};
|
};
|
||||||
|
|
||||||
SystemTray::SystemTray(const FbTk::FbWindow &parent):
|
SystemTray::SystemTray(const FbTk::FbWindow& parent, ButtonTheme& theme, BScreen& screen):
|
||||||
ToolbarItem(ToolbarItem::FIXED),
|
ToolbarItem(ToolbarItem::FIXED),
|
||||||
m_window(parent, 0, 0, 1, 1, ExposureMask | ButtonPressMask | ButtonReleaseMask |
|
m_window(parent, 0, 0, 1, 1, ExposureMask | ButtonPressMask | ButtonReleaseMask |
|
||||||
SubstructureNotifyMask | SubstructureRedirectMask) {
|
SubstructureNotifyMask | SubstructureRedirectMask),
|
||||||
|
m_theme(theme),
|
||||||
|
m_screen(screen),
|
||||||
|
m_pixmap(0) {
|
||||||
|
|
||||||
FbTk::EventManager::instance()->add(*this, m_window);
|
FbTk::EventManager::instance()->add(*this, m_window);
|
||||||
|
m_theme.reconfigSig().attach(this);
|
||||||
|
|
||||||
// just try to blend in... (better than defaulting to white)
|
Fluxbox* fluxbox = Fluxbox::instance();
|
||||||
m_window.setBackgroundPixmap(ParentRelative);
|
Display *disp = fluxbox->display();
|
||||||
|
|
||||||
// setup atom name to _NET_SYSTEM_TRAY_S<screen number>
|
// setup atom name to _NET_SYSTEM_TRAY_S<screen number>
|
||||||
char intbuff[16];
|
char intbuff[16];
|
||||||
|
@ -116,8 +121,6 @@ SystemTray::SystemTray(const FbTk::FbWindow &parent):
|
||||||
std::string atom_name("_NET_SYSTEM_TRAY_S");
|
std::string atom_name("_NET_SYSTEM_TRAY_S");
|
||||||
atom_name += intbuff; // append number
|
atom_name += intbuff; // append number
|
||||||
|
|
||||||
Display *disp = FbTk::App::instance()->display();
|
|
||||||
|
|
||||||
// get selection owner and see if it's free
|
// get selection owner and see if it's free
|
||||||
Atom tray_atom = XInternAtom(disp, atom_name.c_str(), False);
|
Atom tray_atom = XInternAtom(disp, atom_name.c_str(), False);
|
||||||
Window owner = XGetSelectionOwner(disp, tray_atom);
|
Window owner = XGetSelectionOwner(disp, tray_atom);
|
||||||
|
@ -134,11 +137,14 @@ SystemTray::SystemTray(const FbTk::FbWindow &parent):
|
||||||
#endif // DEBUG
|
#endif // DEBUG
|
||||||
// set owner
|
// set owner
|
||||||
XSetSelectionOwner(disp, tray_atom, m_window.window(), CurrentTime);
|
XSetSelectionOwner(disp, tray_atom, m_window.window(), CurrentTime);
|
||||||
|
|
||||||
m_handler.reset(new SystemTrayHandler(*this));
|
m_handler.reset(new SystemTrayHandler(*this));
|
||||||
Fluxbox::instance()->addAtomHandler(m_handler.get(), atom_name);
|
|
||||||
Window root_window = RootWindow(disp, m_window.screenNumber());
|
fluxbox->addAtomHandler(m_handler.get(), atom_name);
|
||||||
|
|
||||||
|
|
||||||
// send selection owner msg
|
// send selection owner msg
|
||||||
|
Window root_window = m_screen.rootWindow().window();
|
||||||
XEvent ce;
|
XEvent ce;
|
||||||
ce.xclient.type = ClientMessage;
|
ce.xclient.type = ClientMessage;
|
||||||
ce.xclient.message_type = XInternAtom(disp, "MANAGER", False);
|
ce.xclient.message_type = XInternAtom(disp, "MANAGER", False);
|
||||||
|
@ -153,12 +159,17 @@ SystemTray::SystemTray(const FbTk::FbWindow &parent):
|
||||||
|
|
||||||
XSendEvent(disp, root_window, false, StructureNotifyMask, &ce);
|
XSendEvent(disp, root_window, false, StructureNotifyMask, &ce);
|
||||||
|
|
||||||
|
update(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemTray::~SystemTray() {
|
SystemTray::~SystemTray() {
|
||||||
// remove us, else fluxbox might delete the memory too
|
// remove us, else fluxbox might delete the memory too
|
||||||
Fluxbox::instance()->removeAtomHandler(m_handler.get());
|
Fluxbox::instance()->removeAtomHandler(m_handler.get());
|
||||||
removeAllClients();
|
removeAllClients();
|
||||||
|
|
||||||
|
if (m_pixmap)
|
||||||
|
m_screen.imageControl().removeImage(m_pixmap);
|
||||||
|
|
||||||
// ~FbWindow cleans EventManager
|
// ~FbWindow cleans EventManager
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,11 +207,13 @@ void SystemTray::hide() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SystemTray::show() {
|
void SystemTray::show() {
|
||||||
|
|
||||||
|
update(0);
|
||||||
m_window.show();
|
m_window.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int SystemTray::width() const {
|
unsigned int SystemTray::width() const {
|
||||||
return m_clients.size()*height();
|
return m_clients.size()* (height() - 2 * m_theme.border().width());
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int SystemTray::height() const {
|
unsigned int SystemTray::height() const {
|
||||||
|
@ -313,6 +326,7 @@ void SystemTray::removeClient(Window win) {
|
||||||
|
|
||||||
void SystemTray::exposeEvent(XExposeEvent &event) {
|
void SystemTray::exposeEvent(XExposeEvent &event) {
|
||||||
m_window.clear();
|
m_window.clear();
|
||||||
|
update(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SystemTray::handleEvent(XEvent &event) {
|
void SystemTray::handleEvent(XEvent &event) {
|
||||||
|
@ -349,11 +363,15 @@ void SystemTray::rearrangeClients() {
|
||||||
ClientList::iterator client_it = m_clients.begin();
|
ClientList::iterator client_it = m_clients.begin();
|
||||||
ClientList::iterator client_it_end = m_clients.end();
|
ClientList::iterator client_it_end = m_clients.end();
|
||||||
int next_x = 0;
|
int next_x = 0;
|
||||||
for (; client_it != client_it_end; ++client_it, next_x += height()) {
|
const unsigned int h = height();
|
||||||
(*client_it)->moveResize(next_x, 0, height(), height());
|
const unsigned int b = m_theme.border().width();
|
||||||
|
for (; client_it != client_it_end;
|
||||||
|
++client_it, next_x += h - 2 * b) {
|
||||||
|
(*client_it)->moveResize(next_x, b, h - b, h - b);
|
||||||
}
|
}
|
||||||
|
|
||||||
resize(next_x, height());
|
resize(next_x, height());
|
||||||
|
update(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SystemTray::removeAllClients() {
|
void SystemTray::removeAllClients() {
|
||||||
|
@ -366,3 +384,34 @@ void SystemTray::removeAllClients() {
|
||||||
m_clients.pop_back();
|
m_clients.pop_back();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SystemTray::update(FbTk::Subject* subject) {
|
||||||
|
|
||||||
|
if (!m_theme.texture().usePixmap()) {
|
||||||
|
m_window.setBackgroundColor(m_theme.texture().color());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(m_pixmap)
|
||||||
|
m_screen.imageControl().removeImage(m_pixmap);
|
||||||
|
m_pixmap = m_screen.imageControl().renderImage(width(), height(),
|
||||||
|
m_theme.texture());
|
||||||
|
m_window.setBackgroundPixmap(m_pixmap);
|
||||||
|
}
|
||||||
|
|
||||||
|
// "themereconfigure"
|
||||||
|
if (subject) {
|
||||||
|
ClientList::iterator client_it = m_clients.begin();
|
||||||
|
ClientList::iterator client_it_end = m_clients.end();
|
||||||
|
int next_x = 0;
|
||||||
|
const unsigned int h = height();
|
||||||
|
const unsigned int b = m_theme.border().width();
|
||||||
|
for (; client_it != client_it_end;
|
||||||
|
++client_it, next_x += h - 2 * b) {
|
||||||
|
|
||||||
|
// maybe not the best solution (yet), force a refresh of the
|
||||||
|
// background of the client
|
||||||
|
(*client_it)->hide();
|
||||||
|
(*client_it)->show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// SystemTray.hh
|
// SystemTray.hh
|
||||||
// Copyright (c) 2003 Henrik Kinnunen (fluxgen at users.sourceforge.net)
|
// Copyright (c) 2003-2005 Henrik Kinnunen (fluxgen at users.sourceforge.net)
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
|
@ -27,8 +27,11 @@
|
||||||
|
|
||||||
#include "FbTk/FbWindow.hh"
|
#include "FbTk/FbWindow.hh"
|
||||||
#include "FbTk/EventHandler.hh"
|
#include "FbTk/EventHandler.hh"
|
||||||
|
#include "FbTk/Observer.hh"
|
||||||
|
|
||||||
#include "ToolbarItem.hh"
|
#include "ToolbarItem.hh"
|
||||||
|
#include "ButtonTheme.hh"
|
||||||
|
#include "Screen.hh"
|
||||||
|
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
|
|
||||||
|
@ -36,10 +39,10 @@
|
||||||
|
|
||||||
class AtomHandler;
|
class AtomHandler;
|
||||||
|
|
||||||
class SystemTray: public ToolbarItem, public FbTk::EventHandler {
|
class SystemTray: public ToolbarItem, public FbTk::EventHandler, public FbTk::Observer {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
explicit SystemTray(const FbTk::FbWindow &parent);
|
explicit SystemTray(const FbTk::FbWindow &parent, ButtonTheme &theme, BScreen& screen);
|
||||||
virtual ~SystemTray();
|
virtual ~SystemTray();
|
||||||
|
|
||||||
void move(int x, int y);
|
void move(int x, int y);
|
||||||
|
@ -69,6 +72,9 @@ public:
|
||||||
inline void updateSizing() {}
|
inline void updateSizing() {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
void update(FbTk::Subject *subj);
|
||||||
|
|
||||||
typedef std::list<FbTk::FbWindow *> ClientList;
|
typedef std::list<FbTk::FbWindow *> ClientList;
|
||||||
ClientList::iterator findClient(Window win);
|
ClientList::iterator findClient(Window win);
|
||||||
|
|
||||||
|
@ -76,6 +82,9 @@ private:
|
||||||
void removeAllClients();
|
void removeAllClients();
|
||||||
|
|
||||||
FbTk::FbWindow m_window;
|
FbTk::FbWindow m_window;
|
||||||
|
ButtonTheme& m_theme;
|
||||||
|
BScreen& m_screen;
|
||||||
|
Pixmap m_pixmap;
|
||||||
|
|
||||||
std::auto_ptr<AtomHandler> m_handler;
|
std::auto_ptr<AtomHandler> m_handler;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// ToolFactory.cc for Fluxbox
|
// ToolFactory.cc for Fluxbox
|
||||||
// Copyright (c) 2003-2004 Henrik Kinnunen (fluxgen at users.sourceforge.net)
|
// Copyright (c) 2003-2005 Henrik Kinnunen (fluxgen at users.sourceforge.net)
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
|
@ -77,6 +77,8 @@ ToolFactory::ToolFactory(BScreen &screen):m_screen(screen),
|
||||||
m_clock_theme(screen.screenNumber(), "toolbar.clock", "Toolbar.Clock"),
|
m_clock_theme(screen.screenNumber(), "toolbar.clock", "Toolbar.Clock"),
|
||||||
m_button_theme(new ButtonTheme(screen.screenNumber(), "toolbar.button", "Toolbar.Button",
|
m_button_theme(new ButtonTheme(screen.screenNumber(), "toolbar.button", "Toolbar.Button",
|
||||||
"toolbar.clock", "Toolbar.Clock")),
|
"toolbar.clock", "Toolbar.Clock")),
|
||||||
|
m_systray_theme(new ButtonTheme(screen.screenNumber(), "toolbar.systray", "Toolbar.Systray",
|
||||||
|
"toolbar.clock", "Toolbar.Systray")),
|
||||||
m_workspace_theme(new WorkspaceNameTheme(screen.screenNumber(), "toolbar.workspace", "Toolbar.Workspace")),
|
m_workspace_theme(new WorkspaceNameTheme(screen.screenNumber(), "toolbar.workspace", "Toolbar.Workspace")),
|
||||||
m_iconbar_theme(screen.screenNumber(), "toolbar.iconbar", "Toolbar.Iconbar") {
|
m_iconbar_theme(screen.screenNumber(), "toolbar.iconbar", "Toolbar.Iconbar") {
|
||||||
|
|
||||||
|
@ -97,10 +99,9 @@ ToolbarItem *ToolFactory::create(const std::string &name, const FbTk::FbWindow &
|
||||||
witem->button().setOnClick(showmenu);
|
witem->button().setOnClick(showmenu);
|
||||||
item = witem;
|
item = witem;
|
||||||
} else if (name == "iconbar") {
|
} else if (name == "iconbar") {
|
||||||
item = new IconbarTool(parent, m_iconbar_theme,
|
item = new IconbarTool(parent, m_iconbar_theme, screen(), tbar.menu());
|
||||||
screen(), tbar.menu());
|
|
||||||
} else if (name == "systemtray") {
|
} else if (name == "systemtray") {
|
||||||
item = new SystemTray(parent);
|
item = new SystemTray(parent, dynamic_cast<ButtonTheme &>(*m_systray_theme), screen());
|
||||||
} else if (name == "clock") {
|
} else if (name == "clock") {
|
||||||
item = new ClockTool(parent, m_clock_theme, screen(), tbar.menu());
|
item = new ClockTool(parent, m_clock_theme, screen(), tbar.menu());
|
||||||
} else if (name == "nextworkspace" ||
|
} else if (name == "nextworkspace" ||
|
||||||
|
|
|
@ -52,7 +52,9 @@ public:
|
||||||
private:
|
private:
|
||||||
BScreen &m_screen;
|
BScreen &m_screen;
|
||||||
ToolTheme m_clock_theme;
|
ToolTheme m_clock_theme;
|
||||||
std::auto_ptr<ToolTheme> m_button_theme, m_workspace_theme;
|
std::auto_ptr<ToolTheme> m_button_theme;
|
||||||
|
std::auto_ptr<ToolTheme> m_workspace_theme;
|
||||||
|
std::auto_ptr<ToolTheme> m_systray_theme;
|
||||||
IconbarTheme m_iconbar_theme;
|
IconbarTheme m_iconbar_theme;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue