diff options
author | mbkma <[email protected]> | 2021-04-24 18:02:25 +0200 |
---|---|---|
committer | raveit65 <[email protected]> | 2021-06-10 15:03:09 +0200 |
commit | 80640c9b70283c5ad13858d8b820302bb6d06132 (patch) | |
tree | 6abe9f3196076ff49ae8221c9c26f957861045a7 /src/prettytable.cpp | |
parent | 91a35358aed44381c9e5e249dcc081d77b4e29ee (diff) | |
download | mate-system-monitor-80640c9b70283c5ad13858d8b820302bb6d06132.tar.bz2 mate-system-monitor-80640c9b70283c5ad13858d8b820302bb6d06132.tar.xz |
add wayland support
therefore make libwnck optional (libwnck is x11 only)
see https://gitlab.gnome.org/GNOME/gnome-system-monitor/-/commit/3705931e307e87878f205b905eaa3f5daaffcf09
and https://gitlab.gnome.org/GNOME/gnome-system-monitor/-/commit/8c4d47d625661e848643ce564f63ed3ec1e83293
and https://gitlab.gnome.org/GNOME/gnome-system-monitor/-/commit/1ea64e9965bd6f1026f1167b692e7cc83c269be3
Diffstat (limited to 'src/prettytable.cpp')
-rw-r--r-- | src/prettytable.cpp | 52 |
1 files changed, 33 insertions, 19 deletions
diff --git a/src/prettytable.cpp b/src/prettytable.cpp index cbc5f0d..153f533 100644 --- a/src/prettytable.cpp +++ b/src/prettytable.cpp @@ -1,6 +1,10 @@ #include <config.h> + +#ifdef HAVE_WNCK #define WNCK_I_KNOW_THIS_IS_UNSTABLE #include <libwnck/libwnck.h> +#endif + #include <dirent.h> #include <sys/stat.h> #include <stdio.h> @@ -19,6 +23,9 @@ #include "proctable.h" #include "util.h" +#ifdef GDK_WINDOWING_X11 +#include <gdk/gdkx.h> +#endif namespace { @@ -28,11 +35,17 @@ namespace PrettyTable::PrettyTable() { - WnckScreen* screen = wnck_screen_get_default(); - g_signal_connect(G_OBJECT(screen), "application_opened", - G_CALLBACK(PrettyTable::on_application_opened), this); - g_signal_connect(G_OBJECT(screen), "application_closed", - G_CALLBACK(PrettyTable::on_application_closed), this); +#ifdef HAVE_WNCK +#ifdef GDK_WINDOWING_X11 + if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())) { + WnckScreen* screen = wnck_screen_get_default(); + g_signal_connect(G_OBJECT(screen), "application_opened", + G_CALLBACK(PrettyTable::on_application_opened), this); + g_signal_connect(G_OBJECT(screen), "application_closed", + G_CALLBACK(PrettyTable::on_application_closed), this); + } +#endif // GDK_WINDOWING_X11 +#endif // HAVE_WNCK // init GIO apps cache std::vector<std::string> dirs = Glib::get_system_data_dirs(); @@ -54,7 +67,7 @@ PrettyTable::~PrettyTable() { } - +#ifdef HAVE_WNCK void PrettyTable::on_application_opened(WnckScreen* screen, WnckApplication* app, gpointer data) { @@ -89,8 +102,6 @@ PrettyTable::on_application_opened(WnckScreen* screen, WnckApplication* app, gpo that->register_application(pid, icon); } - - void PrettyTable::register_application(pid_t pid, Glib::RefPtr<Gdk::Pixbuf> icon) { @@ -116,6 +127,16 @@ PrettyTable::on_application_closed(WnckScreen* screen, WnckApplication* app, gpo static_cast<PrettyTable*>(data)->unregister_application(pid); } +void +PrettyTable::unregister_application(pid_t pid) +{ + IconsForPID::iterator it(this->apps.find(pid)); + + if (it != this->apps.end()) + this->apps.erase(it); +} +#endif // HAVE_WNCK + void PrettyTable::init_gio_app_cache () { this->gio_apps.clear(); @@ -136,16 +157,6 @@ void PrettyTable::file_monitor_event(Glib::RefPtr<Gio::File>, this->init_gio_app_cache(); } -void -PrettyTable::unregister_application(pid_t pid) -{ - IconsForPID::iterator it(this->apps.find(pid)); - - if (it != this->apps.end()) - this->apps.erase(it); -} - - Glib::RefPtr<Gdk::Pixbuf> PrettyTable::get_icon_from_theme(const ProcInfo &info) @@ -215,6 +226,7 @@ PrettyTable::get_icon_from_gio(const ProcInfo &info) return icon; } +#ifdef HAVE_WNCK Glib::RefPtr<Gdk::Pixbuf> PrettyTable::get_icon_from_wnck(const ProcInfo &info) { @@ -227,7 +239,7 @@ PrettyTable::get_icon_from_wnck(const ProcInfo &info) return icon; } - +#endif Glib::RefPtr<Gdk::Pixbuf> @@ -284,7 +296,9 @@ PrettyTable::set_icon(ProcInfo &info) if (getters.empty()) { getters.push_back(&PrettyTable::get_icon_from_gio); +#ifdef HAVE_WNCK getters.push_back(&PrettyTable::get_icon_from_wnck); +#endif getters.push_back(&PrettyTable::get_icon_from_theme); getters.push_back(&PrettyTable::get_icon_from_default); getters.push_back(&PrettyTable::get_icon_from_name); |