annotate src/gtkidle.c @ 12478:8489040cf97b

[gaim-migrate @ 14789] Patch to gaim-devel by Aleksander Piotrowski "Looks like if one sets alias for particular buddy then alias_buddy callback is not called. Following diff fixes that problem for me (verified with jabber and my own protocol plugins) but I'm not sure if it is correct place to call serv_alias_buddy() (as I'm not sure if this whole alias bug isn't only my local problem ;)" committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Tue, 13 Dec 2005 23:25:24 +0000
parents bc249de5ea02
children 723f5b7ef6a2
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"
12410
bc249de5ea02 [gaim-migrate @ 14717]
Richard Laager <rlaager@wiktel.com>
parents: 12278
diff changeset
24 #include "gtkidle.h"
11907
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
25
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
26 #ifdef USE_SCREENSAVER
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
27 # ifndef _WIN32
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
28 # include <X11/Xlib.h>
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
29 # include <X11/Xutil.h>
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
30 # include <X11/extensions/scrnsaver.h>
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
31 # include <gdk/gdkx.h>
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
32 # else
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
33 # include "idletrack.h"
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
34 # endif
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
35 #endif /* USE_SCREENSAVER */
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
36
12272
3ef381cdc47e [gaim-migrate @ 14574]
Mark Doliner <mark@kingant.net>
parents: 12252
diff changeset
37 #include "idle.h"
11907
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 /**
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
40 * 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
41 * 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
42 * on keyboard/mouse usage.
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
43 *
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
44 * In Debian bug #271639, jwz says:
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
45 *
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
46 * Gaim should simply ask xscreensaver how long the user has been idle:
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
47 * % xscreensaver-command -time
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
48 * 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
49 *
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
50 * Or you can monitor the _SCREENSAVER_STATUS property on root window #0.
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
51 * 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
52 * the last state change, and subsequent elements are which hack is running
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
53 * on the various screens:
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
54 * % xprop -f _SCREENSAVER_STATUS 32ac -root _SCREENSAVER_STATUS
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
55 * _SCREENSAVER_STATUS(INTEGER) = BLANK, 1095196626, 10, 237
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
56 *
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
57 * See watch() in xscreensaver/driver/xscreensaver-command.c.
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
58 *
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
59 * @return The number of seconds the user has been idle.
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
60 */
12278
25d7ef365dbf [gaim-migrate @ 14582]
Mark Doliner <mark@kingant.net>
parents: 12272
diff changeset
61 #ifdef USE_SCREENSAVER
12272
3ef381cdc47e [gaim-migrate @ 14574]
Mark Doliner <mark@kingant.net>
parents: 12252
diff changeset
62 static time_t
3ef381cdc47e [gaim-migrate @ 14574]
Mark Doliner <mark@kingant.net>
parents: 12252
diff changeset
63 gaim_gtk_get_time_idle()
11907
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
64 {
12272
3ef381cdc47e [gaim-migrate @ 14574]
Mark Doliner <mark@kingant.net>
parents: 12252
diff changeset
65 # ifndef _WIN32
3ef381cdc47e [gaim-migrate @ 14574]
Mark Doliner <mark@kingant.net>
parents: 12252
diff changeset
66 /* Query xscreensaver */
11907
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
67 static XScreenSaverInfo *mit_info = NULL;
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
68 int event_base, error_base;
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
69 if (XScreenSaverQueryExtension(GDK_DISPLAY(), &event_base, &error_base)) {
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
70 if (mit_info == NULL) {
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
71 mit_info = XScreenSaverAllocInfo();
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
72 }
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
73 XScreenSaverQueryInfo(GDK_DISPLAY(), GDK_ROOT_WINDOW(), mit_info);
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
74 return (mit_info->idle) / 1000;
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
75 } else
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
76 return 0;
12272
3ef381cdc47e [gaim-migrate @ 14574]
Mark Doliner <mark@kingant.net>
parents: 12252
diff changeset
77 # else
3ef381cdc47e [gaim-migrate @ 14574]
Mark Doliner <mark@kingant.net>
parents: 12252
diff changeset
78 /* Query windows */
11907
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
79 return (GetTickCount() - wgaim_get_lastactive()) / 1000;
12272
3ef381cdc47e [gaim-migrate @ 14574]
Mark Doliner <mark@kingant.net>
parents: 12252
diff changeset
80 # endif /* _WIN32 */
12278
25d7ef365dbf [gaim-migrate @ 14582]
Mark Doliner <mark@kingant.net>
parents: 12272
diff changeset
81 }
11907
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
82 #endif /* USE_SCREENSAVER */
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
83
12272
3ef381cdc47e [gaim-migrate @ 14574]
Mark Doliner <mark@kingant.net>
parents: 12252
diff changeset
84 static GaimIdleUiOps ui_ops =
11907
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
85 {
12278
25d7ef365dbf [gaim-migrate @ 14582]
Mark Doliner <mark@kingant.net>
parents: 12272
diff changeset
86 #ifdef USE_SCREENSAVER
12272
3ef381cdc47e [gaim-migrate @ 14574]
Mark Doliner <mark@kingant.net>
parents: 12252
diff changeset
87 gaim_gtk_get_time_idle
12278
25d7ef365dbf [gaim-migrate @ 14582]
Mark Doliner <mark@kingant.net>
parents: 12272
diff changeset
88 #else
25d7ef365dbf [gaim-migrate @ 14582]
Mark Doliner <mark@kingant.net>
parents: 12272
diff changeset
89 NULL
25d7ef365dbf [gaim-migrate @ 14582]
Mark Doliner <mark@kingant.net>
parents: 12272
diff changeset
90 #endif /* USE_SCREENSAVER */
12272
3ef381cdc47e [gaim-migrate @ 14574]
Mark Doliner <mark@kingant.net>
parents: 12252
diff changeset
91 };
11907
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
92
12272
3ef381cdc47e [gaim-migrate @ 14574]
Mark Doliner <mark@kingant.net>
parents: 12252
diff changeset
93 GaimIdleUiOps *
3ef381cdc47e [gaim-migrate @ 14574]
Mark Doliner <mark@kingant.net>
parents: 12252
diff changeset
94 gaim_gtk_idle_get_ui_ops()
11907
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
95 {
12272
3ef381cdc47e [gaim-migrate @ 14574]
Mark Doliner <mark@kingant.net>
parents: 12252
diff changeset
96 return &ui_ops;
11907
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
97 }