void clippy_init(void) { SDL_SysWMinfo info; has_sys_clip = 0; memset(&info, 0, sizeof(info)); SDL_VERSION(&info.version); if (SDL_GetWMInfo(&info)) { #if defined(USE_X11) if (info.subsystem == SDL_SYSWM_X11) { SDL_Display = info.info.x11.display; SDL_Window = info.info.x11.window; lock_display = info.info.x11.lock_func; unlock_display = info.info.x11.unlock_func; SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE); SDL_SetEventFilter(_x11_clip_filter); has_sys_clip = 1; atom_sel = XInternAtom(SDL_Display, "SDL_SELECTION", False); atom_clip = XInternAtom(SDL_Display, "CLIPBOARD", False); orig_xlib_err = XSetErrorHandler(handle_xlib_err); } if (!lock_display) lock_display = __noop_v; if (!unlock_display) unlock_display = __noop_v; #elif defined(WIN32) has_sys_clip = 1; SDL_Window = info.window; #elif defined(__QNXNTO__) has_sys_clip = 1; inputgroup = PhInputGroup(NULL); #endif } }
void ph_UpdateMouse(_THIS) { PhCursorInfo_t phcursor; short abs_x; short abs_y; /* Lock the event thread, in multi-threading environments */ SDL_Lock_EventThread(); /* synchronizing photon mouse cursor position and SDL mouse position, if cursor appears over window. */ PtGetAbsPosition(window, &abs_x, &abs_y); PhQueryCursor(PhInputGroup(NULL), &phcursor); if (((phcursor.pos.x >= abs_x) && (phcursor.pos.x <= abs_x + this->screen->w)) && ((phcursor.pos.y >= abs_y) && (phcursor.pos.y <= abs_y + this->screen->h))) { SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); SDL_PrivateMouseMotion(0, 0, phcursor.pos.x-abs_x, phcursor.pos.y-abs_y); } else { SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); } /* Unlock the event thread, in multi-threading environments */ SDL_Unlock_EventThread(); }
void ph_WarpWMCursor(_THIS, Uint16 x, Uint16 y) { short abs_x, abs_y; SDL_Lock_EventThread(); PtGetAbsPosition( window, &abs_x, &abs_y ); PhMoveCursorAbs( PhInputGroup(NULL), x + abs_x, y + abs_y ); SDL_Unlock_EventThread(); }
void clip_mch_set_selection(VimClipboard *cbd) { int type; long_u len; char_u *text_clip, vim_clip[2], *str = NULL; PhClipHeader clip_header[2]; /* Prevent recursion from clip_get_selection() */ if (cbd->owned == TRUE) return; cbd->owned = TRUE; clip_get_selection(cbd); cbd->owned = FALSE; type = clip_convert_selection(&str, &len, cbd); if (type >= 0) { text_clip = lalloc(len + 1, TRUE); /* Normal text */ if (text_clip && vim_clip) { memset(clip_header, 0, sizeof(clip_header)); STRNCPY(clip_header[0].type, CLIP_TYPE_VIM, 8); clip_header[0].length = sizeof(vim_clip); clip_header[0].data = vim_clip; STRNCPY(clip_header[1].type, CLIP_TYPE_TEXT, 8); clip_header[1].length = len + 1; clip_header[1].data = text_clip; switch(type) { default: /* fallthrough to MLINE */ case MLINE: *vim_clip = 'L'; break; case MCHAR: *vim_clip = 'C'; break; case MBLOCK: *vim_clip = 'B'; break; } vim_strncpy(text_clip, str, len); vim_clip[ 1 ] = NUL; PhClipboardCopy(PhInputGroup(NULL), 2, clip_header); } vim_free(text_clip); } vim_free(str); }
int lost_scrap(void) { int retval = 0; #if defined(WZ_WS_X11) Lock_Display(); retval = ( XGetSelectionOwner(SDL_Display, XA_PRIMARY) != SDL_Window ); Unlock_Display(); #elif defined(WZ_WS_WIN) retval = ( GetClipboardOwner() != SDL_Window ); #elif defined(WZ_WS_QNX) retval = ( PhInputGroup(NULL) != InputGroup ); #endif /* scrap type */ return(retval); }
int init_scrap(void) { SDL_SysWMinfo info; int retval; /* Grab the window manager specific information */ retval = -1; SDL_SetError("SDL is not running on known window manager"); SDL_VERSION(&info.version); if ( SDL_GetWMInfo(&info) ) { /* Save the information for later use */ #if defined(WZ_WS_X11) /* * */ if ( info.subsystem == SDL_SYSWM_X11 ) { SDL_Display = info.info.x11.display; SDL_Window = info.info.x11.window; Lock_Display = info.info.x11.lock_func; Unlock_Display = info.info.x11.unlock_func; /* Enable the special window hook events */ SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE); SDL_SetEventFilter(clipboard_filter); retval = 0; } else { SDL_SetError("SDL is not running on X11"); } #elif defined(WZ_WS_WIN) /* * */ SDL_Window = info.window; retval = 0; #elif defined(WZ_WS_QNX) /* * */ InputGroup=PhInputGroup(NULL); retval = 0; #endif /* scrap type */ } return(retval); }
void clip_mch_request_selection(VimClipboard *cbd) { int type = MLINE, clip_length = 0, is_type_set = FALSE; void *cbdata; PhClipHeader *clip_header; char_u *clip_text = NULL; cbdata = PhClipboardPasteStart(PhInputGroup(NULL)); if (cbdata != NULL) { /* Look for the vim specific clip first */ clip_header = PhClipboardPasteType(cbdata, CLIP_TYPE_VIM); if (clip_header != NULL && clip_header->data != NULL) { switch(*(char *) clip_header->data) { default: /* fallthrough to line type */ case 'L': type = MLINE; break; case 'C': type = MCHAR; break; case 'B': type = MBLOCK; break; } is_type_set = TRUE; } /* Try for just normal text */ clip_header = PhClipboardPasteType(cbdata, CLIP_TYPE_TEXT); if (clip_header != NULL) { clip_text = clip_header->data; clip_length = clip_header->length - 1; if (clip_text != NULL && is_type_set == FALSE) type = MAUTO; } if ((clip_text != NULL) && (clip_length > 0)) { clip_yank_selection(type, clip_text, clip_length, cbd); } PhClipboardPasteFinish(cbdata); } }
SDL_GrabMode ph_GrabInputNoLock(_THIS, SDL_GrabMode mode) { short abs_x, abs_y; if( mode == SDL_GRAB_OFF ) { PtSetResource(window, Pt_ARG_WINDOW_STATE, Pt_FALSE, Ph_WM_STATE_ISALTKEY); } else { PtSetResource(window, Pt_ARG_WINDOW_STATE, Pt_TRUE, Ph_WM_STATE_ISALTKEY); PtGetAbsPosition(window, &abs_x, &abs_y); PhMoveCursorAbs(PhInputGroup(NULL), abs_x + SDL_VideoSurface->w/2, abs_y + SDL_VideoSurface->h/2); } SDL_Unlock_EventThread(); return(mode); }
/* qnx_mouse_position: * Sets the position of the mickey-mode mouse. */ static void qnx_mouse_position(int x, int y) { short mx = 0, my = 0; pthread_mutex_lock(&qnx_event_mutex); _mouse_x = x; _mouse_y = y; if (ph_gfx_mode == PH_GFX_WINDOW) PtGetAbsPosition(ph_window, &mx, &my); PhMoveCursorAbs(PhInputGroup(NULL), x + mx, y + my); mymickey_x = mymickey_y = 0; qnx_mouse_warped = TRUE; pthread_mutex_unlock(&qnx_event_mutex); }
static int ph_WarpedMotion(_THIS, PhEvent_t *winEvent) { PhRect_t *rect = PhGetRects( winEvent ); int centre_x, centre_y; int dx, dy; short abs_x, abs_y; int posted; centre_x = SDL_VideoSurface->w / 2; centre_y = SDL_VideoSurface->h / 2; dx = rect->ul.x - centre_x; dy = rect->ul.y - centre_y; posted = SDL_PrivateMouseMotion( 0, 1, dx, dy ); /* Move mouse cursor to middle of the window */ PtGetAbsPosition( window, &abs_x, &abs_y ); PhMoveCursorAbs(PhInputGroup(NULL), abs_x + centre_x, abs_y + centre_y); return (posted); }