diff options
-rw-r--r-- | configure.ac | 21 | ||||
-rw-r--r-- | src/Makefile.am | 5 | ||||
-rw-r--r-- | src/prettytable.cpp | 52 | ||||
-rw-r--r-- | src/prettytable.h | 7 | ||||
-rw-r--r-- | src/procman-app.cpp | 18 | ||||
-rw-r--r-- | src/procman.h | 2 | ||||
-rw-r--r-- | src/procproperties.cpp | 37 | ||||
-rw-r--r-- | src/proctable.cpp | 43 |
8 files changed, 138 insertions, 47 deletions
diff --git a/configure.ac b/configure.ac index 35a60f3..de525cc 100644 --- a/configure.ac +++ b/configure.ac @@ -42,8 +42,24 @@ LIBXML_REQUIRED=2.0 RSVG_REQUIRED=2.35 SYSTEMD_REQUIRED=44 -PKG_CHECK_MODULES(GMODULE,gmodule-2.0,[GMODULE_ADD="gmodule-2.0"],[GMODULE_ADD=""]) -PKG_CHECK_MODULES(PROCMAN,$GMODULE_ADD glib-2.0 >= $GLIB_REQUIRED libgtop-2.0 >= $LIBGTOP_REQUIRED libwnck-3.0 >= $LIBWNCK_REQUIRED gtk+-3.0 >= $GTK_REQUIRED gtkmm-3.0 >= $GTKMM_REQUIRED libxml-2.0 >= $LIBXML_REQUIRED librsvg-2.0 >= $RSVG_REQUIRED glibmm-2.4 >= $GLIBMM_REQUIRED giomm-2.4 >= $GIOMM_REQUIRED) +PKG_CHECK_MODULES(PROCMAN, [ + glib-2.0 >= $GLIB_REQUIRED + libgtop-2.0 >= $LIBGTOP_REQUIRED + gtk+-3.0 >= $GTK_REQUIRED + gtkmm-3.0 >= $GTKMM_REQUIRED + libxml-2.0 >= $LIBXML_REQUIRED + librsvg-2.0 >= $RSVG_REQUIRED + glibmm-2.4 >= $GLIBMM_REQUIRED + giomm-2.4 >= $GIOMM_REQUIRED + gmodule-2.0 +]) + +AC_ARG_ENABLE(wnck, AS_HELP_STRING([--enable-wnck], [enable wnck support]), enable_wnck="$enableval", enable_wnck=no) +if test "x$enable_wnck" != "xno"; then + PKG_CHECK_MODULES(WNCK, libwnck-3.0 >= $LIBWNCK_REQUIRED gdk-x11-3.0) + AC_DEFINE(HAVE_WNCK, 1, [Define if libwnck is available]) +fi +AM_CONDITIONAL(HAVE_WNCK, [test "enable_wnck" = "yes"]) PKG_CHECK_MODULES(TOOLS, glib-2.0 >= $GLIB_REQUIRED) @@ -128,4 +144,5 @@ Configure summary: WARN_CXXFLAGS: ${WARN_CXXFLAGS} Maintainer mode: ${USE_MAINTAINER_MODE} Systemd support: ${have_systemd} + wnck support: ${enable_wnck} " diff --git a/src/Makefile.am b/src/Makefile.am index 6811bba..9f882fb 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -7,7 +7,8 @@ AM_CPPFLAGS = \ -DPKGLIBEXECDIR=\""$(pkglibexecdir)"\" \ -DLIBEXECDIR=\""$(libexecdir)"\" \ @PROCMAN_CFLAGS@ \ - @SYSTEMD_CFLAGS@ + @SYSTEMD_CFLAGS@ \ + @WNCK_CFLAGS@ bin_PROGRAMS = mate-system-monitor @@ -60,7 +61,7 @@ mate_system_monitor_CXXFLAGS = \ mate_system_monitor_CFLAGS = \ $(WARN_CFLAGS) -mate_system_monitor_LDADD = @PROCMAN_LIBS@ @SYSTEMD_LIBS@ +mate_system_monitor_LDADD = @PROCMAN_LIBS@ @SYSTEMD_LIBS@ @WNCK_LIBS@ specdir = $(datadir)/procman 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); diff --git a/src/prettytable.h b/src/prettytable.h index ac150de..fccca98 100644 --- a/src/prettytable.h +++ b/src/prettytable.h @@ -12,10 +12,12 @@ #include <map> #include <string> +#ifdef HAVE_WNCK extern "C" { #define WNCK_I_KNOW_THIS_IS_UNSTABLE #include <libwnck/libwnck.h> } +#endif #include "iconthemewrapper.h" @@ -35,17 +37,20 @@ class PrettyTable private: +#ifdef HAVE_WNCK static void on_application_opened(WnckScreen* screen, WnckApplication* app, gpointer data); static void on_application_closed(WnckScreen* screen, WnckApplication* app, gpointer data); void register_application(pid_t pid, Glib::RefPtr<Gdk::Pixbuf> icon); void unregister_application(pid_t pid); - +#endif Glib::RefPtr<Gdk::Pixbuf> get_icon_from_theme(const ProcInfo &); Glib::RefPtr<Gdk::Pixbuf> get_icon_from_default(const ProcInfo &); Glib::RefPtr<Gdk::Pixbuf> get_icon_from_gio(const ProcInfo &); +#ifdef HAVE_WNCK Glib::RefPtr<Gdk::Pixbuf> get_icon_from_wnck(const ProcInfo &); +#endif Glib::RefPtr<Gdk::Pixbuf> get_icon_from_name(const ProcInfo &); Glib::RefPtr<Gdk::Pixbuf> get_icon_for_kernel(const ProcInfo &); Glib::RefPtr<Gdk::Pixbuf> get_icon_dummy(const ProcInfo &); diff --git a/src/procman-app.cpp b/src/procman-app.cpp index 3a0c10a..7724a4c 100644 --- a/src/procman-app.cpp +++ b/src/procman-app.cpp @@ -207,7 +207,6 @@ procman_data_new (GSettings *settings) ProcData *pd; gchar *color; gchar **keys; - gint swidth, sheight; glibtop_cpu cpu; pd = ProcData::get_instance(); @@ -308,10 +307,19 @@ procman_data_new (GSettings *settings) g_free (color); /* Sanity checks */ - swidth = WidthOfScreen (gdk_x11_screen_get_xscreen (gdk_screen_get_default ())); - sheight = HeightOfScreen (gdk_x11_screen_get_xscreen (gdk_screen_get_default ())); - pd->config.width = CLAMP (pd->config.width, 50, swidth); - pd->config.height = CLAMP (pd->config.height, 50, sheight); + GdkDisplay *display; + GdkMonitor *monitor; + GdkRectangle monitor_geometry; + + display = gdk_display_get_default (); + monitor = gdk_display_get_monitor_at_point (display, pd->config.xpos, pd->config.ypos); + if (monitor == NULL) { + monitor = gdk_display_get_monitor (display, 0); + } + gdk_monitor_get_geometry (monitor, &monitor_geometry); + + pd->config.width = CLAMP (pd->config.width, 50, monitor_geometry.width); + pd->config.height = CLAMP (pd->config.height, 50, monitor_geometry.height); pd->config.update_interval = MAX (pd->config.update_interval, 1000); pd->config.graph_update_interval = MAX (pd->config.graph_update_interval, 250); pd->config.disks_update_interval = MAX (pd->config.disks_update_interval, 1000); diff --git a/src/procman.h b/src/procman.h index 176df7a..f93bf23 100644 --- a/src/procman.h +++ b/src/procman.h @@ -126,8 +126,10 @@ MutableProcInfo() gulong memwritable; gulong mem; +#ifdef HAVE_WNCK // wnck gives an unsigned long gulong memxserver; +#endif gulong start_time; guint64 cpu_time; diff --git a/src/procproperties.cpp b/src/procproperties.cpp index c8de56b..b74bbce 100644 --- a/src/procproperties.cpp +++ b/src/procproperties.cpp @@ -30,6 +30,10 @@ #include "proctable.h" #include "util.h" +#ifdef GDK_WINDOWING_X11 +#include <gdk/gdkx.h> +#endif + enum { COL_PROP = 0, @@ -71,24 +75,35 @@ static void get_process_memory_info (ProcInfo *info) { glibtop_proc_mem procmem; - WnckResourceUsage xresources; - wnck_pid_read_resource_usage (gdk_screen_get_display (gdk_screen_get_default ()), - info->pid, - &xresources); +#ifdef HAVE_WNCK + info->memxserver = 0; +#ifdef GDK_WINDOWING_X11 + if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())) { + WnckResourceUsage xresources; - glibtop_get_proc_mem(&procmem, info->pid); + wnck_pid_read_resource_usage (gdk_screen_get_display (gdk_screen_get_default ()), + info->pid, + &xresources); + + info->memxserver = xresources.total_bytes_estimate; + } +#endif // GDK_WINDOWING_X11 +#endif // HAVE_WNCK - info->vmsize = procmem.vsize; - info->memres = procmem.resident; - info->memshared = procmem.share; + glibtop_get_proc_mem(&procmem, info->pid); - info->memxserver = xresources.total_bytes_estimate; + info->vmsize = procmem.vsize; + info->memres = procmem.resident; + info->memshared = procmem.share; get_process_memory_writable(info); // fake the smart memory column if writable is not available - info->mem = info->memxserver + (info->memwritable ? info->memwritable : info->memres); + info->mem = info->memwritable ? info->memwritable : info->memres; +#ifdef HAVE_WNCK + info->mem += info->memxserver; +#endif } static gchar* @@ -129,7 +144,9 @@ fill_proc_properties (GtkWidget *tree, ProcInfo *info) { N_("Resident Memory"), format_memsize(info->memres)}, { N_("Writable Memory"), format_memsize(info->memwritable)}, { N_("Shared Memory"), format_memsize(info->memshared)}, +#ifdef HAVE_WNCK { N_("X Server Memory"), format_memsize(info->memxserver)}, +#endif { N_("Disk Read Total"), format_size(info->disk_read_bytes_total)}, { N_("Disk Write Total"), format_size(info->disk_write_bytes_total)}, { N_("CPU"), g_strdup_printf("%d%%", info->pcpu)}, diff --git a/src/proctable.cpp b/src/proctable.cpp index 2cb10c8..4c96d50 100644 --- a/src/proctable.cpp +++ b/src/proctable.cpp @@ -59,6 +59,9 @@ #include "selinux.h" #include "cgroups.h" +#ifdef GDK_WINDOWING_X11 +#include <gdk/gdkx.h> +#endif ProcInfo::UserMap ProcInfo::users; ProcInfo::List ProcInfo::all; @@ -364,6 +367,12 @@ proctable_new (ProcData * const procdata) GtkCellRenderer *cell; GtkTreeViewColumn *col; +#ifndef HAVE_WNCK + if (i == COL_MEMXSERVER) { + continue; + } +#endif + cell = gtk_cell_renderer_text_new(); col = gtk_tree_view_column_new(); gtk_tree_view_column_pack_start(col, cell, TRUE); @@ -377,12 +386,14 @@ proctable_new (ProcData * const procdata) // type switch (i) { +#ifdef HAVE_WNCK case COL_MEMXSERVER: gtk_tree_view_column_set_cell_data_func(col, cell, &procman::memory_size_cell_data_func, GUINT_TO_POINTER(i), NULL); break; +#endif case COL_VMSIZE: case COL_MEMRES: case COL_MEMSHARED: @@ -444,7 +455,9 @@ proctable_new (ProcData * const procdata) // sorting switch (i) { +#ifdef HAVE_WNCK case COL_MEMXSERVER: +#endif case COL_VMSIZE: case COL_MEMRES: case COL_MEMSHARED: @@ -477,7 +490,9 @@ proctable_new (ProcData * const procdata) case COL_MEMRES: case COL_MEMWRITABLE: case COL_MEMSHARED: +#ifdef HAVE_WNCK case COL_MEMXSERVER: +#endif case COL_CPU: case COL_NICE: case COL_PID: @@ -648,11 +663,21 @@ static void get_process_memory_info(ProcInfo *info) { glibtop_proc_mem procmem; - WnckResourceUsage xresources; - wnck_pid_read_resource_usage (gdk_screen_get_display (gdk_screen_get_default ()), - info->pid, - &xresources); +#ifdef HAVE_WNCK + info->memxserver = 0; +#ifdef GDK_WINDOWING_X11 + if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())) { + WnckResourceUsage xresources; + + wnck_pid_read_resource_usage (gdk_screen_get_display (gdk_screen_get_default ()), + info->pid, + &xresources); + + info->memxserver = xresources.total_bytes_estimate; + } +#endif // GDK_WINDOWING_X11 +#endif // HAVE_WNCK glibtop_get_proc_mem(&procmem, info->pid); @@ -660,16 +685,16 @@ get_process_memory_info(ProcInfo *info) info->memres = procmem.resident; info->memshared = procmem.share; - info->memxserver = xresources.total_bytes_estimate; - get_process_memory_writable(info); // fake the smart memory column if writable is not available - info->mem = info->memxserver + (info->memwritable ? info->memwritable : info->memres); + info->mem = info->memwritable ? info->memwritable : info->memres; +#ifdef HAVE_WNCK + info->mem += info->memxserver; +#endif } - static void update_info_mutable_cols(ProcInfo *info) { @@ -685,7 +710,9 @@ update_info_mutable_cols(ProcInfo *info) tree_store_update(model, &info->node, COL_MEMRES, info->memres); tree_store_update(model, &info->node, COL_MEMWRITABLE, info->memwritable); tree_store_update(model, &info->node, COL_MEMSHARED, info->memshared); +#ifdef HAVE_WNCK tree_store_update(model, &info->node, COL_MEMXSERVER, info->memxserver); +#endif tree_store_update(model, &info->node, COL_CPU, info->pcpu); tree_store_update(model, &info->node, COL_CPU_TIME, info->cpu_time); tree_store_update(model, &info->node, COL_DISK_READ_TOTAL, info->disk_read_bytes_total); |