diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-03-03 13:45:23 -0600 |
---|---|---|
committer | Slávek Banko <slavek.banko@axis.cz> | 2012-06-03 03:26:55 +0200 |
commit | 2482dd05e5b7806b4bad69ac8e07dbc4dd6714e0 (patch) | |
tree | 7288de5be377d8fcb6554bf76d45e3705cbcca8d /kwin | |
parent | 44068385780a675e5181730733df308c138c78ff (diff) | |
download | tdebase-2482dd05e5b7806b4bad69ac8e07dbc4dd6714e0.tar.gz tdebase-2482dd05e5b7806b4bad69ac8e07dbc4dd6714e0.zip |
Fix hostname display in titlebar with certain programs
This closes Bug 889
Thanks to Slávek Banko for the patch!
(cherry picked from commit 9e3f8a7f0c9f2ed1125c717f5374aaf8d4ec225e)
Diffstat (limited to 'kwin')
-rw-r--r-- | kwin/utils.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/kwin/utils.cpp b/kwin/utils.cpp index 34d29f98a..a2e563d88 100644 --- a/kwin/utils.cpp +++ b/kwin/utils.cpp @@ -18,6 +18,8 @@ License. See the file "COPYING" for the exact licensing terms. #include "utils.h" #include <unistd.h> +#include <string.h> +#include <netdb.h> #ifndef KCMRULES @@ -323,6 +325,27 @@ bool isLocalMachine( const TQCString& host ) if( host == hostnamebuf ) return true; } + else + { // e.g. LibreOffice likes to give FQDN, even if gethostname() doesn't include domain + struct addrinfo hints, *res, *addr; + bool is_local = false; + + memset (&hints, 0, sizeof (hints)); + hints.ai_family = PF_UNSPEC; + hints.ai_socktype = SOCK_STREAM; + hints.ai_flags |= AI_CANONNAME; + + if( getaddrinfo( host, NULL, &hints, &res ) != 0) + return false; + for(addr = res; !is_local && addr; addr = addr->ai_next) + { + if( res->ai_canonname && + host == TQCString( res->ai_canonname )) + is_local = true; + } + freeaddrinfo(res); + return is_local; + } } return false; } |