From 3c06e9e93fd2057e26bb9df081d8b732916c49d5 Mon Sep 17 00:00:00 2001 From: Mathias Gumz Date: Sat, 9 Jan 2016 18:30:22 +0100 Subject: minor code cosmetics --- src/SystemTray.cc | 34 +++++++++++++++++++++------------- src/SystemTray.hh | 11 ++++++----- 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/src/SystemTray.cc b/src/SystemTray.cc index c908f3e..e45669e 100644 --- a/src/SystemTray.cc +++ b/src/SystemTray.cc @@ -38,39 +38,47 @@ #include -using std::string; - +using std::string; using std::endl; using std::hex; using std::dec; + +namespace { + void getScreenCoordinates(Window win, int x, int y, int &screen_x, int &screen_y) { + XWindowAttributes attr; if (XGetWindowAttributes(FbTk::App::instance()->display(), win, &attr) == 0) { return; } - Window child_win; // not used - Window parent_win; // not used - Window root_win = 0; - Window* child_windows; // not used - unsigned int num_child_windows; // not used + Window unused_win; + Window parent_win; + Window root_win = 0; + Window* unused_childs = 0; + unsigned int unused_number; + XQueryTree(FbTk::App::instance()->display(), win, &root_win, &parent_win, - &child_windows, &num_child_windows); - if (child_windows != 0) { - XFree(child_windows); + &unused_childs, &unused_number); + + if (unused_childs != 0) { + XFree(unused_childs); } + XTranslateCoordinates(FbTk::App::instance()->display(), parent_win, root_win, x, y, - &screen_x, &screen_y, &child_win); + &screen_x, &screen_y, &unused_win); } +}; + /// helper class for tray windows, so we dont call XDestroyWindow -class TrayWindow: public FbTk::FbWindow { +class SystemTray::TrayWindow : public FbTk::FbWindow { public: TrayWindow(Window win, bool using_xembed):FbTk::FbWindow(win), m_visible(false), m_xembedded(using_xembed) { setEventMask(PropertyChangeMask); @@ -183,7 +191,7 @@ SystemTray::SystemTray(const FbTk::FbWindow& parent, m_screen(screen), m_pixmap(0), m_num_visible_clients(0), m_selection_owner(m_window, 0, 0, 1, 1, SubstructureNotifyMask, false, false, CopyFromParent, InputOnly) { - + FbTk::EventManager::instance()->add(*this, m_window); FbTk::EventManager::instance()->add(*this, m_selection_owner); // setup signals diff --git a/src/SystemTray.hh b/src/SystemTray.hh index d92e437..61cd1bb 100644 --- a/src/SystemTray.hh +++ b/src/SystemTray.hh @@ -35,7 +35,6 @@ class BScreen; class ButtonTheme; -class TrayWindow; class AtomHandler; namespace FbTk { @@ -73,12 +72,13 @@ public: int numClients() const { return m_clients.size(); } const FbTk::FbWindow &window() const { return m_window; } - void renderTheme(int alpha) { + void renderTheme(int alpha) { m_window.setBorderWidth(m_theme->border().width()); m_window.setBorderColor(m_theme->border().color()); - m_window.setAlpha(alpha); - update(); + m_window.setAlpha(alpha); + update(); } + void updateSizing() { m_window.setBorderWidth(m_theme->border().width()); } void parentMoved() { m_window.parentMoved(); } @@ -90,7 +90,8 @@ public: private: void update(); - typedef std::list ClientList; + class TrayWindow; + typedef std::list ClientList; ClientList::iterator findClient(Window win); void rearrangeClients(); -- cgit v0.11.2