input_server: Notify apps of new key map
Define a new message, B_KEY_MAP_LOADED, that is broadcast to applications by the Input Server each time a key map is loaded. This allows apps that cache key-map data to know when their copy has become stale. Change InputServer::HandleGetSetKeyMap() so it returns an error in the event loading even the system (fallback) key map fails. Change-Id: Icc6c884f695ca59c687d83c680bb2fb467dd90cc Reviewed-on: https://review.haiku-os.org/c/haiku/+/1741 Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
committed by
Stephan Aßmus
parent
19f8517fc3
commit
b9d9c282fd
@@ -38,6 +38,7 @@ enum {
|
||||
B_KEY_UP = '_KYU',
|
||||
B_UNMAPPED_KEY_DOWN = '_UKD',
|
||||
B_UNMAPPED_KEY_UP = '_UKU',
|
||||
B_KEY_MAP_LOADED = '_KML',
|
||||
B_LAYOUT_WINDOW = '_LAY',
|
||||
B_MODIFIERS_CHANGED = '_MCH',
|
||||
B_MINIMIZE = '_WMN',
|
||||
|
||||
@@ -932,21 +932,33 @@ InputServer::HandleGetSetKeyMap(BMessage* message, BMessage* reply)
|
||||
{
|
||||
CALLED();
|
||||
|
||||
status_t status;
|
||||
if (message->what == IS_GET_KEY_MAP) {
|
||||
status_t status = reply->AddData("keymap", B_ANY_TYPE, &fKeys, sizeof(fKeys));
|
||||
status = reply->AddData("keymap", B_ANY_TYPE, &fKeys, sizeof(fKeys));
|
||||
if (status == B_OK)
|
||||
status = reply->AddData("key_buffer", B_ANY_TYPE, fChars, fCharsSize);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
if (_LoadKeymap() != B_OK)
|
||||
_LoadSystemKeymap();
|
||||
status = _LoadKeymap();
|
||||
if (status != B_OK) {
|
||||
status = _LoadSystemKeymap();
|
||||
if (status != B_OK)
|
||||
return status;
|
||||
}
|
||||
|
||||
BMessage msg(IS_CONTROL_DEVICES);
|
||||
msg.AddInt32("type", B_KEYBOARD_DEVICE);
|
||||
msg.AddInt32("code", B_KEY_MAP_CHANGED);
|
||||
return fAddOnManager->PostMessage(&msg);
|
||||
status = fAddOnManager->PostMessage(&msg);
|
||||
|
||||
if (status == B_OK) {
|
||||
BMessage appMsg(B_KEY_MAP_LOADED);
|
||||
be_roster->Broadcast(&appMsg);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user