Newer
Older
sdl_dac_default[i]=sdl.MapRGB(win->format, sdl_co[i].r, sdl_co[i].g, sdl_co[i].b);
}
free(pal);
}
break;
}
break;
}
case SDL_SYSWMEVENT: /* ToDo... This is where Copy/Paste needs doing */
#if !defined(NO_X) && defined(__unix__) && defined(SDL_VIDEO_DRIVER_X11)
if(sdl_x11available && sdl_using_x11) {
XEvent *e;
e=&ev.syswm.msg->event.xevent;
switch(e->type) {
case SelectionClear: {
XSelectionClearEvent *req;
req=&(e->xselectionclear);
sdl.mutexP(sdl_copybuf_mutex);
if(req->selection==CONSOLE_CLIPBOARD) {
FREE_AND_NULL(sdl_copybuf);
sdl.mutexV(sdl_copybuf_mutex);
break;
}
case SelectionNotify: {
int format=0;
unsigned long len, bytes_left, dummy;
Atom type;
XSelectionEvent *req;
SDL_SysWMinfo wmi;
SDL_VERSION(&(wmi.version));
sdl.GetWMInfo(&wmi);
req=&(e->xselection);
if(req->requestor!=wmi.info.x11.window)
break;
if(req->property) {
sdl_x11.XGetWindowProperty(wmi.info.x11.display, wmi.info.x11.window, req->property, 0, 0, 0, AnyPropertyType, &type, &format, &len, &bytes_left, (unsigned char **)(&sdl_pastebuf));
if(bytes_left > 0 && format==8)
sdl_x11.XGetWindowProperty(wmi.info.x11.display, wmi.info.x11.window, req->property,0,bytes_left,0,AnyPropertyType,&type,&format,&len,&dummy,(unsigned char **)&sdl_pastebuf);
else {
FREE_AND_NULL(sdl_pastebuf);
}
}
else {
FREE_AND_NULL(sdl_pastebuf);
}
/* Set paste buffer */
sdl.SemPost(sdl_pastebuf_set);
sdl.SemWait(sdl_pastebuf_copied);
if(sdl_pastebuf!=NULL) {
sdl_x11.XFree(sdl_pastebuf);
sdl_pastebuf=NULL;
}
break;
}
case SelectionRequest: {
XSelectionRequestEvent *req;
XEvent respond;
req=&(e->xselectionrequest);
sdl.mutexP(sdl_copybuf_mutex);
if(sdl_copybuf==NULL) {
respond.xselection.property=None;
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
}
else {
if(req->target==XA_STRING) {
sdl_x11.XChangeProperty(req->display, req->requestor, req->property, XA_STRING, 8, PropModeReplace, (unsigned char *)sdl_copybuf, strlen(sdl_copybuf));
respond.xselection.property=req->property;
}
else
respond.xselection.property=None;
}
sdl.mutexV(sdl_copybuf_mutex);
respond.xselection.type=SelectionNotify;
respond.xselection.display=req->display;
respond.xselection.requestor=req->requestor;
respond.xselection.selection=req->selection;
respond.xselection.target=req->target;
respond.xselection.time=req->time;
sdl_x11.XSendEvent(req->display,req->requestor,0,0,&respond);
break;
}
} /* switch */
} /* usingx11 */
#endif
/* Ignore this stuff */
case SDL_JOYAXISMOTION:
case SDL_JOYBALLMOTION:
case SDL_JOYHATMOTION:
case SDL_JOYBUTTONDOWN:
case SDL_JOYBUTTONUP:
default:
break;
}
}
}
}
if (upd_rects)
free(upd_rects);
int sdl_initciolib(int mode)
{
if(init_sdl_video()) {
fprintf(stderr,"SDL Video Initialization Failed\n");
return(-1);
sdl_key_pending=sdl.SDL_CreateSemaphore(0);
sdl_ufunc_ret=sdl.SDL_CreateSemaphore(0);
sdl_ufunc_rec=sdl.SDL_CreateSemaphore(0);
sdl_ufunc_mtx=sdl.SDL_CreateMutex();
newrect_mutex=sdl.SDL_CreateMutex();
win_mutex=sdl.SDL_CreateMutex();
sdl_keylock=sdl.SDL_CreateMutex();
bitmap_init_mutex=sdl.SDL_CreateMutex();
#if !defined(NO_X) && defined(__unix__)
sdl_pastebuf_set=sdl.SDL_CreateSemaphore(0);
sdl_pastebuf_copied=sdl.SDL_CreateSemaphore(0);
sdl_copybuf_mutex=sdl.SDL_CreateMutex();
#endif
run_sdl_drawing_thread(sdl_video_event_thread, exit_sdl_con);
return(sdl_init(mode));
}