- make use of new logging system in gkrellm

- removed trayicon on windows as it did not serve any purpose
- win32: load locale files from installation path
- sysdeps/win32.c: massively decreased length by refactoring
- sysdeps/win32.c: use unicode function-calls for better compatibility with non-ascii locales
- sysdeps/win32.c: format debug and warning messages that contain win32 error-codes and provide extensive error handling
- sysdeps/win32.c: completely redid sensor-handling that allows supporting multiple sensor-backends at the same time (like on unix) and optionally launch sensor-apps if they're in $PATH. Sensor detection is now properly done at gkrellm-startup
- sysdeps/win32.c: support CoreTemp application for getting cpu temperatures
- sysdeps/win32.c: proc stats are finally working. Load-computation is based on the number of processes in the processor waiting-queue
- sysdeps/win32.c: properly count number of logged in users by only counting "interactive logins"
- sysdeps/win32.c: memory stats now also monitor cache bytes on winxp and newer (not available on win2k)
- sysdeps/win32.c: system name updated with some new windows versions. Also allow proper OS-detection on 64bit-OS when running as a 32bit-app
This commit is contained in:
Stefan Gehn 2008-09-28 17:27:06 +00:00
parent 32a20aeaef
commit 37c7f836ef
6 changed files with 1840 additions and 1473 deletions

View File

@ -22,6 +22,11 @@ INSTALL ?= install
LINK_FLAGS ?= -Wl,-E
SMC_LIBS ?= -L/usr/X11R6/lib -lSM -lICE
SHARED_PATH = ../shared
# Make GNU Make search for sources somewhere else as well
VPATH = $(SHARED_PATH)
ifeq ($(without-gnutls),1)
CONFIGURE_ARGS += --without-gnutls
endif
@ -40,8 +45,6 @@ endif
ifeq ($(without-libsensors),1)
CONFIGURE_ARGS += --without-libsensors
endif
DUMMY_VAR := $(shell ./configure $(CONFIGURE_ARGS))
HAVE_GNUTLS = $(shell grep -c HAVE_GNUTLS configure.h)
@ -65,14 +68,13 @@ endif
CC ?= gcc
STRIP ?= -s
GKRELLM_INCLUDES = gkrellm.h gkrellm-public-proto.h
GKRELLM_INCLUDES = gkrellm.h gkrellm-public-proto.h $(SHARED_PATH)/log.h
PKG_INCLUDE = `$(PKG_CONFIG) --cflags gtk+-2.0 gthread-2.0`
PKG_LIB = `$(PKG_CONFIG) --libs gtk+-2.0 gthread-2.0`
FLAGS = -O2 -I.. $(PKG_INCLUDE) $(GTOP_INCLUDE)
FLAGS+= $(PTHREAD_INC)
FLAGS = -O2 -I.. -I$(SHARED_PATH) $(PKG_INCLUDE) $(GTOP_INCLUDE) $(PTHREAD_INC) \
-DGKRELLM_CLIENT
LIBS = $(PKG_LIB) $(GTOP_LIBS) $(SMC_LIBS) $(SYS_LIBS) $(SSL_LIBS) $(SENSORS_LIBS)
@ -83,6 +85,13 @@ ifeq ($(debug),yes)
FLAGS += -g
endif
ifeq ($(profile),1)
FLAGS += -g -pg
endif
ifeq ($(profile),yes)
FLAGS += -g -pg
endif
ifeq ($(enable_nls),1)
FLAGS += -DENABLE_NLS -DLOCALEDIR=\"$(LOCALEDIR)\"
endif
@ -91,7 +100,7 @@ ifeq ($(enable_nls),yes)
endif
ifneq ($(PACKAGE),gkrellm)
FLAGS += -DPACKAGE=\"$(PACKAGE)\"
FLAGS += -DPACKAGE=\"$(PACKAGE)\"
endif
ifeq ($(HAVE_GETADDRINFO),1)
@ -105,9 +114,9 @@ OBJS = main.o alerts.o battery.o base64.o clock.o cpu.o disk.o fs.o \
hostname.o inet.o mail.o mem.o net.o proc.o sensors.o uptime.o \
chart.o panel.o config.o gui.o krell.o plugins.o pixops.o \
smbdes.o smbencrypt.o smbmd4.o smbutil.o \
client.o utils.o deprecated.o
client.o utils.o sysdeps-unix.o deprecated.o log.o
UNIXOBJS = winops-x11.o sysdeps-unix.o
UNIXOBJS = winops-x11.o
all: gkrellm
@ -170,13 +179,13 @@ solaris:
windows: libgkrellm.a
$(MAKE) \
CFLAGS="${CFLAGS} -DWIN32_CLIENT -D_WIN32_WINNT=0x0500 -DWINVER=0x0500" \
LINK_FLAGS="${LINK_FLAGS} -mwindows" \
EXTRAOBJS="${EXTRAOBJS} winops-win32.o sysdeps/win32.o win32-plugin.o win32-resource.o" \
SYS_LIBS=" -llargeint -lws2_32 -lpdh -lnetapi32 -liphlpapi -lntdll -lintl" \
SMC_LIBS="" \
UNIXOBJS="" \
gkrellm
CFLAGS="${CFLAGS} -D_WIN32_WINNT=0x0500 -DWINVER=0x0500" \
LINK_FLAGS="${LINK_FLAGS} -mwindows" \
EXTRAOBJS="${EXTRAOBJS} winops-win32.o win32-plugin.o win32-resource.o" \
SYS_LIBS=" -llargeint -lws2_32 -lpdh -lnetapi32 -liphlpapi -lntdll -lintl" \
SMC_LIBS="" \
UNIXOBJS="" \
gkrellm
install: install_bin install_inc install_man
@ -320,14 +329,17 @@ pixops.o: pixops.c $(GKRELLM_H)
client.o: client.c $(GKRELLM_H)
utils.o: utils.c $(GKRELLM_H)
sysdeps-unix.o: sysdeps-unix.c $(GKRELLM_H_SYS) $(SYSDEPS_SRC)
log.o: $(SHARED_PATH)/log.c $(SHARED_PATH)/log.h $(GKRELLM_H)
deprecated.o: deprecated.c $(GKRELLM_H)
winops-x11.o: winops-x11.c $(GKRELLM_H)
winops-gtk-mac.o: winops-gtk-mac.c $(GKRELLM_H)
deprecated.o: deprecated.c $(GKRELLM_H)
sysdeps/win32.o: sysdeps/win32.c $(GKRELLM_H_SYS)
winops-win32.o: winops-win32.c $(GKRELLM_H)
winops-win32.o: winops-win32.c $(GKRELLM_H)
win32-plugin.o: win32-plugin.c win32-plugin.h
win32-libgkrellm.o: win32-libgkrellm.c win32-plugin.h
win32-resource.o: win32-resource.rc win32-resource.h
windres -I.. -o win32-resource.o win32-resource.rc
libgkrellm.a: win32-libgkrellm.o
ar -cr libgkrellm.a win32-libgkrellm.o

