X threading handling
This commit is contained in:
@@ -9,11 +9,13 @@ void glock(gui *_gui)
|
||||
{
|
||||
struct gui *g = _gui;
|
||||
if (pthread_mutex_lock(g->lock)) ERR("mutex error\n");
|
||||
xlock(g->x);
|
||||
}
|
||||
|
||||
void gunlock(gui *_gui)
|
||||
{
|
||||
struct gui *g = _gui;
|
||||
xunlock(g->x);
|
||||
if (pthread_mutex_unlock(g->lock)) ERR("mutex error\n");
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,8 @@ gui *gui_init(void)
|
||||
{
|
||||
struct gui *ret;
|
||||
|
||||
x_init_threading();
|
||||
|
||||
ret = calloc(1, sizeof(struct gui));
|
||||
if (ret == NULL) OOM;
|
||||
|
||||
|
||||
@@ -6,6 +6,23 @@
|
||||
#include <stdlib.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)
|
||||
{
|
||||
struct x_connection *x = _x;
|
||||
|
||||
@@ -6,6 +6,11 @@
|
||||
typedef void x_connection;
|
||||
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_window *x_create_window(x_connection *x, int width, int height,
|
||||
|
||||
Reference in New Issue
Block a user