The AppKit thread should not be calling directly into the X server

functions to change state when the keyboard is reloaded; instead,
pass it as an event.
This commit is contained in:
Ben Byer 2008-04-01 00:40:46 -07:00
parent eb083d3f68
commit 7e653f806f
5 changed files with 13 additions and 16 deletions

View File

@ -91,13 +91,8 @@ extern int darwinMainScreenY;
* Special ddx events understood by the X server * Special ddx events understood by the X server
*/ */
enum { enum {
kXquartzUpdateModifiers // update all modifier keys kXquartzReloadKeymap // Reload system keymap
= LASTEvent+1, // (from X.h list of event names) = LASTEvent+1, // (from X.h list of event names)
kXquartzUpdateButtons, // update state of mouse buttons 2 and up
kXquartzScrollWheel, // scroll wheel event
/*
* Quartz-specific events -- not used in IOKit mode
*/
kXquartzActivate, // restore X drawing and cursor kXquartzActivate, // restore X drawing and cursor
kXquartzDeactivate, // clip X drawing and switch to Aqua cursor kXquartzDeactivate, // clip X drawing and switch to Aqua cursor
kXquartzSetRootClip, // enable or disable drawing to the X screen kXquartzSetRootClip, // enable or disable drawing to the X screen

View File

@ -289,6 +289,7 @@ Bool DarwinEQInit(DevicePtr pKbd, DevicePtr pPtr) {
FatalError("Couldn't allocate event buffer\n"); FatalError("Couldn't allocate event buffer\n");
mieqInit(); mieqInit();
mieqSetHandler(kXquartzReloadKeymap, DarwinKeyboardReloadHandler);
mieqSetHandler(kXquartzActivate, DarwinEventHandler); mieqSetHandler(kXquartzActivate, DarwinEventHandler);
mieqSetHandler(kXquartzDeactivate, DarwinEventHandler); mieqSetHandler(kXquartzDeactivate, DarwinEventHandler);
mieqSetHandler(kXquartzSetRootClip, DarwinEventHandler); mieqSetHandler(kXquartzSetRootClip, DarwinEventHandler);
@ -322,7 +323,7 @@ void ProcessInputEvents(void) {
// Empty the signaling pipe // Empty the signaling pipe
int x = sizeof(xe); int x = sizeof(xe);
while (x == sizeof(xe)) { while (x == sizeof(xe)) {
DEBUG_LOG("draining pipe\n"); // DEBUG_LOG("draining pipe\n");
x = read(darwinEventReadFD, &xe, sizeof(xe)); x = read(darwinEventReadFD, &xe, sizeof(xe));
} }
} }
@ -412,8 +413,8 @@ void DarwinSendKeyboardEvents(int ev_type, int keycode) {
this_seed = QuartzSystemKeymapSeed(); this_seed = QuartzSystemKeymapSeed();
if (this_seed != last_seed) { if (this_seed != last_seed) {
last_seed = this_seed; last_seed = this_seed;
DarwinKeyboardReload(darwinKeyboard); DarwinSendDDXEvent(kXquartzReloadKeymap, 0);
} }
} }

View File

@ -850,16 +850,18 @@ static Bool InitModMap(register KeyClassPtr keyc) {
} }
void DarwinKeyboardReload(DeviceIntPtr pDev) { void DarwinKeyboardReloadHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, int nevents) {
KeySymsRec keySyms; KeySymsRec keySyms;
if (dev == NULL) dev = darwinKeyboard;
DEBUG_LOG("DarwinKeyboardReloadHandler(%p)\n", dev);
DarwinLoadKeyboardMapping(&keySyms); DarwinLoadKeyboardMapping(&keySyms);
if (SetKeySymsMap(&pDev->key->curKeySyms, &keySyms)) { if (SetKeySymsMap(&dev->key->curKeySyms, &keySyms)) {
/* now try to update modifiers. */ /* now try to update modifiers. */
memmove(pDev->key->modifierMap, keyInfo.modMap, MAP_LENGTH); memmove(dev->key->modifierMap, keyInfo.modMap, MAP_LENGTH);
InitModMap(pDev->key); InitModMap(dev->key);
} else DEBUG_LOG("SetKeySymsMap=0\n"); } else DEBUG_LOG("SetKeySymsMap=0\n");
SendMappingNotify(MappingKeyboard, MIN_KEYCODE, NUM_KEYCODES, 0); SendMappingNotify(MappingKeyboard, MIN_KEYCODE, NUM_KEYCODES, 0);

View File

@ -31,7 +31,7 @@
/* Provided for darwinEvents.c */ /* Provided for darwinEvents.c */
extern darwinKeyboardInfo keyInfo; extern darwinKeyboardInfo keyInfo;
void DarwinKeyboardReload(DeviceIntPtr pDev); void DarwinKeyboardReloadHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, int nevents);
void DarwinKeyboardInit(DeviceIntPtr pDev); void DarwinKeyboardInit(DeviceIntPtr pDev);
int DarwinModifierNXKeycodeToNXKey(unsigned char keycode, int *outSide); int DarwinModifierNXKeycodeToNXKey(unsigned char keycode, int *outSide);
int DarwinModifierNXKeyToNXKeycode(int key, int side); int DarwinModifierNXKeyToNXKeycode(int key, int side);

View File

@ -46,7 +46,6 @@ typedef struct darwinKeyboardInfo_struct {
} darwinKeyboardInfo; } darwinKeyboardInfo;
/* These functions need to be implemented by Xquartz, XDarwin, etc. */ /* These functions need to be implemented by Xquartz, XDarwin, etc. */
void DarwinKeyboardReload(DeviceIntPtr pDev);
Bool QuartzReadSystemKeymap(darwinKeyboardInfo *info); Bool QuartzReadSystemKeymap(darwinKeyboardInfo *info);
unsigned int QuartzSystemKeymapSeed(void); unsigned int QuartzSystemKeymapSeed(void);