int window_switch(const char *windowName) { /* {{{ */ int opt; int ret = EXIT_SUCCESS; int missing_option = 1; Display *disp; memset(&options, 0, sizeof(options)); /* just for sure */ /* necessary to make g_get_charset() and g_locale_*() work */ setlocale(LC_ALL, ""); options.param_window=malloc(strlen(windowName)); strncpy(options.param_window,windowName,strlen(windowName)); init_charset(); if (! (disp = XOpenDisplay(NULL))) { fputs("Cannot open display.\n", stderr); return EXIT_FAILURE; } if (! options.param_window) { fputs("No window was specified.\n", stderr); return EXIT_FAILURE; } ret = action_window_str(disp, 'a'); XCloseDisplay(disp); return ret; }
/////////////////////////////////////////////////////////////////////////////// /// @fn FB::variant VideoPinsAPI::Xtest(const std::string classN, const std::string title) /// /// @brief Echos whatever is passed from Javascript. /// Go ahead and change it. See what happens! /////////////////////////////////////////////////////////////////////////////// FB::variant VideoPinsAPI::Xtest(const std::string classN, const std::string title) { Window activate = EXIT_FAILURE; Display *disp = XOpenDisplay(NIL); std::vector<gchar> mTitle(title.c_str(),title.c_str()+title.length()+1); std::vector<gchar> mClass(classN.c_str(),classN.c_str()+classN.length()+1); while(activate==EXIT_FAILURE) { activate = action_window_str(disp, &mClass[0], &mTitle[0]); } XCloseDisplay(disp); /* assert(dpy); Window w = XCreateWindow(dpy, DefaultRootWindow(dpy), 0, 0, 200, 100, 0, CopyFromParent, CopyFromParent, CopyFromParent, NIL, 0); XMapWindow(dpy, w); XFlush(dpy); sleep(10); */ return activate; }
/////////////////////////////////////////////////////////////////////////////// /// @fn FB::variant VideoPinsAPI::vFindWindow(const std::string classN, const std::string title) /// /// @brief Echos whatever is passed from Javascript. /// Go ahead and change it. See what happens! /////////////////////////////////////////////////////////////////////////////// FB::variant VideoPinsAPI::vFindWindow(const std::string classN, const std::string title) { Window activate = EXIT_FAILURE; Display *disp = XOpenDisplay(NIL); std::vector<gchar> mTitle(title.c_str(),title.c_str()+title.length()+1); std::vector<gchar> mClass(classN.c_str(),classN.c_str()+classN.length()+1); activate = action_window_str(disp, &mClass[0], &mTitle[0]); XCloseDisplay(disp); if(activate==EXIT_FAILURE) return 0; else return activate; }