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"
|
2008-09-21 14:12:36 +00:00
|
|
|
#include "FbTk/Signal.hh"
|
2013-12-14 07:43:26 +00:00
|
|
|
#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>
|
2008-04-27 19:22:18 +00:00
|
|
|
#include <memory>
|
2013-12-14 07:43:26 +00:00
|
|
|
#include <string>
|
2003-08-15 13:48:50 +00:00
|
|
|
|
2007-12-30 06:44:11 +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;
|
|
|
|
}
|
|
|
|
|
2008-09-21 14:12:36 +00:00
|
|
|
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();
|
|
|
|
|
2003-10-31 10:37:09 +00:00
|
|
|
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
|
|
|
|
2006-04-17 15:19:07 +00:00
|
|
|
void parentMoved() { m_window.parentMoved(); }
|
|
|
|
|
2010-08-23 17:49:47 +00:00
|
|
|
static std::string getNetSystemTrayAtom(int screen_nr);
|
|
|
|
|
2007-08-06 04:19:48 +00:00
|
|
|
static Atom getXEmbedInfoAtom();
|
|
|
|
|
2016-07-04 19:55:23 +00:00
|
|
|
static bool doesControl(Window win);
|
|
|
|
|
2003-08-15 13:48:50 +00:00
|
|
|
private:
|
2008-04-27 19:22:18 +00:00
|
|
|
void update();
|
2013-12-14 07:43:26 +00:00
|
|
|
void sortClients();
|
2007-12-29 21:38:53 +00:00
|
|
|
|
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);
|
2007-02-23 00:36:32 +00:00
|
|
|
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;
|
2005-01-14 09:58:16 +00:00
|
|
|
BScreen& m_screen;
|
|
|
|
Pixmap m_pixmap;
|
2003-08-15 13:48:50 +00:00
|
|
|
|
2016-08-27 08:05:34 +00:00
|
|
|
std::unique_ptr<AtomHandler> m_handler;
|
2003-08-15 13:48:50 +00:00
|
|
|
|
|
|
|
ClientList m_clients;
|
2007-02-23 00:36:32 +00:00
|
|
|
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;
|
2013-12-14 07:43:26 +00:00
|
|
|
|
|
|
|
// resources
|
|
|
|
FbTk::Resource<std::string> m_rc_systray_pinleft;
|
|
|
|
FbTk::Resource<std::string> m_rc_systray_pinright;
|
2014-01-08 19:38:00 +00:00
|
|
|
std::vector<std::string> m_pinleft, m_pinright;
|
2003-08-15 13:48:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // SYSTEMTRAY_HH
|