diff options
| -rw-r--r-- | plugins/unityshell/src/unityshell.cpp | 81 | ||||
| -rw-r--r-- | plugins/unityshell/src/unityshell.h | 5 | ||||
| -rw-r--r-- | unity-shared/PluginAdapter.h | 4 | ||||
| -rw-r--r-- | unity-shared/PluginAdapterCompiz.cpp | 76 | ||||
| -rw-r--r-- | unity-shared/PluginAdapterStandalone.cpp | 6 | ||||
| -rw-r--r-- | unity-shared/WindowManager.cpp | 5 | ||||
| -rw-r--r-- | unity-shared/WindowManager.h | 2 |
7 files changed, 94 insertions, 85 deletions
diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp index 640fd3654..a22da6e54 100644 --- a/plugins/unityshell/src/unityshell.cpp +++ b/plugins/unityshell/src/unityshell.cpp @@ -3611,7 +3611,7 @@ void UnityWindow::RenderText (WindowCairoContext *context, pango_layout_set_auto_dir (layout, false); pango_layout_set_text (layout, - GetWindowName (window->id ()).c_str (), + WindowManager::Default()->GetWindowName(window->id()).c_str(), -1); /* update the size of the pango layout */ @@ -3863,85 +3863,6 @@ bool UnityPluginVTable::init() return true; } -CompString UnityWindow::GetUtf8Property (Window id, - Atom atom) -{ - Atom type; - int result, format; - unsigned long nItems, bytesAfter; - char *val; - CompString retval; - Atom utf8StringAtom; - - utf8StringAtom = XInternAtom (screen->dpy (), "UTF8_STRING", 0); - result = XGetWindowProperty (screen->dpy (), id, atom, 0L, 65536, False, - utf8StringAtom, &type, &format, &nItems, - &bytesAfter, (unsigned char **) &val); - - if (result != Success) - return retval; - - if (type == utf8StringAtom && format == 8 && val && nItems > 0) - { - char valueString[nItems + 1]; - strncpy (valueString, val, nItems); - valueString[nItems] = 0; - retval = valueString; - } - if (val) - XFree (val); - - return retval; -} - -CompString UnityWindow::GetTextProperty (Window id, - Atom atom) -{ - XTextProperty text; - CompString retval; - - text.nitems = 0; - if (XGetTextProperty (screen->dpy (), id, &text, atom)) - { - if (text.value) - { - char valueString[text.nitems + 1]; - - strncpy (valueString, (char *) text.value, text.nitems); - valueString[text.nitems] = 0; - - retval = valueString; - - XFree (text.value); - } - } - - return retval; -} - - -CompString UnityWindow::GetWindowName (Window id) -{ - CompString name; - Atom visibleNameAtom; - - visibleNameAtom = XInternAtom (screen->dpy (), "_NET_WM_VISIBLE_NAME", 0); - name = GetUtf8Property (id, visibleNameAtom); - if (name.empty ()) - { - Atom wmNameAtom = XInternAtom (screen->dpy (), "_NET_WM_NAME", 0); - name = GetUtf8Property (id, wmNameAtom); - } - - - if (name.empty ()) - name = GetTextProperty (id, XA_WM_NAME); - - return name; -} - - - namespace { diff --git a/plugins/unityshell/src/unityshell.h b/plugins/unityshell/src/unityshell.h index b9bea314a..b9afe93d2 100644 --- a/plugins/unityshell/src/unityshell.h +++ b/plugins/unityshell/src/unityshell.h @@ -482,11 +482,6 @@ private: float maxWidth, float maxHeight); WindowCairoContext* CreateCairoContext (float width, float height); - // based on compiz text plugin - CompString GetWindowName (Window id); - CompString GetUtf8Property (Window id, Atom atom); - CompString GetTextProperty (Window id, Atom atom); - compiz::WindowInputRemoverLock::Weak input_remover_; glib::Source::UniquePtr focus_desktop_timeout_; diff --git a/unity-shared/PluginAdapter.h b/unity-shared/PluginAdapter.h index 8c9882bd1..a6fda2bcf 100644 --- a/unity-shared/PluginAdapter.h +++ b/unity-shared/PluginAdapter.h @@ -154,6 +154,7 @@ public: nux::Geometry GetWindowSavedGeometry(guint32 xid) const; nux::Geometry GetScreenGeometry() const; nux::Geometry GetWorkAreaGeometry(guint32 xid = 0) const; + std::string GetWindowName(guint32 xid) const; void CheckWindowIntersections(nux::Geometry const& region, bool &active, bool &any); @@ -177,6 +178,9 @@ private: bool CheckWindowIntersection(nux::Geometry const& region, CompWindow* window) const; void SetMwmWindowHints(Window xid, MotifWmHints* new_hints); + std::string GetTextProperty(guint32 xid, Atom atom) const; + std::string GetUtf8Property(guint32 xid, Atom atom) const; + CompScreen* m_Screen; MultiActionList m_ExpoActionList; MultiActionList m_ScaleActionList; diff --git a/unity-shared/PluginAdapterCompiz.cpp b/unity-shared/PluginAdapterCompiz.cpp index 1c67e9659..88cb21ebb 100644 --- a/unity-shared/PluginAdapterCompiz.cpp +++ b/unity-shared/PluginAdapterCompiz.cpp @@ -1335,3 +1335,79 @@ PluginAdapter::AddProperties(GVariantBuilder* builder) .add("viewport_switch_running", IsViewPortSwitchStarted()) .add("showdesktop_active", _in_show_desktop); } + +std::string +PluginAdapter::GetWindowName(guint32 xid) const +{ + std::string name; + Atom visibleNameAtom; + + visibleNameAtom = XInternAtom(m_Screen->dpy(), "_NET_WM_VISIBLE_NAME", 0); + name = GetUtf8Property(xid, visibleNameAtom); + if (name.empty()) + { + Atom wmNameAtom = XInternAtom(m_Screen->dpy(), "_NET_WM_NAME", 0); + name = GetUtf8Property(xid, wmNameAtom); + } + + if (name.empty()) + name = GetTextProperty(xid, XA_WM_NAME); + + return name; +} + +std::string +PluginAdapter::GetUtf8Property(guint32 xid, Atom atom) const +{ + Atom type; + int result, format; + unsigned long nItems, bytesAfter; + char *val; + std::string retval; + Atom utf8StringAtom; + + utf8StringAtom = XInternAtom(m_Screen->dpy(), "UTF8_STRING", 0); + result = XGetWindowProperty(m_Screen->dpy(), xid, atom, 0L, 65536, False, + utf8StringAtom, &type, &format, &nItems, + &bytesAfter, reinterpret_cast<unsigned char **>(&val)); + + if (result != Success) + return retval; + + if (type == utf8StringAtom && format == 8 && val && nItems > 0) + { + char valueString[nItems + 1]; + strncpy(valueString, val, nItems); + valueString[nItems] = 0; + retval = valueString; + } + if (val) + XFree(val); + + return retval; +} + +std::string +PluginAdapter::GetTextProperty(guint32 id, Atom atom) const +{ + XTextProperty text; + std::string retval; + + text.nitems = 0; + if (XGetTextProperty(m_Screen->dpy(), id, &text, atom)) + { + if (text.value) + { + char valueString[text.nitems + 1]; + + strncpy(valueString, reinterpret_cast<char *>(text.value), text.nitems); + valueString[text.nitems] = 0; + + retval = valueString; + + XFree (text.value); + } + } + + return retval; +} diff --git a/unity-shared/PluginAdapterStandalone.cpp b/unity-shared/PluginAdapterStandalone.cpp index 9ba893021..9e31f2a1b 100644 --- a/unity-shared/PluginAdapterStandalone.cpp +++ b/unity-shared/PluginAdapterStandalone.cpp @@ -458,3 +458,9 @@ PluginAdapter::AddProperties(GVariantBuilder* builder) .add("viewport_switch_running", IsViewPortSwitchStarted()) .add("showdesktop_active", _in_show_desktop); } + +std::string +PluginAdapter::GetWindowName(guint32 xid) const +{ + return ""; +} diff --git a/unity-shared/WindowManager.cpp b/unity-shared/WindowManager.cpp index 5f5cd6519..df983217c 100644 --- a/unity-shared/WindowManager.cpp +++ b/unity-shared/WindowManager.cpp @@ -240,6 +240,11 @@ class WindowManagerDummy : public WindowManager void AddProperties(GVariantBuilder* builder) { } + + std::string GetWindowName(guint32 xid) const + { + return "unknown"; + } }; WindowManager* diff --git a/unity-shared/WindowManager.h b/unity-shared/WindowManager.h index 84ae82485..204c9439c 100644 --- a/unity-shared/WindowManager.h +++ b/unity-shared/WindowManager.h @@ -111,6 +111,8 @@ public: virtual bool saveInputFocus() = 0; virtual bool restoreInputFocus() = 0; + virtual std::string GetWindowName(guint32 xid) const = 0; + // Signals sigc::signal<void, guint32> window_mapped; sigc::signal<void, guint32> window_unmapped; |
