1
/*********************************************************
2
* Copyright (C) 2010 VMware, Inc. All rights reserved.
4
* This program is free software; you can redistribute it and/or modify it
5
* under the terms of the GNU Lesser General Public License as published
6
* by the Free Software Foundation version 2.1 and no later version.
8
* This program is distributed in the hope that it will be useful, but
9
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10
* or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public
11
* License for more details.
13
* You should have received a copy of the GNU Lesser General Public License
14
* along with this program; if not, write to the Free Software Foundation, Inc.,
15
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17
*********************************************************/
20
* windowPathFactory.hh --
22
* Factory class which, given an X window ID, PID, or pathname tries to
23
* find executable path and its corresponding "desktop entry" file. (See
24
* http://standards.freedesktop.org/desktop-entry-spec/latest/.)
27
#ifndef _UNITY_WINDOWPATHFACTORY_HH_
28
#define _UNITY_WINDOWPATHFACTORY_HH_
30
#include <tr1/unordered_map>
47
class WindowPathFactory {
49
// executable path, desktop entry path
50
typedef std::pair<Glib::ustring, Glib::ustring> WindowPathPair;
52
WindowPathFactory(Display* dpy);
53
bool FindByXid(XID window, WindowPathPair& pathPair);
56
typedef std::tr1::unordered_map<Glib::ustring, WindowPathPair,
57
std::tr1::hash<std::string> > ExecMap;
58
typedef std::pair<Glib::RefPtr<Glib::Regex>, std::string> ExecPattern;
60
Glib::ustring CanonicalizeAppName(const Glib::ustring& appName,
61
const Glib::ustring& cwd);
62
bool FindByArgv(const Glib::ustring& cwd, std::vector<Glib::ustring> argv,
63
WindowPathPair& pathPair);
64
bool FindByPid(pid_t pid, WindowPathPair& pathPair);
65
pid_t GetPidForXid(XID window);
66
bool IsSkippable(const Glib::ustring& component);
67
Window LookupClientLeader(XID window);
71
std::vector<std::string> mEnvPrefixes;
72
std::vector<ExecPattern> mExecPatterns;
73
Glib::RefPtr<Glib::Regex> mSkipPatterns;
76
} /* namespace unity */ } /* namespace tools */ } /* namespace vmware */
79
#endif // ifndef _UNITY_WINDOWPATHFACTORY_HH_