Commit 88bef83d authored by Cedric Roux's avatar Cedric Roux

X threading handling

parent 3bba991e
...@@ -9,11 +9,13 @@ void glock(gui *_gui) ...@@ -9,11 +9,13 @@ void glock(gui *_gui)
{ {
struct gui *g = _gui; struct gui *g = _gui;
if (pthread_mutex_lock(g->lock)) ERR("mutex error\n"); if (pthread_mutex_lock(g->lock)) ERR("mutex error\n");
xlock(g->x);
} }
void gunlock(gui *_gui) void gunlock(gui *_gui)
{ {
struct gui *g = _gui; struct gui *g = _gui;
xunlock(g->x);
if (pthread_mutex_unlock(g->lock)) ERR("mutex error\n"); if (pthread_mutex_unlock(g->lock)) ERR("mutex error\n");
} }
......
...@@ -12,6 +12,8 @@ gui *gui_init(void) ...@@ -12,6 +12,8 @@ gui *gui_init(void)
{ {
struct gui *ret; struct gui *ret;
x_init_threading();
ret = calloc(1, sizeof(struct gui)); ret = calloc(1, sizeof(struct gui));
if (ret == NULL) OOM; if (ret == NULL) OOM;
......
...@@ -6,6 +6,23 @@ ...@@ -6,6 +6,23 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
void x_init_threading(void)
{
if (XInitThreads() == False) abort();
}
void xlock(x_connection *_x)
{
struct x_connection *x = _x;
XLockDisplay(x->d);
}
void xunlock(x_connection *_x)
{
struct x_connection *x = _x;
XUnlockDisplay(x->d);
}
int x_connection_fd(x_connection *_x) int x_connection_fd(x_connection *_x)
{ {
struct x_connection *x = _x; struct x_connection *x = _x;
......
...@@ -6,6 +6,11 @@ ...@@ -6,6 +6,11 @@
typedef void x_connection; typedef void x_connection;
typedef void x_window; typedef void x_window;
void x_init_threading(void);
void xlock(x_connection *x);
void xunlock(x_connection *x);
x_connection *x_open(void); x_connection *x_open(void);
x_window *x_create_window(x_connection *x, int width, int height, x_window *x_create_window(x_connection *x, int width, int height,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment