More work on opensolaris...

Cleaning some warnings.
Added checks for kstat, so cpu applet can show usage via kstat api. Added tests for kstat in configure script.
This commit is contained in:
Sanel Zukan 2013-01-09 16:01:35 +00:00
parent 6495f53404
commit 0b4d9a7f26
9 changed files with 52 additions and 21 deletions

View File

@ -133,6 +133,9 @@ XKB_LIBS ?= @XKB_LIBS@ ;
CURL_CFLAGS ?= @CURL_CFLAGS@ ;
CURL_LIBS ?= @CURL_LIBS@ ;
# kstat
KSTAT_LIBS ?= @KSTAT_LIBS@ ;
# platform specific pthread flags
# FIXME: a quick hack to work everything on SunStudio
if $(SUN_COMPILER) {

View File

@ -257,6 +257,30 @@ else
AC_MSG_RESULT(no)
fi
dnl kstat/solaris
AC_CHECK_HEADER(kstat.h, [have_kstat_h=yes],)
if test "x$have_kstat_h" = "xyes"; then
AC_MSG_CHECKING([for kstat presence])
AC_LANG_SAVE
AC_LANG_C
AC_TRY_COMPILE([
#include <kstat.h>
],[
kstat_named_t k;
k.value.ui32;
],[have_kstat=yes],[])
AC_LANG_RESTORE
if test "x$have_kstat" = "xyes"; then
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_KSTAT, 1, [Define to 1 if you have kstat])
KSTAT_LIBS=" -lkstat"
else
AC_MSG_RESULT(no)
fi
fi
dnl pekwm specific macros
EDE_CHECK_PEKWM_DEPENDENCIES
@ -277,6 +301,7 @@ AC_SUBST(CURL_LIBS)
AC_SUBST(LARGEFILE)
AC_SUBST(XKB_LIBS)
AC_SUBST(my_sysconfdir)
AC_SUBST(KSTAT_LIBS)
AC_SUBST(PEKWM_CXXFLAGS)
AC_SUBST(PEKWM_LIBS)

View File

@ -55,10 +55,6 @@ static void clear_applet(AppletData *a) {
delete a;
}
AppletManager::~AppletManager() {
clear();
}
bool AppletManager::load(const char *path) {
dlerror();
const char *dl_err = NULL;
@ -130,11 +126,12 @@ bool AppletManager::load(const char *path) {
return true;
}
void AppletManager::clear(void) {
void AppletManager::clear(Panel *p) {
E_RETURN_IF_FAIL(applet_list.size() > 0);
AListIter it = applet_list.begin(), ite = applet_list.end();
while(it != ite) {
p->remove((*it)->awidget);
clear_applet(*it);
it = applet_list.erase(it);
}

View File

@ -36,9 +36,8 @@ class AppletManager {
private:
AList applet_list;
public:
~AppletManager();
bool load(const char *path);
void clear(void);
void clear(Panel *p);
void fill_group(Panel *p);
void unfill_group(Panel *p);

View File

@ -30,13 +30,13 @@ rule PanelApplet
}
# append default extension
target = $(<:S=$(SUFLIB_SHARED)) ;
target = $(1:S=$(SUFLIB_SHARED)) ;
Main $(target) : $(>) ;
ObjectC++Flags $(>) : $(GLOBALFLAGS) -fPIC $(FLTKINCLUDE) -I [ FDirName $(TOP) ede-panel ] $(EDELIBINCLUDE) ;
Main $(target) : $(2) ;
ObjectC++Flags $(2) : $(GLOBALFLAGS) -fPIC $(FLTKINCLUDE) -I [ FDirName $(TOP) ede-panel ] $(EDELIBINCLUDE) ;
LinkAgainst $(target) : $(3) $(EDELIBLIB) $(EDELIB_GUI_LIB) $(FLTKLIB) $(STDLIB) ;
LINKFLAGS on $(target) = $(linker_stuff) [ on $(target) return $(LINKFLAGS) ] ;
LINKFLAGS on $(target) = $(linker_stuff) [ on $(target) return $(LINKFLAGS) ] $(3) ;
InstallProgram $(EDE_PANEL_APPLETS_DIR) : $(target) ;

View File

@ -387,10 +387,13 @@ void Panel::hide(void) {
E_DEBUG("Panel::hide()\n");
/* strange; this is not called when panel goes out :S */
mgr.clear();
save_config();
/* clear loaded widgets */
mgr.clear(this);
/* clear whatever was left out, but was not part of applet manager */
clear();
save_config();
Fl_Window::hide();
}

View File

@ -9,6 +9,10 @@
* For ede-panel by Sanel Zukan 2009
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <limits.h>
#include <unistd.h>
#include <stdarg.h>
@ -26,8 +30,10 @@
# include <sys/sysinfo.h>
#endif
#ifdef HAVE_KSTAT_H
#ifdef HAVE_KSTAT
# include <kstat.h>
# include <sys/sysinfo.h>
# include <string.h> /* strncmp */
#endif
#ifdef __FreeBSD__
@ -335,11 +341,10 @@ void CPUMonitor::get_cpu_info() {
#endif /* linux */
#ifdef HAVE_KSTAT_H
#ifdef HAVE_KSTAT
# ifdef HAVE_OLD_KSTAT
# define ui32 ul
#endif
static kstat_ctl_t *kc = NULL;
static kid_t kcid;
kid_t new_kcid;

View File

@ -10,4 +10,4 @@
SubDir TOP ede-panel applets cpu-monitor ;
PanelApplet cpu_monitor : CpuMonitor.cpp ;
PanelApplet cpu_monitor : CpuMonitor.cpp : $(KSTAT_LIBS) ;

View File

@ -184,9 +184,8 @@ void StartMenu::popup(void) {
pressed_menu_button = this;
redraw();
Fl_Widget *mb = this;
#if (FL_MAJOR_VERSION >= 1) && (FL_MINOR_VERSION >= 3)
Fl_Widget *mb = this;
Fl::watch_widget_pointer(mb);
#endif
@ -287,7 +286,7 @@ bool StartMenu::can_reload(void) {
time_t c, diff;
c = time(NULL);
diff = difftime(c, last_reload);
diff = (time_t)difftime(c, last_reload);
last_reload = c;
if(diff >= MENU_UPDATE_DIFF) return true;