diff options
author | JengHyun Kang <jhyuni.kang@samsung.com> | 2016-01-04 08:47:43 -0500 |
---|---|---|
committer | Chris Michael <cpmichael@osg.samsung.com> | 2016-01-04 08:47:58 -0500 |
commit | b3dc27345a59dc21b115fe55bb15e7af092eacbe (patch) | |
tree | 8f66f5941ab4efd09eaadb2cfca12825f09da55a /src/lib/ecore_drm/ecore_drm_device.c | |
parent | fe70f0c080d2f168b5674cd4aa804ec95617739d (diff) |
ecore-drm: Add a new API for keymap cache
Summary:
Originally, each keyboard devices could have their own keymap.
The one keyboard's keymap could different with others.
But for this, Ecore_Drm compile a new keymap when a keyboard is connected.
But this is a burden for some people who doesn't manage keymap for each keyboard.
They want to maintain only one keymap for system.
So, I added cached context/keymap and just ref/unref for each keyboard device.
People who want to different keymap for each keyboard just do not set cached
context/keymap. Then Ecore_Drm maintain keymaps about each keyboard devices.
Test Plan:
Connect a keyboard device and watch flow of ioctl.
Originally Ecore_Drm opened xkb data and compile keymap,
but after patch, that ioctl is disppeared.
@feature
Reviewers: raster, devilhorns, ManMower
Reviewed By: devilhorns, ManMower
Subscribers: cedric, input.hacker, ohduna, jpeg
Differential Revision: https://phab.enlightenment.org/D3503
Diffstat (limited to 'src/lib/ecore_drm/ecore_drm_device.c')
-rw-r--r-- | src/lib/ecore_drm/ecore_drm_device.c | 80 |
1 files changed, 79 insertions, 1 deletions
diff --git a/src/lib/ecore_drm/ecore_drm_device.c b/src/lib/ecore_drm/ecore_drm_device.c index f0c0cfe470..d3eb91f68d 100644 --- a/src/lib/ecore_drm/ecore_drm_device.c +++ b/src/lib/ecore_drm/ecore_drm_device.c | |||
@@ -107,6 +107,58 @@ _ecore_drm_device_cb_output_event(const char *device EINA_UNUSED, Eeze_Udev_Even | |||
107 | _ecore_drm_outputs_update(dev); | 107 | _ecore_drm_outputs_update(dev); |
108 | } | 108 | } |
109 | 109 | ||
110 | struct xkb_context * | ||
111 | _ecore_drm_device_cached_context_get(enum xkb_context_flags flags) | ||
112 | { | ||
113 | if (!cached_context) | ||
114 | return xkb_context_new(flags); | ||
115 | else | ||
116 | return xkb_context_ref(cached_context); | ||
117 | } | ||
118 | |||
119 | struct xkb_keymap * | ||
120 | _ecore_drm_device_cached_keymap_get(struct xkb_context *ctx, | ||
121 | const struct xkb_rule_names *names, | ||
122 | enum xkb_keymap_compile_flags flags) | ||
123 | { | ||
124 | EINA_SAFETY_ON_NULL_RETURN_VAL(ctx, NULL); | ||
125 | |||
126 | if (!cached_keymap) | ||
127 | return xkb_map_new_from_names(ctx, names, flags); | ||
128 | else | ||
129 | return xkb_map_ref(cached_keymap); | ||
130 | } | ||
131 | |||
132 | void | ||
133 | _ecore_drm_device_cached_context_update(struct xkb_context *ctx) | ||
134 | { | ||
135 | Eina_List *l; | ||
136 | Ecore_Drm_Device *dev; | ||
137 | |||
138 | EINA_LIST_FOREACH(drm_devices, l, dev) | ||
139 | { | ||
140 | xkb_context_unref(dev->xkb_ctx); | ||
141 | dev->xkb_ctx = xkb_context_ref(ctx); | ||
142 | } | ||
143 | } | ||
144 | |||
145 | void | ||
146 | _ecore_drm_device_cached_keymap_update(struct xkb_keymap *map) | ||
147 | { | ||
148 | Eina_List *l, *l2, *l3; | ||
149 | Ecore_Drm_Device *dev; | ||
150 | Ecore_Drm_Seat *seat; | ||
151 | Ecore_Drm_Evdev *edev; | ||
152 | |||
153 | EINA_LIST_FOREACH(drm_devices, l, dev) | ||
154 | EINA_LIST_FOREACH(dev->seats, l2, seat) | ||
155 | EINA_LIST_FOREACH(seat->devices, l3, edev) | ||
156 | { | ||
157 | xkb_keymap_unref(edev->xkb.keymap); | ||
158 | edev->xkb.keymap = xkb_keymap_ref(map); | ||
159 | } | ||
160 | } | ||
161 | |||
110 | /** | 162 | /** |
111 | * @defgroup Ecore_Drm_Device_Group Device manipulation functions | 163 | * @defgroup Ecore_Drm_Device_Group Device manipulation functions |
112 | * | 164 | * |
@@ -308,7 +360,7 @@ ecore_drm_device_open(Ecore_Drm_Device *dev) | |||
308 | } | 360 | } |
309 | 361 | ||
310 | /* try to create xkb context */ | 362 | /* try to create xkb context */ |
311 | if (!(dev->xkb_ctx = xkb_context_new(0))) | 363 | if (!(dev->xkb_ctx = _ecore_drm_device_cached_context_get(0))) |
312 | { | 364 | { |
313 | ERR("Failed to create xkb context: %m"); | 365 | ERR("Failed to create xkb context: %m"); |
314 | return EINA_FALSE; | 366 | return EINA_FALSE; |
@@ -590,3 +642,29 @@ ecore_drm_device_pointer_left_handed_set(Ecore_Drm_Device *dev, Eina_Bool left_h | |||
590 | } | 642 | } |
591 | return EINA_TRUE; | 643 | return EINA_TRUE; |
592 | } | 644 | } |
645 | |||
646 | EAPI void | ||
647 | ecore_drm_device_keyboard_cached_context_set(struct xkb_context *ctx) | ||
648 | { | ||
649 | EINA_SAFETY_ON_NULL_RETURN(ctx); | ||
650 | |||
651 | if (cached_context == ctx) return; | ||
652 | |||
653 | if (cached_context) | ||
654 | _ecore_drm_device_cached_context_update(ctx); | ||
655 | |||
656 | cached_context = ctx; | ||
657 | } | ||
658 | |||
659 | EAPI void | ||
660 | ecore_drm_device_keyboard_cached_keymap_set(struct xkb_keymap *map) | ||
661 | { | ||
662 | EINA_SAFETY_ON_NULL_RETURN(map); | ||
663 | |||
664 | if (cached_keymap == map) return; | ||
665 | |||
666 | if (cached_keymap) | ||
667 | _ecore_drm_device_cached_keymap_update(map); | ||
668 | |||
669 | cached_keymap = map; | ||
670 | } | ||