/** @fn static void vehicle_file_enable_watch(struct vehicle_priv *priv) ***************************************************************************** * @b Description: Enable watch ***************************************************************************** * @param priv : pointer on the private data of the plugin ***************************************************************************** **/ static void vehicle_file_enable_watch(struct vehicle_priv *priv) { dbg(1, "enter\n"); #ifdef _WIN32 // add an event : don't use glib timers and g_timeout_add if (priv->timeout_callback != NULL) priv->timeout = event_add_timeout(500, 1, priv->timeout_callback); else dbg(1, "error : watch not enabled : priv->timeout_callback is null\n"); #else if (! priv->watch) priv->watch = event_add_watch((void *)priv->fd, event_watch_cond_read, priv->cb); #endif }
struct graphics_opengl_window_system * graphics_opengl_x11_new(void *displayname, int w, int h, int depth, struct graphics_opengl_window_system_methods **methods) { struct graphics_opengl_window_system *ret=g_new0(struct graphics_opengl_window_system, 1); XSetWindowAttributes attributes; unsigned long valuemask; ret->cb=callback_new_1(callback_cast(graphics_opengl_x11_watch), ret); if (!event_request_system("glib", "graphics_opengl_x11_new")) goto error; *methods=&graphics_opengl_x11_methods; ret->display=XOpenDisplay(displayname); if (!ret->display) { dbg(lvl_error,"failed to open display\n"); goto error; } ret->watch=event_add_watch(ConnectionNumber(ret->display), event_watch_cond_read, ret->cb); ret->screen=XDefaultScreen(ret->display); ret->root_window=RootWindow(ret->display, ret->screen); if (!XMatchVisualInfo(ret->display, ret->screen, depth, TrueColor, &ret->visual)) { dbg(lvl_error,"failed to find visual\n"); goto error; } ret->colormap=XCreateColormap(ret->display, ret->root_window, ret->visual.visual, AllocNone); valuemask = /* CWBackPixel | */ CWBorderPixel | CWEventMask | CWColormap ; // | CWBackingStore; attributes.colormap = ret->colormap; attributes.border_pixel = 0; attributes.event_mask = StructureNotifyMask | ExposureMask | ButtonPressMask | ButtonMotionMask | ButtonReleaseMask | KeyPressMask | KeyReleaseMask; attributes.backing_store = Always; ret->window=XCreateWindow(ret->display, RootWindow(ret->display, ret->screen), 0, 0, w, h, 0, ret->visual.depth, InputOutput, ret->visual.visual, valuemask, &attributes); XMapWindow(ret->display, ret->window); XFlush(ret->display); graphics_opengl_x11_watch(ret); return ret; error: graphics_opengl_x11_destroy(ret); return NULL; }