MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / LoadEngines

Method LoadEngines

cpp/imehandler/windows/src/winapihandler.cc:236–273  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

234}
235
236int WinapiHandler::LoadEngines(const std::vector<std::string>& engine_names) {
237 int nb_loaded_engines = 0;
238 if (!engine_names.empty()) {
239 // First we get the currently loaded engines, to unload the unused
240 // ones afterwards.
241 std::vector<std::string> loaded_engines = GetLoadedEngines();
242
243 // Then we load the new ones, for now it is the same as activating them
244 for (std::vector<std::string>::const_iterator it = engine_names.begin() ;
245 it != engine_names.end() ; it++) {
246 // std::cout <<"Loading keyboard " << it->c_str() << std::endl;
247 // XXX: bug: this never returns NULL as the documentation says...
248 if (LoadKeyboardLayout(GetLayoutHkl(*it).c_str(), 0) != NULL) {
249 ++nb_loaded_engines;
250 }
251 }
252
253 // Then we unload the new ones so that there was always at least one engine
254 // active (windows does not accept unloading the engines first, then
255 // activate the new ones)
256 for (std::vector<std::string>::const_iterator it =
257 loaded_engines.begin() ; it != loaded_engines.end() ; it++) {
258 if (std::find(engine_names.begin(), engine_names.end(), *it) ==
259 engine_names.end()) {
260 // We need to activate it to get the HKL...
261 ActivateEngine(*it);
262 HKL hkl = GetKeyboardLayout(0);
263 // And we activate another one to be able to unload it
264 ActivateEngine(engine_names[0]);
265 if (!UnloadKeyboardLayout(hkl)) {
266 std::cerr << "could not unload keyboard layout " << *it;
267 std::cerr << std::endl;
268 }
269 }
270 }
271 }
272 return nb_loaded_engines;
273}
274
275bool WinapiHandler::ActivateEngine(const std::string& engine) {
276 std::string hkl = GetLayoutHkl(engine);

Callers

nothing calls this directly

Calls 2

endMethod · 0.80
emptyMethod · 0.45

Tested by

no test coverage detected