From c03fe0d1dc69b0322853d4ca4862ece10d942f66 Mon Sep 17 00:00:00 2001 From: Bradley Smith Date: Wed, 12 Mar 2008 17:10:36 +0000 Subject: Make UI update in a loop, and thread out input. Signed-off-by: Bradley Smith --- lib/x11plugin.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/x11plugin.c b/lib/x11plugin.c index 0d9436b..b46b5cd 100644 --- a/lib/x11plugin.c +++ b/lib/x11plugin.c @@ -118,6 +118,8 @@ x11_plugin_constructor (GType type, x11 = X11_PLUGIN (object); + XInitThreads(); + if ((x11->dpy = XOpenDisplay ("")) == NULL) { g_printf ("Couldn't open the X Server Display!\n"); exit (1); /* Exit nicely isn't needed yet, and causes segfault */ @@ -147,7 +149,7 @@ x11_plugin_constructor (GType type, XSetWMHints (x11->dpy, x11->x_win, &wmhints); XSelectInput (x11->dpy, x11->x_win, - KeyPressMask | KeyReleaseMask | StructureNotifyMask + ExposureMask | KeyPressMask | KeyReleaseMask | StructureNotifyMask | FocusChangeMask); XMapWindow (x11->dpy, x11->x_win); @@ -597,12 +599,15 @@ inline void x11_plugin_update_status (X11Plugin *x11, glong score, glong shields) { + x11_update_status (x11, s, energy, score, shields); +} + +inline void x11_plugin_run(X11Plugin* x11) +{ XEvent ev; XClientMessageEvent* evt; - x11_update_status (x11, s, energy, score, shields); - - while (XPending (x11->dpy)) + while (TRUE) { XNextEvent (x11->dpy, &ev); @@ -625,6 +630,9 @@ inline void x11_plugin_update_status (X11Plugin *x11, exit(0); } break; + case Expose: + x11_plugin_draw(x11); + break; } } @@ -752,6 +760,7 @@ static void x11_plugin_interface_init (gpointer g_iface, gpointer iface_data) gint thing)) x11_plugin_add_thing; + klass->user_interface_run = (void(*)(UserInterface *ui)) x11_plugin_run; klass->user_interface_draw = (void (*) (UserInterface *ui)) x11_plugin_draw; klass->user_interface_update_status = (void (*) (UserInterface *ui, const gchar *s, -- cgit v1.1