void DoMoveSizeWindow(struct Window *targetwindow, LONG NewLeftEdge, LONG NewTopEdge, LONG NewWidth, LONG NewHeight, BOOL send_newsize, struct IntuitionBase *IntuitionBase) { struct IIHData *iihdata = (struct IIHData *)GetPrivIBase(IntuitionBase)->InputHandler->is_Data; //struct IntWindow *w = (struct IntWindow *)targetwindow; struct Layer *targetlayer = WLAYER(targetwindow)/*, *L*/; struct Requester *req; struct InputEvent *ie; LONG OldLeftEdge = targetwindow->LeftEdge; LONG OldTopEdge = targetwindow->TopEdge; LONG OldWidth = targetwindow->Width; LONG OldHeight = targetwindow->Height; LONG pos_dx, pos_dy, size_dx, size_dy; /* correct new window coords if necessary */ FixWindowCoords(targetwindow, &NewLeftEdge, &NewTopEdge, &NewWidth, &NewHeight,IntuitionBase); D(bug("DoMoveSizeWindow to %d,%d %d x %d\n", NewLeftEdge, NewTopEdge, NewWidth, NewHeight)); pos_dx = NewLeftEdge - OldLeftEdge; pos_dy = NewTopEdge - OldTopEdge; size_dx = NewWidth - OldWidth; size_dy = NewHeight - OldHeight; LOCK_REFRESH(targetwindow->WScreen); /* jDc: intuition 68k doesn't care about that */ // if (pos_dx || pos_dy || size_dx || size_dy) // { if (size_dx || size_dy) { WindowSizeWillChange(targetwindow, size_dx, size_dy, IntuitionBase); } targetwindow->LeftEdge += pos_dx; targetwindow->TopEdge += pos_dy; #ifndef __MORPHOS__ targetwindow->RelLeftEdge += pos_dx; targetwindow->RelTopEdge += pos_dy; #endif targetwindow->Width = NewWidth; targetwindow->Height = NewHeight; targetwindow->GZZWidth = targetwindow->Width - targetwindow->BorderLeft - targetwindow->BorderRight; targetwindow->GZZHeight = targetwindow->Height - targetwindow->BorderTop - targetwindow->BorderBottom; /* check for GZZ window */ if (BLAYER(targetwindow)) { /* move outer window first */ MoveSizeLayer(BLAYER(targetwindow), pos_dx, pos_dy, size_dx, size_dy); } MoveSizeLayer(targetlayer, pos_dx, pos_dy, size_dx, size_dy); for (req = targetwindow->FirstRequest; req; req = req->OlderRequest) { struct Layer *layer = req->ReqLayer; if (layer) { int dx, dy, dw, dh; int left, top, right, bottom; left = NewLeftEdge + req->LeftEdge; top = NewTopEdge + req->TopEdge; right = left + req->Width - 1; bottom = top + req->Height - 1; if (left > NewLeftEdge + NewWidth - 1) left = NewLeftEdge + NewWidth - 1; if (top > NewTopEdge + NewHeight - 1) top = NewTopEdge + NewHeight - 1; if (right > NewLeftEdge + NewWidth - 1) right = NewLeftEdge + NewWidth - 1; if (bottom > NewTopEdge + NewHeight - 1) bottom = NewTopEdge + NewHeight - 1; dx = left - layer->bounds.MinX; dy = top - layer->bounds.MinY; dw = right - left - layer->bounds.MaxX + layer->bounds.MinX; dh = bottom - top - layer->bounds.MaxY + layer->bounds.MinY; MoveSizeLayer(layer, dx, dy, dw, dh); } } #if 0 if (w->ZipLeftEdge != ~0) w->ZipLeftEdge = OldLeftEdge; if (w->ZipTopEdge != ~0) w->ZipTopEdge = OldTopEdge; if (w->ZipWidth != ~0) w->ZipWidth = OldWidth; if (w->ZipHeight != ~0) w->ZipHeight = OldHeight; #endif if (pos_dx || pos_dy) { UpdateMouseCoords(targetwindow); #ifndef __MORPHOS__ if (HAS_CHILDREN(targetwindow)) move_family(targetwindow, pos_dx, pos_dy); #endif } // } /* if (pos_dx || pos_dy || size_dx || size_dy) */ if (size_dx || size_dy) { WindowSizeHasChanged(targetwindow, size_dx, size_dy, FALSE, IntuitionBase); } ih_fire_intuimessage(targetwindow, IDCMP_CHANGEWINDOW, CWCODE_MOVESIZE, targetwindow, IntuitionBase); if (send_newsize) { /* Send IDCMP_NEWSIZE and IDCMP_CHANGEWINDOW to resized window, even if there was no resizing/position change at all. BGUI for example relies on this! */ ih_fire_intuimessage(targetwindow, IDCMP_NEWSIZE, 0, targetwindow, IntuitionBase); if ((ie = AllocInputEvent(iihdata))) { ie->ie_Class = IECLASS_EVENT; ie->ie_Code = IECODE_NEWSIZE; ie->ie_EventAddress = targetwindow; CurrentTime(&ie->ie_TimeStamp.tv_secs, &ie->ie_TimeStamp.tv_micro); } } // jDc: CheckLayers calls LOCK_REFRESH, so there's no reason to UNLOCK here! // UNLOCK_REFRESH(targetwindow->WScreen); CheckLayers(targetwindow->WScreen, IntuitionBase); UNLOCK_REFRESH(targetwindow->WScreen); #if 0 if (size_dx || size_dy) { if (!(((struct IntWindow *)targetwindow)->CustomShape)) { struct wdpWindowShape shapemsg; struct Region *shape; shapemsg.MethodID = WDM_WINDOWSHAPE; shapemsg.wdp_Width = targetwindow->Width; shapemsg.wdp_Height = targetwindow->Height; shapemsg.wdp_Window = targetwindow; shapemsg.wdp_TrueColor = (((struct IntScreen *)targetwindow->WScreen)->DInfo.dri.dri_Flags & DRIF_DIRECTCOLOR); shapemsg.wdp_UserBuffer = ((struct IntWindow *)targetwindow)->DecorUserBuffer; shape = DoMethodA(((struct IntScreen *)(targetwindow->WScreen))->WinDecorObj, (Msg)&shapemsg); if (((struct IntWindow *)targetwindow)->OutlineShape) DisposeRegion(((struct IntWindow *)targetwindow)->OutlineShape); ((struct IntWindow *)targetwindow)->OutlineShape = shape; ChangeWindowShape(targetwindow, shape, NULL); ((struct IntWindow *)targetwindow)->CustomShape = FALSE; } } #endif }
BOOL ih_fire_intuimessage(struct Window * w, ULONG Class, UWORD Code, APTR IAddress, struct IntuitionBase *IntuitionBase) { struct IIHData *iihd = (struct IIHData *)GetPrivIBase(IntuitionBase)->InputHandler->is_Data; struct InputEvent *ie/* = iihd->ActInputEvent*/; BOOL result; DEBUG_FIREINTUIMSG(dprintf("ih_fire_intuimessage: win 0x%lx class 0x%lx code 0x%lx IAddress 0x%lx\n", w, Class, Code, IAddress)); result = fire_message(w, Class, Code, IAddress, IntuitionBase); DEBUG_FIREINTUIMSG(dprintf("ih_fire_intuimessage: fire_intuimessage result 0x%lx\n", result)); if (result /*&& ie*/) { /* was sent as IDCMP to window so eat inputevent */ //ie->ie_Class = IECLASS_NULL; } #if 0 else if (ie/* && (ie->ie_Class != IECLASS_NULL) && !iihd->ActInputEventUsed*/) { /* ih_fire_intuimessage was called from inside Intuition's event handling loop */ //iihd->ActInputEventUsed = TRUE; ie->ie_SubClass = 0; ie->ie_Code = Code; //ie->ie_Qualifier = iihd->ActQualifier; ie->ie_EventAddress = IAddress; switch(Class) { case IDCMP_GADGETUP: /* Note: on the Amiga if a boopsi Gadget which is GA_Immediate and GA_RelVerify immediately in GM_GOACTIVE returns GMR_VERIFY, then this sends IDCMP_GADGETDOWN + IDCMP_GADGETUP. AROS does the same. But for changed inputevents (if window does not have this IDCMP Flags set) there will be only one IECLASS_GADGETDOWN */ ie->ie_Class = IECLASS_GADGETUP; break; case IDCMP_GADGETDOWN: ie->ie_Class = IECLASS_GADGETDOWN; break; case IDCMP_ACTIVEWINDOW: ie->ie_Class = IECLASS_ACTIVEWINDOW; break; case IDCMP_INACTIVEWINDOW: ie->ie_Class = IECLASS_INACTIVEWINDOW; break; case IDCMP_CLOSEWINDOW: ie->ie_Class = IECLASS_CLOSEWINDOW; break; case IDCMP_MENUHELP: ie->ie_Class = IECLASS_MENUHELP; break; case IDCMP_MENUPICK: ie->ie_Class = IECLASS_MENULIST; break; case IDCMP_MOUSEBUTTONS: case IDCMP_MOUSEMOVE: case IDCMP_RAWKEY: case IDCMP_VANILLAKEY: break; default: D(bug("ih_fireintuimessage: unexpected IDCMP (%x) for an inputevent-handling-fireintuimessage!\n", Class)); break; } } #endif else //if (!ie) { /* ih_fire_intuimessage was called from inside Intuition's defered action handling routines */ if ((ie = AllocInputEvent(iihd))) { switch(Class) { case IDCMP_NEWSIZE: ie->ie_Class = IECLASS_SIZEWINDOW; break; case IDCMP_CHANGEWINDOW: ie->ie_Class = IECLASS_CHANGEWINDOW; break; case IDCMP_ACTIVEWINDOW: ie->ie_Class = IECLASS_ACTIVEWINDOW; break; case IDCMP_INACTIVEWINDOW: ie->ie_Class = IECLASS_INACTIVEWINDOW; break; case IDCMP_CLOSEWINDOW: ie->ie_Class = IECLASS_CLOSEWINDOW; break; case IDCMP_GADGETUP: ie->ie_Class = IECLASS_GADGETUP; break; case IDCMP_GADGETDOWN: ie->ie_Class = IECLASS_GADGETDOWN; break; case IDCMP_REFRESHWINDOW: ie->ie_Class = IECLASS_REFRESHWINDOW; break; case IDCMP_MENUHELP: ie->ie_Class = IECLASS_MENUHELP; break; case IDCMP_MENUPICK: ie->ie_Class = IECLASS_MENULIST; break; default: D(bug("ih_fireintuimessage: unexpected IDCMP (0x%X) for a deferred-action-fireintuimessage!\n", Class)); break; } /* switch(Class) */ ie->ie_Code = Code; ie->ie_Qualifier = iihd->ActQualifier; ie->ie_EventAddress = IAddress; CurrentTime(&ie->ie_TimeStamp.tv_secs, &ie->ie_TimeStamp.tv_micro); D(bug("ih_fireintuimessage: generated InputEvent. Class = 0x%X Code = %d EventAddress = 0x%X\n", ie->ie_Class, ie->ie_Code, ie->ie_EventAddress)); } /* if ((ie = AllocInputEvent(iihd))) */ } DEBUG_FIREINTUIMSG(dprintf("ih_fire_intuimessage: result 0x%lx\n", result)); return result; }
void WindowSizeHasChanged(struct Window *targetwindow, WORD dx, WORD dy, BOOL is_sizewindow, struct IntuitionBase *IntuitionBase) { struct IIHData *iihdata = (struct IIHData *)GetPrivIBase(IntuitionBase)->InputHandler->is_Data; struct Layer *lay; D(bug("********* WindowSizeHasChanged ********\n")); lay = (BLAYER(targetwindow)) ? BLAYER(targetwindow) : WLAYER(targetwindow); /* Fix GadgetInfo domain if there is an active gadget in window which was resized */ if ((iihdata->ActiveGadget) && (targetwindow == iihdata->GadgetInfo.gi_Window)) { GetGadgetDomain(iihdata->ActiveGadget, iihdata->GadgetInfo.gi_Screen, iihdata->GadgetInfo.gi_Window, NULL, &iihdata->GadgetInfo.gi_Domain); } /* Relayout GFLG_REL??? gadgets */ DoGMLayout(targetwindow->FirstGadget, targetwindow, NULL, -1, FALSE, IntuitionBase); /* Add the new area of all GFLG_REL??? gadgets to the damagelist, but don't EraseRect() as the gadgets will be re-rendered at their new position anyway */ { struct Rectangle innerrect; innerrect.MinX = targetwindow->BorderLeft; innerrect.MinY = targetwindow->BorderTop; innerrect.MaxX = targetwindow->Width - 1 - targetwindow->BorderRight; innerrect.MaxY = targetwindow->Height - 1 - targetwindow->BorderBottom; EraseRelGadgetArea(targetwindow, AVOID_WINBORDERERASE ? &innerrect : NULL, TRUE, IntuitionBase); } /* If new size is smaller than old size add right/bottom frame to damagelist */ if ( ((dx < 0) && (targetwindow->BorderRight > 0)) || ((dx > 0) && (targetwindow->BorderTop > 0)) || ((dy < 0) && (targetwindow->BorderBottom > 0)) ) { struct Rectangle rect; LockLayer(0, lay); if ((dx < 0) && (targetwindow->BorderRight > 0)) { rect.MinX = targetwindow->Width - targetwindow->BorderRight; rect.MinY = 0; rect.MaxX = targetwindow->Width - 1; rect.MaxY = targetwindow->Height - 1; OrRectRegion(lay->DamageList, &rect); lay->Flags |= LAYERREFRESH; } if ((dx > 0) && (targetwindow->BorderTop > 0)) { rect.MinX = 0; rect.MinY = 0; rect.MaxX = targetwindow->Width - 1; rect.MaxY = targetwindow->BorderTop - 1; OrRectRegion(lay->DamageList, &rect); lay->Flags |= LAYERREFRESH; } if ((dy < 0) && (targetwindow->BorderBottom > 0)) { rect.MinX = 0; rect.MinY = targetwindow->Height - targetwindow->BorderBottom; rect.MaxX = targetwindow->Width - 1; rect.MaxY = targetwindow->Height - 1; OrRectRegion(lay->DamageList, &rect); lay->Flags |= LAYERREFRESH; } UnlockLayer(lay); } /* if ( ((dx < 0) && (targetwindow->BorderRight > 0)) || ((dy < 0) && (targetwindow->BorderBottom > 0)) ) */ ((struct IntWindow *)(targetwindow))->specialflags |= SPFLAG_LAYERRESIZED; #if 0 if (IS_GZZWINDOW(targetwindow)) { lay = targetwindow->BorderRPort->Layer; if (lay->Flags & LAYERREFRESH) { Gad_BeginUpdate(lay, IntuitionBase); RefreshWindowFrame(targetwindow); lay->Flags &= ~LAYERREFRESH; Gad_EndUpdate(lay, TRUE, IntuitionBase); } lay = targetwindow->WLayer; if (lay->Flags & LAYERREFRESH) { Gad_BeginUpdate(lay, IntuitionBase); int_refreshglist(targetwindow->FirstGadget, targetwindow, NULL, -1, 0, REFRESHGAD_BORDER, IntuitionBase); Gad_EndUpdate(lay, IS_NOCAREREFRESH(targetwindow), IntuitionBase); } } else { lay = targetwindow->WLayer; if (lay->Flags & LAYERREFRESH) { Gad_BeginUpdate(lay, IntuitionBase); RefreshWindowFrame(targetwindow); int_refreshglist(targetwindow->FirstGadget, targetwindow, NULL, -1, 0, REFRESHGAD_BORDER, IntuitionBase); Gad_EndUpdate(lay, IS_NOCAREREFRESH(targetwindow), IntuitionBase); } } lay = targetwindow->WLayer; if (IS_NOCAREREFRESH(targetwindow)) { LockLayer(0, lay); lay->Flags &= ~LAYERREFRESH; UnlockLayer(lay); } #endif #if 0 //if (is_sizewindow) { /* Send IDCMP_NEWSIZE to resized window */ ih_fire_intuimessage(targetwindow, IDCMP_NEWSIZE, 0, targetwindow, IntuitionBase); } if (ie = AllocInputEvent(iihdata)) { ie->ie_Class = IECLASS_EVENT; ie->ie_Code = IECODE_NEWSIZE; ie->ie_EventAddress = targetwindow; CurrentTime(&ie->ie_TimeStamp.tv_secs, &ie->ie_TimeStamp.tv_micro); } /* Send IDCMP_CHANGEWINDOW to resized window */ ih_fire_intuimessage(targetwindow, IDCMP_CHANGEWINDOW, CWCODE_MOVESIZE, targetwindow, IntuitionBase); #endif }