X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/27dee9ae02f0afc054fe7a90bc3d077df1d7914a..528a5e8f92e938407ee2c33b29e519af064e6608:/src/gtk/utilsgtk.cpp diff --git a/src/gtk/utilsgtk.cpp b/src/gtk/utilsgtk.cpp index ae645105e1..1144d39c3a 100644 --- a/src/gtk/utilsgtk.cpp +++ b/src/gtk/utilsgtk.cpp @@ -47,6 +47,12 @@ #undef explicit #endif // HAVE_X11_XKBLIB_H + +#if wxUSE_DETECT_SM + #include "X11/Xlib.h" + #include "X11/SM/SMlib.h" +#endif + //----------------------------------------------------------------------------- // data //----------------------------------------------------------------------------- @@ -283,3 +289,59 @@ wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj, int *verMin) const return wxPORT_GTK; } + +#if wxUSE_DETECT_SM +static wxString GetSM() +{ + class Dpy + { + public: + Dpy() { m_dpy = XOpenDisplay(NULL); } + ~Dpy() { if ( m_dpy ) XCloseDisplay(m_dpy); } + + operator Display *() const { return m_dpy; } + private: + Display *m_dpy; + } dpy; + + if ( !dpy ) + return wxEmptyString; + + char *client_id; + SmcConn smc_conn = SmcOpenConnection(NULL, NULL, + 999, 999, + 0 /* mask */, NULL /* callbacks */, + NULL, &client_id, + 0, NULL); + + if ( !smc_conn ) + return wxEmptyString; + + char *vendor = SmcVendor(smc_conn); + wxString ret = wxString::FromAscii( vendor ); + free(vendor); + + SmcCloseConnection(smc_conn, 0, NULL); + free(client_id); + + return ret; +} +#endif // wxUSE_DETECT_SM + +wxString wxGUIAppTraits::GetDesktopEnvironment() const +{ +#if wxUSE_DETECT_SM + const wxString SM = GetSM(); + + if (SM == wxT("GnomeSM")) + return wxT("GNOME"); + + if (SM == wxT("KDE")) + return wxT("KDE"); +#endif // wxUSE_DETECT_SM + + return wxEmptyString; +} + + +