annotate src/gtkidle.c @ 12340:11d14efe7be2

[gaim-migrate @ 14644] sf patch #1373208, from Will Thompson "In Perl, we have Gaim::Conversation objects. However, all the functions that take Gaim::Conversations as the first argument are in the Gaim::Conv package. This makes the following not work: my $conv = Gaim::Conv::new(); $conv->get_features(); Instead, one has to do the following: my $conv = Gaim::Conv::new(); Gaim::Conv::get_features($conv);" committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Mon, 05 Dec 2005 03:53:00 +0000
parents 25d7ef365dbf
children bc249de5ea02
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11907
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1 /*
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
2 * gaim
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
3 *
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
4 * Gaim is the legal property of its developers, whose names are too numerous
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
6 * source distribution.
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
7 *
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
11 * (at your option) any later version.
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
12 *
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
16 * GNU General Public License for more details.
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
17 *
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
21 *
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
22 */
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
23 #include "internal.h"
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
24
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
25 #ifdef USE_SCREENSAVER
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
26 # ifndef _WIN32
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
27 # include <X11/Xlib.h>
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
28 # include <X11/Xutil.h>
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
29 # include <X11/extensions/scrnsaver.h>
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
30 # include <gdk/gdkx.h>
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
31 # else
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
32 # include "idletrack.h"
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
33 # endif
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
34 #endif /* USE_SCREENSAVER */
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
35
12272
3ef381cdc47e [gaim-migrate @ 14574]
Mark Doliner <mark@kingant.net>
parents: 12252
diff changeset
36 #include "idle.h"
11907
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
37
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
38 /**
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
39 * Get the number of seconds the user has been idle. In Unix-world
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
40 * this is based on the X Windows usage. In MS Windows this is based
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
41 * on keyboard/mouse usage.
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
42 *
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
43 * In Debian bug #271639, jwz says:
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
44 *
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
45 * Gaim should simply ask xscreensaver how long the user has been idle:
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
46 * % xscreensaver-command -time
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
47 * XScreenSaver 4.18: screen blanked since Tue Sep 14 14:10:45 2004
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
48 *
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
49 * Or you can monitor the _SCREENSAVER_STATUS property on root window #0.
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
50 * Element 0 is the status (0, BLANK, LOCK), element 1 is the time_t since
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
51 * the last state change, and subsequent elements are which hack is running
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
52 * on the various screens:
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
53 * % xprop -f _SCREENSAVER_STATUS 32ac -root _SCREENSAVER_STATUS
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
54 * _SCREENSAVER_STATUS(INTEGER) = BLANK, 1095196626, 10, 237
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
55 *
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
56 * See watch() in xscreensaver/driver/xscreensaver-command.c.
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
57 *
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
58 * @return The number of seconds the user has been idle.
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
59 */
12278
25d7ef365dbf [gaim-migrate @ 14582]
Mark Doliner <mark@kingant.net>
parents: 12272
diff changeset
60 #ifdef USE_SCREENSAVER
12272
3ef381cdc47e [gaim-migrate @ 14574]
Mark Doliner <mark@kingant.net>
parents: 12252
diff changeset
61 static time_t
3ef381cdc47e [gaim-migrate @ 14574]
Mark Doliner <mark@kingant.net>
parents: 12252
diff changeset
62 gaim_gtk_get_time_idle()
11907
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
63 {
12272
3ef381cdc47e [gaim-migrate @ 14574]
Mark Doliner <mark@kingant.net>
parents: 12252
diff changeset
64 # ifndef _WIN32
3ef381cdc47e [gaim-migrate @ 14574]
Mark Doliner <mark@kingant.net>
parents: 12252
diff changeset
65 /* Query xscreensaver */
11907
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
66 static XScreenSaverInfo *mit_info = NULL;
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
67 int event_base, error_base;
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
68 if (XScreenSaverQueryExtension(GDK_DISPLAY(), &event_base, &error_base)) {
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
69 if (mit_info == NULL) {
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
70 mit_info = XScreenSaverAllocInfo();
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
71 }
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
72 XScreenSaverQueryInfo(GDK_DISPLAY(), GDK_ROOT_WINDOW(), mit_info);
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
73 return (mit_info->idle) / 1000;
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
74 } else
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
75 return 0;
12272
3ef381cdc47e [gaim-migrate @ 14574]
Mark Doliner <mark@kingant.net>
parents: 12252
diff changeset
76 # else
3ef381cdc47e [gaim-migrate @ 14574]
Mark Doliner <mark@kingant.net>
parents: 12252
diff changeset
77 /* Query windows */
11907
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
78 return (GetTickCount() - wgaim_get_lastactive()) / 1000;
12272
3ef381cdc47e [gaim-migrate @ 14574]
Mark Doliner <mark@kingant.net>
parents: 12252
diff changeset
79 # endif /* _WIN32 */
12278
25d7ef365dbf [gaim-migrate @ 14582]
Mark Doliner <mark@kingant.net>
parents: 12272
diff changeset
80 }
11907
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
81 #endif /* USE_SCREENSAVER */
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
82
12272
3ef381cdc47e [gaim-migrate @ 14574]
Mark Doliner <mark@kingant.net>
parents: 12252
diff changeset
83 static GaimIdleUiOps ui_ops =
11907
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
84 {
12278
25d7ef365dbf [gaim-migrate @ 14582]
Mark Doliner <mark@kingant.net>
parents: 12272
diff changeset
85 #ifdef USE_SCREENSAVER
12272
3ef381cdc47e [gaim-migrate @ 14574]
Mark Doliner <mark@kingant.net>
parents: 12252
diff changeset
86 gaim_gtk_get_time_idle
12278
25d7ef365dbf [gaim-migrate @ 14582]
Mark Doliner <mark@kingant.net>
parents: 12272
diff changeset
87 #else
25d7ef365dbf [gaim-migrate @ 14582]
Mark Doliner <mark@kingant.net>
parents: 12272
diff changeset
88 NULL
25d7ef365dbf [gaim-migrate @ 14582]
Mark Doliner <mark@kingant.net>
parents: 12272
diff changeset
89 #endif /* USE_SCREENSAVER */
12272
3ef381cdc47e [gaim-migrate @ 14574]
Mark Doliner <mark@kingant.net>
parents: 12252
diff changeset
90 };
11907
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
91
12272
3ef381cdc47e [gaim-migrate @ 14574]
Mark Doliner <mark@kingant.net>
parents: 12252
diff changeset
92 GaimIdleUiOps *
3ef381cdc47e [gaim-migrate @ 14574]
Mark Doliner <mark@kingant.net>
parents: 12252
diff changeset
93 gaim_gtk_idle_get_ui_ops()
11907
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
94 {
12272
3ef381cdc47e [gaim-migrate @ 14574]
Mark Doliner <mark@kingant.net>
parents: 12252
diff changeset
95 return &ui_ops;
11907
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
96 }