View File

@ -25,7 +25,8 @@
#if defined(HAVE_CONFIG_H)
#include "config.h"
#endif
#endif
#include "log.h"
#if !defined(WIN32)
#include <sys/param.h>
@ -84,7 +85,7 @@
# define gettext(String) (String)
# define dgettext(Domain,String) (String)
# define dcgettext(Domain,String,Type) (String)
# define bindtextdomain(Domain,Directory) (Domain)
# define bindtextdomain(Domain,Directory) (Domain)
#endif /* ENABLE_NLS */
@ -269,7 +270,7 @@ typedef struct
GdkBitmap *stencil;
gint y_src; /* Offset into pixmap if a vertical stack */
gint w, h; /* Size of the decal */
gint x, y; /* Position of decal in a drawable */
gint x, y; /* Position of decal in a drawable */
gshort flags,
state;
gint value; /* Index into stack, text value, etc */
@ -1050,13 +1051,13 @@ typedef struct _GkrellmMonitor
void (*save_user_config)(FILE *);
void (*load_user_config)(gchar *);
gchar *config_keyword;
void (*undef2)(void);
void (*undef1)(void);
GkrellmMonprivate *privat;
gint insert_before_id; /* If plugin, insert before this mon*/
void *handle; /* If monitor is a plugin. */
gchar *path; /* " */
}

View File

