no more need of GTK+ in idle.c
This commit is contained in:
parent
aed285fce3
commit
6615a51a3a
|
@ -20,8 +20,6 @@
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
#include <X11/extensions/scrnsaver.h>
|
#include <X11/extensions/scrnsaver.h>
|
||||||
#include <gdk/gdkx.h>
|
|
||||||
#include <gtk/gtk.h>
|
|
||||||
#else
|
#else
|
||||||
#define _WIN32_WINNT 0x0500
|
#define _WIN32_WINNT 0x0500
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
@ -34,13 +32,15 @@
|
||||||
typedef BOOL (WINAPI *GETLASTINPUTINFO)(LASTINPUTINFO *);
|
typedef BOOL (WINAPI *GETLASTINPUTINFO)(LASTINPUTINFO *);
|
||||||
static HMODULE g_user32 = NULL;
|
static HMODULE g_user32 = NULL;
|
||||||
static GETLASTINPUTINFO g_GetLastInputInfo = NULL;
|
static GETLASTINPUTINFO g_GetLastInputInfo = NULL;
|
||||||
|
#else
|
||||||
|
Display *display;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static PyObject * idle_init(PyObject *self, PyObject *args)
|
static PyObject * idle_init(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
gtk_init (NULL, NULL);
|
display = XOpenDisplay(NULL);
|
||||||
#else
|
#else
|
||||||
g_user32 = LoadLibrary("user32.dll");
|
g_user32 = LoadLibrary("user32.dll");
|
||||||
if (g_user32) {
|
if (g_user32) {
|
||||||
|
@ -56,17 +56,18 @@ static PyObject * idle_getIdleSec(PyObject *self, PyObject *args)
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
static XScreenSaverInfo *mit_info = NULL;
|
static XScreenSaverInfo *mit_info = NULL;
|
||||||
int idle_time, event_base, error_base;
|
int idle_time, event_base, error_base;
|
||||||
|
Display *dplay;
|
||||||
#else
|
#else
|
||||||
int idle_time = 0;
|
int idle_time = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
gtk_init (NULL, NULL);
|
dplay = XOpenDisplay(NULL);
|
||||||
if (XScreenSaverQueryExtension(GDK_DISPLAY(), &event_base, &error_base))
|
if (!XScreenSaverQueryExtension(dplay, &event_base, &error_base))
|
||||||
{
|
{
|
||||||
if (mit_info == NULL)
|
if (mit_info == NULL)
|
||||||
mit_info = XScreenSaverAllocInfo();
|
mit_info = XScreenSaverAllocInfo();
|
||||||
XScreenSaverQueryInfo(GDK_DISPLAY(), GDK_ROOT_WINDOW(), mit_info);
|
XScreenSaverQueryInfo(dplay, RootWindow(dplay, 0), mit_info);
|
||||||
idle_time = (mit_info->idle) / 1000;
|
idle_time = (mit_info->idle) / 1000;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -88,7 +89,7 @@ static PyObject * idle_getIdleSec(PyObject *self, PyObject *args)
|
||||||
static PyObject * idle_close(PyObject *self, PyObject *args)
|
static PyObject * idle_close(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
gtk_main_quit ();
|
XCloseDisplay(display);
|
||||||
#else
|
#else
|
||||||
if (g_user32 != NULL)
|
if (g_user32 != NULL)
|
||||||
FreeLibrary(g_user32);
|
FreeLibrary(g_user32);
|
||||||
|
@ -99,9 +100,9 @@ static PyObject * idle_close(PyObject *self, PyObject *args)
|
||||||
|
|
||||||
static PyMethodDef idleMethods[] =
|
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"},
|
{"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}
|
{NULL, NULL, 0, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue