summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormbkma <[email protected]>2021-04-24 18:02:25 +0200
committerraveit65 <[email protected]>2021-06-10 15:03:09 +0200
commit80640c9b70283c5ad13858d8b820302bb6d06132 (patch)
tree6abe9f3196076ff49ae8221c9c26f957861045a7 /src
parent91a35358aed44381c9e5e249dcc081d77b4e29ee (diff)
downloadmate-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')
-rw-r--r--src/Makefile.am5
-rw-r--r--src/prettytable.cpp52
-rw-r--r--src/prettytable.h7
-rw-r--r--src/procman-app.cpp18
-rw-r--r--src/procman.h2
-rw-r--r--src/procproperties.cpp37
-rw-r--r--src/proctable.cpp43
7 files changed, 119 insertions, 45 deletions
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);