fluxbox/src/SystemTray.hh

128 lines
3.9 KiB
C++
Raw Normal View History

2003-08-15 13:48:50 +00:00
// SystemTray.hh
2006-02-16 06:53:05 +00:00
// Copyright (c) 2003 - 2006 Henrik Kinnunen (fluxgen at fluxbox dot org)
2003-08-15 13:48:50 +00:00
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
#ifndef SYSTEMTRAY_HH
#define SYSTEMTRAY_HH
#include "FbTk/FbWindow.hh"
#include "FbTk/EventHandler.hh"
#include "FbTk/Signal.hh"
#include "FbTk/Resource.hh"
2003-08-15 13:48:50 +00:00
2008-04-15 08:55:14 +00:00
#include "ToolTheme.hh"
2003-08-15 13:48:50 +00:00
#include "ToolbarItem.hh"
#include <list>
#include <memory>
#include <string>
2003-08-15 13:48:50 +00:00
class BScreen;
class ButtonTheme;
2003-08-15 13:48:50 +00:00
class AtomHandler;
2008-01-05 01:39:19 +00:00
namespace FbTk {
template <class T> class ThemeProxy;
}
class SystemTray: public ToolbarItem, public FbTk::EventHandler,
private FbTk::SignalTracker {
2003-08-15 13:48:50 +00:00
public:
2008-01-05 01:39:19 +00:00
explicit SystemTray(const FbTk::FbWindow &parent,
2008-04-15 08:55:14 +00:00
FbTk::ThemeProxy<ToolTheme> &theme, BScreen& screen);
2003-08-16 12:12:21 +00:00
virtual ~SystemTray();
2003-08-15 13:48:50 +00:00
void move(int x, int y);
void resize(unsigned int width, unsigned int height);
void moveResize(int x, int y,
unsigned int width, unsigned int height);
void show();
void hide();
bool active() { return !m_clients.empty(); }
2003-08-15 13:48:50 +00:00
bool clientMessage(const XClientMessageEvent &event);
void exposeEvent(XExposeEvent &event);
void handleEvent(XEvent &event);
2007-08-06 04:19:48 +00:00
void addClient(Window win, bool using_xembed);
2007-08-04 17:14:13 +00:00
void removeClient(Window win, bool destroyed);
2004-04-19 22:48:19 +00:00
2003-08-15 13:48:50 +00:00
unsigned int width() const;
unsigned int height() const;
unsigned int borderWidth() const;
2003-08-16 12:12:21 +00:00
int numClients() const { return m_clients.size(); }
const FbTk::FbWindow &window() const { return m_window; }
2016-01-09 17:30:22 +00:00
void renderTheme(int alpha) {
2008-04-15 08:55:14 +00:00
m_window.setBorderWidth(m_theme->border().width());
m_window.setBorderColor(m_theme->border().color());
2016-01-09 17:30:22 +00:00
m_window.setAlpha(alpha);
update();
2008-04-15 08:55:14 +00:00
}
2016-01-09 17:30:22 +00:00
2008-04-15 08:55:14 +00:00
void updateSizing() { m_window.setBorderWidth(m_theme->border().width()); }
2004-08-25 17:16:40 +00:00
void parentMoved() { m_window.parentMoved(); }
static std::string getNetSystemTrayAtom(int screen_nr);
2007-08-06 04:19:48 +00:00
static Atom getXEmbedInfoAtom();
static bool doesControl(Window win);
2003-08-15 13:48:50 +00:00
private:
void update();
void sortClients();
2016-01-09 17:30:22 +00:00
class TrayWindow;
typedef std::list<TrayWindow*> ClientList;
2003-08-15 13:48:50 +00:00
ClientList::iterator findClient(Window win);
2004-04-19 22:48:19 +00:00
2003-08-15 13:48:50 +00:00
void rearrangeClients();
void removeAllClients();
2007-08-04 17:14:13 +00:00
void hideClient(TrayWindow *traywin, bool destroyed = false);
void showClient(TrayWindow *traywin);
2003-08-15 13:48:50 +00:00
FbTk::FbWindow m_window;
2008-04-15 08:55:14 +00:00
FbTk::ThemeProxy<ToolTheme> &m_theme;
BScreen& m_screen;
Pixmap m_pixmap;
2003-08-15 13:48:50 +00:00
std::unique_ptr<AtomHandler> m_handler;
2003-08-15 13:48:50 +00:00
ClientList m_clients;
size_t m_num_visible_clients;
2007-08-04 17:14:13 +00:00
// gaim/pidgin seems to barf if the selection is not an independent window.
// I suspect it's an interacton with parent relationship and gdk window caching.
FbTk::FbWindow m_selection_owner;
// resources
FbTk::Resource<std::string> m_rc_systray_pinleft;
FbTk::Resource<std::string> m_rc_systray_pinright;
std::vector<std::string> m_pinleft, m_pinright;
2003-08-15 13:48:50 +00:00
};
#endif // SYSTEMTRAY_HH