* Pidgin is the legal property of its developers, whose names are too numerous * to list here. Please refer to the COPYRIGHT file distributed with this * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA # include <CoreFoundation/CoreFoundation.h> # include <IOKit/IOKitLib.h> # include "gtkwin32dep.h" /* We're on X11 and not MacOS X with IOKit. */ # include <X11/extensions/scrnsaver.h> # endif /* USE_SCREENSAVER */ * Get the number of seconds the user has been idle. In Unix-world * this is based on the X Windows usage. In MS Windows this is * based on keyboard/mouse usage information obtained from the OS. * In MacOS X, this is based on keyboard/mouse usage information * obtained from the OS, if configure detected IOKit. Otherwise, * MacOS X is handled as a case of X Windows. * In Debian bug #271639, jwz says: * Purple should simply ask xscreensaver how long the user has been idle: * % xscreensaver-command -time * XScreenSaver 4.18: screen blanked since Tue Sep 14 14:10:45 2004 * Or you can monitor the _SCREENSAVER_STATUS property on root window #0. * Element 0 is the status (0, BLANK, LOCK), element 1 is the time_t since * the last state change, and subsequent elements are which hack is running * on the various screens: * % xprop -f _SCREENSAVER_STATUS 32ac -root _SCREENSAVER_STATUS * _SCREENSAVER_STATUS(INTEGER) = BLANK, 1095196626, 10, 237 * See watch() in xscreensaver/driver/xscreensaver-command.c. * @return The number of seconds the user has been idle. #if defined(USE_SCREENSAVER) || defined(HAVE_IOKIT) pidgin_get_time_idle(void) /* Query the IOKit API */ static io_service_t macIOsrvc = NULL; uint64_t idle_time = 0; /* nanoseconds */ IOMasterPort(MACH_PORT_NULL, &master); macIOsrvc = IOServiceGetMatchingService(master, IOServiceMatching("IOHIDSystem")); property = IORegistryEntryCreateCFProperty(macIOsrvc, CFSTR("HIDIdleTime"), CFNumberGetValue((CFNumberRef)property, kCFNumberSInt64Type, &idle_time); /* convert nanoseconds to seconds */ return idle_time / 1000000000; return (GetTickCount() - winpidgin_get_lastactive()) / 1000; /* We're on X11 and not MacOS X with IOKit. */ static XScreenSaverInfo *mit_info = NULL; static int has_extension = -1; int event_base, error_base; has_extension = XScreenSaverQueryExtension(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), &event_base, &error_base); mit_info = XScreenSaverAllocInfo(); XScreenSaverQueryInfo(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), GDK_ROOT_WINDOW(), mit_info); return (mit_info->idle) / 1000; # endif /* !HAVE_IOKIT */ #endif /* USE_SCREENSAVER || HAVE_IOKIT */ static PurpleIdleUiOps ui_ops = #if defined(USE_SCREENSAVER) || defined(HAVE_IOKIT) #endif /* USE_SCREENSAVER || HAVE_IOKIT */