@ -22,6 +22,7 @@
#include "gkrellm.h"
#include "gkrellm-private.h"
#include "gkrellm-sysdeps.h"
#include "log-private.h"
#if GTK_CHECK_VERSION(2,4,0)
#include "icon.xpm"
@ -133,17 +134,15 @@ load_font(gchar *font_string, PangoFontDescription **gk_font,
if (font_string)
font_desc = pango_font_description_from_string(font_string);
if (_GK.debug_level & DEBUG_GUI)
printf("load_font: %s %p\n", font_string, font_desc);
gkrellm_debug(DEBUG_GUI, "load_font: %s %p\n", font_string, font_desc);
if (!font_desc)
{
for (i = 0; !font_desc && i < N_FALLBACK_FONTS; ++i)
{
font_desc = pango_font_description_from_string(fallback_fonts[i]);
if (_GK.debug_level & DEBUG_GUI)
printf("load_font trying fallback: %s\n",
fallback_fonts[i]);
gkrellm_debug(DEBUG_GUI, "load_font trying fallback: %s\n",
fallback_fonts[i]);
}
}
if (*gk_font)
@ -222,7 +221,7 @@ setup_colors()
/* Set up the depth 1 GCs
*/
/* printf("white pixel = %ld\n", _GK.white_color.pixel); */
/* g_print("white pixel = %ld\n", _GK.white_color.pixel); */
if (_GK.bit1_GC == NULL)
{
GdkBitmap *dummy_bitmap;
@ -274,8 +273,7 @@ set_or_save_position(gint save)
y_last = _GK.y_position;
fprintf(f, "%d %d\n", _GK.x_position, _GK.y_position);
fclose(f);
if (_GK.debug_level & DEBUG_POSITION)
printf("save_position: %d %d\n", x_last, y_last);
gkrellm_debug(DEBUG_POSITION, "save_position: %d %d\n", x_last, y_last);
}
save_position_countdown = 0;
}
@ -295,8 +293,7 @@ set_or_save_position(gint save)
_GK.y_position = y_last = y;
_GK.position_valid = TRUE;
gdk_window_move(gtree.window->window, x, y);
if (_GK.debug_level & DEBUG_POSITION)
printf("startup_position moveto %d %d (valid)\n", x, y);
gkrellm_debug(DEBUG_POSITION, "startup_position moveto %d %d (valid)\n", x, y);
}
}
}
@ -602,8 +599,7 @@ top_frame_button_release(GtkWidget *widget, GdkEventButton *ev, gpointer data)
if (!no_transparency)
gkrellm_winop_apply_rootpixmap_transparency();
moving_gkrellm = FALSE;
if (_GK.debug_level & DEBUG_POSITION)
printf("gkrellm moveto: x_pos=%d y_pos=%d\n",
gkrellm_debug(DEBUG_POSITION, "gkrellm moveto: x_pos=%d y_pos=%d\n",
_GK.x_position, _GK.y_position);
}
@ -1179,7 +1175,7 @@ gkrellm_pack_side_frames(void)
{
rf_image = gtk_image_new_from_pixmap(gtree.frame_right_pixmap, NULL);
gtk_box_pack_start(GTK_BOX(gtree.right_vbox), rf_image,
FALSE, FALSE, 0);
FALSE, FALSE, 0);
gtk_widget_show(rf_image);
}
else
@ -1199,9 +1195,9 @@ gkrellm_pack_side_frames(void)
{
gdk_window_move(gtree.window->window,
_GK.x_position, _GK.y_position);
if (_GK.debug_level & DEBUG_POSITION)
printf("pack moveto %d %d=y_position (y_gkrell=%d y_bot=%d)\n",
_GK.x_position, _GK.y_position, y_gkrell, y_bottom);
gkrellm_debug(DEBUG_POSITION,
"pack moveto %d %d=y_position (y_gkrell=%d y_bot=%d)\n",
_GK.x_position, _GK.y_position, y_gkrell, y_bottom);
}
y_pack = -1;
}
@ -1218,9 +1214,9 @@ gkrellm_pack_side_frames(void)
if (_GK.position_valid)
{
gdk_window_move(gtree.window->window, _GK.x_position, y_pack);
if (_GK.debug_level & DEBUG_POSITION)
printf("pack moveto %d %d=y_pack (y_gkrell=%d y_bot=%d)\n",
_GK.x_position, y_pack, y_gkrell, y_bottom);
gkrellm_debug(DEBUG_POSITION,
"pack moveto %d %d=y_pack (y_gkrell=%d y_bot=%d)\n",
_GK.x_position, y_pack, y_gkrell, y_bottom);
}
}
/* If GKrellM bottom edge was <= screen bottom, then move to make
@ -1233,9 +1229,9 @@ gkrellm_pack_side_frames(void)
if (_GK.position_valid)
{
gdk_window_move(gtree.window->window, _GK.x_position, y_pack);
if (_GK.debug_level & DEBUG_POSITION)
printf("pack moveto %d %d=y_pack (y_gkrell=%d on_bottom)\n",
_GK.x_position, y_pack, y_gkrell);
gkrellm_debug(DEBUG_POSITION,
"pack moveto %d %d=y_pack (y_gkrell=%d on_bottom)\n",
_GK.x_position, y_pack, y_gkrell);
}
}
}
@ -1293,8 +1289,8 @@ fix_edges()
gdk_window_move(gtree.window->window, x, y);
if (y != _GK.y_position)
y_pack = y;
if (_GK.debug_level & DEBUG_POSITION)
printf("fix_edges: %d %d (y_pos=%d)\n", x, y, _GK.y_position);
gkrellm_debug(DEBUG_POSITION,
"fix_edges: %d %d (y_pos=%d)\n", x, y, _GK.y_position);
}
}
@ -1319,7 +1315,7 @@ gkrellm_render_spacer(GkrellmSpacer *spacer, gint y_src, gint h_src,
)
{
if (spacer->height > 0)
fprintf(stderr, "Bad image size for spacer or bg_chart.\n");
g_warning("Bad image size for spacer or bg_chart.\n");
return FALSE;
}
piximage.border = spacer->piximage->border;
@ -1573,7 +1569,7 @@ cb_client_event(GtkWidget *widget, GdkEventClient *event, gpointer data)
if (!atom_gkrellm_read_theme)
atom_gkrellm_read_theme = gdk_atom_intern("_GKRELLM_READ_THEME",FALSE);
if (event->message_type == atom_gkrellm_read_theme)
if (event->message_type == atom_gkrellm_read_theme)
gkrellm_read_theme_event(NULL);
return FALSE;
}
@ -1673,12 +1669,16 @@ cb_configure_notify(GtkWidget *widget, GdkEventConfigure *ev, gpointer data)
if (y >= 0 && y < _GK.h_display - 5 && y != y_pack)
_GK.y_position = y;
_GK.position_valid = TRUE;
if (!moving_gkrellm && (_GK.debug_level & DEBUG_POSITION))
printf("configure-event: x_pos=%d y_pos=%d x=%d y=%d y_pack=%d\n",
_GK.x_position, _GK.y_position, x, y, y_pack);
if (!moving_gkrellm)
gkrellm_debug(DEBUG_POSITION,
"configure-event: x_pos=%d y_pos=%d x=%d y=%d y_pack=%d\n",
_GK.x_position, _GK.y_position, x, y, y_pack);
}
else
{
gkrellm_debug(DEBUG_POSITION,
"locked configure-event: x=%d y=%d\n", x, y);
}
else if (_GK.debug_level & DEBUG_POSITION)
printf("locked configure-event: x=%d y=%d\n", x, y);
if (size_change || position_change)
gkrellm_winop_update_struts();
@ -1948,26 +1948,11 @@ load_builtin_monitors()
add_builtin(gkrellm_init_uptime_monitor());
}
void
gkrellm_print(const gchar *string)
{
gchar *s;
s = g_locale_from_utf8(string, -1, NULL, NULL, NULL);
if (s)
{
fputs(s, stdout);
g_free(s);
}
else
fputs(string, stdout);
}
static void
gkrellm_exit(gint exit_code)
{
gkrellm_sys_main_cleanup();
gkrellm_log_cleanup();
exit(exit_code);
}
@ -2051,22 +2036,40 @@ main(gint argc, gchar **argv)
gint i;
gchar *s;
gkrellm_sys_main_init();
//gkrellm_sys_main_init();
#ifdef ENABLE_NLS
gtk_set_locale();
#endif
g_thread_init(NULL);
gtk_init(&argc, &argv); /* Will call gdk_init() */
gkrellm_log_init();
gtk_widget_push_colormap(gdk_rgb_get_colormap());
#ifdef ENABLE_NLS
#ifdef LOCALEDIR
#if defined(WIN32)
/*
Prepend app install path to relative locale dir, don't rely on CWD being correct
*/
if (!G_IS_DIR_SEPARATOR(LOCALEDIR[0]))
{
gchar* locale_dir;
locale_dir = g_win32_get_package_installation_subdirectory(NULL, NULL, LOCALEDIR);
if (locale_dir != NULL)
{
bindtextdomain(PACKAGE, locale_dir);
g_free(locale_dir);
}
}
else
{
bindtextdomain(PACKAGE, LOCALEDIR);
}
#else
bindtextdomain(PACKAGE, LOCALEDIR);
#endif
#endif /* !WIN32 */
#endif /* LOCALEDIR */
textdomain(PACKAGE);
bind_textdomain_codeset(PACKAGE, "UTF-8");
#endif /* ENABLE_NLS */
@ -2080,8 +2083,6 @@ main(gint argc, gchar **argv)
signal(SIGSEGV, gkrellm_abort);
signal(SIGABRT, gkrellm_abort);
g_set_print_handler(gkrellm_print);
for (i = 1; i < argc; ++i)
{
s = argv[i];
@ -2128,6 +2129,8 @@ main(gint argc, gchar **argv)
_GK.no_config = TRUE;
else if ((!strcmp(s, "debug-level") || !strcmp(s, "d")) && i < argc-1)
_GK.debug_level = (gint) strtoul(argv[++i], NULL, 0);
else if ((!strcmp(s, "logfile") || !strcmp(s, "l")) && i < argc-1)
gkrellm_log_set_filename(argv[++i]);
else if (!strncmp(s, "debug", 5))
{
if (s[5] != '\0')
@ -2150,7 +2153,7 @@ main(gint argc, gchar **argv)
_GK.test += 1;
else if (!strcmp(s, "version") || !strcmp(s, "v"))
{
printf("%s %d.%d.%d%s\n", PACKAGE, GKRELLM_VERSION_MAJOR,
g_print("%s %d.%d.%d%s\n", PACKAGE, GKRELLM_VERSION_MAJOR,
GKRELLM_VERSION_MINOR, GKRELLM_VERSION_REV,
GKRELLM_EXTRAVERSION);
exit(0);
@ -2168,17 +2171,19 @@ main(gint argc, gchar **argv)
}
}
gkrellm_sys_main_init(); //FIXME: call this later or earlier?
_GK.w_display = gdk_screen_get_width(gdk_screen_get_default());
_GK.h_display = gdk_screen_get_height(gdk_screen_get_default());
if (_GK.debug_level)
printf("--- GKrellM %d.%d.%d ---\n", GKRELLM_VERSION_MAJOR,
GKRELLM_VERSION_MINOR, GKRELLM_VERSION_REV);
if (_GK.debug_level > 0)
g_debug("--- GKrellM %d.%d.%d ---\n", GKRELLM_VERSION_MAJOR,
GKRELLM_VERSION_MINOR, GKRELLM_VERSION_REV);
if (_GK.server && !gkrellm_client_mode_connect())
exit(0);
check_gkrellm_directories();
gkrellm_load_user_config(NULL, FALSE);
gkrellm_load_user_config(NULL, FALSE);
decorated = (_GK.command_line_decorated || _GK.decorated);
if ( _GK.command_line_plugin || _GK.command_line_theme
|| _GK.debug_level > 0 || _GK.debug > 0 || _GK.nolock
@ -2252,33 +2257,10 @@ main(gint argc, gchar **argv)
gkrellm_start_timer(_GK.update_HZ);
setup_signal_handler();
gtk_main ();
gtk_main();
gkrellm_save_all();
gkrellm_exit(0);
return 0;
}
#if defined(WIN32) && defined(_WINDOWS)
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
int argc;
gint i, ret;
gchar *s, *sm;
gchar **argv;
gchar *cmd;
// need to get exe too
cmd = GetCommandLine();
g_shell_parse_argv(cmd, &argc, &argv, NULL);
ret = main(argc, argv);
g_strfreev(argv);
return ret;
}
#endif

View File

@ -68,9 +68,15 @@
#include "sysdeps/gtop.c"
#endif
#include <sys/utsname.h>
#if defined(WIN32)
#include "sysdeps/win32.c"
#endif
#ifndef SENSORS_COMMON
#if !defined(WIN32)
#include <sys/utsname.h>
#endif
#if !defined(SENSORS_COMMON) && !defined(WIN32)
static gboolean (*mbmon_check_func)();
#endif
@ -86,6 +92,7 @@ gkrellm_sys_get_host_name(void)
return buf;
}
#if !defined(WIN32)
gchar *
gkrellm_sys_get_system_name(void)
{
@ -98,12 +105,13 @@ gkrellm_sys_get_system_name(void)
sname = g_strdup("unknown name");
return sname;
}
#endif
gboolean
gkrellm_sys_sensors_mbmon_port_change(gint port)
{
gboolean result = FALSE;
#if !defined(WIN32)
_GK.mbmon_port = port;
/* mbmon_check_func will be set if sysdep code has included
@ -116,11 +124,16 @@ gkrellm_sys_sensors_mbmon_port_change(gint port)
gkrellm_sensors_model_update();
gkrellm_sensors_rebuild(TRUE, TRUE, TRUE);
}
#endif
return result;
}
gboolean
gkrellm_sys_sensors_mbmon_supported(void)
{
#if !defined(WIN32)
return mbmon_check_func ? TRUE : FALSE;
#else
return FALSE;
#endif
}

File diff suppressed because it is too large Load Diff

View File

@ -24,234 +24,157 @@
#include "win32-resource.h"
#include <gdk/gdkwin32.h>
static UINT WM_GKRELLMCALLBACK;
static WNDPROC oldWndProc = 0;
static GdkGC *trans_gc = NULL;
static GdkColor trans_color;
void gkrellm_winop_reset(void)
void
gkrellm_winop_reset(void)
{
}
LRESULT CALLBACK newWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
if (Msg == WM_GKRELLMCALLBACK)
void
gkrellm_winop_options(gint argc, gchar **argv)
{
if (lParam == WM_LBUTTONUP)
SetForegroundWindow(GDK_WINDOW_HWND(gkrellm_get_top_window()->window));
else if (lParam == WM_RBUTTONUP)
gkrellm_menu_popup();
}
/*else if (Msg == WM_SIZE && _GK.withdrawn)
{
HWND slitHwnd = FindWindowEx(NULL, NULL, "BControl", "BSlitWindow");
if (slitHwnd != NULL)
PostMessage(slitHwnd, BM_SLITMESSAGE, BSM_UPDATEPOSITIONS, 0);
InvalidateRgn(GDK_WINDOW_HWND(gkrellm_get_top_window()->window), NULL, FALSE);
}*/
return CallWindowProc(oldWndProc, hWnd, Msg, wParam, lParam);
}
void gkrellm_winop_options(gint argc, gchar **argv)
{
NOTIFYICONDATA nid;
HWND hWnd = GDK_WINDOW_HWND(gkrellm_get_top_window()->window);
// get gtk window procedure and set new one
oldWndProc = (WNDPROC)GetWindowLong(hWnd, GWL_WNDPROC);
SetWindowLong(hWnd, GWL_WNDPROC, (LONG)newWndProc);
// Get rid of task list icon
SetWindowLong(hWnd, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
// Create System Tray Icon
WM_GKRELLMCALLBACK = RegisterWindowMessage(TEXT("GKrellMCallback"));
nid.cbSize = sizeof(NOTIFYICONDATA);
nid.hWnd = hWnd;
nid.uID = 1;
nid.uFlags = (NIF_ICON | NIF_TIP | NIF_MESSAGE);
nid.uCallbackMessage = WM_GKRELLMCALLBACK;
strcpy(nid.szTip, g_locale_from_utf8(_("GKrellM for Windows"), -1, NULL, NULL, NULL));
nid.hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON3));
Shell_NotifyIcon(NIM_ADD, &nid);
// Set stay-on-top flag if requested
if (_GK.on_top)
{
// set stay on top flag if requested
SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
}
/*if (_GK.withdrawn)
{
// put in slit in bluebox
HWND slithWnd = FindWindowEx(NULL, NULL, "BControl", "BSlitWindow");
SetProp(hWnd, "BSlitControl", (HANDLE)1);
if (IsWindow(slithWnd))
{
SendMessage(slithWnd, BM_SLITMESSAGE, BSM_ADDWINDOW, (LPARAM) hWnd);
SetWindowPos(hWnd, NULL, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
gdk_window_move(gkrellm_get_top_window()->window, 0, 0);
_GK.x_position = 0;
_GK.y_position = 0;
_GK.position_valid = TRUE;
SetWindowLong(hWnd, GWL_USERDATA, 0x49474541);
PostMessage(slithWnd, BM_SLITMESSAGE, BSM_UPDATEPOSITIONS, 0);
InvalidateRgn(hWnd, NULL, FALSE);
}
}*/
}
void gkrellm_winop_withdrawn(void)
{
}
void gkrellm_winop_place_gkrellm(gchar *geom)
{
gint newX = _GK.x_position;
gint newY = _GK.y_position;
void
gkrellm_winop_withdrawn(void)
{
}
// parse the command line
// +x+y or -x+y or +x-y or -x-y
void
gkrellm_winop_place_gkrellm(gchar *geom)
{
gint newX = _GK.x_position;
gint newY = _GK.y_position;
gint startx = -1, starty = -1, endx = -1, endy = -1;
gint w_gkrell, h_gkrell;
gint stringSize = strlen(geom);
gint i;
gint xsign = 1, ysign = 1;
gchar* part;
// parse the command line
// +x+y or -x+y or +x-y or -x-y
gint startx = -1, starty = -1, endx = -1, endy = -1;
gint w_gkrell, h_gkrell;
gint stringSize = strlen(geom);
gint i;
gint xsign = 1, ysign = 1;
gchar* part;
for (i = 0; i < stringSize; i++)
{
if (geom[i] != '+' && geom[i] != '-')
{
if (geom[i] != '+' && geom[i] != '-')
{
if (startx == -1)
{
startx = i;
}
startx = i;
if (starty == -1 && endx != -1)
{
starty = i;
}
starty = i;
}
else
{
if (startx != -1 && endx == -1)
{
endx = i - 1;
if (geom[i] == '-')
if (startx != -1 && endx == -1)
{
xsign = -1;
}
endx = i - 1;
if (geom[i] == '-')
xsign = -1;
}
if (starty != -1 && endy == -1)
{
endy = i - 1;
if (geom[i] == '-')
{
ysign = -1;
}
endy = i - 1;
if (geom[i] == '-')
ysign = -1;
}
}
}
if (starty != -1 && endy == -1)
{
endy = stringSize - 1;
}
endy = stringSize - 1;
w_gkrell = _GK.chart_width + _GK.frame_left_width + _GK.frame_right_width;
h_gkrell = _GK.monitor_height + _GK.total_frame_height;
w_gkrell = _GK.chart_width + _GK.frame_left_width + _GK.frame_right_width;
h_gkrell = _GK.monitor_height + _GK.total_frame_height;
if (startx >= 0 && startx <= endx && endx >= 0)
{
part = malloc(sizeof(gchar) * (endx - startx + 1 + 1));
{
part = malloc(sizeof(gchar) * (endx - startx + 1 + 1));
for (i = 0; i < endx - startx + 1; i++)
{
part[i] = geom[i + startx];
}
part[i] = '\0';
newX = atoi(part);
part[i] = geom[i + startx];
part[i] = '\0';
newX = atoi(part);
if (xsign == -1)
{
newX = _GK.w_display - w_gkrell + newX;
}
free(part);
}
if (starty >= 0 && starty <= endy && endy >= 0)
{
part = malloc(sizeof(gchar) * (endy - starty + 1 + 1));
for (i = 0; i < endy - starty + 1; i++)
{
part[i] = geom[i + starty];
}
part[i] = '\0';
newY = atoi(part);
if (ysign == -1)
{
newY = _GK.h_display - h_gkrell + newY;
}
newX = _GK.w_display - w_gkrell + newX;
free(part);
}
if (newX >= 0 && newX < _GK.w_display - 10
&& newY >= 0 && newY < _GK.h_display - 25)
{
gdk_window_move(gkrellm_get_top_window()->window, newX, newY);
_GK.y_position = newY;
_GK.x_position = newX;
if (starty >= 0 && starty <= endy && endy >= 0)
{
part = malloc(sizeof(gchar) * (endy - starty + 1 + 1));
for (i = 0; i < endy - starty + 1; i++)
part[i] = geom[i + starty];
part[i] = '\0';
newY = atoi(part);
if (ysign == -1)
newY = _GK.h_display - h_gkrell + newY;
}
if ( newX >= 0 && newX < _GK.w_display - 10
&& newY >= 0 && newY < _GK.h_display - 25)
{
gdk_window_move(gkrellm_get_top_window()->window, newX, newY);
_GK.y_position = newY;
_GK.x_position = newX;
}
_GK.position_valid = TRUE;
}
void gkrellm_winop_flush_motion_events(void)
void
gkrellm_winop_flush_motion_events(void)
{
}
gboolean gkrellm_winop_updated_background(void)
gboolean
gkrellm_winop_updated_background(void)
{
return TRUE;
}
void gkrellm_winop_update_struts(void)
void
gkrellm_winop_update_struts(void)
{
}
gboolean gkrellm_winop_draw_rootpixmap_onto_transparent_chart(GkrellmChart *p)
gboolean
gkrellm_winop_draw_rootpixmap_onto_transparent_chart(GkrellmChart *p)
{
if (!p->transparency || !p->drawing_area || !p->drawing_area->window || trans_gc == NULL)
return FALSE;
if (!p->transparency || !p->drawing_area || !p->drawing_area->window || !trans_gc)
return FALSE;
// Fill the panel with transparency color
gdk_draw_rectangle(p->bg_src_pixmap, trans_gc, TRUE, 0, 0, p->w, p->h);
// If mode permits, stencil on non transparent parts of bg_clean_pixmap.
if (p->transparency == 2 && p->bg_mask)
{
gdk_gc_set_clip_mask(_GK.text_GC, p->bg_mask);
gdk_draw_drawable(p->bg_src_pixmap, _GK.text_GC, p->bg_clean_pixmap, 0, 0, 0, 0, p->w, p->h);
}
{
gdk_gc_set_clip_mask(_GK.text_GC, p->bg_mask);
gdk_draw_drawable(p->bg_src_pixmap, _GK.text_GC, p->bg_clean_pixmap,
0, 0, 0, 0, p->w, p->h);
}
gdk_gc_set_clip_mask(_GK.text_GC, NULL);
p->bg_sequence_id += 1;
return TRUE;
}
gboolean gkrellm_winop_draw_rootpixmap_onto_transparent_panel(GkrellmPanel *p)
gboolean
gkrellm_winop_draw_rootpixmap_onto_transparent_panel(GkrellmPanel *p)
{
if (!p->transparency || !p->drawing_area || !p->drawing_area->window || trans_gc == NULL)
if (!p->transparency || !p->drawing_area || !p->drawing_area->window || !trans_gc)
return FALSE;
gdk_gc_set_fill(trans_gc, GDK_SOLID);
@ -262,16 +185,17 @@ gboolean gkrellm_winop_draw_rootpixmap_onto_transparent_panel(GkrellmPanel *p)
// If mode permits, stencil on non transparent parts of bg_clean_pixmap.
if (p->transparency == 2 && p->bg_mask)
{
{
gdk_gc_set_clip_mask(_GK.text_GC, p->bg_mask);
gdk_draw_drawable(p->bg_pixmap, _GK.text_GC, p->bg_clean_pixmap, 0, 0, 0, 0, p->w, p->h);
gdk_draw_drawable(p->bg_pixmap, _GK.text_GC, p->bg_clean_pixmap,
0, 0, 0, 0, p->w, p->h);
gdk_gc_set_clip_mask(_GK.text_GC, NULL);
}
}
return TRUE;
}
static void draw_rootpixmap_onto_transparent_spacers(GkrellmMonitor *mon)
static void
draw_rootpixmap_onto_transparent_spacers(GkrellmMonitor *mon)
{
GkrellmMonprivate *mp = mon->privat;
@ -312,36 +236,36 @@ static void draw_rootpixmap_onto_transparent_spacers(GkrellmMonitor *mon)
}
}
void gkrellm_winop_apply_rootpixmap_transparency(void)
void
gkrellm_winop_apply_rootpixmap_transparency(void)
{
static gboolean isTransparent = FALSE;
GList *list;
GList *list;
GkrellmChart *cp;
GkrellmPanel *p;
HWND w;
HWND w;
w = GDK_WINDOW_HWND(gkrellm_get_top_window()->window);
if (!_GK.any_transparency && isTransparent)
{ // make opaque
{ // make opaque
SetWindowLong(w, GWL_EXSTYLE, GetWindowLong(w, GWL_EXSTYLE) & ~WS_EX_LAYERED);
isTransparent = FALSE;
return;
}
}
else if (_GK.any_transparency && !isTransparent)
{ // make transparent
{ // make transparent
if (trans_gc == NULL)
{
{
GdkColormap *cm = gtk_widget_get_colormap(gkrellm_get_top_window());
trans_gc = gdk_gc_new(gkrellm_get_top_window()->window);
if (trans_gc == NULL)
{
printf("ERROR: could not create trans_gc!\n");
{
g_warning("Could not create trans_gc!\n");
return;
}
}
gdk_gc_copy(trans_gc, _GK.draw1_GC);
gdk_gc_set_fill(trans_gc, GDK_SOLID);
@ -350,65 +274,64 @@ void gkrellm_winop_apply_rootpixmap_transparency(void)
trans_color.blue = 65535;
if (!gdk_colormap_alloc_color(cm , &trans_color, FALSE, TRUE))
{
printf("ERROR: could not allocate trans_color!\n");
g_object_unref(trans_gc);
trans_gc = NULL;
return;
}
{
g_warning("Could not allocate trans_color!\n");
g_object_unref(trans_gc);
trans_gc = NULL;
return;
}
gdk_gc_set_foreground(trans_gc, &trans_color);
}
}
SetWindowLong(w, GWL_EXSTYLE, GetWindowLong(w, GWL_EXSTYLE) | WS_EX_LAYERED);
SetLayeredWindowAttributes(w, RGB(255, 0, 255), 0, LWA_COLORKEY);
isTransparent = TRUE;
}
}
if (isTransparent)
{
for (list = gkrellm_get_chart_list(); list; list = list->next)
{
for (list = gkrellm_get_chart_list(); list; list = list->next)
{
cp = (GkrellmChart *) list->data;
if (!cp->transparency || !cp->shown)
continue;
gkrellm_winop_draw_rootpixmap_onto_transparent_chart(cp);
gkrellm_refresh_chart(cp);
}
}
for (list = gkrellm_get_panel_list(); list; list = list->next)
{
{
p = (GkrellmPanel *) list->data;
if (!p->transparency || !p->shown)
continue;
gkrellm_draw_panel_label(p);
}
}
for (list = gkrellm_monitor_list; list; list = list->next)
{
{
draw_rootpixmap_onto_transparent_spacers((GkrellmMonitor *)list->data);
}
}
gdk_gc_set_clip_mask(_GK.text_GC, NULL);
}
}
}
void gkrellm_winop_state_skip_taskbar(gboolean state)
void
gkrellm_winop_state_skip_taskbar(gboolean state)
{
}
void gkrellm_winop_state_skip_pager(gboolean state)
void
gkrellm_winop_state_skip_pager(gboolean state)
{
}
void gkrellm_winop_state_above(gboolean state)
void
gkrellm_winop_state_above(gboolean state)
{
}
void gkrellm_winop_state_below(gboolean state)
void
gkrellm_winop_state_below(gboolean state)
{
}