Change X11 event loop initialization

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3991 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2011-09-28 19:09:38 +00:00
parent 07acb131f0
commit 8a07562c87
4 changed files with 34 additions and 31 deletions

View File

@ -88,15 +88,22 @@ SRCS = $(ASRCS) $(CSRCS) $(HOSTSRCS)
OBJS = $(AOBJS) $(COBJS) $(HOSTOBJS) OBJS = $(AOBJS) $(COBJS) $(HOSTOBJS)
LDFLAGS = $(ARCHSCRIPT) LDFLAGS = $(ARCHSCRIPT)
# Determine which standard libraries will need to be linked in
ifeq ($(CONFIG_SIM_X11FB),y) ifeq ($(CONFIG_SIM_X11FB),y)
STDLIBS = -lX11 -lXext -lc STDLIBS += -lX11 -lXext
else ifeq ($(CONFIG_SIM_TOUCHSCREEN),y)
STDLIBS = -lc STDLIBS += -lpthread
endif endif
endif
ifeq ($(CONFIG_FS_FAT),y) ifeq ($(CONFIG_FS_FAT),y)
STDLIBS += -lz STDLIBS += -lz
endif endif
STDLIBS += -lc
LINKOBJS = up_head$(OBJEXT) LINKOBJS = up_head$(OBJEXT)
LINKLIBS = LINKLIBS =
LDPATHS = $(addprefix -L$(TOPDIR)/,$(dir $(LINKLIBS))) LDPATHS = $(addprefix -L$(TOPDIR)/,$(dir $(LINKLIBS)))

View File

@ -63,18 +63,6 @@
# endif # endif
#endif #endif
#ifdef CONFIG_SIM_TOUCHSCREEN
# ifndef CONFIG_SIM_EVLOOPPRIORITY
# define CONFIG_SIM_EVLOOPPRIORITY 50
# endif
# ifndef CONFIG_SIM_EVLOOPSTACKSIZE
# define CONFIG_SIM_EVLOOPSTACKSIZE 4096
# endif
#else
# undef CONFIG_SIM_EVLOOPPRIORITY
# undef CONFIG_SIM_EVLOOPSTACKSIZE
#endif
/* Context Switching Definitions ******************************************/ /* Context Switching Definitions ******************************************/
/* Storage order: %ebx, $esi, %edi, %ebp, sp, and return PC */ /* Storage order: %ebx, $esi, %edi, %ebp, sp, and return PC */
@ -174,7 +162,7 @@ extern int up_x11cmap(unsigned short first, unsigned short len,
#ifdef CONFIG_SIM_X11FB #ifdef CONFIG_SIM_X11FB
#ifdef CONFIG_SIM_TOUCHSCREEN #ifdef CONFIG_SIM_TOUCHSCREEN
extern int up_x11eventloop(int argc, char *argv[]); extern int up_x11eventloop(void);
#endif #endif
#endif #endif

View File

@ -58,7 +58,6 @@
#include <nuttx/input/touchscreen.h> #include <nuttx/input/touchscreen.h>
#include "os_internal.h"
#include "up_internal.h" #include "up_internal.h"
/**************************************************************************** /****************************************************************************
@ -107,7 +106,6 @@ struct up_dev_s
bool penchange; /* An unreported event is buffered */ bool penchange; /* An unreported event is buffered */
sem_t devsem; /* Manages exclusive access to this structure */ sem_t devsem; /* Manages exclusive access to this structure */
sem_t waitsem; /* Used to wait for the availability of data */ sem_t waitsem; /* Used to wait for the availability of data */
pid_t eventloop; /* PID of the eventloop */
struct up_sample_s sample; /* Last sampled touch point data */ struct up_sample_s sample; /* Last sampled touch point data */
@ -631,7 +629,7 @@ int up_simtouchscreen(int minor)
/* Debug-only sanity checks */ /* Debug-only sanity checks */
DEBUGASSERT(minor >= 0 && minor < 100 && priv->eventloop == 0); DEBUGASSERT(minor >= 0 && minor < 100);
/* Initialize the touchscreen device driver instance */ /* Initialize the touchscreen device driver instance */
@ -641,15 +639,12 @@ int up_simtouchscreen(int minor)
/* Start the X11 event loop */ /* Start the X11 event loop */
ret = KERNEL_THREAD("evloop", CONFIG_SIM_EVLOOPPRIORITY, ret = up_x11eventloop();
CONFIG_SIM_EVLOOPSTACKSIZE,
(main_t)up_x11eventloop, (const char **)NULL);
if (ret < 0) if (ret < 0)
{ {
idbg("Failed to start event loop: %d\n", ret); idbg("Failed to start event loop: %d\n", ret);
goto errout_with_priv; goto errout_with_priv;
} }
priv->eventloop = ret;
/* Register the device as an input device */ /* Register the device as an input device */

View File

@ -38,6 +38,8 @@
****************************************************************************/ ****************************************************************************/
#include <stdio.h> #include <stdio.h>
#include <pthread.h>
#include <X11/Xlib.h> #include <X11/Xlib.h>
/**************************************************************************** /****************************************************************************
@ -68,6 +70,8 @@ extern int up_tcleave(int x, int y, int buttons);
extern Display *g_display; extern Display *g_display;
extern Window g_window; extern Window g_window;
pthread_t g_eventloop;
/**************************************************************************** /****************************************************************************
* Private Variables * Private Variables
****************************************************************************/ ****************************************************************************/
@ -108,15 +112,11 @@ static int up_buttonmap(int state)
return ret; return ret;
} }
/****************************************************************************
* Public Functions
***************************************************************************/
/**************************************************************************** /****************************************************************************
* Name: up_x11eventloop * Name: up_x11eventloop
***************************************************************************/ ***************************************************************************/
int up_x11eventloop(int argc, char *argv[]) static void *up_x11eventthread(void *arg)
{ {
XEvent event; XEvent event;
int ret; int ret;
@ -164,5 +164,18 @@ int up_x11eventloop(int argc, char *argv[])
break; break;
} }
} }
return 0; return NULL;
} }
/****************************************************************************
* Name: up_x11eventloop
***************************************************************************/
int up_x11eventloop(void)
{
/* Start the X11 event loop */
return pthread_create(&g_eventloop, 0, up_x11eventthread, 0);
}