Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(340)

Unified Diff: ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.h

Issue 817983002: ozone: xkb: Load keymaps on worker thread & cache them (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.h
diff --git a/ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.h b/ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.h
index d7a98545d3a435c884854f069798f9b72bcc1b4d..8281b68af27c4fbdf6d1d471b00c64edc595d12a 100644
--- a/ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.h
+++ b/ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.h
@@ -6,10 +6,14 @@
#define UI_EVENTS_OZONE_LAYOUT_XKB_XKB_KEYBOARD_LAYOUT_ENGINE_H_
#include <xkbcommon/xkbcommon.h>
+#include <vector>
#include "base/containers/hash_tables.h"
+#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
#include "base/strings/string16.h"
+#include "base/task_runner.h"
#include "ui/events/ozone/layout/events_ozone_layout_export.h"
#include "ui/events/ozone/layout/keyboard_layout_engine.h"
#include "ui/events/ozone/layout/xkb/scoped_xkb.h"
@@ -37,6 +41,10 @@ class EVENTS_OZONE_LAYOUT_EXPORT XkbKeyboardLayoutEngine
KeyboardCode* key_code,
uint32* platform_keycode) const override;
+ // Gets the names of the RMLO rule for libxkbcommon.
+ // Makes it protected for testing.
+ scoped_ptr<xkb_rule_names> GetXkbRuleNames(const std::string& layout_name);
+
protected:
// Table for EventFlagsToXkbFlags().
struct XkbFlagMapEntry {
@@ -60,6 +68,11 @@ class EVENTS_OZONE_LAYOUT_EXPORT XkbKeyboardLayoutEngine
const XkbKeyCodeConverter& key_code_converter_;
private:
+ struct XkbKeymapEntry {
+ std::string layout_name;
+ xkb_keymap* keymap;
+ };
+ std::vector<XkbKeymapEntry> xkb_keymaps_;
// Sets a new XKB keymap. This updates xkb_state_ (which takes ownership
// of the keymap), and updates xkb_flag_map_ for the new keymap.
void SetKeymap(xkb_keymap* keymap);
@@ -82,10 +95,19 @@ class EVENTS_OZONE_LAYOUT_EXPORT XkbKeyboardLayoutEngine
base::char16 base_character,
int ui_flags) const;
+ // Callback when keymap file is loaded complete.
+ void OnKeymapLoaded(const std::string& layout_name,
+ scoped_ptr<xkb_keymap, XkbKeymapDeleter> keymap);
+
// libxkbcommon uses explicit reference counting for its structures,
// so we need to trigger its cleanup.
scoped_ptr<xkb_context, XkbContextDeleter> xkb_context_;
scoped_ptr<xkb_state, XkbStateDeleter> xkb_state_;
+
+ std::string current_layout_name_;
+
+ // Support weak pointers for attach & detach callbacks.
+ base::WeakPtrFactory<XkbKeyboardLayoutEngine> weak_ptr_factory_;
};
} // namespace ui

Powered by Google App Engine
This is Rietveld 408576698