Пример #1
0
Файл: x11.c Проект: 7max/glc
int __x11_XMaskEvent(Display *display, long event_mask, XEvent *event_return)
{
	INIT_GLC
	int ret = x11.XMaskEvent(display, event_mask, event_return);
	x11_event(display, event_return);
	return ret;
}
Пример #2
0
Файл: x11.c Проект: 7max/glc
int __x11_XPeekIfEvent(Display *display, XEvent *event_return, Bool (*predicate)(), XPointer arg)
{
	INIT_GLC
	int ret = x11.XPeekIfEvent(display, event_return, predicate, arg);
	x11_event(display, event_return);
	return ret;
}
Пример #3
0
Файл: x11.c Проект: 7max/glc
int __x11_XWindowEvent(Display *display, Window w, long event_mask, XEvent *event_return)
{
	INIT_GLC
	int ret = x11.XWindowEvent(display, w, event_mask, event_return);
	x11_event(display, event_return);
	return ret;
}
Пример #4
0
Файл: x11.c Проект: 7max/glc
int __x11_XPeekEvent(Display *display, XEvent *event_return)
{
	INIT_GLC
	int ret = x11.XPeekEvent(display, event_return);
	x11_event(display, event_return);
	return ret;
}
Пример #5
0
Файл: x11.c Проект: 7max/glc
Bool __x11_XCheckIfEvent(Display *display, XEvent *event_return, Bool (*predicate)(), XPointer arg)
{
	INIT_GLC
	Bool ret = x11.XCheckIfEvent(display, event_return, predicate, arg);
	if (ret)
		x11_event(display, event_return);
	return ret;
}
Пример #6
0
Файл: x11.c Проект: 7max/glc
Bool __x11_XCheckTypedWindowEvent(Display *display, Window w, int event_type, XEvent *event_return)
{
	INIT_GLC
	Bool ret = x11.XCheckTypedWindowEvent(display, w, event_type, event_return);
	if (ret)
		x11_event(display, event_return);
	return ret;
}
Пример #7
0
Файл: x11.c Проект: 7max/glc
Bool __x11_XCheckMaskEvent(Display *display, long event_mask, XEvent *event_return)
{
	INIT_GLC
	Bool ret = x11.XCheckMaskEvent(display, event_mask, event_return);
	if (ret)
		x11_event(display, event_return);
	return ret;
}
Пример #8
0
void x11_event_thread(void *args)
{
	int x;
	int high_fd;
	fd_set fdset;
	XEvent ev;
	static struct timeval tv;

	SetThreadName("X11 Events");
	if(video_init()) {
		sem_post(&init_complete);
		return;
	}
	x11_initialized=1;
	sem_post(&init_complete);

	if(local_pipe[0] > xfd)
		high_fd=local_pipe[0];
	else
		high_fd=xfd;

	for (;;) {
		tv.tv_sec=0;
		tv.tv_usec=54925; /* was 54925 (was also 10) */ 

		/*
		 * Handle any events just sitting around...
		 */
		while (QLength(dpy) > 0) {
			x11.XNextEvent(dpy, &ev);
			x11_event(&ev);
		}

		FD_ZERO(&fdset);
		FD_SET(xfd, &fdset);
		FD_SET(local_pipe[0], &fdset);

		x = select(high_fd+1, &fdset, 0, 0, &tv);

		switch (x) {
			case -1:
				/*
				* Errno might be wrong, so we just select again.
				* This could cause a problem is something really
				* was wrong with select....
				*/

				/* perror("select"); */
				break;
			case 0:
				/* Timeout */
				break;
			default:
				if (FD_ISSET(xfd, &fdset)) {
					x11.XNextEvent(dpy, &ev);
					x11_event(&ev);
				}
				while(FD_ISSET(local_pipe[0], &fdset)) {
					struct x11_local_event lev;

					read(local_pipe[0], &lev, sizeof(lev));
					switch(lev.type) {
						case X11_LOCAL_SETMODE:
							init_mode(lev.data.mode);
							break;
						case X11_LOCAL_SETNAME:
							x11.XSetIconName(dpy, win, lev.data.name);
							x11.XFlush(dpy);
							break;
						case X11_LOCAL_SETTITLE:
							x11.XStoreName(dpy, win, lev.data.title);
							x11.XFlush(dpy);
							break;
						case X11_LOCAL_COPY:
							x11.XSetSelectionOwner(dpy, CONSOLE_CLIPBOARD, win, CurrentTime);
							break;
						case X11_LOCAL_PASTE: 
							{
								Window sowner=None;

								sowner=x11.XGetSelectionOwner(dpy, CONSOLE_CLIPBOARD);
								if(sowner==win) {
									/* Get your own primary selection */
									if(copybuf==NULL)
										pastebuf=NULL;
									else
										pastebuf=strdup(copybuf);
									/* Set paste buffer */
									sem_post(&pastebuf_set);
									sem_wait(&pastebuf_used);
									FREE_AND_NULL(pastebuf);
								}
								else if(sowner!=None) {
									x11.XConvertSelection(dpy, CONSOLE_CLIPBOARD, XA_STRING, XA_STRING, win, CurrentTime);
								}
								else {
									/* Set paste buffer */
									pastebuf=NULL;
									sem_post(&pastebuf_set);
									sem_wait(&pastebuf_used);
								}
							}
							break;
						case X11_LOCAL_DRAWRECT:
							local_draw_rect(&lev.data.rect);
							break;
						case X11_LOCAL_FLUSH:
							x11.XFlush(dpy);
							break;
						case X11_LOCAL_BEEP:
							x11.XBell(dpy, 100);
							break;
					}
					tv.tv_sec=0;
					tv.tv_usec=0;

					FD_ZERO(&fdset);
					FD_SET(local_pipe[0], &fdset);

					if(select(local_pipe[0]+1, &fdset, 0, 0, &tv)!=1)
						FD_ZERO(&fdset);
				}
		}
	}
}