static int send_devinfo(gii_input *inp, enum quartz_devtype devtype) { gii_event ev; gii_cmddata_getdevinfo *dinfo; size_t size; quartz_priv *priv = QUARTZ_PRIV(inp); size = sizeof(gii_cmd_nodata_event) + sizeof(gii_cmddata_getdevinfo); _giiEventBlank(&ev, size); ev.any.size = size; ev.any.type = evCommand; ev.any.origin = priv->origin[devtype]; ev.cmd.code = GII_CMDCODE_GETDEVINFO; dinfo = (gii_cmddata_getdevinfo *) ev.cmd.data; switch (devtype) { case QZ_DEV_MOUSE: *dinfo = mouse_devinfo; break; case QZ_DEV_KEY: *dinfo = key_devinfo; break; default: return GGI_EEVNOTARGET; } return _giiEvQueueAdd(inp, &ev); } /* send_devinfo */
static int GII_quartz_send_event(gii_input *inp, gii_event *ev) { quartz_priv *priv = QUARTZ_PRIV(inp); if ((ev->any.target & 0xffffff00) != inp->origin && ev->any.target != GII_EV_TARGET_ALL) { /* not for us */ return GGI_EEVNOTARGET; } if (ev->any.type != evCommand) { return GGI_EEVUNKNOWN; } switch (ev->cmd.code) { case GII_CMDCODE_GETDEVINFO: if (ev->any.target == GII_EV_TARGET_ALL) { send_devinfo(inp, QZ_DEV_KEY); send_devinfo(inp, QZ_DEV_MOUSE); return GGI_OK; } else { if (ev->any.target == priv->origin[QZ_DEV_KEY]) { send_devinfo(inp, QZ_DEV_KEY); return GGI_OK; } if (ev->any.target == priv->origin[QZ_DEV_MOUSE]) { send_devinfo(inp, QZ_DEV_MOUSE); return GGI_OK; } return GGI_EEVNOTARGET; } break; case GII_CMDCODE_QZSETPARAM: do { int err = GGI_OK; gii_quartz_cmddata_setparam data; /* Assure aligned memory access. */ memcpy(&data, (gii_quartz_cmddata_setparam *)ev->cmd.data, sizeof(gii_quartz_cmddata_setparam)); if (data.flags & GII_QZFLAG_UPDATE_WINDOW) { priv->theWindow = data.theWindow; err = update_winparam(inp); } else if (data.flags & GII_QZFLAG_UPDATE_RESIZEFUNC) { priv->resizefunc = data.resizefunc; } return err; } while(0); break; default: break; } return GGI_EEVUNKNOWN; } /* GII_quartz_send_event */
int GGI_quartz_setgamma(struct ggi_visual *vis,double r,double g,double b) { ggi_quartz_priv *priv; const CGGammaValue min = 0.0f, max = 1.0f; priv = QUARTZ_PRIV(vis); if (r == 0.0) { r = FLT_MAX; } else { r = 1.0f / r; } /* if */ if (g == 0.0) { g = FLT_MAX; } else { g = 1.0 / g; } /* if */ if (b == 0.0) { b = FLT_MAX; } else { b = 1.0 / b; } /* if */ if ( CGDisplayNoErr == CGSetDisplayTransferByFormula (priv->display_id, min, max, (CGGammaValue)r, min, max, (CGGammaValue)g, min, max, (CGGammaValue)b) ) { return 0; } else { return -1; } /* if */ } /* GGI_quartz_setgamma */
static int GII_quartz_close(gii_input *inp) { quartz_priv *priv = QUARTZ_PRIV(inp); QuartzExit(priv); free(priv); DPRINT_LIBS("exit ok.\n"); return 0; } /* GII_quartz_close */
int GGI_quartz_setgammamap(struct ggi_visual *vis, int start, int len, const ggi_color *colormap) { int i; ggi_quartz_priv *priv; /* Note: If the compiler breaks here, * then it is not ANSI C99 conform. */ const CGTableCount tableSize = len; CGGammaValue redTable[tableSize]; CGGammaValue greenTable[tableSize]; CGGammaValue blueTable[tableSize]; priv = QUARTZ_PRIV(vis); if (colormap == NULL) return GGI_EARGINVAL; if (start < 0 || start >= vis->gamma->len) return GGI_ENOSPACE; if (len > (vis->gamma->len - start)) return GGI_ENOSPACE; /* Extract gamma values into separate tables, * convert to floats between 0.0 and 1.0 */ #if 0 i = 0; do { if ((start + i) < priv->gamma.maxwrite_r) { priv->gammamap[start + i].red = colormap[i].r; } /* if */ if ((start + i) < priv->gamma.maxwrite_g) { priv->gammamap[start + i].green = colormap[i].g; } /* if */ if ((start + i) < priv->gamma.maxwrite_b) { priv->gammamap[start + i].blue = colormap[i].b; } /* if */ } while (i++ < len); #endif i = 0; do { redTable[i] = (uint16_t)(colormap[i].r / 65535.0); greenTable[i] = (uint16_t)(colormap[i].g / 65535.0); blueTable[i] = (uint16_t)(colormap[i].b / 65535.0); } while (i++ < len); if ( CGDisplayNoErr != CGSetDisplayTransferByTable (priv->display_id, tableSize, redTable, greenTable, blueTable) ) { return -1; } /* if */ return 0; } /* GGI_quartz_setgammamap */
int GGI_quartz_getgamma(struct ggi_visual *vis,double *r,double *g,double *b) { ggi_quartz_priv *priv; CGGammaValue dummy; priv = QUARTZ_PRIV(vis); if ( CGDisplayNoErr != CGGetDisplayTransferByFormula (priv->display_id, &dummy, &dummy, (CGGammaValue *)r, &dummy, &dummy, (CGGammaValue *)g, &dummy, &dummy, (CGGammaValue *)b) ) { return GGI_ENOMATCH; } /* if */ return 0; } /* GGI_quartz_getgamma */
int GGI_quartz_setpalvec(struct ggi_visual *vis,int start,int len,const ggi_color *colormap) { CGTableCount i; CGDeviceColor color; ggi_quartz_priv *priv; priv = QUARTZ_PRIV(vis); DPRINT("quartz setpalette.\n"); if (start == GGI_PALETTE_DONTCARE) { if (len > priv->ncols) { return GGI_ENOSPACE; } /* if */ start = priv->ncols - len; } /* if */ if (start+len > priv->ncols || start < 0) return GGI_ENOSPACE; memcpy(LIBGGI_PAL(vis)->clut.data+start, colormap, len*sizeof(ggi_color)); for (i = (unsigned)start; i < (unsigned)start+len; i++) { /* Clamp colors between 0.0 and 1.0 */ color.red = (uint16_t)(colormap->r / 65535.0); color.green = (uint16_t)(colormap->g / 65535.0); color.blue = (uint16_t)(colormap->b / 65535.0); colormap++; CGPaletteSetColorAtIndex (priv->palette, color, i); } /* for */ if ( CGDisplayNoErr != CGDisplaySetPalette (priv->display_id, priv->palette) ) return 0; return 0; } /* GGI_quartz_setpalvec */
int GGI_quartz_getgammamap(struct ggi_visual *vis, int start, int len, ggi_color *colormap) { ggi_quartz_priv *priv = QUARTZ_PRIV(vis); /* Note: If the compiler breaks here, * then it is not ANSI C99 conform. */ const CGTableCount tableSize = vis->gamma->len; CGGammaValue redTable[tableSize]; CGGammaValue greenTable[tableSize]; CGGammaValue blueTable[tableSize]; CGTableCount actualSize; int i; if (colormap==NULL) return GGI_EARGINVAL; if (start < 0 || start >= vis->gamma->len) return GGI_ENOSPACE; if (len > (vis->gamma->len - start)) return GGI_ENOSPACE; if ( CGDisplayNoErr != CGGetDisplayTransferByTable (priv->display_id, tableSize, redTable, greenTable, blueTable, &actualSize)) { return -1; } /* if */ if ((unsigned)len < actualSize) len = actualSize; if (len < start) return GGI_ENOSPACE; /* Pack tables into one array, with values from 0 to 65535 */ i = 0; do { colormap[i].r = redTable[start + i] * 65535.0; colormap[i].g = greenTable[start + i] * 65535.0; colormap[i].b = blueTable[start + i] * 65535.0; } while (i++ < len); return 0; } /* GGI_quartz_getgammamap */
static Bool QuartzRandRRegisterMode(ScreenPtr pScreen, QuartzModeInfoPtr pMode) { QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen); Bool isCurrentMode = QuartzRandRModesEqual(&pQuartzScreen->currentMode, pMode); /* TODO: DPI */ pMode->pSize = RRRegisterSize(pScreen, pMode->width, pMode->height, pScreen->mmWidth, pScreen->mmHeight); if (pMode->pSize) { //DEBUG_LOG("registering: %d x %d @ %d %s\n", (int)pMode->width, (int)pMode->height, (int)pMode->refresh, isCurrentMode ? "*" : ""); RRRegisterRate(pScreen, pMode->pSize, pMode->refresh); if (isCurrentMode) RRSetCurrentConfig(pScreen, RR_Rotate_0, pMode->refresh, pMode->pSize); return TRUE; } return FALSE; }
static Bool QuartzRandREnumerateModes(ScreenPtr pScreen, QuartzModeCallback callback, void *data) { Bool retval = FALSE; QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen); /* Just an 800x600 fallback if we have no attached heads */ if (pQuartzScreen->displayIDs) { CGDisplayModeRef curModeRef, modeRef; CFStringRef curPixelEnc, pixelEnc; CFComparisonResult pixelEncEqual; CFArrayRef modes; QuartzModeInfo modeInfo; int i; CGDirectDisplayID screenId = pQuartzScreen->displayIDs[0]; curModeRef = CGDisplayCopyDisplayMode(screenId); if (!curModeRef) return FALSE; curPixelEnc = CGDisplayModeCopyPixelEncoding(curModeRef); CGDisplayModeRelease(curModeRef); modes = CGDisplayCopyAllDisplayModes(screenId, NULL); if (!modes) { CFRelease(curPixelEnc); return FALSE; } for (i = 0; i < CFArrayGetCount(modes); i++) { int cb; modeRef = (CGDisplayModeRef)CFArrayGetValueAtIndex(modes, i); /* Skip modes that are not usable on the current display or have a different pixel encoding than the current mode. */ if ((CGDisplayModeGetIOFlags(modeRef) & kDisplayModeUsableFlags) != kDisplayModeUsableFlags) continue; pixelEnc = CGDisplayModeCopyPixelEncoding(modeRef); pixelEncEqual = CFStringCompare(pixelEnc, curPixelEnc, 0); CFRelease(pixelEnc); if (pixelEncEqual != kCFCompareEqualTo) continue; QuartzRandRGetModeInfo(modeRef, &modeInfo); modeInfo.ref = modeRef; cb = callback(pScreen, &modeInfo, data); if (cb == CALLBACK_CONTINUE) { retval = TRUE; } else if (cb == CALLBACK_SUCCESS) { CFRelease(modes); CFRelease(curPixelEnc); return TRUE; } else if (cb == CALLBACK_ERROR) { CFRelease(modes); CFRelease(curPixelEnc); return FALSE; } } CFRelease(modes); CFRelease(curPixelEnc); } switch (callback(pScreen, &pQuartzScreen->rootlessMode, data)) { case CALLBACK_SUCCESS: return TRUE; case CALLBACK_ERROR: return FALSE; case CALLBACK_CONTINUE: retval = TRUE; default: break; } switch (callback(pScreen, &pQuartzScreen->fullscreenMode, data)) { case CALLBACK_SUCCESS: return TRUE; case CALLBACK_ERROR: return FALSE; case CALLBACK_CONTINUE: retval = TRUE; default: break; } return retval; }
static Bool QuartzRandREnumerateModes(ScreenPtr pScreen, QuartzModeCallback callback, void *data) { Bool retval = FALSE; QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen); /* Just an 800x600 fallback if we have no attached heads */ if (pQuartzScreen->displayIDs) { CFDictionaryRef curModeRef, modeRef; long curBpp; CFArrayRef modes; QuartzModeInfo modeInfo; int i; CGDirectDisplayID screenId = pQuartzScreen->displayIDs[0]; curModeRef = CGDisplayCurrentMode(screenId); if (!curModeRef) return FALSE; curBpp = getDictLong(curModeRef, kCGDisplayBitsPerPixel); modes = CGDisplayAvailableModes(screenId); if (!modes) return FALSE; for (i = 0; i < CFArrayGetCount(modes); i++) { int cb; modeRef = (CFDictionaryRef)CFArrayGetValueAtIndex(modes, i); /* Skip modes that are not usable on the current display or have a different pixel encoding than the current mode. */ if (((unsigned long)getDictLong(modeRef, kCGDisplayIOFlags) & kDisplayModeUsableFlags) != kDisplayModeUsableFlags) continue; if (getDictLong(modeRef, kCGDisplayBitsPerPixel) != curBpp) continue; QuartzRandRGetModeInfo(modeRef, &modeInfo); modeInfo.ref = (void *)modeRef; cb = callback(pScreen, &modeInfo, data); if (cb == CALLBACK_CONTINUE) retval = TRUE; else if (cb == CALLBACK_SUCCESS) return TRUE; else if (cb == CALLBACK_ERROR) return FALSE; } } switch (callback(pScreen, &pQuartzScreen->rootlessMode, data)) { case CALLBACK_SUCCESS: return TRUE; case CALLBACK_ERROR: return FALSE; case CALLBACK_CONTINUE: retval = TRUE; default: break; } switch (callback(pScreen, &pQuartzScreen->fullscreenMode, data)) { case CALLBACK_SUCCESS: return TRUE; case CALLBACK_ERROR: return FALSE; case CALLBACK_CONTINUE: retval = TRUE; default: break; } return retval; }
OSStatus DefaultApplicationEventHandler(EventHandlerCallRef nextHandler, EventRef event, void *userData) { OSStatus result = noErr; uint32_t eventClass = GetEventClass(event); uint32_t eventKind = GetEventKind(event); gii_input *inp = (gii_input *)userData; quartz_priv *priv = QUARTZ_PRIV(inp); gii_event ev; static int ignore_mouse = 0; result = CallNextEventHandler(nextHandler, event); switch (eventClass) { case kEventClassMouse: switch (eventKind) { case kEventMouseDown: do { EventMouseButton button; if (ignore_mouse) break; DPRINT("Received kEventClassMouse::kEventMouseDown\n"); GetEventParameter(event, kEventParamMouseButton, typeMouseButton, 0, sizeof(EventMouseButton), 0, &button); DPRINT("Pressed mouse button: %i\n", button); _giiEventBlank(&ev, sizeof(gii_pbutton_event)); ev.any.size = sizeof(gii_pbutton_event); ev.any.type = evPtrButtonPress; ev.any.origin = priv->origin[QZ_DEV_MOUSE]; ev.pbutton.button = button; _giiEvQueueAdd(inp, &ev); } while (0); break; case kEventMouseUp: do { EventMouseButton button; if (ignore_mouse) break; DPRINT("Received kEventClassMouse::kEventMouseUp\n"); GetEventParameter(event, kEventParamMouseButton, typeMouseButton, 0, sizeof(EventMouseButton), 0, &button); DPRINT("Released mouse button: %i\n", button); _giiEventBlank(&ev, sizeof(gii_pbutton_event)); ev.any.size = sizeof(gii_pbutton_event); ev.any.type = evPtrButtonRelease; ev.any.origin = priv->origin[QZ_DEV_MOUSE]; ev.pbutton.button = button; _giiEvQueueAdd(inp, &ev); } while (0); break; case kEventMouseDragged: do { HIPoint mouse_delta; Point mouse_pos; HIPoint mouse_winpos; EventMouseButton button; DPRINT("Received kEventClassMouse::kEventMouseDragged\n"); GetEventParameter(event, kEventParamMouseLocation, typeQDPoint, 0, sizeof(Point), 0, &mouse_pos); GetEventParameter(event, kEventParamWindowMouseLocation, typeHIPoint, 0, sizeof(HIPoint), 0, &mouse_winpos); GetEventParameter(event, kEventParamMouseDelta, typeHIPoint, 0, sizeof(HIPoint), 0, &mouse_delta); GetEventParameter(event, kEventParamMouseButton, typeMouseButton, 0, sizeof(EventMouseButton), 0, &button); DPRINT("Mouse position: %i,%i\n", mouse_pos.h, mouse_pos.v); DPRINT("Mouse win position: %f,%f\n", mouse_winpos.x, mouse_winpos.y); DPRINT("Mouse delta: %f,%f\n", mouse_delta.x, mouse_delta.y); DPRINT("Released mouse button: %i\n", button); _giiEventBlank(&ev, sizeof(gii_pmove_event)); ev.any.size = sizeof(gii_pmove_event); ev.any.origin = priv->origin[QZ_DEV_MOUSE]; #if 0 ev.any.type = evPtrRelative; ev.pmove.x = (int)mouse_delta.x; ev.pmove.y = (int)mouse_delta.y; #else ev.any.type = evPtrAbsolute; ev.pmove.x = (int)mouse_winpos.x; ev.pmove.y = (int)mouse_winpos.y; #endif _giiEvQueueAdd(inp, &ev); _giiEventBlank(&ev, sizeof(gii_pbutton_event)); ev.any.size = sizeof(gii_pbutton_event); ev.any.type = evPtrButtonRelease; ev.any.origin = priv->origin[QZ_DEV_MOUSE]; ev.pbutton.button = button; _giiEvQueueAdd(inp, &ev); } while (0); break; case kEventMouseMoved: do { HIPoint mouse_delta; Point mouse_pos; HIPoint mouse_winpos; if (ignore_mouse) break; DPRINT("Received kEventClassMouse::kEventMouseMoved\n"); GetEventParameter(event, kEventParamMouseLocation, typeQDPoint, 0, sizeof(Point), 0, &mouse_pos); GetEventParameter(event, kEventParamWindowMouseLocation, typeHIPoint, 0, sizeof(HIPoint), 0, &mouse_winpos); GetEventParameter(event, kEventParamMouseDelta, typeHIPoint, 0, sizeof(HIPoint), 0, &mouse_delta); DPRINT("Mouse position: %i,%i\n", mouse_pos.h, mouse_pos.v); DPRINT("Mouse win position: %f,%f\n", mouse_winpos.x, mouse_winpos.y); DPRINT("Mouse delta: %f,%f\n", mouse_delta.x, mouse_delta.y); _giiEventBlank(&ev, sizeof(gii_pmove_event)); ev.any.size = sizeof(gii_pmove_event); ev.any.origin = priv->origin[QZ_DEV_MOUSE]; #if 0 ev.any.type = evPtrRelative; ev.pmove.x = (int)mouse_delta.x; ev.pmove.y = (int)mouse_delta.y; #else ev.any.type = evPtrAbsolute; ev.pmove.x = (int)mouse_winpos.x; ev.pmove.y = (int)mouse_winpos.y; #endif _giiEvQueueAdd(inp, &ev); } while (0); break; case kEventMouseEntered: do { Point mouse_pos; HIPoint mouse_winpos; ignore_mouse = 0; DPRINT("Received kEventClassMouse::kEventMouseEntered\n"); GetEventParameter(event, kEventParamMouseLocation, typeQDPoint, 0, sizeof(Point), 0, &mouse_pos); GetEventParameter(event, kEventParamWindowMouseLocation, typeHIPoint, 0, sizeof(HIPoint), 0, &mouse_winpos); DPRINT("Mouse position: %i,%i\n", mouse_pos.h, mouse_pos.v); DPRINT("Mouse win position: %f,%f\n", mouse_winpos.x, mouse_winpos.y); _giiEventBlank(&ev, sizeof(gii_pmove_event)); ev.any.size = sizeof(gii_pmove_event); ev.any.origin = priv->origin[QZ_DEV_MOUSE]; ev.any.type = evPtrAbsolute; ev.pmove.x = (int)mouse_winpos.x; ev.pmove.y = (int)mouse_winpos.y; _giiEvQueueAdd(inp, &ev); } while (0); break; case kEventMouseExited: DPRINT("Received kEventClassMouse::kEventMouseExited\n"); ignore_mouse = 1; break; case kEventMouseWheelMoved: do { int32_t wheel; EventMouseWheelAxis wheel_axis; if (ignore_mouse) break; DPRINT("Received kEventClassMouse::kEventMouseWheelMoved\n"); GetEventParameter(event, kEventParamMouseWheelDelta, typeSInt32, 0, sizeof(int), 0, &wheel); GetEventParameter(event, kEventParamMouseWheelAxis, kEventParamTabletPointRec, 0, sizeof(EventMouseWheelAxis), 0, &wheel_axis); DPRINT("Wheel moved: %i\n", wheel); _giiEventBlank(&ev, sizeof(gii_pmove_event)); ev.any.size = sizeof(gii_pmove_event); ev.any.type = evPtrRelative; ev.any.origin = priv->origin[QZ_DEV_MOUSE]; ev.pmove.wheel = wheel; _giiEvQueueAdd(inp, &ev); } while (0); break; default: DPRINT("Received unknown event kind of kEventClassMouse: %i\n", eventKind); if (ignore_mouse) break; result = eventNotHandledErr; return result; } break; case kEventClassKeyboard: do { char macCharCodes; uint32_t macKeyCode; uint32_t macKeyModifiers; GetEventParameter(event, kEventParamKeyMacCharCodes, typeChar, NULL, sizeof(macCharCodes), NULL, &macCharCodes); GetEventParameter(event, kEventParamKeyCode, typeUInt32, NULL, sizeof(macKeyCode), NULL, &macKeyCode); GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(macKeyModifiers), NULL, &macKeyModifiers); _giiEventBlank(&ev, sizeof(gii_key_event)); ev.any.size = sizeof(gii_key_event); ev.any.origin = priv->origin[QZ_DEV_KEY]; ev.key.modifiers = priv->modifiers; switch (eventKind) { case kEventRawKeyDown: DPRINT("Received kEventClassKeyboard::kEventRawKeyDown\n"); ev.any.type = evKeyPress; transKeyQuartz2GII(&ev, macKeyCode, macCharCodes, priv->modifiers); _giiEvQueueAdd(inp, &ev); break; case kEventRawKeyUp: DPRINT("Received kEventClassKeyboard::kEventRawKeyUp\n"); ev.any.type = evKeyRelease; transKeyQuartz2GII(&ev, macKeyCode, macCharCodes, priv->modifiers); _giiEvQueueAdd(inp, &ev); break; case kEventRawKeyRepeat: DPRINT("Received kEventClassKeyboard::kEventRawKeyRepeat\n"); ev.any.type = evKeyRepeat; transKeyQuartz2GII(&ev, macKeyCode, macCharCodes, priv->modifiers); _giiEvQueueAdd(inp, &ev); break; case kEventRawKeyModifiersChanged: DPRINT("Received kEventClassKeyboard::kEventRawKeyModifiersChanged\n"); if (macKeyModifiers & kEventKeyModifierNumLockBit) { priv->modifiers |= GII_MOD_NUM; } else { priv->modifiers |= ~GII_MOD_NUM; } #if 0 if (macKeyModifiers & kEventKeyModifierFnBit) { priv->modifiers |= GII_MOD_FN; } else { priv->modifiers |= ~GII_MOD_FN; } #endif if (macKeyModifiers & cmdKeyBit) { priv->modifiers |= GII_MOD_META; } else { priv->modifiers |= ~GII_MOD_META; } if ((macKeyModifiers & shiftKeyBit) || (macKeyModifiers & rightShiftKeyBit)) { priv->modifiers |= GII_MOD_SHIFT; } else { priv->modifiers |= ~GII_MOD_SHIFT; } if (macKeyModifiers & alphaLockBit) { priv->modifiers |= GII_MOD_CAPS; } else { priv->modifiers |= ~GII_MOD_CAPS; } if ((macKeyModifiers & optionKeyBit) || (macKeyModifiers & rightOptionKeyBit)) { priv->modifiers |= GII_MOD_ALT; } else { priv->modifiers |= ~GII_MOD_ALT; } if ((macKeyModifiers & controlKeyBit) || (macKeyModifiers & rightControlKeyBit)) { priv->modifiers |= GII_MOD_CTRL; } else { priv->modifiers |= ~GII_MOD_CTRL; } break; default: DPRINT("Received unknown event kind of kEventClassKeyboard: %i\n", eventKind); result = eventNotHandledErr; return result; } } while(0); break; default: DPRINT("Received unknown event class: %c%c%c%c\n", eventClass>>24,eventClass>>16,eventClass>>8,eventClass&0xff); result = eventNotHandledErr; break; } return result; } /* DefaultApplicationEventHandler */
OSStatus DefaultWindowEventHandler(EventHandlerCallRef nextHandler, EventRef event, void *userData) { OSStatus result = noErr; uint32_t eventClass = GetEventClass(event); uint32_t eventKind = GetEventKind(event); gii_input *inp = (gii_input *)userData; quartz_priv *priv = QUARTZ_PRIV(inp); result = CallNextEventHandler(nextHandler, event); switch (eventClass) { case kEventClassWindow: switch (eventKind) { case kEventWindowClosed: do { WindowRef window; DPRINT("Received kEventClassWindow::kEventWindowClosed\n"); GetEventParameter(event, kEventParamDirectObject, typeWindowRef, NULL, sizeof(WindowRef), NULL, &window); } while (0); break; case kEventWindowBoundsChanging: case kEventWindowBoundsChanged: do { WindowRef window; Rect origRect, prevRect, curRect; DPRINT("Received kEventClassWindow::kEventWindowBoundsChanging\n"); if (priv->resizefunc == NULL) break; GetEventParameter(event, kEventParamDirectObject, typeWindowRef, NULL, sizeof(WindowRef), NULL, &window); GetEventParameter(event, kEventParamOriginalBounds, typeQDRectangle, NULL, sizeof(Rect), NULL, &origRect); GetEventParameter(event, kEventParamPreviousBounds, typeQDRectangle, NULL, sizeof(Rect), NULL, &prevRect); GetEventParameter(event, kEventParamCurrentBounds, typeQDRectangle, NULL, sizeof(Rect), NULL, &curRect); priv->resizefunc(window, origRect, prevRect, curRect); } while (0); break; default: DPRINT("Received unknown event kind of kEventClassWindow: %i\n", eventKind); result = eventNotHandledErr; break; } /* switch */ break; default: DPRINT("Received unknown event class: %c%c%c%c\n", eventClass>>24,eventClass>>16,eventClass>>8,eventClass&0xff); result = eventNotHandledErr; break; } /* switch */ return result; } /* DefaultWindowEventHandler */