From 36489e4a17df27965ff14b7fd0a9482b4cf47882 Mon Sep 17 00:00:00 2001
From: "Vladimir A. Pavlov" <pv4@bk.ru>
Date: Mon, 22 Oct 2012 19:39:35 +0400
Subject: Set WM_WINDOW_ROLE for fluxbox windows

---
 src/FbMenu.cc        | 1 +
 src/FbTk/FbWindow.cc | 7 +++++++
 src/FbTk/FbWindow.hh | 2 ++
 src/Slit.cc          | 2 ++
 src/TextDialog.cc    | 1 +
 src/Toolbar.cc       | 2 ++
 6 files changed, 15 insertions(+)

diff --git a/src/FbMenu.cc b/src/FbMenu.cc
index dffd07c..2871042 100644
--- a/src/FbMenu.cc
+++ b/src/FbMenu.cc
@@ -33,6 +33,7 @@ FbMenu::FbMenu(FbTk::ThemeProxy<FbTk::MenuTheme> &tm,
     FbTk::Menu(tm, imgctrl), 
     m_layeritem(fbwindow(), layer) {
 
+    fbwindow().setWindowRole("fluxbox-menu");
 }
 
 void FbMenu::buttonPressEvent(XButtonEvent &be) {
diff --git a/src/FbTk/FbWindow.cc b/src/FbTk/FbWindow.cc
index 8362733..257447f 100644
--- a/src/FbTk/FbWindow.cc
+++ b/src/FbTk/FbWindow.cc
@@ -265,6 +265,13 @@ void FbWindow::setName(const char *name) {
     XStoreName(display(), m_window, name);
 }
 
+void FbWindow::setWindowRole(const char *windowRole) {
+    XTextProperty tp;
+    XStringListToTextProperty(const_cast<char **>(&windowRole), 1, &tp);
+    XSetTextProperty(display(), m_window, &tp, XInternAtom(display(), "WM_WINDOW_ROLE", False));
+    XFree(tp.value);
+}
+
 void FbWindow::setEventMask(long mask) {
     XSelectInput(display(), m_window, mask);
 }
diff --git a/src/FbTk/FbWindow.hh b/src/FbTk/FbWindow.hh
index 9d335fa..3e1c05b 100644
--- a/src/FbTk/FbWindow.hh
+++ b/src/FbTk/FbWindow.hh
@@ -87,6 +87,8 @@ public:
     virtual void setBorderWidth(unsigned int size);
     /// set window name ("title")
     void setName(const char *name);
+    /// set window role
+    void setWindowRole(const char *windowRole);
     void setEventMask(long mask);
     /// clear window with background pixmap or color
     virtual void clear();
diff --git a/src/Slit.cc b/src/Slit.cc
index 738a81a..7d6b1ef 100644
--- a/src/Slit.cc
+++ b/src/Slit.cc
@@ -262,6 +262,8 @@ Slit::Slit(BScreen &scr, FbTk::Layer &layer, const char *filename)
 
     _FB_USES_NLS;
 
+    frame.window.setWindowRole("fluxbox-slit");
+
     // attach to theme and root window change signal
     join(theme().reconfigSig(), FbTk::MemFun(*this, &Slit::reconfigure));
 
diff --git a/src/TextDialog.cc b/src/TextDialog.cc
index f86c1e6..d27a551 100644
--- a/src/TextDialog.cc
+++ b/src/TextDialog.cc
@@ -50,6 +50,7 @@ TextDialog::TextDialog(BScreen &screen,
     m_move_x(0),
     m_move_y(0),
     m_pixmap(0){
+    setWindowRole("fluxbox-dialog-text");
     init();
 }
 
diff --git a/src/Toolbar.cc b/src/Toolbar.cc
index f46b9e9..5f4cc80 100644
--- a/src/Toolbar.cc
+++ b/src/Toolbar.cc
@@ -225,6 +225,8 @@ Toolbar::Toolbar(BScreen &scrn, FbTk::Layer &layer, size_t width):
     m_resize_lock(false) {
     _FB_USES_NLS;
 
+    frame.window.setWindowRole("fluxbox-toolbar");
+
     // get this on antialias change
     m_signal_tracker.join(screen().reconfigureSig(),
             FbTk::MemFunIgnoreArgs(*this, &Toolbar::reconfigure));
-- 
cgit v0.11.2