From 6615a51a3a77434d993145befdc0a98f60d3297b Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Mon, 18 Jul 2005 14:35:32 +0000 Subject: [PATCH] no more need of GTK+ in idle.c --- src/common/idle.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/common/idle.c b/src/common/idle.c index a5c61bf05..92cf801f9 100644 --- a/src/common/idle.c +++ b/src/common/idle.c @@ -20,8 +20,6 @@ #include #include #include - #include - #include #else #define _WIN32_WINNT 0x0500 #include @@ -34,13 +32,15 @@ typedef BOOL (WINAPI *GETLASTINPUTINFO)(LASTINPUTINFO *); static HMODULE g_user32 = NULL; static GETLASTINPUTINFO g_GetLastInputInfo = NULL; +#else + Display *display; #endif static PyObject * idle_init(PyObject *self, PyObject *args) { #ifndef _WIN32 - gtk_init (NULL, NULL); + display = XOpenDisplay(NULL); #else g_user32 = LoadLibrary("user32.dll"); if (g_user32) { @@ -56,17 +56,18 @@ static PyObject * idle_getIdleSec(PyObject *self, PyObject *args) #ifndef _WIN32 static XScreenSaverInfo *mit_info = NULL; int idle_time, event_base, error_base; + Display *dplay; #else int idle_time = 0; #endif #ifndef _WIN32 - gtk_init (NULL, NULL); - if (XScreenSaverQueryExtension(GDK_DISPLAY(), &event_base, &error_base)) + dplay = XOpenDisplay(NULL); + if (!XScreenSaverQueryExtension(dplay, &event_base, &error_base)) { if (mit_info == NULL) mit_info = XScreenSaverAllocInfo(); - XScreenSaverQueryInfo(GDK_DISPLAY(), GDK_ROOT_WINDOW(), mit_info); + XScreenSaverQueryInfo(dplay, RootWindow(dplay, 0), mit_info); idle_time = (mit_info->idle) / 1000; } else @@ -88,7 +89,7 @@ static PyObject * idle_getIdleSec(PyObject *self, PyObject *args) static PyObject * idle_close(PyObject *self, PyObject *args) { #ifndef _WIN32 - gtk_main_quit (); + XCloseDisplay(display); #else if (g_user32 != NULL) FreeLibrary(g_user32); @@ -99,9 +100,9 @@ static PyObject * idle_close(PyObject *self, PyObject *args) static PyMethodDef idleMethods[] = { - {"init", idle_init, METH_VARARGS, "init gtk"}, + {"init", idle_init, METH_VARARGS, "init idle"}, {"getIdleSec", idle_getIdleSec, METH_VARARGS, "Give the idle time in secondes"}, - {"close", idle_close, METH_VARARGS, "close gtk"}, + {"close", idle_close, METH_VARARGS, "close idle"}, {NULL, NULL, 0, NULL} };