diff options
author | Yukihiro Nakai <nakai@FreeBSD.org> | 2002-02-20 11:38:18 +0000 |
---|---|---|
committer | Yukihiro Nakai <nakai@FreeBSD.org> | 2002-02-20 11:38:18 +0000 |
commit | 30bffc40bea15dc0050aad1164b726c05b6ad195 (patch) | |
tree | 89ff63fee1f354b8c2713d369e39aba5a4e8f4da /x11-wm | |
parent | Update to 0.9.13. (diff) |
Add FreeBSD Cpu status patch
PR: ports/28526
Submitted by: <rguyom@pobox.com>
Notes
Notes:
svn path=/head/; revision=54971
Diffstat (limited to 'x11-wm')
-rw-r--r-- | x11-wm/icewm/Makefile | 3 | ||||
-rw-r--r-- | x11-wm/icewm/files/patch-ai | 29 | ||||
-rw-r--r-- | x11-wm/icewm/files/patch-as | 20 | ||||
-rw-r--r-- | x11-wm/icewm/files/patch-at | 196 | ||||
-rw-r--r-- | x11-wm/icewm/files/patch-au | 44 | ||||
-rw-r--r-- | x11-wm/icewm/files/patch-av | 18 | ||||
-rw-r--r-- | x11-wm/icewm/files/patch-aw | 12 | ||||
-rw-r--r-- | x11-wm/icewm/files/patch-src_Makefile | 15 |
8 files changed, 333 insertions, 4 deletions
diff --git a/x11-wm/icewm/Makefile b/x11-wm/icewm/Makefile index 8ef26275c1aa..d57e7f2606a8 100644 --- a/x11-wm/icewm/Makefile +++ b/x11-wm/icewm/Makefile @@ -7,6 +7,7 @@ PORTNAME= icewm PORTVERSION= 1.0.9 +PORTREVISION= 1 CATEGORIES= x11-wm MASTER_SITES= ${MASTER_SITE_SOURCEFORGE} MASTER_SITE_SUBDIR= ${PORTNAME} @@ -56,5 +57,7 @@ post-install: .endfor ${INSTALL_DATA} ${WRKSRC}/doc/*.html ${PREFIX}/share/doc/icewm .endif + ${CHOWN} root.kmem ${PREFIX}/bin/icewm + ${CHMOD} 2555 ${PREFIX}/bin/icewm .include <bsd.port.post.mk> diff --git a/x11-wm/icewm/files/patch-ai b/x11-wm/icewm/files/patch-ai index e19360105b66..e2358ab5e99e 100644 --- a/x11-wm/icewm/files/patch-ai +++ b/x11-wm/icewm/files/patch-ai @@ -1,5 +1,5 @@ --- src/wmtaskbar.cc.orig Tue Oct 9 23:54:04 2001 -+++ src/wmtaskbar.cc Tue Feb 19 14:10:04 2002 ++++ src/wmtaskbar.cc Wed Feb 20 20:17:52 2002 @@ -66,7 +66,7 @@ #endif @@ -9,6 +9,15 @@ /* #define START_PIXMAP "debian.xpm" #define START_PIXMAP "bsd-daemon.xpm" +@@ -253,7 +253,7 @@ + fAddressBar = 0; + + #ifdef CONFIG_APPLET_CPU_STATUS +-#if (defined(linux) || defined(HAVE_KSTAT_H)) ++#if (defined(linux) || defined(HAVE_KSTAT_H)) || defined(__FreeBSD__) + if (taskBarShowCPUStatus) + fCPUStatus = new CPUStatus(this); + else @@ -287,7 +287,7 @@ } else fClock = 0; @@ -18,3 +27,21 @@ fApm = new YApm(this); if (fApm->height() + ADD1 > ht) ht = fApm->height() + ADD1; } else +@@ -400,7 +400,7 @@ + } + #endif + #ifdef CONFIG_APPLET_CPU_STATUS +-#if (defined(linux) || defined(HAVE_KSTAT_H)) ++#if (defined(linux) || defined(HAVE_KSTAT_H)) || defined(__FreeBSD__) + if (fCPUStatus) { + fCPUStatus->setPosition(rightX - fCPUStatus->width() - 1, + BASE1 + (ht - ADD1 - fCPUStatus->height()) / 2); +@@ -497,7 +497,7 @@ + } + #endif + #ifdef CONFIG_APPLET_CPU_STATUS +-#if (defined(linux) || defined(HAVE_KSTAT_H)) ++#if (defined(linux) || defined(HAVE_KSTAT_H)) || defined(__FreeBSD__) + if (fCPUStatus) { + fCPUStatus->setPosition(rightX - fCPUStatus->width() - 1, + BASE1 + (ht - ADD1 - fCPUStatus->height()) / 2); diff --git a/x11-wm/icewm/files/patch-as b/x11-wm/icewm/files/patch-as new file mode 100644 index 000000000000..bbbc3312bbae --- /dev/null +++ b/x11-wm/icewm/files/patch-as @@ -0,0 +1,20 @@ +--- src/wmtaskbar.h.orig Wed Feb 20 20:18:07 2002 ++++ src/wmtaskbar.h Wed Feb 20 20:18:28 2002 +@@ -15,7 +15,7 @@ + #define ADD2 5 + + class ObjectBar; +-#if (defined(linux)||defined(HAVE_KSTAT_H)) ++#if (defined(linux)||defined(HAVE_KSTAT_H)) || defined(__FreeBSD__) + class CPUStatus; + #endif + #ifdef HAVE_NET_STATUS +@@ -90,7 +90,7 @@ + MailBoxStatus **fMailBoxStatus; + #endif + #ifdef CONFIG_APPLET_CPU_STATUS +-#if (defined(linux)||defined(HAVE_KSTAT_H)) ++#if (defined(linux)||defined(HAVE_KSTAT_H)) || defined(__FreeBSD__) + CPUStatus *fCPUStatus; + #endif + #endif diff --git a/x11-wm/icewm/files/patch-at b/x11-wm/icewm/files/patch-at new file mode 100644 index 000000000000..b108dc22016c --- /dev/null +++ b/x11-wm/icewm/files/patch-at @@ -0,0 +1,196 @@ +--- src/acpustatus.cc.orig Wed Feb 20 19:55:04 2002 ++++ src/acpustatus.cc Wed Feb 20 20:19:20 2002 +@@ -26,7 +26,15 @@ + + #include "intl.h" + +-#if (defined(linux) || defined(HAVE_KSTAT_H)) ++#if (defined(linux) || defined(HAVE_KSTAT_H) || defined(__FreeBSD__)) ++ ++#ifdef __FreeBSD__ ++#include <fcntl.h> ++#include <kvm.h> ++#include <nlist.h> ++#include <sys/dkstat.h> ++#include <devstat.h> ++#endif + + #define UPDATE_INTERVAL 500 + +@@ -49,13 +57,42 @@ + color[IWM_SYS] = new YColor(clrCpuSys); + color[IWM_IDLE] = *clrCpuIdle + ? new YColor(clrCpuIdle) : NULL; +- ++#ifdef __FreeBSD__ ++ color[IWM_INTR] = new YColor(clrCpuIntr); ++ for (unsigned int i = 0; i < taskBarCPUSamples; i++) { ++ cpu[i][IWM_USER] = cpu[i][IWM_NICE] = ++ cpu[i][IWM_SYS] = cpu[i][IWM_INTR] = 0; ++ cpu[i][IWM_IDLE] = 1; ++ } ++ setSize(taskBarCPUSamples, 20); ++ last_cpu[IWM_USER] = last_cpu[IWM_NICE] = last_cpu[IWM_SYS] = ++ last_cpu[IWM_IDLE] = last_cpu[IWM_INTR] = 0; ++ if( setegid( 2 ) == 0 ) { ++ char errbuf[_POSIX2_LINE_MAX]; ++ kd = kvm_openfiles( NULL, NULL, NULL, O_RDONLY, errbuf ); ++ setegid( getgid() ); ++ if( kd == NULL ) ++ fprintf( stderr, "kvm_openfiles: %s\n", errbuf ); ++ else { ++ memset( namelist, 0, sizeof(namelist) ); ++ namelist[0].n_name = (char*)("_cp_time"); ++ if( kvm_nlist( kd, namelist ) != 0 ) { ++ kvm_close( kd ); ++ kd = NULL; ++ } ++ } ++ } else { ++ fprintf( stderr, "can't setegid(2), I'm not a setgid exec ?\n" ); ++ kd = NULL; ++ } ++#else + for (int i(0); i < taskBarCPUSamples; i++) { + cpu[i][IWM_USER] = cpu[i][IWM_NICE] = cpu[i][IWM_SYS] = 0; + cpu[i][IWM_IDLE] = 1; + } + setSize(taskBarCPUSamples, 20); + last_cpu[IWM_USER] = last_cpu[IWM_NICE] = last_cpu[IWM_SYS] = last_cpu[IWM_IDLE] = 0; ++#endif + getStatus(); + updateStatus(); + updateToolTip(); +@@ -70,6 +107,13 @@ + delete color[IWM_NICE]; color[IWM_NICE] = 0; + delete color[IWM_SYS]; color[IWM_SYS] = 0; + delete color[IWM_IDLE]; color[IWM_IDLE] = 0; ++#ifdef __FreeBSD__ ++ delete color[IWM_INTR]; color[IWM_INTR] = 0; ++ if( kd != NULL ) { ++ kvm_close( kd ); ++ kd = NULL; ++ } ++#endif + } + + void CPUStatus::paint(Graphics &g, int /*x*/, int /*y*/, unsigned int /*width*/, unsigned int /*height*/) { +@@ -80,13 +124,34 @@ + int nice = cpu[i][IWM_NICE]; + int sys = cpu[i][IWM_SYS]; + int idle = cpu[i][IWM_IDLE]; ++#ifdef __FreeBSD__ ++ int intr = cpu[i][IWM_INTR]; ++ int total = user + sys + intr + nice + idle; ++ int totald = total; ++#else + int total = user + sys + nice + idle; ++#endif + + int y = height() - 1; + + if (total > 0) { ++#ifdef __FreeBSD__ ++ if (intr) { ++ totald -= intr; ++ n = (h * totald) / total; // check rounding ++ if (n >= y) n = y; ++ g.setColor(color[IWM_INTR]); ++ g.drawLine(i, y, i, n); ++ y = n - 1; ++ } ++#endif + if (sys) { ++#ifdef __FreeBSD__ ++ totald -= nice; ++ n = (h * totald)/ total; ++#else + n = (h * (total - sys)) / total; // check rounding ++#endif + if (n >= y) n = y; + g.setColor(color[IWM_SYS]); + g.drawLine(i, y, i, n); +@@ -102,7 +167,12 @@ + } + + if (user) { ++#ifdef __FreeBSD__ ++ totald -= user; ++ n = (h * totald)/ total; ++#else + n = (h * (total - sys - nice - user))/ total; ++#endif + if (n >= y) n = y; + g.setColor(color[IWM_USER]); + g.drawLine(i, y, i, n); +@@ -152,6 +222,14 @@ + sprintf(load, _("CPU Load: %3.2f %3.2f %3.2f, %d processes."), + l1, l5, l15, sys.procs); + setToolTip(load); ++#elif defined(__FreeBSD__) ++ char load[31]; // enough for "CPU Load: 999.99 999.99 999.99\0" ++ double loadavg[3]; ++ if( kd != NULL && kvm_getloadavg( kd, loadavg, 3 ) != 3 ) ++ return; ++ snprintf(load, sizeof(load), "CPU Load: %3.2f %3.2f %3.2f", ++ loadavg[0], loadavg[1], loadavg[2]); ++ setToolTip(load); + #endif + } + +@@ -169,13 +247,43 @@ + cpu[i - 1][IWM_NICE] = cpu[i][IWM_NICE]; + cpu[i - 1][IWM_SYS] = cpu[i][IWM_SYS]; + cpu[i - 1][IWM_IDLE] = cpu[i][IWM_IDLE]; ++#ifdef __FreeBSD__ ++ cpu[i - 1][IWM_INTR] = cpu[i][IWM_INTR]; ++#endif + } + getStatus(), + repaint(); + } + + void CPUStatus::getStatus() { +-#ifdef linux ++#ifdef __FreeBSD__ ++ ++ cpu[taskBarCPUSamples-1][IWM_USER] = 0; ++ cpu[taskBarCPUSamples-1][IWM_NICE] = 0; ++ cpu[taskBarCPUSamples-1][IWM_SYS] = 0; ++ cpu[taskBarCPUSamples-1][IWM_INTR] = 0; ++ cpu[taskBarCPUSamples-1][IWM_IDLE] = 0; ++ ++ if( kd == NULL ) return; ++ ++ long cp_time[CPUSTATES]; ++ int c = sizeof( cp_time ); ++ if (kvm_read(kd, namelist[0].n_value, &cp_time, c) != c) ++ return; ++ ++ long cur[IWM_STATES]; ++ cur[IWM_USER] = cp_time[CP_USER]; ++ cur[IWM_NICE] = cp_time[CP_NICE]; ++ cur[IWM_SYS] = cp_time[CP_SYS]; ++ cur[IWM_INTR] = cp_time[CP_INTR]; ++ cur[IWM_IDLE] = cp_time[CP_IDLE]; ++ ++ for (int i = 0; i < IWM_STATES; i++) { ++ cpu[taskBarCPUSamples-1][i] = cur[i] - last_cpu[i]; ++ last_cpu[i] = cur[i]; ++ } ++ ++#elif defined(linux) + char *p, buf[128]; + long cur[IWM_STATES]; + int len, fd = open("/proc/stat", O_RDONLY); +@@ -209,8 +317,8 @@ + cpu[taskBarCPUSamples-1][IWM_USER], cpu[taskBarCPUSamples-1][IWM_NICE], + cpu[taskBarCPUSamples-1][IWM_SYS], cpu[taskBarCPUSamples-1][IDLE]); + #endif +-#endif /* linux */ +-#ifdef HAVE_KSTAT_H ++ ++#elif defined(HAVE_KSTAT_H) + #ifdef HAVE_OLD_KSTAT + #define ui32 ul + #endif diff --git a/x11-wm/icewm/files/patch-au b/x11-wm/icewm/files/patch-au new file mode 100644 index 000000000000..7842944dcf63 --- /dev/null +++ b/x11-wm/icewm/files/patch-au @@ -0,0 +1,44 @@ +--- src/acpustatus.h.orig Wed Feb 20 20:11:52 2002 ++++ src/acpustatus.h Wed Feb 20 20:14:16 2002 +@@ -1,19 +1,29 @@ + #ifndef __CPUSTATUS_H + #define __CPUSTATUS_H + +-#if (defined(linux) || defined(HAVE_KSTAT_H)) ++#if (defined(linux) || defined(HAVE_KSTAT_H)) || defined (__FreeBSD__) + + #ifdef HAVE_KSTAT_H + #include <kstat.h> + #include <sys/sysinfo.h> + #endif /* have_kstat_h */ + ++#ifdef __FreeBSD__ ++#include <kvm.h> ++#include <nlist.h> ++#endif + + #define IWM_USER (0) + #define IWM_NICE (1) + #define IWM_SYS (2) ++#ifdef __FreeBSD__ ++#define IWM_INTR (3) ++#define IWM_IDLE (4) ++#define IWM_STATES (5) ++#else + #define IWM_IDLE (3) + #define IWM_STATES (4) ++#endif + + #include "ywindow.h" + #include "ytimer.h" +@@ -38,6 +48,10 @@ + long last_cpu[IWM_STATES]; + YColor *color[IWM_STATES]; + YTimer *fUpdateTimer; ++#ifdef __FreeBSD__ ++ struct nlist namelist[2]; ++ kvm_t *kd; ++#endif + }; + + #endif diff --git a/x11-wm/icewm/files/patch-av b/x11-wm/icewm/files/patch-av new file mode 100644 index 000000000000..f32d2db48aeb --- /dev/null +++ b/x11-wm/icewm/files/patch-av @@ -0,0 +1,18 @@ +--- src/default.h.orig Wed Feb 20 20:14:24 2002 ++++ src/default.h Wed Feb 20 20:16:04 2002 +@@ -455,6 +455,7 @@ + XSV(const char *, clrLabelText, "rgb:00/00/00") + XSV(const char *, clrCpuUser, "rgb:00/FF/00") + XSV(const char *, clrCpuSys, "rgb:FF/00/00") ++XSV(const char *, clrCpuIntr, "rgb:FF/FF/00") + XSV(const char *, clrCpuNice, "rgb:00/00/FF") + XSV(const char *, clrCpuIdle, "rgb:00/00/00") + XSV(const char *, clrNetSend, "rgb:FF/FF/00") +@@ -837,6 +838,7 @@ + #ifdef CONFIG_APPLET_CPU_STATUS + OSV("ColorCPUStatusUser", &clrCpuUser, "User load on the CPU monitor"), + OSV("ColorCPUStatusSystem", &clrCpuSys, "System load on the CPU monitor"), ++ OSV("ColorCPUStatusInterrupts", &clrCpuIntr, "Inturrupts on the CPU monitor"), + OSV("ColorCPUStatusNice", &clrCpuNice, "Nice load on the CPU monitor"), + OSV("ColorCPUStatusIdle", &clrCpuIdle, "Idle (non) load on the CPU monitor, leave empty to force transparency"), + #endif diff --git a/x11-wm/icewm/files/patch-aw b/x11-wm/icewm/files/patch-aw new file mode 100644 index 000000000000..9e11d6673f90 --- /dev/null +++ b/x11-wm/icewm/files/patch-aw @@ -0,0 +1,12 @@ +--- src/wmapp.cc.orig Wed Feb 20 20:16:15 2002 ++++ src/wmapp.cc Wed Feb 20 20:16:48 2002 +@@ -1308,6 +1308,9 @@ + } + + int main(int argc, char **argv) { ++#ifdef __FreeBSD__ ++ setegid( getgid() ); ++#endif + YLocale locale; + + #ifndef NO_CONFIGURE diff --git a/x11-wm/icewm/files/patch-src_Makefile b/x11-wm/icewm/files/patch-src_Makefile index c70a52c83f6e..29a0eddc79c2 100644 --- a/x11-wm/icewm/files/patch-src_Makefile +++ b/x11-wm/icewm/files/patch-src_Makefile @@ -1,6 +1,6 @@ ---- src/Makefile.orig Fri Apr 27 09:32:22 2001 -+++ src/Makefile Tue May 1 06:19:51 2001 -@@ -17,9 +17,9 @@ +--- src/Makefile.orig Tue Oct 9 23:54:03 2001 ++++ src/Makefile Wed Feb 20 19:54:01 2002 +@@ -18,9 +18,9 @@ -DHOSTOS='"$(shell uname -s || echo unknown)"' \ -DHOSTCPU='"$(shell uname -m || echo unknown)"' \ -DEXEEXT='"$(EXEEXT)"' \ @@ -13,3 +13,12 @@ $(SYS_CFLAGS) $(SYS_INCDIRS) LFLAGS = $(SYS_LIBDIRS) LIBS = $(SYS_LIBS) +@@ -37,7 +37,7 @@ + genpref.o + + icewm_LIBS = \ +- $(CORE_LIBS) $(IMAGE_LIBS) $(GNOME_LIBS) ++ $(CORE_LIBS) $(IMAGE_LIBS) $(GNOME_LIBS) -lkvm + icewm_OBJS = \ + ymsgbox.o ydialog.o yurl.o \ + wmsession.o wmwinlist.o wmtaskbar.o wmwinmenu.o \ |