int X11_VideoInit(_THIS) { SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; /* Get the window class name, usually the name of the application */ data->classname = get_classname(); /* Get the process PID to be associated to the window */ data->pid = getpid(); /* Open a connection to the X input manager */ #ifdef X_HAVE_UTF8_STRING if (SDL_X11_HAVE_UTF8) { data->im = XOpenIM(data->display, NULL, data->classname, data->classname); } #endif /* Look up some useful Atoms */ #define GET_ATOM(X) data->X = XInternAtom(data->display, #X, False) GET_ATOM(WM_PROTOCOLS); GET_ATOM(WM_DELETE_WINDOW); GET_ATOM(_NET_WM_STATE); GET_ATOM(_NET_WM_STATE_HIDDEN); GET_ATOM(_NET_WM_STATE_FOCUSED); GET_ATOM(_NET_WM_STATE_MAXIMIZED_VERT); GET_ATOM(_NET_WM_STATE_MAXIMIZED_HORZ); GET_ATOM(_NET_WM_STATE_FULLSCREEN); GET_ATOM(_NET_WM_ALLOWED_ACTIONS); GET_ATOM(_NET_WM_ACTION_FULLSCREEN); GET_ATOM(_NET_WM_NAME); GET_ATOM(_NET_WM_ICON_NAME); GET_ATOM(_NET_WM_ICON); GET_ATOM(_NET_WM_PING); GET_ATOM(UTF8_STRING); /* Detect the window manager */ X11_CheckWindowManager(_this); if (X11_InitModes(_this) < 0) { return -1; } X11_InitXinput2(_this); if (X11_InitKeyboard(_this) != 0) { return -1; } X11_InitMouse(_this); X11_InitTouch(_this); #if SDL_USE_LIBDBUS X11_InitDBus(_this); #endif return 0; }
bool f_is_subclass_of(CVarRef class_or_object, CStrRef class_name) { const ClassInfo *classInfo = ClassInfo::FindClass(get_classname(class_or_object)); if (classInfo) { return classInfo->derivesFrom(class_name, false); } return false; }
bool f_method_exists(CVarRef class_or_object, CStrRef method_name) { const ClassInfo *classInfo = ClassInfo::FindClass(get_classname(class_or_object)); if (classInfo) { return classInfo->hasMethod(method_name); } return false; }
Array f_get_class_methods(CVarRef class_or_object) { ClassInfo::MethodVec methods; ClassInfo::GetClassMethods(methods, get_classname(class_or_object)); Array ret = Array::Create(); for (unsigned int i = 0; i < methods.size(); i++) { ret.set(methods[i]->name, true); } return ret.keys(); }
bool f_property_exists(CVarRef class_or_object, CStrRef property) { const ClassInfo *classInfo = ClassInfo::FindClass(get_classname(class_or_object)); while (classInfo) { if (classInfo->hasProperty(property)) { return true; } else { classInfo = ClassInfo::FindClass(classInfo->getParentClass()); } } return false; }
Array f_get_class_methods(CVarRef class_or_object) { ClassInfo::MethodVec methods; CStrRef class_name = get_classname(class_or_object); ClassInfo::GetClassMethods(methods, class_name); CStrRef klass = FrameInjection::GetClassName(true); bool allowPrivate = !klass.empty() && klass->isame(class_name.get()); Array ret = Array::Create(); for (unsigned int i = 0; i < methods.size(); i++) { if ((methods[i]->attribute & ClassInfo::IsPublic) || allowPrivate) { ret.set(methods[i]->name, true); } } return ret.keys(); }
Array f_get_class_methods(CVarRef class_or_object) { ClassInfo::MethodVec methods; const String &class_name = get_classname(class_or_object); ClassInfo::GetClassMethods(methods, class_name); const char *klass = FrameInjection::GetClassName(true); bool allowPrivate = klass && *klass && !strcasecmp(class_name->data(), klass); Array ret = Array::Create(); for (unsigned int i = 0; i < methods.size(); i++) { if ((methods[i]->attribute & ClassInfo::IsPublic) || allowPrivate) { ret.set(methods[i]->name, true); } } return ret.keys(); }
bool f_property_exists(CVarRef class_or_object, CStrRef property) { if (class_or_object.isObject()) { // Call o_exists for objects, to include dynamic properties. return class_or_object.toObject()->o_propExists(property); } const ClassInfo *classInfo = ClassInfo::FindClass(get_classname(class_or_object)); while (classInfo) { if (classInfo->hasProperty(property)) { return true; } else { classInfo = classInfo->getParentClassInfo(); } } return false; }
int X11_VideoInit(_THIS) { SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; /* Get the window class name, usually the name of the application */ data->classname = get_classname(); /* Open a connection to the X input manager */ #ifdef X_HAVE_UTF8_STRING if (SDL_X11_HAVE_UTF8) { data->im = XOpenIM(data->display, NULL, data->classname, data->classname); } #endif /* Look up some useful Atoms */ #define GET_ATOM(X) data->X = XInternAtom(data->display, #X, False) GET_ATOM(WM_DELETE_WINDOW); GET_ATOM(_NET_WM_STATE); GET_ATOM(_NET_WM_STATE_HIDDEN); GET_ATOM(_NET_WM_STATE_MAXIMIZED_VERT); GET_ATOM(_NET_WM_STATE_MAXIMIZED_HORZ); GET_ATOM(_NET_WM_STATE_FULLSCREEN); GET_ATOM(_NET_WM_NAME); GET_ATOM(_NET_WM_ICON_NAME); GET_ATOM(_NET_WM_ICON); GET_ATOM(UTF8_STRING); /* Detect the window manager */ X11_CheckWindowManager(_this); if (X11_InitModes(_this) < 0) { return -1; } #if SDL_VIDEO_RENDER_X11 X11_AddRenderDriver(_this); #endif if (X11_InitKeyboard(_this) != 0) { return -1; } X11_InitMouse(_this); return 0; }
int Wayland_VideoInit(_THIS) { SDL_VideoData *data = SDL_malloc(sizeof *data); if (data == NULL) return SDL_OutOfMemory(); memset(data, 0, sizeof *data); _this->driverdata = data; data->xkb_context = WAYLAND_xkb_context_new(0); if (!data->xkb_context) { return SDL_SetError("Failed to create XKB context"); } data->display = WAYLAND_wl_display_connect(NULL); if (data->display == NULL) { return SDL_SetError("Failed to connect to a Wayland display"); } data->registry = wl_display_get_registry(data->display); if (data->registry == NULL) { return SDL_SetError("Failed to get the Wayland registry"); } wl_registry_add_listener(data->registry, ®istry_listener, data); // First roundtrip to receive all registry objects. WAYLAND_wl_display_roundtrip(data->display); // Second roundtrip to receive all output events. WAYLAND_wl_display_roundtrip(data->display); Wayland_InitMouse(); /* Get the surface class name, usually the name of the application */ data->classname = get_classname(); WAYLAND_wl_display_flush(data->display); return 0; }
SEXP extract_transcripts(SEXP classname, SEXP x, SEXP exonStarts, SEXP exonEnds, SEXP strand, SEXP decreasing_rank_on_minus_strand, SEXP lkup) { cachedCharSeq X, Y; SEXP ans_width, ans, starts, ends; cachedXVectorList cached_ans; int decreasing_rank_on_minus_strand0, ans_length, i, on_minus_strand; X = cache_XRaw(x); decreasing_rank_on_minus_strand0 = LOGICAL(decreasing_rank_on_minus_strand)[0]; PROTECT(ans_width = mk_transcript_widths(exonStarts, exonEnds, X.length)); PROTECT(ans = alloc_XRawList(CHAR(STRING_ELT(classname, 0)), get_classname(x), ans_width)); cached_ans = cache_XVectorList(ans); ans_length = get_cachedXVectorList_length(&cached_ans); for (i = 0; i < ans_length; i++) { starts = VECTOR_ELT(exonStarts, i); if (starts == R_NilValue || LENGTH(starts) == 0) continue; ends = VECTOR_ELT(exonEnds, i); on_minus_strand = strand_is_minus(strand, i); if (on_minus_strand == -1) { UNPROTECT(2); error("%s", errmsg_buf); } Y = get_cachedXRawList_elt(&cached_ans, i); /* Y.seq is a const char * so we need to cast it to char * before we can write to it */ copy_transcript((char *) Y.seq, &X, starts, ends, on_minus_strand, decreasing_rank_on_minus_strand0, lkup); } UNPROTECT(2); return ans; }
static void match_pdict(SEXP pptb, HeadTail *headtail, const Chars_holder *S, SEXP max_mismatch, SEXP min_mismatch, SEXP fixed, MatchPDictBuf *matchpdict_buf) { int max_nmis, min_nmis, fixedP, fixedS; SEXP low2high; const char *type; TBMatchBuf *tb_matches; max_nmis = INTEGER(max_mismatch)[0]; min_nmis = INTEGER(min_mismatch)[0]; fixedP = LOGICAL(fixed)[0]; fixedS = LOGICAL(fixed)[1]; type = get_classname(pptb); /* if (strcmp(type, "ACtree2") == 0) { _match_pdictACtree2(pptb, headtail, S, max_nmis, min_nmis, fixedP, fixedS, matchpdict_buf); return; } */ low2high = _get_PreprocessedTB_low2high(pptb); tb_matches = &(matchpdict_buf->tb_matches); if (strcmp(type, "Twobit") == 0) _match_Twobit(pptb, S, fixedS, tb_matches); else if (strcmp(type, "ACtree2") == 0) _match_tbACtree2(pptb, S, fixedS, tb_matches); else error("%s: unsupported Trusted Band type in 'pdict'", type); /* Call _match_pdict_all_flanks() even if 'headtail' is empty * (i.e. headtail->max_HTwidth == 0) because we need to propagate * the matches to the duplicates anyway */ _match_pdict_all_flanks(low2high, headtail, S, max_nmis, min_nmis, fixedP, fixedS, matchpdict_buf); return; }
/* Create auxiliary (toplevel) windows with the current visual */ static void create_aux_windows(_THIS) { int x = 0, y = 0; char classname[1024]; XSetWindowAttributes xattr; XWMHints *hints; unsigned long app_event_mask; int def_vis = (SDL_Visual == DefaultVisual(SDL_Display, SDL_Screen)); /* Look up some useful Atoms */ WM_DELETE_WINDOW = XInternAtom(SDL_Display, "WM_DELETE_WINDOW", False); /* Don't create any extra windows if we are being managed */ if ( SDL_windowid ) { FSwindow = 0; WMwindow = SDL_strtol(SDL_windowid, NULL, 0); return; } if(FSwindow) XDestroyWindow(SDL_Display, FSwindow); #if SDL_VIDEO_DRIVER_X11_XINERAMA if ( use_xinerama ) { x = xinerama_info.x_org; y = xinerama_info.y_org; } #endif xattr.override_redirect = True; xattr.background_pixel = def_vis ? BlackPixel(SDL_Display, SDL_Screen) : 0; xattr.border_pixel = 0; xattr.colormap = SDL_XColorMap; FSwindow = XCreateWindow(SDL_Display, SDL_Root, x, y, 32, 32, 0, this->hidden->depth, InputOutput, SDL_Visual, CWOverrideRedirect | CWBackPixel | CWBorderPixel | CWColormap, &xattr); XSelectInput(SDL_Display, FSwindow, StructureNotifyMask); /* Tell KDE to keep the fullscreen window on top */ { XEvent ev; long mask; SDL_memset(&ev, 0, sizeof(ev)); ev.xclient.type = ClientMessage; ev.xclient.window = SDL_Root; ev.xclient.message_type = XInternAtom(SDL_Display, "KWM_KEEP_ON_TOP", False); ev.xclient.format = 32; ev.xclient.data.l[0] = FSwindow; ev.xclient.data.l[1] = CurrentTime; mask = SubstructureRedirectMask; XSendEvent(SDL_Display, SDL_Root, False, mask, &ev); } hints = NULL; if(WMwindow) { /* All window attributes must survive the recreation */ hints = XGetWMHints(SDL_Display, WMwindow); XDestroyWindow(SDL_Display, WMwindow); } /* Create the window for windowed management */ /* (reusing the xattr structure above) */ WMwindow = XCreateWindow(SDL_Display, SDL_Root, x, y, 32, 32, 0, this->hidden->depth, InputOutput, SDL_Visual, CWBackPixel | CWBorderPixel | CWColormap, &xattr); /* Set the input hints so we get keyboard input */ if(!hints) { hints = XAllocWMHints(); hints->input = True; hints->flags = InputHint; } XSetWMHints(SDL_Display, WMwindow, hints); XFree(hints); X11_SetCaptionNoLock(this, this->wm_title, this->wm_icon); app_event_mask = FocusChangeMask | KeyPressMask | KeyReleaseMask | PropertyChangeMask | StructureNotifyMask | KeymapStateMask; XSelectInput(SDL_Display, WMwindow, app_event_mask); /* Set the class hints so we can get an icon (AfterStep) */ get_classname(classname, sizeof(classname)); { XClassHint *classhints; classhints = XAllocClassHint(); if(classhints != NULL) { classhints->res_name = classname; classhints->res_class = classname; XSetClassHint(SDL_Display, WMwindow, classhints); XFree(classhints); } } /* Setup the communication with the IM server */ /* create_aux_windows may be called several times against the same Display. We should reuse the SDL_IM if one has been opened for the Display, so we should not simply reset SDL_IM here. */ #ifdef X_HAVE_UTF8_STRING if (SDL_X11_HAVE_UTF8) { /* Discard obsolete resources if any. */ if (SDL_IM != NULL && SDL_Display != XDisplayOfIM(SDL_IM)) { /* Just a double check. I don't think this code is ever executed. */ SDL_SetError("display has changed while an IM is kept"); if (SDL_IC) { XUnsetICFocus(SDL_IC); XDestroyIC(SDL_IC); SDL_IC = NULL; } XCloseIM(SDL_IM); SDL_IM = NULL; } /* Open an input method. */ if (SDL_IM == NULL) { char *old_locale = NULL, *old_modifiers = NULL; const char *p; size_t n; /* I'm not comfortable to do locale setup here. However, we need C library locale (and xlib modifiers) to be set based on the user's preference to use XIM, and many existing game programs doesn't take care of users' locale preferences, so someone other than the game program should do it. Moreover, ones say that some game programs heavily rely on the C locale behaviour, e.g., strcol()'s, and we can't change the C library locale. Given the situation, I couldn't find better place to do the job... */ /* Save the current (application program's) locale settings. */ p = setlocale(LC_ALL, NULL); if ( p ) { n = SDL_strlen(p)+1; old_locale = SDL_stack_alloc(char, n); if ( old_locale ) { SDL_strlcpy(old_locale, p, n); } } p = XSetLocaleModifiers(NULL); if ( p ) { n = SDL_strlen(p)+1; old_modifiers = SDL_stack_alloc(char, n); if ( old_modifiers ) { SDL_strlcpy(old_modifiers, p, n); } } /* Fetch the user's preferences and open the input method with them. */ setlocale(LC_ALL, ""); XSetLocaleModifiers(""); SDL_IM = XOpenIM(SDL_Display, NULL, classname, classname); /* Restore the application's locale settings so that we don't break the application's expected behaviour. */ if ( old_locale ) { /* We need to restore the C library locale first, since the interpretation of the X modifier may depend on it. */ setlocale(LC_ALL, old_locale); SDL_stack_free(old_locale); } if ( old_modifiers ) { XSetLocaleModifiers(old_modifiers); SDL_stack_free(old_modifiers); } } /* Create a new input context for the new window just created. */ if (SDL_IM == NULL) { SDL_SetError("no input method could be opened"); } else { if (SDL_IC != NULL) { /* Discard the old IC before creating new one. */ XUnsetICFocus(SDL_IC); XDestroyIC(SDL_IC); } /* Theoretically we should check the current IM supports PreeditNothing+StatusNothing style (i.e., root window method) before creating the IC. However, it is the bottom line method, and we supports any other options. If the IM didn't support root window method, the following call fails, and SDL falls back to pre-XIM keyboard handling. */ SDL_IC = pXCreateIC(SDL_IM, XNClientWindow, WMwindow, XNFocusWindow, WMwindow, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, XNResourceName, classname, XNResourceClass, classname, NULL); if (SDL_IC == NULL) { SDL_SetError("no input context could be created"); XCloseIM(SDL_IM); SDL_IM = NULL; } else { /* We need to receive X events that an IM wants and to pass them to the IM through XFilterEvent. The set of events may vary depending on the IM implementation and the options specified through various routes. Although unlikely, the xlib specification allows IM to change the event requirement with its own circumstances, it is safe to call SelectInput whenever we re-create an IC. */ unsigned long mask = 0; char *ret = pXGetICValues(SDL_IC, XNFilterEvents, &mask, NULL); if (ret != NULL) { XUnsetICFocus(SDL_IC); XDestroyIC(SDL_IC); SDL_IC = NULL; SDL_SetError("no input context could be created"); XCloseIM(SDL_IM); SDL_IM = NULL; } else { XSelectInput(SDL_Display, WMwindow, app_event_mask | mask); XSetICFocus(SDL_IC); } } } }
/* * Instrument classfile to invoke new object & array creation hooks in <cinit> of java.lang.Object */ void instrument_classfile( jvmtiEnv* jvmti, JNIEnv* jni , jclass class_being_redefined, jobject loader , const char* name, jobject protection_domain , jint class_data_len, const unsigned char* class_data , jint* new_class_data_len, unsigned char** new_class_data ) { static size_t classfile_index; // determine classname const char* classname = get_classname( name, class_data, class_data_len ); std::string internal_classname("L"); internal_classname += classname; internal_classname += ";"; xpr::sregex thread_filter = xpr::sregex::compile( eraser::agent::instance()->thread_filter_regex_ ); bool is_thread = xpr::regex_match( internal_classname, thread_filter ); bool obj_match = strcmp(classname, "java/lang/Object") == 0; if( !( is_thread || obj_match ) ) { free((void*)classname); return; } logger::instance()->level(200) << classname << std::boolalpha << " is_thread= " << is_thread << " obj_match= " << obj_match << std::endl; // prevent self-instrumentation if( strcmp(classname, PROXY_CLASS) == 0 ) { free((void*)classname); return; } unsigned char* new_image = 0; long new_length = 0; *new_class_data_len = 0; *new_class_data = 0; classfile_index++; bool is_system_class = ( agent::instance()->phase() < JVMTI_PHASE_START ); // go instrument if( obj_match ) java_crw_demo( classfile_index, classname , class_data, class_data_len , is_system_class , PROXY_CLASS , "L" PROXY_CLASS ";" , 0, 0 , 0, 0 , NEW_OBJ_METHOD, "(Ljava/lang/Object;)V" , NEW_ARR_METHOD, "(Ljava/lang/Object;)V" , &new_image , &new_length , 0, 0 ); else if( is_thread ) java_crw_demo( classfile_index, classname , class_data, class_data_len , is_system_class , PROXY_CLASS , "L" PROXY_CLASS ";" , MONITOR_ENTER, "(Ljava/lang/Object;)V" , MONITOR_EXIT, "(Ljava/lang/Object;)V" , 0, 0 , 0, 0 , &new_image , &new_length , 0, 0 ); else BOOST_ASSERT( false ); // memcpy transformed classfile to jvmti allocated memory if( new_length > 0 ) { # if defined( ERASER_DEBUG ) std::ofstream class_dump( "dump", std::ofstream::binary ); class_dump.write( (const char*)new_image, (std::streamsize)new_length ); class_dump.close(); # endif unsigned char *jvmtispace = (unsigned char *)allocate( jvmti, (jint)new_length ); memcpy( (void*)jvmtispace, (void*)new_image, new_length ); *new_class_data_len = new_length; *new_class_data = jvmtispace; } if( new_image != 0 ) free(new_image); free((void*)classname); }
int X11_VideoInit(_THIS) { SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; /* Get the window class name, usually the name of the application */ data->classname = get_classname(); /* Get the process PID to be associated to the window */ data->pid = getpid(); /* I have no idea how random this actually is, or has to be. */ data->window_group = (XID) (((size_t) data->pid) ^ ((size_t) _this)); /* Look up some useful Atoms */ #define GET_ATOM(X) data->X = X11_XInternAtom(data->display, #X, False) GET_ATOM(WM_PROTOCOLS); GET_ATOM(WM_DELETE_WINDOW); GET_ATOM(WM_TAKE_FOCUS); GET_ATOM(_NET_WM_STATE); GET_ATOM(_NET_WM_STATE_HIDDEN); GET_ATOM(_NET_WM_STATE_FOCUSED); GET_ATOM(_NET_WM_STATE_MAXIMIZED_VERT); GET_ATOM(_NET_WM_STATE_MAXIMIZED_HORZ); GET_ATOM(_NET_WM_STATE_FULLSCREEN); GET_ATOM(_NET_WM_STATE_ABOVE); GET_ATOM(_NET_WM_STATE_SKIP_TASKBAR); GET_ATOM(_NET_WM_STATE_SKIP_PAGER); GET_ATOM(_NET_WM_ALLOWED_ACTIONS); GET_ATOM(_NET_WM_ACTION_FULLSCREEN); GET_ATOM(_NET_WM_NAME); GET_ATOM(_NET_WM_ICON_NAME); GET_ATOM(_NET_WM_ICON); GET_ATOM(_NET_WM_PING); GET_ATOM(_NET_WM_WINDOW_OPACITY); GET_ATOM(_NET_WM_USER_TIME); GET_ATOM(_NET_ACTIVE_WINDOW); GET_ATOM(_NET_FRAME_EXTENTS); GET_ATOM(UTF8_STRING); GET_ATOM(PRIMARY); GET_ATOM(XdndEnter); GET_ATOM(XdndPosition); GET_ATOM(XdndStatus); GET_ATOM(XdndTypeList); GET_ATOM(XdndActionCopy); GET_ATOM(XdndDrop); GET_ATOM(XdndFinished); GET_ATOM(XdndSelection); GET_ATOM(XKLAVIER_STATE); /* Detect the window manager */ X11_CheckWindowManager(_this); if (X11_InitModes(_this) < 0) { return -1; } X11_InitXinput2(_this); if (X11_InitKeyboard(_this) != 0) { return -1; } X11_InitMouse(_this); X11_InitTouch(_this); #if SDL_USE_LIBDBUS SDL_DBus_Init(); #endif return 0; }
int X11_VideoInit(_THIS) { SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; /* Get the window class name, usually the name of the application */ data->classname = get_classname(); /* Get the process PID to be associated to the window */ data->pid = getpid(); /* I have no idea how random this actually is, or has to be. */ data->window_group = (XID) (((size_t) data->pid) ^ ((size_t) _this)); /* Open a connection to the X input manager */ #ifdef X_HAVE_UTF8_STRING if (SDL_X11_HAVE_UTF8) { /* Set the locale, and call XSetLocaleModifiers before XOpenIM so that Compose keys will work correctly. */ char *prev_locale = setlocale(LC_ALL, NULL); char *prev_xmods = X11_XSetLocaleModifiers(NULL); const char *new_xmods = ""; #if defined(HAVE_IBUS_IBUS_H) || defined(HAVE_FCITX_FRONTEND_H) const char *env_xmods = SDL_getenv("XMODIFIERS"); #endif SDL_bool has_dbus_ime_support = SDL_FALSE; if (prev_locale) { prev_locale = SDL_strdup(prev_locale); } if (prev_xmods) { prev_xmods = SDL_strdup(prev_xmods); } /* IBus resends some key events that were filtered by XFilterEvents when it is used via XIM which causes issues. Prevent this by forcing @im=none if XMODIFIERS contains @im=ibus. IBus can still be used via the DBus implementation, which also has support for pre-editing. */ #ifdef HAVE_IBUS_IBUS_H if (env_xmods && SDL_strstr(env_xmods, "@im=ibus") != NULL) { has_dbus_ime_support = SDL_TRUE; } #endif #ifdef HAVE_FCITX_FRONTEND_H if (env_xmods && SDL_strstr(env_xmods, "@im=fcitx") != NULL) { has_dbus_ime_support = SDL_TRUE; } #endif if (has_dbus_ime_support) { new_xmods = "@im=none"; } setlocale(LC_ALL, ""); X11_XSetLocaleModifiers(new_xmods); data->im = X11_XOpenIM(data->display, NULL, data->classname, data->classname); /* Reset the locale + X locale modifiers back to how they were, locale first because the X locale modifiers depend on it. */ setlocale(LC_ALL, prev_locale); X11_XSetLocaleModifiers(prev_xmods); if (prev_locale) { SDL_free(prev_locale); } if (prev_xmods) { SDL_free(prev_xmods); } } #endif /* Look up some useful Atoms */ #define GET_ATOM(X) data->X = X11_XInternAtom(data->display, #X, False) GET_ATOM(WM_PROTOCOLS); GET_ATOM(WM_DELETE_WINDOW); GET_ATOM(WM_TAKE_FOCUS); GET_ATOM(_NET_WM_STATE); GET_ATOM(_NET_WM_STATE_HIDDEN); GET_ATOM(_NET_WM_STATE_FOCUSED); GET_ATOM(_NET_WM_STATE_MAXIMIZED_VERT); GET_ATOM(_NET_WM_STATE_MAXIMIZED_HORZ); GET_ATOM(_NET_WM_STATE_FULLSCREEN); GET_ATOM(_NET_WM_STATE_ABOVE); GET_ATOM(_NET_WM_STATE_SKIP_TASKBAR); GET_ATOM(_NET_WM_STATE_SKIP_PAGER); GET_ATOM(_NET_WM_ALLOWED_ACTIONS); GET_ATOM(_NET_WM_ACTION_FULLSCREEN); GET_ATOM(_NET_WM_NAME); GET_ATOM(_NET_WM_ICON_NAME); GET_ATOM(_NET_WM_ICON); GET_ATOM(_NET_WM_PING); GET_ATOM(_NET_WM_WINDOW_OPACITY); GET_ATOM(_NET_WM_USER_TIME); GET_ATOM(_NET_ACTIVE_WINDOW); GET_ATOM(_NET_FRAME_EXTENTS); GET_ATOM(UTF8_STRING); GET_ATOM(PRIMARY); GET_ATOM(XdndEnter); GET_ATOM(XdndPosition); GET_ATOM(XdndStatus); GET_ATOM(XdndTypeList); GET_ATOM(XdndActionCopy); GET_ATOM(XdndDrop); GET_ATOM(XdndFinished); GET_ATOM(XdndSelection); GET_ATOM(XKLAVIER_STATE); /* Detect the window manager */ X11_CheckWindowManager(_this); if (X11_InitModes(_this) < 0) { return -1; } X11_InitXinput2(_this); if (X11_InitKeyboard(_this) != 0) { return -1; } X11_InitMouse(_this); X11_InitTouch(_this); #if SDL_USE_LIBDBUS SDL_DBus_Init(); #endif return 0; }
static void create_aux_windows(_THIS) { int x = 0, y = 0; char classname[1024]; XSetWindowAttributes xattr; XWMHints *hints; unsigned long app_event_mask; int def_vis = (SDL_Visual == DefaultVisual(SDL_Display, SDL_Screen)); WM_DELETE_WINDOW = XInternAtom(SDL_Display, "WM_DELETE_WINDOW", False); if ( SDL_windowid ) { FSwindow = 0; WMwindow = SDL_strtol(SDL_windowid, NULL, 0); return; } if(FSwindow) XDestroyWindow(SDL_Display, FSwindow); #if SDL_VIDEO_DRIVER_X11_XINERAMA if ( use_xinerama ) { x = xinerama_info.x_org; y = xinerama_info.y_org; } #endif xattr.override_redirect = True; xattr.background_pixel = def_vis ? BlackPixel(SDL_Display, SDL_Screen) : 0; xattr.border_pixel = 0; xattr.colormap = SDL_XColorMap; FSwindow = XCreateWindow(SDL_Display, SDL_Root, x + X11_wmXAdjust, y + X11_wmYAdjust, 32, 32, 0, this->hidden->depth, InputOutput, SDL_Visual, CWOverrideRedirect | CWBackPixel | CWBorderPixel | CWColormap, &xattr); XSelectInput(SDL_Display, FSwindow, StructureNotifyMask); { XEvent ev; long mask; SDL_memset(&ev, 0, sizeof(ev)); ev.xclient.type = ClientMessage; ev.xclient.window = SDL_Root; ev.xclient.message_type = XInternAtom(SDL_Display, "KWM_KEEP_ON_TOP", False); ev.xclient.format = 32; ev.xclient.data.l[0] = FSwindow; ev.xclient.data.l[1] = CurrentTime; mask = SubstructureRedirectMask; XSendEvent(SDL_Display, SDL_Root, False, mask, &ev); } hints = NULL; if(WMwindow) { hints = XGetWMHints(SDL_Display, WMwindow); XDestroyWindow(SDL_Display, WMwindow); } WMwindow = XCreateWindow(SDL_Display, SDL_Root, x, y, 32, 32, 0, this->hidden->depth, InputOutput, SDL_Visual, CWBackPixel | CWBorderPixel | CWColormap, &xattr); if(!hints) { hints = XAllocWMHints(); hints->input = True; hints->flags = InputHint; } XSetWMHints(SDL_Display, WMwindow, hints); XFree(hints); X11_SetCaptionNoLock(this, this->wm_title, this->wm_icon); app_event_mask = FocusChangeMask | KeyPressMask | KeyReleaseMask | PropertyChangeMask | StructureNotifyMask | KeymapStateMask; XSelectInput(SDL_Display, WMwindow, app_event_mask); get_classname(classname, sizeof(classname)); { XClassHint *classhints; classhints = XAllocClassHint(); if(classhints != NULL) { classhints->res_name = classname; classhints->res_class = classname; XSetClassHint(SDL_Display, WMwindow, classhints); XFree(classhints); } } { pid_t pid = getpid(); char hostname[256]; if (pid > 0 && gethostname(hostname, sizeof(hostname)) > -1) { Atom _NET_WM_PID = XInternAtom(SDL_Display, "_NET_WM_PID", False); Atom WM_CLIENT_MACHINE = XInternAtom(SDL_Display, "WM_CLIENT_MACHINE", False); hostname[sizeof(hostname)-1] = '\0'; XChangeProperty(SDL_Display, WMwindow, _NET_WM_PID, XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&pid, 1); XChangeProperty(SDL_Display, WMwindow, WM_CLIENT_MACHINE, XA_STRING, 8, PropModeReplace, (unsigned char *)hostname, SDL_strlen(hostname)); } } #ifdef X_HAVE_UTF8_STRING if (SDL_X11_HAVE_UTF8) { if (SDL_IM != NULL && SDL_Display != XDisplayOfIM(SDL_IM)) { SDL_SetError("display has changed while an IM is kept"); if (SDL_IC) { XUnsetICFocus(SDL_IC); XDestroyIC(SDL_IC); SDL_IC = NULL; } XCloseIM(SDL_IM); SDL_IM = NULL; } if (SDL_IM == NULL) { char *old_locale = NULL, *old_modifiers = NULL; const char *p; size_t n; p = setlocale(LC_ALL, NULL); if ( p ) { n = SDL_strlen(p)+1; old_locale = SDL_stack_alloc(char, n); if ( old_locale ) { SDL_strlcpy(old_locale, p, n); } } p = XSetLocaleModifiers(NULL); if ( p ) { n = SDL_strlen(p)+1; old_modifiers = SDL_stack_alloc(char, n); if ( old_modifiers ) { SDL_strlcpy(old_modifiers, p, n); } } setlocale(LC_ALL, ""); XSetLocaleModifiers(""); SDL_IM = XOpenIM(SDL_Display, NULL, classname, classname); if ( old_locale ) { setlocale(LC_ALL, old_locale); SDL_stack_free(old_locale); } if ( old_modifiers ) { XSetLocaleModifiers(old_modifiers); SDL_stack_free(old_modifiers); } } if (SDL_IM == NULL) { SDL_SetError("no input method could be opened"); } else { if (SDL_IC != NULL) { XUnsetICFocus(SDL_IC); XDestroyIC(SDL_IC); } SDL_IC = pXCreateIC(SDL_IM, XNClientWindow, WMwindow, XNFocusWindow, WMwindow, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, XNResourceName, classname, XNResourceClass, classname, NULL); if (SDL_IC == NULL) { SDL_SetError("no input context could be created"); XCloseIM(SDL_IM); SDL_IM = NULL; } else { unsigned long mask = 0; char *ret = pXGetICValues(SDL_IC, XNFilterEvents, &mask, NULL); if (ret != NULL) { XUnsetICFocus(SDL_IC); XDestroyIC(SDL_IC); SDL_IC = NULL; SDL_SetError("no input context could be created"); XCloseIM(SDL_IM); SDL_IM = NULL; } else { XSelectInput(SDL_Display, WMwindow, app_event_mask | mask); XSetICFocus(SDL_IC); } } } }