From 95193fd598968fc0ad5ea113410c6fd6e6042629 Mon Sep 17 00:00:00 2001 From: fluxgen Date: Sun, 22 Jun 2003 12:35:03 +0000 Subject: moved getWMName to Xutil --- src/SlitClient.cc | 53 +++-------------------------------------------------- src/WinClient.cc | 44 +++++++------------------------------------- 2 files changed, 10 insertions(+), 87 deletions(-) diff --git a/src/SlitClient.cc b/src/SlitClient.cc index 74a10a4..fe2567f 100644 --- a/src/SlitClient.cc +++ b/src/SlitClient.cc @@ -19,64 +19,17 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: SlitClient.cc,v 1.1 2003/06/20 01:25:26 fluxgen Exp $ +// $Id: SlitClient.cc,v 1.2 2003/06/22 12:30:59 fluxgen Exp $ #include "SlitClient.hh" -#include "I18n.hh" #include "Screen.hh" #include "App.hh" +#include "Xutil.hh" #include #include -namespace { - -void getWMName(BScreen *screen, Window window, std::string& name) { - name = ""; - - if (screen == 0 || window == None) - return; - - Display *display = FbTk::App::instance()->display(); - - XTextProperty text_prop; - char **list; - int num; - I18n *i18n = I18n::instance(); - - if (XGetWMName(display, window, &text_prop)) { - if (text_prop.value && text_prop.nitems > 0) { - if (text_prop.encoding != XA_STRING) { - - text_prop.nitems = strlen((char *) text_prop.value); - - if ((XmbTextPropertyToTextList(display, &text_prop, - &list, &num) == Success) && - (num > 0) && *list) { - name = static_cast(*list); - XFreeStringList(list); - } else - name = (char *)text_prop.value; - - } else - name = (char *)text_prop.value; - } else { // default name - name = i18n->getMessage( - FBNLS::WindowSet, FBNLS::WindowUnnamed, - "Unnamed"); - } - } else { - // default name - name = i18n->getMessage( - FBNLS::WindowSet, FBNLS::WindowUnnamed, - "Unnamed"); - } - -} - -}; // end anonymous namespace - SlitClient::SlitClient(BScreen *screen, Window win) { initialize(screen, win); } @@ -100,7 +53,7 @@ void SlitClient::initialize(BScreen *screen, Window win) { resize(0, 0); if (matchName().empty()) - getWMName(screen, clientWindow(), m_match_name); + m_match_name = Xutil::getWMName(clientWindow()); m_visible = true; } diff --git a/src/WinClient.cc b/src/WinClient.cc index ea29bc2..88be980 100644 --- a/src/WinClient.cc +++ b/src/WinClient.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: WinClient.cc,v 1.12 2003/06/15 18:36:16 fluxgen Exp $ +// $Id: WinClient.cc,v 1.13 2003/06/22 12:35:03 fluxgen Exp $ #include "WinClient.hh" @@ -29,6 +29,7 @@ #include "I18n.hh" #include "FbAtoms.hh" #include "EventManager.hh" +#include "Xutil.hh" #include #include @@ -256,39 +257,7 @@ void WinClient::updateTransientInfo() { void WinClient::updateTitle() { - XTextProperty text_prop; - char **list = 0; - int num = 0; - I18n *i18n = I18n::instance(); - - if (getWMName(text_prop)) { - if (text_prop.value && text_prop.nitems > 0) { - if (text_prop.encoding != XA_STRING) { - - text_prop.nitems = strlen((char *) text_prop.value); - - if (XmbTextPropertyToTextList(FbTk::App::instance()->display(), &text_prop, - &list, &num) == Success && - num > 0 && *list) { - m_title = static_cast(*list); - XFreeStringList(list); - } else - m_title = (char *)text_prop.value; - - } else - m_title = (char *)text_prop.value; - XFree((char *) text_prop.value); - } else { // ok, we don't have a name, set default name - m_title = i18n->getMessage( - FBNLS::WindowSet, FBNLS::WindowUnnamed, - "Unnamed"); - } - } else { - m_title = i18n->getMessage( - FBNLS::WindowSet, FBNLS::WindowUnnamed, - "Unnamed"); - } - + m_title = Xutil::getWMName(window()); } void WinClient::updateIconTitle() { @@ -307,11 +276,12 @@ void WinClient::updateIconTitle() { m_icon_title = (char *)*list; XFreeStringList(list); } else - m_icon_title = (char *)text_prop.value; + m_icon_title = text_prop.value ? (char *)text_prop.value : ""; } else - m_icon_title = (char *)text_prop.value; + m_icon_title = text_prop.value ? (char *)text_prop.value : ""; - XFree((char *) text_prop.value); + if (text_prop.value) + XFree((char *) text_prop.value); } else m_icon_title = title(); } else -- cgit v0.11.2